From 72743b165424efc4ef6f6614add9033ea1ef31db Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 18 May 2015 14:53:43 -0700 Subject: Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (patchset #25 id:480001 of https://codereview.chromium.org/1112523006/) Reason for revert: win_chromium_compile_dbg_ng FAILED: ninja -t msvc -e environment.x86 -- E:\b\build\goma/gomacc "E:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\skia\src\core\skia.SkBitmapHeap.obj.rsp /c ..\..\third_party\skia\src\core\SkBitmapHeap.cpp /Foobj\third_party\skia\src\core\skia.SkBitmapHeap.obj /Fdobj\skia\skia.cc.pdb e:\b\build\slave\win\build\src\third_party\skia\include\core\skpicture.h(176) : error C2487: 'CURRENT_PICTURE_VERSION' : member of dll interface class may not be declared with dll interface Original issue's description: > Sketch splitting SkPicture into an interface and SkBigPicture. > > Adds small pictures for drawRect(), drawTextBlob(), and drawPath(). > These cover about 89% of draw calls from Blink SKPs, > and about 25% of draw calls from our GMs. > > SkPicture handles: > - serialization and deserialization > - unique IDs > > Everything else is left to the subclasses: > - playback(), cullRect() > - hasBitmap(), hasText(), suitableForGPU(), etc. > - LayerInfo / AccelData if applicable. > > The time to record a 1-op picture improves a good chunk > (2 mallocs to 1), and the time to record a 0-op picture > greatly improves (2 mallocs to none): > > picture_overhead_draw: 450ns -> 350ns > picture_overhead_nodraw: 300ns -> 90ns > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b > > Latest blink_linux_rel: > > http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/61248 > > Committed: https://skia.googlesource.com/skia/+/15877b6eae33a9282458bdb904a6d00440eca0ec TBR=reed@google.com,robertphillips@google.com,fmalita@chromium.org,mtklein@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1130283004 --- tests/GpuLayerCacheTest.cpp | 5 +---- tests/PictureTest.cpp | 46 +++++++++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/GpuLayerCacheTest.cpp b/tests/GpuLayerCacheTest.cpp index efb1ec1c20..6b3084b641 100644 --- a/tests/GpuLayerCacheTest.cpp +++ b/tests/GpuLayerCacheTest.cpp @@ -111,10 +111,7 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) { } SkPictureRecorder recorder; - SkCanvas* c = recorder.beginRecording(1, 1); - // Draw something, anything, to prevent an empty-picture optimization, - // which is a singleton and never purged. - c->drawRect(SkRect::MakeWH(1,1), SkPaint()); + recorder.beginRecording(1, 1); SkAutoTUnref picture(recorder.endRecording()); GrLayerCache cache(context); diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index 0ccef3f0a9..16d98b3245 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -23,7 +23,6 @@ #include "SkPictureUtils.h" #include "SkPixelRef.h" #include "SkPixelSerializer.h" -#include "SkMiniRecorder.h" #include "SkRRect.h" #include "SkRandom.h" #include "SkRecord.h" @@ -364,10 +363,9 @@ static void test_savelayer_extraction(skiatest::Reporter* reporter) { // Now test out the SaveLayer extraction if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) { - const SkBigPicture* bp = pict->asSkBigPicture(); - REPORTER_ASSERT(reporter, bp); + SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); - const SkBigPicture::AccelData* data = bp->accelData(); + const SkPicture::AccelData* data = pict->EXPERIMENTAL_getAccelData(key); REPORTER_ASSERT(reporter, data); const SkLayerInfo *gpuData = static_cast(data); @@ -1109,6 +1107,30 @@ static void test_gen_id(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, hasData->uniqueID() != empty->uniqueID()); } +static void test_bytes_used(skiatest::Reporter* reporter) { + SkPictureRecorder recorder; + + recorder.beginRecording(0, 0); + SkAutoTUnref empty(recorder.endRecording()); + + // Sanity check to make sure we aren't under-measuring. + REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) >= + sizeof(SkPicture) + sizeof(SkRecord)); + + // Protect against any unintentional bloat. + size_t approxUsed = SkPictureUtils::ApproximateBytesUsed(empty.get()); + REPORTER_ASSERT(reporter, approxUsed <= 432); + + // Sanity check of nested SkPictures. + SkPictureRecorder r2; + r2.beginRecording(0, 0); + r2.getRecordingCanvas()->drawPicture(empty.get()); + SkAutoTUnref nested(r2.endRecording()); + + REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get()) >= + SkPictureUtils::ApproximateBytesUsed(empty.get())); +} + DEF_TEST(Picture, reporter) { #ifdef SK_DEBUG test_deleting_empty_picture(); @@ -1129,6 +1151,7 @@ DEF_TEST(Picture, reporter) { test_hierarchical(reporter); test_gen_id(reporter); test_savelayer_extraction(reporter); + test_bytes_used(reporter); } static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) { @@ -1244,10 +1267,7 @@ DEF_TEST(Picture_SkipBBH, r) { SpoonFedBBHFactory factory(&bbh); SkPictureRecorder recorder; - SkCanvas* c = recorder.beginRecording(bound, &factory); - // Record a few ops so we don't hit a small- or empty- picture optimization. - c->drawRect(bound, SkPaint()); - c->drawRect(bound, SkPaint()); + recorder.beginRecording(bound, &factory); SkAutoTUnref picture(recorder.endRecording()); SkCanvas big(640, 480), small(300, 200); @@ -1303,13 +1323,3 @@ DEF_TEST(Picture_getRecordingCanvas, r) { REPORTER_ASSERT(r, !rec.getRecordingCanvas()); } } - -DEF_TEST(MiniRecorderLeftHanging, r) { - // Any shader or other ref-counted effect will do just fine here. - SkPaint paint; - paint.setShader(SkShader::CreateColorShader(SK_ColorRED))->unref(); - - SkMiniRecorder rec; - REPORTER_ASSERT(r, rec.drawRect(SkRect::MakeWH(20,30), paint)); - // Don't call rec.detachPicture(). Test succeeds by not asserting or leaking the shader. -} -- cgit v1.2.3