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/GrInOrderDrawBuffer.h

Issue 816513003: Stop creating GrODS for stencilPath commands. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years 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
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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // tracking for draws 44 // tracking for draws
45 DrawToken getCurrentDrawToken() SK_OVERRIDE { return DrawToken(this, fDrawID ); } 45 DrawToken getCurrentDrawToken() SK_OVERRIDE { return DrawToken(this, fDrawID ); }
46 46
47 void clearStencilClip(const SkIRect& rect, 47 void clearStencilClip(const SkIRect& rect,
48 bool insideClip, 48 bool insideClip,
49 GrRenderTarget* renderTarget) SK_OVERRIDE; 49 GrRenderTarget* renderTarget) SK_OVERRIDE;
50 50
51 void discard(GrRenderTarget*) SK_OVERRIDE; 51 void discard(GrRenderTarget*) SK_OVERRIDE;
52 52
53 private: 53 private:
54 typedef GrClipMaskManager::ScissorState ScissorState;
55 enum { 54 enum {
56 kDraw_Cmd = 1, 55 kDraw_Cmd = 1,
57 kStencilPath_Cmd = 2, 56 kStencilPath_Cmd = 2,
58 kSetState_Cmd = 3, 57 kSetState_Cmd = 3,
59 kClear_Cmd = 4, 58 kClear_Cmd = 4,
60 kCopySurface_Cmd = 5, 59 kCopySurface_Cmd = 5,
61 kDrawPath_Cmd = 6, 60 kDrawPath_Cmd = 6,
62 kDrawPaths_Cmd = 7, 61 kDrawPaths_Cmd = 7,
63 }; 62 };
64 63
65 struct Cmd : ::SkNoncopyable { 64 struct Cmd : ::SkNoncopyable {
66 Cmd(uint8_t type) : fType(type) {} 65 Cmd(uint8_t type) : fType(type) {}
67 virtual ~Cmd() {} 66 virtual ~Cmd() {}
68 67
69 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) = 0; 68 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) = 0;
70 69
71 uint8_t fType; 70 uint8_t fType;
72 }; 71 };
73 72
74 struct Draw : public Cmd { 73 struct Draw : public Cmd {
75 Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} 74 Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {}
76 75
77 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; 76 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE;
78 77
79 DrawInfo fInfo; 78 DrawInfo fInfo;
80 }; 79 };
81 80
82 struct StencilPath : public Cmd { 81 struct StencilPath : public Cmd {
83 StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {} 82 StencilPath(const GrPath* path, GrRenderTarget* rt)
83 : Cmd(kStencilPath_Cmd)
84 , fRenderTarget(rt)
85 , fPath(path) {}
84 86
85 const GrPath* path() const { return fPath.get(); } 87 const GrPath* path() const { return fPath.get(); }
86 88
87 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; 89 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE;
88 90
89 GrStencilSettings fStencilSettings; 91 SkMatrix fViewMatrix;
90 92 bool fUseHWAA;
93 GrStencilSettings fStencil;
94 GrScissorState fScissor;
91 private: 95 private:
92 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; 96 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
97 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
93 }; 98 };
94 99
95 struct DrawPath : public Cmd { 100 struct DrawPath : public Cmd {
96 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} 101 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {}
97 102
98 const GrPath* path() const { return fPath.get(); } 103 const GrPath* path() const { return fPath.get(); }
99 104
100 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; 105 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE;
101 106
102 GrStencilSettings fStencilSettings; 107 GrStencilSettings fStencilSettings;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 SkIRect fSrcRect; 171 SkIRect fSrcRect;
167 172
168 private: 173 private:
169 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; 174 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst;
170 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; 175 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
171 }; 176 };
172 177
173 struct SetState : public Cmd { 178 struct SetState : public Cmd {
174 SetState(const GrDrawState& drawState, const GrGeometryProcessor* gp, 179 SetState(const GrDrawState& drawState, const GrGeometryProcessor* gp,
175 const GrPathProcessor* pp, const GrDrawTargetCaps& caps, 180 const GrPathProcessor* pp, const GrDrawTargetCaps& caps,
176 const ScissorState& scissor, const GrDeviceCoordTexture* dstCop y, 181 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC opy,
177 GrGpu::DrawType drawType) 182 GrGpu::DrawType drawType)
178 : Cmd(kSetState_Cmd) 183 : Cmd(kSetState_Cmd)
179 , fState(drawState, gp, pp, caps, scissor, dstCopy, drawType) {} 184 , fState(drawState, gp, pp, caps, scissor, dstCopy, drawType) {}
180 185
181 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; 186 void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE;
182 187
183 GrOptDrawState fState; 188 GrOptDrawState fState;
184 }; 189 };
185 190
186 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. 191 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
187 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; 192 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
188 193
189 void onReset() SK_OVERRIDE; 194 void onReset() SK_OVERRIDE;
190 void onFlush() SK_OVERRIDE; 195 void onFlush() SK_OVERRIDE;
191 196
192 // overrides from GrDrawTarget 197 // overrides from GrDrawTarget
193 void onDraw(const GrDrawState&, 198 void onDraw(const GrDrawState&,
194 const GrGeometryProcessor*, 199 const GrGeometryProcessor*,
195 const DrawInfo&, 200 const DrawInfo&,
196 const ScissorState&, 201 const GrScissorState&,
197 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; 202 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
198 void onDrawRect(GrDrawState*, 203 void onDrawRect(GrDrawState*,
199 GrColor, 204 GrColor,
200 const SkRect& rect, 205 const SkRect& rect,
201 const SkRect* localRect, 206 const SkRect* localRect,
202 const SkMatrix* localMatrix) SK_OVERRIDE; 207 const SkMatrix* localMatrix) SK_OVERRIDE;
203 208
204 void onStencilPath(const GrDrawState&, 209 void onStencilPath(const GrDrawState&,
205 const GrPathProcessor*, 210 const GrPathProcessor*,
206 const GrPath*, 211 const GrPath*,
207 const ScissorState&, 212 const GrScissorState&,
208 const GrStencilSettings&) SK_OVERRIDE; 213 const GrStencilSettings&) SK_OVERRIDE;
209 void onDrawPath(const GrDrawState&, 214 void onDrawPath(const GrDrawState&,
210 const GrPathProcessor*, 215 const GrPathProcessor*,
211 const GrPath*, 216 const GrPath*,
212 const ScissorState&, 217 const GrScissorState&,
213 const GrStencilSettings&, 218 const GrStencilSettings&,
214 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; 219 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
215 void onDrawPaths(const GrDrawState&, 220 void onDrawPaths(const GrDrawState&,
216 const GrPathProcessor*, 221 const GrPathProcessor*,
217 const GrPathRange*, 222 const GrPathRange*,
218 const void* indices, 223 const void* indices,
219 PathIndexType, 224 PathIndexType,
220 const float transformValues[], 225 const float transformValues[],
221 PathTransformType, 226 PathTransformType,
222 int count, 227 int count,
223 const ScissorState&, 228 const GrScissorState&,
224 const GrStencilSettings&, 229 const GrStencilSettings&,
225 const GrDeviceCoordTexture*) SK_OVERRIDE; 230 const GrDeviceCoordTexture*) SK_OVERRIDE;
226 void onClear(const SkIRect* rect, 231 void onClear(const SkIRect* rect,
227 GrColor color, 232 GrColor color,
228 bool canIgnoreRect, 233 bool canIgnoreRect,
229 GrRenderTarget* renderTarget) SK_OVERRIDE; 234 GrRenderTarget* renderTarget) SK_OVERRIDE;
230 bool onCopySurface(GrSurface* dst, 235 bool onCopySurface(GrSurface* dst,
231 GrSurface* src, 236 GrSurface* src,
232 const SkIRect& srcRect, 237 const SkIRect& srcRect,
233 const SkIPoint& dstPoint) SK_OVERRIDE; 238 const SkIPoint& dstPoint) SK_OVERRIDE;
234 239
235 // Attempts to concat instances from info onto the previous draw. info must represent an 240 // Attempts to concat instances from info onto the previous draw. info must represent an
236 // instanced draw. The caller must have already recorded a new draw state an d clip if necessary. 241 // instanced draw. The caller must have already recorded a new draw state an d clip if necessary.
237 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); 242 int concatInstancedDraw(const GrDrawState&, const DrawInfo&);
238 243
239 // Determines whether the current draw operation requires a new GrOptDrawSta te and if so 244 // Determines whether the current draw operation requires a new GrOptDrawSta te and if so
240 // records it. If the draw can be skipped false is returned and no new GrOpt DrawState is 245 // records it. If the draw can be skipped false is returned and no new GrOpt DrawState is
241 // recorded. 246 // recorded.
242 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, 247 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&,
243 const GrGeometryProcesso r*, 248 const GrGeometryProcesso r*,
244 const GrPathProcessor*, 249 const GrPathProcessor*,
245 GrGpu::DrawType, 250 GrGpu::DrawType,
246 const GrClipMaskManager: :ScissorState&, 251 const GrScissorState&,
247 const GrDeviceCoordTextu re*); 252 const GrDeviceCoordTextu re*);
248 // We lazily record clip changes in order to skip clips that have no effect. 253 // We lazily record clip changes in order to skip clips that have no effect.
249 void recordClipIfNecessary(); 254 void recordClipIfNecessary();
250 // Records any trace markers for a command after adding it to the buffer. 255 // Records any trace markers for a command after adding it to the buffer.
251 void recordTraceMarkersIfNecessary(); 256 void recordTraceMarkersIfNecessary();
252 257
253 virtual bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawI D; } 258 virtual bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawI D; }
254 259
255 // TODO: Use a single allocator for commands and records 260 // TODO: Use a single allocator for commands and records
256 enum { 261 enum {
257 kCmdBufferInitialSizeInBytes = 8 * 1024, 262 kCmdBufferInitialSizeInBytes = 8 * 1024,
258 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's 263 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's
259 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms 264 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms
260 }; 265 };
261 266
262 CmdBuffer fCmdBuffer; 267 CmdBuffer fCmdBuffer;
263 GrOptDrawState* fPrevState; 268 GrOptDrawState* fPrevState;
264 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; 269 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers;
265 SkTDArray<char> fPathIndexBuffer; 270 SkTDArray<char> fPathIndexBuffer;
266 SkTDArray<float> fPathTransformBuffer; 271 SkTDArray<float> fPathTransformBuffer;
267 uint32_t fDrawID; 272 uint32_t fDrawID;
268 273
269 typedef GrFlushToGpuDrawTarget INHERITED; 274 typedef GrFlushToGpuDrawTarget INHERITED;
270 }; 275 };
271 276
272 #endif 277 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698