From 0db6dfaeb2d1376ad393516fb22af7ecf62718fa Mon Sep 17 00:00:00 2001 From: joshualitt Date: Fri, 10 Apr 2015 07:01:30 -0700 Subject: The TextBlobCache needs the ability to trigger a flush because otherwise its entire budget can be used up, but it will not be able to free up any space due to blobs being stuck in the GrInOrderDrawBuffer. This was causing a segfault. After this CL the cache will try to purge, and then flush if it cannot purge enough. It will not purge the most recent addition to the cache. TBR=bsalomon@google.com BUG=skia: Review URL: https://codereview.chromium.org/1071333002 --- src/gpu/GrContext.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/gpu/GrContext.cpp') diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 2d61f35a4f..04e3f8fa9f 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(data); + context->flush(); +} + int GrContext::getMaxTextureSize() const { return SkTMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride); } -- cgit v1.2.3