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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 // to avoid even the initial copy of the struct, we have a getter for the fi
rst item which | 76 // to avoid even the initial copy of the struct, we have a getter for the fi
rst item which |
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->viewMatrix(); |
85 | 85 |
86 // We don't yet position distance field text on the cpu, so we have to m
ap the vertex bounds | 86 geo.fBlob->computeSubRunBounds(&fBounds, geo.fRun, geo.fSubRun); |
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]; | |
92 SkRect bounds = run.fSubRunInfo[geo.fSubRun].vertexBounds(); | |
93 if (run.fSubRunInfo[geo.fSubRun].drawAsDistanceFields()) { | |
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); | |
98 fBatch.fViewMatrix.mapRect(&bounds); | |
99 this->setBounds(bounds); | |
100 } else { | |
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); | |
116 } | |
117 } | 87 } |
118 | 88 |
119 const char* name() const override { return "TextBatch"; } | 89 const char* name() const override { return "TextBatch"; } |
120 | 90 |
121 SkString dumpInfo() const override; | 91 SkString dumpInfo() const override; |
122 | 92 |
123 protected: | 93 protected: |
124 void computePipelineOptimizations(GrInitInvariantOutput* color, | 94 void computePipelineOptimizations(GrInitInvariantOutput* color, |
125 GrInitInvariantOutput* coverage, | 95 GrInitInvariantOutput* coverage, |
126 GrBatchToXPOverrides* overrides) const ove
rride; | 96 GrBatchToXPOverrides* overrides) const ove
rride; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 GrBatchFontCache* fFontCache; | 188 GrBatchFontCache* fFontCache; |
219 | 189 |
220 // Distance field properties | 190 // Distance field properties |
221 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; | 191 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
222 SkColor fFilteredColor; | 192 SkColor fFilteredColor; |
223 | 193 |
224 typedef GrVertexBatch INHERITED; | 194 typedef GrVertexBatch INHERITED; |
225 }; | 195 }; |
226 | 196 |
227 #endif | 197 #endif |
OLD | NEW |