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 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 : fUseRegionToDraw(UsingRegionToDraw(draw.fRC)) | 1448 : fUseRegionToDraw(UsingRegionToDraw(draw.fRC)) |
1449 , fGlyphCache(cache) | 1449 , fGlyphCache(cache) |
1450 , fBlitter(blitter) | 1450 , fBlitter(blitter) |
1451 , fClip(fUseRegionToDraw ? &draw.fRC->bwRgn() : nullptr) | 1451 , fClip(fUseRegionToDraw ? &draw.fRC->bwRgn() : nullptr) |
1452 , fDraw(draw) | 1452 , fDraw(draw) |
1453 , fPaint(paint) | 1453 , fPaint(paint) |
1454 , fClipBounds(PickClipBounds(draw)) { } | 1454 , fClipBounds(PickClipBounds(draw)) { } |
1455 | 1455 |
1456 void operator()(const SkGlyph& glyph, SkPoint position, SkPoint rounding) { | 1456 void operator()(const SkGlyph& glyph, SkPoint position, SkPoint rounding) { |
1457 position += rounding; | 1457 position += rounding; |
1458 Sk48Dot16 fx = SkScalarTo48Dot16(position.fX); | |
1459 Sk48Dot16 fy = SkScalarTo48Dot16(position.fY); | |
1460 // Prevent glyphs from being drawn outside of or straddling the edge of
device space. | 1458 // Prevent glyphs from being drawn outside of or straddling the edge of
device space. |
1461 if ((fx >> 16) > INT_MAX - (INT16_MAX + UINT16_MAX) || | 1459 if (position.fX > INT_MAX - (INT16_MAX + UINT16_MAX) || |
1462 (fx >> 16) < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/) || | 1460 position.fX < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/) || |
1463 (fy >> 16) > INT_MAX - (INT16_MAX + UINT16_MAX) || | 1461 position.fY > INT_MAX - (INT16_MAX + UINT16_MAX) || |
1464 (fy >> 16) < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)) { | 1462 position.fY < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)) { |
1465 return; | 1463 return; |
1466 } | 1464 } |
1467 | 1465 |
1468 int left = Sk48Dot16FloorToInt(fx); | 1466 int left = SkScalarFloorToInt(position.fX); |
1469 int top = Sk48Dot16FloorToInt(fy); | 1467 int top = SkScalarFloorToInt(position.fY); |
1470 SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0); | 1468 SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0); |
1471 | 1469 |
1472 left += glyph.fLeft; | 1470 left += glyph.fLeft; |
1473 top += glyph.fTop; | 1471 top += glyph.fTop; |
1474 | 1472 |
1475 int right = left + glyph.fWidth; | 1473 int right = left + glyph.fWidth; |
1476 int bottom = top + glyph.fHeight; | 1474 int bottom = top + glyph.fHeight; |
1477 | 1475 |
1478 SkMask mask; | 1476 SkMask mask; |
1479 mask.fBounds.set(left, top, right, bottom); | 1477 mask.fBounds.set(left, top, right, bottom); |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 mask->fImage = SkMask::AllocImage(size); | 2069 mask->fImage = SkMask::AllocImage(size); |
2072 memset(mask->fImage, 0, mask->computeImageSize()); | 2070 memset(mask->fImage, 0, mask->computeImageSize()); |
2073 } | 2071 } |
2074 | 2072 |
2075 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2073 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2076 draw_into_mask(*mask, devPath, style); | 2074 draw_into_mask(*mask, devPath, style); |
2077 } | 2075 } |
2078 | 2076 |
2079 return true; | 2077 return true; |
2080 } | 2078 } |
OLD | NEW |