Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e74c776

Browse files
herbderbySkia Commit-Bot
authored andcommitted
Specialize vertex size for GrTextBlob
The old code assumes a conservative size for vertices of 20 bytes, but this only happens in perspective or strange DFT modes. This can be reduced to 16 bytes in the non-perspective case a savings of 20% Change-Id: Ife7e7cc4bd00798f173c5390c3100605908e6276 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257923 Commit-Queue: Herb Derby <[email protected]> Reviewed-by: Brian Salomon <[email protected]>
1 parent 7a67198 commit e74c776

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/gpu/text/GrTextBlob.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,20 @@ sk_sp<GrTextBlob> GrTextBlob::Make(int glyphCount,
2929
SkPoint origin,
3030
GrColor color,
3131
bool forceWForDistanceFields) {
32+
// Default to no perspective. Implies one of the following vertex formats: kColorTextVASize,
33+
// kGrayTextVASize, kLCDTextVASize.
34+
static_assert(kColorTextVASize <= kGrayTextVASize && kLCDTextVASize <= kGrayTextVASize);
35+
size_t quadSize = kVerticesPerGlyph * kGrayTextVASize;
36+
if (viewMatrix.hasPerspective() || forceWForDistanceFields) {
37+
// Perspective. Implies one of the following vertex formats: kColorTextPerspectiveVASize,
38+
// kGrayTextDFPerspectiveVASize.
39+
static_assert(kColorTextPerspectiveVASize <= kGrayTextDFPerspectiveVASize);
40+
quadSize = kVerticesPerGlyph * kGrayTextDFPerspectiveVASize;
41+
}
42+
3243
// We allocate size for the GrTextBlob itself, plus size for the vertices array,
3344
// and size for the glyphIds array.
34-
size_t verticesCount = glyphCount * kVerticesPerGlyph * kMaxVASize;
45+
size_t verticesCount = glyphCount * quadSize;
3546

3647
size_t blobStart = 0;
3748
size_t vertex = sk_align<alignof(char)> (blobStart + sizeof(GrTextBlob) * 1);

0 commit comments

Comments
 (0)