Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / gpu / gl / GrGLInterface.cpp
index f40821f..063de56 100644 (file)
@@ -39,57 +39,29 @@ const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) {
     GrGLInterface* newInterface = GrGLInterface::NewClone(interface);
 
     newInterface->fExtensions.remove("GL_NV_path_rendering");
-
     newInterface->fFunctions.fPathCommands = NULL;
     newInterface->fFunctions.fPathCoords = NULL;
-    newInterface->fFunctions.fPathSubCommands = NULL;
-    newInterface->fFunctions.fPathSubCoords = NULL;
-    newInterface->fFunctions.fPathString = NULL;
-    newInterface->fFunctions.fPathGlyphs = NULL;
-    newInterface->fFunctions.fPathGlyphRange = NULL;
-    newInterface->fFunctions.fWeightPaths = NULL;
-    newInterface->fFunctions.fCopyPath = NULL;
-    newInterface->fFunctions.fInterpolatePaths = NULL;
-    newInterface->fFunctions.fTransformPath = NULL;
-    newInterface->fFunctions.fPathParameteriv = NULL;
     newInterface->fFunctions.fPathParameteri = NULL;
-    newInterface->fFunctions.fPathParameterfv = NULL;
     newInterface->fFunctions.fPathParameterf = NULL;
-    newInterface->fFunctions.fPathDashArray = NULL;
     newInterface->fFunctions.fGenPaths = NULL;
     newInterface->fFunctions.fDeletePaths = NULL;
     newInterface->fFunctions.fIsPath = NULL;
     newInterface->fFunctions.fPathStencilFunc = NULL;
-    newInterface->fFunctions.fPathStencilDepthOffset = NULL;
     newInterface->fFunctions.fStencilFillPath = NULL;
     newInterface->fFunctions.fStencilStrokePath = NULL;
     newInterface->fFunctions.fStencilFillPathInstanced = NULL;
     newInterface->fFunctions.fStencilStrokePathInstanced = NULL;
-    newInterface->fFunctions.fPathCoverDepthFunc = NULL;
-    newInterface->fFunctions.fPathColorGen = NULL;
     newInterface->fFunctions.fPathTexGen = NULL;
-    newInterface->fFunctions.fPathFogGen = NULL;
     newInterface->fFunctions.fCoverFillPath = NULL;
     newInterface->fFunctions.fCoverStrokePath = NULL;
     newInterface->fFunctions.fCoverFillPathInstanced = NULL;
     newInterface->fFunctions.fCoverStrokePathInstanced = NULL;
-    newInterface->fFunctions.fGetPathParameteriv = NULL;
-    newInterface->fFunctions.fGetPathParameterfv = NULL;
-    newInterface->fFunctions.fGetPathCommands = NULL;
-    newInterface->fFunctions.fGetPathCoords = NULL;
-    newInterface->fFunctions.fGetPathDashArray = NULL;
-    newInterface->fFunctions.fGetPathMetrics = NULL;
-    newInterface->fFunctions.fGetPathMetricRange = NULL;
-    newInterface->fFunctions.fGetPathSpacing = NULL;
-    newInterface->fFunctions.fGetPathColorGeniv = NULL;
-    newInterface->fFunctions.fGetPathColorGenfv = NULL;
-    newInterface->fFunctions.fGetPathTexGeniv = NULL;
-    newInterface->fFunctions.fGetPathTexGenfv = NULL;
-    newInterface->fFunctions.fIsPointInFillPath = NULL;
-    newInterface->fFunctions.fIsPointInStrokePath = NULL;
-    newInterface->fFunctions.fGetPathLength = NULL;
-    newInterface->fFunctions.fPointAlongPath = NULL;
-
+    newInterface->fFunctions.fStencilThenCoverFillPath = NULL;
+    newInterface->fFunctions.fStencilThenCoverStrokePath = NULL;
+    newInterface->fFunctions.fStencilThenCoverFillPathInstanced = NULL;
+    newInterface->fFunctions.fStencilThenCoverStrokePathInstanced = NULL;
+    newInterface->fFunctions.fProgramPathFragmentInputGen = NULL;
+    newInterface->fFunctions.fPathMemoryGlyphIndexArray = NULL;
     return newInterface;
 }
 
@@ -103,7 +75,7 @@ GrGLInterface::GrGLInterface() {
 }
 
 GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
-    SkASSERT(NULL != interface);
+    SkASSERT(interface);
 
     GrGLInterface* clone = SkNEW(GrGLInterface);
     clone->fStandard = interface->fStandard;
@@ -116,9 +88,15 @@ GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) {
     return clone;
 }
 
-#define RETURN_FALSE_INTERFACE                             \
-    GrDebugCrash("GrGLInterface::validate() failed.");     \
-    return false;                                          \
+#ifdef SK_DEBUG
+    static int kIsDebug = 1;
+#else
+    static int kIsDebug = 0;
+#endif
+
+#define RETURN_FALSE_INTERFACE                                                                   \
+    if (kIsDebug) { SkDebugf("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); } \
+    return false;
 
 bool GrGLInterface::validate() const {
 
@@ -227,12 +205,8 @@ bool GrGLInterface::validate() const {
     }
 
     GrGLVersion glVer = GrGLGetVersion(this);
-
-    bool isCoreProfile = false;
-    if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,2)) {
-        GrGLint profileMask;
-        GR_GL_GetIntegerv(this, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
-        isCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
+    if (GR_GL_INVALID_VER == glVer) {
+        RETURN_FALSE_INTERFACE
     }
 
     // Now check that baseline ES/Desktop fns not covered above are present
@@ -290,75 +264,17 @@ bool GrGLInterface::validate() const {
                 RETURN_FALSE_INTERFACE
             }
         }
-        if (!isCoreProfile) {
-            if (NULL == fFunctions.fLoadIdentity ||
-                NULL == fFunctions.fLoadMatrixf ||
-                NULL == fFunctions.fMatrixMode ||
-                NULL == fFunctions.fTexGenfv ||
-                NULL == fFunctions.fTexGeni) {
-                RETURN_FALSE_INTERFACE
-            }
-        }
-        if (fExtensions.has("GL_NV_path_rendering")) {
-            if (NULL == fFunctions.fPathCommands ||
-                NULL == fFunctions.fPathCoords ||
-                NULL == fFunctions.fPathSubCommands ||
-                NULL == fFunctions.fPathSubCoords ||
-                NULL == fFunctions.fPathString ||
-                NULL == fFunctions.fPathGlyphs ||
-                NULL == fFunctions.fPathGlyphRange ||
-                NULL == fFunctions.fWeightPaths ||
-                NULL == fFunctions.fCopyPath ||
-                NULL == fFunctions.fInterpolatePaths ||
-                NULL == fFunctions.fTransformPath ||
-                NULL == fFunctions.fPathParameteriv ||
-                NULL == fFunctions.fPathParameteri ||
-                NULL == fFunctions.fPathParameterfv ||
-                NULL == fFunctions.fPathParameterf ||
-                NULL == fFunctions.fPathDashArray ||
-                NULL == fFunctions.fGenPaths ||
-                NULL == fFunctions.fDeletePaths ||
-                NULL == fFunctions.fIsPath ||
-                NULL == fFunctions.fPathStencilFunc ||
-                NULL == fFunctions.fPathStencilDepthOffset ||
-                NULL == fFunctions.fStencilFillPath ||
-                NULL == fFunctions.fStencilStrokePath ||
-                NULL == fFunctions.fStencilFillPathInstanced ||
-                NULL == fFunctions.fStencilStrokePathInstanced ||
-                NULL == fFunctions.fPathCoverDepthFunc ||
-                NULL == fFunctions.fPathColorGen ||
-                NULL == fFunctions.fPathTexGen ||
-                NULL == fFunctions.fPathFogGen ||
-                NULL == fFunctions.fCoverFillPath ||
-                NULL == fFunctions.fCoverStrokePath ||
-                NULL == fFunctions.fCoverFillPathInstanced ||
-                NULL == fFunctions.fCoverStrokePathInstanced ||
-                NULL == fFunctions.fGetPathParameteriv ||
-                NULL == fFunctions.fGetPathParameterfv ||
-                NULL == fFunctions.fGetPathCommands ||
-                NULL == fFunctions.fGetPathCoords ||
-                NULL == fFunctions.fGetPathDashArray ||
-                NULL == fFunctions.fGetPathMetrics ||
-                NULL == fFunctions.fGetPathMetricRange ||
-                NULL == fFunctions.fGetPathSpacing ||
-                NULL == fFunctions.fGetPathColorGeniv ||
-                NULL == fFunctions.fGetPathColorGenfv ||
-                NULL == fFunctions.fGetPathTexGeniv ||
-                NULL == fFunctions.fGetPathTexGenfv ||
-                NULL == fFunctions.fIsPointInFillPath ||
-                NULL == fFunctions.fIsPointInStrokePath ||
-                NULL == fFunctions.fGetPathLength ||
-                NULL == fFunctions.fPointAlongPath) {
-                RETURN_FALSE_INTERFACE
-            }
-        }
     }
 
     // optional function on desktop before 1.3
     if (kGL_GrGLStandard != fStandard ||
         (glVer >= GR_GL_VER(1,3)) ||
         fExtensions.has("GL_ARB_texture_compression")) {
-        if (NULL == fFunctions.fCompressedTexImage2D) {
+        if (NULL == fFunctions.fCompressedTexImage2D
+#if 0
+            || NULL == fFunctions.fCompressedTexSubImage2D
+#endif
+            ) {
             RETURN_FALSE_INTERFACE
         }
     }
@@ -486,5 +402,96 @@ bool GrGLInterface::validate() const {
             RETURN_FALSE_INTERFACE
         }
     }
+
+    if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
+        fExtensions.has("GL_ARB_invalidate_subdata")) {
+        if (NULL == fFunctions.fInvalidateBufferData ||
+            NULL == fFunctions.fInvalidateBufferSubData ||
+            NULL == fFunctions.fInvalidateFramebuffer ||
+            NULL == fFunctions.fInvalidateSubFramebuffer ||
+            NULL == fFunctions.fInvalidateTexImage ||
+            NULL == fFunctions.fInvalidateTexSubImage) {
+            RETURN_FALSE_INTERFACE;
+        }
+    } else if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
+        // ES 3.0 adds the framebuffer functions but not the others.
+        if (NULL == fFunctions.fInvalidateFramebuffer ||
+            NULL == fFunctions.fInvalidateSubFramebuffer) {
+            RETURN_FALSE_INTERFACE;
+        }
+    }
+
+    if (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_CHROMIUM_map_sub")) {
+        if (NULL == fFunctions.fMapBufferSubData ||
+            NULL == fFunctions.fMapTexSubImage2D ||
+            NULL == fFunctions.fUnmapBufferSubData ||
+            NULL == fFunctions.fUnmapTexSubImage2D) {
+            RETURN_FALSE_INTERFACE;
+        }
+    }
+
+    // These functions are added to the 3.0 version of both GLES and GL.
+    if (glVer >= GR_GL_VER(3,0) ||
+        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
+        (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
+        if (NULL == fFunctions.fMapBufferRange ||
+            NULL == fFunctions.fFlushMappedBufferRange) {
+            RETURN_FALSE_INTERFACE;
+        }
+    }
+
+    if ((kGL_GrGLStandard == fStandard && fExtensions.has("GL_EXT_direct_state_access")) ||
+        (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_NV_path_rendering"))) {
+        if (NULL == fFunctions.fMatrixLoadf ||
+            NULL == fFunctions.fMatrixLoadIdentity) {
+            RETURN_FALSE_INTERFACE
+        }
+    }
+
+    if ((kGL_GrGLStandard == fStandard &&
+         (glVer >= GR_GL_VER(4,3) || fExtensions.has("GL_ARB_program_interface_query"))) ||
+        (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,1))) {
+        if (NULL == fFunctions.fGetProgramResourceLocation) {
+            RETURN_FALSE_INTERFACE
+        }
+    }
+
+    if (fExtensions.has("GL_NV_path_rendering")) {
+        if (NULL == fFunctions.fPathCommands ||
+            NULL == fFunctions.fPathCoords ||
+            NULL == fFunctions.fPathParameteri ||
+            NULL == fFunctions.fPathParameterf ||
+            NULL == fFunctions.fGenPaths ||
+            NULL == fFunctions.fDeletePaths ||
+            NULL == fFunctions.fIsPath ||
+            NULL == fFunctions.fPathStencilFunc ||
+            NULL == fFunctions.fStencilFillPath ||
+            NULL == fFunctions.fStencilStrokePath ||
+            NULL == fFunctions.fStencilFillPathInstanced ||
+            NULL == fFunctions.fStencilStrokePathInstanced ||
+            NULL == fFunctions.fCoverFillPath ||
+            NULL == fFunctions.fCoverStrokePath ||
+            NULL == fFunctions.fCoverFillPathInstanced ||
+            NULL == fFunctions.fCoverStrokePathInstanced) {
+            RETURN_FALSE_INTERFACE
+        }
+        if (kGL_GrGLStandard == fStandard) {
+            // Some methods only exist on desktop
+            if (NULL == fFunctions.fPathTexGen) {
+                RETURN_FALSE_INTERFACE
+            }
+        } else {
+            // All additions through v1.3 exist on GLES
+            if (NULL == fFunctions.fStencilThenCoverFillPath ||
+                NULL == fFunctions.fStencilThenCoverStrokePath ||
+                NULL == fFunctions.fStencilThenCoverFillPathInstanced ||
+                NULL == fFunctions.fStencilThenCoverStrokePathInstanced ||
+                NULL == fFunctions.fProgramPathFragmentInputGen ||
+                NULL == fFunctions.fPathMemoryGlyphIndexArray) {
+                RETURN_FALSE_INTERFACE
+            }
+        }
+    }
+
     return true;
 }