Add tokens and entry points for KHR_blend_equation_advanced
authorcdalton <cdalton@nvidia.com>
Wed, 22 Apr 2015 17:39:03 +0000 (10:39 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 22 Apr 2015 17:39:03 +0000 (10:39 -0700)
Also adds glBlendEquation, which the extension interacts with, to the
core of GrGLInterface. Validation of this function is temporarily
disabled until Chrome hooks it up.

BUG=skia:

Review URL: https://codereview.chromium.org/1039693004

include/gpu/gl/GrGLFunctions.h
include/gpu/gl/GrGLInterface.h
src/gpu/gl/GrGLAssembleInterface.cpp
src/gpu/gl/GrGLCreateNullInterface.cpp
src/gpu/gl/GrGLDefines.h
src/gpu/gl/GrGLInterface.cpp
src/gpu/gl/GrGLNoOpInterface.cpp
src/gpu/gl/GrGLNoOpInterface.h
src/gpu/gl/SkNullGLContext.cpp
src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
src/gpu/gl/debug/GrGLCreateDebugInterface.cpp

index 3995ead79759d3859cadddd225c5d42f5bef3951..5c2cf7bc4d12eac192fd7977ff42663e66f6faf1 100644 (file)
@@ -72,10 +72,12 @@ extern "C" {
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindTextureProc)(GrGLenum target, GrGLuint texture);
-    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindFragDataLocationProc)(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBindVertexArrayProc)(GrGLuint array);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendBarrierProc)();
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendEquationProc)(GrGLenum mode);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBlitFramebufferProc)(GrGLint srcX0, GrGLint srcY0, GrGLint srcX1, GrGLint srcY1, GrGLint dstX0, GrGLint dstY0, GrGLint dstX1, GrGLint dstY1, GrGLbitfield mask, GrGLenum filter);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage);
index a96d2f404a14d94730c9804f7343b0e0496659f4..2e9ef6fea7d166bbcd779c2333a8eda8ffc96fa2 100644 (file)
@@ -156,7 +156,9 @@ public:
         GLPtr<GrGLBindRenderbufferProc> fBindRenderbuffer;
         GLPtr<GrGLBindTextureProc> fBindTexture;
         GLPtr<GrGLBindVertexArrayProc> fBindVertexArray;
+        GLPtr<GrGLBlendBarrierProc> fBlendBarrier;
         GLPtr<GrGLBlendColorProc> fBlendColor;
+        GLPtr<GrGLBlendEquationProc> fBlendEquation;
         GLPtr<GrGLBlendFuncProc> fBlendFunc;
         GLPtr<GrGLBlitFramebufferProc> fBlitFramebuffer;
         GLPtr<GrGLBufferDataProc> fBufferData;
index b0f0430ffb3e20bca1e0cbbe945fa8556f501499..89b21fdec3567169f6d93c73ebb75329d5cc0501 100644 (file)
@@ -70,14 +70,28 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
     }
     GET_PROC(BeginQuery);
     GET_PROC(BindTexture);
-    GET_PROC(BlendFunc);
+
+    if (extensions.has("GL_KHR_blend_equation_advanced")) {
+        GET_PROC_SUFFIX(BlendBarrier, KHR);
+    } else if (extensions.has("GL_NV_blend_equation_advanced")) {
+        GET_PROC_SUFFIX(BlendBarrier, NV);
+    }
 
     if (glVer >= GR_GL_VER(1,4) ||
-        extensions.has("GL_ARB_imaging") ||
-        extensions.has("GL_EXT_blend_color")) {
+        extensions.has("GL_ARB_imaging")) {
         GET_PROC(BlendColor);
+    } else if (extensions.has("GL_EXT_blend_color")) {
+        GET_PROC_SUFFIX(BlendColor, EXT);
+    }
+
+    if (glVer >= GR_GL_VER(1,4) ||
+        extensions.has("GL_ARB_imaging")) {
+        GET_PROC(BlendEquation);
+    } else if (extensions.has("GL_EXT_blend_subtract")) {
+        GET_PROC_SUFFIX(BlendEquation, EXT);
     }
 
+    GET_PROC(BlendFunc);
     GET_PROC(BufferData);
     GET_PROC(BufferSubData);
     GET_PROC(Clear);
@@ -341,7 +355,15 @@ const GrGLInterface* GrGLAssembleGLESInterface(void* ctx, GrGLGetProc get) {
     GET_PROC(BindBuffer);
     GET_PROC(BindTexture);
     GET_PROC_SUFFIX(BindVertexArray, OES);
+
+    if (extensions.has("GL_KHR_blend_equation_advanced")) {
+        GET_PROC_SUFFIX(BlendBarrier, KHR);
+    } else if (extensions.has("GL_NV_blend_equation_advanced")) {
+        GET_PROC_SUFFIX(BlendBarrier, NV);
+    }
+
     GET_PROC(BlendColor);
+    GET_PROC(BlendEquation);
     GET_PROC(BlendFunc);
     GET_PROC(BufferData);
     GET_PROC(BufferSubData);
index c86a0bd2fd87548f78b371f978525cf5f0fbf417..512c672a65fe1a397280f5b788e09fa44fe73150 100644 (file)
@@ -357,6 +357,7 @@ const GrGLInterface* GrGLCreateNullInterface() {
     functions->fBindTexture = nullGLBindTexture;
     functions->fBindVertexArray = nullGLBindVertexArray;
     functions->fBlendColor = noOpGLBlendColor;
+    functions->fBlendEquation = noOpGLBlendEquation;
     functions->fBlendFunc = noOpGLBlendFunc;
     functions->fBufferData = nullGLBufferData;
     functions->fBufferSubData = noOpGLBufferSubData;
index ae4050014ba902555a910fda37755bd582b7735a..511659c49211d639ef5402e309844afef1956f04 100644 (file)
 /*      GL_GEQUAL */
 /*      GL_ALWAYS */
 
+/* Basic OpenGL blend equations */
+#define GR_GL_FUNC_ADD                       0x8006
+#define GR_GL_FUNC_SUBTRACT                  0x800A
+#define GR_GL_FUNC_REVERSE_SUBTRACT          0x800B
+
+/* GL_KHR_blend_equation_advanced */
+#define GR_GL_SCREEN                         0x9295
+#define GR_GL_OVERLAY                        0x9296
+#define GR_GL_DARKEN                         0x9297
+#define GR_GL_LIGHTEN                        0x9298
+#define GR_GL_COLORDODGE                     0x9299
+#define GR_GL_COLORBURN                      0x929A
+#define GR_GL_HARDLIGHT                      0x929B
+#define GR_GL_SOFTLIGHT                      0x929C
+#define GR_GL_DIFFERENCE                     0x929E
+#define GR_GL_EXCLUSION                      0x92A0
+#define GR_GL_MULTIPLY                       0x9294
+#define GR_GL_HSL_HUE                        0x92AD
+#define GR_GL_HSL_SATURATION                 0x92AE
+#define GR_GL_HSL_COLOR                      0x92AF
+#define GR_GL_HSL_LUMINOSITY                 0x92B0
+
 /* BlendingFactorDest */
 #define GR_GL_ZERO                           0
 #define GR_GL_ONE                            1
index da1c3fc0e13b2d57207ea4f813248a2eb9d4978c..d134cd56c82df3962949f3b6bf37effc9bb5c76f 100644 (file)
@@ -114,8 +114,12 @@ bool GrGLInterface::validate() const {
         NULL == fFunctions.fBindAttribLocation ||
         NULL == fFunctions.fBindBuffer ||
         NULL == fFunctions.fBindTexture ||
+        NULL == fFunctions.fBlendColor ||      // -> GL >= 1.4 or extension, ES >= 2.0
+#if 0
+        // TODO: Re-enable validation for fBlendEquation when Chrome has it hooked up.
+        NULL == fFunctions.fBlendEquation ||   // -> GL >= 1.4 or extension, ES >= 2.0
+#endif
         NULL == fFunctions.fBlendFunc ||
-        NULL == fFunctions.fBlendColor ||      // -> GL >= 1.4, ES >= 2.0 or extension
         NULL == fFunctions.fBufferData ||
         NULL == fFunctions.fBufferSubData ||
         NULL == fFunctions.fClear ||
@@ -321,6 +325,13 @@ bool GrGLInterface::validate() const {
         }
     }
 
+    if (fExtensions.has("GL_KHR_blend_equation_advanced") ||
+        fExtensions.has("GL_NV_blend_equation_advanced")) {
+        if (NULL == fFunctions.fBlendBarrier) {
+            RETURN_FALSE_INTERFACE
+        }
+    }
+
     if (fExtensions.has("GL_EXT_discard_framebuffer")) {
 // FIXME: Remove this once Chromium is updated to provide this function
 #if 0
index 6b8880ed81c9c19ad1bf646438b4a88fa41e2ba1..f5880464557cc4e7f1e50c8715caffb962279a8f 100644 (file)
@@ -27,7 +27,6 @@ static const char* kExtensions[] = {
     "GL_ARB_timer_query",
     "GL_ARB_draw_buffers",
     "GL_ARB_occlusion_query",
-    "GL_EXT_blend_color",
     "GL_EXT_stencil_wrap"
 };
 
@@ -48,15 +47,18 @@ const GrGLubyte* combined_extensions_string() {
 }
 }
 
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocation(GrGLuint program,
+                                                        GrGLuint colorNumber,
+                                                        const GrGLchar* name) {
+}
+
 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendColor(GrGLclampf red,
                                               GrGLclampf green,
                                               GrGLclampf blue,
                                               GrGLclampf alpha) {
 }
 
-GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocation(GrGLuint program,
-                                                        GrGLuint colorNumber,
-                                                        const GrGLchar* name) {
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendEquation(GrGLenum mode) {
 }
 
 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendFunc(GrGLenum sfactor,
index c7bc9d8cbbd63d6b5423b0e23cee02fab19f211a..b803b46097652a140f47bb5e8607d644e1abeeaf 100644 (file)
 
 // These are constants/functions that are common to the Null and Debug GL interface implementations.
 
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocation(GrGLuint program,
+                                                        GrGLuint colorNumber,
+                                                        const GrGLchar* name);
+
 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendColor(GrGLclampf red,
                                               GrGLclampf green,
                                               GrGLclampf blue,
                                               GrGLclampf alpha);
 
-GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocation(GrGLuint program,
-                                                        GrGLuint colorNumber,
-                                                        const GrGLchar* name);
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendEquation(GrGLenum mode);
 
 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendFunc(GrGLenum sfactor,
                                              GrGLenum dfactor);
index 69b559629c77597e457c48ace718ee7a12686f19..cf07cb3ca260898d35ccafcc0cdc8ad04a5d1fe7 100644 (file)
@@ -360,6 +360,7 @@ static GrGLInterface* create_null_interface(State* state) {
     functions->fBindTexture = nullGLBindTexture;
     functions->fBindVertexArray = nullGLBindVertexArray;
     functions->fBlendColor = noOpGLBlendColor;
+    functions->fBlendEquation = noOpGLBlendEquation;
     functions->fBlendFunc = noOpGLBlendFunc;
     functions->fBufferData = nullGLBufferData;
     functions->fBufferSubData = noOpGLBufferSubData;
index 99219d0fd52ba53651c80a040aea20590841aeae..4569cc8f23f0e730687d26734c23bacc4d7bcb71 100644 (file)
@@ -30,6 +30,8 @@ static GrGLFuncPtr android_get_gl_proc(void* ctx, const char name[]) {
         return (GrGLFuncPtr) glBindTexture;
     } else if (0 == strcmp("glBlendColor", name)) {
         return (GrGLFuncPtr) glBlendColor;
+    } else if (0 == strcmp("glBlendEquation", name)) {
+        return (GrGLFuncPtr) glBlendEquation;
     } else if (0 == strcmp("glBlendFunc", name)) {
         return (GrGLFuncPtr) glBlendFunc;
     } else if (0 == strcmp("glBufferData", name)) {
index 4c2acc3fc4e50d292928b48d68eacfd6012be5b8..e60c519be372eacb8d051aedc04ac3e3f7f6a384 100644 (file)
@@ -850,6 +850,7 @@ const GrGLInterface* GrGLCreateDebugInterface() {
     functions->fBindTexture = debugGLBindTexture;
     functions->fBindVertexArray = debugGLBindVertexArray;
     functions->fBlendColor = noOpGLBlendColor;
+    functions->fBlendEquation = noOpGLBlendEquation;
     functions->fBlendFunc = noOpGLBlendFunc;
     functions->fBufferData = debugGLBufferData;
     functions->fBufferSubData = noOpGLBufferSubData;