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

Side by Side Diff: src/gpu/GrContext.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 | « gyp/gpu.gypi ('k') | src/gpu/GrDrawingManager.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrContext.h" 9 #include "GrContext.h"
10
11 #include "GrBatchFontCache.h"
12 #include "GrBatchFlushState.h"
13 #include "GrBatchTest.h"
14 #include "GrCaps.h"
15 #include "GrContextOptions.h" 10 #include "GrContextOptions.h"
16 #include "GrDefaultGeoProcFactory.h"
17 #include "GrDrawingManager.h" 11 #include "GrDrawingManager.h"
18 #include "GrDrawContext.h" 12 #include "GrDrawContext.h"
19 #include "GrDrawTarget.h"
20 #include "GrGpuResource.h"
21 #include "GrGpuResourcePriv.h"
22 #include "GrGpu.h"
23 #include "GrIndexBuffer.h"
24 #include "GrLayerCache.h" 13 #include "GrLayerCache.h"
25 #include "GrOvalRenderer.h"
26 #include "GrPathRenderer.h"
27 #include "GrPathUtils.h"
28 #include "GrRenderTargetPriv.h"
29 #include "GrResourceCache.h" 14 #include "GrResourceCache.h"
30 #include "GrResourceProvider.h" 15 #include "GrResourceProvider.h"
31 #include "GrSoftwarePathRenderer.h" 16 #include "GrSoftwarePathRenderer.h"
32 #include "GrStencilAndCoverTextContext.h"
33 #include "GrStrokeInfo.h"
34 #include "GrSurfacePriv.h" 17 #include "GrSurfacePriv.h"
35 #include "GrTextBlobCache.h" 18 #include "GrTextBlobCache.h"
36 #include "GrTexturePriv.h" 19
37 #include "GrTracing.h"
38 #include "GrVertices.h"
39 #include "SkDashPathPriv.h"
40 #include "SkConfig8888.h" 20 #include "SkConfig8888.h"
41 #include "SkGrPriv.h" 21 #include "SkGrPriv.h"
42 #include "SkRRect.h"
43 #include "SkStrokeRec.h"
44 #include "SkSurfacePriv.h"
45 #include "SkTLazy.h"
46 #include "SkTLS.h"
47 #include "SkTraceEvent.h"
48 #include "SkTTopoSort.h"
49
50 #include "batches/GrBatch.h"
51 22
52 #include "effects/GrConfigConversionEffect.h" 23 #include "effects/GrConfigConversionEffect.h"
53 #include "effects/GrDashingEffect.h"
54 #include "effects/GrSingleTextureEffect.h"
55 24
56 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) 25 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
57 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } 26 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
58 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal se; } 27 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal se; }
59 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null ptr; } 28 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null ptr; }
60 29
61
62 //////////////////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////////////////
63 31
64 void GrDrawingManager::cleanup() {
65 for (int i = 0; i < fDrawTargets.count(); ++i) {
66 fDrawTargets[i]->unref();
67 }
68
69 fDrawTargets.reset();
70
71 delete fNVPRTextContext;
72 fNVPRTextContext = nullptr;
73
74 for (int i = 0; i < kNumPixelGeometries; ++i) {
75 delete fTextContexts[i][0];
76 fTextContexts[i][0] = nullptr;
77 delete fTextContexts[i][1];
78 fTextContexts[i][1] = nullptr;
79 }
80 }
81
82 GrDrawingManager::~GrDrawingManager() {
83 this->cleanup();
84 }
85
86 void GrDrawingManager::abandon() {
87 fAbandoned = true;
88 this->cleanup();
89 }
90
91 void GrDrawingManager::reset() {
92 for (int i = 0; i < fDrawTargets.count(); ++i) {
93 fDrawTargets[i]->reset();
94 }
95 }
96
97 void GrDrawingManager::flush() {
98 SkDEBUGCODE(bool result =)
99 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>( &fDrawTargets);
100 SkASSERT(result);
101
102 for (int i = 0; i < fDrawTargets.count(); ++i) {
103 //SkDEBUGCODE(fDrawTargets[i]->dump();)
104 fDrawTargets[i]->flush();
105 }
106
107 #ifndef ENABLE_MDB
108 // When MDB is disabled we keep reusing the same drawTarget
109 if (fDrawTargets.count()) {
110 SkASSERT(fDrawTargets.count() == 1);
111 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag);
112 }
113 #endif
114 }
115
116 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props,
117 GrRenderTarget* rt) {
118 if (this->abandoned()) {
119 return nullptr;
120 }
121
122 SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
123 bool useDIF = props.isUseDeviceIndependentFonts();
124
125 if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() &&
126 rt->isStencilBufferMultisampled()) {
127 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt achment(rt);
128 if (sb) {
129 if (!fNVPRTextContext) {
130 fNVPRTextContext = GrStencilAndCoverTextContext::Create(fContext , props);
131 }
132
133 return fNVPRTextContext;
134 }
135 }
136
137 if (!fTextContexts[props.pixelGeometry()][useDIF]) {
138 fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Creat e(fContext, props);
139 }
140
141 return fTextContexts[props.pixelGeometry()][useDIF];
142 }
143
144 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) {
145 SkASSERT(fContext);
146
147 #ifndef ENABLE_MDB
148 // When MDB is disabled we always just return the single drawTarget
149 if (fDrawTargets.count()) {
150 SkASSERT(fDrawTargets.count() == 1);
151 // DrawingManager gets the creation ref - this ref is for the caller
152 return SkRef(fDrawTargets[0]);
153 }
154 #endif
155
156 GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourcePr ovider());
157
158 *fDrawTargets.append() = dt;
159
160 // DrawingManager gets the creation ref - this ref is for the caller
161 return SkRef(dt);
162 }
163
164 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt,
165 const SkSurfaceProps* surfaceProps) {
166 if (this->abandoned()) {
167 return nullptr;
168 }
169
170 return new GrDrawContext(this, rt, surfaceProps);
171 }
172
173 ////////////////////////////////////////////////////////////////////////////////
174
175
176 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) { 32 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
177 GrContextOptions defaultOptions; 33 GrContextOptions defaultOptions;
178 return Create(backend, backendContext, defaultOptions); 34 return Create(backend, backendContext, defaultOptions);
179 } 35 }
180 36
181 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext, 37 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
182 const GrContextOptions& options) { 38 const GrContextOptions& options) {
183 GrContext* context = new GrContext; 39 GrContext* context = new GrContext;
184 40
185 if (context->init(backend, backendContext, options)) { 41 if (context->init(backend, backendContext, options)) {
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 665
810 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) { 666 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) {
811 fResourceCache->setLimits(maxTextures, maxTextureBytes); 667 fResourceCache->setLimits(maxTextures, maxTextureBytes);
812 } 668 }
813 669
814 ////////////////////////////////////////////////////////////////////////////// 670 //////////////////////////////////////////////////////////////////////////////
815 671
816 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { 672 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
817 fResourceCache->dumpMemoryStatistics(traceMemoryDump); 673 fResourceCache->dumpMemoryStatistics(traceMemoryDump);
818 } 674 }
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrDrawingManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698