| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 key.fUniqueID = blob->uniqueID(); | 105 key.fUniqueID = blob->uniqueID(); |
| 106 key.fStyle = skPaint.getStyle(); | 106 key.fStyle = skPaint.getStyle(); |
| 107 key.fHasBlur = SkToBool(mf); | 107 key.fHasBlur = SkToBool(mf); |
| 108 key.fCanonicalColor = canonicalColor; | 108 key.fCanonicalColor = canonicalColor; |
| 109 cacheBlob.reset(SkSafeRef(cache->find(key))); | 109 cacheBlob.reset(SkSafeRef(cache->find(key))); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Though for the time being runs in the textblob can override the paint, th
ey only touch font | 112 // Though for the time being runs in the textblob can override the paint, th
ey only touch font |
| 113 // info. | 113 // info. |
| 114 GrPaint grPaint; | 114 GrPaint grPaint; |
| 115 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, &grPaint)) { | 115 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.allowSRGBInputs(),
&grPaint)) { |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 | 118 |
| 119 if (cacheBlob) { | 119 if (cacheBlob) { |
| 120 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view
Matrix, x, y)) { | 120 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view
Matrix, x, y)) { |
| 121 // We have to remake the blob because changes may invalidate our mas
ks. | 121 // We have to remake the blob because changes may invalidate our mas
ks. |
| 122 // TODO we could probably get away reuse most of the time if the poi
nter is unique, | 122 // TODO we could probably get away reuse most of the time if the poi
nter is unique, |
| 123 // but we'd have to clear the subrun information | 123 // but we'd have to clear the subrun information |
| 124 cache->remove(cacheBlob); | 124 cache->remove(cacheBlob); |
| 125 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk
Paint))); | 125 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk
Paint))); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // Setup dummy SkPaint / GrPaint | 375 // Setup dummy SkPaint / GrPaint |
| 376 GrColor color = GrRandomColor(random); | 376 GrColor color = GrRandomColor(random); |
| 377 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 377 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
| 378 SkPaint skPaint; | 378 SkPaint skPaint; |
| 379 skPaint.setColor(color); | 379 skPaint.setColor(color); |
| 380 skPaint.setLCDRenderText(random->nextBool()); | 380 skPaint.setLCDRenderText(random->nextBool()); |
| 381 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 381 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
| 382 skPaint.setSubpixelText(random->nextBool()); | 382 skPaint.setSubpixelText(random->nextBool()); |
| 383 | 383 |
| 384 GrPaint grPaint; | 384 GrPaint grPaint; |
| 385 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, &grPaint)) { | 385 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.allowSRGBI
nputs(), |
| 386 &grPaint)) { |
| 386 SkFAIL("couldn't convert paint\n"); | 387 SkFAIL("couldn't convert paint\n"); |
| 387 } | 388 } |
| 388 | 389 |
| 389 const char* text = "The quick brown fox jumps over the lazy dog."; | 390 const char* text = "The quick brown fox jumps over the lazy dog."; |
| 390 int textLen = (int)strlen(text); | 391 int textLen = (int)strlen(text); |
| 391 | 392 |
| 392 // create some random x/y offsets, including negative offsets | 393 // create some random x/y offsets, including negative offsets |
| 393 static const int kMaxTrans = 1024; | 394 static const int kMaxTrans = 1024; |
| 394 int xPos = (random->nextU() % 2) * 2 - 1; | 395 int xPos = (random->nextU() % 2) * 2 - 1; |
| 395 int yPos = (random->nextU() % 2) * 2 - 1; | 396 int yPos = (random->nextU() % 2) * 2 - 1; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 407 viewMatrix, | 408 viewMatrix, |
| 408 gSurfaceProps, text, | 409 gSurfaceProps, text, |
| 409 static_cast<size_t>(textLen), x,
y)); | 410 static_cast<size_t>(textLen), x,
y)); |
| 410 | 411 |
| 411 return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPain
t, | 412 return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPain
t, |
| 412 gSurfaceProps, gTextContext->dfAdjustTable(), | 413 gSurfaceProps, gTextContext->dfAdjustTable(), |
| 413 context->getBatchFontCache()); | 414 context->getBatchFontCache()); |
| 414 } | 415 } |
| 415 | 416 |
| 416 #endif | 417 #endif |
| OLD | NEW |