aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrContext.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-04-10 07:01:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-10 07:01:30 -0700
commit0db6dfaeb2d1376ad393516fb22af7ecf62718fa (patch)
treebb4e19cebcedf94b9abd455c637712e5544beaa3 /src/gpu/GrContext.cpp
parentc5e0891029bed0f9619d67281a81f13983a9687b (diff)
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
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rwxr-xr-xsrc/gpu/GrContext.cpp13
1 files changed, 12 insertions, 1 deletions
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<GrContext*>(data);
+ context->flush();
+}
+
int GrContext::getMaxTextureSize() const {
return SkTMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride);
}