diff options
author | 2016-09-07 10:02:04 -0700 | |
---|---|---|
committer | 2016-09-07 10:02:04 -0700 | |
commit | b77a907c2fb4402b7e70e9fff70eb71482354e67 (patch) | |
tree | 692acfaad6a575969ceb547d617aa6bfcbc7a4d8 /src/gpu/GrContext.cpp | |
parent | 5edf2908a305d3365a1574a8358343bb26468b35 (diff) |
Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache.
Consolidates all flush actions into GrDrawingManager and makes GrContext::flush a passthrough.
Removes the unused and untested discard flush variation.
Replaces the indirect overbudget callback mechanism of GrResourceCache with a flag set by resource cache when it wants to flush that is checked after each draw by GrDrawContext.
Modifies GrResourceCache::notifyFlushOccurred() to take a param indicating whether it triggered the
flush that just occurred.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2307053002
Committed: https://skia.googlesource.com/skia/+/1dbb207babecdae8f1f74ed9d9900c73064df744
Review-Url: https://codereview.chromium.org/2307053002
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rw-r--r-- | src/gpu/GrContext.cpp | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 3f4d2fa959..357f58e6e3 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -66,7 +66,6 @@ GrContext::GrContext() : fUniqueID(next_id()) { fResourceCache = nullptr; fResourceProvider = nullptr; fBatchFontCache = nullptr; - fFlushToReduceCacheSize = false; } bool GrContext::init(GrBackend backend, GrBackendContext backendContext, @@ -87,7 +86,6 @@ void GrContext::initCommon(const GrContextOptions& options) { fCaps = SkRef(fGpu->caps()); fResourceCache = new GrResourceCache(fCaps); - fResourceCache->setOverBudgetCallback(OverBudgetCB, this); fResourceProvider = new GrResourceProvider(fGpu, fResourceCache, &fSingleOwner); fDidTestPMConversions = false; @@ -97,7 +95,8 @@ void GrContext::initCommon(const GrContextOptions& options) { dtOptions.fDrawBatchBounds = options.fDrawBatchBounds; dtOptions.fMaxBatchLookback = options.fMaxBatchLookback; dtOptions.fMaxBatchLookahead = options.fMaxBatchLookahead; - fDrawingManager.reset(new GrDrawingManager(this, dtOptions, &fSingleOwner)); + fDrawingManager.reset(new GrDrawingManager(this, dtOptions, options.fImmediateMode, + &fSingleOwner)); // GrBatchFontCache will eventually replace GrFontCache fBatchFontCache = new GrBatchFontCache(this); @@ -203,41 +202,21 @@ void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) //////////////////////////////////////////////////////////////////////////////// -void GrContext::OverBudgetCB(void* data) { - SkASSERT(data); - - GrContext* context = reinterpret_cast<GrContext*>(data); - - // Flush the GrBufferedDrawTarget to possibly free up some textures - 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 + // TextBlobs are drawn at the SkGpuDevice level, therefore they cannot rely on GrDrawContext + // to perform a necessary flush. 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(); } //////////////////////////////////////////////////////////////////////////////// -void GrContext::flush(int flagsBitfield) { +void GrContext::flush() { ASSERT_SINGLE_OWNER RETURN_IF_ABANDONED - bool flushed = false; - if (kDiscard_FlushBit & flagsBitfield) { - fDrawingManager->reset(); - } else { - flushed = fDrawingManager->flush(); - } - if (flushed) { - fResourceCache->notifyFlushOccurred(); - } - fFlushToReduceCacheSize = false; + fDrawingManager->flush(); } bool sw_convert_to_premul(GrPixelConfig srcConfig, int width, int height, size_t inRowBytes, |