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(), dc->getColorSpace(), | 127 if (!SkPaintToGrPaint(context, dc, skPaint, viewMatrix, &grPaint)) { |
128 &grPaint)) { | |
129 return; | 128 return; |
130 } | 129 } |
131 | 130 |
132 if (cacheBlob) { | 131 if (cacheBlob) { |
133 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view Matrix, x, y)) { | 132 if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, view Matrix, x, y)) { |
134 // We have to remake the blob because changes may invalidate our mas ks. | 133 // We have to remake the blob because changes may invalidate our mas ks. |
135 // TODO we could probably get away reuse most of the time if the poi nter is unique, | 134 // TODO we could probably get away reuse most of the time if the poi nter is unique, |
136 // but we'd have to clear the subrun information | 135 // but we'd have to clear the subrun information |
137 cache->remove(cacheBlob); | 136 cache->remove(cacheBlob); |
138 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint))); | 137 cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, sk Paint))); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 static GrAtlasTextContext* gTextContext = nullptr; | 381 static GrAtlasTextContext* gTextContext = nullptr; |
383 static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType ); | 382 static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType ); |
384 | 383 |
385 if (context->uniqueID() != gContextID) { | 384 if (context->uniqueID() != gContextID) { |
386 gContextID = context->uniqueID(); | 385 gContextID = context->uniqueID(); |
387 delete gTextContext; | 386 delete gTextContext; |
388 | 387 |
389 gTextContext = GrAtlasTextContext::Create(); | 388 gTextContext = GrAtlasTextContext::Create(); |
390 } | 389 } |
391 | 390 |
392 // Setup dummy SkPaint / GrPaint | 391 // Setup dummy SkPaint / GrPaint / GrDrawContext |
robertphillips
2016/07/25 19:32:02
Can this be 64x64 ?
| |
392 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr ox, 1024, 1024, | |
393 kSkia8888_GrPixelCo nfig, nullptr)); | |
394 | |
393 GrColor color = GrRandomColor(random); | 395 GrColor color = GrRandomColor(random); |
394 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); | 396 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
395 SkPaint skPaint; | 397 SkPaint skPaint; |
396 skPaint.setColor(color); | 398 skPaint.setColor(color); |
397 skPaint.setLCDRenderText(random->nextBool()); | 399 skPaint.setLCDRenderText(random->nextBool()); |
398 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); | 400 skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
399 skPaint.setSubpixelText(random->nextBool()); | 401 skPaint.setSubpixelText(random->nextBool()); |
400 | 402 |
401 GrPaint grPaint; | 403 GrPaint grPaint; |
402 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.isGammaCor rect(), nullptr, | 404 if (!SkPaintToGrPaint(context, drawContext.get(), skPaint, viewMatrix, &grPa int)) { |
403 &grPaint)) { | |
404 SkFAIL("couldn't convert paint\n"); | 405 SkFAIL("couldn't convert paint\n"); |
405 } | 406 } |
406 | 407 |
407 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."; |
408 int textLen = (int)strlen(text); | 409 int textLen = (int)strlen(text); |
409 | 410 |
410 // create some random x/y offsets, including negative offsets | 411 // create some random x/y offsets, including negative offsets |
411 static const int kMaxTrans = 1024; | 412 static const int kMaxTrans = 1024; |
412 int xPos = (random->nextU() % 2) * 2 - 1; | 413 int xPos = (random->nextU() % 2) * 2 - 1; |
413 int yPos = (random->nextU() % 2) * 2 - 1; | 414 int yPos = (random->nextU() % 2) * 2 - 1; |
(...skipping 12 matching lines...) Expand all Loading... | |
426 viewMatrix, | 427 viewMatrix, |
427 gSurfaceProps, text, | 428 gSurfaceProps, text, |
428 static_cast<size_t>(textLen), x, y)); | 429 static_cast<size_t>(textLen), x, y)); |
429 | 430 |
430 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, |
431 gSurfaceProps, gTextContext->dfAdjustTable(), | 432 gSurfaceProps, gTextContext->dfAdjustTable(), |
432 context->getBatchFontCache()); | 433 context->getBatchFontCache()); |
433 } | 434 } |
434 | 435 |
435 #endif | 436 #endif |
OLD | NEW |