2010-05-18 08:04:22 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
#include "GLContextTypes.h"
|
2014-01-08 00:02:18 +04:00
|
|
|
#include <windows.h>
|
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
struct PRLibrary;
|
2010-05-18 08:04:22 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class WGLLibrary
|
|
|
|
{
|
|
|
|
public:
|
2015-10-08 23:36:58 +03:00
|
|
|
WGLLibrary()
|
2015-11-06 03:19:24 +03:00
|
|
|
: mInitialized(false)
|
|
|
|
, mOGLLibrary(nullptr)
|
|
|
|
, mHasRobustness(false)
|
|
|
|
, mHasDXInterop(false)
|
|
|
|
, mHasDXInterop2(false)
|
|
|
|
, mWindow (0)
|
|
|
|
, mWindowDC(0)
|
|
|
|
, mWindowGLContext(0)
|
|
|
|
, mWindowPixelFormat(0)
|
2012-06-02 20:05:45 +04:00
|
|
|
{}
|
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
typedef HGLRC (GLAPIENTRY * PFNWGLCREATECONTEXTPROC) (HDC);
|
|
|
|
PFNWGLCREATECONTEXTPROC fCreateContext;
|
|
|
|
typedef BOOL (GLAPIENTRY * PFNWGLDELETECONTEXTPROC) (HGLRC);
|
|
|
|
PFNWGLDELETECONTEXTPROC fDeleteContext;
|
|
|
|
typedef BOOL (GLAPIENTRY * PFNWGLMAKECURRENTPROC) (HDC, HGLRC);
|
|
|
|
PFNWGLMAKECURRENTPROC fMakeCurrent;
|
|
|
|
typedef PROC (GLAPIENTRY * PFNWGLGETPROCADDRESSPROC) (LPCSTR);
|
|
|
|
PFNWGLGETPROCADDRESSPROC fGetProcAddress;
|
|
|
|
typedef HGLRC (GLAPIENTRY * PFNWGLGETCURRENTCONTEXT) (void);
|
|
|
|
PFNWGLGETCURRENTCONTEXT fGetCurrentContext;
|
|
|
|
typedef HDC (GLAPIENTRY * PFNWGLGETCURRENTDC) (void);
|
|
|
|
PFNWGLGETCURRENTDC fGetCurrentDC;
|
2010-07-19 09:01:14 +04:00
|
|
|
typedef BOOL (GLAPIENTRY * PFNWGLSHARELISTS) (HGLRC oldContext, HGLRC newContext);
|
|
|
|
PFNWGLSHARELISTS fShareLists;
|
2010-05-18 08:04:22 +04:00
|
|
|
|
|
|
|
typedef HANDLE (WINAPI * PFNWGLCREATEPBUFFERPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);
|
|
|
|
PFNWGLCREATEPBUFFERPROC fCreatePbuffer;
|
|
|
|
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERPROC) (HANDLE hPbuffer);
|
|
|
|
PFNWGLDESTROYPBUFFERPROC fDestroyPbuffer;
|
|
|
|
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCPROC) (HANDLE hPbuffer);
|
|
|
|
PFNWGLGETPBUFFERDCPROC fGetPbufferDC;
|
|
|
|
|
|
|
|
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
|
|
|
|
PFNWGLBINDTEXIMAGEPROC fBindTexImage;
|
|
|
|
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
|
|
|
|
PFNWGLRELEASETEXIMAGEPROC fReleaseTexImage;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT* pfAttribFList, UINT nMaxFormats, int* piFormats, UINT* nNumFormats);
|
2010-05-18 08:04:22 +04:00
|
|
|
PFNWGLCHOOSEPIXELFORMATPROC fChoosePixelFormat;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int* piValues);
|
2010-05-18 08:04:22 +04:00
|
|
|
PFNWGLGETPIXELFORMATATTRIBIVPROC fGetPixelFormatAttribiv;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGPROC) (HDC hdc);
|
2011-12-03 11:50:11 +04:00
|
|
|
PFNWGLGETEXTENSIONSSTRINGPROC fGetExtensionsString;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSPROC) (HDC hdc, HGLRC hShareContext, const int* attribList);
|
2011-12-03 11:50:11 +04:00
|
|
|
PFNWGLCREATECONTEXTATTRIBSPROC fCreateContextAttribs;
|
|
|
|
|
2015-10-08 23:36:58 +03:00
|
|
|
// WGL_NV_DX_interop:
|
2016-06-11 04:37:07 +03:00
|
|
|
// BOOL wglDXSetResourceShareHandleNV(void* dxObject, HANDLE shareHandle);
|
2015-10-08 23:36:58 +03:00
|
|
|
typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLEPROC) (void* dxObject, HANDLE shareHandle);
|
|
|
|
PFNWGLDXSETRESOURCESHAREHANDLEPROC fDXSetResourceShareHandle;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
// HANDLE wglDXOpenDeviceNV(void* dxDevice);
|
2015-10-08 23:36:58 +03:00
|
|
|
typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICEPROC) (void* dxDevice);
|
|
|
|
PFNWGLDXOPENDEVICEPROC fDXOpenDevice;
|
|
|
|
|
|
|
|
// BOOL wglDXCloseDeviceNV(HANDLE hDevice);
|
|
|
|
typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICEPROC) (HANDLE hDevice);
|
|
|
|
PFNWGLDXCLOSEDEVICEPROC fDXCloseDevice;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
// HANDLE wglDXRegisterObjectNV(HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);
|
2015-10-08 23:36:58 +03:00
|
|
|
typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);
|
|
|
|
PFNWGLDXREGISTEROBJECTPROC fDXRegisterObject;
|
|
|
|
|
|
|
|
// BOOL wglDXUnregisterObjectNV(HANDLE hDevice, HANDLE hObject);
|
|
|
|
typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECT) (HANDLE hDevice, HANDLE hObject);
|
|
|
|
PFNWGLDXUNREGISTEROBJECT fDXUnregisterObject;
|
|
|
|
|
|
|
|
// BOOL wglDXObjectAccessNV(HANDLE hObject, GLenum access);
|
|
|
|
typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSPROC) (HANDLE hObject, GLenum access);
|
|
|
|
PFNWGLDXOBJECTACCESSPROC fDXObjectAccess;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
// BOOL wglDXLockObjectsNV(HANDLE hDevice, GLint count, HANDLE* hObjects);
|
2015-10-08 23:36:58 +03:00
|
|
|
typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);
|
|
|
|
PFNWGLDXLOCKOBJECTSPROC fDXLockObjects;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
// BOOL wglDXUnlockObjectsNV(HANDLE hDevice, GLint count, HANDLE* hObjects);
|
2015-10-08 23:36:58 +03:00
|
|
|
typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);
|
|
|
|
PFNWGLDXUNLOCKOBJECTSPROC fDXUnlockObjects;
|
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
bool EnsureInitialized();
|
2016-06-11 04:37:07 +03:00
|
|
|
HWND CreateDummyWindow(HDC* aWindowDC = nullptr);
|
2011-12-03 11:50:11 +04:00
|
|
|
|
2012-07-31 00:15:39 +04:00
|
|
|
bool HasRobustness() const { return mHasRobustness; }
|
2015-10-08 23:36:58 +03:00
|
|
|
bool HasDXInterop() const { return mHasDXInterop; }
|
|
|
|
bool HasDXInterop2() const { return mHasDXInterop2; }
|
2012-07-31 00:15:39 +04:00
|
|
|
bool IsInitialized() const { return mInitialized; }
|
|
|
|
HWND GetWindow() const { return mWindow; }
|
|
|
|
HDC GetWindowDC() const {return mWindowDC; }
|
|
|
|
HGLRC GetWindowGLContext() const {return mWindowGLContext; }
|
2012-06-02 20:05:45 +04:00
|
|
|
int GetWindowPixelFormat() const { return mWindowPixelFormat; }
|
2016-06-11 04:37:07 +03:00
|
|
|
PRLibrary* GetOGLLibrary() { return mOGLLibrary; }
|
2013-12-18 22:09:11 +04:00
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
private:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInitialized;
|
2016-06-11 04:37:07 +03:00
|
|
|
PRLibrary* mOGLLibrary;
|
2011-12-03 11:50:11 +04:00
|
|
|
bool mHasRobustness;
|
2015-10-08 23:36:58 +03:00
|
|
|
bool mHasDXInterop;
|
|
|
|
bool mHasDXInterop2;
|
2012-06-02 20:05:45 +04:00
|
|
|
|
|
|
|
HWND mWindow;
|
|
|
|
HDC mWindowDC;
|
|
|
|
HGLRC mWindowGLContext;
|
|
|
|
int mWindowPixelFormat;
|
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// a global WGLLibrary instance
|
2015-11-06 03:19:24 +03:00
|
|
|
extern WGLLibrary sWGLLib;
|
2010-05-18 08:04:22 +04:00
|
|
|
|
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|