Skip to content

Commit 00ae959

Browse files
herbderbySkia Commit-Bot
authored andcommitted
Start cleanup of GrTextBlob
* Make a single private section * Reorganzie private section * Start making const things const Change-Id: I88081d02ee6034234d35d15306bffb47ce63ac8c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257688 Commit-Queue: Herb Derby <herb@google.com> Commit-Queue: Ben Wagner <bungeman@google.com> Auto-Submit: Herb Derby <herb@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
1 parent 75368c3 commit 00ae959

File tree

2 files changed

+47
-41
lines changed

2 files changed

+47
-41
lines changed

src/gpu/text/GrTextBlob.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ sk_sp<GrTextBlob> GrTextBlob::Make(int glyphCount,
4242
sk_bzero(allocation, size);
4343
}
4444

45-
sk_sp<GrTextBlob> blob{new (allocation) GrTextBlob{strikeCache, color, forceWForDistanceFields}};
46-
blob->fSize = size;
45+
sk_sp<GrTextBlob> blob{new (allocation) GrTextBlob{
46+
size, strikeCache, color, forceWForDistanceFields}};
4747

4848
// setup offsets for vertices / glyphs
4949
blob->fVertices = SkTAddOffset<char>(blob.get(), vertex);
@@ -354,6 +354,13 @@ void GrTextBlob::AssertEqual(const GrTextBlob& l, const GrTextBlob& r) {
354354
}
355355
}
356356

357+
GrTextBlob::GrTextBlob(size_t size, GrStrikeCache* strikeCache, GrColor color,
358+
bool forceWForDistanceFields)
359+
: fSize{size}
360+
, fStrikeCache{strikeCache}
361+
, fForceWForDistanceFields{forceWForDistanceFields}
362+
, fColor{color} { }
363+
357364
void GrTextBlob::SubRun::computeTranslation(const SkMatrix& viewMatrix,
358365
SkScalar x, SkScalar y, SkScalar* transX,
359366
SkScalar* transY) {

src/gpu/text/GrTextBlob.h

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,6 @@ class GrTextBlob : public SkNVRefCnt<GrTextBlob>, public SkGlyphRunPainterInterf
231231
const SkSurfaceProps&, const GrDistanceFieldAdjustTable*,
232232
GrTextTarget*);
233233

234-
private:
235-
GrTextBlob(GrStrikeCache* strikeCache, GrColor color, bool forceWForDistanceFields)
236-
: fColor{color}
237-
, fStrikeCache{strikeCache}
238-
, fForceWForDistanceFields{forceWForDistanceFields} { }
239-
240-
// This function will only be called when we are generating a blob from scratch. We record the
241-
// initial view matrix and initial offsets(x,y), because we record vertex bounds relative to
242-
// these numbers. When blobs are reused with new matrices, we need to return to model space so
243-
// we can update the vertex bounds appropriately.
244-
void setupViewMatrix(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
245-
fInitialViewMatrix = viewMatrix;
246-
if (!viewMatrix.invert(&fInitialViewMatrixInverse)) {
247-
fInitialViewMatrixInverse = SkMatrix::I();
248-
}
249-
fInitialX = x;
250-
fInitialY = y;
251-
}
252-
253234
public:
254235
// Any glyphs that can't be rendered with the base or override descriptor
255236
// are rendered as paths
@@ -396,6 +377,33 @@ class GrTextBlob : public SkNVRefCnt<GrTextBlob>, public SkGlyphRunPainterInterf
396377
SkScalar maxScale);
397378

398379
private:
380+
GrTextBlob(
381+
size_t size, GrStrikeCache* strikeCache, GrColor color, bool forceWForDistanceFields);
382+
383+
struct StrokeInfo {
384+
SkScalar fFrameWidth;
385+
SkScalar fMiterLimit;
386+
SkPaint::Join fJoin;
387+
};
388+
389+
enum TextType {
390+
kHasDistanceField_TextType = 0x1,
391+
kHasBitmap_TextType = 0x2,
392+
};
393+
394+
// This function will only be called when we are generating a blob from scratch. We record the
395+
// initial view matrix and initial offsets(x,y), because we record vertex bounds relative to
396+
// these numbers. When blobs are reused with new matrices, we need to return to model space so
397+
// we can update the vertex bounds appropriately.
398+
void setupViewMatrix(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
399+
fInitialViewMatrix = viewMatrix;
400+
if (!viewMatrix.invert(&fInitialViewMatrixInverse)) {
401+
fInitialViewMatrixInverse = SkMatrix::I();
402+
}
403+
fInitialX = x;
404+
fInitialY = y;
405+
}
406+
399407
std::unique_ptr<GrAtlasTextOp> makeOp(
400408
SubRun& info, int glyphCount,
401409
const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const SkIRect& clipRect,
@@ -418,7 +426,18 @@ class GrTextBlob : public SkNVRefCnt<GrTextBlob>, public SkGlyphRunPainterInterf
418426
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
419427
const SkStrikeSpec& strikeSpec) override;
420428

429+
// Overall size of this struct plus vertices and glyphs at the end.
430+
const size_t fSize;
421431

432+
// Lifetime: The GrStrikeCache is owned by and has the same lifetime as the GrRecordingContext.
433+
// The GrRecordingContext also owns the GrTextBlob cache which owns this GrTextBlob.
434+
GrStrikeCache* const fStrikeCache;
435+
436+
// From the distance field options to force distance fields to have a W coordinate.
437+
const bool fForceWForDistanceFields;
438+
439+
// The color of the text to draw for solid colors.
440+
const GrColor fColor;
422441

423442
// Pool of bytes for vertex data.
424443
char* fVertices;
@@ -432,24 +451,11 @@ class GrTextBlob : public SkNVRefCnt<GrTextBlob>, public SkGlyphRunPainterInterf
432451
// Assume one run per text blob.
433452
SkSTArray<1, SubRun> fSubRuns;
434453

435-
// The color of the text to draw for solid colors.
436-
const GrColor fColor;
437-
438-
// Lifetime: The GrStrikeCache is owned by and has the same lifetime as the GrRecordingContext.
439-
// The GrRecordingContext also owns the GrTextBlob cache which owns this GrTextBlob.
440-
GrStrikeCache* const fStrikeCache;
441454
SkMaskFilterBase::BlurRec fBlurRec;
442-
443-
struct StrokeInfo {
444-
SkScalar fFrameWidth;
445-
SkScalar fMiterLimit;
446-
SkPaint::Join fJoin;
447-
};
448455
StrokeInfo fStrokeInfo;
449456
Key fKey;
450457
SkMatrix fInitialViewMatrix;
451458
SkMatrix fInitialViewMatrixInverse;
452-
size_t fSize;
453459
SkColor fLuminanceColor;
454460
SkScalar fInitialX;
455461
SkScalar fInitialY;
@@ -460,13 +466,6 @@ class GrTextBlob : public SkNVRefCnt<GrTextBlob>, public SkGlyphRunPainterInterf
460466
SkScalar fMaxMinScale{-SK_ScalarMax};
461467
SkScalar fMinMaxScale{SK_ScalarMax};
462468

463-
// From the distance field options to force distance fields to have a W coordinate.
464-
const bool fForceWForDistanceFields;
465-
466-
enum TextType {
467-
kHasDistanceField_TextType = 0x1,
468-
kHasBitmap_TextType = 0x2,
469-
};
470469
uint8_t fTextType{0};
471470
};
472471

0 commit comments

Comments
 (0)