From 0799b6633d3bb916b2bc72d684ab5f88b9508b7d Mon Sep 17 00:00:00 2001 From: msarett Date: Thu, 11 Aug 2016 10:31:49 -0700 Subject: [PATCH] Delete quickRejectY() This is the first step in a refactor of quickReject(). TBR=reed@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2241473002 Change-Id: I6b7b02f1d59b9c21973155c1342d61b899fcf978 Review-Url: https://codereview.chromium.org/2241473002 --- include/core/SkCanvas.h | 34 ---------------------------------- src/core/SkPicturePlayback.cpp | 14 +++++++++++--- 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index d0f9f28575..5c1eac6017 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -515,40 +515,6 @@ class SK_API SkCanvas : public SkRefCnt { */ bool quickReject(const SkPath& path) const; - /** Return true if the horizontal band specified by top and bottom is - completely clipped out. This is a conservative calculation, meaning - that it is possible that if the method returns false, the band may still - in fact be clipped out, but the converse is not true. If this method - returns true, then the band is guaranteed to be clipped out. - @param top The top of the horizontal band to compare with the clip - @param bottom The bottom of the horizontal and to compare with the clip - @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; - } - /** 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 in a way similar to quickReject, in that it tells you that drawing diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index a5dd814b82..caf39879d7 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -349,7 +349,9 @@ void SkPicturePlayback::handleOp(SkReader32* reader, const SkPoint* pos = (const SkPoint*)reader->skip(points * sizeof(SkPoint)); const SkScalar top = reader->readScalar(); const SkScalar bottom = reader->readScalar(); - if (!canvas->quickRejectY(top, bottom)) { + SkRect clip; + canvas->getClipBounds(&clip); + if (top < clip.fBottom && bottom > clip.fTop) { canvas->drawPosText(text.text(), text.length(), pos, paint); } } break; @@ -371,7 +373,9 @@ void SkPicturePlayback::handleOp(SkReader32* reader, const SkScalar top = *xpos++; const SkScalar bottom = *xpos++; const SkScalar constY = *xpos++; - if (!canvas->quickRejectY(top, bottom)) { + SkRect clip; + canvas->getClipBounds(&clip); + if (top < clip.fBottom && bottom > clip.fTop) { canvas->drawPosTextH(text.text(), text.length(), xpos, constY, paint); } } break; @@ -416,7 +420,11 @@ void SkPicturePlayback::handleOp(SkReader32* reader, // ptr[1] == y // ptr[2] == top // ptr[3] == bottom - if (!canvas->quickRejectY(ptr[2], ptr[3])) { + SkRect clip; + canvas->getClipBounds(&clip); + float top = ptr[2]; + float bottom = ptr[3]; + if (top < clip.fBottom && bottom > clip.fTop) { canvas->drawText(text.text(), text.length(), ptr[0], ptr[1], paint); } } break;