Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: src/gpu/batches/GrAtlasTextBatch.h

Issue 1605013002: Fix GrAtlasTextBlob bounds management (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext17
Patch Set: fix glprograms Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/batches/GrAtlasTextBatch.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrAtlasTextBatch_DEFINED 8 #ifndef GrAtlasTextBatch_DEFINED
9 #define GrAtlasTextBatch_DEFINED 9 #define GrAtlasTextBatch_DEFINED
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // is used to seed the batch with its initial geometry. After seeding, the client should call 77 // is used to seed the batch with its initial geometry. After seeding, the client should call
78 // init() so the Batch can initialize itself 78 // init() so the Batch can initialize itself
79 Geometry& geometry() { return fGeoData[0]; } 79 Geometry& geometry() { return fGeoData[0]; }
80 80
81 void init() { 81 void init() {
82 const Geometry& geo = fGeoData[0]; 82 const Geometry& geo = fGeoData[0];
83 fBatch.fColor = geo.fColor; 83 fBatch.fColor = geo.fColor;
84 fBatch.fViewMatrix = geo.fBlob->fViewMatrix; 84 fBatch.fViewMatrix = geo.fBlob->fViewMatrix;
85 85
86 // We don't yet position distance field text on the cpu, so we have to m ap the vertex bounds 86 // We don't yet position distance field text on the cpu, so we have to m ap the vertex bounds
87 // into device space 87 // into device space.
88 // We handle vertex bounds differently for distance field text and bitma p text because
89 // the vertex bounds of bitmap text are in device space. If we are flus hing multiple runs
90 // from one blob then we are going to pay the price here of mapping the rect for each run.
88 const Run& run = geo.fBlob->fRuns[geo.fRun]; 91 const Run& run = geo.fBlob->fRuns[geo.fRun];
92 SkRect bounds = run.fSubRunInfo[geo.fSubRun].vertexBounds();
89 if (run.fSubRunInfo[geo.fSubRun].drawAsDistanceFields()) { 93 if (run.fSubRunInfo[geo.fSubRun].drawAsDistanceFields()) {
90 SkRect bounds = run.fVertexBounds; 94 // Distance field text is positioned with the (X,Y) as part of the g lyph position,
95 // and currently the view matrix is applied on the GPU
96 bounds.offset(geo.fBlob->fX - geo.fBlob->fInitialX,
97 geo.fBlob->fY - geo.fBlob->fInitialY);
91 fBatch.fViewMatrix.mapRect(&bounds); 98 fBatch.fViewMatrix.mapRect(&bounds);
92 this->setBounds(bounds); 99 this->setBounds(bounds);
93 } else { 100 } else {
94 this->setBounds(run.fVertexBounds); 101 // Bitmap text is fully positioned on the CPU, and offset by an (X,Y ) translate in
102 // device space.
103 SkMatrix boundsMatrix = geo.fBlob->fInitialViewMatrixInverse;
104
105 boundsMatrix.postTranslate(-geo.fBlob->fInitialX, -geo.fBlob->fIniti alY);
106
107 boundsMatrix.postTranslate(geo.fBlob->fX, geo.fBlob->fY);
108
109 boundsMatrix.postConcat(geo.fBlob->fViewMatrix);
110 boundsMatrix.mapRect(&bounds);
111
112 // Due to floating point numerical inaccuracies, we have to round ou t here
113 SkRect roundedOutBounds;
114 bounds.roundOut(&roundedOutBounds);
115 this->setBounds(roundedOutBounds);
95 } 116 }
96 } 117 }
97 118
98 const char* name() const override { return "TextBatch"; } 119 const char* name() const override { return "TextBatch"; }
99 120
100 SkString dumpInfo() const override; 121 SkString dumpInfo() const override;
101 122
102 protected: 123 protected:
103 void computePipelineOptimizations(GrInitInvariantOutput* color, 124 void computePipelineOptimizations(GrInitInvariantOutput* color,
104 GrInitInvariantOutput* coverage, 125 GrInitInvariantOutput* coverage,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 GrBatchFontCache* fFontCache; 218 GrBatchFontCache* fFontCache;
198 219
199 // Distance field properties 220 // Distance field properties
200 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; 221 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable;
201 SkColor fFilteredColor; 222 SkColor fFilteredColor;
202 223
203 typedef GrVertexBatch INHERITED; 224 typedef GrVertexBatch INHERITED;
204 }; 225 };
205 226
206 #endif 227 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/batches/GrAtlasTextBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698