Debian Codegraph @

debian/patches/CVE-2026-14414

raw
1 From b854499783643689c608a113a340d7c75460e215 Mon Sep 17 00:00:00 2001
2 From: Thomas Smith <[email protected]>
3 Date: Fri, 29 May 2026 11:35:55 -0400
4 Subject: [PATCH] Reland "Reconstruct subRun bounds from glyphs"
5
6 * Allow subRuns which are drawn with drawable or path rendering to exit gracefully instead of failing.
7
8 * Remove erroneous SFINAE
9
10 This reverts commit c480ba2eb2eba29a78b28b188cf2e8a3fb44dd49.
11
12 Original change's description:
13 > Revert "Reconstruct subRun bounds from glyphs"
14 >
15 > This reverts commit f93ed13d77fb28b1ab5c058c10bda3049ccbc5f5.
16 >
17 > Reason for revert: SkRemoteGlyphCacheTest failures and build failures
18 >
19 > ../../../../../skia/tests/SkRemoteGlyphCacheTest.cpp:193:37: error: unused function template 'get_container_ptr' [-Werror,-Wunused-template]
20 > 193 | const sktext::gpu::SubRunContainer* get_container_ptr(const T& t) {
21 > | ^~~~~~~~~~~~~~~~~
22 > ../../../../../skia/tests/SkRemoteGlyphCacheTest.cpp:212:37: error: unused function template 'get_container' [-Werror,-Wunused-template]
23 > 212 | const sktext::gpu::SubRunContainer* get_container(T* slugImpl) {
24 > | ^~~~~~~~~~~~~
25 > 2 errors generated.
26 >
27 > and
28 >
29 >
30 > ../../../../../skia/tests/SkRemoteGlyphCacheTest.cpp:660 Dst subrun is null for TransformedMaskSubRun [SkRemoteGlyphCache_SubRunBoundsReconstruction, OpenGL]
31 >
32 > Original change's description:
33 > > Reconstruct subRun bounds from glyphs
34 > >
35 > > * Reconstruct the bounds of a subRun after deserialization instead of packaging onto the VertexFiller.
36 > >
37 > > * An attacker could create a VertexFiller with creation bounds that did not contain its glyphs but were entirely contained within the current clip, enabling to the glyphs to ignore the creation bounds clip and sample from stale scratch textures
38 > >
39 > > Bug: b/513948227
40 > > Change-Id: Ib4902657e6a50dd5675db4d73a1576b77c4ce88e
41 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1239916
42 > > Commit-Queue: Thomas Smith <[email protected]>
43 > > Reviewed-by: Michael Ludwig <[email protected]>
44 >
45 > Bug: b/513948227
46 > No-Presubmit: true
47 > No-Tree-Checks: true
48 > No-Try: true
49 > Change-Id: Ide85466e17b870d2cc738bd25602d6cbf65d332b
50 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1249276
51 > Auto-Submit: Michael Ludwig <[email protected]>
52 > Commit-Queue: [email protected] <[email protected]>
53 > Bot-Commit: [email protected] <[email protected]>
54
55 Bug: https://issues.chromium.org/issues/513948227
56 Change-Id: I7f5bff928f1b58830075c1ec6ca15600d49519c9
57 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1249536
58 Reviewed-by: Michael Ludwig <[email protected]>
59 Commit-Queue: Thomas Smith <[email protected]>
60 ---
61 src/text/gpu/GlyphVector.h | 12 ++
62 src/text/gpu/SubRunContainer.cpp | 184 ++++++++++++++++---------
63 src/text/gpu/SubRunContainer.h | 8 +-
64 src/text/gpu/VertexFiller.cpp | 31 -----
65 src/text/gpu/VertexFiller.h | 11 +-
66 tests/SkRemoteGlyphCacheTest.cpp | 222 ++++++++++++++++++++++++++++++-
67 tools/text/gpu/TextBlobTools.cpp | 13 +-
68 tools/text/gpu/TextBlobTools.h | 2 +
69 8 files changed, 378 insertions(+), 105 deletions(-)
70
71 --- a/src/text/gpu/GlyphVector.h
72 +++ b/src/text/gpu/GlyphVector.h
73 @@ -58,6 +58,7 @@
74 SubRunAllocator* alloc);
75
76 SkSpan<const Glyph*> glyphs() const;
77 + int glyphCount() const { return SkToInt(fGlyphs.size()); }
78
79 static std::optional<GlyphVector> MakeFromBuffer(SkReadBuffer& buffer,
80 const SkStrikeClient* strikeClient,
81 @@ -68,6 +69,14 @@
82 // the sub runs.
83 int unflattenSize() const { return GlyphVectorSize(fGlyphs.size()); }
84
85 + SkPackedGlyphID getPackedGlyphID(int index) const {
86 + SkASSERT(index >= 0 && index < this->glyphCount());
87 + return fGlyphs[index].packedGlyphID;
88 + }
89 +
90 + SkStrikePromise& strikePromise() { return fStrikePromise; }
91 + const SkStrikePromise& strikePromise() const { return fStrikePromise; }
92 +
93 void packedGlyphIDToGlyph(StrikeCache* cache, skgpu::MaskFormat);
94
95 static size_t GlyphVectorSize(size_t count) {
96 --- a/src/text/gpu/SubRunContainer.cpp
97 +++ b/src/text/gpu/SubRunContainer.cpp
98 @@ -101,11 +101,89 @@
99 return accepted.get<0>();
100 }
101
102 -template <typename U>
103 -SkSpan<const SkPoint> get_positions(SkZip<U, const SkPoint> accepted) {
104 +template <typename U> SkSpan<const SkPoint> get_positions(SkZip<U, const SkPoint> accepted) {
105 return accepted.template get<1>();
106 }
107
108 +SkGlyphRect glyph_bounds(SkGlyphDigest digest, int inset, SkPoint origin) {
109 + return digest.bounds().inset(inset, inset).offset(origin);
110 +}
111 +
112 +SkGlyphRect glyph_bounds_from_left_top(SkGlyphDigest digest, int inset, SkPoint leftTop) {
113 + SkGlyphRect bounds = digest.bounds();
114 + SkPoint offset = leftTop - bounds.leftTop() - SkPoint{SkIntToScalar(inset),
115 + SkIntToScalar(inset)};
116 + return glyph_bounds(digest, inset, offset);
117 +}
118 +
119 +// Returns the empty span if there is a problem reading the positions.
120 +SkSpan<SkPoint> make_points_from_buffer(SkReadBuffer& buffer, SubRunAllocator* alloc) {
121 + uint32_t glyphCount = buffer.getArrayCount();
122 +
123 + // Zero indicates a problem with serialization.
124 + if (!buffer.validate(glyphCount != 0)) { return {}; }
125 +
126 + // Check that the count will not overflow the arena.
127 + if (!buffer.validate(glyphCount <= INT_MAX &&
128 + BagOfBytes::WillCountFit<SkPoint>(glyphCount))) { return {}; }
129 +
130 + SkPoint* positionsData = alloc->makePODArray<SkPoint>(glyphCount);
131 + if (!buffer.readPointArray({positionsData, glyphCount})) { return {}; }
132 + return {positionsData, glyphCount};
133 +}
134 +
135 +SkRect reconstruct_safe_bounds(SkSpan<const SkPoint> leftTop,
136 + GlyphVector* glyphVector,
137 + skglyph::ActionType actionType,
138 + int inset) {
139 + int count = leftTop.size();
140 +
141 + StrikeForGPU* strike = glyphVector->strikePromise().strike();
142 + StrikeMutationMonitor m{strike};
143 +
144 + SkGlyphRect boundingRect = skglyph::empty_rect();
145 + for (int i = 0; i < count; ++i) {
146 + SkPackedGlyphID packedID = glyphVector->getPackedGlyphID(i);
147 + SkGlyphDigest digest = strike->digestFor(actionType, packedID);
148 + boundingRect = skglyph::rect_union(
149 + boundingRect, glyph_bounds_from_left_top(digest, inset, leftTop[i]));
150 + }
151 + return boundingRect.empty() ? SkRect::MakeEmpty() : boundingRect.rect();
152 +}
153 +
154 +void flatten_vertex_filler(SkWriteBuffer &buffer, const VertexFiller& vf) {
155 + buffer.writeInt(static_cast<int>(vf.maskFormat()));
156 + buffer.writeBool(vf.canDrawDirect());
157 + buffer.writeMatrix(vf.creationMatrix());
158 + buffer.writePointArray(vf.topLefts());
159 +}
160 +
161 +std::optional<VertexFiller> make_vertex_filler_from_buffer(SkReadBuffer& buffer,
162 + SubRunAllocator* alloc,
163 + GlyphVector* glyphVector,
164 + skglyph::ActionType actionType,
165 + int inset) {
166 + MaskFormat maskFormat = buffer.read32LE(MaskFormat::kLast);
167 +
168 + const bool canDrawDirect = buffer.readBool();
169 +
170 + SkMatrix creationMatrix;
171 + buffer.readMatrix(&creationMatrix);
172 +
173 + SkSpan<SkPoint> leftTop = make_points_from_buffer(buffer, alloc);
174 + if (leftTop.empty()) {
175 + return std::nullopt;
176 + }
177 +
178 + if (!buffer.validate(glyphVector->glyphCount() == (int)leftTop.size())) {
179 + return std::nullopt;
180 + }
181 +
182 + SkRect safeBounds = reconstruct_safe_bounds(leftTop, glyphVector, actionType, inset);
183 +
184 + return VertexFiller{maskFormat, creationMatrix, safeBounds, leftTop, canDrawDirect};
185 +}
186 +
187 // -- PathOpSubmitter ------------------------------------------------------------------------------
188 // PathOpSubmitter holds glyph ids until ready to draw. During drawing, the glyph ids are
189 // converted to SkPaths. PathOpSubmitter can only be serialized when it is holding glyph ids;
190 @@ -196,7 +274,7 @@
191 SkScalar strikeToSourceScale = buffer.readScalar();
192 if (!buffer.validate(0 < strikeToSourceScale)) { return std::nullopt; }
193
194 - SkSpan<SkPoint> positions = MakePointsFromBuffer(buffer, alloc);
195 + SkSpan<SkPoint> positions = make_points_from_buffer(buffer, alloc);
196 if (positions.empty()) { return std::nullopt; }
197 const int glyphCount = SkCount(positions);
198
199 @@ -453,7 +531,7 @@
200 SkScalar strikeToSourceScale = buffer.readScalar();
201 if (!buffer.validate(0 < strikeToSourceScale)) { return std::nullopt; }
202
203 - SkSpan<SkPoint> positions = MakePointsFromBuffer(buffer, alloc);
204 + SkSpan<SkPoint> positions = make_points_from_buffer(buffer, alloc);
205 if (positions.empty()) { return std::nullopt; }
206 const int glyphCount = SkCount(positions);
207
208 @@ -594,6 +672,8 @@
209 // -- DirectMaskSubRun -----------------------------------------------------------------------------
210 class DirectMaskSubRun final : public AtlasSubRun {
211 public:
212 + static constexpr int kGlyphInsetting = 0;
213 +
214 DirectMaskSubRun(VertexFiller&& vertexFiller,
215 GlyphVector&& glyphs)
216 : AtlasSubRun(std::move(vertexFiller), std::move(glyphs)) {}
217 @@ -620,14 +700,11 @@
218 static SubRunOwner MakeFromBuffer(SkReadBuffer& buffer,
219 SubRunAllocator* alloc,
220 const SkStrikeClient* client) {
221 - auto vertexFiller = VertexFiller::MakeFromBuffer(buffer, alloc);
222 - if (!buffer.validate(vertexFiller.has_value())) { return nullptr; }
223 -
224 auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc);
225 if (!buffer.validate(glyphVector.has_value())) { return nullptr; }
226 - if (!buffer.validate(SkCount(glyphVector->glyphs()) == vertexFiller->count())) {
227 - return nullptr;
228 - }
229 + auto vertexFiller = make_vertex_filler_from_buffer(buffer, alloc, &glyphVector.value(),
230 + skglyph::kDirectMask, kGlyphInsetting);
231 + if (!buffer.validate(vertexFiller.has_value())) { return nullptr; }
232
233 SkASSERT(buffer.isValid());
234 return alloc->makeUnique<DirectMaskSubRun>(
235 @@ -649,7 +726,7 @@
236 fVertexFiller.unflattenSize();
237 }
238
239 - int glyphSrcPadding() const override { return 0; }
240 + int glyphSrcPadding() const override { return kGlyphInsetting; }
241
242 void testingOnly_packedGlyphIDToGlyph(StrikeCache* cache,
243 skgpu::MaskFormat maskFormat) const override {
244 @@ -689,14 +766,16 @@
245 }
246
247 void doFlatten(SkWriteBuffer& buffer) const override {
248 - fVertexFiller.flatten(buffer);
249 fGlyphs.flatten(buffer);
250 + flatten_vertex_filler(buffer, fVertexFiller);
251 }
252 };
253
254 // -- TransformedMaskSubRun ------------------------------------------------------------------------
255 class TransformedMaskSubRun final : public AtlasSubRun {
256 public:
257 + static constexpr int kGlyphInsetting = 0;
258 +
259 TransformedMaskSubRun(bool isBigEnough,
260 VertexFiller&& vertexFiller,
261 GlyphVector&& glyphs)
262 @@ -721,7 +800,7 @@
263 std::move(strikePromise), get_packedIDs(accepted), alloc);
264
265 return alloc->makeUnique<TransformedMaskSubRun>(
266 - initialPositionMatrix.getMaxScale() >= 1,
267 + AtlasSubRun::IsBigEnough(initialPositionMatrix),
268 std::move(vertexFiller),
269 std::move(glyphVector));
270 }
271 @@ -729,17 +808,16 @@
272 static SubRunOwner MakeFromBuffer(SkReadBuffer& buffer,
273 SubRunAllocator* alloc,
274 const SkStrikeClient* client) {
275 - auto vertexFiller = VertexFiller::MakeFromBuffer(buffer, alloc);
276 - if (!buffer.validate(vertexFiller.has_value())) { return nullptr; }
277 -
278 auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc);
279 if (!buffer.validate(glyphVector.has_value())) { return nullptr; }
280 - if (!buffer.validate(SkCount(glyphVector->glyphs()) == vertexFiller->count())) {
281 - return nullptr;
282 - }
283 + auto vertexFiller = make_vertex_filler_from_buffer(buffer, alloc, &glyphVector.value(),
284 + skglyph::kMask, kGlyphInsetting);
285 + if (!buffer.validate(vertexFiller.has_value())) { return nullptr; }
286 +
287 const bool isBigEnough = buffer.readBool();
288 return alloc->makeUnique<TransformedMaskSubRun>(
289 - isBigEnough, std::move(*vertexFiller), std::move(*glyphVector));
290 + AtlasSubRun::IsBigEnough(vertexFiller->creationMatrix()),
291 + std::move(*vertexFiller), std::move(*glyphVector));
292 }
293
294 int unflattenSize() const override {
295 @@ -761,7 +839,7 @@
296 fGlyphs.packedGlyphIDToGlyph(cache, maskFormat);
297 }
298
299 - int glyphSrcPadding() const override { return 1; }
300 + int glyphSrcPadding() const override { return 1; } // Padding NOT equal to insetting
301
302 void draw(SkCanvas*,
303 SkPoint drawOrigin,
304 @@ -795,9 +873,8 @@
305 }
306
307 void doFlatten(SkWriteBuffer& buffer) const override {
308 - fVertexFiller.flatten(buffer);
309 fGlyphs.flatten(buffer);
310 - buffer.writeBool(fIsBigEnough);
311 + flatten_vertex_filler(buffer, fVertexFiller);
312 }
313
314 private:
315 @@ -816,6 +893,8 @@
316
317 class SDFTSubRun final : public AtlasSubRun {
318 public:
319 + static constexpr int kGlyphInsetting = SK_DistanceFieldInset;
320 +
321 SDFTSubRun(bool useLCDText,
322 bool antiAliased,
323 const SDFTMatrixRange& matrixRange,
324 @@ -868,16 +947,13 @@
325 int useLCD = buffer.readInt();
326 int isAntiAliased = buffer.readInt();
327 SDFTMatrixRange matrixRange = SDFTMatrixRange::MakeFromBuffer(buffer);
328 - auto vertexFiller = VertexFiller::MakeFromBuffer(buffer, alloc);
329 - if (!buffer.validate(vertexFiller.has_value())) { return nullptr; }
330 - if (!buffer.validate(vertexFiller.value().grMaskType() == MaskFormat::kA8)) {
331 - return nullptr;
332 - }
333 +
334 auto glyphVector = GlyphVector::MakeFromBuffer(buffer, client, alloc);
335 if (!buffer.validate(glyphVector.has_value())) { return nullptr; }
336 - if (!buffer.validate(SkCount(glyphVector->glyphs()) == vertexFiller->count())) {
337 - return nullptr;
338 - }
339 + auto vertexFiller = make_vertex_filler_from_buffer(buffer, alloc, &glyphVector.value(),
340 + skglyph::kSDFT, kGlyphInsetting);
341 + if (!buffer.validate(vertexFiller.has_value())) { return nullptr; }
342 +
343 return alloc->makeUnique<SDFTSubRun>(useLCD,
344 isAntiAliased,
345 matrixRange,
346 @@ -900,7 +976,7 @@
347 fGlyphs.packedGlyphIDToGlyph(cache, maskFormat);
348 }
349
350 - int glyphSrcPadding() const override { return SK_DistanceFieldInset; }
351 + int glyphSrcPadding() const override { return kGlyphInsetting; }
352
353 void draw(SkCanvas*,
354 SkPoint drawOrigin,
355 @@ -932,8 +1008,8 @@
356 buffer.writeInt(fUseLCDText);
357 buffer.writeInt(fAntiAliased);
358 fMatrixRange.flatten(buffer);
359 - fVertexFiller.flatten(buffer);
360 fGlyphs.flatten(buffer);
361 + flatten_vertex_filler(buffer, fVertexFiller);
362 }
363
364 private:
365 @@ -975,6 +1051,7 @@
366
367 namespace sktext::gpu {
368 SubRun::~SubRun() = default;
369 +
370 void SubRun::flatten(SkWriteBuffer& buffer) const {
371 buffer.writeInt(this->subRunStreamTag());
372 this->doFlatten(buffer);
373 @@ -1106,11 +1183,7 @@
374 case GlyphAction::kAccept: {
375 SkPoint mappedPos = creationMatrix.mapPoint(pos);
376 const SkGlyphRect glyphBounds =
377 - digest.bounds()
378 - // The SDFT glyphs have 2-pixel wide padding that should
379 - // not be used in calculating the source rectangle.
380 - .inset(SK_DistanceFieldInset, SK_DistanceFieldInset)
381 - .offset(mappedPos);
382 + glyph_bounds(digest, SDFTSubRun::kGlyphInsetting, mappedPos);
383 boundingRect = skglyph::rect_union(boundingRect, glyphBounds);
384 acceptedBuffer[acceptedSize++] = std::make_tuple(packedID, glyphBounds.leftTop());
385 break;
386 @@ -1161,7 +1234,9 @@
387 case GlyphAction::kAccept: {
388 const SkPoint roundedPos{SkScalarFloorToScalar(mappedPos.x()),
389 SkScalarFloorToScalar(mappedPos.y())};
390 - const SkGlyphRect glyphBounds = digest.bounds().offset(roundedPos);
391 + const SkGlyphRect glyphBounds = glyph_bounds(digest,
392 + DirectMaskSubRun::kGlyphInsetting,
393 + roundedPos);
394 boundingRect = skglyph::rect_union(boundingRect, glyphBounds);
395 acceptedBuffer[acceptedSize++] =
396 std::make_tuple(packedID, glyphBounds.leftTop(), digest.maskFormat());
397 @@ -1202,7 +1277,8 @@
398 digest.actionFor(kMask)) {
399 case GlyphAction::kAccept: {
400 const SkPoint mappedPos = creationMatrix.mapPoint(pos);
401 - const SkGlyphRect glyphBounds = digest.bounds().offset(mappedPos);
402 + const SkGlyphRect glyphBounds =
403 + glyph_bounds(digest, TransformedMaskSubRun::kGlyphInsetting, mappedPos);
404 boundingRect = skglyph::rect_union(boundingRect, glyphBounds);
405 acceptedBuffer[acceptedSize++] =
406 std::make_tuple(packedID, glyphBounds.leftTop(), digest.maskFormat());
407 @@ -1250,7 +1326,7 @@
408 }
409
410 std::tuple<SkZip<const SkGlyphID, const SkPoint>, SkZip<SkGlyphID, SkPoint>>
411 - prepare_for_drawable_drawing(StrikeForGPU* strike,
412 +prepare_for_drawable_drawing(StrikeForGPU* strike,
413 SkZip<const SkGlyphID, const SkPoint> source,
414 SkZip<SkGlyphID, SkPoint> acceptedBuffer,
415 SkZip<SkGlyphID, SkPoint> rejectedBuffer) {
416 @@ -1637,20 +1713,4 @@
417 return true;
418 }
419
420 -// Returns the empty span if there is a problem reading the positions.
421 -SkSpan<SkPoint> MakePointsFromBuffer(SkReadBuffer& buffer, SubRunAllocator* alloc) {
422 - uint32_t glyphCount = buffer.getArrayCount();
423 -
424 - // Zero indicates a problem with serialization.
425 - if (!buffer.validate(glyphCount != 0)) { return {}; }
426 -
427 - // Check that the count will not overflow the arena.
428 - if (!buffer.validate(glyphCount <= INT_MAX &&
429 - BagOfBytes::WillCountFit<SkPoint>(glyphCount))) { return {}; }
430 -
431 - SkPoint* positionsData = alloc->makePODArray<SkPoint>(glyphCount);
432 - if (!buffer.readPointArray({positionsData, glyphCount})) { return {}; }
433 - return {positionsData, glyphCount};
434 -}
435 -
436 } // namespace sktext::gpu
437 --- a/src/text/gpu/SubRunContainer.h
438 +++ b/src/text/gpu/SubRunContainer.h
439 @@ -101,6 +101,7 @@
440
441 private:
442 friend class SubRunList;
443 + friend class TextBlobTools;
444 SubRunOwner fNext;
445 };
446
447 @@ -125,6 +126,10 @@
448 , fGlyphs{std::move(glyphs)} {}
449 ~AtlasSubRun() override = default;
450
451 + static bool IsBigEnough(const SkMatrix& matrix) {
452 + return matrix.getMaxScale() >= 1.f;
453 + }
454 +
455 SkSpan<const Glyph*> glyphs() const { return fGlyphs.glyphs(); }
456 int glyphCount() const { return SkCount(fGlyphs.glyphs()); }
457 skgpu::MaskFormat maskFormat() const { return fVertexFiller.grMaskType(); }
458 @@ -264,9 +269,6 @@
459 SubRunList fSubRuns;
460 };
461
462 -// Returns the empty span if there is a problem reading the positions.
463 -SkSpan<SkPoint> MakePointsFromBuffer(SkReadBuffer&, SubRunAllocator*);
464 -
465 } // namespace sktext::gpu
466
467 #endif // sktext_gpu_SubRunContainer_DEFINED
468 --- a/src/text/gpu/VertexFiller.cpp
469 +++ b/src/text/gpu/VertexFiller.cpp
470 @@ -44,37 +44,6 @@
471 maskType, creationMatrix, creationBounds, leftTop, fillerType == kIsDirect};
472 }
473
474 -std::optional<VertexFiller> VertexFiller::MakeFromBuffer(SkReadBuffer &buffer,
475 - SubRunAllocator *alloc) {
476 - int checkingMaskType = buffer.readInt();
477 - if (!buffer.validate(
478 - 0 <= checkingMaskType && checkingMaskType < skgpu::kMaskFormatCount)) {
479 - return std::nullopt;
480 - }
481 - MaskFormat maskType = (MaskFormat) checkingMaskType;
482 -
483 - const bool canDrawDirect = buffer.readBool();
484 -
485 - SkMatrix creationMatrix;
486 - buffer.readMatrix(&creationMatrix);
487 -
488 - SkRect creationBounds = buffer.readRect();
489 -
490 - SkSpan<SkPoint> leftTop = MakePointsFromBuffer(buffer, alloc);
491 - if (leftTop.empty()) { return std::nullopt; }
492 -
493 - SkASSERT(buffer.isValid());
494 - return VertexFiller{maskType, creationMatrix, creationBounds, leftTop, canDrawDirect};
495 -}
496 -
497 -void VertexFiller::flatten(SkWriteBuffer &buffer) const {
498 - buffer.writeInt(static_cast<int>(fMaskType));
499 - buffer.writeBool(fCanDrawDirect);
500 - buffer.writeMatrix(fCreationMatrix);
501 - buffer.writeRect(fCreationBounds);
502 - buffer.writePointArray(fLeftTop);
503 -}
504 -
505 SkMatrix VertexFiller::viewDifference(const SkMatrix &positionMatrix) const {
506 if (SkMatrix inverse; fCreationMatrix.invert(&inverse)) {
507 return SkMatrix::Concat(positionMatrix, inverse);
508 --- a/src/text/gpu/VertexFiller.h
509 +++ b/src/text/gpu/VertexFiller.h
510 @@ -37,6 +37,7 @@
511 namespace sktext::gpu {
512 class Glyph;
513 class SubRunAllocator;
514 +class AtlasSubRun;
515
516 enum FillerType {
517 kIsDirect,
518 @@ -68,13 +69,8 @@
519 SubRunAllocator *alloc,
520 FillerType fillerType);
521
522 - static std::optional<VertexFiller> MakeFromBuffer(SkReadBuffer &buffer,
523 - SubRunAllocator *alloc);
524 -
525 int unflattenSize() const { return fLeftTop.size_bytes(); }
526
527 - void flatten(SkWriteBuffer &buffer) const;
528 -
529 // These are only available if the Ganesh backend is compiled in (see GaneshVertexFiller.cpp)
530 size_t vertexStride(const SkMatrix &matrix) const;
531 void fillVertexData(int offset, int count,
532 @@ -105,7 +101,14 @@
533
534 int count() const { return SkCount(fLeftTop); }
535
536 + skgpu::MaskFormat maskFormat() const { return fMaskType; }
537 + bool canDrawDirect() const { return fCanDrawDirect; }
538 + const SkMatrix& creationMatrix() const { return fCreationMatrix; }
539 + SkSpan<const SkPoint> topLefts() const { return fLeftTop; }
540 +
541 private:
542 + friend class AtlasSubRun;
543 +
544 static std::tuple<bool, SkVector> CanUseDirect(const SkMatrix& creationMatrix,
545 const SkMatrix& positionMatrix);
546
547 --- a/tools/text/gpu/TextBlobTools.cpp
548 +++ b/tools/text/gpu/TextBlobTools.cpp
549 @@ -12,12 +12,17 @@
550
551 namespace sktext::gpu {
552
553 -const AtlasSubRun* TextBlobTools::FirstSubRun(const TextBlob* blob) {
554 - SkASSERT(blob);
555 - if (blob->fSubRuns->fSubRuns.isEmpty()) {
556 +const AtlasSubRun* TextBlobTools::FirstSubRun(const SubRunContainer* container) {
557 + SkASSERT(container);
558 + if (container->fSubRuns.isEmpty()) {
559 return nullptr;
560 }
561 - return blob->fSubRuns->fSubRuns.front().testingOnly_atlasSubRun();
562 + return container->fSubRuns.front().testingOnly_atlasSubRun();
563 +}
564 +
565 +const AtlasSubRun* TextBlobTools::FirstSubRun(const TextBlob* blob) {
566 + SkASSERT(blob);
567 + return FirstSubRun(blob->fSubRuns.get());
568 }
569
570 } // namespace sktext::gpu
571 --- a/tools/text/gpu/TextBlobTools.h
572 +++ b/tools/text/gpu/TextBlobTools.h
573 @@ -11,10 +11,12 @@
574 namespace sktext::gpu {
575 class AtlasSubRun;
576 class TextBlob;
577 +class SubRunContainer;
578
579 class TextBlobTools final {
580 public:
581 static const AtlasSubRun* FirstSubRun(const TextBlob*);
582 + static const AtlasSubRun* FirstSubRun(const SubRunContainer*);
583
584 private:
585 TextBlobTools();