OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "GrBitmapTextContext.h" | 8 #include "GrBitmapTextContext.h" |
9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
10 #include "GrDefaultGeoProcFactory.h" | 10 #include "GrDefaultGeoProcFactory.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 fxMask = 0; | 147 fxMask = 0; |
148 halfSampleX = SK_FixedHalf; | 148 halfSampleX = SK_FixedHalf; |
149 } | 149 } |
150 } else { | 150 } else { |
151 halfSampleX = halfSampleY = SK_FixedHalf; | 151 halfSampleX = halfSampleY = SK_FixedHalf; |
152 } | 152 } |
153 | 153 |
154 SkFixed fx = SkScalarToFixed(x) + halfSampleX; | 154 SkFixed fx = SkScalarToFixed(x) + halfSampleX; |
155 SkFixed fy = SkScalarToFixed(y) + halfSampleY; | 155 SkFixed fy = SkScalarToFixed(y) + halfSampleY; |
156 | 156 |
157 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix | 157 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix, but for |
158 if (kARGB_GrMaskFormat != fCurrMaskFormat && !viewMatrix.invert(&fLocalMatri
x)) { | 158 // performance reasons we just invert here instead |
159 SkDebugf("Cannot invert viewmatrix\n"); | 159 if (!viewMatrix.invert(&fLocalMatrix)) { |
| 160 SkDebugf("Cannot invert viewmatrix\n"); |
160 } | 161 } |
161 | 162 |
162 while (text < stop) { | 163 while (text < stop) { |
163 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); | 164 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); |
164 | 165 |
165 fx += autokern.adjust(glyph); | 166 fx += autokern.adjust(glyph); |
166 | 167 |
167 if (glyph.fWidth) { | 168 if (glyph.fWidth) { |
168 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 169 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
169 glyph.getSubXFixed(), | 170 glyph.getSubXFixed(), |
(...skipping 24 matching lines...) Expand all Loading... |
194 } | 195 } |
195 | 196 |
196 this->init(paint, skPaint); | 197 this->init(paint, skPaint); |
197 | 198 |
198 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); | 199 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); |
199 | 200 |
200 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); | 201 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); |
201 SkGlyphCache* cache = autoCache.getCache(); | 202 SkGlyphCache* cache = autoCache.getCache(); |
202 GrFontScaler* fontScaler = GetGrFontScaler(cache); | 203 GrFontScaler* fontScaler = GetGrFontScaler(cache); |
203 | 204 |
204 // store original matrix before we reset, so we can use it to transform posi
tions | 205 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix, but for |
205 SkMatrix ctm = viewMatrix; | 206 // performance reasons we just invert here instead |
206 | 207 if (!viewMatrix.invert(&fLocalMatrix)) { |
207 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix | |
208 if (kARGB_GrMaskFormat != fCurrMaskFormat && !viewMatrix.invert(&fLocalMatri
x)) { | |
209 SkDebugf("Cannot invert viewmatrix\n"); | 208 SkDebugf("Cannot invert viewmatrix\n"); |
210 } | 209 } |
211 | 210 |
212 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); | 211 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
213 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; | 212 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; |
214 | 213 |
215 const char* stop = text + byteLength; | 214 const char* stop = text + byteLength; |
216 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); | 215 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); |
217 SkTextMapStateProc tmsProc(ctm, offset, scalarsPerPosition); | 216 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition); |
218 SkFixed halfSampleX = 0, halfSampleY = 0; | 217 SkFixed halfSampleX = 0, halfSampleY = 0; |
219 | 218 |
220 if (cache->isSubpixel()) { | 219 if (cache->isSubpixel()) { |
221 // maybe we should skip the rounding if linearText is set | 220 // maybe we should skip the rounding if linearText is set |
222 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(ctm); | 221 SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix); |
223 | 222 |
224 SkFixed fxMask = ~0; | 223 SkFixed fxMask = ~0; |
225 SkFixed fyMask = ~0; | 224 SkFixed fyMask = ~0; |
226 if (kX_SkAxisAlignment == baseline) { | 225 if (kX_SkAxisAlignment == baseline) { |
227 fyMask = 0; | 226 fyMask = 0; |
228 halfSampleY = SK_FixedHalf; | 227 halfSampleY = SK_FixedHalf; |
229 } else if (kY_SkAxisAlignment == baseline) { | 228 } else if (kY_SkAxisAlignment == baseline) { |
230 fxMask = 0; | 229 fxMask = 0; |
231 halfSampleX = SK_FixedHalf; | 230 halfSampleX = SK_FixedHalf; |
232 } | 231 } |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } | 611 } |
613 } | 612 } |
614 | 613 |
615 inline void GrBitmapTextContext::finish() { | 614 inline void GrBitmapTextContext::finish() { |
616 this->flush(); | 615 this->flush(); |
617 fTotalVertexCount = 0; | 616 fTotalVertexCount = 0; |
618 | 617 |
619 GrTextContext::finish(); | 618 GrTextContext::finish(); |
620 } | 619 } |
621 | 620 |
OLD | NEW |