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

Unified Diff: src/gpu/gl/iOS/SkCreatePlatformGLContext_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: 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/glx/SkNativeGLContext_glx.cpp ('k') | src/gpu/gl/iOS/SkNativeGLContext_iOS.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm
diff --git a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm b/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm
similarity index 56%
rename from src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
rename to src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm
index 1bdaf70f1c37c60fb47caecda58ece76a8acbb04..9989957ac9ea684fdebb2539dc2c9f99df6c9edf 100644
--- a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
+++ b/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm
@@ -6,36 +6,38 @@
* found in the LICENSE file.
*/
-#include "gl/SkNativeGLContext.h"
+#include "gl/SkGLContext.h"
#import <OpenGLES/EAGL.h>
#define EAGLCTX ((EAGLContext*)(fEAGLContext))
-SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
- fEAGLContext = [EAGLContext currentContext];
- if (EAGLCTX) {
- [EAGLCTX retain];
- }
-}
+namespace {
-SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
- if (EAGLCTX) {
- [EAGLContext setCurrentContext:EAGLCTX];
- [EAGLCTX release];
- }
-}
+class IOSGLContext : public SkGLContext {
+public:
+ IOSGLContext();
+
+ virtual ~IOSGLContext();
-///////////////////////////////////////////////////////////////////////////////
+ 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;
-SkNativeGLContext::SkNativeGLContext()
+private:
+ void* fEAGLContext;
+};
+
+IOSGLContext::IOSGLContext()
: fEAGLContext(NULL) {
}
-SkNativeGLContext::~SkNativeGLContext() {
+IOSGLContext::~IOSGLContext() {
this->destroyGLContext();
}
-void SkNativeGLContext::destroyGLContext() {
+void IOSGLContext::destroyGLContext() {
if (fEAGLContext) {
if ([EAGLContext currentContext] == EAGLCTX) {
[EAGLContext setCurrentContext:nil];
@@ -45,7 +47,7 @@ void SkNativeGLContext::destroyGLContext() {
}
}
-const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* IOSGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
if (kGL_GrGLStandard == forcedGpuAPI) {
return NULL;
}
@@ -62,10 +64,18 @@ const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP
return interface;
}
-void SkNativeGLContext::makeCurrent() const {
+void IOSGLContext::makeCurrent() const {
if (![EAGLContext setCurrentContext:EAGLCTX]) {
SkDebugf("Could not set the context.\n");
}
}
-void SkNativeGLContext::swapBuffers() const { }
+void IOSGLContext::swapBuffers() const { }
+
+} // anonymous namespace
+
+
+SkGLContext* SkCreatePlatformGLContext() {
+ return SkNEW(IOSGLContext);
+}
+
« no previous file with comments | « src/gpu/gl/glx/SkNativeGLContext_glx.cpp ('k') | src/gpu/gl/iOS/SkNativeGLContext_iOS.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698