Skip to content

Commit

Permalink
Delete quickRejectY()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mattsarett authored and nychitman1 committed Jan 7, 2017
1 parent a272c6d commit 0799b66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
34 changes: 0 additions & 34 deletions include/core/SkCanvas.h
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions src/core/SkPicturePlayback.cpp
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0799b66

Please sign in to comment.