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

Unified Diff: src/core/SkCanvas.cpp

Issue 200923008: Fix cull nesting assertion. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Split validation method. Created 6 years, 9 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 | « include/core/SkCanvas.h ('k') | src/core/SkPictureRecord.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index cd2065bd30daaa135d98507edd2b1f5b48c0b091..787d89d184a3a87ddf88be1a7aa1b6556f7aa313 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1162,6 +1162,60 @@ void SkCanvas::onPopCull() {
}
/////////////////////////////////////////////////////////////////////////////
+#ifdef SK_DEBUG
+// Ensure that cull rects are monotonically nested in device space.
+void SkCanvas::validateCull(const SkIRect& devCull) {
+ if (fCullStack.isEmpty()
+ || devCull.isEmpty()
+ || fCullStack.top().contains(devCull)) {
+ return;
+ }
+
+ SkDEBUGF(("Invalid cull: [%d %d %d %d] (previous cull: [%d %d %d %d])\n",
+ devCull.x(), devCull.y(), devCull.right(), devCull.bottom(),
+ fCullStack.top().x(), fCullStack.top().y(),
+ fCullStack.top().right(), fCullStack.top().bottom()));
+
+#ifdef ASSERT_NESTED_CULLING
+ SkDEBUGFAIL("Invalid cull.");
+#endif
+}
+#endif
+
+void SkCanvas::pushCull(const SkRect& cullRect) {
+ ++fCullCount;
+ this->onPushCull(cullRect);
+
+#ifdef SK_DEBUG
+ // Map the cull rect into device space.
+ SkRect mappedCull;
+ this->getTotalMatrix().mapRect(&mappedCull, cullRect);
+
+ // Take clipping into account.
+ SkIRect devClip, devCull;
+ mappedCull.roundOut(&devCull);
+ this->getClipDeviceBounds(&devClip);
+ if (!devCull.intersect(devClip)) {
+ devCull.setEmpty();
+ }
+
+ this->validateCull(devCull);
+ fCullStack.push(devCull); // balanced in popCull
+#endif
+}
+
+void SkCanvas::popCull() {
+ SkASSERT(fCullStack.count() == fCullCount);
+
+ if (fCullCount > 0) {
+ --fCullCount;
+ this->onPopCull();
+
+ SkDEBUGCODE(fCullStack.pop());
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint* paint) {
« no previous file with comments | « include/core/SkCanvas.h ('k') | src/core/SkPictureRecord.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698