Commit 665e4d97 by Geoff Lang Committed by Commit Bot

Perform all wglMakeCurrent calls from DisplayWGL.

Display WGL is the best place to track the currently bound surfaces and contexts and cache them appropriately. This results in a ~40% speed increase in the WebGL Aqarium demo because wglMakeCurrent is now only called once at initialization. BUG=angleproject:1651 Change-Id: I61132bb4a0db8de592600173c20787c67d18e067 Reviewed-on: https://chromium-review.googlesource.com/543583 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 579d8c7d
...@@ -215,12 +215,11 @@ D3DTextureSurfaceWGL::D3DTextureSurfaceWGL(const egl::SurfaceState &state, ...@@ -215,12 +215,11 @@ D3DTextureSurfaceWGL::D3DTextureSurfaceWGL(const egl::SurfaceState &state,
EGLenum buftype, EGLenum buftype,
EGLClientBuffer clientBuffer, EGLClientBuffer clientBuffer,
DisplayWGL *display, DisplayWGL *display,
HGLRC wglContext,
HDC deviceContext, HDC deviceContext,
ID3D11Device *displayD3D11Device, ID3D11Device *displayD3D11Device,
const FunctionsGL *functionsGL, const FunctionsGL *functionsGL,
const FunctionsWGL *functionsWGL) const FunctionsWGL *functionsWGL)
: SurfaceGL(state, renderer), : SurfaceWGL(state, renderer),
mBuftype(buftype), mBuftype(buftype),
mClientBuffer(clientBuffer), mClientBuffer(clientBuffer),
mRenderer(renderer), mRenderer(renderer),
...@@ -230,7 +229,6 @@ D3DTextureSurfaceWGL::D3DTextureSurfaceWGL(const egl::SurfaceState &state, ...@@ -230,7 +229,6 @@ D3DTextureSurfaceWGL::D3DTextureSurfaceWGL(const egl::SurfaceState &state,
mWorkarounds(renderer->getWorkarounds()), mWorkarounds(renderer->getWorkarounds()),
mFunctionsGL(functionsGL), mFunctionsGL(functionsGL),
mFunctionsWGL(functionsWGL), mFunctionsWGL(functionsWGL),
mWGLContext(wglContext),
mDeviceContext(deviceContext), mDeviceContext(deviceContext),
mWidth(0), mWidth(0),
mHeight(0), mHeight(0),
...@@ -341,12 +339,6 @@ egl::Error D3DTextureSurfaceWGL::initialize(const egl::Display *display) ...@@ -341,12 +339,6 @@ egl::Error D3DTextureSurfaceWGL::initialize(const egl::Display *display)
egl::Error D3DTextureSurfaceWGL::makeCurrent() egl::Error D3DTextureSurfaceWGL::makeCurrent()
{ {
if (!mFunctionsWGL->makeCurrent(mDeviceContext, mWGLContext))
{
// TODO(geofflang): What error type here?
return egl::EglContextLost() << "Failed to make the WGL context current.";
}
if (!mFunctionsWGL->dxLockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle)) if (!mFunctionsWGL->dxLockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle))
{ {
DWORD error = GetLastError(); DWORD error = GetLastError();
...@@ -476,4 +468,10 @@ FramebufferImpl *D3DTextureSurfaceWGL::createDefaultFramebuffer(const gl::Frameb ...@@ -476,4 +468,10 @@ FramebufferImpl *D3DTextureSurfaceWGL::createDefaultFramebuffer(const gl::Frameb
return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds, return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds,
mRenderer->getBlitter(), mStateManager); mRenderer->getBlitter(), mStateManager);
} }
HDC D3DTextureSurfaceWGL::getDC() const
{
return mDeviceContext;
}
} // namespace rx } // namespace rx
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#ifndef LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_ #ifndef LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_
#define LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_ #define LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h" #include "libANGLE/renderer/gl/wgl/SurfaceWGL.h"
#include <GL/wglext.h> #include <GL/wglext.h>
...@@ -22,7 +22,7 @@ class DisplayWGL; ...@@ -22,7 +22,7 @@ class DisplayWGL;
class StateManagerGL; class StateManagerGL;
struct WorkaroundsGL; struct WorkaroundsGL;
class D3DTextureSurfaceWGL : public SurfaceGL class D3DTextureSurfaceWGL : public SurfaceWGL
{ {
public: public:
D3DTextureSurfaceWGL(const egl::SurfaceState &state, D3DTextureSurfaceWGL(const egl::SurfaceState &state,
...@@ -30,7 +30,6 @@ class D3DTextureSurfaceWGL : public SurfaceGL ...@@ -30,7 +30,6 @@ class D3DTextureSurfaceWGL : public SurfaceGL
EGLenum buftype, EGLenum buftype,
EGLClientBuffer clientBuffer, EGLClientBuffer clientBuffer,
DisplayWGL *display, DisplayWGL *display,
HGLRC wglContext,
HDC deviceContext, HDC deviceContext,
ID3D11Device *displayD3D11Device, ID3D11Device *displayD3D11Device,
const FunctionsGL *functionsGL, const FunctionsGL *functionsGL,
...@@ -64,6 +63,8 @@ class D3DTextureSurfaceWGL : public SurfaceGL ...@@ -64,6 +63,8 @@ class D3DTextureSurfaceWGL : public SurfaceGL
FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override; FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override;
HDC getDC() const override;
private: private:
EGLenum mBuftype; EGLenum mBuftype;
EGLClientBuffer mClientBuffer; EGLClientBuffer mClientBuffer;
...@@ -78,7 +79,6 @@ class D3DTextureSurfaceWGL : public SurfaceGL ...@@ -78,7 +79,6 @@ class D3DTextureSurfaceWGL : public SurfaceGL
const FunctionsGL *mFunctionsGL; const FunctionsGL *mFunctionsGL;
const FunctionsWGL *mFunctionsWGL; const FunctionsWGL *mFunctionsWGL;
HGLRC mWGLContext;
HDC mDeviceContext; HDC mDeviceContext;
size_t mWidth; size_t mWidth;
......
...@@ -27,12 +27,11 @@ DXGISwapChainWindowSurfaceWGL::DXGISwapChainWindowSurfaceWGL(const egl::SurfaceS ...@@ -27,12 +27,11 @@ DXGISwapChainWindowSurfaceWGL::DXGISwapChainWindowSurfaceWGL(const egl::SurfaceS
EGLNativeWindowType window, EGLNativeWindowType window,
ID3D11Device *device, ID3D11Device *device,
HANDLE deviceHandle, HANDLE deviceHandle,
HGLRC wglContext,
HDC deviceContext, HDC deviceContext,
const FunctionsGL *functionsGL, const FunctionsGL *functionsGL,
const FunctionsWGL *functionsWGL, const FunctionsWGL *functionsWGL,
EGLint orientation) EGLint orientation)
: SurfaceGL(state, renderer), : SurfaceWGL(state, renderer),
mWindow(window), mWindow(window),
mStateManager(renderer->getStateManager()), mStateManager(renderer->getStateManager()),
mWorkarounds(renderer->getWorkarounds()), mWorkarounds(renderer->getWorkarounds()),
...@@ -42,7 +41,6 @@ DXGISwapChainWindowSurfaceWGL::DXGISwapChainWindowSurfaceWGL(const egl::SurfaceS ...@@ -42,7 +41,6 @@ DXGISwapChainWindowSurfaceWGL::DXGISwapChainWindowSurfaceWGL(const egl::SurfaceS
mDevice(device), mDevice(device),
mDeviceHandle(deviceHandle), mDeviceHandle(deviceHandle),
mWGLDevice(deviceContext), mWGLDevice(deviceContext),
mWGLContext(wglContext),
mSwapChainFormat(DXGI_FORMAT_UNKNOWN), mSwapChainFormat(DXGI_FORMAT_UNKNOWN),
mSwapChainFlags(0), mSwapChainFlags(0),
mDepthBufferFormat(GL_NONE), mDepthBufferFormat(GL_NONE),
...@@ -118,12 +116,6 @@ egl::Error DXGISwapChainWindowSurfaceWGL::initialize(const egl::Display *display ...@@ -118,12 +116,6 @@ egl::Error DXGISwapChainWindowSurfaceWGL::initialize(const egl::Display *display
egl::Error DXGISwapChainWindowSurfaceWGL::makeCurrent() egl::Error DXGISwapChainWindowSurfaceWGL::makeCurrent()
{ {
if (!mFunctionsWGL->makeCurrent(mWGLDevice, mWGLContext))
{
// TODO: What error type here?
return egl::EglContextLost() << "Failed to make the WGL context current.";
}
return egl::NoError(); return egl::NoError();
} }
...@@ -281,6 +273,11 @@ FramebufferImpl *DXGISwapChainWindowSurfaceWGL::createDefaultFramebuffer( ...@@ -281,6 +273,11 @@ FramebufferImpl *DXGISwapChainWindowSurfaceWGL::createDefaultFramebuffer(
mRenderer->getBlitter(), mStateManager); mRenderer->getBlitter(), mStateManager);
} }
HDC DXGISwapChainWindowSurfaceWGL::getDC() const
{
return mWGLDevice;
}
egl::Error DXGISwapChainWindowSurfaceWGL::setObjectsLocked(bool locked) egl::Error DXGISwapChainWindowSurfaceWGL::setObjectsLocked(bool locked)
{ {
if (mRenderbufferBufferHandle == nullptr) if (mRenderbufferBufferHandle == nullptr)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#ifndef LIBANGLE_RENDERER_GL_WGL_DXGISWAPCHAINSURFACEWGL_H_ #ifndef LIBANGLE_RENDERER_GL_WGL_DXGISWAPCHAINSURFACEWGL_H_
#define LIBANGLE_RENDERER_GL_WGL_DXGISWAPCHAINSURFACEWGL_H_ #define LIBANGLE_RENDERER_GL_WGL_DXGISWAPCHAINSURFACEWGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h" #include "libANGLE/renderer/gl/wgl/SurfaceWGL.h"
#include <GL/wglext.h> #include <GL/wglext.h>
...@@ -23,7 +23,7 @@ class DisplayWGL; ...@@ -23,7 +23,7 @@ class DisplayWGL;
class StateManagerGL; class StateManagerGL;
struct WorkaroundsGL; struct WorkaroundsGL;
class DXGISwapChainWindowSurfaceWGL : public SurfaceGL class DXGISwapChainWindowSurfaceWGL : public SurfaceWGL
{ {
public: public:
DXGISwapChainWindowSurfaceWGL(const egl::SurfaceState &state, DXGISwapChainWindowSurfaceWGL(const egl::SurfaceState &state,
...@@ -31,7 +31,6 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL ...@@ -31,7 +31,6 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL
EGLNativeWindowType window, EGLNativeWindowType window,
ID3D11Device *device, ID3D11Device *device,
HANDLE deviceHandle, HANDLE deviceHandle,
HGLRC wglContext,
HDC deviceContext, HDC deviceContext,
const FunctionsGL *functionsGL, const FunctionsGL *functionsGL,
const FunctionsWGL *functionsWGL, const FunctionsWGL *functionsWGL,
...@@ -60,6 +59,8 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL ...@@ -60,6 +59,8 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL
FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override; FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override;
HDC getDC() const override;
private: private:
egl::Error setObjectsLocked(bool locked); egl::Error setObjectsLocked(bool locked);
egl::Error checkForResize(); egl::Error checkForResize();
...@@ -78,7 +79,6 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL ...@@ -78,7 +79,6 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL
HANDLE mDeviceHandle; HANDLE mDeviceHandle;
HDC mWGLDevice; HDC mWGLDevice;
HGLRC mWGLContext;
DXGI_FORMAT mSwapChainFormat; DXGI_FORMAT mSwapChainFormat;
UINT mSwapChainFlags; UINT mSwapChainFlags;
......
...@@ -60,6 +60,7 @@ class FunctionsGLWindows : public FunctionsGL ...@@ -60,6 +60,7 @@ class FunctionsGLWindows : public FunctionsGL
DisplayWGL::DisplayWGL(const egl::DisplayState &state) DisplayWGL::DisplayWGL(const egl::DisplayState &state)
: DisplayGL(state), : DisplayGL(state),
mCurrentDC(nullptr),
mOpenGLModule(nullptr), mOpenGLModule(nullptr),
mFunctionsWGL(nullptr), mFunctionsWGL(nullptr),
mFunctionsGL(nullptr), mFunctionsGL(nullptr),
...@@ -270,6 +271,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display) ...@@ -270,6 +271,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
{ {
return egl::EglNotInitialized() << "Failed to make the intermediate WGL context current."; return egl::EglNotInitialized() << "Failed to make the intermediate WGL context current.";
} }
mCurrentDC = mDeviceContext;
mFunctionsGL = new FunctionsGLWindows(mOpenGLModule, mFunctionsWGL->getProcAddress); mFunctionsGL = new FunctionsGLWindows(mOpenGLModule, mFunctionsWGL->getProcAddress);
mFunctionsGL->initialize(); mFunctionsGL->initialize();
...@@ -331,6 +333,7 @@ void DisplayWGL::terminate() ...@@ -331,6 +333,7 @@ void DisplayWGL::terminate()
releaseD3DDevice(mD3D11DeviceHandle); releaseD3DDevice(mD3D11DeviceHandle);
mFunctionsWGL->makeCurrent(mDeviceContext, nullptr); mFunctionsWGL->makeCurrent(mDeviceContext, nullptr);
mCurrentDC = nullptr;
mFunctionsWGL->deleteContext(mWGLContext); mFunctionsWGL->deleteContext(mWGLContext);
mWGLContext = nullptr; mWGLContext = nullptr;
...@@ -380,13 +383,13 @@ SurfaceImpl *DisplayWGL::createWindowSurface(const egl::SurfaceState &state, ...@@ -380,13 +383,13 @@ SurfaceImpl *DisplayWGL::createWindowSurface(const egl::SurfaceState &state,
} }
return new DXGISwapChainWindowSurfaceWGL(state, getRenderer(), window, mD3D11Device, return new DXGISwapChainWindowSurfaceWGL(state, getRenderer(), window, mD3D11Device,
mD3D11DeviceHandle, mWGLContext, mDeviceContext, mD3D11DeviceHandle, mDeviceContext, mFunctionsGL,
mFunctionsGL, mFunctionsWGL, orientation); mFunctionsWGL, orientation);
} }
else else
{ {
return new WindowSurfaceWGL(state, getRenderer(), window, mPixelFormat, mWGLContext, return new WindowSurfaceWGL(state, getRenderer(), window, mPixelFormat, mFunctionsWGL,
mFunctionsWGL, orientation); orientation);
} }
} }
...@@ -400,7 +403,7 @@ SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::SurfaceState &state, ...@@ -400,7 +403,7 @@ SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::SurfaceState &state,
EGLenum textureTarget = static_cast<EGLenum>(attribs.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE)); EGLenum textureTarget = static_cast<EGLenum>(attribs.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE));
return new PbufferSurfaceWGL(state, getRenderer(), width, height, textureFormat, textureTarget, return new PbufferSurfaceWGL(state, getRenderer(), width, height, textureFormat, textureTarget,
largest, mPixelFormat, mDeviceContext, mWGLContext, mFunctionsWGL); largest, mPixelFormat, mDeviceContext, mFunctionsWGL);
} }
SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &state, SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
...@@ -414,7 +417,7 @@ SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState & ...@@ -414,7 +417,7 @@ SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &
return nullptr; return nullptr;
} }
return new D3DTextureSurfaceWGL(state, getRenderer(), buftype, clientBuffer, this, mWGLContext, return new D3DTextureSurfaceWGL(state, getRenderer(), buftype, clientBuffer, this,
mDeviceContext, mD3D11Device, mFunctionsGL, mFunctionsWGL); mDeviceContext, mD3D11Device, mFunctionsGL, mFunctionsWGL);
} }
...@@ -645,6 +648,28 @@ egl::Error DisplayWGL::waitNative(const gl::Context *context, EGLint engine) con ...@@ -645,6 +648,28 @@ egl::Error DisplayWGL::waitNative(const gl::Context *context, EGLint engine) con
return egl::NoError(); return egl::NoError();
} }
egl::Error DisplayWGL::makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context)
{
if (drawSurface)
{
SurfaceWGL *drawSurfaceWGL = GetImplAs<SurfaceWGL>(drawSurface);
HDC dc = drawSurfaceWGL->getDC();
if (dc != mCurrentDC)
{
if (!mFunctionsWGL->makeCurrent(dc, mWGLContext))
{
// TODO(geofflang): What error type here?
return egl::EglContextLost() << "Failed to make the WGL context current.";
}
mCurrentDC = dc;
}
}
return DisplayGL::makeCurrent(drawSurface, readSurface, context);
}
egl::Error DisplayWGL::registerD3DDevice(IUnknown *device, HANDLE *outHandle) egl::Error DisplayWGL::registerD3DDevice(IUnknown *device, HANDLE *outHandle)
{ {
ASSERT(device != nullptr); ASSERT(device != nullptr);
......
...@@ -59,6 +59,10 @@ class DisplayWGL : public DisplayGL ...@@ -59,6 +59,10 @@ class DisplayWGL : public DisplayGL
egl::Error waitClient(const gl::Context *context) const override; egl::Error waitClient(const gl::Context *context) const override;
egl::Error waitNative(const gl::Context *context, EGLint engine) const override; egl::Error waitNative(const gl::Context *context, EGLint engine) const override;
egl::Error makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context) override;
egl::Error registerD3DDevice(IUnknown *device, HANDLE *outHandle); egl::Error registerD3DDevice(IUnknown *device, HANDLE *outHandle);
void releaseD3DDevice(HANDLE handle); void releaseD3DDevice(HANDLE handle);
...@@ -75,6 +79,8 @@ class DisplayWGL : public DisplayGL ...@@ -75,6 +79,8 @@ class DisplayWGL : public DisplayGL
HGLRC initializeContextAttribs(const egl::AttributeMap &eglAttributes) const; HGLRC initializeContextAttribs(const egl::AttributeMap &eglAttributes) const;
HGLRC createContextAttribs(const gl::Version &version, int profileMask) const; HGLRC createContextAttribs(const gl::Version &version, int profileMask) const;
HDC mCurrentDC;
HMODULE mOpenGLModule; HMODULE mOpenGLModule;
FunctionsWGL *mFunctionsWGL; FunctionsWGL *mFunctionsWGL;
......
...@@ -25,16 +25,14 @@ PbufferSurfaceWGL::PbufferSurfaceWGL(const egl::SurfaceState &state, ...@@ -25,16 +25,14 @@ PbufferSurfaceWGL::PbufferSurfaceWGL(const egl::SurfaceState &state,
bool largest, bool largest,
int pixelFormat, int pixelFormat,
HDC deviceContext, HDC deviceContext,
HGLRC wglContext,
const FunctionsWGL *functions) const FunctionsWGL *functions)
: SurfaceGL(state, renderer), : SurfaceWGL(state, renderer),
mWidth(width), mWidth(width),
mHeight(height), mHeight(height),
mLargest(largest), mLargest(largest),
mTextureFormat(textureFormat), mTextureFormat(textureFormat),
mTextureTarget(textureTarget), mTextureTarget(textureTarget),
mPixelFormat(pixelFormat), mPixelFormat(pixelFormat),
mShareWGLContext(wglContext),
mParentDeviceContext(deviceContext), mParentDeviceContext(deviceContext),
mPbuffer(nullptr), mPbuffer(nullptr),
mPbufferDeviceContext(nullptr), mPbufferDeviceContext(nullptr),
...@@ -116,12 +114,6 @@ egl::Error PbufferSurfaceWGL::initialize(const egl::Display *display) ...@@ -116,12 +114,6 @@ egl::Error PbufferSurfaceWGL::initialize(const egl::Display *display)
egl::Error PbufferSurfaceWGL::makeCurrent() egl::Error PbufferSurfaceWGL::makeCurrent()
{ {
if (!mFunctionsWGL->makeCurrent(mPbufferDeviceContext, mShareWGLContext))
{
// TODO: What error type here?
return egl::EglContextLost() << "Failed to make the WGL context current.";
}
return egl::NoError(); return egl::NoError();
} }
...@@ -202,4 +194,8 @@ EGLint PbufferSurfaceWGL::getSwapBehavior() const ...@@ -202,4 +194,8 @@ EGLint PbufferSurfaceWGL::getSwapBehavior() const
return EGL_BUFFER_PRESERVED; return EGL_BUFFER_PRESERVED;
} }
HDC PbufferSurfaceWGL::getDC() const
{
return mPbufferDeviceContext;
}
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#ifndef LIBANGLE_RENDERER_GL_WGL_PBUFFERSURFACEWGL_H_ #ifndef LIBANGLE_RENDERER_GL_WGL_PBUFFERSURFACEWGL_H_
#define LIBANGLE_RENDERER_GL_WGL_PBUFFERSURFACEWGL_H_ #define LIBANGLE_RENDERER_GL_WGL_PBUFFERSURFACEWGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h" #include "libANGLE/renderer/gl/wgl/SurfaceWGL.h"
#include <GL/wglext.h> #include <GL/wglext.h>
...@@ -18,7 +18,7 @@ namespace rx ...@@ -18,7 +18,7 @@ namespace rx
class FunctionsWGL; class FunctionsWGL;
class PbufferSurfaceWGL : public SurfaceGL class PbufferSurfaceWGL : public SurfaceWGL
{ {
public: public:
PbufferSurfaceWGL(const egl::SurfaceState &state, PbufferSurfaceWGL(const egl::SurfaceState &state,
...@@ -30,7 +30,6 @@ class PbufferSurfaceWGL : public SurfaceGL ...@@ -30,7 +30,6 @@ class PbufferSurfaceWGL : public SurfaceGL
bool largest, bool largest,
int pixelFormat, int pixelFormat,
HDC deviceContext, HDC deviceContext,
HGLRC wglContext,
const FunctionsWGL *functions); const FunctionsWGL *functions);
~PbufferSurfaceWGL() override; ~PbufferSurfaceWGL() override;
...@@ -54,6 +53,8 @@ class PbufferSurfaceWGL : public SurfaceGL ...@@ -54,6 +53,8 @@ class PbufferSurfaceWGL : public SurfaceGL
EGLint isPostSubBufferSupported() const override; EGLint isPostSubBufferSupported() const override;
EGLint getSwapBehavior() const override; EGLint getSwapBehavior() const override;
HDC getDC() const override;
private: private:
EGLint mWidth; EGLint mWidth;
EGLint mHeight; EGLint mHeight;
...@@ -63,8 +64,6 @@ class PbufferSurfaceWGL : public SurfaceGL ...@@ -63,8 +64,6 @@ class PbufferSurfaceWGL : public SurfaceGL
int mPixelFormat; int mPixelFormat;
HGLRC mShareWGLContext;
HDC mParentDeviceContext; HDC mParentDeviceContext;
HPBUFFERARB mPbuffer; HPBUFFERARB mPbuffer;
......
//
// Copyright (c) 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// SurfaceWGL.h: Base class for WGL surface types
#ifndef LIBANGLE_RENDERER_GL_WGL_SURFACEWGL_H_
#define LIBANGLE_RENDERER_GL_WGL_SURFACEWGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h"
namespace rx
{
class SurfaceWGL : public SurfaceGL
{
public:
SurfaceWGL(const egl::SurfaceState &state, RendererGL *renderer) : SurfaceGL(state, renderer) {}
~SurfaceWGL() override {}
virtual HDC getDC() const = 0;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_WGL_SURFACEWGL_H_
...@@ -20,12 +20,10 @@ WindowSurfaceWGL::WindowSurfaceWGL(const egl::SurfaceState &state, ...@@ -20,12 +20,10 @@ WindowSurfaceWGL::WindowSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer, RendererGL *renderer,
EGLNativeWindowType window, EGLNativeWindowType window,
int pixelFormat, int pixelFormat,
HGLRC wglContext,
const FunctionsWGL *functions, const FunctionsWGL *functions,
EGLint orientation) EGLint orientation)
: SurfaceGL(state, renderer), : SurfaceWGL(state, renderer),
mPixelFormat(pixelFormat), mPixelFormat(pixelFormat),
mWGLContext(wglContext),
mWindow(window), mWindow(window),
mDeviceContext(nullptr), mDeviceContext(nullptr),
mFunctionsWGL(functions), mFunctionsWGL(functions),
...@@ -95,12 +93,6 @@ egl::Error WindowSurfaceWGL::initialize(const egl::Display *display) ...@@ -95,12 +93,6 @@ egl::Error WindowSurfaceWGL::initialize(const egl::Display *display)
egl::Error WindowSurfaceWGL::makeCurrent() egl::Error WindowSurfaceWGL::makeCurrent()
{ {
if (!mFunctionsWGL->makeCurrent(mDeviceContext, mWGLContext))
{
// TODO: What error type here?
return egl::EglContextLost() << "Failed to make the WGL context current.";
}
return egl::NoError(); return egl::NoError();
} }
...@@ -183,4 +175,8 @@ EGLint WindowSurfaceWGL::getSwapBehavior() const ...@@ -183,4 +175,8 @@ EGLint WindowSurfaceWGL::getSwapBehavior() const
return mSwapBehavior; return mSwapBehavior;
} }
HDC WindowSurfaceWGL::getDC() const
{
return mDeviceContext;
}
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#ifndef LIBANGLE_RENDERER_GL_WGL_WINDOWSURFACEWGL_H_ #ifndef LIBANGLE_RENDERER_GL_WGL_WINDOWSURFACEWGL_H_
#define LIBANGLE_RENDERER_GL_WGL_WINDOWSURFACEWGL_H_ #define LIBANGLE_RENDERER_GL_WGL_WINDOWSURFACEWGL_H_
#include "libANGLE/renderer/gl/SurfaceGL.h" #include "libANGLE/renderer/gl/wgl/SurfaceWGL.h"
#include <GL/wglext.h> #include <GL/wglext.h>
...@@ -18,14 +18,13 @@ namespace rx ...@@ -18,14 +18,13 @@ namespace rx
class FunctionsWGL; class FunctionsWGL;
class WindowSurfaceWGL : public SurfaceGL class WindowSurfaceWGL : public SurfaceWGL
{ {
public: public:
WindowSurfaceWGL(const egl::SurfaceState &state, WindowSurfaceWGL(const egl::SurfaceState &state,
RendererGL *renderer, RendererGL *renderer,
EGLNativeWindowType window, EGLNativeWindowType window,
int pixelFormat, int pixelFormat,
HGLRC wglContext,
const FunctionsWGL *functions, const FunctionsWGL *functions,
EGLint orientation); EGLint orientation);
~WindowSurfaceWGL() override; ~WindowSurfaceWGL() override;
...@@ -50,11 +49,11 @@ class WindowSurfaceWGL : public SurfaceGL ...@@ -50,11 +49,11 @@ class WindowSurfaceWGL : public SurfaceGL
EGLint isPostSubBufferSupported() const override; EGLint isPostSubBufferSupported() const override;
EGLint getSwapBehavior() const override; EGLint getSwapBehavior() const override;
HDC getDC() const override;
private: private:
int mPixelFormat; int mPixelFormat;
HGLRC mWGLContext;
HWND mWindow; HWND mWindow;
HDC mDeviceContext; HDC mDeviceContext;
......
...@@ -588,6 +588,7 @@ ...@@ -588,6 +588,7 @@
'libANGLE/renderer/gl/wgl/FunctionsWGL.h', 'libANGLE/renderer/gl/wgl/FunctionsWGL.h',
'libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.cpp', 'libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.cpp',
'libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.h', 'libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.h',
'libANGLE/renderer/gl/wgl/SurfaceWGL.h',
'libANGLE/renderer/gl/wgl/WindowSurfaceWGL.cpp', 'libANGLE/renderer/gl/wgl/WindowSurfaceWGL.cpp',
'libANGLE/renderer/gl/wgl/WindowSurfaceWGL.h', 'libANGLE/renderer/gl/wgl/WindowSurfaceWGL.h',
'libANGLE/renderer/gl/wgl/functionswgl_typedefs.h', 'libANGLE/renderer/gl/wgl/functionswgl_typedefs.h',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment