diff options
author | 2017-10-25 14:25:27 -0400 | |
---|---|---|
committer | 2017-10-25 18:54:34 +0000 | |
commit | c8a65e3e6ee5505e44ad1e8adcd3189edc61328c (patch) | |
tree | 6c9fe7c37cb806bb31567aa7df62d9a2ec33edf9 /src/gpu/text/GrAtlasTextBlob.cpp | |
parent | 4d3f20f9b3de31b7629e5b4fca53326c6e0c6169 (diff) |
Some more clipped text optimizations.
* Limit size of text batches to keep inside default vertex buffer size
* Expand geodata allocation by 1.5x rather than 2x
* Don't add text subruns that lie outside the clip rect
Bug: skia:3990
Change-Id: I2b8f8bc5599d14c43e0a98e9633bc51980a7619c
Reviewed-on: https://skia-review.googlesource.com/62861
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/text/GrAtlasTextBlob.cpp')
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp index be83dc1085..a6dbd67286 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -306,31 +306,39 @@ inline void GrAtlasTextBlob::flushRun(GrRenderTargetContext* rtc, const GrClip& continue; } + bool skipClip = false; + bool submitOp = true; + SkIRect clipRect = SkIRect::MakeEmpty(); SkRect rtBounds = SkRect::MakeWH(rtc->width(), rtc->height()); SkRRect clipRRect; GrAA aa; - // we can clip geometrically if we're not using SDFs, + // We can clip geometrically if we're not using SDFs, // and we have an axis-aligned rectangular non-AA clip - bool skipClip = false; - SkIRect clipRect = SkIRect::MakeEmpty(); if (!info.drawAsDistanceFields() && clip.isRRect(rtBounds, &clipRRect, &aa) && clipRRect.isRect() && GrAA::kNo == aa) { skipClip = true; - // we only need to do clipping work if the subrun isn't contained by the clip + // We only need to do clipping work if the subrun isn't contained by the clip SkRect subRunBounds; this->computeSubRunBounds(&subRunBounds, run, subRun, viewMatrix, x, y); if (!clipRRect.getBounds().contains(subRunBounds)) { - clipRRect.getBounds().round(&clipRect); + // If the subrun is completely outside, don't add an op for it + if (!clipRRect.getBounds().intersects(subRunBounds)) { + submitOp = false; + } else { + clipRRect.getBounds().round(&clipRect); + } } } - auto op = this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, clipRect, - std::move(paint), props, distanceAdjustTable, cache, rtc); - if (op) { - if (skipClip) { - rtc->addDrawOp(GrNoClip(), std::move(op)); - } else { - rtc->addDrawOp(clip, std::move(op)); + if (submitOp) { + auto op = this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, clipRect, + std::move(paint), props, distanceAdjustTable, cache, rtc); + if (op) { + if (skipClip) { + rtc->addDrawOp(GrNoClip(), std::move(op)); + } else { + rtc->addDrawOp(clip, std::move(op)); + } } } } |