aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/batches/GrAtlasTextBatch.h
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-01-22 06:08:48 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-22 06:08:48 -0800
commit7481e75830dfae1e9084ff62e3d8438879e31aaa (patch)
tree4539059e92f3b850044ea91ba708a89f0996e85e /src/gpu/batches/GrAtlasTextBatch.h
parent4c5cd7d527ed29aabfa72aa47b23a4496eeda357 (diff)
Fix GrAtlasTextBlob bounds management
Diffstat (limited to 'src/gpu/batches/GrAtlasTextBatch.h')
-rw-r--r--src/gpu/batches/GrAtlasTextBatch.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/gpu/batches/GrAtlasTextBatch.h b/src/gpu/batches/GrAtlasTextBatch.h
index 8f20313378..f4008c9471 100644
--- a/src/gpu/batches/GrAtlasTextBatch.h
+++ b/src/gpu/batches/GrAtlasTextBatch.h
@@ -84,14 +84,35 @@ public:
fBatch.fViewMatrix = geo.fBlob->fViewMatrix;
// We don't yet position distance field text on the cpu, so we have to map the vertex bounds
- // into device space
+ // into device space.
+ // We handle vertex bounds differently for distance field text and bitmap text because
+ // the vertex bounds of bitmap text are in device space. If we are flushing multiple runs
+ // from one blob then we are going to pay the price here of mapping the rect for each run.
const Run& run = geo.fBlob->fRuns[geo.fRun];
+ SkRect bounds = run.fSubRunInfo[geo.fSubRun].vertexBounds();
if (run.fSubRunInfo[geo.fSubRun].drawAsDistanceFields()) {
- SkRect bounds = run.fVertexBounds;
+ // 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
+ bounds.offset(geo.fBlob->fX - geo.fBlob->fInitialX,
+ geo.fBlob->fY - geo.fBlob->fInitialY);
fBatch.fViewMatrix.mapRect(&bounds);
this->setBounds(bounds);
} else {
- this->setBounds(run.fVertexBounds);
+ // Bitmap text is fully positioned on the CPU, and offset by an (X,Y) translate in
+ // device space.
+ SkMatrix boundsMatrix = geo.fBlob->fInitialViewMatrixInverse;
+
+ boundsMatrix.postTranslate(-geo.fBlob->fInitialX, -geo.fBlob->fInitialY);
+
+ boundsMatrix.postTranslate(geo.fBlob->fX, geo.fBlob->fY);
+
+ boundsMatrix.postConcat(geo.fBlob->fViewMatrix);
+ boundsMatrix.mapRect(&bounds);
+
+ // Due to floating point numerical inaccuracies, we have to round out here
+ SkRect roundedOutBounds;
+ bounds.roundOut(&roundedOutBounds);
+ this->setBounds(roundedOutBounds);
}
}