| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 BitmapTextBlob::Key key; | 359 BitmapTextBlob::Key key; |
| 360 // It might be worth caching these things, but its not clear at this time | 360 // It might be worth caching these things, but its not clear at this time |
| 361 // TODO for animated mask filters, this will fill up our cache. We need a s
afeguard here | 361 // TODO for animated mask filters, this will fill up our cache. We need a s
afeguard here |
| 362 const SkMaskFilter* mf = skPaint.getMaskFilter(); | 362 const SkMaskFilter* mf = skPaint.getMaskFilter(); |
| 363 bool canCache = !(skPaint.getPathEffect() || | 363 bool canCache = !(skPaint.getPathEffect() || |
| 364 (mf && !mf->asABlur(&blurRec)) || | 364 (mf && !mf->asABlur(&blurRec)) || |
| 365 drawFilter); | 365 drawFilter); |
| 366 | 366 |
| 367 if (canCache) { | 367 if (canCache) { |
| 368 bool hasLCD = HasLCD(blob); | 368 bool hasLCD = HasLCD(blob); |
| 369 |
| 370 // We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry |
| 371 SkPixelGeometry pixelGeometry = hasLCD ? fDeviceProperties.pixelGeometry
() : |
| 372 kUnknown_SkPixelGeometry; |
| 373 |
| 369 // TODO we want to figure out a way to be able to use the canonical colo
r on LCD text, | 374 // TODO we want to figure out a way to be able to use the canonical colo
r on LCD text, |
| 370 // see the note on ComputeCanonicalColor above. We pick a dummy value f
or LCD text to | 375 // see the note on ComputeCanonicalColor above. We pick a dummy value f
or LCD text to |
| 371 // ensure we always match the same key | 376 // ensure we always match the same key |
| 372 GrColor canonicalColor = hasLCD ? SK_ColorTRANSPARENT : | 377 GrColor canonicalColor = hasLCD ? SK_ColorTRANSPARENT : |
| 373 ComputeCanonicalColor(skPaint, hasLCD)
; | 378 ComputeCanonicalColor(skPaint, hasLCD)
; |
| 374 | 379 |
| 380 key.fPixelGeometry = pixelGeometry; |
| 375 key.fUniqueID = blob->uniqueID(); | 381 key.fUniqueID = blob->uniqueID(); |
| 376 key.fStyle = skPaint.getStyle(); | 382 key.fStyle = skPaint.getStyle(); |
| 377 key.fHasBlur = SkToBool(mf); | 383 key.fHasBlur = SkToBool(mf); |
| 378 key.fCanonicalColor = canonicalColor; | 384 key.fCanonicalColor = canonicalColor; |
| 379 cacheBlob.reset(SkSafeRef(fCache->find(key))); | 385 cacheBlob.reset(SkSafeRef(fCache->find(key))); |
| 380 } | 386 } |
| 381 | 387 |
| 382 SkIRect clipRect; | 388 SkIRect clipRect; |
| 383 clip.getConservativeBounds(rt->width(), rt->height(), &clipRect); | 389 clip.getConservativeBounds(rt->width(), rt->height(), &clipRect); |
| 384 | 390 |
| (...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2264 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2270 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
| 2265 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2271 static_cast<size_t>(textLen), 0, 0,
noClip)); |
| 2266 | 2272 |
| 2267 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2273 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
| 2268 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2274 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
| 2269 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; | 2275 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; |
| 2270 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); | 2276 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); |
| 2271 } | 2277 } |
| 2272 | 2278 |
| 2273 #endif | 2279 #endif |
| OLD | NEW |