| 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 "GrDrawContext.h" | 9 #include "GrDrawContext.h" |
| 10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // We have to remake the blob because changes may invalidate our mas
ks. | 149 // We have to remake the blob because changes may invalidate our mas
ks. |
| 150 // TODO we could probably get away reuse most of the time if the poi
nter is unique, | 150 // TODO we could probably get away reuse most of the time if the poi
nter is unique, |
| 151 // but we'd have to clear the subrun information | 151 // but we'd have to clear the subrun information |
| 152 fCache->remove(cacheBlob); | 152 fCache->remove(cacheBlob); |
| 153 cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, s
kPaint, | 153 cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, s
kPaint, |
| 154 GrAtlasTextBlob::kGra
yTextVASize))); | 154 GrAtlasTextBlob::kGra
yTextVASize))); |
| 155 this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), vie
wMatrix, | 155 this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), vie
wMatrix, |
| 156 blob, x, y, drawFilter); | 156 blob, x, y, drawFilter); |
| 157 } else { | 157 } else { |
| 158 fCache->makeMRU(cacheBlob); | 158 fCache->makeMRU(cacheBlob); |
| 159 #ifdef CACHE_SANITY_CHECK | 159 |
| 160 { | 160 if (CACHE_SANITY_CHECK) { |
| 161 int glyphCount = 0; | 161 int glyphCount = 0; |
| 162 int runCount = 0; | 162 int runCount = 0; |
| 163 GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob); | 163 GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob); |
| 164 SkAutoTUnref<GrAtlasTextBlob> sanityBlob(fCache->createBlob(glyp
hCount, runCount, | 164 SkAutoTUnref<GrAtlasTextBlob> sanityBlob( |
| 165 kGra
yTextVASize)); | 165 fCache->createBlob(glyphCount, runCount, GrAtlasTextBlob::kG
rayTextVASize)); |
| 166 GrTextBlobCache::SetupCacheBlobKey(sanityBlob, key, blurRec, skP
aint); | 166 GrTextBlobCache::SetupCacheBlobKey(sanityBlob, key, blurRec, skP
aint); |
| 167 this->regenerateTextBlob(sanityBlob, skPaint, grPaint.getColor()
, viewMatrix, | 167 this->regenerateTextBlob(sanityBlob, skPaint, grPaint.getColor()
, viewMatrix, |
| 168 blob, x, y, drawFilter); | 168 blob, x, y, drawFilter); |
| 169 GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob); | 169 GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob); |
| 170 } | 170 } |
| 171 | |
| 172 #endif | |
| 173 } | 171 } |
| 174 } else { | 172 } else { |
| 175 if (canCache) { | 173 if (canCache) { |
| 176 cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, s
kPaint, | 174 cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, s
kPaint, |
| 177 GrAtlasTextBlob::kGra
yTextVASize))); | 175 GrAtlasTextBlob::kGra
yTextVASize))); |
| 178 } else { | 176 } else { |
| 179 cacheBlob.reset(fCache->createBlob(blob, GrAtlasTextBlob::kGrayTextV
ASize)); | 177 cacheBlob.reset(fCache->createBlob(blob, GrAtlasTextBlob::kGrayTextV
ASize)); |
| 180 } | 178 } |
| 181 this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMat
rix, | 179 this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMat
rix, |
| 182 blob, x, y, drawFilter); | 180 blob, x, y, drawFilter); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 // We'd like to be able to test this with random translations, but currently
the vertex | 394 // We'd like to be able to test this with random translations, but currently
the vertex |
| 397 // bounds and vertices will get out of sync | 395 // bounds and vertices will get out of sync |
| 398 SkScalar transX = 0.f;//SkIntToScalar(random->nextU()); | 396 SkScalar transX = 0.f;//SkIntToScalar(random->nextU()); |
| 399 SkScalar transY = 0.f;//SkIntToScalar(random->nextU()); | 397 SkScalar transY = 0.f;//SkIntToScalar(random->nextU()); |
| 400 return blob->test_createBatch(textLen, 0, 0, color, transX, transY, skPaint, | 398 return blob->test_createBatch(textLen, 0, 0, color, transX, transY, skPaint, |
| 401 gSurfaceProps, gTextContext->dfAdjustTable(), | 399 gSurfaceProps, gTextContext->dfAdjustTable(), |
| 402 context->getBatchFontCache()); | 400 context->getBatchFontCache()); |
| 403 } | 401 } |
| 404 | 402 |
| 405 #endif | 403 #endif |
| OLD | NEW |