Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / gfx / gl / WGLLibrary.h
blob82c764b3dba884656de7431fa9728561704666f1
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "GLContextTypes.h"
7 #include "GLLibraryLoader.h"
8 #include "mozilla/UniquePtr.h"
9 #include <windows.h>
11 struct PRLibrary;
13 namespace mozilla {
14 namespace gl {
16 struct ScopedDC
18 const HDC mDC;
20 ScopedDC() = delete;
21 virtual ~ScopedDC() = 0;
24 struct WindowDC final : public ScopedDC
26 const HWND mWindow;
28 WindowDC() = delete;
29 ~WindowDC();
32 struct PBufferDC final : public ScopedDC
34 const HWND mWindow;
36 PBufferDC() = delete;
37 ~PBufferDC();
40 class WGLLibrary {
41 public:
42 ~WGLLibrary() { Reset(); }
44 private:
45 void Reset();
47 public:
48 struct {
49 HGLRC(GLAPIENTRY* fCreateContext)(HDC);
50 BOOL(GLAPIENTRY* fDeleteContext)(HGLRC);
51 BOOL(GLAPIENTRY* fMakeCurrent)(HDC, HGLRC);
52 PROC(GLAPIENTRY* fGetProcAddress)(LPCSTR);
53 HGLRC(GLAPIENTRY* fGetCurrentContext)(void);
54 HDC(GLAPIENTRY* fGetCurrentDC)(void);
55 // BOOL (GLAPIENTRY * fShareLists) (HGLRC oldContext, HGLRC newContext);
56 HANDLE(GLAPIENTRY* fCreatePbuffer)
57 (HDC hDC, int iPixelFormat, int iWidth, int iHeight,
58 const int* piAttribList);
59 BOOL(GLAPIENTRY* fDestroyPbuffer)(HANDLE hPbuffer);
60 HDC(GLAPIENTRY* fGetPbufferDC)(HANDLE hPbuffer);
61 int(GLAPIENTRY* fReleasePbufferDC)(HANDLE hPbuffer, HDC dc);
62 // BOOL (GLAPIENTRY * fBindTexImage) (HANDLE hPbuffer, int iBuffer);
63 // BOOL (GLAPIENTRY * fReleaseTexImage) (HANDLE hPbuffer, int iBuffer);
64 BOOL(GLAPIENTRY* fChoosePixelFormat)
65 (HDC hdc, const int* piAttribIList, const FLOAT* pfAttribFList,
66 UINT nMaxFormats, int* piFormats, UINT* nNumFormats);
67 // BOOL (GLAPIENTRY * fGetPixelFormatAttribiv) (HDC hdc,
68 // int iPixelFormat,
69 // int iLayerPlane,
70 // UINT nAttributes,
71 // int* piAttributes,
72 // int* piValues);
73 const char*(GLAPIENTRY* fGetExtensionsStringARB)(HDC hdc);
74 HGLRC(GLAPIENTRY* fCreateContextAttribsARB)
75 (HDC hdc, HGLRC hShareContext, const int* attribList);
76 // WGL_NV_DX_interop:
77 BOOL(GLAPIENTRY* fDXSetResourceShareHandleNV)
78 (void* dxObject, HANDLE shareHandle);
79 HANDLE(GLAPIENTRY* fDXOpenDeviceNV)(void* dxDevice);
80 BOOL(GLAPIENTRY* fDXCloseDeviceNV)(HANDLE hDevice);
81 HANDLE(GLAPIENTRY* fDXRegisterObjectNV)
82 (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);
83 BOOL(GLAPIENTRY* fDXUnregisterObjectNV)(HANDLE hDevice, HANDLE hObject);
84 BOOL(GLAPIENTRY* fDXObjectAccessNV)(HANDLE hObject, GLenum access);
85 BOOL(GLAPIENTRY* fDXLockObjectsNV)
86 (HANDLE hDevice, GLint count, HANDLE* hObjects);
87 BOOL(GLAPIENTRY* fDXUnlockObjectsNV)
88 (HANDLE hDevice, GLint count, HANDLE* hObjects);
89 } mSymbols = {};
91 bool EnsureInitialized();
92 // UniquePtr<WindowDC> CreateDummyWindow();
93 HGLRC CreateContextWithFallback(HDC dc, bool tryRobustBuffers) const;
95 bool HasDXInterop2() const { return bool(mSymbols.fDXOpenDeviceNV); }
96 bool IsInitialized() const { return mInitialized; }
97 auto GetOGLLibrary() const { return mOGLLibrary; }
98 auto RootDc() const { return mRootDc; }
99 SymbolLoader GetSymbolLoader() const;
101 private:
102 bool mInitialized = false;
103 PRLibrary* mOGLLibrary;
104 bool mHasRobustness;
105 HWND mDummyWindow;
106 HDC mRootDc;
107 HGLRC mDummyGlrc;
110 // a global WGLLibrary instance
111 extern WGLLibrary sWGLLib;
113 } /* namespace gl */
114 } /* namespace mozilla */