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

Unified Diff: src/gpu/gl/egl/SkCreatePlatformGLContext_egl.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/debug/GrGLCreateDebugInterface.cpp ('k') | src/gpu/gl/egl/SkNativeGLContext_egl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
diff --git a/src/gpu/gl/egl/SkNativeGLContext_egl.cpp b/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
similarity index 83%
rename from src/gpu/gl/egl/SkNativeGLContext_egl.cpp
rename to src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
index d4d7219b5bbbf7a3799e367d7102288cfa382abc..f33e84abc4e1370db50f641e22b474ed1771e810 100644
--- a/src/gpu/gl/egl/SkNativeGLContext_egl.cpp
+++ b/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
@@ -5,34 +5,42 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gl/SkNativeGLContext.h"
+#include "gl/SkGLContext.h"
-SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
- fOldEGLContext = eglGetCurrentContext();
- fOldDisplay = eglGetCurrentDisplay();
- fOldSurface = eglGetCurrentSurface(EGL_DRAW);
+#include <GLES2/gl2.h>
+#include <EGL/egl.h>
-}
+namespace {
-SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
- if (fOldDisplay) {
- eglMakeCurrent(fOldDisplay, fOldSurface, fOldSurface, fOldEGLContext);
- }
-}
+class EGLGLContext : public SkGLContext {
+public:
+ EGLGLContext();
+
+ virtual ~EGLGLContext();
+
+ 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;
-///////////////////////////////////////////////////////////////////////////////
+private:
+ EGLContext fContext;
+ EGLDisplay fDisplay;
+ EGLSurface fSurface;
+};
-SkNativeGLContext::SkNativeGLContext()
+EGLGLContext::EGLGLContext()
: fContext(EGL_NO_CONTEXT)
, fDisplay(EGL_NO_DISPLAY)
, fSurface(EGL_NO_SURFACE) {
}
-SkNativeGLContext::~SkNativeGLContext() {
+EGLGLContext::~EGLGLContext() {
this->destroyGLContext();
}
-void SkNativeGLContext::destroyGLContext() {
+void EGLGLContext::destroyGLContext() {
if (fDisplay) {
eglMakeCurrent(fDisplay, 0, 0, 0);
@@ -51,7 +59,7 @@ void SkNativeGLContext::destroyGLContext() {
}
}
-const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* EGLGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
static const EGLint kEGLContextAttribsForOpenGL[] = {
EGL_NONE
};
@@ -169,14 +177,21 @@ const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
return interface;
}
-void SkNativeGLContext::makeCurrent() const {
+void EGLGLContext::makeCurrent() const {
if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
SkDebugf("Could not set the context.\n");
}
}
-void SkNativeGLContext::swapBuffers() const {
+void EGLGLContext::swapBuffers() const {
if (!eglSwapBuffers(fDisplay, fSurface)) {
SkDebugf("Could not complete eglSwapBuffers.\n");
}
}
+
+} // anonymous namespace
+
+SkGLContext* SkCreatePlatformGLContext() {
+ return SkNEW(EGLGLContext);
+}
+
« no previous file with comments | « src/gpu/gl/debug/GrGLCreateDebugInterface.cpp ('k') | src/gpu/gl/egl/SkNativeGLContext_egl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698