Added glBlendEquation to GL interface

http://codereview.appspot.com/6057047/



git-svn-id: http://skia.googlecode.com/svn/trunk@3720 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h
index 876c072..4b76def 100644
--- a/include/gpu/gl/GrGLInterface.h
+++ b/include/gpu/gl/GrGLInterface.h
@@ -155,6 +155,7 @@
     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 *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);
@@ -318,6 +319,7 @@
     GLPtr<GrGLBindTextureProc> fBindTexture;
     GLPtr<GrGLBlendColorProc> fBlendColor;
     GLPtr<GrGLBlendFuncProc> fBlendFunc;
+    GLPtr<GrGLBlendEquationProc> fBlendEquation;
     GLPtr<GrGLBlitFramebufferProc> fBlitFramebuffer;
     GLPtr<GrGLBufferDataProc> fBufferData;
     GLPtr<GrGLBufferSubDataProc> fBufferSubData;
diff --git a/src/gpu/android/GrGLCreateNativeInterface_android.cpp b/src/gpu/android/GrGLCreateNativeInterface_android.cpp
index db629f2..41bcab8 100644
--- a/src/gpu/android/GrGLCreateNativeInterface_android.cpp
+++ b/src/gpu/android/GrGLCreateNativeInterface_android.cpp
@@ -26,6 +26,7 @@
         interface->fBindTexture = glBindTexture;
         interface->fBlendColor = glBlendColor;
         interface->fBlendFunc = glBlendFunc;
+        interface->fBlendEquation = glBlendEquation;
         interface->fBufferData = glBufferData;
         interface->fBufferSubData = glBufferSubData;
         interface->fClear = glClear;
diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp
index 5095079..7fd4d0d 100644
--- a/src/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/src/gpu/gl/GrGLCreateNullInterface.cpp
@@ -18,6 +18,7 @@
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBlendColor(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha) {}
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindFragDataLocation(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name) {}
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBlendFunc(GrGLenum sfactor, GrGLenum dfactor) {}
+GrGLvoid GR_GL_FUNCTION_TYPE nullGLBlendEquation(GrGLenum mode) {}
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferData(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage) {}
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferSubData(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data) {}
 GrGLvoid GR_GL_FUNCTION_TYPE nullGLClear(GrGLbitfield mask) {}
@@ -394,6 +395,7 @@
         interface->fBindTexture = nullGLBindTexture;
         interface->fBlendColor = nullGLBlendColor;
         interface->fBlendFunc = nullGLBlendFunc;
+        interface->fBlendEquation = nullGLBlendEquation;
         interface->fBufferData = nullGLBufferData;
         interface->fBufferSubData = nullGLBufferSubData;
         interface->fClear = nullGLClear;
diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp
index 39732db..57de3e0 100644
--- a/src/gpu/gl/GrGLInterface.cpp
+++ b/src/gpu/gl/GrGLInterface.cpp
@@ -174,6 +174,8 @@
         NULL == fBindBuffer ||
         NULL == fBindTexture ||
         NULL == fBlendFunc ||
+        NULL == fBlendColor ||      // -> GL >= 1.4, ES >= 2.0 or extension
+        NULL == fBlendEquation ||   // -> GL >= 1.4, ES >= 2.0 or extension
         NULL == fBufferData ||
         NULL == fBufferSubData ||
         NULL == fClear ||
@@ -270,13 +272,13 @@
     // On the desktop we assume they are available if the extension
     // is present or GL version is high enough.
     if (kES2_GrGLBinding == binding) {
-        if (NULL == fBlendColor ||
-            NULL == fStencilFuncSeparate ||
+        if (NULL == fStencilFuncSeparate ||
             NULL == fStencilMaskSeparate ||
             NULL == fStencilOpSeparate) {
             return false;
         }
     } else if (kDesktop_GrGLBinding == binding) {
+
         if (glVer >= GR_GL_VER(2,0)) {
             if (NULL == fStencilFuncSeparate ||
                 NULL == fStencilMaskSeparate ||
@@ -293,12 +295,7 @@
                 return false;
             }
         }
-        if (glVer >= GR_GL_VER(1,4) ||
-            GrGLHasExtensionFromString("GL_EXT_blend_color", ext)) {
-            if (NULL == fBlendColor) {
-                return false;
-            }
-        }
+
         if (glVer >= GR_GL_VER(1,5) ||
             GrGLHasExtensionFromString("GL_ARB_occlusion_query", ext)) {
             if (NULL == fGenQueries ||
diff --git a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
index 8cc7ad5..19c4532 100644
--- a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
+++ b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
@@ -46,6 +46,7 @@
         GR_GET_PROC(GrGLBindTextureProc,        BindTexture);
         GR_GET_PROC(GrGLBlendColorProc,         BlendColor);
         GR_GET_PROC(GrGLBlendFuncProc,          BlendFunc);
+        GR_GET_PROC(GrGLBlendEquationProc,      BlendEquation);
         GR_GET_PROC(GrGLBufferDataProc,         BufferData);
         GR_GET_PROC(GrGLBufferSubDataProc,      BufferSubData);
         GR_GET_PROC(GrGLClearProc,              Clear);
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index ff744c0..120381e 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -70,6 +70,7 @@
 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBlendColor(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha) {}
 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFragDataLocation(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name) {}
 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBlendFunc(GrGLenum sfactor, GrGLenum dfactor) {}
+GrGLvoid GR_GL_FUNCTION_TYPE debugGLBlendEquation(GrGLenum mode) {}
 
 ////////////////////////////////////////////////////////////////////////////////
 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage) {
@@ -924,6 +925,7 @@
         interface->fBindTexture = debugGLBindTexture;
         interface->fBlendColor = debugGLBlendColor;
         interface->fBlendFunc = debugGLBlendFunc;
+        interface->fBlendEquation = debugGLBlendEquation;
         interface->fBufferData = debugGLBufferData;
         interface->fBufferSubData = debugGLBufferSubData;
         interface->fClear = debugGLClear;
diff --git a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
index 5ae214a..6a56eb5 100644
--- a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
+++ b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp
@@ -52,8 +52,24 @@
             #endif
         }
         interface->fBindTexture = glBindTexture;
-        interface->fBlendColor = glBlendColor;
         interface->fBlendFunc = glBlendFunc;
+
+        if (ver >= GR_GL_VER(1,4)) {
+            interface->fBlendColor = glBlendColor;
+            interface->fBlendEquation = glBlendEquation;
+        } else if (GrGLHasExtensionFromString("GL_ARB_imaging", extStr)) {
+            GET_PROC(BlendColor);
+            GET_PROC(BlendEquation);
+        } else {
+            if (GrGLHasExtensionFromString("GL_EXT_blend_color", extStr)) {
+                GET_PROC_SUFFIX(BlendColor, EXT);
+            } 
+            if (GrGLHasExtensionFromString("GL_EXT_blend_minmax", extStr) ||
+                GrGLHasExtensionFromString("GL_EXT_blend_subtract", extStr)) {
+                GET_PROC_SUFFIX(BlendEquation, EXT);
+            } 
+        } 
+
         interface->fBufferData = glBufferData;
         interface->fBufferSubData = glBufferSubData;
         interface->fClear = glClear;
diff --git a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
index 4686438..7fb5895 100644
--- a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
+++ b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
@@ -40,8 +40,22 @@
         GR_GL_GET_PROC(BindBuffer);
         GR_GL_GET_PROC(BindFragDataLocation);
         GR_GL_GET_PROC(BindTexture);
-        GR_GL_GET_PROC(BlendColor);
         GR_GL_GET_PROC(BlendFunc);
+
+        if (glVer >= GR_GL_VER(1,4) ||
+            GrGLHasExtensionFromString("GL_ARB_imaging", extString)) {
+            GR_GL_GET_PROC(BlendColor);
+            GR_GL_GET_PROC(BlendEquation);
+        } else {
+            if (GrGLHasExtensionFromString("GL_EXT_blend_color", extString)) {
+                GR_GL_GET_PROC_SUFFIX(BlendColor, EXT);
+            } 
+            if (GrGLHasExtensionFromString("GL_EXT_blend_minmax", extString) ||
+                GrGLHasExtensionFromString("GL_EXT_blend_subtract", extString)) {
+                GR_GL_GET_PROC_SUFFIX(BlendEquation, EXT);
+            } 
+        } 
+
         GR_GL_GET_PROC(BufferData);
         GR_GL_GET_PROC(BufferSubData);
         GR_GL_GET_PROC(Clear);
diff --git a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
index be915ac..0da63b5 100644
--- a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
+++ b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
@@ -39,8 +39,22 @@
         GR_GL_GET_PROC(BindFragDataLocation);
         GR_GL_GET_PROC(BeginQuery);
         interface->fBindTexture = glBindTexture;
-        interface->fBlendColor = glBlendColor;
         interface->fBlendFunc = glBlendFunc;
+
+        if (glVer >= GR_GL_VER(1,4) ||
+            GrGLHasExtensionFromString("GL_ARB_imaging", extString)) {
+            GR_GL_GET_PROC(BlendColor);
+            GR_GL_GET_PROC(BlendEquation);
+        } else {
+            if (GrGLHasExtensionFromString("GL_EXT_blend_color", extString)) {
+                GR_GL_GET_PROC_SUFFIX(BlendColor, EXT);
+            } 
+            if (GrGLHasExtensionFromString("GL_EXT_blend_minmax", extString) ||
+                GrGLHasExtensionFromString("GL_EXT_blend_subtract", extString)) {
+                GR_GL_GET_PROC_SUFFIX(BlendEquation, EXT);
+            } 
+        } 
+
         GR_GL_GET_PROC(BufferData);
         GR_GL_GET_PROC(BufferSubData);
         interface->fClear = glClear;
diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
index 2048974..5b2d10b 100644
--- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
+++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
@@ -41,6 +41,21 @@
         // wglGetProcAddress
         interface->fBindTexture = glBindTexture;
         interface->fBlendFunc = glBlendFunc;
+
+        if (glVer >= GR_GL_VER(1,4) ||
+            GrGLHasExtensionFromString("GL_ARB_imaging", extString)) {
+            GR_GL_GET_PROC(BlendColor);
+            GR_GL_GET_PROC(BlendEquation);
+        } else {
+            if (GrGLHasExtensionFromString("GL_EXT_blend_color", extString)) {
+                GR_GL_GET_PROC_SUFFIX(BlendColor, EXT);
+            } 
+            if (GrGLHasExtensionFromString("GL_EXT_blend_minmax", extString) ||
+                GrGLHasExtensionFromString("GL_EXT_blend_subtract", extString)) {
+                GR_GL_GET_PROC_SUFFIX(BlendEquation, EXT);
+            } 
+        } 
+
         interface->fClear = glClear;
         interface->fClearColor = glClearColor;
         interface->fClearStencil = glClearStencil;
@@ -87,7 +102,6 @@
         GR_GL_GET_PROC(BindAttribLocation);
         GR_GL_GET_PROC(BindBuffer);
         GR_GL_GET_PROC(BindFragDataLocation);
-        GR_GL_GET_PROC(BlendColor);
         GR_GL_GET_PROC(BufferData);
         GR_GL_GET_PROC(BufferSubData);
         GR_GL_GET_PROC(CompileShader);
diff --git a/src/gpu/ios/GrGLDefaultInterface_iOS.cpp b/src/gpu/ios/GrGLDefaultInterface_iOS.cpp
index 9fc953f..8923f6e 100644
--- a/src/gpu/ios/GrGLDefaultInterface_iOS.cpp
+++ b/src/gpu/ios/GrGLDefaultInterface_iOS.cpp
@@ -24,6 +24,7 @@
         interface->fBindBuffer = glBindBuffer;
         interface->fBindTexture = glBindTexture;
         interface->fBlendColor = glBlendColor;
+        interface->fBlendEquation = glBlendEquation;
         interface->fBlendFunc = glBlendFunc;
         interface->fBufferData = (GrGLBufferDataProc)glBufferData;
         interface->fBufferSubData = (GrGLBufferSubDataProc)glBufferSubData;