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. | |
91 const Run& run = geo.fBlob->fRuns[geo.fRun]; | 88 const Run& run = geo.fBlob->fRuns[geo.fRun]; |
92 SkRect bounds = run.fSubRunInfo[geo.fSubRun].vertexBounds(); | |
93 if (run.fSubRunInfo[geo.fSubRun].drawAsDistanceFields()) { | 89 if (run.fSubRunInfo[geo.fSubRun].drawAsDistanceFields()) { |
94 // Distance field text is positioned with the (X,Y) as part of the g
lyph position, | 90 SkRect bounds = run.fVertexBounds; |
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); | |
98 fBatch.fViewMatrix.mapRect(&bounds); | 91 fBatch.fViewMatrix.mapRect(&bounds); |
99 this->setBounds(bounds); | 92 this->setBounds(bounds); |
100 } else { | 93 } else { |
101 // Bitmap text is fully positioned on the CPU | 94 this->setBounds(run.fVertexBounds); |
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); | |
112 } | 95 } |
113 } | 96 } |
114 | 97 |
115 const char* name() const override { return "TextBatch"; } | 98 const char* name() const override { return "TextBatch"; } |
116 | 99 |
117 SkString dumpInfo() const override; | 100 SkString dumpInfo() const override; |
118 | 101 |
119 protected: | 102 protected: |
120 void computePipelineOptimizations(GrInitInvariantOutput* color, | 103 void computePipelineOptimizations(GrInitInvariantOutput* color, |
121 GrInitInvariantOutput* coverage, | 104 GrInitInvariantOutput* coverage, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 GrBatchFontCache* fFontCache; | 197 GrBatchFontCache* fFontCache; |
215 | 198 |
216 // Distance field properties | 199 // Distance field properties |
217 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; | 200 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
218 SkColor fFilteredColor; | 201 SkColor fFilteredColor; |
219 | 202 |
220 typedef GrVertexBatch INHERITED; | 203 typedef GrVertexBatch INHERITED; |
221 }; | 204 }; |
222 | 205 |
223 #endif | 206 #endif |
OLD | NEW |