aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2015-04-22 10:39:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-22 10:39:03 -0700
commitbae6f6c3ec927bc1f87cd4c13fec0b52e5677c23 (patch)
tree5f444c5882e7e615ffa2e143bcca630b71d4fb6e
parent87cbcf3f86a58cacab2e576ebc0e29399a1d48b3 (diff)
Add tokens and entry points for KHR_blend_equation_advanced
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
-rw-r--r--include/gpu/gl/GrGLFunctions.h4
-rw-r--r--include/gpu/gl/GrGLInterface.h2
-rw-r--r--src/gpu/gl/GrGLAssembleInterface.cpp28
-rw-r--r--src/gpu/gl/GrGLCreateNullInterface.cpp1
-rw-r--r--src/gpu/gl/GrGLDefines.h22
-rw-r--r--src/gpu/gl/GrGLInterface.cpp13
-rw-r--r--src/gpu/gl/GrGLNoOpInterface.cpp10
-rw-r--r--src/gpu/gl/GrGLNoOpInterface.h8
-rw-r--r--src/gpu/gl/SkNullGLContext.cpp1
-rw-r--r--src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp2
-rw-r--r--src/gpu/gl/debug/GrGLCreateDebugInterface.cpp1
11 files changed, 80 insertions, 12 deletions
diff --git a/include/gpu/gl/GrGLFunctions.h b/include/gpu/gl/GrGLFunctions.h
index 3995ead797..5c2cf7bc4d 100644
--- a/include/gpu/gl/GrGLFunctions.h
+++ b/include/gpu/gl/GrGLFunctions.h
@@ -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);
diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h
index a96d2f404a..2e9ef6fea7 100644
--- a/include/gpu/gl/GrGLInterface.h
+++ b/include/gpu/gl/GrGLInterface.h
@@ -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;
diff --git a/src/gpu/gl/GrGLAssembleInterface.cpp b/src/gpu/gl/GrGLAssembleInterface.cpp
index b0f0430ffb..89b21fdec3 100644
--- a/src/gpu/gl/GrGLAssembleInterface.cpp
+++ b/src/gpu/gl/GrGLAssembleInterface.cpp
@@ -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);
diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp
index c86a0bd2fd..512c672a65 100644
--- a/src/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/src/gpu/gl/GrGLCreateNullInterface.cpp
@@ -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;
diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h
index ae4050014b..511659c492 100644
--- a/src/gpu/gl/GrGLDefines.h
+++ b/src/gpu/gl/GrGLDefines.h
@@ -45,6 +45,28 @@
/* 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
diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp
index da1c3fc0e1..d134cd56c8 100644
--- a/src/gpu/gl/GrGLInterface.cpp
+++ b/src/gpu/gl/GrGLInterface.cpp
@@ -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
diff --git a/src/gpu/gl/GrGLNoOpInterface.cpp b/src/gpu/gl/GrGLNoOpInterface.cpp
index 6b8880ed81..f588046455 100644
--- a/src/gpu/gl/GrGLNoOpInterface.cpp
+++ b/src/gpu/gl/GrGLNoOpInterface.cpp
@@ -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,
diff --git a/src/gpu/gl/GrGLNoOpInterface.h b/src/gpu/gl/GrGLNoOpInterface.h
index c7bc9d8cbb..b803b46097 100644
--- a/src/gpu/gl/GrGLNoOpInterface.h
+++ b/src/gpu/gl/GrGLNoOpInterface.h
@@ -13,14 +13,16 @@
// 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);
diff --git a/src/gpu/gl/SkNullGLContext.cpp b/src/gpu/gl/SkNullGLContext.cpp
index 69b559629c..cf07cb3ca2 100644
--- a/src/gpu/gl/SkNullGLContext.cpp
+++ b/src/gpu/gl/SkNullGLContext.cpp
@@ -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;
diff --git a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
index 99219d0fd5..4569cc8f23 100644
--- a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
+++ b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
@@ -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)) {
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index 4c2acc3fc4..e60c519be3 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -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;