Skip to content

Commit 5dfa02b

Browse files
herbderbySkia Commit-Bot
authored andcommitted
tighten up device bounds for glyphs
Change-Id: I61655b9492bdaacc2c1d5c7631b2e67af2b46668 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335280 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
1 parent e1bbd5c commit 5dfa02b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/gpu/text/GrTextBlob.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ GrSubRun* DirectMaskSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables
524524
GlyphVector::Variant* glyphIDs =
525525
alloc->makeArray<GlyphVector::Variant>(drawables.size());
526526

527+
// The lower bounds of drawing is always (0, 0). Since glyphs from the atlas can be at most
528+
// 256x256, use kMinPos to eliminate glyphs that have no pixels on the device.
529+
constexpr SkScalar kMinPos = 0 - SkStrikeCommon::kSkSideTooBigForAtlas;
527530
// Because this is the direct case, the maximum width or height is the size that fits in the
528531
// atlas. This boundary is checked below to ensure that the call to SkGlyphRect below will
529532
// not overflow.
@@ -536,7 +539,7 @@ GrSubRun* DirectMaskSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables
536539
// Ensure that the .offset() call below does not overflow. And, at this point none of the
537540
// rectangles are empty because they were culled before the run was created. Basically,
538541
// cull all the glyphs that can't appear on the screen.
539-
if (-kMaxPos < x && x < kMaxPos && -kMaxPos < y && y < kMaxPos) {
542+
if (kMinPos < x && x < kMaxPos && kMinPos < y && y < kMaxPos) {
540543
const SkGlyph* const skGlyph = variant;
541544
const SkGlyphRect deviceBounds =
542545
skGlyph->glyphRect().offset(SkScalarRoundToInt(x), SkScalarRoundToInt(y));

0 commit comments

Comments
 (0)