hide getTotalClip, so we can eventually remove it
hide getClipType, so we can eventually remove it
patch from issue 189443007
TBR=robertphilips@google.com
Author: reed@chromium.org
Review URL: https://codereview.chromium.org/189883010
git-svn-id: http://skia.googlecode.com/svn/trunk@13715 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index b3a63f1..4b6f0fa 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -64,6 +64,20 @@
#include "SkTDArray.h"
#include "Test.h"
+static bool equal_clips(const SkCanvas& a, const SkCanvas& b) {
+ if (a.isClipEmpty()) {
+ return b.isClipEmpty();
+ }
+ if (!a.isClipRect()) {
+ // this is liberally true, since we don't expose a way to know this exactly (for non-rects)
+ return !b.isClipRect();
+ }
+ SkIRect ar, br;
+ a.getClipDeviceBounds(&ar);
+ b.getClipDeviceBounds(&br);
+ return ar == br;
+}
+
class Canvas2CanvasClipVisitor : public SkCanvas::ClipVisitor {
public:
Canvas2CanvasClipVisitor(SkCanvas* target) : fTarget(target) {}
@@ -92,7 +106,7 @@
Canvas2CanvasClipVisitor visitor(&c);
canvas->replayClips(&visitor);
- REPORTER_ASSERT(reporter, c.getTotalClip() == canvas->getTotalClip());
+ REPORTER_ASSERT(reporter, equal_clips(c, *canvas));
}
static const int kWidth = 2;
@@ -369,8 +383,7 @@
testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalMatrix().isIdentity(),
testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() == kTestRegion,
- testStep->assertMessage());
+// REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() == kTestRegion, testStep->assertMessage());
}
TEST_STEP(SaveMatrix, SaveMatrixStep);
@@ -386,8 +399,7 @@
testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, !canvas->getTotalMatrix().isIdentity(),
testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion,
- testStep->assertMessage());
+// REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion, testStep->assertMessage());
}
TEST_STEP(SaveClip, SaveClipStep);
@@ -403,8 +415,7 @@
testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalMatrix().isIdentity(),
testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion,
- testStep->assertMessage());
+// REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion, testStep->assertMessage());
}
TEST_STEP(SaveMatrixClip, SaveMatrixClipStep);
@@ -628,10 +639,7 @@
canvas2->getBounder(), testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, canvas1->getTotalMatrix() ==
canvas2->getTotalMatrix(), testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, canvas1->getClipType() ==
- canvas2->getClipType(), testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, canvas1->getTotalClip() ==
- canvas2->getTotalClip(), testStep->assertMessage());
+ REPORTER_ASSERT_MESSAGE(reporter, equal_clips(*canvas1, *canvas2), testStep->assertMessage());
// The following test code is commented out because the test fails when
// the canvas is an SkPictureRecord or SkDeferredCanvas