aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-07 00:35:25 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-07 00:35:25 +0000
commit709906b74dc0179609e9f1455dc6e9e13675c0fa (patch)
treedd077f408c77952feb20dc06dd2f1a56df495725
parent8ac811e1604d7bddff33f4f52c00ada10b19c59a (diff)
Fix a perf regression introduced by r7594: when computing a texture cache key, use the resolved (Top or Bottom) surface origin, never Default, otherwise we never get a cache hit.
Covered by polygon, path benches. See also: https://code.google.com/p/chromium/issues/detail?id=174749. Review URL: https://codereview.appspot.com/7299059 git-svn-id: http://skia.googlecode.com/svn/trunk@7635 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/gpu/GrTexture.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 4dea2a6d5f..1e306613c8 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -151,6 +151,19 @@ GrResourceKey::ResourceType texture_resource_type() {
static const GrResourceKey::ResourceType gType = GrResourceKey::GenerateResourceType();
return gType;
}
+
+// FIXME: This should be refactored with the code in gl/GrGpuGL.cpp.
+GrSurfaceOrigin resolve_origin(const GrTextureDesc& desc) {
+ // By default, GrRenderTargets are GL's normal orientation so that they
+ // can be drawn to by the outside world without the client having
+ // to render upside down.
+ bool renderTarget = 0 != (desc.fFlags & kRenderTarget_GrTextureFlagBit);
+ if (kDefault_GrSurfaceOrigin == desc.fOrigin) {
+ return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
+ } else {
+ return desc.fOrigin;
+ }
+}
}
GrResourceKey GrTexture::ComputeKey(const GrGpu* gpu,
@@ -171,7 +184,7 @@ GrResourceKey GrTexture::ComputeScratchKey(const GrTextureDesc& desc) {
idKey.fData32[0] = (desc.fWidth) | (desc.fHeight << 16);
idKey.fData32[1] = desc.fConfig | desc.fSampleCnt << 16;
idKey.fData32[2] = desc.fFlags;
- idKey.fData32[3] = desc.fOrigin; // Only needs 2 bits actually
+ idKey.fData32[3] = resolve_origin(desc); // Only needs 2 bits actually
static const int kPadSize = sizeof(idKey) - 16;
GR_STATIC_ASSERT(kPadSize >= 0);
memset(idKey.fData8 + 16, 0, kPadSize);