reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrInOrderDrawBuffer_DEFINED |
| 9 | #define GrInOrderDrawBuffer_DEFINED |
| 10 | |
bsalomon | 371bcbc | 2014-12-01 08:19:34 -0800 | [diff] [blame] | 11 | #include "GrFlushToGpuDrawTarget.h" |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 12 | |
| 13 | #include "GrBatch.h" |
| 14 | #include "GrBatchTarget.h" |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 15 | #include "GrPipeline.h" |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 16 | #include "GrPath.h" |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 17 | #include "GrTRecorder.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 18 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 19 | /** |
bsalomon@google.com | 55e4a20 | 2013-01-11 13:54:21 +0000 | [diff] [blame] | 20 | * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws for eventual |
| 21 | * playback into a GrGpu. In theory one draw buffer could playback into another. When index or |
| 22 | * vertex buffers are used as geometry sources it is the callers the draw buffer only holds |
| 23 | * references to the buffers. It is the callers responsibility to ensure that the data is still |
| 24 | * valid when the draw buffer is played back into a GrGpu. Similarly, it is the caller's |
| 25 | * responsibility to ensure that all referenced textures, buffers, and render-targets are associated |
| 26 | * in the GrGpu object that the buffer is played back into. The buffer requires VB and IB pools to |
| 27 | * store geometry. |
skia.committer@gmail.com | 07d3a65 | 2013-04-10 07:01:15 +0000 | [diff] [blame] | 28 | */ |
bsalomon | 371bcbc | 2014-12-01 08:19:34 -0800 | [diff] [blame] | 29 | class GrInOrderDrawBuffer : public GrFlushToGpuDrawTarget { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 30 | public: |
| 31 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 32 | /** |
| 33 | * Creates a GrInOrderDrawBuffer |
| 34 | * |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 35 | * @param gpu the gpu object that this draw buffer flushes to. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 36 | * @param vertexPool pool where vertices for queued draws will be saved when |
| 37 | * the vertex source is either reserved or array. |
| 38 | * @param indexPool pool where indices for queued draws will be saved when |
| 39 | * the index source is either reserved or array. |
| 40 | */ |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 41 | GrInOrderDrawBuffer(GrGpu* gpu, |
bsalomon@google.com | 471d471 | 2011-08-23 15:45:25 +0000 | [diff] [blame] | 42 | GrVertexBufferAllocPool* vertexPool, |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 43 | GrIndexBufferAllocPool* indexPool); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 44 | |
bsalomon | f90a02b | 2014-11-26 12:28:00 -0800 | [diff] [blame] | 45 | ~GrInOrderDrawBuffer() SK_OVERRIDE; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 46 | |
commit-bot@chromium.org | a8916ff | 2013-08-16 15:53:46 +0000 | [diff] [blame] | 47 | // tracking for draws |
tfarina | 912ed6e | 2014-12-14 15:20:10 -0800 | [diff] [blame] | 48 | DrawToken getCurrentDrawToken() SK_OVERRIDE { return DrawToken(this, fDrawID); } |
commit-bot@chromium.org | a8916ff | 2013-08-16 15:53:46 +0000 | [diff] [blame] | 49 | |
bsalomon | f90a02b | 2014-11-26 12:28:00 -0800 | [diff] [blame] | 50 | void clearStencilClip(const SkIRect& rect, |
| 51 | bool insideClip, |
| 52 | GrRenderTarget* renderTarget) SK_OVERRIDE; |
joshualitt | a702415 | 2014-11-03 14:16:35 -0800 | [diff] [blame] | 53 | |
bsalomon | f90a02b | 2014-11-26 12:28:00 -0800 | [diff] [blame] | 54 | void discard(GrRenderTarget*) SK_OVERRIDE; |
bsalomon@google.com | eb85117 | 2013-04-15 13:51:00 +0000 | [diff] [blame] | 55 | |
robertphillips | 54fac8b | 2015-02-16 09:35:50 -0800 | [diff] [blame] | 56 | protected: |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 57 | void willReserveVertexAndIndexSpace(int vertexCount, |
| 58 | size_t vertexStride, |
| 59 | int indexCount); |
| 60 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 61 | private: |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 62 | typedef GrGpu::DrawArgs DrawArgs; |
bsalomon@google.com | a4f6b10 | 2012-06-26 21:04:22 +0000 | [diff] [blame] | 63 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 64 | struct SetState; |
| 65 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 66 | struct Cmd : ::SkNoncopyable { |
robertphillips | e5e72f1 | 2015-02-17 09:14:33 -0800 | [diff] [blame^] | 67 | enum { |
| 68 | kDraw_Cmd = 1, |
| 69 | kStencilPath_Cmd = 2, |
| 70 | kSetState_Cmd = 3, |
| 71 | kClear_Cmd = 4, |
| 72 | kCopySurface_Cmd = 5, |
| 73 | kDrawPath_Cmd = 6, |
| 74 | kDrawPaths_Cmd = 7, |
| 75 | kDrawBatch_Cmd = 8, |
| 76 | }; |
| 77 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 78 | Cmd(uint8_t type) : fType(type) {} |
| 79 | virtual ~Cmd() {} |
| 80 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 81 | virtual void execute(GrInOrderDrawBuffer*, const SetState*) = 0; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 82 | |
robertphillips | e5e72f1 | 2015-02-17 09:14:33 -0800 | [diff] [blame^] | 83 | uint8_t type() const { return fType & kCmdMask; } |
| 84 | |
| 85 | bool isTraced() const { return SkToBool(fType & kTraceCmdBit); } |
| 86 | void makeTraced() { fType |= kTraceCmdBit; } |
| 87 | |
| 88 | private: |
| 89 | static const int kCmdMask = 0x7F; |
| 90 | static const int kTraceCmdBit = 0x80; |
| 91 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 92 | uint8_t fType; |
| 93 | }; |
| 94 | |
| 95 | struct Draw : public Cmd { |
joshualitt | 54e0c12 | 2014-11-19 09:38:51 -0800 | [diff] [blame] | 96 | Draw(const DrawInfo& info) : Cmd(kDraw_Cmd), fInfo(info) {} |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 97 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 98 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 99 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 100 | DrawInfo fInfo; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 103 | struct StencilPath : public Cmd { |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 104 | StencilPath(const GrPath* path, GrRenderTarget* rt) |
| 105 | : Cmd(kStencilPath_Cmd) |
| 106 | , fRenderTarget(rt) |
| 107 | , fPath(path) {} |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 108 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 109 | const GrPath* path() const { return fPath.get(); } |
| 110 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 111 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 112 | |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 113 | SkMatrix fViewMatrix; |
| 114 | bool fUseHWAA; |
| 115 | GrStencilSettings fStencil; |
| 116 | GrScissorState fScissor; |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 117 | private: |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 118 | GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 119 | GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 120 | }; |
| 121 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 122 | struct DrawPath : public Cmd { |
| 123 | DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 124 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 125 | const GrPath* path() const { return fPath.get(); } |
| 126 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 127 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 128 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 129 | GrStencilSettings fStencilSettings; |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 130 | |
| 131 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 132 | GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 133 | }; |
| 134 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 135 | struct DrawPaths : public Cmd { |
| 136 | DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRange(pathRange) {} |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 137 | |
| 138 | const GrPathRange* pathRange() const { return fPathRange.get(); } |
| 139 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 140 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 141 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 142 | int fIndicesLocation; |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 143 | PathIndexType fIndexType; |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 144 | int fTransformsLocation; |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 145 | PathTransformType fTransformType; |
| 146 | int fCount; |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 147 | GrStencilSettings fStencilSettings; |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 148 | |
| 149 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 150 | GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 151 | }; |
| 152 | |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 153 | // This is also used to record a discard by setting the color to GrColor_ILLEGAL |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 154 | struct Clear : public Cmd { |
| 155 | Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} |
| 156 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 157 | GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 158 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 159 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 160 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 161 | SkIRect fRect; |
| 162 | GrColor fColor; |
| 163 | bool fCanIgnoreRect; |
| 164 | |
| 165 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 166 | GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
bsalomon@google.com | 0b335c1 | 2011-04-25 19:17:44 +0000 | [diff] [blame] | 167 | }; |
| 168 | |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 169 | // This command is ONLY used by the clip mask manager to clear the stencil clip bits |
| 170 | struct ClearStencilClip : public Cmd { |
| 171 | ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} |
| 172 | |
| 173 | GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
| 174 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 175 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 176 | |
| 177 | SkIRect fRect; |
| 178 | bool fInsideClip; |
| 179 | |
| 180 | private: |
| 181 | GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 182 | }; |
| 183 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 184 | struct CopySurface : public Cmd { |
| 185 | CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDst(dst), fSrc(src) {} |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 186 | |
| 187 | GrSurface* dst() const { return fDst.get(); } |
| 188 | GrSurface* src() const { return fSrc.get(); } |
| 189 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 190 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 191 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 192 | SkIPoint fDstPoint; |
| 193 | SkIRect fSrcRect; |
| 194 | |
| 195 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 196 | GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
| 197 | GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 198 | }; |
| 199 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 200 | // TODO: rename to SetPipeline once pp, batch tracker, and desc are removed |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 201 | struct SetState : public Cmd { |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 202 | // TODO get rid of the prim proc parameter when we use batch everywhere |
| 203 | SetState(const GrPrimitiveProcessor* primProc = NULL) |
bsalomon | 932f866 | 2014-11-24 06:47:48 -0800 | [diff] [blame] | 204 | : Cmd(kSetState_Cmd) |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 205 | , fPrimitiveProcessor(primProc) {} |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 206 | |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 207 | ~SetState() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipeline(); } |
| 208 | |
| 209 | // This function is only for getting the location in memory where we will create our |
| 210 | // pipeline object. |
| 211 | GrPipeline* pipelineLocation() { return reinterpret_cast<GrPipeline*>(fPipeline.get()); } |
| 212 | |
| 213 | const GrPipeline* getPipeline() const { |
| 214 | return reinterpret_cast<const GrPipeline*>(fPipeline.get()); |
| 215 | } |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 216 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 217 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 218 | |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 219 | typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor; |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 220 | ProgramPrimitiveProcessor fPrimitiveProcessor; |
| 221 | SkAlignedSStorage<sizeof(GrPipeline)> fPipeline; |
| 222 | GrProgramDesc fDesc; |
| 223 | GrBatchTracker fBatchTracker; |
bsalomon | f0480b1 | 2014-07-02 12:11:24 -0700 | [diff] [blame] | 224 | }; |
| 225 | |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 226 | struct DrawBatch : public Cmd { |
| 227 | DrawBatch(GrBatch* batch) : Cmd(kDrawBatch_Cmd), fBatch(SkRef(batch)) { |
| 228 | SkASSERT(!batch->isUsed()); |
| 229 | } |
| 230 | |
| 231 | void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
| 232 | |
| 233 | // TODO it wouldn't be too hard to let batches allocate in the cmd buffer |
| 234 | SkAutoTUnref<GrBatch> fBatch; |
| 235 | }; |
| 236 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 237 | typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. |
| 238 | typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
| 239 | |
bsalomon | 371bcbc | 2014-12-01 08:19:34 -0800 | [diff] [blame] | 240 | void onReset() SK_OVERRIDE; |
| 241 | void onFlush() SK_OVERRIDE; |
| 242 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 243 | // overrides from GrDrawTarget |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 244 | void onDraw(const GrGeometryProcessor*, const DrawInfo&, const PipelineInfo&) SK_OVERRIDE; |
| 245 | void onDrawBatch(GrBatch*, const PipelineInfo&) SK_OVERRIDE; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 246 | void onDrawRect(GrPipelineBuilder*, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 247 | GrColor, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 248 | const SkMatrix& viewMatrix, |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 249 | const SkRect& rect, |
| 250 | const SkRect* localRect, |
| 251 | const SkMatrix* localMatrix) SK_OVERRIDE; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 252 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 253 | void onStencilPath(const GrPipelineBuilder&, |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 254 | const GrPathProcessor*, |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 255 | const GrPath*, |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 256 | const GrScissorState&, |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 257 | const GrStencilSettings&) SK_OVERRIDE; |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 258 | void onDrawPath(const GrPathProcessor*, |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 259 | const GrPath*, |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 260 | const GrStencilSettings&, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 261 | const PipelineInfo&) SK_OVERRIDE; |
| 262 | void onDrawPaths(const GrPathProcessor*, |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 263 | const GrPathRange*, |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 264 | const void* indices, |
| 265 | PathIndexType, |
| 266 | const float transformValues[], |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 267 | PathTransformType, |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 268 | int count, |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 269 | const GrStencilSettings&, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 270 | const PipelineInfo&) SK_OVERRIDE; |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 271 | void onClear(const SkIRect* rect, |
| 272 | GrColor color, |
| 273 | bool canIgnoreRect, |
| 274 | GrRenderTarget* renderTarget) SK_OVERRIDE; |
bsalomon | f90a02b | 2014-11-26 12:28:00 -0800 | [diff] [blame] | 275 | bool onCopySurface(GrSurface* dst, |
| 276 | GrSurface* src, |
| 277 | const SkIRect& srcRect, |
| 278 | const SkIPoint& dstPoint) SK_OVERRIDE; |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 279 | |
bsalomon@google.com | d62e88e | 2013-02-01 14:19:27 +0000 | [diff] [blame] | 280 | // Attempts to concat instances from info onto the previous draw. info must represent an |
| 281 | // instanced draw. The caller must have already recorded a new draw state and clip if necessary. |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 282 | int concatInstancedDraw(const DrawInfo&); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 283 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 284 | // Determines whether the current draw operation requires a new GrPipeline and if so |
| 285 | // records it. If the draw can be skipped false is returned and no new GrPipeline is |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 286 | // recorded. |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 287 | // TODO delete the primproc variant when we have batches everywhere |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 288 | bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(const GrPrimitiveProcessor*, |
| 289 | const PipelineInfo&); |
| 290 | bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrBatch*, const PipelineInfo&); |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 291 | |
bsalomon | 838f62d | 2014-08-05 07:15:57 -0700 | [diff] [blame] | 292 | // We lazily record clip changes in order to skip clips that have no effect. |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 293 | void recordClipIfNecessary(); |
| 294 | // Records any trace markers for a command after adding it to the buffer. |
| 295 | void recordTraceMarkersIfNecessary(); |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 296 | |
mtklein | 72c9faa | 2015-01-09 10:06:39 -0800 | [diff] [blame] | 297 | bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } |
bsalomon@google.com | 934c570 | 2012-03-20 21:17:58 +0000 | [diff] [blame] | 298 | |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 299 | GrBatchTarget* getBatchTarget() { return &fBatchTarget; } |
| 300 | |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 301 | // TODO: Use a single allocator for commands and records |
bsalomon@google.com | 4b90c62 | 2011-09-28 17:52:15 +0000 | [diff] [blame] | 302 | enum { |
cdalton | c4650ee | 2014-11-07 12:51:18 -0800 | [diff] [blame] | 303 | kCmdBufferInitialSizeInBytes = 8 * 1024, |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 304 | kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
| 305 | kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
bsalomon@google.com | 4b90c62 | 2011-09-28 17:52:15 +0000 | [diff] [blame] | 306 | }; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 307 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 308 | CmdBuffer fCmdBuffer; |
joshualitt | 873ad0e | 2015-01-20 09:08:51 -0800 | [diff] [blame] | 309 | SetState* fPrevState; |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 310 | SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 311 | SkTDArray<char> fPathIndexBuffer; |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 312 | SkTDArray<float> fPathTransformBuffer; |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 313 | uint32_t fDrawID; |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 314 | GrBatchTarget fBatchTarget; |
| 315 | // TODO hack until batch is everywhere |
| 316 | DrawBatch* fDrawBatch; |
| 317 | |
joshualitt | 70f0004 | 2015-02-06 15:53:59 -0800 | [diff] [blame] | 318 | // This will go away when everything uses batch. However, in the short term anything which |
| 319 | // might be put into the GrInOrderDrawBuffer needs to make sure it closes the last batch |
| 320 | void closeBatch() { |
| 321 | if (fDrawBatch) { |
| 322 | fBatchTarget.resetNumberOfDraws(); |
| 323 | fDrawBatch->execute(this, fPrevState); |
| 324 | fDrawBatch->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
| 325 | fDrawBatch = NULL; |
| 326 | } |
| 327 | } |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 328 | |
bsalomon | 371bcbc | 2014-12-01 08:19:34 -0800 | [diff] [blame] | 329 | typedef GrFlushToGpuDrawTarget INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 330 | }; |
| 331 | |
| 332 | #endif |