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, and offset by an (X,Y ) translate in |
102 // device space. | |
103 SkMatrix boundsMatrix = geo.fBlob->fInitialViewMatrixInverse; | |
104 | |
robertphillips
2016/01/21 17:46:44
boundsMatrix.postTranslate(-geo.fBlob->fInitialX,
| |
105 SkMatrix invInitialTrans; | |
106 invInitialTrans.setTranslate(-geo.fBlob->fInitialX, -geo.fBlob->fIni tialY); | |
107 boundsMatrix.postConcat(invInitialTrans); | |
108 | |
robertphillips
2016/01/21 17:46:44
same here ?
| |
109 SkMatrix xyTrans; | |
110 xyTrans.setTranslate(geo.fBlob->fX, geo.fBlob->fY); | |
111 boundsMatrix.postConcat(xyTrans); | |
112 | |
113 boundsMatrix.postConcat(geo.fBlob->fViewMatrix); | |
114 boundsMatrix.mapRect(&bounds); | |
115 | |
116 // Due to floating point numerical inaccuracies, we have to round ou t here | |
117 SkRect roundedOutBounds; | |
118 bounds.roundOut(&roundedOutBounds); | |
119 this->setBounds(roundedOutBounds); | |
95 } | 120 } |
96 } | 121 } |
97 | 122 |
98 const char* name() const override { return "TextBatch"; } | 123 const char* name() const override { return "TextBatch"; } |
99 | 124 |
100 SkString dumpInfo() const override; | 125 SkString dumpInfo() const override; |
101 | 126 |
102 protected: | 127 protected: |
103 void computePipelineOptimizations(GrInitInvariantOutput* color, | 128 void computePipelineOptimizations(GrInitInvariantOutput* color, |
104 GrInitInvariantOutput* coverage, | 129 GrInitInvariantOutput* coverage, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 GrBatchFontCache* fFontCache; | 222 GrBatchFontCache* fFontCache; |
198 | 223 |
199 // Distance field properties | 224 // Distance field properties |
200 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; | 225 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
201 SkColor fFilteredColor; | 226 SkColor fFilteredColor; |
202 | 227 |
203 typedef GrVertexBatch INHERITED; | 228 typedef GrVertexBatch INHERITED; |
204 }; | 229 }; |
205 | 230 |
206 #endif | 231 #endif |
OLD | NEW |