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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // Scaling up beyond 2x yields undesireable artifacts | 440 // Scaling up beyond 2x yields undesireable artifacts |
441 if (scaledTextSize < kMinDFFontSize || scaledTextSize > kLargeDFFontLimit) { | 441 if (scaledTextSize < kMinDFFontSize || scaledTextSize > kLargeDFFontLimit) { |
442 return false; | 442 return false; |
443 } | 443 } |
444 | 444 |
445 bool useDFT = fDeviceProperties.useDFT(); | 445 bool useDFT = fDeviceProperties.useDFT(); |
446 #if SK_FORCE_DISTANCE_FIELD_TEXT | 446 #if SK_FORCE_DISTANCE_FIELD_TEXT |
447 useDFT = true; | 447 useDFT = true; |
448 #endif | 448 #endif |
449 | 449 |
450 if (!useDFT && !skPaint.isDistanceFieldTextTEMP() && scaledTextSize < kLarge
DFFontSize) { | 450 if (!useDFT && scaledTextSize < kLargeDFFontSize) { |
451 return false; | 451 return false; |
452 } | 452 } |
453 | 453 |
454 // rasterizers and mask filters modify alpha, which doesn't | 454 // rasterizers and mask filters modify alpha, which doesn't |
455 // translate well to distance | 455 // translate well to distance |
456 if (skPaint.getRasterizer() || skPaint.getMaskFilter() || | 456 if (skPaint.getRasterizer() || skPaint.getMaskFilter() || |
457 !fContext->caps()->shaderCaps()->shaderDerivativeSupport()) { | 457 !fContext->caps()->shaderCaps()->shaderDerivativeSupport()) { |
458 return false; | 458 return false; |
459 } | 459 } |
460 | 460 |
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 desc.fSampleCnt = 0; | 2241 desc.fSampleCnt = 0; |
2242 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de
sc, true, NULL, 0)); | 2242 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de
sc, true, NULL, 0)); |
2243 SkASSERT(texture); | 2243 SkASSERT(texture); |
2244 SkASSERT(NULL != texture->asRenderTarget()); | 2244 SkASSERT(NULL != texture->asRenderTarget()); |
2245 GrRenderTarget* rt = texture->asRenderTarget(); | 2245 GrRenderTarget* rt = texture->asRenderTarget(); |
2246 | 2246 |
2247 // Setup dummy SkPaint / GrPaint | 2247 // Setup dummy SkPaint / GrPaint |
2248 GrColor color = GrRandomColor(random); | 2248 GrColor color = GrRandomColor(random); |
2249 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 2249 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
2250 SkPaint skPaint; | 2250 SkPaint skPaint; |
2251 skPaint.setDistanceFieldTextTEMP(random->nextBool()); | |
2252 skPaint.setColor(color); | 2251 skPaint.setColor(color); |
2253 skPaint.setLCDRenderText(random->nextBool()); | 2252 skPaint.setLCDRenderText(random->nextBool()); |
2254 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 2253 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
2255 skPaint.setSubpixelText(random->nextBool()); | 2254 skPaint.setSubpixelText(random->nextBool()); |
2256 | 2255 |
2257 GrPaint grPaint; | 2256 GrPaint grPaint; |
2258 if (!SkPaint2GrPaint(context, rt, skPaint, viewMatrix, true, &grPaint)) { | 2257 if (!SkPaint2GrPaint(context, rt, skPaint, viewMatrix, true, &grPaint)) { |
2259 SkFAIL("couldn't convert paint\n"); | 2258 SkFAIL("couldn't convert paint\n"); |
2260 } | 2259 } |
2261 | 2260 |
(...skipping 10 matching lines...) Expand all Loading... |
2272 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, | 2271 gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMat
rix, text, |
2273 static_cast<size_t>(textLen), 0, 0,
noClip)); | 2272 static_cast<size_t>(textLen), 0, 0,
noClip)); |
2274 | 2273 |
2275 SkScalar transX = static_cast<SkScalar>(random->nextU()); | 2274 SkScalar transX = static_cast<SkScalar>(random->nextU()); |
2276 SkScalar transY = static_cast<SkScalar>(random->nextU()); | 2275 SkScalar transY = static_cast<SkScalar>(random->nextU()); |
2277 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; | 2276 const GrAtlasTextContext::BitmapTextBlob::Run::SubRunInfo& info = blob->fRun
s[0].fSubRunInfo[0]; |
2278 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); | 2277 return gTextContext->createBatch(blob, info, textLen, 0, 0, color, transX, t
ransY, skPaint); |
2279 } | 2278 } |
2280 | 2279 |
2281 #endif | 2280 #endif |
OLD | NEW |