aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-08 03:57:19 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-08 03:57:19 +0000
commit5c70cdca5efe541b70d010e91607bf8626ea49ca (patch)
tree4099bb80e271cd9bf2a80dccbf3ec916b61f1fee
parente62513fb9274b65bcd9fecf61acc418dd3949df5 (diff)
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
-rw-r--r--experimental/PdfViewer/SkNulCanvas.h2
-rw-r--r--gyp/skia_for_chromium_defines.gypi3
-rw-r--r--include/core/SkCanvas.h18
-rw-r--r--src/core/SkCanvas.cpp30
-rw-r--r--src/utils/SkCanvasStateUtils.cpp3
-rw-r--r--src/utils/debugger/SkDebugCanvas.cpp4
-rw-r--r--src/utils/debugger/SkDebugCanvas.h3
-rw-r--r--tests/CanvasTest.cpp30
8 files changed, 72 insertions, 21 deletions
diff --git a/experimental/PdfViewer/SkNulCanvas.h b/experimental/PdfViewer/SkNulCanvas.h
index af933526f5..1c12a5b88f 100644
--- a/experimental/PdfViewer/SkNulCanvas.h
+++ b/experimental/PdfViewer/SkNulCanvas.h
@@ -84,7 +84,9 @@ public:
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE {return NULL;}
virtual bool isClipEmpty() const SK_OVERRIDE { return false; }
+#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; }
+#endif
virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
if (NULL != bounds) {
bounds->setXYWH(0, 0,
diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi
index 19741962ea..074be7838e 100644
--- a/gyp/skia_for_chromium_defines.gypi
+++ b/gyp/skia_for_chromium_defines.gypi
@@ -16,6 +16,9 @@
'SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG=1',
'SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS=1',
'SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG',
+ 'SK_SUPPORT_LEGACY_GETCLIPTYPE',
+ 'SK_SUPPORT_LEGACY_GETTOTALCLIP',
],
},
}
+
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index a987708c42..093185c940 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -19,6 +19,8 @@
#include "SkXfermode.h"
//#define SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
+//#define SK_SUPPORT_LEGACY_GETCLIPTYPE
+//#define SK_SUPPORT_LEGACY_GETTOTALCLIP
class SkBounder;
class SkBaseDevice;
@@ -1057,29 +1059,38 @@ public:
*/
virtual bool isClipEmpty() const;
+ /**
+ * Returns true if the current clip is just a (non-empty) rectangle.
+ * Returns false if the clip is empty, or if it is complex.
+ */
+ virtual bool isClipRect() const;
+
/** Return the current matrix on the canvas.
This does not account for the translate in any of the devices.
@return The current matrix on the canvas.
*/
const SkMatrix& getTotalMatrix() const;
+#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
enum ClipType {
kEmpty_ClipType = 0,
kRect_ClipType,
kComplex_ClipType
};
-
/** Returns a description of the total clip; may be cheaper than
getting the clip and querying it directly.
*/
virtual ClipType getClipType() const;
+#endif
+#ifdef SK_SUPPORT_LEGACY_GETTOTALCLIP
/** DEPRECATED -- need to move this guy to private/friend
* Return the current device clip (concatenation of all clip calls).
* This does not account for the translate in any of the devices.
* @return the current device clip (concatenation of all clip calls).
*/
const SkRegion& getTotalClip() const;
+#endif
/** Return the clip stack. The clip stack stores all the individual
* clips organized by the save/restore frame in which they were
@@ -1145,6 +1156,11 @@ public:
bool fDone;
};
+ // don't call
+ const SkRegion& internal_private_getTotalClip() const;
+ // don't call
+ void internal_private_getTotalClipAsPath(SkPath*) const;
+
protected:
// default impl defers to getDevice()->newSurface(info)
virtual SkSurface* onNewSurface(const SkImageInfo&);
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 58ec8fd4c5..9dcbfdbc38 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1526,7 +1526,7 @@ void SkCanvas::validateClip() const {
// construct clipRgn from the clipstack
const SkBaseDevice* device = this->getDevice();
if (!device) {
- SkASSERT(this->getTotalClip().isEmpty());
+ SkASSERT(this->isClipEmpty());
return;
}
@@ -1553,12 +1553,6 @@ void SkCanvas::validateClip() const {
}
}
}
-
-#if 0 // enable this locally for testing
- // now compare against the current rgn
- const SkRegion& rgn = this->getTotalClip();
- SkASSERT(rgn == tmpClip);
-#endif
}
#endif
@@ -1591,6 +1585,10 @@ bool SkCanvas::isClipEmpty() const {
return fMCRec->fRasterClip->isEmpty();
}
+bool SkCanvas::isClipRect() const {
+ return fMCRec->fRasterClip->isRect();
+}
+
bool SkCanvas::quickReject(const SkRect& rect) const {
if (!rect.isFinite())
@@ -1671,6 +1669,7 @@ const SkMatrix& SkCanvas::getTotalMatrix() const {
return *fMCRec->fMatrix;
}
+#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
SkCanvas::ClipType SkCanvas::getClipType() const {
if (fMCRec->fRasterClip->isEmpty()) {
return kEmpty_ClipType;
@@ -1680,10 +1679,27 @@ SkCanvas::ClipType SkCanvas::getClipType() const {
}
return kComplex_ClipType;
}
+#endif
+#ifdef SK_SUPPORT_LEGACY_GETTOTALCLIP
const SkRegion& SkCanvas::getTotalClip() const {
return fMCRec->fRasterClip->forceGetBW();
}
+#endif
+
+const SkRegion& SkCanvas::internal_private_getTotalClip() const {
+ return fMCRec->fRasterClip->forceGetBW();
+}
+
+void SkCanvas::internal_private_getTotalClipAsPath(SkPath* path) const {
+ path->reset();
+
+ const SkRegion& rgn = fMCRec->fRasterClip->forceGetBW();
+ if (rgn.isEmpty()) {
+ return;
+ }
+ (void)rgn.getBoundaryPath(path);
+}
SkBaseDevice* SkCanvas::createLayerDevice(const SkImageInfo& info) {
SkBaseDevice* device = this->getTopDevice();
diff --git a/src/utils/SkCanvasStateUtils.cpp b/src/utils/SkCanvasStateUtils.cpp
index 4b8868b02a..c5b558a1fb 100644
--- a/src/utils/SkCanvasStateUtils.cpp
+++ b/src/utils/SkCanvasStateUtils.cpp
@@ -194,7 +194,8 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
SkAutoTDelete<SkCanvasState> canvasState(SkNEW_ARGS(SkCanvasState, (canvas)));
// decompose the total matrix and clip
- setup_MC_state(&canvasState->mcState, canvas->getTotalMatrix(), canvas->getTotalClip());
+ setup_MC_state(&canvasState->mcState, canvas->getTotalMatrix(),
+ canvas->internal_private_getTotalClip());
/*
* decompose the layers
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 066d7a601a..08e6d94f9e 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -328,7 +328,9 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
canvas->restore();
}
fMatrix = canvas->getTotalMatrix();
- fClip = canvas->getTotalClip().getBounds();
+ if (!canvas->getClipDeviceBounds(&fClip)) {
+ fClip.setEmpty();
+ }
fIndex = index;
}
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index b9780369d1..0bbb640a98 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -226,9 +226,12 @@ public:
static const int kVizImageWidth = 256;
virtual bool isClipEmpty() const SK_OVERRIDE { return false; }
+ virtual bool isClipRect() const SK_OVERRIDE { return true; }
+#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
virtual ClipType getClipType() const SK_OVERRIDE {
return kRect_ClipType;
}
+#endif
virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
if (NULL != bounds) {
bounds->setXYWH(0, 0,
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index b3a63f1cbe..4b6f0fa3eb 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 @@ static void test_clipVisitor(skiatest::Reporter* reporter, SkCanvas* canvas) {
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 @@ static void SaveMatrixStep(SkCanvas* canvas,
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 @@ static void SaveClipStep(SkCanvas* canvas,
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 @@ static void SaveMatrixClipStep(SkCanvas* canvas,
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 @@ static void AssertCanvasStatesEqual(skiatest::Reporter* reporter,
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