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

Side by Side Diff: src/gpu/GrDrawingManager.cpp

Issue 2298003003: Don't purge resources for trivial GrContext flushes (Closed)
Patch Set: Fix speeling 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawingManager.h ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrDrawContext.h" 8 #include "GrDrawContext.h"
9 #include "GrDrawingManager.h" 9 #include "GrDrawingManager.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 } 68 }
69 69
70 void GrDrawingManager::reset() { 70 void GrDrawingManager::reset() {
71 for (int i = 0; i < fDrawTargets.count(); ++i) { 71 for (int i = 0; i < fDrawTargets.count(); ++i) {
72 fDrawTargets[i]->reset(); 72 fDrawTargets[i]->reset();
73 } 73 }
74 fFlushState.reset(); 74 fFlushState.reset();
75 } 75 }
76 76
77 void GrDrawingManager::flush() { 77 bool GrDrawingManager::flush() {
78 if (fFlushing || this->wasAbandoned()) { 78 if (fFlushing || this->wasAbandoned()) {
79 return; 79 return false;
80 } 80 }
81 fFlushing = true; 81 fFlushing = true;
82 82 bool flushed = false;
83 SkDEBUGCODE(bool result =) 83 SkDEBUGCODE(bool result =)
84 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>( &fDrawTargets); 84 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>( &fDrawTargets);
85 SkASSERT(result); 85 SkASSERT(result);
86 86
87 for (int i = 0; i < fDrawTargets.count(); ++i) { 87 for (int i = 0; i < fDrawTargets.count(); ++i) {
88 fDrawTargets[i]->prepareBatches(&fFlushState); 88 fDrawTargets[i]->prepareBatches(&fFlushState);
89 } 89 }
90 90
91 // Enable this to print out verbose batching information 91 // Enable this to print out verbose batching information
92 #if 0 92 #if 0
93 for (int i = 0; i < fDrawTargets.count(); ++i) { 93 for (int i = 0; i < fDrawTargets.count(); ++i) {
94 SkDEBUGCODE(fDrawTargets[i]->dump();) 94 SkDEBUGCODE(fDrawTargets[i]->dump();)
95 } 95 }
96 #endif 96 #endif
97 97
98 // Upload all data to the GPU 98 // Upload all data to the GPU
99 fFlushState.preIssueDraws(); 99 fFlushState.preIssueDraws();
100 100
101 for (int i = 0; i < fDrawTargets.count(); ++i) { 101 for (int i = 0; i < fDrawTargets.count(); ++i) {
102 fDrawTargets[i]->drawBatches(&fFlushState); 102 if (fDrawTargets[i]->drawBatches(&fFlushState)) {
103 flushed = true;
104 }
103 } 105 }
104 106
105 SkASSERT(fFlushState.nextDrawToken() == fFlushState.nextTokenToFlush()); 107 SkASSERT(fFlushState.nextDrawToken() == fFlushState.nextTokenToFlush());
106 108
107 for (int i = 0; i < fDrawTargets.count(); ++i) { 109 for (int i = 0; i < fDrawTargets.count(); ++i) {
108 fDrawTargets[i]->reset(); 110 fDrawTargets[i]->reset();
109 #ifdef ENABLE_MDB 111 #ifdef ENABLE_MDB
110 fDrawTargets[i]->unref(); 112 fDrawTargets[i]->unref();
111 #endif 113 #endif
112 } 114 }
113 115
114 #ifndef ENABLE_MDB 116 #ifndef ENABLE_MDB
115 // When MDB is disabled we keep reusing the same drawTarget 117 // When MDB is disabled we keep reusing the same drawTarget
116 if (fDrawTargets.count()) { 118 if (fDrawTargets.count()) {
117 SkASSERT(fDrawTargets.count() == 1); 119 SkASSERT(fDrawTargets.count() == 1);
118 // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnm arked check 120 // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnm arked check
119 // won't bark 121 // won't bark
120 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); 122 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag);
121 } 123 }
122 #else 124 #else
123 fDrawTargets.reset(); 125 fDrawTargets.reset();
124 #endif 126 #endif
125 127
126 fFlushState.reset(); 128 fFlushState.reset();
127 fFlushing = false; 129 fFlushing = false;
130 return flushed;
128 } 131 }
129 132
130 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { 133 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) {
131 SkASSERT(fContext); 134 SkASSERT(fContext);
132 135
133 #ifndef ENABLE_MDB 136 #ifndef ENABLE_MDB
134 // When MDB is disabled we always just return the single drawTarget 137 // When MDB is disabled we always just return the single drawTarget
135 if (fDrawTargets.count()) { 138 if (fDrawTargets.count()) {
136 SkASSERT(fDrawTargets.count() == 1); 139 SkASSERT(fDrawTargets.count() == 1);
137 // In the non-MDB-world the same drawTarget gets reused for multiple ren der targets. 140 // In the non-MDB-world the same drawTarget gets reused for multiple ren der targets.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 std::move(colorSpace), s urfaceProps, 216 std::move(colorSpace), s urfaceProps,
214 fContext->getAuditTrail( ), fSingleOwner)); 217 fContext->getAuditTrail( ), fSingleOwner));
215 } 218 }
216 } 219 }
217 220
218 return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt), 221 return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt),
219 std::move(colorSpace), surface Props, 222 std::move(colorSpace), surface Props,
220 fContext->getAuditTrail(), 223 fContext->getAuditTrail(),
221 fSingleOwner)); 224 fSingleOwner));
222 } 225 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawingManager.h ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698