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

Side by Side Diff: src/core/SkDraw.cpp

Issue 2085023002: Cherry-pick 875e13ca0 to M52. (Closed) Base URL: https://skia.googlesource.com/skia.git@m52
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/DrawTextTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 , fGlyphCache(cache) 1453 , fGlyphCache(cache)
1454 , fBlitter(blitter) 1454 , fBlitter(blitter)
1455 , fClip(fUseRegionToDraw ? &draw.fRC->bwRgn() : nullptr) 1455 , fClip(fUseRegionToDraw ? &draw.fRC->bwRgn() : nullptr)
1456 , fDraw(draw) 1456 , fDraw(draw)
1457 , fPaint(paint) 1457 , fPaint(paint)
1458 , fClipBounds(PickClipBounds(draw)) { } 1458 , fClipBounds(PickClipBounds(draw)) { }
1459 1459
1460 void operator()(const SkGlyph& glyph, SkPoint position, SkPoint rounding) { 1460 void operator()(const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
1461 position += rounding; 1461 position += rounding;
1462 // Prevent glyphs from being drawn outside of or straddling the edge of device space. 1462 // Prevent glyphs from being drawn outside of or straddling the edge of device space.
1463 if (position.fX > INT_MAX - (INT16_MAX + UINT16_MAX) || 1463 // Comparisons written a little weirdly so that NaN coordinates are trea ted safely.
1464 position.fX < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/) || 1464 auto gt = [](float a, int b) { return !(a <= (float)b); };
1465 position.fY > INT_MAX - (INT16_MAX + UINT16_MAX) || 1465 auto lt = [](float a, int b) { return !(a >= (float)b); };
1466 position.fY < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)) { 1466 if (gt(position.fX, INT_MAX - (INT16_MAX + UINT16_MAX)) ||
1467 lt(position.fX, INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)) ||
1468 gt(position.fY, INT_MAX - (INT16_MAX + UINT16_MAX)) ||
1469 lt(position.fY, INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/))) {
1467 return; 1470 return;
1468 } 1471 }
1469 1472
1470 int left = SkScalarFloorToInt(position.fX); 1473 int left = SkScalarFloorToInt(position.fX);
1471 int top = SkScalarFloorToInt(position.fY); 1474 int top = SkScalarFloorToInt(position.fY);
1472 SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0); 1475 SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0);
1473 1476
1474 left += glyph.fLeft; 1477 left += glyph.fLeft;
1475 top += glyph.fTop; 1478 top += glyph.fTop;
1476 1479
1477 int right = left + glyph.fWidth; 1480 int right = left + glyph.fWidth;
1478 int bottom = top + glyph.fHeight; 1481 int bottom = top + glyph.fHeight;
1479 1482
1480 SkMask mask; 1483 SkMask mask;
1481 mask.fBounds.set(left, top, right, bottom); 1484 mask.fBounds.set(left, top, right, bottom);
1485 SkASSERT(!mask.fBounds.isEmpty());
1482 1486
1483 if (fUseRegionToDraw) { 1487 if (fUseRegionToDraw) {
1484 SkRegion::Cliperator clipper(*fClip, mask.fBounds); 1488 SkRegion::Cliperator clipper(*fClip, mask.fBounds);
1485 1489
1486 if (!clipper.done() && this->getImageData(glyph, &mask)) { 1490 if (!clipper.done() && this->getImageData(glyph, &mask)) {
1487 const SkIRect& cr = clipper.rect(); 1491 const SkIRect& cr = clipper.rect();
1488 do { 1492 do {
1489 this->blitMask(mask, cr); 1493 this->blitMask(mask, cr);
1490 clipper.next(); 1494 clipper.next();
1491 } while (!clipper.done()); 1495 } while (!clipper.done());
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 mask->fImage = SkMask::AllocImage(size); 2083 mask->fImage = SkMask::AllocImage(size);
2080 memset(mask->fImage, 0, mask->computeImageSize()); 2084 memset(mask->fImage, 0, mask->computeImageSize());
2081 } 2085 }
2082 2086
2083 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2087 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2084 draw_into_mask(*mask, devPath, style); 2088 draw_into_mask(*mask, devPath, style);
2085 } 2089 }
2086 2090
2087 return true; 2091 return true;
2088 } 2092 }
OLDNEW
« 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