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

Unified Diff: src/gpu/gl/win/SkCreatePlatformGLContext_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: fix android link problem and ios compile problem 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
« no previous file with comments | « src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp ('k') | src/gpu/gl/win/SkNativeGLContext_win.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
diff --git a/src/gpu/gl/win/SkNativeGLContext_win.cpp b/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
similarity index 79%
rename from src/gpu/gl/win/SkNativeGLContext_win.cpp
rename to src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
index ab66ba4d55ce3e61a715692e015d3453ca5e0909..d362556a4e96271e4846f560785bd0acc4173c5c 100644
--- a/src/gpu/gl/win/SkNativeGLContext_win.cpp
+++ b/src/gpu/gl/win/SkCreatePlatformGLContext_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 WinGLContext : public SkGLContext {
+public:
+ WinGLContext();
+
+ virtual ~WinGLContext();
-///////////////////////////////////////////////////////////////////////////////
+ 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 WinGLContext::gWC = 0;
+
+WinGLContext::WinGLContext()
: fWindow(NULL)
, fDeviceContext(NULL)
, fGlRenderContext(0)
, fPbufferContext(NULL) {
}
-SkNativeGLContext::~SkNativeGLContext() {
+WinGLContext::~WinGLContext() {
this->destroyGLContext();
}
-void SkNativeGLContext::destroyGLContext() {
+void WinGLContext::destroyGLContext() {
SkSafeSetNull(fPbufferContext);
if (fGlRenderContext) {
wglDeleteContext(fGlRenderContext);
@@ -51,7 +66,7 @@ void SkNativeGLContext::destroyGLContext() {
}
}
-const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* WinGLContext::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 WinGLContext::makeCurrent() const {
HDC dc;
HGLRC glrc;
@@ -151,7 +166,7 @@ void SkNativeGLContext::makeCurrent() const {
}
}
-void SkNativeGLContext::swapBuffers() const {
+void WinGLContext::swapBuffers() const {
HDC dc;
if (NULL == fPbufferContext) {
@@ -163,3 +178,10 @@ void SkNativeGLContext::swapBuffers() const {
SkDebugf("Could not complete SwapBuffers.\n");
}
}
+
+} // anonymous namespace
+
+SkGLContext* SkCreatePlatformGLContext() {
+ return SkNEW(WinGLContext);
+}
+
« no previous file with comments | « src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp ('k') | src/gpu/gl/win/SkNativeGLContext_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698