Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: src/gpu/GrContext.cpp

Issue 2312123003: Revert of Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 357f58e6e323240234a8f226fd0e65b3ea2a76c3..3f4d2fa95913a066f2eb8719cf375e97780af159 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -66,6 +66,7 @@
fResourceCache = nullptr;
fResourceProvider = nullptr;
fBatchFontCache = nullptr;
+ fFlushToReduceCacheSize = false;
}
bool GrContext::init(GrBackend backend, GrBackendContext backendContext,
@@ -86,6 +87,7 @@
fCaps = SkRef(fGpu->caps());
fResourceCache = new GrResourceCache(fCaps);
+ fResourceCache->setOverBudgetCallback(OverBudgetCB, this);
fResourceProvider = new GrResourceProvider(fGpu, fResourceCache, &fSingleOwner);
fDidTestPMConversions = false;
@@ -95,8 +97,7 @@
dtOptions.fDrawBatchBounds = options.fDrawBatchBounds;
dtOptions.fMaxBatchLookback = options.fMaxBatchLookback;
dtOptions.fMaxBatchLookahead = options.fMaxBatchLookahead;
- fDrawingManager.reset(new GrDrawingManager(this, dtOptions, options.fImmediateMode,
- &fSingleOwner));
+ fDrawingManager.reset(new GrDrawingManager(this, dtOptions, &fSingleOwner));
// GrBatchFontCache will eventually replace GrFontCache
fBatchFontCache = new GrBatchFontCache(this);
@@ -202,21 +203,41 @@
////////////////////////////////////////////////////////////////////////////////
+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);
- // 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.
+
+ // 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();
}
////////////////////////////////////////////////////////////////////////////////
-void GrContext::flush() {
+void GrContext::flush(int flagsBitfield) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
- fDrawingManager->flush();
+ bool flushed = false;
+ if (kDiscard_FlushBit & flagsBitfield) {
+ fDrawingManager->reset();
+ } else {
+ flushed = fDrawingManager->flush();
+ }
+ if (flushed) {
+ fResourceCache->notifyFlushOccurred();
+ }
+ fFlushToReduceCacheSize = false;
}
bool sw_convert_to_premul(GrPixelConfig srcConfig, int width, int height, size_t inRowBytes,
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698