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

Side by Side Diff: src/gpu/GrInOrderDrawBuffer.h

Issue 858343002: Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits Created 5 years, 11 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/GrGpu.h ('k') | src/gpu/GrInOrderDrawBuffer.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 * 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 #ifndef GrInOrderDrawBuffer_DEFINED 8 #ifndef GrInOrderDrawBuffer_DEFINED
9 #define GrInOrderDrawBuffer_DEFINED 9 #define GrInOrderDrawBuffer_DEFINED
10 10
11 #include "GrFlushToGpuDrawTarget.h" 11 #include "GrFlushToGpuDrawTarget.h"
12 #include "GrOptDrawState.h" 12 #include "GrPipeline.h"
13 #include "GrPath.h" 13 #include "GrPath.h"
14 #include "GrTRecorder.h" 14 #include "GrTRecorder.h"
15 15
16 /** 16 /**
17 * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws for eventual 17 * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws for eventual
18 * playback into a GrGpu. In theory one draw buffer could playback into another. When index or 18 * playback into a GrGpu. In theory one draw buffer could playback into another. When index or
19 * vertex buffers are used as geometry sources it is the callers the draw buffer only holds 19 * vertex buffers are used as geometry sources it is the callers the draw buffer only holds
20 * references to the buffers. It is the callers responsibility to ensure that th e data is still 20 * references to the buffers. It is the callers responsibility to ensure that th e data is still
21 * valid when the draw buffer is played back into a GrGpu. Similarly, it is the caller's 21 * valid when the draw buffer is played back into a GrGpu. Similarly, it is the caller's
22 * responsibility to ensure that all referenced textures, buffers, and render-ta rgets are associated 22 * responsibility to ensure that all referenced textures, buffers, and render-ta rgets are associated
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; 171 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
172 172
173 SkIPoint fDstPoint; 173 SkIPoint fDstPoint;
174 SkIRect fSrcRect; 174 SkIRect fSrcRect;
175 175
176 private: 176 private:
177 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; 177 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst;
178 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; 178 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
179 }; 179 };
180 180
181 // TODO: rename to SetPipeline once pp, batch tracker, and desc are removed
181 struct SetState : public Cmd { 182 struct SetState : public Cmd {
182 SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primP roc, 183 SetState(const GrPipelineBuilder& pipelineBuilder, const GrPrimitiveProc essor* primProc,
183 const GrDrawTargetCaps& caps, 184 const GrDrawTargetCaps& caps,
184 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC opy) 185 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC opy)
185 : Cmd(kSetState_Cmd) 186 : Cmd(kSetState_Cmd)
186 , fPrimitiveProcessor(primProc) 187 , fPrimitiveProcessor(primProc)
187 , fState(drawState, primProc, caps, scissor, dstCopy) {} 188 , fPipeline(pipelineBuilder, primProc, caps, scissor, dstCopy) {}
188 189
189 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; 190 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
190 191
191 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor; 192 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor;
192 ProgramPrimitiveProcessor fPrimitiveProcessor; 193 ProgramPrimitiveProcessor fPrimitiveProcessor;
193 const GrOptDrawState fState; 194 const GrPipeline fPipeline;
194 GrProgramDesc fDesc; 195 GrProgramDesc fDesc;
195 GrBatchTracker fBatchTracker; 196 GrBatchTracker fBatchTracker;
196 }; 197 };
197 198
198 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. 199 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
199 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; 200 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
200 201
201 void onReset() SK_OVERRIDE; 202 void onReset() SK_OVERRIDE;
202 void onFlush() SK_OVERRIDE; 203 void onFlush() SK_OVERRIDE;
203 204
204 // overrides from GrDrawTarget 205 // overrides from GrDrawTarget
205 void onDraw(const GrDrawState&, 206 void onDraw(const GrPipelineBuilder&,
206 const GrGeometryProcessor*, 207 const GrGeometryProcessor*,
207 const DrawInfo&, 208 const DrawInfo&,
208 const GrScissorState&, 209 const GrScissorState&,
209 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; 210 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
210 void onDrawRect(GrDrawState*, 211 void onDrawRect(GrPipelineBuilder*,
211 GrColor, 212 GrColor,
212 const SkMatrix& viewMatrix, 213 const SkMatrix& viewMatrix,
213 const SkRect& rect, 214 const SkRect& rect,
214 const SkRect* localRect, 215 const SkRect* localRect,
215 const SkMatrix* localMatrix) SK_OVERRIDE; 216 const SkMatrix* localMatrix) SK_OVERRIDE;
216 217
217 void onStencilPath(const GrDrawState&, 218 void onStencilPath(const GrPipelineBuilder&,
218 const GrPathProcessor*, 219 const GrPathProcessor*,
219 const GrPath*, 220 const GrPath*,
220 const GrScissorState&, 221 const GrScissorState&,
221 const GrStencilSettings&) SK_OVERRIDE; 222 const GrStencilSettings&) SK_OVERRIDE;
222 void onDrawPath(const GrDrawState&, 223 void onDrawPath(const GrPipelineBuilder&,
223 const GrPathProcessor*, 224 const GrPathProcessor*,
224 const GrPath*, 225 const GrPath*,
225 const GrScissorState&, 226 const GrScissorState&,
226 const GrStencilSettings&, 227 const GrStencilSettings&,
227 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; 228 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
228 void onDrawPaths(const GrDrawState&, 229 void onDrawPaths(const GrPipelineBuilder&,
229 const GrPathProcessor*, 230 const GrPathProcessor*,
230 const GrPathRange*, 231 const GrPathRange*,
231 const void* indices, 232 const void* indices,
232 PathIndexType, 233 PathIndexType,
233 const float transformValues[], 234 const float transformValues[],
234 PathTransformType, 235 PathTransformType,
235 int count, 236 int count,
236 const GrScissorState&, 237 const GrScissorState&,
237 const GrStencilSettings&, 238 const GrStencilSettings&,
238 const GrDeviceCoordTexture*) SK_OVERRIDE; 239 const GrDeviceCoordTexture*) SK_OVERRIDE;
239 void onClear(const SkIRect* rect, 240 void onClear(const SkIRect* rect,
240 GrColor color, 241 GrColor color,
241 bool canIgnoreRect, 242 bool canIgnoreRect,
242 GrRenderTarget* renderTarget) SK_OVERRIDE; 243 GrRenderTarget* renderTarget) SK_OVERRIDE;
243 bool onCopySurface(GrSurface* dst, 244 bool onCopySurface(GrSurface* dst,
244 GrSurface* src, 245 GrSurface* src,
245 const SkIRect& srcRect, 246 const SkIRect& srcRect,
246 const SkIPoint& dstPoint) SK_OVERRIDE; 247 const SkIPoint& dstPoint) SK_OVERRIDE;
247 248
248 // Attempts to concat instances from info onto the previous draw. info must represent an 249 // Attempts to concat instances from info onto the previous draw. info must represent an
249 // instanced draw. The caller must have already recorded a new draw state an d clip if necessary. 250 // instanced draw. The caller must have already recorded a new draw state an d clip if necessary.
250 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); 251 int concatInstancedDraw(const GrPipelineBuilder&, const DrawInfo&);
251 252
252 // Determines whether the current draw operation requires a new GrOptDrawSta te and if so 253 // Determines whether the current draw operation requires a new GrPipeline a nd if so
253 // records it. If the draw can be skipped false is returned and no new GrOpt DrawState is 254 // records it. If the draw can be skipped false is returned and no new GrPip eline is
254 // recorded. 255 // recorded.
255 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, 256 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrPipelineBuilder& ,
256 const GrPrimitiveProcess or*, 257 const GrPrimitiveProcess or*,
257 const GrScissorState&, 258 const GrScissorState&,
258 const GrDeviceCoordTextu re*); 259 const GrDeviceCoordTextu re*);
259 // We lazily record clip changes in order to skip clips that have no effect. 260 // We lazily record clip changes in order to skip clips that have no effect.
260 void recordClipIfNecessary(); 261 void recordClipIfNecessary();
261 // Records any trace markers for a command after adding it to the buffer. 262 // Records any trace markers for a command after adding it to the buffer.
262 void recordTraceMarkersIfNecessary(); 263 void recordTraceMarkersIfNecessary();
263 264
264 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } 265 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; }
265 266
266 // TODO: Use a single allocator for commands and records 267 // TODO: Use a single allocator for commands and records
267 enum { 268 enum {
268 kCmdBufferInitialSizeInBytes = 8 * 1024, 269 kCmdBufferInitialSizeInBytes = 8 * 1024,
269 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's 270 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's
270 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms 271 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms
271 }; 272 };
272 273
273 CmdBuffer fCmdBuffer; 274 CmdBuffer fCmdBuffer;
274 SetState* fPrevState; 275 SetState* fPrevState;
275 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; 276 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers;
276 SkTDArray<char> fPathIndexBuffer; 277 SkTDArray<char> fPathIndexBuffer;
277 SkTDArray<float> fPathTransformBuffer; 278 SkTDArray<float> fPathTransformBuffer;
278 uint32_t fDrawID; 279 uint32_t fDrawID;
279 280
280 typedef GrFlushToGpuDrawTarget INHERITED; 281 typedef GrFlushToGpuDrawTarget INHERITED;
281 }; 282 };
282 283
283 #endif 284 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698