Add flag to disable gl error checking when allocating gpu objects

Review URL: http://codereview.appspot.com/5558052/



git-svn-id: http://skia.googlecode.com/svn/trunk@3075 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/GrGLConfig.h b/include/gpu/GrGLConfig.h
index c9aaec5..167c8eb 100644
--- a/include/gpu/GrGLConfig.h
+++ b/include/gpu/GrGLConfig.h
@@ -86,6 +86,12 @@
  * glReadPixels to read the entire framebuffer is faster than calling it with
  * the same sized rectangle but with a framebuffer bound that is larger than
  * the rectangle read.
+ *
+ * GR_GL_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage,
+ * glBufferData, glRenderbufferStorage, etc will be checked for errors. This
+ * amounts to ensuring the error is GL_NO_ERROR, calling the allocating
+ * function, and then checking that the error is still GL_NO_ERROR. When the
+ * value is 0 we will assume no error was generated without checking.
  */
 
 #if !defined(GR_GL_LOG_CALLS)
@@ -128,6 +134,10 @@
     #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 0
 #endif
 
+#if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR)
+    #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR    1
+#endif
+
 #if(GR_GL_NO_CONSTANT_ATTRIBUTES) && (GR_GL_ATTRIBUTE_MATRICES)
     #error "Cannot combine GR_GL_NO_CONSTANT_ATTRIBUTES and GR_GL_ATTRIBUTE_MATRICES"
 #endif
diff --git a/include/gpu/GrGLConfig_chrome.h b/include/gpu/GrGLConfig_chrome.h
index ee3c991..2bae145 100644
--- a/include/gpu/GrGLConfig_chrome.h
+++ b/include/gpu/GrGLConfig_chrome.h
@@ -9,22 +9,26 @@
 #define GrGLConfig_chrome_DEFINED
 
 // glGetError() forces a sync with gpu process on chrome
-#define GR_GL_CHECK_ERROR_START         0
+#define GR_GL_CHECK_ERROR_START                     0
 
 // ANGLE creates a temp VB for vertex attributes not specified per-vertex.
-#define GR_GL_NO_CONSTANT_ATTRIBUTES    GR_WIN32_BUILD
+#define GR_GL_NO_CONSTANT_ATTRIBUTES                GR_WIN32_BUILD
 
 // For RGBA teximage/readpixels ANGLE will sw-convert to/from BGRA.
-#define GR_GL_RGBA_8888_PIXEL_OPS_SLOW  GR_WIN32_BUILD
+#define GR_GL_RGBA_8888_PIXEL_OPS_SLOW              GR_WIN32_BUILD
 
 // ANGLE can go faster if the entire fbo is read rather than a subrect
-#define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL GR_WIN32_BUILD
+#define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL   GR_WIN32_BUILD
 
 // cmd buffer allocates memory and memsets it to zero when it sees glBufferData
 // with NULL.
-#define GR_GL_USE_BUFFER_DATA_NULL_HINT 0
+#define GR_GL_USE_BUFFER_DATA_NULL_HINT             0
 
 // chrome uses this to set the context on each GL call.
-#define GR_GL_PER_GL_FUNC_CALLBACK      1
+#define GR_GL_PER_GL_FUNC_CALLBACK                  1
+
+// Check error is even more expensive in chrome (cmd buffer flush). The
+// compositor also doesn't check its allocations.
+#define GR_GL_CHECK_ALLOC_WITH_GET_ERROR            0
 
 #endif