Move clientID into texture desc

http://codereview.appspot.com/6305044/



git-svn-id: http://skia.googlecode.com/svn/trunk@4201 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index b62aad0..e7dcf53 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -81,7 +81,6 @@
                 desc.fConfig    = kSkia8888_PM_GrPixelConfig;
                 desc.fWidth     = 2 * S;
                 desc.fHeight    = 2 * S;
-                desc.fSampleCnt = 0;
                 GrTexture* texture = 
                     ctx->createUncachedTexture(desc, gTextureData, 0);
 
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 33a3abf..7f47c4f 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -111,9 +111,6 @@
      *  Create a new entry, based on the specified key and texture, and return
      *  its "locked" entry. Must call be balanced with an unlockTexture() call.
      *
-     *  @param key      A client-generated key that identifies the contents
-     *                  of the texture. Respecified to findAndLockTexture
-     *                  for subsequent uses of the texture.
      *  @param sampler  The sampler state used to draw a texture may be used
      *                  to determine how to store the pixel data in the texture
      *                  cache. (e.g. different versions may exist for different
@@ -125,8 +122,7 @@
      * @param rowBytes  The number of bytes between rows of the texture. Zero
      *                  implies tightly packed rows.
      */
-    TextureCacheEntry createAndLockTexture(GrTexture::TextureKey key,
-                                           const GrSamplerState* sampler,
+    TextureCacheEntry createAndLockTexture(const GrSamplerState* sampler,
                                            const GrTextureDesc& desc,
                                            void* srcData, size_t rowBytes);
 
@@ -135,14 +131,7 @@
      *  return it. The entry's texture() function will return NULL if not found.
      *  Must be balanced with an unlockTexture() call.
      *
-     *  @param key      A client-generated key that identifies the contents
-     *                  of the texture.
-     *  @param width    The width of the texture in pixels as specifed in
-     *                  the GrTextureDesc originally passed to
-     *                  createAndLockTexture
-     *  @param width    The height of the texture in pixels as specifed in
-     *                  the GrTextureDesc originally passed to
-     *                  createAndLockTexture
+     *  @param desc      Description of the texture properties.
      *  @param sampler  The sampler state used to draw a texture may be used
      *                  to determine the cache entry used. (e.g. different
      *                  versions may exist for different wrap modes on GPUs with
@@ -150,17 +139,15 @@
      *                  filter fields are used. NULL implies clamp wrap modes
      *                  and nearest filtering.
      */
-    TextureCacheEntry findAndLockTexture(GrTexture::TextureKey key,
-                                         const GrTextureDesc& desc,
+    TextureCacheEntry findAndLockTexture(const GrTextureDesc& desc,
                                          const GrSamplerState* sampler);
     /**
      * Determines whether a texture is in the cache. If the texture is found it
      * will not be locked or returned. This call does not affect the priority of
      * the texture for deletion.
      */
-    bool isTextureInCache(GrTexture::TextureKey key,
-                          const GrTextureDesc& desc,
-                          const GrSamplerState*) const;
+    bool isTextureInCache(const GrTextureDesc& desc,
+                          const GrSamplerState* sampler) const;
 
     /**
      * Enum that determines how closely a returned scratch texture must match
@@ -194,7 +181,8 @@
      * such an API will create gaps in the tiling pattern. This includes clamp
      * mode. (This may be addressed in a future update.)
      */
-    TextureCacheEntry lockScratchTexture(const GrTextureDesc& desc, ScratchTexMatch match);
+    TextureCacheEntry lockScratchTexture(const GrTextureDesc& desc, 
+                                         ScratchTexMatch match);
 
     /**
      *  When done with an entry, call unlockTexture(entry) on it, which returns
@@ -206,14 +194,14 @@
      * Creates a texture that is outside the cache. Does not count against
      * cache's budget.
      */
-    GrTexture* createUncachedTexture(const GrTextureDesc&,
+    GrTexture* createUncachedTexture(const GrTextureDesc& desc,
                                      void* srcData,
                                      size_t rowBytes);
 
     /**
      *  Returns true if the specified use of an indexed texture is supported.
      */
-    bool supportsIndex8PixelConfig(const GrSamplerState*,
+    bool supportsIndex8PixelConfig(const GrSamplerState* sampler,
                                    int width,
                                    int height) const;
 
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index c3e2946..17d4e1e 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -17,17 +17,21 @@
 class GrResourceKey;
 class GrSamplerState;
 
+/*
+ * All uncached textures should have this value as their fClientCacheID
+ */
+static const uint64_t kUncached_CacheID = 0xAAAAAAAA;
+
+/*
+ * Scratch textures should all have this value as their fClientCacheID
+ */
+static const uint64_t kScratch_CacheID = 0xBBBBBBBB;
+
+
 class GrTexture : public GrResource {
 
 public:
     /**
-     * Key generated by client. Should be a unique key on the texture data.
-     * Does not need to consider that width and height of the texture. Two
-     * textures with the same TextureKey but different bounds will not collide.
-     */
-    typedef uint64_t TextureKey;
-
-    /**
      * Retrieves the width of the texture.
      *
      * @return the width in texels
@@ -141,7 +145,6 @@
 
     static GrResourceKey ComputeKey(const GrGpu* gpu,
                                     const GrSamplerState* sampler,
-                                    TextureKey clientKey,
                                     const GrTextureDesc& desc,
                                     bool scratch);
 
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index c3f659c..a5d8549 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -459,10 +459,24 @@
     kGrColorTableSize = 256 * 4 //sizeof(GrColor)
 };
 
+/*
+ * Default value for fClientCacheID
+ */
+static const uint64_t kDefault_CacheID = 0;
+
 /**
  * Describes a texture to be created.
  */
 struct GrTextureDesc {
+    GrTextureDesc() 
+    : fFlags(kNone_GrTextureFlags)
+    , fWidth(0)
+    , fHeight(0)
+    , fConfig(kUnknown_GrPixelConfig)
+    , fSampleCnt(0)
+    , fClientCacheID(kDefault_CacheID) {
+    }
+
     GrTextureFlags         fFlags;  //!< bitfield of TextureFlags
     int                    fWidth;  //!< Width of the texture
     int                    fHeight; //!< Height of the texture
@@ -480,7 +494,15 @@
      * up to the next supported sample count, or down if it is larger than the
      * max supportex count.
      */
-    int fSampleCnt;
+    int                    fSampleCnt;
+
+    /**
+     * A user-provided texture ID. It should be unique to the texture data and
+     * does not need to take into account the width or height. Two textures
+     * with the same ID but different dimensions will not collide. This field
+     * is only relevant for textures that will be cached.
+     */
+    uint64_t               fClientCacheID;
 };
 
 /**
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index 1a5cc93..44a351e 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -152,9 +152,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 // Helper functions
 
-static const GrTexture::TextureKey gUNCACHED_KEY = ~0U;
 GrContext::TextureCacheEntry sk_gr_create_bitmap_texture(GrContext* ctx,
-                                                GrTexture::TextureKey key,
+                                                uint64_t key,
                                                 const GrSamplerState* sampler,
                                                 const SkBitmap& bitmap);
 
diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp
index f8586fa..fb12719 100644
--- a/src/gpu/GrAtlas.cpp
+++ b/src/gpu/GrAtlas.cpp
@@ -177,13 +177,12 @@
     GrAssert(0 == kA8_GrMaskFormat);
     GrAssert(1 == kA565_GrMaskFormat);
     if (NULL == fTexture[format]) {
-        GrTextureDesc desc = {
-            kDynamicUpdate_GrTextureFlagBit,
-            GR_ATLAS_TEXTURE_WIDTH,
-            GR_ATLAS_TEXTURE_HEIGHT,
-            maskformat2pixelconfig(format),
-            0 // samples
-        };
+        GrTextureDesc desc;
+        desc.fFlags = kDynamicUpdate_GrTextureFlagBit;
+        desc.fWidth = GR_ATLAS_TEXTURE_WIDTH;
+        desc.fHeight = GR_ATLAS_TEXTURE_HEIGHT;
+        desc.fConfig = maskformat2pixelconfig(format);
+
         fTexture[format] = fGpu->createTexture(desc, NULL, 0);
         if (NULL == fTexture[format]) {
             return NULL;
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index c0272bb..28ce46d 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -481,13 +481,11 @@
         return;
     }
 
-    const GrTextureDesc desc = {
-        kRenderTarget_GrTextureFlagBit|kNoStencil_GrTextureFlagBit,
-        bounds.width(),
-        bounds.height(),
-        kAlpha_8_GrPixelConfig,
-        0           // samples
-    };
+    GrTextureDesc desc;
+    desc.fFlags = kRenderTarget_GrTextureFlagBit|kNoStencil_GrTextureFlagBit;
+    desc.fWidth = bounds.width();
+    desc.fHeight = bounds.height();
+    desc.fConfig = kAlpha_8_GrPixelConfig;
 
     temp->set(this->getContext(), desc);
 }
@@ -499,13 +497,11 @@
     // Free up the currently cached mask so it can be reused
     fAACache.reset();
 
-    const GrTextureDesc desc = {
-        kRenderTarget_GrTextureFlagBit|kNoStencil_GrTextureFlagBit,
-        bounds.width(),
-        bounds.height(),
-        kAlpha_8_GrPixelConfig,
-        0           // samples
-    };
+    GrTextureDesc desc;
+    desc.fFlags = kRenderTarget_GrTextureFlagBit|kNoStencil_GrTextureFlagBit;
+    desc.fWidth = bounds.width();
+    desc.fHeight = bounds.height();
+    desc.fConfig = kAlpha_8_GrPixelConfig;
 
     fAACache.acquireMask(clipIn, desc, bounds);
 }
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index 2f4d8c7..1acdba5 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -251,8 +251,7 @@
         void reset () {
             fLastClip.setEmpty();
 
-            const GrTextureDesc desc = { kNone_GrTextureFlags, 0, 0, 
-                                         kUnknown_GrPixelConfig, 0 };
+            GrTextureDesc desc;
 
             fLastMask.set(NULL, desc);
             fLastBound.setEmpty();
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 1c55ecf..3708993 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -252,18 +252,16 @@
 }
 
 GrContext::TextureCacheEntry GrContext::findAndLockTexture(
-        GrTexture::TextureKey key,
         const GrTextureDesc& desc,
         const GrSamplerState* sampler) {
-    GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, sampler, key, desc, false);
+    GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, sampler, desc, false);
     return TextureCacheEntry(fTextureCache->findAndLock(resourceKey,
                                             GrResourceCache::kNested_LockType));
 }
 
-bool GrContext::isTextureInCache(GrTexture::TextureKey key,
-                                 const GrTextureDesc& desc,
+bool GrContext::isTextureInCache(const GrTextureDesc& desc,
                                  const GrSamplerState* sampler) const {
-    GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, sampler, key, desc, false);
+    GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, sampler, desc, false);
     return fTextureCache->hasKey(resourceKey);
 }
 
@@ -323,7 +321,6 @@
 }
 
 GrContext::TextureCacheEntry GrContext::createAndLockTexture(
-        GrTexture::TextureKey key,
         const GrSamplerState* sampler,
         const GrTextureDesc& desc,
         void* srcData,
@@ -336,19 +333,18 @@
 
     TextureCacheEntry entry;
 
-    GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, sampler, key,
+    GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, sampler,
                                                       desc, false);
 
     if (GrTexture::NeedsResizing(resourceKey)) {
         // The desired texture is NPOT and tiled but that isn't supported by 
         // the current hardware. Resize the texture to be a POT
         GrAssert(NULL != sampler);
-        TextureCacheEntry clampEntry = this->findAndLockTexture(key,
-                                                                desc,
+        TextureCacheEntry clampEntry = this->findAndLockTexture(desc,
                                                                 NULL);
 
         if (NULL == clampEntry.texture()) {
-            clampEntry = this->createAndLockTexture(key, NULL, desc,
+            clampEntry = this->createAndLockTexture(NULL, desc,
                                                     srcData, rowBytes);
             GrAssert(NULL != clampEntry.texture());
             if (NULL == clampEntry.texture()) {
@@ -438,8 +434,9 @@
 GrContext::TextureCacheEntry GrContext::lockScratchTexture(
                                                 const GrTextureDesc& inDesc,
                                                 ScratchTexMatch match) {
-
     GrTextureDesc desc = inDesc;
+    desc.fClientCacheID = kScratch_CacheID;
+
     if (kExact_ScratchTexMatch != match) {
         // bin by pow2 with a reasonable min
         static const int MIN_SIZE = 256;
@@ -454,7 +451,7 @@
     bool doubledH = false;
 
     do {
-        GrResourceKey key = GrTexture::ComputeKey(fGpu, NULL, 0, desc, true);
+        GrResourceKey key = GrTexture::ComputeKey(fGpu, NULL, desc, true);
         entry = fTextureCache->findAndLock(key,
                                            GrResourceCache::kNested_LockType);
         // if we miss, relax the fit of the flags...
@@ -487,7 +484,7 @@
         desc.fHeight = origHeight;
         GrTexture* texture = fGpu->createTexture(desc, NULL, 0);
         if (NULL != texture) {
-            GrResourceKey key = GrTexture::ComputeKey(fGpu, NULL, 0,
+            GrResourceKey key = GrTexture::ComputeKey(fGpu, NULL,
                                                       texture->desc(),
                                                       true);
             entry = fTextureCache->createAndLock(key, texture);
@@ -515,10 +512,12 @@
     }
 }
 
-GrTexture* GrContext::createUncachedTexture(const GrTextureDesc& desc,
+GrTexture* GrContext::createUncachedTexture(const GrTextureDesc& descIn,
                                             void* srcData,
                                             size_t rowBytes) {
-    return fGpu->createTexture(desc, srcData, rowBytes);
+    GrTextureDesc descCopy = descIn;
+    descCopy.fClientCacheID = kUncached_CacheID;
+    return fGpu->createTexture(descCopy, srcData, rowBytes);
 }
 
 void GrContext::getTextureCacheLimits(int* maxTextures,
@@ -1547,12 +1546,11 @@
         }
         // Make the scratch a render target because we don't have a robust
         // readTexturePixels as of yet (it calls this function).
-        const GrTextureDesc desc = {
-            kRenderTarget_GrTextureFlagBit,
-            width, height,
-            config,
-            0 // samples
-        };
+        GrTextureDesc desc;
+        desc.fFlags = kRenderTarget_GrTextureFlagBit;
+        desc.fWidth = width;
+        desc.fHeight = height;
+        desc.fConfig = config;
 
         // When a full readback is faster than a partial we could always make
         // the scratch exactly match the passed rect. However, if we see many
@@ -1705,9 +1703,11 @@
         config = GrPixelConfigSwapRAndB(config);
     }
 
-    const GrTextureDesc desc = {
-        kNone_GrTextureFlags, width, height, config, 0
-    };
+    GrTextureDesc desc;
+    desc.fWidth = width;
+    desc.fHeight = height;
+    desc.fConfig = config;
+
     GrAutoScratchTexture ast(this, desc);
     GrTexture* texture = ast.texture();
     if (NULL == texture) {
@@ -1992,13 +1992,11 @@
              kRGBA_8888_PM_GrPixelConfig == srcTexture->config() ||
              kAlpha_8_GrPixelConfig == srcTexture->config());
 
-    const GrTextureDesc desc = {
-        kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit,
-        SkScalarFloorToInt(srcRect.width()),
-        SkScalarFloorToInt(srcRect.height()),
-        srcTexture->config(), 
-        0 // samples 
-    };
+    GrTextureDesc desc;
+    desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
+    desc.fWidth = SkScalarFloorToInt(srcRect.width());
+    desc.fHeight = SkScalarFloorToInt(srcRect.height());
+    desc.fConfig = srcTexture->config();
 
     temp1->set(this, desc);
     if (temp2) {
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 99209c6..1213c41 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -201,13 +201,10 @@
  * Get a texture (from the texture cache) of the correct size & format
  */
 bool GrSWMaskHelper::getTexture(GrAutoScratchTexture* tex) {
-    const GrTextureDesc desc = {
-        kNone_GrTextureFlags,
-        fBM.width(),
-        fBM.height(),
-        kAlpha_8_GrPixelConfig,
-        0 // samples
-    };
+    GrTextureDesc desc;
+    desc.fWidth = fBM.width();
+    desc.fHeight = fBM.height();
+    desc.fConfig = kAlpha_8_GrPixelConfig;
 
     tex->set(fContext, desc);
     GrTexture* texture = tex->texture();
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 8dd0b0b..4f4c5f5 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -107,16 +107,16 @@
 namespace {
 void gen_texture_key_values(const GrGpu* gpu,
                             const GrSamplerState* sampler,
-                            GrTexture::TextureKey clientKey,
                             const GrTextureDesc& desc,
                             bool scratch,
                             uint32_t v[4]) {
-    GR_STATIC_ASSERT(sizeof(GrTexture::TextureKey) == sizeof(uint64_t));
+
+    uint64_t clientKey = desc.fClientCacheID;
 
     if (scratch) {
         // Instead of a client-provided key of the texture contents
         // we create a key of from the descriptor.
-        GrAssert(0 == clientKey);
+        GrAssert(kScratch_CacheID == clientKey);
         clientKey = (desc.fFlags << 8) | ((uint64_t) desc.fConfig << 32);
     }
 
@@ -156,11 +156,10 @@
 
 GrResourceKey GrTexture::ComputeKey(const GrGpu* gpu,
                                     const GrSamplerState* sampler,
-                                    TextureKey clientKey,
                                     const GrTextureDesc& desc,
                                     bool scratch) {
     uint32_t v[4];
-    gen_texture_key_values(gpu, sampler, clientKey, desc, scratch, v);
+    gen_texture_key_values(gpu, sampler, desc, scratch, v);
     return GrResourceKey(v);
 }
 
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index b0ff43a..b62e5be 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -226,13 +226,11 @@
     SkBitmap bm;
     bm.setConfig(config, width, height);
 
-    const GrTextureDesc desc = {
-        kRenderTarget_GrTextureFlagBit,
-        width,
-        height,
-        SkGr::BitmapConfig2PixelConfig(bm.config()),
-        0 // samples
-    };
+    GrTextureDesc desc;
+    desc.fFlags = kRenderTarget_GrTextureFlagBit;
+    desc.fWidth = width;
+    desc.fHeight = height;
+    desc.fConfig = SkGr::BitmapConfig2PixelConfig(bm.config());
 
     fTexture = fContext->createUncachedTexture(desc, NULL, 0);
 
@@ -792,15 +790,13 @@
     }
     GrPoint offset = GrPoint::Make(-srcRect.fLeft, -srcRect.fTop);
     srcRect.offset(offset);
-    GrTextureDesc desc = {
-        kRenderTarget_GrTextureFlagBit,
-        SkScalarCeilToInt(srcRect.width()),
-        SkScalarCeilToInt(srcRect.height()),
-        // We actually only need A8, but it often isn't supported as a
-        // render target so default to RGBA_8888
-        kRGBA_8888_PM_GrPixelConfig,
-        0 // samples
-    };
+    GrTextureDesc desc;
+    desc.fFlags = kRenderTarget_GrTextureFlagBit;
+    desc.fWidth = SkScalarCeilToInt(srcRect.width());
+    desc.fHeight = SkScalarCeilToInt(srcRect.height());
+    // We actually only need A8, but it often isn't supported as a
+    // render target so default to RGBA_8888
+    desc.fConfig = kRGBA_8888_PM_GrPixelConfig;
 
     if (context->isConfigRenderable(kAlpha_8_GrPixelConfig)) {
         desc.fConfig = kAlpha_8_GrPixelConfig;
@@ -930,13 +926,10 @@
 
     GrAutoMatrix avm(context, GrMatrix::I());
 
-    const GrTextureDesc desc = {
-        kNone_GrTextureFlags,
-        dstM.fBounds.width(),
-        dstM.fBounds.height(),
-        kAlpha_8_GrPixelConfig,
-        0, // samples
-    };
+    GrTextureDesc desc;
+    desc.fWidth = dstM.fBounds.width();
+    desc.fHeight = dstM.fBounds.height();
+    desc.fConfig = kAlpha_8_GrPixelConfig;
 
     GrAutoScratchTexture ast(context, desc);
     GrTexture* texture = ast.texture();
@@ -1436,13 +1429,11 @@
     SkSize blurSize;
     SkISize radius;
 
-    const GrTextureDesc desc = {
-        kRenderTarget_GrTextureFlagBit,
-        SkScalarCeilToInt(rect.width()),
-        SkScalarCeilToInt(rect.height()),
-        kRGBA_8888_PM_GrPixelConfig,
-        0 // samples
-    };
+    GrTextureDesc desc;
+    desc.fFlags = kRenderTarget_GrTextureFlagBit,
+    desc.fWidth = SkScalarCeilToInt(rect.width());
+    desc.fHeight = SkScalarCeilToInt(rect.height());
+    desc.fConfig = kRGBA_8888_PM_GrPixelConfig;
 
     if (filter->asABlur(&blurSize)) {
         GrAutoScratchTexture temp1, temp2;
@@ -1833,24 +1824,21 @@
     GrContext* ctx = this->context();
 
     if (!bitmap.isVolatile()) {
-        GrTexture::TextureKey key = bitmap.getGenerationID();
+        uint64_t key = bitmap.getGenerationID();
         key |= ((uint64_t) bitmap.pixelRefOffset()) << 32;
 
-        GrTextureDesc desc = {
-            kNone_GrTextureFlags,
-            bitmap.width(),
-            bitmap.height(),
-            SkGr::BitmapConfig2PixelConfig(bitmap.config()),
-            0 // samples
-        };
+        GrTextureDesc desc;
+        desc.fWidth = bitmap.width();
+        desc.fHeight = bitmap.height();
+        desc.fConfig = SkGr::BitmapConfig2PixelConfig(bitmap.config());
 
-        entry = ctx->findAndLockTexture(key, desc, sampler);
+        entry = ctx->findAndLockTexture(desc, sampler);
         if (NULL == entry.texture()) {
             entry = sk_gr_create_bitmap_texture(ctx, key, sampler,
                                                 bitmap);
         }
     } else {
-        entry = sk_gr_create_bitmap_texture(ctx, gUNCACHED_KEY,
+        entry = sk_gr_create_bitmap_texture(ctx, kUncached_CacheID,
                                             sampler, bitmap);
     }
     if (NULL == entry.texture()) {
@@ -1866,18 +1854,16 @@
 
 bool SkGpuDevice::isBitmapInTextureCache(const SkBitmap& bitmap,
                                          const GrSamplerState& sampler) const {
-    GrTexture::TextureKey key = bitmap.getGenerationID();
+    uint64_t key = bitmap.getGenerationID();
     key |= ((uint64_t) bitmap.pixelRefOffset()) << 32;
 
-    GrTextureDesc desc = {
-        kNone_GrTextureFlags,
-        bitmap.width(),
-        bitmap.height(),
-        SkGr::BitmapConfig2PixelConfig(bitmap.config()),
-        0 // samples
-    };
+    GrTextureDesc desc;
+    desc.fWidth = bitmap.width();
+    desc.fHeight = bitmap.height();
+    desc.fConfig = SkGr::BitmapConfig2PixelConfig(bitmap.config());
+    desc.fClientCacheID = key;
 
-    return this->context()->isTextureInCache(key, desc, &sampler);
+    return this->context()->isTextureInCache(desc, &sampler);
 }
 
 
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 00a0282..6fc851a 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -57,7 +57,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 GrContext::TextureCacheEntry sk_gr_create_bitmap_texture(GrContext* ctx,
-                                                GrTexture::TextureKey key,
+                                                uint64_t key,
                                                 const GrSamplerState* sampler,
                                                 const SkBitmap& origBitmap) {
     SkAutoLockPixels alp(origBitmap);
@@ -71,13 +71,11 @@
 
     const SkBitmap* bitmap = &origBitmap;
 
-    GrTextureDesc desc = {
-        kNone_GrTextureFlags,
-        bitmap->width(),
-        bitmap->height(),
-        SkGr::BitmapConfig2PixelConfig(bitmap->config()),
-        0 // samples
-    };
+    GrTextureDesc desc;
+    desc.fWidth = bitmap->width();
+    desc.fHeight = bitmap->height();
+    desc.fConfig = SkGr::BitmapConfig2PixelConfig(bitmap->config());
+    desc.fClientCacheID = key;
 
     if (SkBitmap::kIndex8_Config == bitmap->config()) {
         // build_compressed_data doesn't do npot->pot expansion
@@ -93,8 +91,8 @@
             // our compressed data will be trimmed, so pass width() for its
             // "rowBytes", since they are the same now.
             
-            if (gUNCACHED_KEY != key) {
-                return ctx->createAndLockTexture(key, sampler, desc, storage.get(),
+            if (kUncached_CacheID != key) {
+                return ctx->createAndLockTexture(sampler, desc, storage.get(),
                                                  bitmap->width());
             } else {
                 entry = ctx->lockScratchTexture(desc,
@@ -113,8 +111,8 @@
     }
 
     desc.fConfig = SkGr::BitmapConfig2PixelConfig(bitmap->config());
-    if (gUNCACHED_KEY != key) {
-        return ctx->createAndLockTexture(key, sampler, desc,
+    if (kUncached_CacheID != key) {
+        return ctx->createAndLockTexture(sampler, desc,
                                          bitmap->getPixels(),
                                          bitmap->rowBytes());
     } else {
diff --git a/src/gpu/SkGrTexturePixelRef.cpp b/src/gpu/SkGrTexturePixelRef.cpp
index 485d572..0caf0b4 100644
--- a/src/gpu/SkGrTexturePixelRef.cpp
+++ b/src/gpu/SkGrTexturePixelRef.cpp
@@ -63,7 +63,6 @@
     desc.fHeight = texture->height();
     desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
     desc.fConfig = SkGr::BitmapConfig2PixelConfig(dstConfig);
-    desc.fSampleCnt = 0;
 
     GrTexture* dst = context->createUncachedTexture(desc, NULL, 0);
     if (NULL == dst) {
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index d5c0bd2..da168cd 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -375,7 +375,6 @@
         dstDesc.fWidth = 256;
         dstDesc.fHeight = 256;
         dstDesc.fConfig = kRGBA_8888_PM_GrPixelConfig;
-        dstDesc.fSampleCnt = 0;
 
         SkAutoTUnref<GrTexture> dstTex(this->createTexture(dstDesc, NULL, 0));
         if (!dstTex.get()) {
@@ -1015,6 +1014,7 @@
     glTexDesc.fHeight = desc.fHeight;
     glTexDesc.fConfig = desc.fConfig;
     glTexDesc.fSampleCnt = desc.fSampleCnt;
+    glTexDesc.fClientCacheID = desc.fClientCacheID;
 
     glTexDesc.fOwnsID = true;
 
diff --git a/tests/ClipCacheTest.cpp b/tests/ClipCacheTest.cpp
index ae3337e..249bd58 100644
--- a/tests/ClipCacheTest.cpp
+++ b/tests/ClipCacheTest.cpp
@@ -26,7 +26,6 @@
     desc.fConfig    = kSkia8888_PM_GrPixelConfig;
     desc.fWidth     = X_SIZE;
     desc.fHeight    = Y_SIZE;
-    desc.fSampleCnt = 0;
 
     // We are initializing the texture with zeros here
     GrTexture* texture = context->createUncachedTexture(desc, textureData, 0);
@@ -83,13 +82,11 @@
     GrClip clip1;
     clip1.setFromIRect(bound1);
 
-    const GrTextureDesc desc = {
-        kRenderTarget_GrTextureFlagBit,
-        X_SIZE,
-        Y_SIZE,
-        kSkia8888_PM_GrPixelConfig,
-        0
-    };
+    GrTextureDesc desc;
+    desc.fFlags = kRenderTarget_GrTextureFlagBit;
+    desc.fWidth = X_SIZE;
+    desc.fHeight = Y_SIZE;
+    desc.fConfig = kSkia8888_PM_GrPixelConfig;
 
     cache.acquireMask(clip1, desc, bound1);
 
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 536d0c5..fb818b3 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -31,7 +31,6 @@
     desc.fConfig    = kAlpha_8_GrPixelConfig;
     desc.fWidth     = X_SIZE;
     desc.fHeight    = Y_SIZE;
-    desc.fSampleCnt = 0;
 
     // We are initializing the texture with zeros here
     GrTexture* texture = context->createUncachedTexture(desc, textureData, 0);