aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GpuLayerCacheTest.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-12-01 09:09:27 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-01 09:09:27 -0800
commit01d6e5f462d1d52203ee1a6660415877e4cf2dde (patch)
treeddbfc5b976c891adf2e318008043a76e9c4a7f8d /tests/GpuLayerCacheTest.cpp
parente05162d15741eb642080a31f28c38a99b3142dfb (diff)
Use variable length key (rather than accumulated matrix) as save layer hoisting key
Adding the rendering canvas' CTM to the layer hoisting key (i.e., Add support for hoisting layers in pictures drawn with a matrix - https://codereview.chromium.org/748853002/) has increased the cache miss rate due to accumulated floating point error. This CL fixes part of the issue by using the chain of operation indices leading to each saveLayer as the key. The canvas' CTM must still form part of the key but should be less subject to accumulated error. BUG=skia:2315 Review URL: https://codereview.chromium.org/753253002
Diffstat (limited to 'tests/GpuLayerCacheTest.cpp')
-rw-r--r--tests/GpuLayerCacheTest.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/tests/GpuLayerCacheTest.cpp b/tests/GpuLayerCacheTest.cpp
index 1043a208f5..43a845b11d 100644
--- a/tests/GpuLayerCacheTest.cpp
+++ b/tests/GpuLayerCacheTest.cpp
@@ -24,6 +24,10 @@ public:
static int Uses(GrCachedLayer* layer) {
return layer->uses();
}
+ static GrCachedLayer* Find(GrLayerCache* cache, uint32_t pictureID,
+ const SkMatrix& initialMat, const int* key, int keySize) {
+ return cache->findLayer(pictureID, initialMat, key, keySize);
+ }
};
// Add several layers to the cache
@@ -34,14 +38,16 @@ static void create_layers(skiatest::Reporter* reporter,
int idOffset) {
for (int i = 0; i < numToAdd; ++i) {
+ int indices[1] = { idOffset+i+1 };
GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(),
idOffset+i+1, idOffset+i+2,
SkIRect::MakeEmpty(),
SkMatrix::I(),
+ indices, 1,
NULL);
REPORTER_ASSERT(reporter, layer);
- GrCachedLayer* temp = cache->findLayer(picture.uniqueID(), idOffset + i + 1,
- SkIRect::MakeEmpty(), SkMatrix::I());
+ GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkMatrix::I(),
+ indices, 1);
REPORTER_ASSERT(reporter, temp == layer);
REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1);
@@ -111,8 +117,9 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) {
create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
for (int i = 0; i < kInitialNumLayers; ++i) {
- GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1,
- SkIRect::MakeEmpty(), SkMatrix::I());
+ int indices[1] = { i + 1 };
+ GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(),
+ indices, 1);
REPORTER_ASSERT(reporter, layer);
lock_layer(reporter, &cache, layer);
@@ -129,15 +136,19 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) {
// Unlock the textures
for (int i = 0; i < kInitialNumLayers; ++i) {
- GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1,
- SkIRect::MakeEmpty(), SkMatrix::I());
+ int indices[1] = { i+1 };
+
+ GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(),
+ indices, 1);
REPORTER_ASSERT(reporter, layer);
cache.removeUse(layer);
}
for (int i = 0; i < kInitialNumLayers; ++i) {
- GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1,
- SkIRect::MakeEmpty(), SkMatrix::I());
+ int indices[1] = { i+1 };
+
+ GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(),
+ indices, 1);
REPORTER_ASSERT(reporter, layer);
// All the layers should be unlocked
@@ -161,12 +172,13 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) {
}
{
+ int indices[1] = { kInitialNumLayers+1 };
+
// Add an additional layer. Since all the layers are unlocked this
// will force out the first atlased layer
create_layers(reporter, &cache, *picture, 1, kInitialNumLayers);
- GrCachedLayer* layer = cache.findLayer(picture->uniqueID(),
- kInitialNumLayers+1,
- SkIRect::MakeEmpty(), SkMatrix::I());
+ GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(),
+ indices, 1);
REPORTER_ASSERT(reporter, layer);
lock_layer(reporter, &cache, layer);
@@ -174,8 +186,10 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) {
}
for (int i = 0; i < kInitialNumLayers+1; ++i) {
- GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i + 1,
- SkIRect::MakeEmpty(), SkMatrix::I());
+ int indices[1] = { i+1 };
+
+ GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(),
+ indices, 1);
#if GR_CACHE_HOISTED_LAYERS
// 3 old layers plus the new one should be in the atlas.
if (1 == i || 2 == i || 3 == i || 5 == i) {