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

Unified Diff: tests/PictureStateTreeTest.cpp

Issue 617953002: Strip old backend recording down to essentials (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: debug-only Created 6 years, 3 months 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 | « src/core/SkPictureStateTree.cpp ('k') | tests/RecordingXfermodeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PictureStateTreeTest.cpp
diff --git a/tests/PictureStateTreeTest.cpp b/tests/PictureStateTreeTest.cpp
deleted file mode 100644
index cb154def9683941b53f347e9d5267644deb197af..0000000000000000000000000000000000000000
--- a/tests/PictureStateTreeTest.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkBBHFactory.h"
-#include "SkCanvas.h"
-#include "SkPictureRecorder.h"
-#include "SkPictureStateTree.h"
-#include "Test.h"
-
-static SkPicture* draw_scene(SkBBHFactory* bbhFactory) {
- SkPictureRecorder recorder;
- SkCanvas* canvas = recorder.beginRecording(200, 200, bbhFactory, 0);
-
- SkPaint p1, p2;
- p1.setStyle(SkPaint::kFill_Style);
- p1.setARGB(0x80, 0, 0xff, 0);
- p2.setStyle(SkPaint::kFill_Style);
- p2.setARGB(0x80, 0xff, 0, 0);
-
- canvas->drawColor(SK_ColorWHITE);
-
- // This is intended to exercise some tricky SkPictureStateTree code paths when
- // played back with various clips:
- //
- // * cleanup/rewind when the last draw is not at the root of the state tree.
- // * state nodes with both kSave_Flag & kSaveLayer_Flag set.
- // * state tree transitions which implicitly reset the matrix via. restore().
-
- canvas->save();
- canvas->translate(10, 10);
-
- canvas->drawRect(SkRect::MakeWH(100, 50), p1);
- canvas->drawRect(SkRect::MakeWH(50, 100), p2);
-
- SkRect layerBounds = SkRect::MakeXYWH(0, 0, 90, 90);
- canvas->saveLayer(&layerBounds, NULL);
- canvas->save();
- canvas->clipRect(layerBounds);
-
- canvas->save();
- canvas->clipRect(SkRect::MakeWH(25, 25));
- canvas->rotate(90);
- canvas->drawRect(SkRect::MakeWH(100, 50), p1);
- canvas->restore();
-
- canvas->save();
- canvas->clipRect(SkRect::MakeWH(25, 25));
- canvas->save();
- canvas->rotate(90);
- canvas->drawRect(SkRect::MakeWH(50, 100), p2);
- canvas->restore();
- canvas->drawRect(SkRect::MakeWH(100, 50), p1);
- canvas->restore();
- canvas->drawRect(SkRect::MakeXYWH(99, 99, 1, 1), p1);
- canvas->restore();
- canvas->restore();
-
- canvas->restore();
-
- return recorder.endRecording();
-}
-
-static void check_bms(skiatest::Reporter* reporter, const SkBitmap& bm1, const SkBitmap& bm2) {
- SkASSERT(bm1.getSize() == bm2.getSize());
- REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getAddr(0, 0), bm2.getAddr(0, 0), bm1.getSize()));
-}
-
-static void test_reference_picture(skiatest::Reporter* reporter) {
- SkRTreeFactory bbhFactory;
-
- SkAutoTUnref<SkPicture> bbhPicture(draw_scene(&bbhFactory));
- SkAutoTUnref<SkPicture> referencePicture(draw_scene(NULL));
-
- SkBitmap referenceBitmap;
- referenceBitmap.allocN32Pixels(100, 100);
- SkCanvas referenceCanvas(referenceBitmap);
-
- SkBitmap bbhBitmap;
- bbhBitmap.allocN32Pixels(100, 100);
- SkCanvas bbhCanvas(bbhBitmap);
-
- referenceCanvas.drawColor(SK_ColorTRANSPARENT);
- referenceCanvas.drawPicture(referencePicture.get());
- bbhCanvas.drawColor(SK_ColorTRANSPARENT);
- bbhCanvas.drawPicture(bbhPicture.get());
- REPORTER_ASSERT(reporter,
- referenceCanvas.getSaveCount() == bbhCanvas.getSaveCount());
- REPORTER_ASSERT(reporter,
- referenceCanvas.getTotalMatrix() == bbhCanvas.getTotalMatrix());
- check_bms(reporter, referenceBitmap, bbhBitmap);
-
- referenceCanvas.drawColor(SK_ColorTRANSPARENT);
- referenceCanvas.clipRect(SkRect::MakeWH(50, 50));
- referenceCanvas.drawPicture(referencePicture.get());
- bbhCanvas.drawColor(SK_ColorTRANSPARENT);
- bbhCanvas.clipRect(SkRect::MakeWH(50, 50));
- bbhCanvas.drawPicture(bbhPicture.get());
- REPORTER_ASSERT(reporter,
- referenceCanvas.getSaveCount() == bbhCanvas.getSaveCount());
- REPORTER_ASSERT(reporter,
- referenceCanvas.getTotalMatrix() == bbhCanvas.getTotalMatrix());
- check_bms(reporter, referenceBitmap, bbhBitmap);
-
- referenceCanvas.drawColor(SK_ColorTRANSPARENT);
- referenceCanvas.clipRect(SkRect::MakeWH(10, 10));
- referenceCanvas.drawPicture(referencePicture.get());
- bbhCanvas.drawColor(SK_ColorTRANSPARENT);
- bbhCanvas.clipRect(SkRect::MakeWH(10, 10));
- bbhCanvas.drawPicture(bbhPicture.get());
- REPORTER_ASSERT(reporter,
- referenceCanvas.getSaveCount() == bbhCanvas.getSaveCount());
- REPORTER_ASSERT(reporter,
- referenceCanvas.getTotalMatrix() == bbhCanvas.getTotalMatrix());
- check_bms(reporter, referenceBitmap, bbhBitmap);
-}
-
-DEF_TEST(PictureStateTree, reporter) {
- test_reference_picture(reporter);
-}
« no previous file with comments | « src/core/SkPictureStateTree.cpp ('k') | tests/RecordingXfermodeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698