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

Unified Diff: src/gpu/GrContext.cpp

Issue 1406173003: Loosen requirement that there be only one GrDrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 5 years, 2 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/GrRenderTarget.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 82550d0d297d3c8be9ab2d72ba6c4c25790ca948..a691da7de326360c8c69dd2f81c6c0b68d38235c 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -62,13 +62,18 @@
void GrContext::DrawingMgr::init(GrContext* context) {
fContext = context;
- fDrawTarget = new GrDrawTarget(context->getGpu(), context->resourceProvider());
}
void GrContext::DrawingMgr::cleanup() {
- SkSafeSetNull(fDrawTarget);
+ for (int i = 0; i < fDrawTargets.count(); ++i) {
+ fDrawTargets[i]->unref();
+ }
+
+ fDrawTargets.reset();
+
delete fNVPRTextContext;
fNVPRTextContext = nullptr;
+
for (int i = 0; i < kNumPixelGeometries; ++i) {
delete fTextContexts[i][0];
fTextContexts[i][0] = nullptr;
@@ -82,18 +87,19 @@ GrContext::DrawingMgr::~DrawingMgr() {
}
void GrContext::DrawingMgr::abandon() {
+ fAbandoned = true;
this->cleanup();
}
void GrContext::DrawingMgr::reset() {
- if (fDrawTarget) {
- fDrawTarget->reset();
+ for (int i = 0; i < fDrawTargets.count(); ++i) {
+ fDrawTargets[i]->reset();
}
}
void GrContext::DrawingMgr::flush() {
- if (fDrawTarget) {
- fDrawTarget->flush();
+ for (int i = 0; i < fDrawTargets.count(); ++i) {
+ fDrawTargets[i]->flush();
}
}
@@ -125,13 +131,33 @@ GrTextContext* GrContext::DrawingMgr::textContext(const SkSurfaceProps& props,
return fTextContexts[props.pixelGeometry()][useDIF];
}
+GrDrawTarget* GrContext::DrawingMgr::newDrawTarget(GrRenderTarget* rt) {
+ SkASSERT(fContext);
+
+ // When MDB is disabled we always just return the single drawTarget
+#ifndef ENABLE_MDB
+ if (fDrawTargets.count()) {
+ SkASSERT(fDrawTargets.count() == 1);
+ // DrawingMgr gets the creation ref - this ref is for the caller
+ return SkRef(fDrawTargets[0]);
+ }
+#endif
+
+ GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourceProvider());
+
+ *fDrawTargets.append() = dt;
+
+ // DrawingMgr gets the creation ref - this ref is for the caller
+ return SkRef(dt);
+}
+
GrDrawContext* GrContext::DrawingMgr::drawContext(GrRenderTarget* rt,
const SkSurfaceProps* surfaceProps) {
if (this->abandoned()) {
return nullptr;
}
- return new GrDrawContext(fContext, rt, fDrawTarget, surfaceProps);
+ return new GrDrawContext(fContext, rt, surfaceProps);
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « include/gpu/GrRenderTarget.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698