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

Unified Diff: include/core/SkCanvas.h

Issue 2225393002: Optimized implementation of quickReject() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleaning things up Created 4 years, 4 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
Index: include/core/SkCanvas.h
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index c3f8599db4d31be8c0b708c97bfce64efe24e334..59c5a5622851acd05948afab0b3cb057e9502dd0 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -566,29 +566,7 @@ public:
@return true if the horizontal band is completely clipped out (i.e. does
not intersect the current clip)
*/
- bool quickRejectY(SkScalar top, SkScalar bottom) const {
- SkASSERT(top <= bottom);
-
-#ifndef SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT
- // TODO: add a hasPerspective method similar to getLocalClipBounds. This
- // would cache the SkMatrix::hasPerspective result. Alternatively, have
- // the MC stack just set a hasPerspective boolean as it is updated.
- if (this->getTotalMatrix().hasPerspective()) {
- // TODO: consider implementing some half-plane test between the
- // two Y planes and the device-bounds (i.e., project the top and
- // bottom Y planes and then determine if the clip bounds is completely
- // outside either one).
- return false;
- }
-#endif
-
- const SkRect& clipR = this->getLocalClipBounds();
- // In the case where the clip is empty and we are provided with a
- // negative top and positive bottom parameter then this test will return
- // false even though it will be clipped. We have chosen to exclude that
- // check as it is rare and would result double the comparisons.
- return top >= clipR.fBottom || bottom <= clipR.fTop;
- }
+ bool quickRejectY(SkScalar top, SkScalar bottom) const;
/** Return the bounds of the current clip (in local coordinates) in the
bounds parameter, and return true if it is non-empty. This can be useful
@@ -1639,25 +1617,18 @@ private:
*/
bool canDrawBitmapAsSprite(SkScalar x, SkScalar y, int w, int h, const SkPaint&);
- /* These maintain a cache of the clip bounds in local coordinates,
- (converted to 2s-compliment if floats are slow).
+
+ /**
+ * Keep track of the device clip bounds and if the matrix is scale-translate. This allows
+ * us to do a fast quick reject in the common case.
*/
- mutable SkRect fCachedLocalClipBounds;
- mutable bool fCachedLocalClipBoundsDirty;
+ bool fIsScaleTranslate;
+ SkRect fDeviceClipBounds;
+
bool fAllowSoftClip;
bool fAllowSimplifyClip;
const bool fConservativeRasterClip;
- const SkRect& getLocalClipBounds() const {
- if (fCachedLocalClipBoundsDirty) {
- if (!this->getClipBounds(&fCachedLocalClipBounds)) {
- fCachedLocalClipBounds.setEmpty();
- }
- fCachedLocalClipBoundsDirty = false;
- }
- return fCachedLocalClipBounds;
- }
-
class AutoValidateClip : ::SkNoncopyable {
public:
explicit AutoValidateClip(SkCanvas* canvas) : fCanvas(canvas) {
« no previous file with comments | « bench/QuickRejectBench.cpp ('k') | src/core/SkCanvas.cpp » ('j') | src/core/SkCanvas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698