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

Unified Diff: src/gpu/gl/mesa/SkMesaGLContext.cpp

Issue 640283004: Refactor SkGLContext to be actually extendable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: win compile fix. 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/mesa/SkMesaGLContext.cpp
diff --git a/src/gpu/gl/mesa/SkMesaGLContext.cpp b/src/gpu/gl/mesa/SkMesaGLContext.cpp
index 8c339c7fac4fc50ac837b4155464b92d6a8e7b69..3c5cc971a209a70d6bd4b61f9c662e369a7f639f 100644
--- a/src/gpu/gl/mesa/SkMesaGLContext.cpp
+++ b/src/gpu/gl/mesa/SkMesaGLContext.cpp
@@ -11,34 +11,12 @@
#include "gl/SkMesaGLContext.h"
#include "gl/GrGLDefines.h"
+static const GrGLint gBOGUS_SIZE = 16;
+
SkMesaGLContext::SkMesaGLContext()
: fContext(static_cast<Context>(NULL))
, fImage(NULL) {
GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext));
-}
-
-SkMesaGLContext::~SkMesaGLContext() {
- this->destroyGLContext();
-}
-
-void SkMesaGLContext::destroyGLContext() {
- if (fImage) {
- sk_free(fImage);
- fImage = NULL;
- }
-
- if (fContext) {
- OSMesaDestroyContext((OSMesaContext)fContext);
- fContext = static_cast<Context>(NULL);
- }
-}
-
-static const GrGLint gBOGUS_SIZE = 16;
-
-const GrGLInterface* SkMesaGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
- if (kGLES_GrGLStandard == forcedGpuAPI) {
- return NULL;
- }
/* Create an RGBA-mode context */
#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305
@@ -50,7 +28,7 @@ const GrGLInterface* SkMesaGLContext::createGLContext(GrGLStandard forcedGpuAPI)
if (!fContext) {
SkDebugf("OSMesaCreateContext failed!\n");
this->destroyGLContext();
- return NULL;
+ return;
}
// Allocate the image buffer
fImage = (GrGLubyte *) sk_malloc_throw(gBOGUS_SIZE * gBOGUS_SIZE *
@@ -58,7 +36,7 @@ const GrGLInterface* SkMesaGLContext::createGLContext(GrGLStandard forcedGpuAPI)
if (!fImage) {
SkDebugf("Alloc image buffer failed!\n");
this->destroyGLContext();
- return NULL;
+ return;
}
// Bind the buffer to the context and make it current
@@ -69,19 +47,42 @@ const GrGLInterface* SkMesaGLContext::createGLContext(GrGLStandard forcedGpuAPI)
gBOGUS_SIZE)) {
SkDebugf("OSMesaMakeCurrent failed!\n");
this->destroyGLContext();
- return NULL;
+ return;
}
- const GrGLInterface* interface = GrGLCreateMesaInterface();
- if (!interface) {
+ fGL.reset(GrGLCreateMesaInterface());
+ if (NULL == fGL.get()) {
SkDebugf("Could not create GL interface!\n");
this->destroyGLContext();
- return NULL;
+ return;
}
- return interface;
+ if (!fGL->validate()) {
+ SkDebugf("Could not validate GL interface!\n");
+ this->destroyGLContext();
+ return;
+ }
}
+SkMesaGLContext::~SkMesaGLContext() {
+ this->destroyGLContext();
+}
+
+void SkMesaGLContext::destroyGLContext() {
+ fGL.reset(NULL);
+ if (fImage) {
+ sk_free(fImage);
+ fImage = NULL;
+ }
+
+ if (fContext) {
+ OSMesaDestroyContext((OSMesaContext)fContext);
+ fContext = static_cast<Context>(NULL);
+ }
+}
+
+
+
void SkMesaGLContext::makeCurrent() const {
if (fContext) {
if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage,
« no previous file with comments | « src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp ('k') | src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698