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

Unified Diff: src/core/SkDraw.cpp

Issue 2073873002: Simplify mask/clip intersection, making sure to explicitly check for an empty mask. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: revert old change Created 4 years, 6 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 | tests/DrawTextTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 24fc9064a6dd092a91301d3608834fb9256f9b87..9a0509c488b357a4b04ba1fd7e1d33a289c51006 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1457,10 +1457,13 @@ public:
void operator()(const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
position += rounding;
// Prevent glyphs from being drawn outside of or straddling the edge of device space.
- if (position.fX > INT_MAX - (INT16_MAX + UINT16_MAX) ||
- position.fX < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/) ||
- position.fY > INT_MAX - (INT16_MAX + UINT16_MAX) ||
- position.fY < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)) {
+ // Comparisons written a little weirdly so that NaN coordinates are treated safely.
+ auto gt = [](float a, int b) { return !(a <= (float)b); };
+ auto lt = [](float a, int b) { return !(a >= (float)b); };
+ if (gt(position.fX, INT_MAX - (INT16_MAX + UINT16_MAX)) ||
+ lt(position.fX, INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)) ||
+ gt(position.fY, INT_MAX - (INT16_MAX + UINT16_MAX)) ||
+ lt(position.fY, INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/))) {
return;
}
@@ -1476,6 +1479,7 @@ public:
SkMask mask;
mask.fBounds.set(left, top, right, bottom);
+ SkASSERT(!mask.fBounds.isEmpty());
if (fUseRegionToDraw) {
SkRegion::Cliperator clipper(*fClip, mask.fBounds);
« no previous file with comments | « no previous file | tests/DrawTextTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698