Remove the compile-time selection of the GL implementation based on the
GR_SUPPORT_GLDESKTOP family of macros.
Support for the platform is configured dynamically, by querying the
fBindingsExported member of active GrGLInterface instance.
Review: http://codereview.appspot.com/4298048/
git-svn-id: http://skia.googlecode.com/svn/trunk@960 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrGLConfig.h b/gpu/include/GrGLConfig.h
index 3c1c597..8599b63 100644
--- a/gpu/include/GrGLConfig.h
+++ b/gpu/include/GrGLConfig.h
@@ -23,6 +23,16 @@
#include "GrGLDefines.h"
/**
+ * The following macros are used to staticlly configure the default
+ * GrGLInterface, but should not be used outside of the GrGLInterface
+ * scaffolding. Undefine here to prevent accidental use.
+ */
+#undef GR_SUPPORT_GLDESKTOP
+#undef GR_SUPPORT_GLES1
+#undef GR_SUPPORT_GLES2
+#undef GR_SUPPORT_GLES
+
+/**
* The following are optional defines that can be enabled at the compiler
* command line, in a IDE project, in a GrUserConfig.h file, or in a GL custom
* file (if one is in use). They don't require GR_GL_CUSTOM_SETUP or
@@ -158,19 +168,22 @@
#define GR_GL(X) GrGLGetGLInterface()->f##X;; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
#define GR_GL_NO_ERR(X) GrGLGetGLInterface()->f##X;; GR_GL_LOG_CALLS_IMPL(X); GR_GL_CHECK_ERROR_IMPL(X);
+#define GR_GL_SUPPORT_DESKTOP (kDesktop_GrGLBinding == GrGLGetGLInterface()->fBindingsExported)
+#define GR_GL_SUPPORT_ES1 (kES1_GrGLBinding == GrGLGetGLInterface()->fBindingsExported)
+#define GR_GL_SUPPORT_ES2 (kES2_GrGLBinding == GrGLGetGLInterface()->fBindingsExported)
+#define GR_GL_SUPPORT_ES (GR_GL_SUPPORT_ES1 || GR_GL_SUPPORT_ES2)
+
////////////////////////////////////////////////////////////////////////////////
/**
* GrGL_RestoreResetRowLength() will reset GL_UNPACK_ROW_LENGTH to 0. We write
* this wrapper, since GL_UNPACK_ROW_LENGTH is not available on all GL versions
*/
-#if GR_SUPPORT_GLDESKTOP
- static inline void GrGL_RestoreResetRowLength() {
+static inline void GrGL_RestoreResetRowLength() {
+ if (GR_GL_SUPPORT_DESKTOP) {
GR_GL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
}
-#else
- #define GrGL_RestoreResetRowLength()
-#endif
+}
////////////////////////////////////////////////////////////////////////////////
diff --git a/gpu/include/GrGLInterface.h b/gpu/include/GrGLInterface.h
index 7bee111..7a44f4f 100644
--- a/gpu/include/GrGLInterface.h
+++ b/gpu/include/GrGLInterface.h
@@ -63,6 +63,12 @@
typedef double GrGLclampd;
typedef void GrGLvoid;
+enum GrGLBinding {
+ kDesktop_GrGLBinding = 0x01,
+ kES1_GrGLBinding = 0x02,
+ kES2_GrGLBinding = 0x04
+};
+
extern "C" {
/*
* The following interface exports the OpenGL entry points used by the system.
@@ -178,6 +184,10 @@
typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target);
+ // Indicator variable specifying the type of GL implementation
+ // exported: GLES{1|2} or Desktop.
+ GrGLBinding fBindingsExported;
+
GrGLActiveTextureProc fActiveTexture;
GrGLAttachShaderProc fAttachShader;
GrGLBindAttribLocationProc fBindAttribLocation;
diff --git a/gpu/include/GrGLPlatformIncludes.h b/gpu/include/GrGLPlatformIncludes.h
index 54ae6bf..65e5281 100644
--- a/gpu/include/GrGLPlatformIncludes.h
+++ b/gpu/include/GrGLPlatformIncludes.h
@@ -63,7 +63,13 @@
* Alternatively, define GR_GL_CUSTOM_SETUP_HEADER (and not GR_GL_CUSTOM_SETUP)
* to a header that can be included. This file should:
* 1. Define the approprate GR_SUPPORT_GL* macro(s) to 1
- * 2. Includes all necessary GL headers.
+ * 2. Specify all of the necessary GL include headers in the following
+ * macros:
+ * GR_GL_PLATFORM_HEADER_SUPPORT: Header required before GL
+ * includes.
+ * GR_GL_PLATFORM_HEADER: GL header location.
+ * GR_GL_PLATFORM_HEADER_EXT: (Optional) Header for extension
+ * definitions.
* 3. Optionally define GR_GL_FUNCTION_TYPE.
* 4. Define GR_GL_PROC_ADDRESS.
* 5. Optionally define GR_GL_PROC_ADDRESS_HEADER
@@ -72,23 +78,23 @@
#if GR_GL_CUSTOM_SETUP
#ifdef GR_SUPPORT_GLES1
- #include GR_INCLUDE_GLES1
+ #define GR_GL_PLATFORM_HEADER GR_INCLUDE_GLES1
#if defined(GR_INCLUDE_GLES1ext)
- #include GR_INCLUDE_GLES1ext
+ #define GR_GL_PLATFORM_HEADER_EXT GR_INCLUDE_GLES1ext
#endif
#endif
#ifdef GR_SUPPORT_GLES2
- #include GR_INCLUDE_GLES2
+ #define GR_GL_PLATFORM_HEADER GR_INCLUDE_GLES2
#if defined(GR_INCLUDE_GLES2ext)
- #include GR_INCLUDE_GLES2ext
+ #define GR_GL_PLATFORM_HEADER_EXT GR_INCLUDE_GLES2ext
#endif
#endif
#ifdef GR_SUPPORT_GLDESKTOP
- #include GR_INCLUDE_GLDESKTOP
+ #define GR_GL_PLATFORM_HEADER GR_INCLUDE_GLDESKTOP
#if defined(GR_INCLUDE_GLDESKTOPext)
- #include GR_INCLUDE_GLDESKTOPext
+ #define GR_GL_PLATFORM_HEADER_EXT GR_INCLUDE_GLDESKTOPext
#endif
#endif
diff --git a/gpu/include/GrGLTexture.h b/gpu/include/GrGLTexture.h
index 0a1c107..1747b6d 100644
--- a/gpu/include/GrGLTexture.h
+++ b/gpu/include/GrGLTexture.h
@@ -210,7 +210,7 @@
GrGLRenderTarget* fRenderTarget;
GrGpuGL* fGpuGL;
- static const GrGLenum gWrapMode2GLWrap[];
+ static const GrGLenum* WrapMode2GLWrap();
friend class GrGpuGL;