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

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

Issue 1284983002: Remove trace marker support from GrBufferedDrawTarget (Closed) Base URL: https://skia.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/gpu/GrBufferedDrawTarget.h ('k') | src/gpu/GrTargetCommands.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 2011 Google Inc. 2 * Copyright 2011 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 "GrBufferedDrawTarget.h" 8 #include "GrBufferedDrawTarget.h"
9 9
10 // We will use the reordering buffer, unless we have NVPR. 10 // We will use the reordering buffer, unless we have NVPR.
11 // TODO move NVPR to batch so we can reorder 11 // TODO move NVPR to batch so we can reorder
12 static inline bool allow_reordering(const GrCaps* caps) { 12 static inline bool allow_reordering(const GrCaps* caps) {
13 return caps && caps->shaderCaps() && !caps->shaderCaps()->pathRenderingSuppo rt(); 13 return caps && caps->shaderCaps() && !caps->shaderCaps()->pathRenderingSuppo rt();
14 } 14 }
15 15
16 GrBufferedDrawTarget::GrBufferedDrawTarget(GrContext* context) 16 GrBufferedDrawTarget::GrBufferedDrawTarget(GrContext* context)
17 : INHERITED(context) 17 : INHERITED(context)
18 , fCommands(GrCommandBuilder::Create(context->getGpu(), allow_reordering(con text->caps()))) 18 , fCommands(GrCommandBuilder::Create(context->getGpu(), allow_reordering(con text->caps())))
19 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) 19 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4)
20 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) 20 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4)
21 , fPipelineBuffer(kPipelineBufferMinReserve) 21 , fPipelineBuffer(kPipelineBufferMinReserve)
22 , fDrawID(0) { 22 , fDrawID(0) {
23 } 23 }
24 24
25 GrBufferedDrawTarget::~GrBufferedDrawTarget() { 25 GrBufferedDrawTarget::~GrBufferedDrawTarget() {
26 this->reset(); 26 this->reset();
27 } 27 }
28 28
29 void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) { 29 void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) {
30 this->recordTraceMarkersIfNecessary( 30 fCommands->recordXferBarrierIfNecessary(*batch->pipeline(), *this->caps());
31 fCommands->recordXferBarrierIfNecessary(*batch->pipeline(), *this->caps( ))); 31 fCommands->recordDrawBatch(batch);
32
33 GrTargetCommands::Cmd* cmd = fCommands->recordDrawBatch(batch);
34 this->recordTraceMarkersIfNecessary(cmd);
35 } 32 }
36 33
37 void GrBufferedDrawTarget::onStencilPath(const GrPipelineBuilder& pipelineBuilde r, 34 void GrBufferedDrawTarget::onStencilPath(const GrPipelineBuilder& pipelineBuilde r,
38 const GrPathProcessor* pathProc, 35 const GrPathProcessor* pathProc,
39 const GrPath* path, 36 const GrPath* path,
40 const GrScissorState& scissorState, 37 const GrScissorState& scissorState,
41 const GrStencilSettings& stencilSetting s) { 38 const GrStencilSettings& stencilSetting s) {
42 GrTargetCommands::Cmd* cmd = fCommands->recordStencilPath(pipelineBuilder, 39 fCommands->recordStencilPath(pipelineBuilder, pathProc, path, scissorState, stencilSettings);
43 pathProc, path, sc issorState,
44 stencilSettings);
45 this->recordTraceMarkersIfNecessary(cmd);
46 } 40 }
47 41
48 void GrBufferedDrawTarget::onDrawPath(const GrPathProcessor* pathProc, 42 void GrBufferedDrawTarget::onDrawPath(const GrPathProcessor* pathProc,
49 const GrPath* path, 43 const GrPath* path,
50 const GrStencilSettings& stencilSettings, 44 const GrStencilSettings& stencilSettings,
51 const PipelineInfo& pipelineInfo) { 45 const PipelineInfo& pipelineInfo) {
52 GrPipelineOptimizations opts; 46 GrPipelineOptimizations opts;
53 StateForPathDraw* state = this->createStateForPathDraw(pathProc, pipelineInf o, &opts); 47 StateForPathDraw* state = this->createStateForPathDraw(pathProc, pipelineInf o, &opts);
54 if (!state) { 48 if (!state) {
55 return; 49 return;
56 } 50 }
57 GrTargetCommands::Cmd* cmd = fCommands->recordDrawPath(state, pathProc, path , stencilSettings); 51 fCommands->recordDrawPath(state, pathProc, path, stencilSettings);
58 this->recordTraceMarkersIfNecessary(cmd);
59 } 52 }
60 53
61 void GrBufferedDrawTarget::onDrawPaths(const GrPathProcessor* pathProc, 54 void GrBufferedDrawTarget::onDrawPaths(const GrPathProcessor* pathProc,
62 const GrPathRange* pathRange, 55 const GrPathRange* pathRange,
63 const void* indices, 56 const void* indices,
64 PathIndexType indexType, 57 PathIndexType indexType,
65 const float transformValues[], 58 const float transformValues[],
66 PathTransformType transformType, 59 PathTransformType transformType,
67 int count, 60 int count,
68 const GrStencilSettings& stencilSettings, 61 const GrStencilSettings& stencilSettings,
69 const PipelineInfo& pipelineInfo) { 62 const PipelineInfo& pipelineInfo) {
70 GrPipelineOptimizations opts; 63 GrPipelineOptimizations opts;
71 StateForPathDraw* state = this->createStateForPathDraw(pathProc, pipelineInf o, &opts); 64 StateForPathDraw* state = this->createStateForPathDraw(pathProc, pipelineInf o, &opts);
72 if (!state) { 65 if (!state) {
73 return; 66 return;
74 } 67 }
75 GrTargetCommands::Cmd* cmd = fCommands->recordDrawPaths(state, this, pathPro c, pathRange, 68 fCommands->recordDrawPaths(state, this, pathProc, pathRange, indices, indexT ype,
76 indices, indexType, transformValues, 69 transformValues, transformType, count, stencilSet tings,
77 transformType, count , 70 pipelineInfo);
78 stencilSettings, pip elineInfo);
79 this->recordTraceMarkersIfNecessary(cmd);
80 } 71 }
81 72
82 void GrBufferedDrawTarget::onClear(const SkIRect& rect, GrColor color, 73 void GrBufferedDrawTarget::onClear(const SkIRect& rect, GrColor color,
83 GrRenderTarget* renderTarget) { 74 GrRenderTarget* renderTarget) {
84 GrTargetCommands::Cmd* cmd = fCommands->recordClear(rect, color, renderTarge t); 75 fCommands->recordClear(rect, color, renderTarget);
85 this->recordTraceMarkersIfNecessary(cmd);
86 } 76 }
87 77
88 void GrBufferedDrawTarget::clearStencilClip(const SkIRect& rect, 78 void GrBufferedDrawTarget::clearStencilClip(const SkIRect& rect,
89 bool insideClip, 79 bool insideClip,
90 GrRenderTarget* renderTarget) { 80 GrRenderTarget* renderTarget) {
91 GrTargetCommands::Cmd* cmd = fCommands->recordClearStencilClip(rect, insideC lip, renderTarget); 81 fCommands->recordClearStencilClip(rect, insideClip, renderTarget);
92 this->recordTraceMarkersIfNecessary(cmd);
93 } 82 }
94 83
95 void GrBufferedDrawTarget::discard(GrRenderTarget* renderTarget) { 84 void GrBufferedDrawTarget::discard(GrRenderTarget* renderTarget) {
96 if (!this->caps()->discardRenderTargetSupport()) { 85 if (!this->caps()->discardRenderTargetSupport()) {
97 return; 86 return;
98 } 87 }
99 88 fCommands->recordDiscard(renderTarget);
100 GrTargetCommands::Cmd* cmd = fCommands->recordDiscard(renderTarget);
101 this->recordTraceMarkersIfNecessary(cmd);
102 } 89 }
103 90
104 void GrBufferedDrawTarget::onReset() { 91 void GrBufferedDrawTarget::onReset() {
105 fCommands->reset(); 92 fCommands->reset();
106 fPathIndexBuffer.rewind(); 93 fPathIndexBuffer.rewind();
107 fPathTransformBuffer.rewind(); 94 fPathTransformBuffer.rewind();
108 fGpuCmdMarkers.reset();
109 95
110 fPrevState.reset(NULL); 96 fPrevState.reset(NULL);
111 // Note, fPrevState points into fPipelineBuffer's allocation, so we have to reset first. 97 // Note, fPrevState points into fPipelineBuffer's allocation, so we have to reset first.
112 // Furthermore, we have to reset fCommands before fPipelineBuffer too. 98 // Furthermore, we have to reset fCommands before fPipelineBuffer too.
113 if (fDrawID % kPipelineBufferHighWaterMark) { 99 if (fDrawID % kPipelineBufferHighWaterMark) {
114 fPipelineBuffer.rewind(); 100 fPipelineBuffer.rewind();
115 } else { 101 } else {
116 fPipelineBuffer.reset(); 102 fPipelineBuffer.reset();
117 } 103 }
118 } 104 }
119 105
120 void GrBufferedDrawTarget::onFlush() { 106 void GrBufferedDrawTarget::onFlush() {
121 fCommands->flush(this); 107 fCommands->flush(this);
122 ++fDrawID; 108 ++fDrawID;
123 } 109 }
124 110
125 void GrBufferedDrawTarget::onCopySurface(GrSurface* dst, 111 void GrBufferedDrawTarget::onCopySurface(GrSurface* dst,
126 GrSurface* src, 112 GrSurface* src,
127 const SkIRect& srcRect, 113 const SkIRect& srcRect,
128 const SkIPoint& dstPoint) { 114 const SkIPoint& dstPoint) {
129 GrTargetCommands::Cmd* cmd = fCommands->recordCopySurface(dst, src, srcRect, dstPoint); 115 fCommands->recordCopySurface(dst, src, srcRect, dstPoint);
130 this->recordTraceMarkersIfNecessary(cmd);
131 }
132
133 void GrBufferedDrawTarget::recordTraceMarkersIfNecessary(GrTargetCommands::Cmd* cmd) {
134 if (!cmd) {
135 return;
136 }
137 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
138 if (activeTraceMarkers.count() > 0) {
139 if (cmd->isTraced()) {
140 fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers);
141 } else {
142 cmd->setMarkerID(fGpuCmdMarkers.count());
143 fGpuCmdMarkers.push_back(activeTraceMarkers);
144 }
145 }
146 } 116 }
147 117
148 GrTargetCommands::StateForPathDraw* 118 GrTargetCommands::StateForPathDraw*
149 GrBufferedDrawTarget::createStateForPathDraw(const GrPrimitiveProcessor* primPro c, 119 GrBufferedDrawTarget::createStateForPathDraw(const GrPrimitiveProcessor* primPro c,
150 const GrDrawTarget::PipelineInfo& p ipelineInfo, 120 const GrDrawTarget::PipelineInfo& p ipelineInfo,
151 GrPipelineOptimizations* opts) { 121 GrPipelineOptimizations* opts) {
152 StateForPathDraw* state = this->allocState(primProc); 122 StateForPathDraw* state = this->allocState(primProc);
153 if (!GrPipeline::CreateAt(state->pipelineLocation(), pipelineInfo.pipelineCr eateArgs(), opts)) { 123 if (!GrPipeline::CreateAt(state->pipelineLocation(), pipelineInfo.pipelineCr eateArgs(), opts)) {
154 this->unallocState(state); 124 this->unallocState(state);
155 return NULL; 125 return NULL;
156 } 126 }
157 127
158 state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker, *opts); 128 state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker, *opts);
159 129
160 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && 130 if (fPrevState && fPrevState->fPrimitiveProcessor.get() &&
161 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, 131 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
162 *state->fPrimitiveProcesso r, 132 *state->fPrimitiveProcesso r,
163 state->fBatchTracker) && 133 state->fBatchTracker) &&
164 fPrevState->getPipeline()->isEqual(*state->getPipeline())) { 134 fPrevState->getPipeline()->isEqual(*state->getPipeline())) {
165 this->unallocState(state); 135 this->unallocState(state);
166 } else { 136 } else {
167 fPrevState.reset(state); 137 fPrevState.reset(state);
168 } 138 }
169 139
170 this->recordTraceMarkersIfNecessary( 140 fCommands->recordXferBarrierIfNecessary(*fPrevState->getPipeline(), *this->c aps());
171 fCommands->recordXferBarrierIfNecessary(*fPrevState->getPipeline(), *this->caps()));
172 return fPrevState; 141 return fPrevState;
173 } 142 }
OLDNEW
« no previous file with comments | « src/gpu/GrBufferedDrawTarget.h ('k') | src/gpu/GrTargetCommands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698