| 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 "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 key.fUniqueID = blob->uniqueID(); | 117 key.fUniqueID = blob->uniqueID(); |
| 118 key.fStyle = skPaint.getStyle(); | 118 key.fStyle = skPaint.getStyle(); |
| 119 key.fHasBlur = SkToBool(mf); | 119 key.fHasBlur = SkToBool(mf); |
| 120 key.fCanonicalColor = canonicalColor; | 120 key.fCanonicalColor = canonicalColor; |
| 121 cacheBlob.reset(SkSafeRef(cache->find(key))); | 121 cacheBlob.reset(SkSafeRef(cache->find(key))); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Though for the time being runs in the textblob can override the paint, th
ey only touch font | 124 // Though for the time being runs in the textblob can override the paint, th
ey only touch font |
| 125 // info. | 125 // info. |
| 126 GrPaint grPaint; | 126 GrPaint grPaint; |
| 127 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.allowSRGBInputs(),
&grPaint)) { | 127 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.isGammaCorrect(),
&grPaint)) { |
| 128 return; | 128 return; |
| 129 } | 129 } |
| 130 | 130 |
| 131 uint32_t scalerContextFlags = ComputeScalerContextFlags(dc, grPaint); | 131 uint32_t scalerContextFlags = ComputeScalerContextFlags(dc, grPaint); |
| 132 | 132 |
| 133 if (cacheBlob) { | 133 if (cacheBlob) { |
| 134 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view
Matrix, x, y)) { | 134 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view
Matrix, x, y)) { |
| 135 // We have to remake the blob because changes may invalidate our mas
ks. | 135 // We have to remake the blob because changes may invalidate our mas
ks. |
| 136 // TODO we could probably get away reuse most of the time if the poi
nter is unique, | 136 // TODO we could probably get away reuse most of the time if the poi
nter is unique, |
| 137 // but we'd have to clear the subrun information | 137 // but we'd have to clear the subrun information |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 // Setup dummy SkPaint / GrPaint | 393 // Setup dummy SkPaint / GrPaint |
| 394 GrColor color = GrRandomColor(random); | 394 GrColor color = GrRandomColor(random); |
| 395 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 395 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
| 396 SkPaint skPaint; | 396 SkPaint skPaint; |
| 397 skPaint.setColor(color); | 397 skPaint.setColor(color); |
| 398 skPaint.setLCDRenderText(random->nextBool()); | 398 skPaint.setLCDRenderText(random->nextBool()); |
| 399 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 399 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
| 400 skPaint.setSubpixelText(random->nextBool()); | 400 skPaint.setSubpixelText(random->nextBool()); |
| 401 | 401 |
| 402 GrPaint grPaint; | 402 GrPaint grPaint; |
| 403 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.allowSRGBI
nputs(), | 403 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.isGammaCor
rect(), |
| 404 &grPaint)) { | 404 &grPaint)) { |
| 405 SkFAIL("couldn't convert paint\n"); | 405 SkFAIL("couldn't convert paint\n"); |
| 406 } | 406 } |
| 407 | 407 |
| 408 const char* text = "The quick brown fox jumps over the lazy dog."; | 408 const char* text = "The quick brown fox jumps over the lazy dog."; |
| 409 int textLen = (int)strlen(text); | 409 int textLen = (int)strlen(text); |
| 410 | 410 |
| 411 // create some random x/y offsets, including negative offsets | 411 // create some random x/y offsets, including negative offsets |
| 412 static const int kMaxTrans = 1024; | 412 static const int kMaxTrans = 1024; |
| 413 int xPos = (random->nextU() % 2) * 2 - 1; | 413 int xPos = (random->nextU() % 2) * 2 - 1; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 427 viewMatrix, | 427 viewMatrix, |
| 428 gSurfaceProps, text, | 428 gSurfaceProps, text, |
| 429 static_cast<size_t>(textLen), x,
y)); | 429 static_cast<size_t>(textLen), x,
y)); |
| 430 | 430 |
| 431 return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPain
t, | 431 return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPain
t, |
| 432 gSurfaceProps, gTextContext->dfAdjustTable(), | 432 gSurfaceProps, gTextContext->dfAdjustTable(), |
| 433 context->getBatchFontCache()); | 433 context->getBatchFontCache()); |
| 434 } | 434 } |
| 435 | 435 |
| 436 #endif | 436 #endif |
| OLD | NEW |