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"
|
2018-01-03 05:30:15 +03:00
|
|
|
#include "mozilla/UniquePtr.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 {
|
2018-01-03 05:30:15 +03:00
|
|
|
/*
|
|
|
|
struct ScopedDC
|
|
|
|
{
|
|
|
|
const HDC mDC;
|
|
|
|
|
|
|
|
ScopedDC() = delete;
|
|
|
|
virtual ~ScopedDC() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WindowDC final : public ScopedDC
|
|
|
|
{
|
|
|
|
const HWND mWindow;
|
|
|
|
|
|
|
|
WindowDC() = delete;
|
|
|
|
~WindowDC();
|
|
|
|
};
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2018-01-03 05:30:15 +03:00
|
|
|
struct PBufferDC final : public ScopedDC
|
|
|
|
{
|
|
|
|
const HWND mWindow;
|
|
|
|
|
|
|
|
PBufferDC() = delete;
|
|
|
|
~PBufferDC();
|
|
|
|
};
|
|
|
|
*/
|
2010-05-18 08:04:22 +04:00
|
|
|
class WGLLibrary
|
|
|
|
{
|
|
|
|
public:
|
2015-10-08 23:36:58 +03:00
|
|
|
WGLLibrary()
|
2018-01-03 05:30:15 +03:00
|
|
|
: mSymbols{}
|
2017-03-04 03:49:49 +03:00
|
|
|
{ }
|
2012-06-02 20:05:45 +04:00
|
|
|
|
2018-01-03 05:30:15 +03:00
|
|
|
~WGLLibrary() {
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Reset();
|
|
|
|
|
2017-03-04 03:49:49 +03:00
|
|
|
public:
|
|
|
|
struct {
|
|
|
|
HGLRC (GLAPIENTRY * fCreateContext) (HDC);
|
|
|
|
BOOL (GLAPIENTRY * fDeleteContext) (HGLRC);
|
|
|
|
BOOL (GLAPIENTRY * fMakeCurrent) (HDC, HGLRC);
|
|
|
|
PROC (GLAPIENTRY * fGetProcAddress) (LPCSTR);
|
|
|
|
HGLRC (GLAPIENTRY * fGetCurrentContext) (void);
|
|
|
|
HDC (GLAPIENTRY * fGetCurrentDC) (void);
|
2018-01-03 05:30:15 +03:00
|
|
|
//BOOL (GLAPIENTRY * fShareLists) (HGLRC oldContext, HGLRC newContext);
|
2017-03-04 03:49:49 +03:00
|
|
|
HANDLE (GLAPIENTRY * fCreatePbuffer) (HDC hDC, int iPixelFormat, int iWidth,
|
|
|
|
int iHeight, const int* piAttribList);
|
|
|
|
BOOL (GLAPIENTRY * fDestroyPbuffer) (HANDLE hPbuffer);
|
|
|
|
HDC (GLAPIENTRY * fGetPbufferDC) (HANDLE hPbuffer);
|
2018-01-03 05:30:15 +03:00
|
|
|
int (GLAPIENTRY * fReleasePbufferDC) (HANDLE hPbuffer, HDC dc);
|
|
|
|
//BOOL (GLAPIENTRY * fBindTexImage) (HANDLE hPbuffer, int iBuffer);
|
|
|
|
//BOOL (GLAPIENTRY * fReleaseTexImage) (HANDLE hPbuffer, int iBuffer);
|
2017-03-04 03:49:49 +03:00
|
|
|
BOOL (GLAPIENTRY * fChoosePixelFormat) (HDC hdc, const int* piAttribIList,
|
|
|
|
const FLOAT* pfAttribFList,
|
|
|
|
UINT nMaxFormats, int* piFormats,
|
|
|
|
UINT* nNumFormats);
|
2018-01-03 05:30:15 +03:00
|
|
|
//BOOL (GLAPIENTRY * fGetPixelFormatAttribiv) (HDC hdc, int iPixelFormat,
|
|
|
|
// int iLayerPlane, UINT nAttributes,
|
|
|
|
// int* piAttributes, int* piValues);
|
2017-03-04 03:49:49 +03:00
|
|
|
const char* (GLAPIENTRY * fGetExtensionsStringARB) (HDC hdc);
|
|
|
|
HGLRC (GLAPIENTRY * fCreateContextAttribsARB) (HDC hdc, HGLRC hShareContext,
|
|
|
|
const int* attribList);
|
|
|
|
// WGL_NV_DX_interop:
|
|
|
|
BOOL (GLAPIENTRY * fDXSetResourceShareHandleNV) (void* dxObject,
|
|
|
|
HANDLE shareHandle);
|
|
|
|
HANDLE (GLAPIENTRY * fDXOpenDeviceNV) (void* dxDevice);
|
|
|
|
BOOL (GLAPIENTRY * fDXCloseDeviceNV) (HANDLE hDevice);
|
|
|
|
HANDLE (GLAPIENTRY * fDXRegisterObjectNV) (HANDLE hDevice, void* dxObject,
|
|
|
|
GLuint name, GLenum type,
|
|
|
|
GLenum access);
|
|
|
|
BOOL (GLAPIENTRY * fDXUnregisterObjectNV) (HANDLE hDevice, HANDLE hObject);
|
|
|
|
BOOL (GLAPIENTRY * fDXObjectAccessNV) (HANDLE hObject, GLenum access);
|
|
|
|
BOOL (GLAPIENTRY * fDXLockObjectsNV) (HANDLE hDevice, GLint count,
|
|
|
|
HANDLE* hObjects);
|
|
|
|
BOOL (GLAPIENTRY * fDXUnlockObjectsNV) (HANDLE hDevice, GLint count,
|
|
|
|
HANDLE* hObjects);
|
|
|
|
} mSymbols;
|
2015-10-08 23:36:58 +03:00
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
bool EnsureInitialized();
|
2018-01-03 05:30:15 +03:00
|
|
|
//UniquePtr<WindowDC> CreateDummyWindow();
|
|
|
|
HGLRC CreateContextWithFallback(HDC dc, bool tryRobustBuffers) const;
|
2011-12-03 11:50:11 +04:00
|
|
|
|
2017-03-04 03:49:49 +03:00
|
|
|
bool HasDXInterop2() const { return bool(mSymbols.fDXOpenDeviceNV); }
|
2012-07-31 00:15:39 +04:00
|
|
|
bool IsInitialized() const { return mInitialized; }
|
2018-01-03 05:30:15 +03:00
|
|
|
auto GetOGLLibrary() const { return mOGLLibrary; }
|
|
|
|
auto RootDc() const { return mRootDc; }
|
2013-12-18 22:09:11 +04:00
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
private:
|
2018-01-03 05:30:15 +03:00
|
|
|
bool mInitialized = false;
|
2016-06-11 04:37:07 +03:00
|
|
|
PRLibrary* mOGLLibrary;
|
2011-12-03 11:50:11 +04:00
|
|
|
bool mHasRobustness;
|
2018-01-03 05:30:15 +03:00
|
|
|
HWND mDummyWindow;
|
|
|
|
HDC mRootDc;
|
|
|
|
HGLRC mDummyGlrc;
|
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 */
|