OLD | NEW |
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 Loading... |
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 |
| 102 SkMatrix boundsMatrix; |
| 103 bounds.offset(-geo.fBlob->fInitialX, -geo.fBlob->fInitialY); |
| 104 boundsMatrix.setConcat(fBatch.fViewMatrix, geo.fBlob->fInitialViewMa
trixInverse); |
| 105 boundsMatrix.mapRect(&bounds); |
| 106 |
| 107 // Due to floating point numerical inaccuracies, we have to round ou
t here |
| 108 SkRect roundedOutBounds; |
| 109 bounds.roundOut(&roundedOutBounds); |
| 110 roundedOutBounds.offset(geo.fBlob->fX, geo.fBlob->fY); |
| 111 this->setBounds(roundedOutBounds); |
95 } | 112 } |
96 } | 113 } |
97 | 114 |
98 const char* name() const override { return "TextBatch"; } | 115 const char* name() const override { return "TextBatch"; } |
99 | 116 |
100 SkString dumpInfo() const override; | 117 SkString dumpInfo() const override; |
101 | 118 |
102 protected: | 119 protected: |
103 void computePipelineOptimizations(GrInitInvariantOutput* color, | 120 void computePipelineOptimizations(GrInitInvariantOutput* color, |
104 GrInitInvariantOutput* coverage, | 121 GrInitInvariantOutput* coverage, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 GrBatchFontCache* fFontCache; | 214 GrBatchFontCache* fFontCache; |
198 | 215 |
199 // Distance field properties | 216 // Distance field properties |
200 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; | 217 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
201 SkColor fFilteredColor; | 218 SkColor fFilteredColor; |
202 | 219 |
203 typedef GrVertexBatch INHERITED; | 220 typedef GrVertexBatch INHERITED; |
204 }; | 221 }; |
205 | 222 |
206 #endif | 223 #endif |
OLD | NEW |