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

Side by Side Diff: tests/CanvasTest.cpp

Issue 1577933002: SkPaintFilterCanvas skip-draw support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: lazy paint copy + missing onDrawImageNine override Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 /* Description: 8 /* Description:
9 * This test defines a series of elementatry test steps that perform 9 * This test defines a series of elementatry test steps that perform
10 * a single or a small group of canvas API calls. Each test step is 10 * a single or a small group of canvas API calls. Each test step is
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 canvas.restore(); 723 canvas.restore();
724 } 724 }
725 725
726 namespace { 726 namespace {
727 727
728 class MockFilterCanvas : public SkPaintFilterCanvas { 728 class MockFilterCanvas : public SkPaintFilterCanvas {
729 public: 729 public:
730 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } 730 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { }
731 731
732 protected: 732 protected:
733 void onFilterPaint(SkPaint *paint, Type type) const override { } 733 bool onFilter(const SkPaint*, Type, SkTLazy<SkPaint>*) const override { retu rn true; }
734 734
735 private: 735 private:
736 typedef SkPaintFilterCanvas INHERITED; 736 typedef SkPaintFilterCanvas INHERITED;
737 }; 737 };
738 738
739 } // anonymous namespace 739 } // anonymous namespace
740 740
741 // SkPaintFilterCanvas should inherit the initial target canvas state. 741 // SkPaintFilterCanvas should inherit the initial target canvas state.
742 DEF_TEST(PaintFilterCanvas_ConsistentState, reporter) { 742 DEF_TEST(PaintFilterCanvas_ConsistentState, reporter) {
743 SkCanvas canvas(100, 100); 743 SkCanvas canvas(100, 100);
744 canvas.clipRect(SkRect::MakeXYWH(12.7f, 12.7f, 75, 75)); 744 canvas.clipRect(SkRect::MakeXYWH(12.7f, 12.7f, 75, 75));
745 canvas.scale(0.5f, 0.75f); 745 canvas.scale(0.5f, 0.75f);
746 746
747 SkRect clip1, clip2; 747 SkRect clip1, clip2;
748 748
749 MockFilterCanvas filterCanvas(&canvas); 749 MockFilterCanvas filterCanvas(&canvas);
750 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 750 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
751 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 751 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
752 REPORTER_ASSERT(reporter, clip1 == clip2); 752 REPORTER_ASSERT(reporter, clip1 == clip2);
753 753
754 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); 754 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100));
755 filterCanvas.scale(0.75f, 0.5f); 755 filterCanvas.scale(0.75f, 0.5f);
756 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 756 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
757 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 757 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
758 REPORTER_ASSERT(reporter, clip1 == clip2); 758 REPORTER_ASSERT(reporter, clip1 == clip2);
759 } 759 }
OLDNEW
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698