Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index baa002a54a5a0c387789e78b1003f4dc4399e955..3d29c9051fd39f7a747af6882a63ff0b1f7df801 100644 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -407,6 +407,33 @@ GrTexture* GrContext::createTexture(const GrTextureParams* params, |
return texture; |
} |
+GrTexture* GrContext::createCompressedTexture(const GrTextureParams* params, |
+ const GrTextureDesc& desc, |
+ const GrCacheID& cacheID, |
+ const void* srcData, |
+ GrCompressedFormat format, |
+ GrResourceKey* cacheKey) { |
+ GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID); |
+ |
+ GrTexture* texture = NULL; |
+ if (!GrTextureImpl::NeedsResizing(resourceKey)) { |
+ texture = fGpu->createCompressedTexture(desc, srcData, format); |
+ } |
+ |
+ if (NULL != texture) { |
+ // Adding a resource could put us overbudget. Try to free up the |
+ // necessary space before adding it. |
+ fResourceCache->purgeAsNeeded(1, texture->gpuMemorySize()); |
+ fResourceCache->addResource(resourceKey, texture); |
+ |
+ if (NULL != cacheKey) { |
+ *cacheKey = resourceKey; |
+ } |
+ } |
+ |
+ return texture; |
+} |
+ |
static GrTexture* create_scratch_texture(GrGpu* gpu, |
GrResourceCache* resourceCache, |
const GrTextureDesc& desc) { |