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

Unified Diff: src/core/SkRecordDraw.cpp

Issue 971803002: Update SkPicture cull rects with RTree information (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix the bug breaking CC unit tests. Created 5 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRecordDraw.cpp
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index b66c721aee2346129e01a7b53ec504ede6543949..76c0ae378ae426bf1a5e9e224ff8f9477b8130ef 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -248,7 +248,18 @@ private:
Bounds clip = SkRect::Make(devBounds);
// We don't call adjustAndMap() because as its last step it would intersect the adjusted
// clip bounds with the previous clip, exactly what we can't do when the clip grows.
- fCurrentClipBounds = this->adjustForSaveLayerPaints(&clip) ? clip : fCullRect;
+ bool isBoundedClip = this->adjustForSaveLayerPaints(&clip);
+ if (isBoundedClip) {
mtklein 2015/03/06 18:18:50 Let's definitely create a little method for the as
+ bool intersects = clip.intersect(fCullRect);
+ if (intersects)
+ fCurrentClipBounds = clip;
+ else
+ fCurrentClipBounds = Bounds::MakeEmpty();
+ } else {
+ fCurrentClipBounds = fCullRect;
+ }
+ SkASSERT((fCurrentClipBounds.isEmpty() || fCullRect.contains(fCurrentClipBounds))
+ || (fCurrentClipBounds.isEmpty() && fCullRect.isEmpty()));
}
// Restore holds the devBounds for the clip after the {save,saveLayer}/restore block completes.
@@ -259,8 +270,18 @@ private:
// so they are not affected by the saveLayer's paint.
const int kSavesToIgnore = 1;
Bounds clip = SkRect::Make(op.devBounds);
- fCurrentClipBounds =
- this->adjustForSaveLayerPaints(&clip, kSavesToIgnore) ? clip : fCullRect;
+ bool isBoundedClip = this->adjustForSaveLayerPaints(&clip, kSavesToIgnore);
+ if (isBoundedClip) {
+ bool intersects = clip.intersect(fCullRect);
+ if (intersects)
+ fCurrentClipBounds = clip;
+ else
+ fCurrentClipBounds = Bounds::MakeEmpty();
+ } else {
+ fCurrentClipBounds = fCullRect;
+ }
+ SkASSERT((fCurrentClipBounds.isEmpty() || fCullRect.contains(fCurrentClipBounds))
+ || (fCurrentClipBounds.isEmpty() && fCullRect.isEmpty()));
}
// We also take advantage of SaveLayer bounds when present to further cut the clip down.
@@ -268,6 +289,8 @@ private:
if (op.bounds) {
// adjustAndMap() intersects these layer bounds with the previous clip for us.
fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint);
+ SkASSERT((fCurrentClipBounds.isEmpty() || fCullRect.contains(fCurrentClipBounds))
+ || (fCurrentClipBounds.isEmpty() && fCullRect.isEmpty()));
}
}
@@ -275,7 +298,11 @@ private:
// from the bounds of the ops in the same Save block.
void trackBounds(const Save&) { this->pushSaveBlock(NULL); }
void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); }
- void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); }
+ void trackBounds(const Restore&) {
+ fBounds[fCurrentOp] = this->popSaveBlock();
+ SkASSERT((fBounds[fCurrentOp].isEmpty() || fCullRect.contains(fBounds[fCurrentOp]))
+ || (fBounds[fCurrentOp].isEmpty() && fCullRect.isEmpty()));
+ }
void trackBounds(const SetMatrix&) { this->pushControl(); }
void trackBounds(const ClipRect&) { this->pushControl(); }
@@ -289,6 +316,8 @@ private:
// For all other ops, we can calculate and store the bounds directly now.
template <typename T> void trackBounds(const T& op) {
fBounds[fCurrentOp] = this->bounds(op);
+ SkASSERT((fBounds[fCurrentOp].isEmpty() || fCullRect.contains(fBounds[fCurrentOp]))
+ || (fBounds[fCurrentOp].isEmpty() && fCullRect.isEmpty()));
this->updateSaveBounds(fBounds[fCurrentOp]);
}
@@ -370,6 +399,8 @@ private:
}
void popControl(const Bounds& bounds) {
+ SkASSERT((bounds.isEmpty() || fCullRect.contains(bounds))
+ || (bounds.isEmpty() && fCullRect.isEmpty()));
fBounds[fControlIndices.top()] = bounds;
fControlIndices.pop();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698