Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index 2d61f35a4f02151bfc5508513ffb52c89e8c96b4..04e3f8fa9ff16aee0b03f47eaf8b1393a3512ae9 100755 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -137,7 +137,7 @@ void GrContext::initCommon() { |
// GrBatchFontCache will eventually replace GrFontCache |
fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this)); |
- fTextBlobCache.reset(SkNEW(GrTextBlobCache)); |
+ fTextBlobCache.reset(SkNEW_ARGS(GrTextBlobCache, (TextBlobCacheOverBudgetCB, this))); |
} |
GrContext::~GrContext() { |
@@ -354,6 +354,17 @@ void GrContext::OverBudgetCB(void* data) { |
context->fFlushToReduceCacheSize = true; |
} |
+void GrContext::TextBlobCacheOverBudgetCB(void* data) { |
+ SkASSERT(data); |
+ |
+ // Unlike the GrResourceCache, TextBlobs are drawn at the SkGpuDevice level, therefore they |
+ // cannot use fFlushTorReduceCacheSize because it uses AutoCheckFlush. The solution is to move |
+ // drawText calls to below the GrContext level, but this is not trivial because they call |
+ // drawPath on SkGpuDevice |
+ GrContext* context = reinterpret_cast<GrContext*>(data); |
+ context->flush(); |
+} |
+ |
int GrContext::getMaxTextureSize() const { |
return SkTMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride); |
} |