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

Unified Diff: tests/CanvasTest.cpp

Issue 1294013002: SkPaintFilterCanvas should inherit the target canvas state (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 4 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/utils/SkPaintFilterCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CanvasTest.cpp
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 0d5c86236075e6609f6f0a2705022566eb706f7f..5aa3d4662863efb96a4fd0d00d6e8e3b8b851ef5 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -52,6 +52,7 @@
#include "SkMatrix.h"
#include "SkNWayCanvas.h"
#include "SkPaint.h"
+#include "SkPaintFilterCanvas.h"
#include "SkPath.h"
#include "SkPicture.h"
#include "SkPictureRecord.h"
@@ -782,3 +783,38 @@ DEF_TEST(Canvas_ClipEmptyPath, reporter) {
canvas.clipPath(path); // should not assert here
canvas.restore();
}
+
+namespace {
+
+class MockFilterCanvas : public SkPaintFilterCanvas {
+public:
+ MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { }
+
+protected:
+ void onFilterPaint(SkPaint *paint, Type type) const override { }
+
+private:
+ typedef SkPaintFilterCanvas INHERITED;
+};
+
+} // anonymous namespace
+
+// SkPaintFilterCanvas should inherit the initial target canvas state.
+DEF_TEST(PaintFilterCanvas_ConsistentState, reporter) {
+ SkCanvas canvas(100, 100);
+ canvas.clipRect(SkRect::MakeXYWH(12.7f, 12.7f, 75, 75));
+ canvas.scale(0.5f, 0.75f);
+
+ SkRect clip1, clip2;
+
+ MockFilterCanvas filterCanvas(&canvas);
+ REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMatrix());
+ REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getClipBounds(&clip2));
+ REPORTER_ASSERT(reporter, clip1 == clip2);
+
+ filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100));
+ filterCanvas.scale(0.75f, 0.5f);
+ REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMatrix());
+ REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getClipBounds(&clip2));
+ REPORTER_ASSERT(reporter, clip1 == clip2);
+}
« no previous file with comments | « src/utils/SkPaintFilterCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698