Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: src/gpu/gl/win/SkNativeGLContext_win.cpp

Issue 630843002: Make the Sk GL context class an abstract base class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/win/SkNativeGLContext_win.cpp
diff --git a/src/gpu/gl/win/SkNativeGLContext_win.cpp b/src/gpu/gl/win/SkNativeGLContext_win.cpp
index ab66ba4d55ce3e61a715692e015d3453ca5e0909..7d008e88e39fa015897ae305bb4d8e9ee466b737 100644
--- a/src/gpu/gl/win/SkNativeGLContext_win.cpp
+++ b/src/gpu/gl/win/SkNativeGLContext_win.cpp
@@ -6,36 +6,51 @@
* found in the LICENSE file.
*/
-#include "gl/SkNativeGLContext.h"
+#include "gl/SkGLContext.h"
+
+#include <windows.h>
+#include <GL/GL.h>
+#include "SkWGL.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
- fOldHGLRC = wglGetCurrentContext();
- fOldHDC = wglGetCurrentDC();
-}
+namespace {
-SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
- wglMakeCurrent(fOldHDC, fOldHGLRC);
-}
+class SkGLContextWin : public SkGLContext {
+public:
+ SkGLContextWin();
+
+ virtual ~SkGLContextWin();
-///////////////////////////////////////////////////////////////////////////////
+ virtual void makeCurrent() const SK_OVERRIDE;
+ virtual void swapBuffers() const SK_OVERRIDE;
+protected:
+ virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
+ virtual void destroyGLContext() SK_OVERRIDE;
-ATOM SkNativeGLContext::gWC = 0;
+private:
+ HWND fWindow;
+ HDC fDeviceContext;
+ HGLRC fGlRenderContext;
+ static ATOM gWC;
+ SkWGLPbufferContext* fPbufferContext;
+};
-SkNativeGLContext::SkNativeGLContext()
+ATOM SkGLContextWin::gWC = 0;
+
+SkGLContextWin::SkGLContextWin()
: fWindow(NULL)
, fDeviceContext(NULL)
, fGlRenderContext(0)
, fPbufferContext(NULL) {
}
-SkNativeGLContext::~SkNativeGLContext() {
+SkGLContextWin::~SkGLContextWin() {
this->destroyGLContext();
}
-void SkNativeGLContext::destroyGLContext() {
+void SkGLContextWin::destroyGLContext() {
SkSafeSetNull(fPbufferContext);
if (fGlRenderContext) {
wglDeleteContext(fGlRenderContext);
@@ -51,7 +66,7 @@ void SkNativeGLContext::destroyGLContext() {
}
}
-const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* SkGLContextWin::createGLContext(GrGLStandard forcedGpuAPI) {
HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
if (!gWC) {
@@ -134,7 +149,7 @@ const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
return interface;
}
-void SkNativeGLContext::makeCurrent() const {
+void SkGLContextWin::makeCurrent() const {
HDC dc;
HGLRC glrc;
@@ -151,7 +166,7 @@ void SkNativeGLContext::makeCurrent() const {
}
}
-void SkNativeGLContext::swapBuffers() const {
+void SkGLContextWin::swapBuffers() const {
HDC dc;
if (NULL == fPbufferContext) {
@@ -163,3 +178,10 @@ void SkNativeGLContext::swapBuffers() const {
SkDebugf("Could not complete SwapBuffers.\n");
}
}
+
+} // anonymous namespace
+
+SkGLContext* SkCreateGLContext() {
+ return SkNEW(SkGLContextWin);
+}
+

Powered by Google App Engine
This is Rietveld 408576698