aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
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
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')
-rw-r--r--tests/GpuLayerCacheTest.cpp40
-rw-r--r--tests/PictureTest.cpp2
-rw-r--r--tests/RecordReplaceDrawTest.cpp6
3 files changed, 32 insertions, 16 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) {
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 64073d3b00..7a8c8fa9e3 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -938,7 +938,7 @@ static void test_savelayer_extraction(skiatest::Reporter* reporter) {
// 2)
c->saveLayer(NULL, NULL); // layer #1
- c->translate(kWidth/2.0f, kHeight/2.0f);
+ c->translate(kWidth / 2.0f, kHeight / 2.0f);
SkRect r = SkRect::MakeXYWH(0, 0, kWidth/2, kHeight/2);
c->saveLayer(&r, &complexPaint); // layer #2
c->restore();
diff --git a/tests/RecordReplaceDrawTest.cpp b/tests/RecordReplaceDrawTest.cpp
index 5d407387da..8fc824d8cc 100644
--- a/tests/RecordReplaceDrawTest.cpp
+++ b/tests/RecordReplaceDrawTest.cpp
@@ -115,9 +115,11 @@ void test_replacements(skiatest::Reporter* r, bool useBBH) {
pic.reset(recorder.endRecording());
}
+ int key[1] = { 0 };
+
GrReplacements replacements;
- GrReplacements::ReplacementInfo* ri = replacements.newReplacement(pic->uniqueID(),
- 0, SkMatrix::I());
+ GrReplacements::ReplacementInfo* ri = replacements.newReplacement(pic->uniqueID(),
+ SkMatrix::I(), key, 1);
ri->fStop = 2;
ri->fPos.set(0, 0);
ri->fImage = make_image(SK_ColorRED);