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

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

Issue 1441533003: Update testing frameworks/tests for MDB (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix ref counting bug Created 5 years, 1 month 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') | src/gpu/GrTest.h » ('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 "GrAtlasTextContext.h" 8 #include "GrAtlasTextContext.h"
9 #include "GrDrawContext.h" 9 #include "GrDrawContext.h"
10 #include "GrDrawingManager.h" 10 #include "GrDrawingManager.h"
11 #include "GrDrawTarget.h" 11 #include "GrDrawTarget.h"
12 #include "GrResourceProvider.h" 12 #include "GrResourceProvider.h"
13 #include "GrSoftwarePathRenderer.h" 13 #include "GrSoftwarePathRenderer.h"
14 #include "GrStencilAndCoverTextContext.h" 14 #include "GrStencilAndCoverTextContext.h"
15 #include "SkTTopoSort.h" 15 #include "SkTTopoSort.h"
16 16
17 //#define ENABLE_MDB 1
18 17
19 void GrDrawingManager::cleanup() { 18 void GrDrawingManager::cleanup() {
20 for (int i = 0; i < fDrawTargets.count(); ++i) { 19 for (int i = 0; i < fDrawTargets.count(); ++i) {
20 fDrawTargets[i]->makeClosed(); // no drawTarget should receive a new co mmand after this
21 fDrawTargets[i]->clearRT();
22
21 fDrawTargets[i]->unref(); 23 fDrawTargets[i]->unref();
22 } 24 }
23 25
24 fDrawTargets.reset(); 26 fDrawTargets.reset();
25 27
26 delete fNVPRTextContext; 28 delete fNVPRTextContext;
27 fNVPRTextContext = nullptr; 29 fNVPRTextContext = nullptr;
28 30
29 for (int i = 0; i < kNumPixelGeometries; ++i) { 31 for (int i = 0; i < kNumPixelGeometries; ++i) {
30 delete fTextContexts[i][0]; 32 delete fTextContexts[i][0];
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 80
79 // Upload all data to the GPU 81 // Upload all data to the GPU
80 fFlushState.preIssueDraws(); 82 fFlushState.preIssueDraws();
81 83
82 for (int i = 0; i < fDrawTargets.count(); ++i) { 84 for (int i = 0; i < fDrawTargets.count(); ++i) {
83 fDrawTargets[i]->drawBatches(&fFlushState); 85 fDrawTargets[i]->drawBatches(&fFlushState);
84 } 86 }
85 87
86 SkASSERT(fFlushState.lastFlushedToken() == fFlushState.currentToken()); 88 SkASSERT(fFlushState.lastFlushedToken() == fFlushState.currentToken());
87 89
90 for (int i = 0; i < fDrawTargets.count(); ++i) {
91 fDrawTargets[i]->reset();
92 #ifdef ENABLE_MDB
93 fDrawTargets[i]->unref();
94 #endif
95 }
96
88 #ifndef ENABLE_MDB 97 #ifndef ENABLE_MDB
89 // When MDB is disabled we keep reusing the same drawTarget 98 // When MDB is disabled we keep reusing the same drawTarget
90 if (fDrawTargets.count()) { 99 if (fDrawTargets.count()) {
91 SkASSERT(fDrawTargets.count() == 1); 100 SkASSERT(fDrawTargets.count() == 1);
101 // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnm arked check
102 // won't bark
92 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); 103 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag);
93 } 104 }
105 #else
106 fDrawTargets.reset();
94 #endif 107 #endif
95 108
96 for (int i = 0; i < fDrawTargets.count(); ++i) {
97 fDrawTargets[i]->reset();
98 }
99 fFlushState.reset(); 109 fFlushState.reset();
100 } 110 }
101 111
102 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, 112 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props,
103 GrRenderTarget* rt) { 113 GrRenderTarget* rt) {
104 if (this->abandoned()) { 114 if (this->abandoned()) {
105 return nullptr; 115 return nullptr;
106 } 116 }
107 117
108 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); 118 SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
(...skipping 18 matching lines...) Expand all
127 return fTextContexts[props.pixelGeometry()][useDIF]; 137 return fTextContexts[props.pixelGeometry()][useDIF];
128 } 138 }
129 139
130 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { 140 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) {
131 SkASSERT(fContext); 141 SkASSERT(fContext);
132 142
133 #ifndef ENABLE_MDB 143 #ifndef ENABLE_MDB
134 // When MDB is disabled we always just return the single drawTarget 144 // When MDB is disabled we always just return the single drawTarget
135 if (fDrawTargets.count()) { 145 if (fDrawTargets.count()) {
136 SkASSERT(fDrawTargets.count() == 1); 146 SkASSERT(fDrawTargets.count() == 1);
147 // In the non-MDB-world the same drawTarget gets reused for multiple ren der targets.
148 // Update this pointer so all the asserts are happy
149 rt->setLastDrawTarget(fDrawTargets[0]);
137 // DrawingManager gets the creation ref - this ref is for the caller 150 // DrawingManager gets the creation ref - this ref is for the caller
138 return SkRef(fDrawTargets[0]); 151 return SkRef(fDrawTargets[0]);
139 } 152 }
140 #endif 153 #endif
141 154
142 GrDrawTarget* dt = new GrDrawTarget(rt, fContext->getGpu(), fContext->resour ceProvider()); 155 GrDrawTarget* dt = new GrDrawTarget(rt, fContext->getGpu(), fContext->resour ceProvider());
143 156
144 *fDrawTargets.append() = dt; 157 *fDrawTargets.append() = dt;
145 158
146 // DrawingManager gets the creation ref - this ref is for the caller 159 // DrawingManager gets the creation ref - this ref is for the caller
(...skipping 27 matching lines...) Expand all
174 } 187 }
175 188
176 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, 189 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt,
177 const SkSurfaceProps* surfaceProps) { 190 const SkSurfaceProps* surfaceProps) {
178 if (this->abandoned()) { 191 if (this->abandoned()) {
179 return nullptr; 192 return nullptr;
180 } 193 }
181 194
182 return new GrDrawContext(this, rt, surfaceProps); 195 return new GrDrawContext(this, rt, surfaceProps);
183 } 196 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawingManager.h ('k') | src/gpu/GrTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698