diff options
author | robertphillips <robertphillips@google.com> | 2015-11-04 04:31:06 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-04 04:31:06 -0800 |
commit | 07b41eb962fdb007f788fcd82e338d7aef126064 (patch) | |
tree | ff76adbce640eef823be4e9f66a0978b7b77cddb | |
parent | 677de31a2f39b8230122f7cb569f2bcccee594d4 (diff) |
Update RecordReplaceDraw unit test
Review URL: https://codereview.chromium.org/1407143011
-rw-r--r-- | tests/RecordReplaceDrawTest.cpp | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/tests/RecordReplaceDrawTest.cpp b/tests/RecordReplaceDrawTest.cpp index 3074cfdc13..225185ddd3 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); } } |