diff options
author | joshualitt <joshualitt@chromium.org> | 2015-04-21 10:07:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-21 10:07:26 -0700 |
commit | 010db5346e425be8ce659b23b75943ee8ef9d537 (patch) | |
tree | c3165e75f24da099b7509a73020c4389e2d0c6c6 /src/gpu/GrAtlasTextContext.cpp | |
parent | 409fd66a5afcef5f165f7ccec7c3473add231752 (diff) |
Some simple optimizations for improving GrAtlasTextContext perf
BUG=skia:
Review URL: https://codereview.chromium.org/1093083003
Diffstat (limited to 'src/gpu/GrAtlasTextContext.cpp')
-rw-r--r-- | src/gpu/GrAtlasTextContext.cpp | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp index 8c162220f9..c1a46fea9c 100644 --- a/src/gpu/GrAtlasTextContext.cpp +++ b/src/gpu/GrAtlasTextContext.cpp @@ -1201,7 +1201,7 @@ void GrAtlasTextContext::bmpAppendGlyph(BitmapTextBlob* blob, int runIndex, } GrGlyph* glyph = fCurrStrike->getGlyph(packed, scaler); - if (!glyph || glyph->fBounds.isEmpty()) { + if (!glyph) { return; } @@ -1225,7 +1225,7 @@ void GrAtlasTextContext::bmpAppendGlyph(BitmapTextBlob* blob, int runIndex, #endif // If the glyph is too large we fall back to paths - if (fCurrStrike->glyphTooLargeForAtlas(glyph)) { + if (glyph->fTooLargeForAtlas) { this->appendGlyphPath(blob, glyph, scaler, vx, vy); return; } @@ -1264,7 +1264,7 @@ bool GrAtlasTextContext::dfAppendGlyph(BitmapTextBlob* blob, int runIndex, } GrGlyph* glyph = fCurrStrike->getGlyph(packed, scaler); - if (!glyph || glyph->fBounds.isEmpty()) { + if (!glyph) { return true; } @@ -1301,7 +1301,7 @@ bool GrAtlasTextContext::dfAppendGlyph(BitmapTextBlob* blob, int runIndex, // TODO combine with the above // If the glyph is too large we fall back to paths - if (fCurrStrike->glyphTooLargeForAtlas(glyph)) { + if (glyph->fTooLargeForAtlas) { this->appendGlyphPath(blob, glyph, scaler, SkScalarRoundToInt(sx - dx), SkScalarRoundToInt(sy - dy)); return true; @@ -1345,39 +1345,52 @@ inline void GrAtlasTextContext::appendGlyphCommon(BitmapTextBlob* blob, Run* run intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVertices + subRun->fVertexEndIndex); - // V0 - SkPoint* position = reinterpret_cast<SkPoint*>(vertex); - position->set(positions.fLeft, positions.fTop); if (useVertexColor) { + // V0 + SkPoint* position = reinterpret_cast<SkPoint*>(vertex); + position->set(positions.fLeft, positions.fTop); SkColor* colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); *colorPtr = color; - } - vertex += vertexStride; + vertex += vertexStride; - // V1 - position = reinterpret_cast<SkPoint*>(vertex); - position->set(positions.fLeft, positions.fBottom); - if (useVertexColor) { - SkColor* colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); + // V1 + position = reinterpret_cast<SkPoint*>(vertex); + position->set(positions.fLeft, positions.fBottom); + colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); *colorPtr = color; - } - vertex += vertexStride; + vertex += vertexStride; - // V2 - position = reinterpret_cast<SkPoint*>(vertex); - position->set(positions.fRight, positions.fBottom); - if (useVertexColor) { - SkColor* colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); + // V2 + position = reinterpret_cast<SkPoint*>(vertex); + position->set(positions.fRight, positions.fBottom); + colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); *colorPtr = color; - } - vertex += vertexStride; + vertex += vertexStride; - // V3 - position = reinterpret_cast<SkPoint*>(vertex); - position->set(positions.fRight, positions.fTop); - if (useVertexColor) { - SkColor* colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); + // V3 + position = reinterpret_cast<SkPoint*>(vertex); + position->set(positions.fRight, positions.fTop); + colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); *colorPtr = color; + } else { + // V0 + SkPoint* position = reinterpret_cast<SkPoint*>(vertex); + position->set(positions.fLeft, positions.fTop); + vertex += vertexStride; + + // V1 + position = reinterpret_cast<SkPoint*>(vertex); + position->set(positions.fLeft, positions.fBottom); + vertex += vertexStride; + + // V2 + position = reinterpret_cast<SkPoint*>(vertex); + position->set(positions.fRight, positions.fBottom); + vertex += vertexStride; + + // V3 + position = reinterpret_cast<SkPoint*>(vertex); + position->set(positions.fRight, positions.fTop); } subRun->fGlyphEndIndex++; |