| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, but for | 157 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix, but for |
| 158 // performance reasons we just invert here instead | 158 // performance reasons we just invert here instead |
| 159 if (!viewMatrix.invert(&fLocalMatrix)) { | 159 if (!viewMatrix.invert(&fLocalMatrix)) { |
| 160 SkDebugf("Cannot invert viewmatrix\n"); | 160 SkDebugf("Cannot invert viewmatrix\n"); |
| 161 return; |
| 161 } | 162 } |
| 162 | 163 |
| 163 while (text < stop) { | 164 while (text < stop) { |
| 164 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); | 165 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); |
| 165 | 166 |
| 166 fx += autokern.adjust(glyph); | 167 fx += autokern.adjust(glyph); |
| 167 | 168 |
| 168 if (glyph.fWidth) { | 169 if (glyph.fWidth) { |
| 169 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 170 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 170 glyph.getSubXFixed(), | 171 glyph.getSubXFixed(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 198 | 199 |
| 199 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); | 200 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); |
| 200 | 201 |
| 201 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); | 202 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); |
| 202 SkGlyphCache* cache = autoCache.getCache(); | 203 SkGlyphCache* cache = autoCache.getCache(); |
| 203 GrFontScaler* fontScaler = GetGrFontScaler(cache); | 204 GrFontScaler* fontScaler = GetGrFontScaler(cache); |
| 204 | 205 |
| 205 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix, but for | 206 // if we have RGB, then we won't have any SkShaders so no need to use a loca
lmatrix, but for |
| 206 // performance reasons we just invert here instead | 207 // performance reasons we just invert here instead |
| 207 if (!viewMatrix.invert(&fLocalMatrix)) { | 208 if (!viewMatrix.invert(&fLocalMatrix)) { |
| 208 SkDebugf("Cannot invert viewmatrix\n"); | 209 SkDebugf("Cannot invert viewmatrix\n"); |
| 210 return; |
| 209 } | 211 } |
| 210 | 212 |
| 211 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); | 213 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
| 212 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; | 214 fTotalVertexCount = kVerticesPerGlyph*numGlyphs; |
| 213 | 215 |
| 214 const char* stop = text + byteLength; | 216 const char* stop = text + byteLength; |
| 215 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); | 217 SkTextAlignProc alignProc(fSkPaint.getTextAlign()); |
| 216 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition); | 218 SkTextMapStateProc tmsProc(viewMatrix, offset, scalarsPerPosition); |
| 217 SkFixed halfSampleX = 0, halfSampleY = 0; | 219 SkFixed halfSampleX = 0, halfSampleY = 0; |
| 218 | 220 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 613 } |
| 612 } | 614 } |
| 613 | 615 |
| 614 inline void GrBitmapTextContext::finish() { | 616 inline void GrBitmapTextContext::finish() { |
| 615 this->flush(); | 617 this->flush(); |
| 616 fTotalVertexCount = 0; | 618 fTotalVertexCount = 0; |
| 617 | 619 |
| 618 GrTextContext::finish(); | 620 GrTextContext::finish(); |
| 619 } | 621 } |
| 620 | 622 |
| OLD | NEW |