Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: tests/RecordReplaceDrawTest.cpp

Issue 1407143011: Update RecordReplaceDraw unit test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update parameter name Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordReplaceDrawTest.cpp
diff --git a/tests/RecordReplaceDrawTest.cpp b/tests/RecordReplaceDrawTest.cpp
index 3074cfdc13b3e029f76591c70434eb3750743473..225185ddd32ee69389b9ce8ddc7f0f6aff7c2334 100644
--- a/tests/RecordReplaceDrawTest.cpp
+++ b/tests/RecordReplaceDrawTest.cpp
@@ -90,15 +90,12 @@ DEF_TEST(RecordReplaceDraw_Unbalanced, r) {
}
// Test out the layer replacement functionality with and w/o a BBH
-void test_replacements(skiatest::Reporter* r, GrContext* context, bool useBBH) {
+void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace) {
SkAutoTUnref<const SkPicture> pic;
{
- SkRTreeFactory bbhFactory;
SkPictureRecorder recorder;
- SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight),
- useBBH ? &bbhFactory : nullptr);
-
+ SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
SkPaint paint;
canvas->saveLayer(nullptr, &paint);
canvas->clear(SK_ColorRED);
@@ -108,44 +105,38 @@ void test_replacements(skiatest::Reporter* r, GrContext* context, bool useBBH) {
pic.reset(recorder.endRecording());
}
- int key[1] = { 0 };
-
+ SkAutoTUnref<GrTexture> texture;
SkPaint paint;
GrLayerCache* layerCache = context->getLayerCache();
- GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2,
- SkIRect::MakeWH(kWidth, kHeight),
- SkIRect::MakeWH(kWidth, kHeight),
- SkMatrix::I(), key, 1, &paint);
- GrSurfaceDesc desc;
- desc.fConfig = kSkia8888_GrPixelConfig;
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fWidth = kWidth;
- desc.fHeight = kHeight;
- desc.fSampleCnt = 0;
+ if (doReplace) {
+ int key[1] = { 0 };
- SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc,
- false, nullptr, 0));
- layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight));
+ GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2,
+ SkIRect::MakeWH(kWidth, kHeight),
+ SkIRect::MakeWH(kWidth, kHeight),
+ SkMatrix::I(), key, 1, &paint);
- SkAutoTUnref<SkBBoxHierarchy> bbh;
+ GrSurfaceDesc desc;
+ desc.fConfig = kSkia8888_GrPixelConfig;
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fWidth = kWidth;
+ desc.fHeight = kHeight;
+ desc.fSampleCnt = 0;
+
+ texture.reset(context->textureProvider()->createTexture(desc, false, nullptr, 0));
+ layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight));
+ }
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
GrRecordReplaceDraw(pic, &canvas, layerCache, SkMatrix::I(), nullptr/*callback*/);
- int recount = rerecord.count();
- REPORTER_ASSERT(r, 2 == recount || 4 == recount);
-
- int index = 0;
- if (4 == recount) {
- assert_type<SkRecords::Save>(r, rerecord, 0);
- index += 1;
- }
- assert_type<SkRecords::DrawSprite>(r, rerecord, index + 0);
- assert_type<SkRecords::DrawRect>(r, rerecord, index + 1);
- if (4 == recount) {
- assert_type<SkRecords::Restore>(r, rerecord, 3);
+ int numLayers = count_instances_of_type<SkRecords::SaveLayer>(rerecord);
+ if (doReplace) {
+ REPORTER_ASSERT(r, 0 == numLayers);
+ } else {
+ REPORTER_ASSERT(r, 1 == numLayers);
}
}
@@ -160,8 +151,8 @@ DEF_GPUTEST(RecordReplaceDraw, r, factory) {
continue;
}
- test_replacements(r, context, true);
test_replacements(r, context, false);
+ test_replacements(r, context, true);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698