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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 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/GrCommandBuilder.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.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 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #define RETURN_FALSE_IF_ABANDONED if (fDrawingMgr.abandoned()) { return false; } 57 #define RETURN_FALSE_IF_ABANDONED if (fDrawingMgr.abandoned()) { return false; }
58 #define RETURN_NULL_IF_ABANDONED if (fDrawingMgr.abandoned()) { return NULL; } 58 #define RETURN_NULL_IF_ABANDONED if (fDrawingMgr.abandoned()) { return NULL; }
59 59
60 60
61 //////////////////////////////////////////////////////////////////////////////// 61 ////////////////////////////////////////////////////////////////////////////////
62 62
63 void GrContext::DrawingMgr::init(GrContext* context) { 63 void GrContext::DrawingMgr::init(GrContext* context) {
64 fContext = context; 64 fContext = context;
65 65
66 #ifdef IMMEDIATE_MODE 66 #ifdef IMMEDIATE_MODE
67 fDrawTarget = SkNEW_ARGS(GrImmediateDrawTarget, (context)); 67 fDrawTarget = new GrImmediateDrawTarget(context);
68 #else 68 #else
69 fDrawTarget = SkNEW_ARGS(GrBufferedDrawTarget, (context)); 69 fDrawTarget = new GrBufferedDrawTarget(context);
70 #endif 70 #endif
71 } 71 }
72 72
73 void GrContext::DrawingMgr::cleanup() { 73 void GrContext::DrawingMgr::cleanup() {
74 SkSafeSetNull(fDrawTarget); 74 SkSafeSetNull(fDrawTarget);
75 for (int i = 0; i < kNumPixelGeometries; ++i) { 75 for (int i = 0; i < kNumPixelGeometries; ++i) {
76 SkSafeSetNull(fDrawContext[i][0]); 76 SkSafeSetNull(fDrawContext[i][0]);
77 SkSafeSetNull(fDrawContext[i][1]); 77 SkSafeSetNull(fDrawContext[i][1]);
78 } 78 }
79 } 79 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceP rops) { 115 GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceP rops) {
116 if (this->abandoned()) { 116 if (this->abandoned()) {
117 return NULL; 117 return NULL;
118 } 118 }
119 119
120 const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps)); 120 const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps));
121 121
122 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); 122 SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
123 if (!fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()]) { 123 if (!fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()]) {
124 fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()] = 124 fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()] =
125 SkNEW_ARGS(GrDrawContext, (fContext, fDrawTarget, props)); 125 new GrDrawContext(fContext, fDrawTarget, props);
126 } 126 }
127 127
128 return fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()]; 128 return fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()];
129 } 129 }
130 130
131 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
132 132
133 133
134 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) { 134 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
135 GrContextOptions defaultOptions; 135 GrContextOptions defaultOptions;
136 return Create(backend, backendContext, defaultOptions); 136 return Create(backend, backendContext, defaultOptions);
137 } 137 }
138 138
139 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext, 139 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
140 const GrContextOptions& options) { 140 const GrContextOptions& options) {
141 GrContext* context = SkNEW(GrContext); 141 GrContext* context = new GrContext;
142 142
143 if (context->init(backend, backendContext, options)) { 143 if (context->init(backend, backendContext, options)) {
144 return context; 144 return context;
145 } else { 145 } else {
146 context->unref(); 146 context->unref();
147 return NULL; 147 return NULL;
148 } 148 }
149 } 149 }
150 150
151 static int32_t gNextID = 1; 151 static int32_t gNextID = 1;
(...skipping 23 matching lines...) Expand all
175 fGpu = GrGpu::Create(backend, backendContext, options, this); 175 fGpu = GrGpu::Create(backend, backendContext, options, this);
176 if (!fGpu) { 176 if (!fGpu) {
177 return false; 177 return false;
178 } 178 }
179 this->initCommon(); 179 this->initCommon();
180 return true; 180 return true;
181 } 181 }
182 182
183 void GrContext::initCommon() { 183 void GrContext::initCommon() {
184 fCaps = SkRef(fGpu->caps()); 184 fCaps = SkRef(fGpu->caps());
185 fResourceCache = SkNEW_ARGS(GrResourceCache, (fCaps)); 185 fResourceCache = new GrResourceCache(fCaps);
186 fResourceCache->setOverBudgetCallback(OverBudgetCB, this); 186 fResourceCache->setOverBudgetCallback(OverBudgetCB, this);
187 fResourceProvider = SkNEW_ARGS(GrResourceProvider, (fGpu, fResourceCache)); 187 fResourceProvider = new GrResourceProvider(fGpu, fResourceCache);
188 188
189 fLayerCache.reset(SkNEW_ARGS(GrLayerCache, (this))); 189 fLayerCache.reset(new GrLayerCache(this));
190 190
191 fDidTestPMConversions = false; 191 fDidTestPMConversions = false;
192 192
193 fDrawingMgr.init(this); 193 fDrawingMgr.init(this);
194 194
195 // GrBatchFontCache will eventually replace GrFontCache 195 // GrBatchFontCache will eventually replace GrFontCache
196 fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this)); 196 fBatchFontCache = new GrBatchFontCache(this);
197 197
198 fTextBlobCache.reset(SkNEW_ARGS(GrTextBlobCache, (TextBlobCacheOverBudgetCB, this))); 198 fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this));
199 } 199 }
200 200
201 GrContext::~GrContext() { 201 GrContext::~GrContext() {
202 if (!fGpu) { 202 if (!fGpu) {
203 SkASSERT(!fCaps); 203 SkASSERT(!fCaps);
204 return; 204 return;
205 } 205 }
206 206
207 this->flush(); 207 this->flush();
208 208
209 fDrawingMgr.cleanup(); 209 fDrawingMgr.cleanup();
210 210
211 for (int i = 0; i < fCleanUpData.count(); ++i) { 211 for (int i = 0; i < fCleanUpData.count(); ++i) {
212 (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo); 212 (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo);
213 } 213 }
214 214
215 SkDELETE(fResourceProvider); 215 delete fResourceProvider;
216 SkDELETE(fResourceCache); 216 delete fResourceCache;
217 SkDELETE(fBatchFontCache); 217 delete fBatchFontCache;
218 218
219 fGpu->unref(); 219 fGpu->unref();
220 fCaps->unref(); 220 fCaps->unref();
221 SkSafeUnref(fPathRendererChain); 221 SkSafeUnref(fPathRendererChain);
222 SkSafeUnref(fSoftwarePathRenderer); 222 SkSafeUnref(fSoftwarePathRenderer);
223 } 223 }
224 224
225 void GrContext::abandonContext() { 225 void GrContext::abandonContext() {
226 fResourceProvider->abandon(); 226 fResourceProvider->abandon();
227 // abandon first to so destructors 227 // abandon first to so destructors
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target, 638 GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target,
639 const GrPipelineBuilder* pipelineBuil der, 639 const GrPipelineBuilder* pipelineBuil der,
640 const SkMatrix& viewMatrix, 640 const SkMatrix& viewMatrix,
641 const SkPath& path, 641 const SkPath& path,
642 const GrStrokeInfo& stroke, 642 const GrStrokeInfo& stroke,
643 bool allowSW, 643 bool allowSW,
644 GrPathRendererChain::DrawType drawTyp e, 644 GrPathRendererChain::DrawType drawTyp e,
645 GrPathRendererChain::StencilSupport* stencilSupport) { 645 GrPathRendererChain::StencilSupport* stencilSupport) {
646 646
647 if (!fPathRendererChain) { 647 if (!fPathRendererChain) {
648 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this)); 648 fPathRendererChain = new GrPathRendererChain(this);
649 } 649 }
650 650
651 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target, 651 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target,
652 pipelineBuilder, 652 pipelineBuilder,
653 viewMatrix, 653 viewMatrix,
654 path, 654 path,
655 stroke, 655 stroke,
656 drawType, 656 drawType,
657 stencilSupport); 657 stencilSupport);
658 658
659 if (!pr && allowSW) { 659 if (!pr && allowSW) {
660 if (!fSoftwarePathRenderer) { 660 if (!fSoftwarePathRenderer) {
661 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this)); 661 fSoftwarePathRenderer = new GrSoftwarePathRenderer(this);
662 } 662 }
663 pr = fSoftwarePathRenderer; 663 pr = fSoftwarePathRenderer;
664 } 664 }
665 665
666 return pr; 666 return pr;
667 } 667 }
668 668
669 //////////////////////////////////////////////////////////////////////////////// 669 ////////////////////////////////////////////////////////////////////////////////
670 int GrContext::getRecommendedSampleCount(GrPixelConfig config, 670 int GrContext::getRecommendedSampleCount(GrPixelConfig config,
671 SkScalar dpi) const { 671 SkScalar dpi) const {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 ////////////////////////////////////////////////////////////////////////////// 754 //////////////////////////////////////////////////////////////////////////////
755 755
756 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { 756 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
757 fGpu->addGpuTraceMarker(marker); 757 fGpu->addGpuTraceMarker(marker);
758 } 758 }
759 759
760 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { 760 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
761 fGpu->removeGpuTraceMarker(marker); 761 fGpu->removeGpuTraceMarker(marker);
762 } 762 }
763 763
OLDNEW
« no previous file with comments | « src/gpu/GrCommandBuilder.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698