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

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

Issue 2066993003: Begin instanced rendering for simple shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rix perf regressions Created 4 years, 5 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/GrDrawTarget.cpp ('k') | src/gpu/GrGpu.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 "GrDrawContext.h" 8 #include "GrDrawContext.h"
9 #include "GrDrawingManager.h" 9 #include "GrDrawingManager.h"
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
11 #include "GrPathRenderingDrawContext.h" 11 #include "GrPathRenderingDrawContext.h"
12 #include "GrResourceProvider.h" 12 #include "GrResourceProvider.h"
13 #include "GrSoftwarePathRenderer.h" 13 #include "GrSoftwarePathRenderer.h"
14 #include "SkTTopoSort.h" 14 #include "SkTTopoSort.h"
15 15
16 #include "instanced/InstancedRendering.h"
17
16 #include "text/GrAtlasTextContext.h" 18 #include "text/GrAtlasTextContext.h"
17 #include "text/GrStencilAndCoverTextContext.h" 19 #include "text/GrStencilAndCoverTextContext.h"
18 20
21 using gr_instanced::InstancedRendering;
22
19 void GrDrawingManager::cleanup() { 23 void GrDrawingManager::cleanup() {
20 for (int i = 0; i < fDrawTargets.count(); ++i) { 24 for (int i = 0; i < fDrawTargets.count(); ++i) {
21 fDrawTargets[i]->makeClosed(); // no drawTarget should receive a new co mmand after this 25 fDrawTargets[i]->makeClosed(); // no drawTarget should receive a new co mmand after this
22 fDrawTargets[i]->clearRT(); 26 fDrawTargets[i]->clearRT();
23 27
24 // We shouldn't need to do this, but it turns out some clients still hol d onto drawtargets 28 // We shouldn't need to do this, but it turns out some clients still hol d onto drawtargets
25 // after a cleanup 29 // after a cleanup
26 fDrawTargets[i]->reset(); 30 fDrawTargets[i]->reset();
27 fDrawTargets[i]->unref(); 31 fDrawTargets[i]->unref();
28 } 32 }
29 33
30 fDrawTargets.reset(); 34 fDrawTargets.reset();
31 35
32 delete fPathRendererChain; 36 delete fPathRendererChain;
33 fPathRendererChain = nullptr; 37 fPathRendererChain = nullptr;
34 SkSafeSetNull(fSoftwarePathRenderer); 38 SkSafeSetNull(fSoftwarePathRenderer);
35 } 39 }
36 40
37 GrDrawingManager::~GrDrawingManager() { 41 GrDrawingManager::~GrDrawingManager() {
38 this->cleanup(); 42 this->cleanup();
39 } 43 }
40 44
41 void GrDrawingManager::abandon() { 45 void GrDrawingManager::abandon() {
42 fAbandoned = true; 46 fAbandoned = true;
47 for (int i = 0; i < fDrawTargets.count(); ++i) {
48 if (InstancedRendering* ir = fDrawTargets[i]->instancedRendering()) {
49 ir->resetGpuResources(InstancedRendering::ResetType::kAbandon);
50 }
51 }
43 this->cleanup(); 52 this->cleanup();
44 } 53 }
45 54
46 void GrDrawingManager::freeGpuResources() { 55 void GrDrawingManager::freeGpuResources() {
47 // a path renderer may be holding onto resources 56 // a path renderer may be holding onto resources
48 delete fPathRendererChain; 57 delete fPathRendererChain;
49 fPathRendererChain = nullptr; 58 fPathRendererChain = nullptr;
50 SkSafeSetNull(fSoftwarePathRenderer); 59 SkSafeSetNull(fSoftwarePathRenderer);
60 for (int i = 0; i < fDrawTargets.count(); ++i) {
61 if (InstancedRendering* ir = fDrawTargets[i]->instancedRendering()) {
62 ir->resetGpuResources(InstancedRendering::ResetType::kDestroy);
63 }
64 }
51 } 65 }
52 66
53 void GrDrawingManager::reset() { 67 void GrDrawingManager::reset() {
54 for (int i = 0; i < fDrawTargets.count(); ++i) { 68 for (int i = 0; i < fDrawTargets.count(); ++i) {
55 fDrawTargets[i]->reset(); 69 fDrawTargets[i]->reset();
56 } 70 }
57 fFlushState.reset(); 71 fFlushState.reset();
58 } 72 }
59 73
60 void GrDrawingManager::flush() { 74 void GrDrawingManager::flush() {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 fContext, this, std::mov e(rt), 194 fContext, this, std::mov e(rt),
181 surfaceProps, 195 surfaceProps,
182 fContext->getAuditTrail( ), fSingleOwner)); 196 fContext->getAuditTrail( ), fSingleOwner));
183 } 197 }
184 } 198 }
185 199
186 return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt), surfaceProps, 200 return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt), surfaceProps,
187 fContext->getAuditTrail(), 201 fContext->getAuditTrail(),
188 fSingleOwner)); 202 fSingleOwner));
189 } 203 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698