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

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

Issue 1302663003: Sample for GPU memory dumping using new SkTraceMemoryDump. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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/core/SkTraceMemoryDump.h ('k') | src/gpu/GrGpuResource.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 27 matching lines...) Expand all
38 #include "GrVertices.h" 38 #include "GrVertices.h"
39 #include "SkDashPathPriv.h" 39 #include "SkDashPathPriv.h"
40 #include "SkConfig8888.h" 40 #include "SkConfig8888.h"
41 #include "SkGr.h" 41 #include "SkGr.h"
42 #include "SkRRect.h" 42 #include "SkRRect.h"
43 #include "SkStrokeRec.h" 43 #include "SkStrokeRec.h"
44 #include "SkSurfacePriv.h" 44 #include "SkSurfacePriv.h"
45 #include "SkTLazy.h" 45 #include "SkTLazy.h"
46 #include "SkTLS.h" 46 #include "SkTLS.h"
47 #include "SkTraceEvent.h" 47 #include "SkTraceEvent.h"
48 #include "SkTraceMemoryDump.h"
48 49
49 #include "batches/GrBatch.h" 50 #include "batches/GrBatch.h"
50 51
51 #include "effects/GrConfigConversionEffect.h" 52 #include "effects/GrConfigConversionEffect.h"
52 #include "effects/GrDashingEffect.h" 53 #include "effects/GrDashingEffect.h"
53 #include "effects/GrSingleTextureEffect.h" 54 #include "effects/GrSingleTextureEffect.h"
54 55
55 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) 56 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
56 #define RETURN_IF_ABANDONED if (fDrawingMgr.abandoned()) { return; } 57 #define RETURN_IF_ABANDONED if (fDrawingMgr.abandoned()) { return; }
57 #define RETURN_FALSE_IF_ABANDONED if (fDrawingMgr.abandoned()) { return false; } 58 #define RETURN_FALSE_IF_ABANDONED if (fDrawingMgr.abandoned()) { return false; }
58 #define RETURN_NULL_IF_ABANDONED if (fDrawingMgr.abandoned()) { return NULL; } 59 #define RETURN_NULL_IF_ABANDONED if (fDrawingMgr.abandoned()) { return NULL; }
59 60
60 61
61 //////////////////////////////////////////////////////////////////////////////// 62 ////////////////////////////////////////////////////////////////////////////////
62 63
63 void GrContext::DrawingMgr::init(GrContext* context) { 64 void GrContext::DrawingMgr::init(GrContext* context) {
64 fContext = context; 65 fContext = context;
65 66
66 #ifdef IMMEDIATE_MODE 67 #ifdef IMMEDIATE_MODE
67 fDrawTarget = SkNEW_ARGS(GrImmediateDrawTarget, (context)); 68 fDrawTarget = SkNEW_ARGS(GrImmediateDrawTarget, (context));
68 #else 69 #else
69 fDrawTarget = SkNEW_ARGS(GrBufferedDrawTarget, (context)); 70 fDrawTarget = SkNEW_ARGS(GrBufferedDrawTarget, (context));
70 #endif 71 #endif
71 } 72 }
72 73
73 void GrContext::DrawingMgr::cleanup() { 74 void GrContext::DrawingMgr::cleanup() {
74 SkSafeSetNull(fDrawTarget); 75 SkSafeSetNull(fDrawTarget);
75 for (int i = 0; i < kNumPixelGeometries; ++i) { 76 for (int i = 0; i < kNumPixelGeometries; ++i) {
76 SkSafeSetNull(fDrawContext[i][0]); 77 SkSafeSetNull(fDrawContext[i][0]);
77 SkSafeSetNull(fDrawContext[i][1]); 78 SkSafeSetNull(fDrawContext[i][1]);
78 } 79 }
79 } 80 }
80 81
(...skipping 24 matching lines...) Expand all
105 fDrawTarget->reset(); 106 fDrawTarget->reset();
106 } 107 }
107 } 108 }
108 109
109 void GrContext::DrawingMgr::flush() { 110 void GrContext::DrawingMgr::flush() {
110 if (fDrawTarget) { 111 if (fDrawTarget) {
111 fDrawTarget->flush(); 112 fDrawTarget->flush();
112 } 113 }
113 } 114 }
114 115
115 GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceP rops) { 116 GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceP rops) {
116 if (this->abandoned()) { 117 if (this->abandoned()) {
117 return NULL; 118 return NULL;
118 } 119 }
119 120
120 const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps)); 121 const SkSurfaceProps props(SkSurfacePropsCopyOrDefault(surfaceProps));
121 122
122 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); 123 SkASSERT(props.pixelGeometry() < kNumPixelGeometries);
123 if (!fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()]) { 124 if (!fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()]) {
124 fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()] = 125 fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()] =
125 SkNEW_ARGS(GrDrawContext, (fContext, fDrawTarget, props)); 126 SkNEW_ARGS(GrDrawContext, (fContext, fDrawTarget, props));
126 } 127 }
127 128
128 return fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()]; 129 return fDrawContext[props.pixelGeometry()][props.isUseDistanceFieldFonts()];
129 } 130 }
130 131
131 //////////////////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////////////////
132 133
133 134
134 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) { 135 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
135 GrContextOptions defaultOptions; 136 GrContextOptions defaultOptions;
136 return Create(backend, backendContext, defaultOptions); 137 return Create(backend, backendContext, defaultOptions);
137 } 138 }
138 139
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 ////////////////////////////////////////////////////////////////////////////// 755 //////////////////////////////////////////////////////////////////////////////
755 756
756 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { 757 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
757 fGpu->addGpuTraceMarker(marker); 758 fGpu->addGpuTraceMarker(marker);
758 } 759 }
759 760
760 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { 761 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
761 fGpu->removeGpuTraceMarker(marker); 762 fGpu->removeGpuTraceMarker(marker);
762 } 763 }
763 764
765 //////////////////////////////////////////////////////////////////////////////
766 void GrContext::onMemoryDump(SkTraceMemoryDump *traceMemoryDump) const {
767 fResourceCache->onMemoryDump(traceMemoryDump);
768 }
OLDNEW
« no previous file with comments | « src/core/SkTraceMemoryDump.h ('k') | src/gpu/GrGpuResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698