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/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);
 }