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 #include "GrAtlasTextContext.h" | 7 #include "GrAtlasTextContext.h" |
8 | 8 |
9 #include "GrBatch.h" | 9 #include "GrBatch.h" |
10 #include "GrBatchFontCache.h" | 10 #include "GrBatchFontCache.h" |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 // We could store the cliprect in the key, but then we'd lose the ability to
do integer scrolls | 1248 // We could store the cliprect in the key, but then we'd lose the ability to
do integer scrolls |
1249 // TODO verify this | 1249 // TODO verify this |
1250 // check if we clipped out | 1250 // check if we clipped out |
1251 if (clipRect.quickReject(x, y, x + width, y + height)) { | 1251 if (clipRect.quickReject(x, y, x + width, y + height)) { |
1252 return; | 1252 return; |
1253 } | 1253 } |
1254 #endif | 1254 #endif |
1255 | 1255 |
1256 // If the glyph is too large we fall back to paths | 1256 // If the glyph is too large we fall back to paths |
1257 if (glyph->fTooLargeForAtlas) { | 1257 if (glyph->fTooLargeForAtlas) { |
1258 this->appendGlyphPath(blob, glyph, scaler, vx, vy); | 1258 this->appendGlyphPath(blob, glyph, scaler, SkIntToScalar(vx), SkIntToSca
lar(vy)); |
1259 return; | 1259 return; |
1260 } | 1260 } |
1261 | 1261 |
1262 GrMaskFormat format = glyph->fMaskFormat; | 1262 GrMaskFormat format = glyph->fMaskFormat; |
1263 | 1263 |
1264 PerSubRunInfo* subRun = &run.fSubRunInfo.back(); | 1264 PerSubRunInfo* subRun = &run.fSubRunInfo.back(); |
1265 if (run.fInitialized && subRun->fMaskFormat != format) { | 1265 if (run.fInitialized && subRun->fMaskFormat != format) { |
1266 subRun = &run.fSubRunInfo.push_back(); | 1266 subRun = &run.fSubRunInfo.push_back(); |
1267 } | 1267 } |
1268 | 1268 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 SkScalarTruncToInt(dstRect.top()), | 1324 SkScalarTruncToInt(dstRect.top()), |
1325 SkScalarTruncToInt(dstRect.right()), | 1325 SkScalarTruncToInt(dstRect.right()), |
1326 SkScalarTruncToInt(dstRect.bottom()))) { | 1326 SkScalarTruncToInt(dstRect.bottom()))) { |
1327 return true; | 1327 return true; |
1328 } | 1328 } |
1329 #endif | 1329 #endif |
1330 | 1330 |
1331 // TODO combine with the above | 1331 // TODO combine with the above |
1332 // If the glyph is too large we fall back to paths | 1332 // If the glyph is too large we fall back to paths |
1333 if (glyph->fTooLargeForAtlas) { | 1333 if (glyph->fTooLargeForAtlas) { |
1334 this->appendGlyphPath(blob, glyph, scaler, SkScalarRoundToInt(sx - dx), | 1334 this->appendGlyphPath(blob, glyph, scaler, sx - dx, sy - dy); |
1335 SkScalarRoundToInt(sy - dy)); | |
1336 return true; | 1335 return true; |
1337 } | 1336 } |
1338 | 1337 |
1339 PerSubRunInfo* subRun = &run.fSubRunInfo.back(); | 1338 PerSubRunInfo* subRun = &run.fSubRunInfo.back(); |
1340 SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat); | 1339 SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat); |
1341 subRun->fMaskFormat = kA8_GrMaskFormat; | 1340 subRun->fMaskFormat = kA8_GrMaskFormat; |
1342 | 1341 |
1343 size_t vertexStride = get_vertex_stride_df(kA8_GrMaskFormat, subRun->fUseLCD
Text); | 1342 size_t vertexStride = get_vertex_stride_df(kA8_GrMaskFormat, subRun->fUseLCD
Text); |
1344 | 1343 |
1345 bool useColorVerts = !subRun->fUseLCDText; | 1344 bool useColorVerts = !subRun->fUseLCDText; |
1346 this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride,
useColorVerts, | 1345 this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride,
useColorVerts, |
1347 glyph); | 1346 glyph); |
1348 return true; | 1347 return true; |
1349 } | 1348 } |
1350 | 1349 |
1351 inline void GrAtlasTextContext::appendGlyphPath(BitmapTextBlob* blob, GrGlyph* g
lyph, | 1350 inline void GrAtlasTextContext::appendGlyphPath(BitmapTextBlob* blob, GrGlyph* g
lyph, |
1352 GrFontScaler* scaler, int x, int
y) { | 1351 GrFontScaler* scaler, SkScalar x
, SkScalar y) { |
1353 if (NULL == glyph->fPath) { | 1352 if (NULL == glyph->fPath) { |
1354 SkPath* path = SkNEW(SkPath); | 1353 SkPath* path = SkNEW(SkPath); |
1355 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { | 1354 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
1356 // flag the glyph as being dead? | 1355 // flag the glyph as being dead? |
1357 SkDELETE(path); | 1356 SkDELETE(path); |
1358 return; | 1357 return; |
1359 } | 1358 } |
1360 glyph->fPath = path; | 1359 glyph->fPath = path; |
1361 } | 1360 } |
1362 SkASSERT(glyph->fPath); | 1361 SkASSERT(glyph->fPath); |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 target->drawBatch(pipelineBuilder, batch); | 2142 target->drawBatch(pipelineBuilder, batch); |
2144 } | 2143 } |
2145 } | 2144 } |
2146 | 2145 |
2147 inline void GrAtlasTextContext::flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRend
erTarget* rt, | 2146 inline void GrAtlasTextContext::flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRend
erTarget* rt, |
2148 const SkPaint& skPaint, | 2147 const SkPaint& skPaint, |
2149 SkScalar transX, SkScalar transY, | 2148 SkScalar transX, SkScalar transY, |
2150 const SkIRect& clipBounds) { | 2149 const SkIRect& clipBounds) { |
2151 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) { | 2150 for (int i = 0; i < cacheBlob->fBigGlyphs.count(); i++) { |
2152 BitmapTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i]; | 2151 BitmapTextBlob::BigGlyph& bigGlyph = cacheBlob->fBigGlyphs[i]; |
2153 bigGlyph.fVx += SkScalarTruncToInt(transX); | 2152 bigGlyph.fVx += transX; |
2154 bigGlyph.fVy += SkScalarTruncToInt(transY); | 2153 bigGlyph.fVy += transY; |
2155 SkMatrix translate; | 2154 SkMatrix translate; |
2156 translate.setTranslate(SkIntToScalar(bigGlyph.fVx), | 2155 translate.setTranslate(bigGlyph.fVx, bigGlyph.fVy); |
2157 SkIntToScalar(bigGlyph.fVy)); | |
2158 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); | |
2159 fGpuDevice->internalDrawPath(bigGlyph.fPath, skPaint, SkMatrix::I(), &tr
anslate, clipBounds, | 2156 fGpuDevice->internalDrawPath(bigGlyph.fPath, skPaint, SkMatrix::I(), &tr
anslate, clipBounds, |
2160 false); | 2157 false); |
2161 } | 2158 } |
2162 } | 2159 } |
2163 | 2160 |
2164 void GrAtlasTextContext::flush(GrDrawTarget* target, | 2161 void GrAtlasTextContext::flush(GrDrawTarget* target, |
2165 const SkTextBlob* blob, | 2162 const SkTextBlob* blob, |
2166 BitmapTextBlob* cacheBlob, | 2163 BitmapTextBlob* cacheBlob, |
2167 GrRenderTarget* rt, | 2164 GrRenderTarget* rt, |
2168 const SkPaint& skPaint, | 2165 const SkPaint& skPaint, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2268 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
2272 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2269 static_cast<size_t>(textLen), 0, 0,
noClip)); |
2273 | 2270 |
2274 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2271 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
2275 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2272 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
2276 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; | 2273 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; |
2277 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); | 2274 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); |
2278 } | 2275 } |
2279 | 2276 |
2280 #endif | 2277 #endif |
OLD | NEW |