OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #define __STDC_LIMIT_MACROS | 7 #define __STDC_LIMIT_MACROS |
8 | 8 |
9 #include "SkDraw.h" | 9 #include "SkDraw.h" |
10 #include "SkBlitter.h" | 10 #include "SkBlitter.h" |
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 , fGlyphCache(cache) | 1450 , fGlyphCache(cache) |
1451 , fBlitter(blitter) | 1451 , fBlitter(blitter) |
1452 , fClip(fUseRegionToDraw ? &draw.fRC->bwRgn() : nullptr) | 1452 , fClip(fUseRegionToDraw ? &draw.fRC->bwRgn() : nullptr) |
1453 , fDraw(draw) | 1453 , fDraw(draw) |
1454 , fPaint(paint) | 1454 , fPaint(paint) |
1455 , fClipBounds(PickClipBounds(draw)) { } | 1455 , fClipBounds(PickClipBounds(draw)) { } |
1456 | 1456 |
1457 void operator()(const SkGlyph& glyph, SkPoint position, SkPoint rounding) { | 1457 void operator()(const SkGlyph& glyph, SkPoint position, SkPoint rounding) { |
1458 position += rounding; | 1458 position += rounding; |
1459 // Prevent glyphs from being drawn outside of or straddling the edge of
device space. | 1459 // Prevent glyphs from being drawn outside of or straddling the edge of
device space. |
1460 if (position.fX > INT_MAX - (INT16_MAX + UINT16_MAX) || | 1460 // Comparisons written a little weirdly so that NaN coordinates are trea
ted safely. |
1461 position.fX < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/) || | 1461 auto gt = [](float a, int b) { return !(a <= (float)b); }; |
1462 position.fY > INT_MAX - (INT16_MAX + UINT16_MAX) || | 1462 auto lt = [](float a, int b) { return !(a >= (float)b); }; |
1463 position.fY < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)) { | 1463 if (gt(position.fX, INT_MAX - (INT16_MAX + UINT16_MAX)) || |
| 1464 lt(position.fX, INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)) || |
| 1465 gt(position.fY, INT_MAX - (INT16_MAX + UINT16_MAX)) || |
| 1466 lt(position.fY, INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/))) { |
1464 return; | 1467 return; |
1465 } | 1468 } |
1466 | 1469 |
1467 int left = SkScalarFloorToInt(position.fX); | 1470 int left = SkScalarFloorToInt(position.fX); |
1468 int top = SkScalarFloorToInt(position.fY); | 1471 int top = SkScalarFloorToInt(position.fY); |
1469 SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0); | 1472 SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0); |
1470 | 1473 |
1471 left += glyph.fLeft; | 1474 left += glyph.fLeft; |
1472 top += glyph.fTop; | 1475 top += glyph.fTop; |
1473 | 1476 |
1474 int right = left + glyph.fWidth; | 1477 int right = left + glyph.fWidth; |
1475 int bottom = top + glyph.fHeight; | 1478 int bottom = top + glyph.fHeight; |
1476 | 1479 |
1477 SkMask mask; | 1480 SkMask mask; |
1478 mask.fBounds.set(left, top, right, bottom); | 1481 mask.fBounds.set(left, top, right, bottom); |
| 1482 SkASSERT(!mask.fBounds.isEmpty()); |
1479 | 1483 |
1480 if (fUseRegionToDraw) { | 1484 if (fUseRegionToDraw) { |
1481 SkRegion::Cliperator clipper(*fClip, mask.fBounds); | 1485 SkRegion::Cliperator clipper(*fClip, mask.fBounds); |
1482 | 1486 |
1483 if (!clipper.done() && this->getImageData(glyph, &mask)) { | 1487 if (!clipper.done() && this->getImageData(glyph, &mask)) { |
1484 const SkIRect& cr = clipper.rect(); | 1488 const SkIRect& cr = clipper.rect(); |
1485 do { | 1489 do { |
1486 this->blitMask(mask, cr); | 1490 this->blitMask(mask, cr); |
1487 clipper.next(); | 1491 clipper.next(); |
1488 } while (!clipper.done()); | 1492 } while (!clipper.done()); |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 mask->fImage = SkMask::AllocImage(size); | 2080 mask->fImage = SkMask::AllocImage(size); |
2077 memset(mask->fImage, 0, mask->computeImageSize()); | 2081 memset(mask->fImage, 0, mask->computeImageSize()); |
2078 } | 2082 } |
2079 | 2083 |
2080 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2084 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2081 draw_into_mask(*mask, devPath, style); | 2085 draw_into_mask(*mask, devPath, style); |
2082 } | 2086 } |
2083 | 2087 |
2084 return true; | 2088 return true; |
2085 } | 2089 } |
OLD | NEW |