Add support for GL_ANGLE_texture_usage
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 9 Dec 2011 19:40:36 +0000 (19:40 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 9 Dec 2011 19:40:36 +0000 (19:40 +0000)
Review URL: http://codereview.appspot.com/5478052/

git-svn-id: http://skia.googlecode.com/svn/trunk@2845 2bbb7eff-a529-9590-31e7-b0007b416f81

include/gpu/GrGLDefines.h
src/gpu/GrGpuGL.cpp
src/gpu/GrGpuGL.h

index 4dc6278..6a57982 100644 (file)
 #define GR_GL_NEAREST_MIPMAP_LINEAR          0x2702
 #define GR_GL_LINEAR_MIPMAP_LINEAR           0x2703
 
+/* TextureUsage */
+#define GR_GL_FRAMEBUFFER_ATTACHMENT         0x93A3
+
 /* TextureParameterName */
 #define GR_GL_TEXTURE_MAG_FILTER             0x2800
 #define GR_GL_TEXTURE_MIN_FILTER             0x2801
 #define GR_GL_TEXTURE_WRAP_S                 0x2802
 #define GR_GL_TEXTURE_WRAP_T                 0x2803
+#define GR_GL_TEXTURE_USAGE                  0x93A2
 
 /* TextureTarget */
 /*      GL_TEXTURE_2D */
index 190a412..fb16b22 100644 (file)
@@ -336,6 +336,9 @@ void GrGpuGL::initCaps() {
         fCaps.fNPOTTextureTileSupport = this->hasExtension("GL_OES_texture_npot");
     }
 
+    fGLCaps.fTextureUsageSupport = (kES2_GrGLBinding == this->glBinding()) &&
+                                   this->hasExtension("GL_ANGLE_texture_usage");
+
     fCaps.fHWAALineSupport = (kDesktop_GrGLBinding == this->glBinding());
 
     ////////////////////////////////////////////////////////////////////////////
@@ -1044,6 +1047,12 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc,
     }
 
     GL_CALL(GenTextures(1, &glTexDesc.fTextureID));
+    if (renderTarget && this->glCaps().fTextureUsageSupport) {
+        // provides a hint about how this texture will be used
+        GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
+                              GR_GL_TEXTURE_USAGE,
+                              GR_GL_FRAMEBUFFER_ATTACHMENT));
+    }
     if (!glTexDesc.fTextureID) {
         return return_null_texture();
     }
index 57a4d97..5f9180f 100644 (file)
@@ -57,7 +57,8 @@ protected:
             , fUnpackRowLengthSupport(false)
             , fUnpackFlipYSupport(false)
             , fPackRowLengthSupport(false)
-            , fPackFlipYSupport(false) {
+            , fPackFlipYSupport(false)
+            , fTextureUsageSupport(false) {
             memset(fAASamples, 0, sizeof(fAASamples));
         }
         SkTArray<GrGLStencilBuffer::Format, true> fStencilFormats;
@@ -113,6 +114,9 @@ protected:
         // Is there support for GL_PACK_REVERSE_ROW_ORDER
         bool fPackFlipYSupport;
 
+        // Is there support for texture parameter GL_TEXTURE_USAGE
+        bool fTextureUsageSupport;
+
         void print() const;
     } fGLCaps;