Split GrGLContextInfo into GrGLContext & GrGLContextInfo
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 28 Feb 2013 20:16:25 +0000 (20:16 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 28 Feb 2013 20:16:25 +0000 (20:16 +0000)
https://codereview.appspot.com/7436045/

git-svn-id: http://skia.googlecode.com/svn/trunk@7905 2bbb7eff-a529-9590-31e7-b0007b416f81

37 files changed:
bench/BenchGpuTimer_gl.cpp
bench/BenchGpuTimer_gl.h
bench/BenchTimer.cpp
bench/BenchTimer.h
bench/benchmain.cpp
gyp/gpu.gypi
include/gpu/GrContextFactory.h
include/gpu/gl/SkANGLEGLContext.h
include/gpu/gl/SkDebugGLContext.h
include/gpu/gl/SkGLContext.h [deleted file]
include/gpu/gl/SkGLContextHelper.h [new file with mode: 0644]
include/gpu/gl/SkMesaGLContext.h
include/gpu/gl/SkNativeGLContext.h
include/gpu/gl/SkNullGLContext.h
src/gpu/GrGpuFactory.cpp
src/gpu/gl/GrGLCaps.cpp
src/gpu/gl/GrGLCaps.h
src/gpu/gl/GrGLContext.cpp [new file with mode: 0644]
src/gpu/gl/GrGLContext.h [new file with mode: 0644]
src/gpu/gl/GrGLContextInfo.cpp [deleted file]
src/gpu/gl/GrGLContextInfo.h [deleted file]
src/gpu/gl/GrGLProgram.cpp
src/gpu/gl/GrGLProgram.h
src/gpu/gl/GrGLShaderBuilder.cpp
src/gpu/gl/GrGLShaderBuilder.h
src/gpu/gl/GrGLShaderVar.h
src/gpu/gl/GrGLUniformManager.h
src/gpu/gl/GrGpuGL.cpp
src/gpu/gl/GrGpuGL.h
src/gpu/gl/GrGpuGL_program.cpp
src/gpu/gl/SkGLContext.cpp [deleted file]
src/gpu/gl/SkGLContextHelper.cpp [new file with mode: 0644]
src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
tests/GLProgramsTest.cpp
tools/PdfRenderer.h
tools/PictureRenderer.cpp
tools/PictureRenderer.h

index 1b317c6aaac8a2a24f6cf85abdf4b16699686c49..349fc1529de6ac32754950f20c1ab5bd6037ecb2 100644 (file)
@@ -6,10 +6,10 @@
  * found in the LICENSE file.
  */
 #include "BenchGpuTimer_gl.h"
-#include "gl/SkGLContext.h"
+#include "gl/SkGLContextHelper.h"
 #include "gl/GrGLUtil.h"
 
-BenchGpuTimer::BenchGpuTimer(const SkGLContext* glctx) {
+BenchGpuTimer::BenchGpuTimer(const SkGLContextHelper* glctx) {
     fContext = glctx;
     glctx->ref();
     glctx->makeCurrent();
index 7c7b5c294902ff6686c9ab73f66291353af31b86..e472a4c51447d380b71d7f57d763a293de951cc9 100644 (file)
@@ -8,18 +8,18 @@
 #ifndef SkBenchGpuTimer_DEFINED
 #define SkBenchGpuTimer_DEFINED
 
-class SkGLContext;
+class SkGLContextHelper;
 
 class BenchGpuTimer {
 public:
-    BenchGpuTimer(const SkGLContext* glctx);
+    BenchGpuTimer(const SkGLContextHelper* glctx);
     ~BenchGpuTimer();
     void startGpu();
     double endGpu();
 private:
     unsigned fQuery;
     int fStarted;
-    const SkGLContext* fContext;
+    const SkGLContextHelper* fContext;
     bool fSupported;
 };
 
index 4e0484459d1b9c926446a4c75613251ec008d65d..ab9dfdaf18caef23d4113b64fbe62689fc833e64 100644 (file)
@@ -20,7 +20,7 @@
 #include "BenchGpuTimer_gl.h"
 #endif
 
-BenchTimer::BenchTimer(SkGLContext* gl)
+BenchTimer::BenchTimer(SkGLContextHelper* gl)
         : fCpu(-1.0)
         , fWall(-1.0)
         , fTruncatedCpu(-1.0)
index 58773d403cc1b6d2b42917e799753c39c1d9b497..79e1036c527294e871f24ebbc79e178da2f6ffa2 100644 (file)
@@ -14,7 +14,7 @@
 class BenchSysTimer;
 class BenchGpuTimer;
 
-class SkGLContext;
+class SkGLContextHelper;
 
 /**
  * SysTimers and GpuTimers are implemented orthogonally.
@@ -27,7 +27,7 @@ class SkGLContext;
  */
 class BenchTimer {
 public:
-    BenchTimer(SkGLContext* gl = NULL);
+    BenchTimer(SkGLContextHelper* gl = NULL);
     ~BenchTimer();
     void start();
     void end();
index 5fc74bcec637672f778ffbd559a313f894c4e1b1..96db07d465568a59c994def22a4e6e9ab0d59798 100644 (file)
@@ -625,7 +625,7 @@ int tool_main(int argc, char** argv) {
     SkTArray<BenchTimer*> timers(SK_ARRAY_COUNT(gConfigs));
     for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) {
 #if SK_SUPPORT_GPU
-        SkGLContext* ctx = NULL;
+        SkGLContextHelper* ctx = NULL;
         if (kGPU_Backend == gConfigs[i].fBackend) {
             ctx = gContextFactory.getGLContext(gConfigs[i].fContextType);
         }
@@ -680,7 +680,7 @@ int tool_main(int argc, char** argv) {
             configName = gConfigs[configIndex].fName;
             backend = gConfigs[configIndex].fBackend;
             GrContext* context = NULL;
-            SkGLContext* glContext = NULL;
+            SkGLContextHelper* glContext = NULL;
             BenchTimer* timer = timers[configIndex];
 
 #if SK_SUPPORT_GPU
index dffc07dc70c0b1d1125273765ecac7c6455dcf07..a1c17273b58b5b8e76d5de5e288359b039dd9d08 100644 (file)
       '<(skia_src_path)/gpu/gl/GrGLBufferImpl.h',
       '<(skia_src_path)/gpu/gl/GrGLCaps.cpp',
       '<(skia_src_path)/gpu/gl/GrGLCaps.h',
-      '<(skia_src_path)/gpu/gl/GrGLContextInfo.cpp',
-      '<(skia_src_path)/gpu/gl/GrGLContextInfo.h',
+      '<(skia_src_path)/gpu/gl/GrGLContext.cpp',
+      '<(skia_src_path)/gpu/gl/GrGLContext.h',
       '<(skia_src_path)/gpu/gl/GrGLCreateNativeInterface_none.cpp',
       '<(skia_src_path)/gpu/gl/GrGLDefaultInterface_none.cpp',
       '<(skia_src_path)/gpu/gl/GrGLDefines.h',
       '<(skia_include_path)/gpu/SkGrPixelRef.h',
       '<(skia_include_path)/gpu/SkGrTexturePixelRef.h',
 
-      '<(skia_include_path)/gpu/gl/SkGLContext.h',
+      '<(skia_include_path)/gpu/gl/SkGLContextHelper.h',
 
       '<(skia_src_path)/gpu/SkGpuDevice.cpp',
       '<(skia_src_path)/gpu/SkGr.cpp',
       '<(skia_src_path)/image/SkImage_Gpu.cpp',
       '<(skia_src_path)/image/SkSurface_Gpu.cpp',
 
-      '<(skia_src_path)/gpu/gl/SkGLContext.cpp'
+      '<(skia_src_path)/gpu/gl/SkGLContextHelper.cpp'
     ],
     'skgr_native_gl_sources': [
       '<(skia_include_path)/gpu/gl/SkNativeGLContext.h',
index d425b744162bf2a1cc4f3c928fbefbf4d73a1488..3d9f1a386dd7f32507e0eac569a5ea6ff217881c 100644 (file)
@@ -104,7 +104,7 @@ public:
                 return fContexts[i].fGrContext;
             }
         }
-        SkAutoTUnref<SkGLContext> glCtx;
+        SkAutoTUnref<SkGLContextHelper> glCtx;
         SkAutoTUnref<GrContext> grCtx;
         switch (type) {
             case kNative_GLContextType:
@@ -150,7 +150,7 @@ public:
 
     // Returns the GLContext of the given type. If it has not been created yet,
     // NULL is returned instead.
-    SkGLContext* getGLContext(GLContextType type) {
+    SkGLContextHelper* getGLContext(GLContextType type) {
         for (int i = 0; i < fContexts.count(); ++i) {
             if (fContexts[i].fType == type) {
                 return fContexts[i].fGLContext;
@@ -163,7 +163,7 @@ public:
 private:
     struct GPUContext {
         GLContextType             fType;
-        SkGLContext*              fGLContext;
+        SkGLContextHelper*        fGLContext;
         GrContext*                fGrContext;
     };
     SkTArray<GPUContext, true> fContexts;
index 7bcf07a87df40a15ab8ba207de45169c17a29d89..63765a0131fc16f8ac6f91c82f8e047ddd2142b0 100644 (file)
 
 #if SK_ANGLE
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
 #include <GLES2/gl2.h>
 #include <EGL/egl.h>
 
-class SkANGLEGLContext : public SkGLContext {
+class SkANGLEGLContext : public SkGLContextHelper {
 public:
     SkANGLEGLContext();
 
index 6e29b6738b67ad61440188d6d89a9bcaeb2ea69a..2437aaeb5f196a2f984f5b73146b2f0608532e54 100644 (file)
@@ -8,9 +8,9 @@
 #ifndef SkDebugGLContext_DEFINED
 #define SkDebugGLContext_DEFINED
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
-class SkDebugGLContext : public SkGLContext {
+class SkDebugGLContext : public SkGLContextHelper {
 
 public:
     SkDebugGLContext() {};
diff --git a/include/gpu/gl/SkGLContext.h b/include/gpu/gl/SkGLContext.h
deleted file mode 100644 (file)
index 43ae9cd..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkGLContext_DEFINED
-#define SkGLContext_DEFINED
-
-#include "GrGLExtensions.h"
-#include "GrGLInterface.h"
-
-/**
- * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
- * Provides a GrGLInterface struct of function pointers for the context.
- */
-
-class SkGLContext : public SkRefCnt {
-public:
-    SK_DECLARE_INST_COUNT(SkGLContext)
-
-    SkGLContext();
-    virtual ~SkGLContext();
-
-    /**
-     * Initializes the context and makes it current.
-     */
-    bool init(const int width, const int height);
-
-    int getFBOID() const { return fFBO; }
-
-    const GrGLInterface* gl() const { return fGL; }
-
-    virtual void makeCurrent() const = 0;
-
-    bool hasExtension(const char* extensionName) const {
-        GrAssert(NULL != fGL);
-        return fExtensions.has(extensionName);
-    }
-
-protected:
-    /**
-     * Subclass implements this to make a GL context. The returned GrGLInterface
-     * should be populated with functions compatible with the context. The
-     * format and size of backbuffers does not matter since an FBO will be
-     * created.
-     */
-    virtual const GrGLInterface* createGLContext() = 0;
-
-    /**
-     * Subclass should destroy the underlying GL context.
-     */
-    virtual void destroyGLContext() = 0;
-
-private:
-    GrGLExtensions fExtensions;
-    GrGLuint fFBO;
-    GrGLuint fColorBufferID;
-    GrGLuint fDepthStencilBufferID;
-    const GrGLInterface* fGL;
-
-    typedef SkRefCnt INHERITED;
-};
-
-/**
- * Helper macros for using the GL context through the GrGLInterface. Example:
- * SK_GL(glCtx, GenTextures(1, &texID));
- */
-#define SK_GL(ctx, X) (ctx).gl()->f ## X;    \
-                      SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError())
-#define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->f ## X;    \
-                  SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError())
-#define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->f ## X
-#define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->f ## X
-
-#endif
diff --git a/include/gpu/gl/SkGLContextHelper.h b/include/gpu/gl/SkGLContextHelper.h
new file mode 100644 (file)
index 0000000..386a695
--- /dev/null
@@ -0,0 +1,77 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkGLContextHelper_DEFINED
+#define SkGLContextHelper_DEFINED
+
+#include "GrGLExtensions.h"
+#include "GrGLInterface.h"
+
+/**
+ * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
+ * Provides a GrGLInterface struct of function pointers for the context.
+ */
+
+class SkGLContextHelper : public SkRefCnt {
+public:
+    SK_DECLARE_INST_COUNT(SkGLContextHelper)
+
+    SkGLContextHelper();
+    virtual ~SkGLContextHelper();
+
+    /**
+     * Initializes the context and makes it current.
+     */
+    bool init(const int width, const int height);
+
+    int getFBOID() const { return fFBO; }
+
+    const GrGLInterface* gl() const { return fGL; }
+
+    virtual void makeCurrent() const = 0;
+
+    bool hasExtension(const char* extensionName) const {
+        GrAssert(NULL != fGL);
+        return fExtensions.has(extensionName);
+    }
+
+protected:
+    /**
+     * Subclass implements this to make a GL context. The returned GrGLInterface
+     * should be populated with functions compatible with the context. The
+     * format and size of backbuffers does not matter since an FBO will be
+     * created.
+     */
+    virtual const GrGLInterface* createGLContext() = 0;
+
+    /**
+     * Subclass should destroy the underlying GL context.
+     */
+    virtual void destroyGLContext() = 0;
+
+private:
+    GrGLExtensions fExtensions;
+    GrGLuint fFBO;
+    GrGLuint fColorBufferID;
+    GrGLuint fDepthStencilBufferID;
+    const GrGLInterface* fGL;
+
+    typedef SkRefCnt INHERITED;
+};
+
+/**
+ * Helper macros for using the GL context through the GrGLInterface. Example:
+ * SK_GL(glCtx, GenTextures(1, &texID));
+ */
+#define SK_GL(ctx, X) (ctx).gl()->f ## X;    \
+                      SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError())
+#define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->f ## X;    \
+                  SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError())
+#define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->f ## X
+#define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->f ## X
+
+#endif
index 14a3ca7b272e272162c411857d09de9f0af399c9..6470d2eef09cabb7415cf4e1514225286a10b3eb 100644 (file)
@@ -8,11 +8,11 @@
 #ifndef SkMesaGLContext_DEFINED
 #define SkMesaGLContext_DEFINED
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
 #if SK_MESA
 
-class SkMesaGLContext : public SkGLContext {
+class SkMesaGLContext : public SkGLContextHelper {
 private:
     typedef intptr_t Context;
 
index 410c14907f927b9ab806770e4092aa4c886a100a..27a8f09bacb396771d1edf1083e1e00dd68474b8 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SkNativeGLContext_DEFINED
 #define SkNativeGLContext_DEFINED
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
 #if defined(SK_BUILD_FOR_MAC)
     #include <OpenGL/OpenGL.h>
@@ -23,7 +23,7 @@
     #include <GL/GL.h>
 #endif
 
-class SkNativeGLContext : public SkGLContext {
+class SkNativeGLContext : public SkGLContextHelper {
 public:
     SkNativeGLContext();
 
index 83213a3ac30772d5d05f37d3d3bfdef33137253f..4f2639c8d7c0f2ae9c6157860f0cde1aa21ed7fb 100644 (file)
@@ -8,9 +8,9 @@
 #ifndef SkNullGLContext_DEFINED
 #define SkNullGLContext_DEFINED
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
-class SkNullGLContext : public SkGLContext {
+class SkNullGLContext : public SkGLContextHelper {
 
 public:
     SkNullGLContext() {};
index a5114469ae81c4aba089727315bde109fd7dfff9..a3c8eba45299623d827b27654450db714aa9310d 100644 (file)
@@ -34,9 +34,9 @@ GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrConte
 #endif
             return NULL;
         }
-        GrGLContextInfo ctxInfo(glInterface);
-        if (ctxInfo.isInitialized()) {
-            return SkNEW_ARGS(GrGpuGL, (ctxInfo, context));
+        GrGLContext ctx(glInterface);
+        if (ctx.isInitialized()) {
+            return SkNEW_ARGS(GrGpuGL, (ctx, context));
         }
     }
     return NULL;
index 1276a65a1942426177d3f927a2ba2bc4d86b2262..d62a310fc6505b4f2bd260c2395a11ecc99886cd 100644 (file)
@@ -7,7 +7,7 @@
 
 
 #include "GrGLCaps.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
 #include "SkTSearch.h"
 
 GrGLCaps::GrGLCaps() {
@@ -73,14 +73,13 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
     return *this;
 }
 
-void GrGLCaps::init(const GrGLContextInfo& ctxInfo) {
+void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
 
     this->reset();
     if (!ctxInfo.isInitialized()) {
         return;
     }
 
-    const GrGLInterface* gli = ctxInfo.interface();
     GrGLBinding binding = ctxInfo.binding();
     GrGLVersion version = ctxInfo.version();
 
@@ -178,7 +177,7 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo) {
         fUseNonVBOVertexAndIndexDynamicData = true;
     }
 
-    this->initFSAASupport(ctxInfo);
+    this->initFSAASupport(ctxInfo, gli);
     this->initStencilFormats(ctxInfo);
 }
 
@@ -227,7 +226,7 @@ int coverage_mode_compare(const GrGLCaps::MSAACoverageMode* left,
 }
 }
 
-void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) {
+void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
 
     fMSFBOType = kNone_MSFBOType;
     if (kDesktop_GrGLBinding != ctxInfo.binding()) {
@@ -253,11 +252,11 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) {
         if (ctxInfo.hasExtension("GL_NV_framebuffer_multisample_coverage")) {
             fCoverageAAType = kNVDesktop_CoverageAAType;
             GrGLint count;
-            GR_GL_GetIntegerv(ctxInfo.interface(),
+            GR_GL_GetIntegerv(gli,
                               GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES,
                               &count);
             fMSAACoverageModes.setCount(count);
-            GR_GL_GetIntegerv(ctxInfo.interface(),
+            GR_GL_GetIntegerv(gli,
                               GR_GL_MULTISAMPLE_COVERAGE_MODES,
                               (int*)&fMSAACoverageModes[0]);
             // The NV driver seems to return the modes already sorted but the
@@ -269,9 +268,7 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) {
         }
     }
     if (kNone_MSFBOType != fMSFBOType) {
-        GR_GL_GetIntegerv(ctxInfo.interface(),
-                          GR_GL_MAX_SAMPLES,
-                          &fMaxSampleCount);
+        GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
     }
 }
 
index 4143868ed82273f76a7af71d42336ec7fdcadd5d..48ceb33637f113ad9c165af728d9444f9e468394 100644 (file)
@@ -95,7 +95,7 @@ public:
      * Initializes the GrGLCaps to the set of features supported in the current
      * OpenGL context accessible via ctxInfo.
      */
-    void init(const GrGLContextInfo& ctxInfo);
+    void init(const GrGLContextInfo& ctxInfo, const GrGLInterface* interface);
 
     /**
      * Call to note that a color config has been verified as a valid color
@@ -267,7 +267,7 @@ private:
         }
     };
 
-    void initFSAASupport(const GrGLContextInfo& ctxInfo);
+    void initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli);
     void initStencilFormats(const GrGLContextInfo& ctxInfo);
 
     // tracks configs that have been verified to pass the FBO completeness when
diff --git a/src/gpu/gl/GrGLContext.cpp b/src/gpu/gl/GrGLContext.cpp
new file mode 100644 (file)
index 0000000..ba4196d
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLContext.h"
+
+////////////////////////////////////////////////////////////////////////////////
+GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) {
+    fBindingInUse = ctxInfo.fBindingInUse;
+    fGLVersion = ctxInfo.fGLVersion;
+    fGLSLGeneration = ctxInfo.fGLSLGeneration;
+    fVendor = ctxInfo.fVendor;
+    fExtensions = ctxInfo.fExtensions;
+    fGLCaps = ctxInfo.fGLCaps;
+    return *this;
+}
+    
+bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
+    this->reset();
+    // We haven't validated the GrGLInterface yet, so check for GetString
+    // function pointer
+    if (interface->fGetString) {
+        const GrGLubyte* verUByte;
+        GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION));
+        const char* ver = reinterpret_cast<const char*>(verUByte);
+        GrGLBinding binding = GrGLGetBindingInUseFromString(ver);
+
+        if (0 != binding && interface->validate(binding) && fExtensions.init(binding, interface)) {
+            fBindingInUse = binding;
+
+            fGLVersion = GrGLGetVersionFromString(ver);
+
+            fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface);
+
+            fVendor = GrGLGetVendor(interface);
+            fGLCaps.init(*this, interface);
+            return true;
+        }
+    }
+    return false;
+}
+
+bool GrGLContextInfo::isInitialized() const {
+    return kNone_GrGLBinding != fBindingInUse;    
+}
+
+void GrGLContextInfo::reset() {
+    fBindingInUse = kNone_GrGLBinding;
+    fGLVersion = GR_GL_VER(0, 0);
+    fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
+    fVendor = kOther_GrGLVendor;
+    fExtensions.reset();
+    fGLCaps.reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+GrGLContext::GrGLContext(const GrGLInterface* interface) {
+    fInterface = NULL;
+    this->initialize(interface);
+}
+
+GrGLContext::GrGLContext(const GrGLContext& ctx) {
+    fInterface = NULL;
+    *this = ctx;
+}
+
+GrGLContext& GrGLContext::operator = (const GrGLContext& ctx) {
+    GrSafeAssign(fInterface, ctx.fInterface);
+    fInfo = ctx.fInfo;
+    return *this;
+}
+
+void GrGLContext::reset() {
+    GrSafeSetNull(fInterface);
+    fInfo.reset();
+}
+
+bool GrGLContext::initialize(const GrGLInterface* interface) {
+    if (fInfo.initialize(interface)) {
+        fInterface = interface;
+        interface->ref();
+        return true;
+    }
+    return false;
+}
diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h
new file mode 100644 (file)
index 0000000..05647cc
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#ifndef GrGLContext_DEFINED
+#define GrGLContext_DEFINED
+
+#include "gl/GrGLExtensions.h"
+#include "gl/GrGLInterface.h"
+#include "GrGLCaps.h"
+#include "GrGLSL.h"
+#include "GrGLUtil.h"
+
+#include "SkString.h"
+
+/**
+ * Encapsulates information about an OpenGL context including the OpenGL 
+ * version, the GrGLBinding type of the context, and GLSL version.
+ */
+class GrGLContextInfo {
+public:
+    /**
+     * Default constructor
+     */
+    GrGLContextInfo() { this->reset(); }
+
+    /**
+     * Copies a GrGLContextInfo
+     */
+    GrGLContextInfo& operator= (const GrGLContextInfo& ctxInfo);
+    
+    /**
+     * Initializes a GrGLContextInfo from a GrGLInterface and the currently
+     * bound OpenGL context accessible by the GrGLInterface.
+     */
+    bool initialize(const GrGLInterface* interface);
+    bool isInitialized() const;
+
+    GrGLBinding binding() const { return fBindingInUse; }
+    GrGLVersion version() const { return fGLVersion; }
+    GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
+    GrGLVendor vendor() const { return fVendor; }
+    const GrGLCaps& caps() const { return fGLCaps; }
+    GrGLCaps& caps() { return fGLCaps; }
+
+    /**
+     * Checks for extension support using a cached copy of the GL_EXTENSIONS
+     * string.
+     */
+    bool hasExtension(const char* ext) const {
+        if (!this->isInitialized()) {
+            return false;
+        }
+        return fExtensions.has(ext);
+    }
+
+    /**
+     * Reset the information
+     */
+    void reset();
+
+private:
+
+    GrGLBinding          fBindingInUse;
+    GrGLVersion          fGLVersion;
+    GrGLSLGeneration     fGLSLGeneration;
+    GrGLVendor           fVendor;
+    GrGLExtensions       fExtensions;
+    GrGLCaps             fGLCaps;
+};
+
+/**
+ * Encapsulates the GrGLInterface used to make GL calls plus information
+ * about the context (via GrGLContextInfo).
+ */
+class GrGLContext {
+public:
+    /**
+     * Default constructor
+     */
+    GrGLContext() { this->reset(); }
+
+    /**
+     * Creates a GrGLContext from a GrGLInterface and the currently
+     * bound OpenGL context accessible by the GrGLInterface.
+     */
+    explicit GrGLContext(const GrGLInterface* interface);
+
+    /**
+     * Copies a GrGLContext
+     */
+    GrGLContext(const GrGLContext& ctx);
+
+    ~GrGLContext() { GrSafeUnref(fInterface); }
+
+    /**
+     * Copies a GrGLContext
+     */
+    GrGLContext& operator= (const GrGLContext& ctx);
+
+    /**
+     * Initializes a GrGLContext from a GrGLInterface and the currently
+     * bound OpenGL context accessible by the GrGLInterface.
+     */
+    bool initialize(const GrGLInterface* interface);
+    bool isInitialized() const { return fInfo.isInitialized(); }
+
+    const GrGLInterface* interface() const { return fInterface; }
+    const GrGLContextInfo& info() const { return fInfo; }
+    GrGLContextInfo& info() { return fInfo; }
+
+private:
+    void reset();
+
+    const GrGLInterface* fInterface;
+    GrGLContextInfo      fInfo;
+};
+
+#endif
diff --git a/src/gpu/gl/GrGLContextInfo.cpp b/src/gpu/gl/GrGLContextInfo.cpp
deleted file mode 100644 (file)
index 1522618..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrGLContextInfo.h"
-
-GrGLContextInfo::~GrGLContextInfo() {
-    GrSafeUnref(fInterface);
-}
-
-GrGLContextInfo::GrGLContextInfo() {
-    this->reset();
-}
-
-GrGLContextInfo::GrGLContextInfo(const GrGLInterface* interface) {
-    fInterface = NULL;
-    this->initialize(interface);
-}
-
-GrGLContextInfo::GrGLContextInfo(const GrGLContextInfo& ctx) {
-    fInterface = NULL;
-    *this = ctx;
-}
-
-GrGLContextInfo& GrGLContextInfo::operator = (const GrGLContextInfo& ctx) {
-    GrSafeAssign(fInterface, ctx.fInterface);
-    fBindingInUse = ctx.fBindingInUse;
-    fGLVersion = ctx.fGLVersion;
-    fGLSLGeneration = ctx.fGLSLGeneration;
-    fVendor = ctx.fVendor;
-    fExtensions = ctx.fExtensions;
-    fGLCaps = ctx.fGLCaps;
-    return *this;
-}
-
-void GrGLContextInfo::reset() {
-    GrSafeSetNull(fInterface);
-    fBindingInUse = kNone_GrGLBinding;
-    fGLVersion = GR_GL_VER(0, 0);
-    fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
-    fVendor = kOther_GrGLVendor;
-    fExtensions.reset();
-    fGLCaps.reset();
-}
-
-bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
-    this->reset();
-    // We haven't validated the GrGLInterface yet, so check for GetString
-    // function pointer
-    if (interface->fGetString) {
-        const GrGLubyte* verUByte;
-        GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION));
-        const char* ver = reinterpret_cast<const char*>(verUByte);
-        GrGLBinding binding = GrGLGetBindingInUseFromString(ver);
-
-        if (0 != binding && interface->validate(binding) && fExtensions.init(binding, interface)) {
-
-            fInterface = interface;
-            interface->ref();
-
-            fBindingInUse = binding;
-
-            fGLVersion = GrGLGetVersionFromString(ver);
-
-            fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse,
-                                                  this->interface());
-
-            fVendor = GrGLGetVendor(interface);
-            fGLCaps.init(*this);
-            return true;
-        }
-    }
-    return false;
-}
-
-bool GrGLContextInfo::isInitialized() const {
-    return kNone_GrGLBinding != fBindingInUse;
-}
diff --git a/src/gpu/gl/GrGLContextInfo.h b/src/gpu/gl/GrGLContextInfo.h
deleted file mode 100644 (file)
index bfadabe..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef GrGLContextInfo_DEFINED
-#define GrGLContextInfo_DEFINED
-
-#include "gl/GrGLExtensions.h"
-#include "gl/GrGLInterface.h"
-#include "GrGLCaps.h"
-#include "GrGLSL.h"
-#include "GrGLUtil.h"
-
-#include "SkString.h"
-
-/**
- * Encapsulates information about an OpenGL context including the GrGLInterface
- * used to make GL calls, the OpenGL version, the GrGLBinding type of the
- * context, and GLSL version.
- */
-class GrGLContextInfo {
-public:
-
-    /**
-     * Default constructor, creates an uninitialized GrGLContextInfo
-     */
-    GrGLContextInfo();
-
-    /**
-     * Creates a GrGLContextInfo from a GrGLInterface and the currently
-     * bound OpenGL context accessible by the GrGLInterface.
-     */
-    explicit GrGLContextInfo(const GrGLInterface* interface);
-
-    /**
-     * Copies a GrGLContextInfo
-     */
-    GrGLContextInfo(const GrGLContextInfo& ctx);
-
-    ~GrGLContextInfo();
-
-    /**
-     * Copies a GrGLContextInfo
-     */
-    GrGLContextInfo& operator = (const GrGLContextInfo& ctx);
-
-    /**
-     * Initializes a GrGLContextInfo from a GrGLInterface and the currently
-     * bound OpenGL context accessible by the GrGLInterface.
-     */
-    bool initialize(const GrGLInterface* interface);
-    bool isInitialized() const;
-
-    const GrGLInterface* interface() const { return fInterface; }
-    GrGLBinding binding() const { return fBindingInUse; }
-    GrGLVersion version() const { return fGLVersion; }
-    GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
-    GrGLVendor vendor() const { return fVendor; }
-    const GrGLCaps& caps() const { return fGLCaps; }
-    GrGLCaps& caps() { return fGLCaps; }
-
-    /**
-     * Checks for extension support using a cached copy of the GL_EXTENSIONS
-     * string.
-     */
-    bool hasExtension(const char* ext) const {
-        if (!this->isInitialized()) {
-            return false;
-        }
-        return fExtensions.has(ext);
-    }
-
-private:
-    void reset();
-
-    const GrGLInterface* fInterface;
-    GrGLBinding          fBindingInUse;
-    GrGLVersion          fGLVersion;
-    GrGLSLGeneration     fGLSLGeneration;
-    GrGLVendor           fVendor;
-    GrGLExtensions       fExtensions;
-    GrGLCaps             fGLCaps;
-};
-
-#endif
index eb493257f3725f86066f000aeda9ca62226169a5..781e15fdde34f7d9418180f48a2fe83d2988060c 100644 (file)
@@ -20,8 +20,8 @@
 
 SK_DEFINE_INST_COUNT(GrGLProgram)
 
-#define GL_CALL(X) GR_GL_CALL(fContextInfo.interface(), X)
-#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContextInfo.interface(), R, X)
+#define GL_CALL(X) GR_GL_CALL(fContext.interface(), X)
+#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContext.interface(), R, X)
 
 SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, "Print the source code for all shaders generated.");
 
@@ -229,7 +229,7 @@ void GrGLProgram::BuildDesc(const GrDrawState& drawState,
 #endif
 }
 
-GrGLProgram* GrGLProgram::Create(const GrGLContextInfo& gl,
+GrGLProgram* GrGLProgram::Create(const GrGLContext& gl,
                                  const Desc& desc,
                                  const GrEffectStage* stages[]) {
     GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, stages));
@@ -240,10 +240,10 @@ GrGLProgram* GrGLProgram::Create(const GrGLContextInfo& gl,
     return program;
 }
 
-GrGLProgram::GrGLProgram(const GrGLContextInfo& gl,
+GrGLProgram::GrGLProgram(const GrGLContext& gl,
                          const Desc& desc,
                          const GrEffectStage* stages[])
-: fContextInfo(gl)
+: fContext(gl)
 , fUniformManager(gl) {
     fDesc = desc;
     fVShaderID = 0;
@@ -438,7 +438,7 @@ bool GrGLProgram::genEdgeCoverage(SkString* coverageVar,
             builder->fFSCode.appendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
             builder->fFSCode.append("\t\tedgeAlpha = clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);\n"
                                     "\t}\n");
-            if (kES2_GrGLBinding == fContextInfo.binding()) {
+            if (kES2_GrGLBinding == fContext.info().binding()) {
                 builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
             }
             break;
@@ -451,7 +451,7 @@ bool GrGLProgram::genEdgeCoverage(SkString* coverageVar,
             builder->fFSCode.appendf("\tfloat edgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
             builder->fFSCode.append("\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / dot(gF, gF));\n");
             builder->fFSCode.append("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
-            if (kES2_GrGLBinding == fContextInfo.binding()) {
+            if (kES2_GrGLBinding == fContext.info().binding()) {
                 builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
             }
             break;
@@ -548,7 +548,7 @@ void gen_attribute_coverage(GrGLShaderBuilder* segments,
 void GrGLProgram::genGeometryShader(GrGLShaderBuilder* segments) const {
 #if GR_GL_EXPERIMENTAL_GS
     if (fDesc.fExperimentalGS) {
-        GrAssert(fContextInfo.glslGeneration() >= k150_GrGLSLGeneration);
+        GrAssert(fContext.info().glslGeneration() >= k150_GrGLSLGeneration);
         segments->fGSHeader.append("layout(triangles) in;\n"
                                    "layout(triangle_strip, max_vertices = 6) out;\n");
         segments->fGSCode.append("\tfor (int i = 0; i < 3; ++i) {\n"
@@ -597,7 +597,7 @@ void print_shader(GrGLint stringCnt,
 }
 
 // Compiles a GL shader, returns shader ID or 0 if failed params have same meaning as glShaderSource
-GrGLuint compile_shader(const GrGLContextInfo& gl,
+GrGLuint compile_shader(const GrGLContext& gl,
                         GrGLenum type,
                         int stringCnt,
                         const char** strings,
@@ -638,7 +638,7 @@ GrGLuint compile_shader(const GrGLContextInfo& gl,
 }
 
 // helper version of above for when shader is already flattened into a single SkString
-GrGLuint compile_shader(const GrGLContextInfo& gl, GrGLenum type, const SkString& shader) {
+GrGLuint compile_shader(const GrGLContext& gl, GrGLenum type, const SkString& shader) {
     const GrGLchar* str = shader.c_str();
     int length = shader.size();
     return compile_shader(gl, type, 1, &str, &length);
@@ -657,7 +657,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
         GrPrintf("\n");
     }
 
-    if (!(fVShaderID = compile_shader(fContextInfo, GR_GL_VERTEX_SHADER, shader))) {
+    if (!(fVShaderID = compile_shader(fContext, GR_GL_VERTEX_SHADER, shader))) {
         return false;
     }
 
@@ -667,7 +667,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
             GrPrintf(shader.c_str());
             GrPrintf("\n");
         }
-        if (!(fGShaderID = compile_shader(fContextInfo, GR_GL_GEOMETRY_SHADER, shader))) {
+        if (!(fGShaderID = compile_shader(fContext, GR_GL_GEOMETRY_SHADER, shader))) {
             return false;
         }
     } else {
@@ -679,7 +679,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
         GrPrintf(shader.c_str());
         GrPrintf("\n");
     }
-    if (!(fFShaderID = compile_shader(fContextInfo, GR_GL_FRAGMENT_SHADER, shader))) {
+    if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader))) {
         return false;
     }
 
@@ -689,7 +689,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
 bool GrGLProgram::genProgram(const GrEffectStage* stages[]) {
     GrAssert(0 == fProgramID);
 
-    GrGLShaderBuilder builder(fContextInfo, fUniformManager);
+    GrGLShaderBuilder builder(fContext.info(), fUniformManager);
     const GrAttribBindings& attribBindings = fDesc.fAttribBindings;
 
 #if GR_GL_EXPERIMENTAL_GS
@@ -738,11 +738,11 @@ bool GrGLProgram::genProgram(const GrEffectStage* stages[]) {
     // the dual source output has no canonical var name, have to
     // declare an output, which is incompatible with gl_FragColor/gl_FragData.
     bool dualSourceOutputWritten = false;
-    builder.fHeader.append(GrGetGLSLVersionDecl(fContextInfo.binding(),
-                                                fContextInfo.glslGeneration()));
+    builder.fHeader.append(GrGetGLSLVersionDecl(fContext.info().binding(),
+                                                fContext.info().glslGeneration()));
 
     GrGLShaderVar colorOutput;
-    bool isColorDeclared = GrGLSLSetupFSColorOuput(fContextInfo.glslGeneration(),
+    bool isColorDeclared = GrGLSLSetupFSColorOuput(fContext.info().glslGeneration(),
                                                    declared_color_output_name(),
                                                    &colorOutput);
     if (isColorDeclared) {
index ea39fa8e5390648a1368b5f9f20732c07ec0facb..cde918b54b1d17cfbb5b3e4cf8fe5a5bf6e14cd7 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "GrDrawState.h"
 #include "GrGLEffect.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
 #include "GrGLSL.h"
 #include "GrGLTexture.h"
 #include "GrGLUniformManager.h"
@@ -55,7 +55,7 @@ public:
                           const GrGpuGL* gpu,
                           Desc* outDesc);
 
-    static GrGLProgram* Create(const GrGLContextInfo& gl,
+    static GrGLProgram* Create(const GrGLContext& gl,
                                const Desc& desc,
                                const GrEffectStage* stages[]);
 
@@ -206,7 +206,7 @@ public:
     static const AttribLayout kAttribLayouts[kGrVertexAttribTypeCount];
 
 private:
-    GrGLProgram(const GrGLContextInfo& gl,
+    GrGLProgram(const GrGLContext& gl,
                 const Desc& desc,
                 const GrEffectStage* stages[]);
 
@@ -290,7 +290,7 @@ private:
     GrGLEffect*                 fEffects[GrDrawState::kNumStages];
 
     Desc                        fDesc;
-    const GrGLContextInfo&      fContextInfo;
+    const GrGLContext&          fContext;
 
     GrGLUniformManager          fUniformManager;
     UniformHandles              fUniformHandles;
index 1618fe54164ec13126088f17c3f4b86269809d22..aa3505cba51a02f338caf4ff33dce7acb0d05d40 100644 (file)
@@ -81,7 +81,8 @@ void append_swizzle(SkString* outAppend,
 // varying by stage, if we use 1D textures for gradients!
 //const int GrGLShaderBuilder::fCoordDims = 2;
 
-GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctx, GrGLUniformManager& uniformManager)
+GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, 
+                                     GrGLUniformManager& uniformManager)
     : fUniforms(kVarsPerBlock)
     , fVSAttrs(kVarsPerBlock)
     , fVSOutputs(kVarsPerBlock)
@@ -90,7 +91,7 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctx, GrGLUniformMana
     , fFSInputs(kVarsPerBlock)
     , fFSOutputs(kMaxFSOutputs)
     , fUsesGS(false)
-    , fContext(ctx)
+    , fCtxInfo(ctxInfo)
     , fUniformManager(uniformManager)
     , fCurrentStageIdx(kNonStageIdx)
     , fSetupFragPosition(false)
@@ -111,7 +112,7 @@ void GrGLShaderBuilder::appendTextureLookup(SkString* out,
                  sample_function_name(varyingType),
                  this->getUniformCStr(sampler.fSamplerUniform),
                  coordName);
-    append_swizzle(out, *sampler.textureAccess(), fContext.caps());
+    append_swizzle(out, *sampler.textureAccess(), fCtxInfo.caps());
 }
 
 void GrGLShaderBuilder::appendTextureLookupAndModulate(
@@ -261,7 +262,7 @@ void GrGLShaderBuilder::addVarying(GrSLType type,
 
 const char* GrGLShaderBuilder::fragmentPosition() {
 #if 1
-    if (fContext.caps().fragCoordConventionsSupport()) {
+    if (fCtxInfo.caps().fragCoordConventionsSupport()) {
         if (!fSetupFragPosition) {
             fFSHeader.append("#extension GL_ARB_fragment_coord_conventions: require\n");
             fFSInputs.push_back().set(kVec4f_GrSLType,
@@ -327,7 +328,7 @@ void GrGLShaderBuilder::emitFunction(ShaderType shader,
     fFSFunctions.append(*outName);
     fFSFunctions.append("(");
     for (int i = 0; i < argCnt; ++i) {
-        args[i].appendDecl(fContext, &fFSFunctions);
+        args[i].appendDecl(fCtxInfo, &fFSFunctions);
         if (i < argCnt - 1) {
             fFSFunctions.append(", ");
         }
@@ -365,7 +366,7 @@ inline void append_default_precision_qualifier(GrGLShaderVar::Precision p,
 
 void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
     for (int i = 0; i < vars.count(); ++i) {
-        vars[i].appendDecl(fContext, out);
+        vars[i].appendDecl(fCtxInfo, out);
         out->append(";\n");
     }
 }
@@ -373,7 +374,7 @@ void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
 void GrGLShaderBuilder::appendUniformDecls(ShaderType stype, SkString* out) const {
     for (int i = 0; i < fUniforms.count(); ++i) {
         if (fUniforms[i].fVisibility & stype) {
-            fUniforms[i].fVariable.appendDecl(fContext, out);
+            fUniforms[i].fVariable.appendDecl(fCtxInfo, out);
             out->append(";\n");
         }
     }
@@ -406,13 +407,13 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
         case kFragment_ShaderType:
             *shaderStr = fHeader;
             append_default_precision_qualifier(kDefaultFragmentPrecision,
-                                               fContext.binding(),
+                                               fCtxInfo.binding(),
                                                shaderStr);
             shaderStr->append(fFSHeader);
             this->appendUniformDecls(kFragment_ShaderType, shaderStr);
             this->appendDecls(fFSInputs, shaderStr);
             // We shouldn't have declared outputs on 1.10
-            GrAssert(k110_GrGLSLGeneration != fContext.glslGeneration() || fFSOutputs.empty());
+            GrAssert(k110_GrGLSLGeneration != fCtxInfo.glslGeneration() || fFSOutputs.empty());
             this->appendDecls(fFSOutputs, shaderStr);
             shaderStr->append(fFSFunctions);
             shaderStr->append("void main() {\n");
index 87136cdf530a4a4a8840e86abe501c440639e3da..d50fbce9c8e566fb4b117c751aab499b253c0254 100644 (file)
@@ -217,7 +217,7 @@ private:
         kNonStageIdx = -1,
     };
 
-    const GrGLContextInfo&              fContext;
+    const GrGLContextInfo&              fCtxInfo;
     GrGLUniformManager&                 fUniformManager;
     int                                 fCurrentStageIdx;
     SkString                            fFSFunctions;
index 89fa087460a6c928889ff56bc403ba780419d9a6..ecf0b479ae778f6b43f13c4d6e94ac9080d12e62 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef GrGLShaderVar_DEFINED
 #define GrGLShaderVar_DEFINED
 
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
 #include "GrGLSL.h"
 #include "SkString.h"
 
@@ -252,7 +252,7 @@ public:
     /**
      * Write a declaration of this variable to out.
      */
-    void appendDecl(const GrGLContextInfo& gl, SkString* out) const {
+    void appendDecl(const GrGLContextInfo& ctxInfo, SkString* out) const {
         if (kUpperLeft_Origin == fOrigin) {
             // this is the only place where we specify a layout modifier. If we use other layout
             // modifiers in the future then they should be placed in a list.
@@ -260,10 +260,10 @@ public:
         }
         if (this->getTypeModifier() != kNone_TypeModifier) {
            out->append(TypeModifierString(this->getTypeModifier(),
-                                          gl.glslGeneration()));
+                                          ctxInfo.glslGeneration()));
            out->append(" ");
         }
-        out->append(PrecisionString(fPrecision, gl.binding()));
+        out->append(PrecisionString(fPrecision, ctxInfo.binding()));
         GrSLType effectiveType = this->getType();
         if (this->isArray()) {
             if (this->isUnsizedArray()) {
index 8f435d3037ed456707602cec64382a0d3f2b2d23..ee693a6a5bba7d8554416a07f5b43b9e9c3504a7 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "SkTArray.h"
 
-class GrGLContextInfo;
+class GrGLContext;
 class SkMatrix;
 
 /** Manages a program's uniforms.
@@ -25,7 +25,7 @@ public:
     typedef int UniformHandle;
     static const UniformHandle kInvalidUniformHandle = 0;
 
-    GrGLUniformManager(const GrGLContextInfo& context) : fContext(context) {}
+    GrGLUniformManager(const GrGLContext& context) : fContext(context) {}
 
     UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::kNonArray);
 
@@ -78,7 +78,7 @@ private:
     };
 
     SkTArray<Uniform, true> fUniforms;
-    const GrGLContextInfo&  fContext;
+    const GrGLContext&  fContext;
 };
 
 #endif
index 92bac03b8a173d409c272f8ee89fbe6a6cb726c1..8ea7e5cde4f46db98af6eb1e3ab3d4283fe9eafe 100644 (file)
@@ -147,17 +147,17 @@ static bool fbo_test(const GrGLInterface* gl, int w, int h) {
     return status == GR_GL_FRAMEBUFFER_COMPLETE;
 }
 
-GrGpuGL::GrGpuGL(const GrGLContextInfo& ctxInfo, GrContext* context)
+GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context)
     : GrGpu(context)
-    , fGLContextInfo(ctxInfo) {
+    , fGLContext(ctx) {
 
-    GrAssert(ctxInfo.isInitialized());
+    GrAssert(ctx.isInitialized());
 
     fillInConfigRenderableTable();
 
     fPrintedCaps = false;
 
-    GrGLClearErr(fGLContextInfo.interface());
+    GrGLClearErr(fGLContext.interface());
 
     if (gPrintStartupSpew) {
         const GrGLubyte* ext;
@@ -178,7 +178,7 @@ GrGpuGL::GrGpuGL(const GrGLContextInfo& ctxInfo, GrContext* context)
 
     this->initCaps();
 
-    fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContextInfo()));
+    fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext()));
 
     fHWGeometryState.setMaxAttribArrays(this->glCaps().maxVertexAttributes());
 
@@ -827,34 +827,34 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc,
 }
 
 namespace {
-bool renderbuffer_storage_msaa(GrGLContextInfo& ctxInfo,
+bool renderbuffer_storage_msaa(GrGLContext& ctx,
                                int sampleCount,
                                GrGLenum format,
                                int width, int height) {
-    CLEAR_ERROR_BEFORE_ALLOC(ctxInfo.interface());
-    GrAssert(GrGLCaps::kNone_MSFBOType != ctxInfo.caps().msFBOType());
+    CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
+    GrAssert(GrGLCaps::kNone_MSFBOType != ctx.info().caps().msFBOType());
     bool created = false;
     if (GrGLCaps::kNVDesktop_CoverageAAType ==
-        ctxInfo.caps().coverageAAType()) {
+        ctx.info().caps().coverageAAType()) {
         const GrGLCaps::MSAACoverageMode& mode =
-            ctxInfo.caps().getMSAACoverageMode(sampleCount);
-        GL_ALLOC_CALL(ctxInfo.interface(),
+            ctx.info().caps().getMSAACoverageMode(sampleCount);
+        GL_ALLOC_CALL(ctx.interface(),
                       RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER,
                                                         mode.fCoverageSampleCnt,
                                                         mode.fColorSampleCnt,
                                                         format,
                                                         width, height));
-        created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctxInfo.interface()));
+        created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
     }
     if (!created) {
         // glRBMS will fail if requested samples is > max samples.
-        sampleCount = GrMin(sampleCount, ctxInfo.caps().maxSampleCount());
-        GL_ALLOC_CALL(ctxInfo.interface(),
+        sampleCount = GrMin(sampleCount, ctx.info().caps().maxSampleCount());
+        GL_ALLOC_CALL(ctx.interface(),
                       RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
                                                      sampleCount,
                                                      format,
                                                      width, height));
-        created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctxInfo.interface()));
+        created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
     }
     return created;
 }
@@ -904,7 +904,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
         GrAssert(desc->fSampleCnt > 0);
         GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER,
                                desc->fMSColorRenderbufferID));
-        if (!renderbuffer_storage_msaa(fGLContextInfo,
+        if (!renderbuffer_storage_msaa(fGLContext,
                                        desc->fSampleCnt,
                                        msColorFormat,
                                        width, height)) {
@@ -920,7 +920,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
             if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
                 goto FAILED;
             }
-            fGLContextInfo.caps().markConfigAsValidColorAttachment(
+            fGLContext.info().caps().markConfigAsValidColorAttachment(
                                                                 desc->fConfig);
         }
     }
@@ -935,7 +935,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
         if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
             goto FAILED;
         }
-        fGLContextInfo.caps().markConfigAsValidColorAttachment(desc->fConfig);
+        fGLContext.info().caps().markConfigAsValidColorAttachment(desc->fConfig);
     }
 
     return true;
@@ -1131,7 +1131,7 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
         // version on a GL that doesn't have an MSAA extension.
         bool created;
         if (samples > 0) {
-            created = renderbuffer_storage_msaa(fGLContextInfo,
+            created = renderbuffer_storage_msaa(fGLContext,
                                                 samples,
                                                 sFmt.fInternalFormat,
                                                 width, height);
@@ -1220,7 +1220,7 @@ bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb,
                 }
                 return false;
             } else {
-                fGLContextInfo.caps().markColorConfigAndStencilFormatAsVerified(
+                fGLContext.info().caps().markColorConfigAndStencilFormatAsVerified(
                     rt->config(),
                     glsb->format());
             }
index b47865cba77fb946418442f94eca63c8875a0efb..a859d1859598145c5bfe01603259c7102ae67782 100644 (file)
@@ -13,7 +13,7 @@
 #include "GrBinHashKey.h"
 #include "GrDrawState.h"
 #include "GrGpu.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
 #include "GrGLIndexBuffer.h"
 #include "GrGLIRect.h"
 #include "GrGLProgram.h"
 
 class GrGpuGL : public GrGpu {
 public:
-    GrGpuGL(const GrGLContextInfo& ctxInfo, GrContext* context);
+    GrGpuGL(const GrGLContext& ctx, GrContext* context);
     virtual ~GrGpuGL();
 
-    const GrGLInterface* glInterface() const {
-        return fGLContextInfo.interface();
-    }
-    GrGLBinding glBinding() const { return fGLContextInfo.binding(); }
-    GrGLVersion glVersion() const { return fGLContextInfo.version(); }
-    GrGLSLGeneration glslGeneration() const {
-        return fGLContextInfo.glslGeneration();
-    }
+    const GrGLInterface* glInterface() const { return fGLContext.interface(); }
+    GrGLBinding glBinding() const { return fGLContext.info().binding(); }
+    GrGLVersion glVersion() const { return fGLContext.info().version(); }
+    GrGLSLGeneration glslGeneration() const { return fGLContext.info().glslGeneration(); }
 
     // Used by GrGLProgram to bind necessary textures for GrGLEffects.
     void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture);
@@ -55,7 +51,7 @@ public:
 
     virtual void abandonResources() SK_OVERRIDE;
 
-    const GrGLCaps& glCaps() const { return fGLContextInfo.caps(); }
+    const GrGLCaps& glCaps() const { return fGLContext.info().caps(); }
 
     // Callbacks to update state tracking when related GL objects are bound or deleted
     void notifyVertexBufferBind(GrGLuint id);
@@ -137,17 +133,15 @@ private:
     // have been accounted for).
     void flushBlend(bool isLines, GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff);
 
-    bool hasExtension(const char* ext) const {
-        return fGLContextInfo.hasExtension(ext);
-    }
+    bool hasExtension(const char* ext) const { return fGLContext.info().hasExtension(ext); }
 
-    const GrGLContextInfo& glContextInfo() const { return fGLContextInfo; }
+    const GrGLContext& glContext() const { return fGLContext; }
 
     static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
 
     class ProgramCache : public ::GrNoncopyable {
     public:
-        ProgramCache(const GrGLContextInfo& gl);
+        ProgramCache(const GrGLContext& gl);
 
         void abandon();
         GrGLProgram* getProgram(const GrGLProgram::Desc& desc, const GrEffectStage* stages[]);
@@ -188,7 +182,7 @@ private:
         Entry                       fEntries[kMaxEntries];
         int                         fCount;
         unsigned int                fCurrLRUStamp;
-        const GrGLContextInfo&      fGL;
+        const GrGLContext&          fGL;
     };
 
     // sets the matrix for path stenciling (uses the GL fixed pipe matrices)
@@ -236,7 +230,7 @@ private:
 
     void fillInConfigRenderableTable();
 
-    GrGLContextInfo fGLContextInfo;
+    GrGLContext fGLContext;
 
     // GL program-related state
     ProgramCache*               fProgramCache;
index 8526100f9d6f1d816a9b120dc670a10fed2fee94..e5a71831ec278ccf5e82a19b02e0e541467e141e 100644 (file)
@@ -16,7 +16,7 @@ static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidU
 #define SKIP_CACHE_CHECK    true
 #define GR_UINT32_MAX   static_cast<uint32_t>(-1)
 
-GrGpuGL::ProgramCache::ProgramCache(const GrGLContextInfo& gl)
+GrGpuGL::ProgramCache::ProgramCache(const GrGLContext& gl)
     : fCount(0)
     , fCurrLRUStamp(0)
     , fGL(gl) {
diff --git a/src/gpu/gl/SkGLContext.cpp b/src/gpu/gl/SkGLContext.cpp
deleted file mode 100644 (file)
index 6076845..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "gl/SkGLContext.h"
-#include "GrGLUtil.h"
-
-SK_DEFINE_INST_COUNT(SkGLContext)
-
-SkGLContext::SkGLContext()
-    : fFBO(0)
-    , fColorBufferID(0)
-    , fDepthStencilBufferID(0)
-    , fGL(NULL) {
-}
-
-SkGLContext::~SkGLContext() {
-
-    if (fGL) {
-        // TODO: determine why DeleteFramebuffers is generating a GL error in tests
-        SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO));
-        SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fColorBufferID));
-        SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID));
-    }
-
-    SkSafeUnref(fGL);
-}
-
-bool SkGLContext::init(int width, int height) {
-    if (fGL) {
-        fGL->unref();
-        this->destroyGLContext();
-    }
-
-    fGL = this->createGLContext();
-    if (fGL) {
-        const GrGLubyte* temp;
-
-        GrGLBinding bindingInUse = GrGLGetBindingInUse(this->gl());
-
-        if (!fGL->validate(bindingInUse) || !fExtensions.init(bindingInUse, fGL)) {
-            fGL = NULL;
-            this->destroyGLContext();
-            return false;
-        }
-
-        SK_GL_RET(*this, temp, GetString(GR_GL_VERSION));
-        const char* versionStr = reinterpret_cast<const char*>(temp);
-        GrGLVersion version = GrGLGetVersionFromString(versionStr);
-
-        // clear any existing GL erorrs
-        GrGLenum error;
-        do {
-            SK_GL_RET(*this, error, GetError());
-        } while (GR_GL_NO_ERROR != error);
-
-        SK_GL(*this, GenFramebuffers(1, &fFBO));
-        SK_GL(*this, BindFramebuffer(GR_GL_FRAMEBUFFER, fFBO));
-        SK_GL(*this, GenRenderbuffers(1, &fColorBufferID));
-        SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fColorBufferID));
-        if (kES2_GrGLBinding == bindingInUse) {
-            SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
-                                             GR_GL_RGBA8,
-                                             width, height));
-        } else {
-            SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
-                                             GR_GL_RGBA,
-                                             width, height));
-        }
-        SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
-                                             GR_GL_COLOR_ATTACHMENT0,
-                                             GR_GL_RENDERBUFFER,
-                                             fColorBufferID));
-        SK_GL(*this, GenRenderbuffers(1, &fDepthStencilBufferID));
-        SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fDepthStencilBufferID));
-
-        // Some drivers that support packed depth stencil will only succeed
-        // in binding a packed format an FBO. However, we can't rely on packed
-        // depth stencil being available.
-        bool supportsPackedDepthStencil;
-        if (kES2_GrGLBinding == bindingInUse) {
-            supportsPackedDepthStencil = this->hasExtension("GL_OES_packed_depth_stencil");
-        } else {
-            supportsPackedDepthStencil = version >= GR_GL_VER(3,0) ||
-                                         this->hasExtension("GL_EXT_packed_depth_stencil") ||
-                                         this->hasExtension("GL_ARB_framebuffer_object");
-        }
-
-        if (supportsPackedDepthStencil) {
-            // ES2 requires sized internal formats for RenderbufferStorage
-            // On Desktop we let the driver decide.
-            GrGLenum format = kES2_GrGLBinding == bindingInUse ?
-                                    GR_GL_DEPTH24_STENCIL8 :
-                                    GR_GL_DEPTH_STENCIL;
-            SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
-                                             format,
-                                             width, height));
-            SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
-                                                 GR_GL_DEPTH_ATTACHMENT,
-                                                 GR_GL_RENDERBUFFER,
-                                                 fDepthStencilBufferID));
-        } else {
-            GrGLenum format = kES2_GrGLBinding == bindingInUse ?
-                                    GR_GL_STENCIL_INDEX8 :
-                                    GR_GL_STENCIL_INDEX;
-            SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
-                                             format,
-                                             width, height));
-        }
-        SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
-                                             GR_GL_STENCIL_ATTACHMENT,
-                                             GR_GL_RENDERBUFFER,
-                                             fDepthStencilBufferID));
-        SK_GL(*this, Viewport(0, 0, width, height));
-        SK_GL(*this, ClearStencil(0));
-        SK_GL(*this, Clear(GR_GL_STENCIL_BUFFER_BIT));
-
-        SK_GL_RET(*this, error, GetError());
-        GrGLenum status;
-        SK_GL_RET(*this, status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
-
-        if (GR_GL_FRAMEBUFFER_COMPLETE != status ||
-            GR_GL_NO_ERROR != error) {
-            fFBO = 0;
-            fColorBufferID = 0;
-            fDepthStencilBufferID = 0;
-            fGL->unref();
-            fGL = NULL;
-            this->destroyGLContext();
-            return false;
-        } else {
-            return true;
-        }
-    }
-    return false;
-}
diff --git a/src/gpu/gl/SkGLContextHelper.cpp b/src/gpu/gl/SkGLContextHelper.cpp
new file mode 100644 (file)
index 0000000..9dcc8ec
--- /dev/null
@@ -0,0 +1,139 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "gl/SkGLContextHelper.h"
+#include "GrGLUtil.h"
+
+SK_DEFINE_INST_COUNT(SkGLContextHelper)
+
+SkGLContextHelper::SkGLContextHelper()
+    : fFBO(0)
+    , fColorBufferID(0)
+    , fDepthStencilBufferID(0)
+    , fGL(NULL) {
+}
+
+SkGLContextHelper::~SkGLContextHelper() {
+
+    if (fGL) {
+        // TODO: determine why DeleteFramebuffers is generating a GL error in tests
+        SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO));
+        SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fColorBufferID));
+        SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID));
+    }
+
+    SkSafeUnref(fGL);
+}
+
+bool SkGLContextHelper::init(int width, int height) {
+    if (fGL) {
+        fGL->unref();
+        this->destroyGLContext();
+    }
+
+    fGL = this->createGLContext();
+    if (fGL) {
+        const GrGLubyte* temp;
+
+        GrGLBinding bindingInUse = GrGLGetBindingInUse(this->gl());
+
+        if (!fGL->validate(bindingInUse) || !fExtensions.init(bindingInUse, fGL)) {
+            fGL = NULL;
+            this->destroyGLContext();
+            return false;
+        }
+
+        SK_GL_RET(*this, temp, GetString(GR_GL_VERSION));
+        const char* versionStr = reinterpret_cast<const char*>(temp);
+        GrGLVersion version = GrGLGetVersionFromString(versionStr);
+
+        // clear any existing GL erorrs
+        GrGLenum error;
+        do {
+            SK_GL_RET(*this, error, GetError());
+        } while (GR_GL_NO_ERROR != error);
+
+        SK_GL(*this, GenFramebuffers(1, &fFBO));
+        SK_GL(*this, BindFramebuffer(GR_GL_FRAMEBUFFER, fFBO));
+        SK_GL(*this, GenRenderbuffers(1, &fColorBufferID));
+        SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fColorBufferID));
+        if (kES2_GrGLBinding == bindingInUse) {
+            SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
+                                             GR_GL_RGBA8,
+                                             width, height));
+        } else {
+            SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
+                                             GR_GL_RGBA,
+                                             width, height));
+        }
+        SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
+                                             GR_GL_COLOR_ATTACHMENT0,
+                                             GR_GL_RENDERBUFFER,
+                                             fColorBufferID));
+        SK_GL(*this, GenRenderbuffers(1, &fDepthStencilBufferID));
+        SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fDepthStencilBufferID));
+
+        // Some drivers that support packed depth stencil will only succeed
+        // in binding a packed format an FBO. However, we can't rely on packed
+        // depth stencil being available.
+        bool supportsPackedDepthStencil;
+        if (kES2_GrGLBinding == bindingInUse) {
+            supportsPackedDepthStencil = this->hasExtension("GL_OES_packed_depth_stencil");
+        } else {
+            supportsPackedDepthStencil = version >= GR_GL_VER(3,0) ||
+                                         this->hasExtension("GL_EXT_packed_depth_stencil") ||
+                                         this->hasExtension("GL_ARB_framebuffer_object");
+        }
+
+        if (supportsPackedDepthStencil) {
+            // ES2 requires sized internal formats for RenderbufferStorage
+            // On Desktop we let the driver decide.
+            GrGLenum format = kES2_GrGLBinding == bindingInUse ?
+                                    GR_GL_DEPTH24_STENCIL8 :
+                                    GR_GL_DEPTH_STENCIL;
+            SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
+                                             format,
+                                             width, height));
+            SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
+                                                 GR_GL_DEPTH_ATTACHMENT,
+                                                 GR_GL_RENDERBUFFER,
+                                                 fDepthStencilBufferID));
+        } else {
+            GrGLenum format = kES2_GrGLBinding == bindingInUse ?
+                                    GR_GL_STENCIL_INDEX8 :
+                                    GR_GL_STENCIL_INDEX;
+            SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
+                                             format,
+                                             width, height));
+        }
+        SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
+                                             GR_GL_STENCIL_ATTACHMENT,
+                                             GR_GL_RENDERBUFFER,
+                                             fDepthStencilBufferID));
+        SK_GL(*this, Viewport(0, 0, width, height));
+        SK_GL(*this, ClearStencil(0));
+        SK_GL(*this, Clear(GR_GL_STENCIL_BUFFER_BIT));
+
+        SK_GL_RET(*this, error, GetError());
+        GrGLenum status;
+        SK_GL_RET(*this, status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
+
+        if (GR_GL_FRAMEBUFFER_COMPLETE != status ||
+            GR_GL_NO_ERROR != error) {
+            fFBO = 0;
+            fColorBufferID = 0;
+            fDepthStencilBufferID = 0;
+            fGL->unref();
+            fGL = NULL;
+            this->destroyGLContext();
+            return false;
+        } else {
+            return true;
+        }
+    }
+    return false;
+}
index ab3501c14b83b54f6cefa205d33814916e047663..21a3d1bf71cc3493c974e71f07c4f45712d12ea0 100644 (file)
@@ -738,7 +738,7 @@ public:
     //      The solution to this is probably to alter SkDebugGlContext's
     //      "makeCurrent" method to make a call like "makeCurrent(this)" to
     //      the debug GL interface (assuming that the application will create
-    //      multiple SkGLContext's) to let it switch between the active
+    //      multiple SkGLContextHelper's) to let it switch between the active
     //      context. Everything in the GrDebugGL object would then need to be
     //      moved to a GrContextObj and the GrDebugGL object would just switch
     //      between them. Note that this approach would also require that
index 3c9af5c98f521775794521d9b11c33c653f3087a..45c5f2d16216a2319a743adaa11ddac147bc9436 100644 (file)
@@ -138,7 +138,7 @@ bool GrGpuGL::programUnitTest(int maxStages) {
         for (int s = 0; s < GrDrawState::kNumStages; ++s) {
             stagePtrs[s] = &stages[s];
         }
-        SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this->glContextInfo(),
+        SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this->glContext(),
                                                               pdesc,
                                                               stagePtrs));
         if (NULL == program.get()) {
index 3524a9d8f94236f63b7e1fd836920851537b4e29..d2d66378b618954d9a3f174a6279cf745cfd8eb4 100644 (file)
@@ -22,7 +22,6 @@
 
 class SkBitmap;
 class SkCanvas;
-class SkGLContext;
 class SkPDFDevice;
 
 namespace sk_tools {
index caab64a98dcc89f19b85a361f9c35ff9d438a420..ab5df5414ee9fe909e22fd632fc915068e6cc96a 100644 (file)
@@ -203,7 +203,7 @@ void PictureRenderer::buildBBoxHierarchy() {
 
 void PictureRenderer::resetState(bool callFinish) {
 #if SK_SUPPORT_GPU
-    SkGLContext* glContext = this->getGLContext();
+    SkGLContextHelper* glContext = this->getGLContext();
     if (NULL == glContext) {
         SkASSERT(kBitmap_DeviceType == fDeviceType);
         return;
index 47fc7d7a31f92faacbfece58e043fd439dda87bb..438488a66bd14db9c949d9692d1c9374106e7dbc 100644 (file)
@@ -29,7 +29,7 @@
 
 class SkBitmap;
 class SkCanvas;
-class SkGLContext;
+class SkGLContextHelper;
 class SkThread;
 
 namespace sk_tools {
@@ -228,7 +228,7 @@ public:
         }
     }
 
-    SkGLContext* getGLContext() {
+    SkGLContextHelper* getGLContext() {
         GrContextFactory::GLContextType glContextType
                 = GrContextFactory::kNull_GLContextType;
         switch(fDeviceType) {