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

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

Issue 1407393004: Move GrDrawingManager methods to their own .cpp file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrAtlasTextContext.h"
9 #include "GrDrawContext.h"
10 #include "GrDrawingManager.h"
11 #include "GrDrawTarget.h"
12 #include "GrResourceProvider.h"
13 #include "GrStencilAndCoverTextContext.h"
14 #include "SkTTopoSort.h"
15
16 void GrDrawingManager::cleanup() {
17 for (int i = 0; i < fDrawTargets.count(); ++i) {
18 fDrawTargets[i]->unref();
19 }
20
21 fDrawTargets.reset();
22
23 delete fNVPRTextContext;
24 fNVPRTextContext = nullptr;
25
26 for (int i = 0; i < kNumPixelGeometries; ++i) {
27 delete fTextContexts[i][0];
28 fTextContexts[i][0] = nullptr;
29 delete fTextContexts[i][1];
30 fTextContexts[i][1] = nullptr;
31 }
32 }
33
34 GrDrawingManager::~GrDrawingManager() {
35 this->cleanup();
36 }
37
38 void GrDrawingManager::abandon() {
39 fAbandoned = true;
40 this->cleanup();
41 }
42
43 void GrDrawingManager::reset() {
44 for (int i = 0; i < fDrawTargets.count(); ++i) {
45 fDrawTargets[i]->reset();
46 }
47 }
48
49 void GrDrawingManager::flush() {
50 SkDEBUGCODE(bool result =)
51 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>( &fDrawTargets);
52 SkASSERT(result);
53
54 for (int i = 0; i < fDrawTargets.count(); ++i) {
55 //SkDEBUGCODE(fDrawTargets[i]->dump();)
56 fDrawTargets[i]->flush();
57 }
58
59 #ifndef ENABLE_MDB
60 // When MDB is disabled we keep reusing the same drawTarget
61 if (fDrawTargets.count()) {
62 SkASSERT(fDrawTargets.count() == 1);
63 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag);
64 }
65 #endif
66 }
67
68 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props,
69 GrRenderTarget* rt) {
70 if (this->abandoned()) {
71 return nullptr;
72 }
73
74 SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
75 bool useDIF = props.isUseDeviceIndependentFonts();
76
77 if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() &&
78 rt->isStencilBufferMultisampled()) {
79 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt achment(rt);
80 if (sb) {
81 if (!fNVPRTextContext) {
82 fNVPRTextContext = GrStencilAndCoverTextContext::Create(fContext , props);
83 }
84
85 return fNVPRTextContext;
86 }
87 }
88
89 if (!fTextContexts[props.pixelGeometry()][useDIF]) {
90 fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Creat e(fContext, props);
91 }
92
93 return fTextContexts[props.pixelGeometry()][useDIF];
94 }
95
96 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) {
97 SkASSERT(fContext);
98
99 #ifndef ENABLE_MDB
100 // When MDB is disabled we always just return the single drawTarget
101 if (fDrawTargets.count()) {
102 SkASSERT(fDrawTargets.count() == 1);
103 // DrawingManager gets the creation ref - this ref is for the caller
104 return SkRef(fDrawTargets[0]);
105 }
106 #endif
107
108 GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourcePr ovider());
109
110 *fDrawTargets.append() = dt;
111
112 // DrawingManager gets the creation ref - this ref is for the caller
113 return SkRef(dt);
114 }
115
116 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt,
117 const SkSurfaceProps* surfaceProps) {
118 if (this->abandoned()) {
119 return nullptr;
120 }
121
122 return new GrDrawContext(this, rt, surfaceProps);
123 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698