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

Unified Diff: src/gpu/gl/iOS/SkNativeGLContext_iOS.mm

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/iOS/SkNativeGLContext_iOS.mm
diff --git a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm b/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
index 1bdaf70f1c37c60fb47caecda58ece76a8acbb04..1cc51e8a18f570a4575d84df9072f7bda6ebf351 100644
--- a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
+++ b/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
@@ -11,14 +11,32 @@
#define EAGLCTX ((EAGLContext*)(fEAGLContext))
-SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
+namespace {
+
+class SkNativeGLContextIOS : public SkNativeGLContext {
+public:
+ SkNativeGLContextIOS();
+
+ virtual ~SkNativeGLContextIOS();
+
+ 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:
+ void* fEAGLContext;
+};
+
+SkNativeGLContextIOS::AutoContextRestore::AutoContextRestore() {
fEAGLContext = [EAGLContext currentContext];
if (EAGLCTX) {
[EAGLCTX retain];
}
}
-SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
+SkNativeGLContextIOS::AutoContextRestore::~AutoContextRestore() {
if (EAGLCTX) {
[EAGLContext setCurrentContext:EAGLCTX];
[EAGLCTX release];
@@ -27,15 +45,15 @@ SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
///////////////////////////////////////////////////////////////////////////////
-SkNativeGLContext::SkNativeGLContext()
+SkNativeGLContextIOS::SkNativeGLContextIOS()
: fEAGLContext(NULL) {
}
-SkNativeGLContext::~SkNativeGLContext() {
+SkNativeGLContextIOS::~SkNativeGLContextIOS() {
this->destroyGLContext();
}
-void SkNativeGLContext::destroyGLContext() {
+void SkNativeGLContextIOS::destroyGLContext() {
if (fEAGLContext) {
if ([EAGLContext currentContext] == EAGLCTX) {
[EAGLContext setCurrentContext:nil];
@@ -45,7 +63,7 @@ void SkNativeGLContext::destroyGLContext() {
}
}
-const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* SkNativeGLContextIOS::createGLContext(GrGLStandard forcedGpuAPI) {
if (kGL_GrGLStandard == forcedGpuAPI) {
return NULL;
}
@@ -62,10 +80,18 @@ const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
return interface;
}
-void SkNativeGLContext::makeCurrent() const {
+void SkNativeGLContextIOS::makeCurrent() const {
if (![EAGLContext setCurrentContext:EAGLCTX]) {
SkDebugf("Could not set the context.\n");
}
}
-void SkNativeGLContext::swapBuffers() const { }
+void SkNativeGLContextIOS::swapBuffers() const { }
+
+} // anonymous namespace
+
+
+SkNativeGLContext* SkCreateGLContext() {
+ return SkNEW(SkNativeGLContextIOS);
+}
+

Powered by Google App Engine
This is Rietveld 408576698