Index: src/effects/SkColorCubeFilter.cpp |
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp |
index bfe28396ffbb741aab7d669b127f7b6137260a5c..f4ffefc8891284f9e6eec28997b6de57b1c16c75 100644 |
--- a/src/effects/SkColorCubeFilter.cpp |
+++ b/src/effects/SkColorCubeFilter.cpp |
@@ -354,12 +354,12 @@ GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* context) |
desc.fHeight = fCache.cubeDimension() * fCache.cubeDimension(); |
desc.fConfig = kRGBA_8888_GrPixelConfig; |
- GrSurface* surface = static_cast<GrSurface*>(context->findAndRefCachedResource(key)); |
- SkAutoTUnref<GrTexture> textureCube; |
- if (surface) { |
- textureCube.reset(surface->asTexture()); |
- } else { |
- textureCube.reset(context->createTexture(NULL, desc, key, fCubeData->data(), 0)); |
+ SkAutoTUnref<GrTexture> textureCube(context->findAndRefCachedTexture(key)); |
+ if (!textureCube) { |
+ textureCube.reset(context->createTexture(desc, fCubeData->data(), 0)); |
+ if (textureCube) { |
+ SkAssertResult(context->addResourceToCache(key, textureCube)); |
+ } |
} |
return textureCube ? GrColorCubeEffect::Create(textureCube) : NULL; |