diff options
author | 2018-06-01 13:46:46 -0400 | |
---|---|---|
committer | 2018-06-01 18:31:47 +0000 | |
commit | 70276915db0c4ec604213c61cb69d8f0419e0e60 (patch) | |
tree | d14b0dad8c1c3745df84b88f0dcec33ebda6098b /src | |
parent | 8683037a2ea9d75d1aea8915bf8acdc9cc6f4d24 (diff) |
Set bounds correctly for color emoji that need post-cache transfoms
We need to handle the bounds for transformed color emoji the same
way we handle the bounds for distance field text. Without this
bounds correction, the glyphs were being clipped out.
Also adds a sample to test this case.
Bug: 848616
Change-Id: I39dedbe2fd19331ad67978c95519f5c9d46f59fc
Reviewed-on: https://skia-review.googlesource.com/131523
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/ops/GrAtlasTextOp.cpp | 12 | ||||
-rw-r--r-- | src/gpu/text/GrTextBlob.cpp | 3 | ||||
-rw-r--r-- | src/gpu/text/GrTextBlob.h | 5 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index 82f4b54c10..a83e025a50 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -25,11 +25,6 @@ static const int kDistanceAdjustLumShift = 5; void GrAtlasTextOp::init() { const Geometry& geo = fGeoData[0]; - SkRect bounds; - geo.fBlob->computeSubRunBounds(&bounds, geo.fRun, geo.fSubRun, geo.fViewMatrix, geo.fX, geo.fY); - // We don't have tight bounds on the glyph paths in device space. For the purposes of bounds - // we treat this as a set of non-AA rects rendered with a texture. - this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); if (this->usesDistanceFields()) { bool isLCD = this->isLCD(); @@ -51,6 +46,13 @@ void GrAtlasTextOp::init() { fNeedsGlyphTransform = true; } + + SkRect bounds; + geo.fBlob->computeSubRunBounds(&bounds, geo.fRun, geo.fSubRun, geo.fViewMatrix, geo.fX, geo.fY, + fNeedsGlyphTransform); + // We don't have tight bounds on the glyph paths in device space. For the purposes of bounds + // we treat this as a set of non-AA rects rendered with a texture. + this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); } void GrAtlasTextOp::visitProxies(const VisitProxyFunc& func) const { diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index c3d06e81fd..b6fc3ce170 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -353,7 +353,8 @@ void GrTextBlob::flush(GrTextUtils::Target* target, const SkSurfaceProps& props, skipClip = true; // We only need to do clipping work if the subrun isn't contained by the clip SkRect subRunBounds; - this->computeSubRunBounds(&subRunBounds, runIndex, subRun, viewMatrix, x, y); + this->computeSubRunBounds(&subRunBounds, runIndex, subRun, viewMatrix, x, y, + false); if (!clipRRect.getBounds().contains(subRunBounds)) { // If the subrun is completely outside, don't add an op for it if (!clipRRect.getBounds().intersects(subRunBounds)) { diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h index 49615a92ed..e34ab88ef2 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -210,7 +210,8 @@ public: SkScalar y); void computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex, - const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { + const SkMatrix& viewMatrix, SkScalar x, SkScalar y, + bool needsGlyphTransform) { // We don't yet position distance field text on the cpu, so we have to map the vertex bounds // into device space. // We handle vertex bounds differently for distance field text and bitmap text because @@ -219,7 +220,7 @@ public: const Run& run = fRuns[runIndex]; const Run::SubRunInfo& subRun = run.fSubRunInfo[subRunIndex]; *outBounds = subRun.vertexBounds(); - if (subRun.drawAsDistanceFields()) { + if (needsGlyphTransform) { // Distance field text is positioned with the (X,Y) as part of the glyph position, // and currently the view matrix is applied on the GPU outBounds->offset(x - fInitialX, y - fInitialY); |