Index: src/core/SkCanvas.cpp |
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp |
index cd2065bd30daaa135d98507edd2b1f5b48c0b091..77256840fc903efb4fa82f8b8081f21858ece25f 100644 |
--- a/src/core/SkCanvas.cpp |
+++ b/src/core/SkCanvas.cpp |
@@ -1162,6 +1162,54 @@ void SkCanvas::onPopCull() { |
} |
///////////////////////////////////////////////////////////////////////////// |
+#ifdef SK_DEBUG |
+// Ensure that cull rects are properly nested in device space. |
robertphillips
2014/03/20 12:23:56
I think this is a bad name since it conflates vali
f(malita)
2014/03/20 13:30:58
Renamed to validateAndTrack().
|
+void SkCanvas::validateCull(const SkRect& cull) { |
+ SkRect mappedCull; |
+ this->getTotalMatrix().mapRect(&mappedCull, cull); |
+ |
+ // Take clipping into account. |
+ SkIRect devClip, devCull; |
+ this->getClipDeviceBounds(&devClip); |
+ mappedCull.roundOut(&devCull); |
+ if (!devCull.intersect(devClip)) |
robertphillips
2014/03/20 12:23:56
{} needed
f(malita)
2014/03/20 13:30:58
Done.
|
+ devCull.setEmpty(); |
+ |
+ if (!fCullStack.isEmpty() |
+ && !devCull.isEmpty() |
+ && !fCullStack.top().contains(devCull)) { |
+ 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 |
robertphillips
2014/03/20 12:23:56
This assert seems odd inside this code block.
f(malita)
2014/03/20 13:30:58
Hmm, the intention is to provide an easy way to se
|
+ SkASSERT(fCullStack.top().contains(devCull)); |
+#endif |
+ } |
+ |
+ fCullStack.push(devCull); // balanced in popCull |
+} |
+#endif |
+ |
+void SkCanvas::pushCull(const SkRect& cullRect) { |
robertphillips
2014/03/20 12:23:56
this->
|
+ SkDEBUGCODE(validateCull(cullRect)); |
+ |
+ ++fCullCount; |
+ this->onPushCull(cullRect); |
+} |
+ |
+void SkCanvas::popCull() { |
+ SkASSERT(fCullStack.count() == fCullCount); |
+ |
+ if (fCullCount > 0) { |
+ SkDEBUGCODE(fCullStack.pop()); |
+ --fCullCount; |
+ this->onPopCull(); |
+ } |
+} |
+ |
+///////////////////////////////////////////////////////////////////////////// |
void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap, |
const SkMatrix& matrix, const SkPaint* paint) { |