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.fStyle = skPaint.getStyle(); | 117 key.fStyle = skPaint.getStyle(); |
118 key.fHasBlur = SkToBool(mf); | 118 key.fHasBlur = SkToBool(mf); |
119 key.fCanonicalColor = canonicalColor; | 119 key.fCanonicalColor = canonicalColor; |
120 key.fScalerContextFlags = scalerContextFlags; | 120 key.fScalerContextFlags = scalerContextFlags; |
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.isGammaCorrect(),
&grPaint)) { | 127 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.isGammaCorrect(),
dc->getColorSpace(), |
| 128 &grPaint)) { |
128 return; | 129 return; |
129 } | 130 } |
130 | 131 |
131 if (cacheBlob) { | 132 if (cacheBlob) { |
132 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view
Matrix, x, y)) { | 133 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view
Matrix, x, y)) { |
133 // We have to remake the blob because changes may invalidate our mas
ks. | 134 // We have to remake the blob because changes may invalidate our mas
ks. |
134 // TODO we could probably get away reuse most of the time if the poi
nter is unique, | 135 // TODO we could probably get away reuse most of the time if the poi
nter is unique, |
135 // but we'd have to clear the subrun information | 136 // but we'd have to clear the subrun information |
136 cache->remove(cacheBlob); | 137 cache->remove(cacheBlob); |
137 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk
Paint))); | 138 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk
Paint))); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 // Setup dummy SkPaint / GrPaint | 392 // Setup dummy SkPaint / GrPaint |
392 GrColor color = GrRandomColor(random); | 393 GrColor color = GrRandomColor(random); |
393 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 394 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
394 SkPaint skPaint; | 395 SkPaint skPaint; |
395 skPaint.setColor(color); | 396 skPaint.setColor(color); |
396 skPaint.setLCDRenderText(random->nextBool()); | 397 skPaint.setLCDRenderText(random->nextBool()); |
397 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 398 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
398 skPaint.setSubpixelText(random->nextBool()); | 399 skPaint.setSubpixelText(random->nextBool()); |
399 | 400 |
400 GrPaint grPaint; | 401 GrPaint grPaint; |
401 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.isGammaCor
rect(), | 402 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.isGammaCor
rect(), nullptr, |
402 &grPaint)) { | 403 &grPaint)) { |
403 SkFAIL("couldn't convert paint\n"); | 404 SkFAIL("couldn't convert paint\n"); |
404 } | 405 } |
405 | 406 |
406 const char* text = "The quick brown fox jumps over the lazy dog."; | 407 const char* text = "The quick brown fox jumps over the lazy dog."; |
407 int textLen = (int)strlen(text); | 408 int textLen = (int)strlen(text); |
408 | 409 |
409 // create some random x/y offsets, including negative offsets | 410 // create some random x/y offsets, including negative offsets |
410 static const int kMaxTrans = 1024; | 411 static const int kMaxTrans = 1024; |
411 int xPos = (random->nextU() % 2) * 2 - 1; | 412 int xPos = (random->nextU() % 2) * 2 - 1; |
(...skipping 13 matching lines...) Expand all Loading... |
425 viewMatrix, | 426 viewMatrix, |
426 gSurfaceProps, text, | 427 gSurfaceProps, text, |
427 static_cast<size_t>(textLen), x,
y)); | 428 static_cast<size_t>(textLen), x,
y)); |
428 | 429 |
429 return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPain
t, | 430 return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPain
t, |
430 gSurfaceProps, gTextContext->dfAdjustTable(), | 431 gSurfaceProps, gTextContext->dfAdjustTable(), |
431 context->getBatchFontCache()); | 432 context->getBatchFontCache()); |
432 } | 433 } |
433 | 434 |
434 #endif | 435 #endif |
OLD | NEW |