| 1 |
From 43f969a9bce8019354d392f384fe10328655f924 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Michael Ludwig <[email protected]> |
| 3 |
Date: Tue, 19 May 2026 14:53:32 -0400 |
| 4 |
Subject: [PATCH] [ganesh] Require glyph padding to use linear sampling |
| 5 |
|
| 6 |
Bug: https://issues.chromium.org/issues/514017326 |
| 7 |
Change-Id: I9425c1f86aa8762333ba72b4ba30f5a056cdbfa9 |
| 8 |
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1239738 |
| 9 |
Commit-Queue: Michael Ludwig <[email protected]> |
| 10 |
Reviewed-by: Robert Phillips <[email protected]> |
| 11 |
--- |
| 12 |
src/gpu/ganesh/ops/AtlasTextOp.cpp | 19 +++++++++++++++---- |
| 13 |
1 file changed, 15 insertions(+), 4 deletions(-) |
| 14 |
|
| 15 |
--- a/src/gpu/ganesh/ops/AtlasTextOp.cpp |
| 16 |
+++ b/src/gpu/ganesh/ops/AtlasTextOp.cpp |
| 17 |
@@ -473,8 +473,12 @@ |
| 18 |
} else |
| 19 |
#endif |
| 20 |
{ |
| 21 |
- auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kLinear |
| 22 |
- : GrSamplerState::Filter::kNearest; |
| 23 |
+ // Only use linear padding if the glyphs were also padded for it. If we somehow get a direct |
| 24 |
+ // subrun with a corrupted transform, we should still use nearest neighbor since it was |
| 25 |
+ // packed tightly. |
| 26 |
+ const bool hasGlyphPadding = fHead->fSubRun.glyphSrcPadding() > 0; |
| 27 |
+ auto filter = fNeedsGlyphTransform && hasGlyphPadding ? GrSamplerState::Filter::kLinear |
| 28 |
+ : GrSamplerState::Filter::kNearest; |
| 29 |
// Bitmap text uses a single color, combineIfPossible ensures all geometries have the same |
| 30 |
// color, so we can use the first's without worry. |
| 31 |
flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make( |
| 32 |
@@ -620,8 +624,9 @@ |
| 33 |
} else |
| 34 |
#endif |
| 35 |
{ |
| 36 |
- auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kLinear |
| 37 |
- : GrSamplerState::Filter::kNearest; |
| 38 |
+ const bool hasGlyphPadding = fHead->fSubRun.glyphSrcPadding() > 0; |
| 39 |
+ auto filter = fNeedsGlyphTransform && hasGlyphPadding |
| 40 |
+ ? GrSamplerState::Filter::kLinear : GrSamplerState::Filter::kNearest; |
| 41 |
reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewViews(views, numActiveViews, filter); |
| 42 |
} |
| 43 |
} |
| 44 |
@@ -650,6 +655,12 @@ |
| 45 |
return CombineResult::kCannotCombine; |
| 46 |
} |
| 47 |
|
| 48 |
+ // We use the same filter for every Geometry that is combined, but the filter choice only looks |
| 49 |
+ // at the head's src padding, so we can only combine if we are consistent with that. |
| 50 |
+ if (fHead->fSubRun.glyphSrcPadding() != that->fHead->fSubRun.glyphSrcPadding()) { |
| 51 |
+ return CombineResult::kCannotCombine; |
| 52 |
+ } |
| 53 |
+ |
| 54 |
if (fProcessors != that->fProcessors) { |
| 55 |
return CombineResult::kCannotCombine; |
| 56 |
} |