Use timestamp to detect when client GL calls could cause Gr's cache of glTexParam values to be invalid.


git-svn-id: http://skia.googlecode.com/svn/trunk@2609 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGLTexture.h b/src/gpu/GrGLTexture.h
index 49002af..1f9636a 100644
--- a/src/gpu/GrGLTexture.h
+++ b/src/gpu/GrGLTexture.h
@@ -10,9 +10,8 @@
 #ifndef GrGLTexture_DEFINED
 #define GrGLTexture_DEFINED
 
+#include "GrGpu.h"
 #include "GrGLRenderTarget.h"
-#include "GrScalar.h"
-#include "GrTexture.h"
 
 /**
  * A ref counted tex id that deletes the texture in its destructor.
@@ -75,13 +74,11 @@
     // creates a texture that is also an RT
     GrGLTexture(GrGpuGL* gpu,
                 const Desc& textureDesc,
-                const GrGLRenderTarget::Desc& rtDesc,
-                const TexParams& initialTexParams);
+                const GrGLRenderTarget::Desc& rtDesc);
 
     // creates a non-RT texture
     GrGLTexture(GrGpuGL* gpu,
-                const Desc& textureDesc,
-                const TexParams& initialTexParams);
+                const Desc& textureDesc);
 
 
     virtual ~GrGLTexture() { this->release(); }
@@ -95,8 +92,16 @@
                                    size_t rowBytes);
     virtual intptr_t getTextureHandle() const;
 
-    const TexParams& getTexParams() const { return fTexParams; }
-    void setTexParams(const TexParams& texParams) { fTexParams = texParams; }
+    // these functions 
+    const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const {
+        *timestamp = fTexParamsTimestamp;
+        return fTexParams;
+    }
+    void setCachedTexParams(const TexParams& texParams,
+                            GrGpu::ResetTimestamp timestamp) {
+        fTexParams = texParams;
+        fTexParamsTimestamp = timestamp;
+    }
     GrGLuint textureID() const { return fTexIDObj->id(); }
 
     GrGLenum uploadFormat() const { return fUploadFormat; }
@@ -116,7 +121,7 @@
     // in the top-left corner of the image. OpenGL, however,
     // has the origin in the lower-left corner. For content that
     // is loaded by Ganesh we just push the content "upside down"
-    // (by GL's understanding of the world ) in glTex*Image and the
+    // (by GL's understanding of the world) in glTex*Image and the
     // addressing just works out. However, content generated by GL
     // (FBO or externally imported texture) will be updside down
     // and it is up to the GrGpuGL derivative to handle y-mirroing.
@@ -131,19 +136,19 @@
     virtual void onRelease();
 
 private:
-    TexParams           fTexParams;
-    GrGLTexID*          fTexIDObj;
-    GrGLenum            fUploadFormat;
-    GrGLenum            fUploadType;
+    TexParams                       fTexParams;
+    GrGpu::ResetTimestamp           fTexParamsTimestamp;
+    GrGLTexID*                      fTexIDObj;
+    GrGLenum                        fUploadFormat;
+    GrGLenum                        fUploadType;
     // precomputed content / alloc ratios
-    GrScalar            fScaleX;
-    GrScalar            fScaleY;
-    Orientation         fOrientation;
+    GrScalar                        fScaleX;
+    GrScalar                        fScaleY;
+    Orientation                     fOrientation;
 
     void init(GrGpuGL* gpu,
               const Desc& textureDesc,
-              const GrGLRenderTarget::Desc* rtDesc,
-              const TexParams& initialTexParams);
+              const GrGLRenderTarget::Desc* rtDesc);
 
     typedef GrTexture INHERITED;
 };