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 | |
| 11 | #include "GrDrawTarget.h" |
joshualitt | d53a827 | 2014-11-10 16:03:14 -0800 | [diff] [blame] | 12 | #include "GrGpu.h" |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 13 | #include "GrIndexBuffer.h" |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 14 | #include "GrOptDrawState.h" |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 15 | #include "GrPath.h" |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 16 | #include "GrPathRange.h" |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 17 | #include "GrRenderTarget.h" |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 18 | #include "GrSurface.h" |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 19 | #include "GrTRecorder.h" |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 20 | #include "GrVertexBuffer.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 21 | |
robertphillips@google.com | 641f8b1 | 2012-07-31 19:15:58 +0000 | [diff] [blame] | 22 | #include "SkClipStack.h" |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 23 | #include "SkTemplates.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 24 | #include "SkTypes.h" |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 25 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 26 | class GrIndexBufferAllocPool; |
bsalomon@google.com | 471d471 | 2011-08-23 15:45:25 +0000 | [diff] [blame] | 27 | class GrVertexBufferAllocPool; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 28 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 29 | /** |
bsalomon@google.com | 55e4a20 | 2013-01-11 13:54:21 +0000 | [diff] [blame] | 30 | * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws for eventual |
| 31 | * playback into a GrGpu. In theory one draw buffer could playback into another. When index or |
| 32 | * vertex buffers are used as geometry sources it is the callers the draw buffer only holds |
| 33 | * references to the buffers. It is the callers responsibility to ensure that the data is still |
| 34 | * valid when the draw buffer is played back into a GrGpu. Similarly, it is the caller's |
| 35 | * responsibility to ensure that all referenced textures, buffers, and render-targets are associated |
| 36 | * in the GrGpu object that the buffer is played back into. The buffer requires VB and IB pools to |
| 37 | * store geometry. |
skia.committer@gmail.com | 07d3a65 | 2013-04-10 07:01:15 +0000 | [diff] [blame] | 38 | */ |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 39 | class GrInOrderDrawBuffer : public GrClipTarget { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 40 | public: |
| 41 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 42 | /** |
| 43 | * Creates a GrInOrderDrawBuffer |
| 44 | * |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 45 | * @param gpu the gpu object that this draw buffer flushes to. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 46 | * @param vertexPool pool where vertices for queued draws will be saved when |
| 47 | * the vertex source is either reserved or array. |
| 48 | * @param indexPool pool where indices for queued draws will be saved when |
| 49 | * the index source is either reserved or array. |
| 50 | */ |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 51 | GrInOrderDrawBuffer(GrGpu* gpu, |
bsalomon@google.com | 471d471 | 2011-08-23 15:45:25 +0000 | [diff] [blame] | 52 | GrVertexBufferAllocPool* vertexPool, |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 53 | GrIndexBufferAllocPool* indexPool); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 54 | |
| 55 | virtual ~GrInOrderDrawBuffer(); |
| 56 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 57 | /** |
bsalomon@google.com | 55e4a20 | 2013-01-11 13:54:21 +0000 | [diff] [blame] | 58 | * Empties the draw buffer of any queued up draws. This must not be called while inside an |
| 59 | * unbalanced pushGeometrySource(). The current draw state and clip are preserved. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 60 | */ |
| 61 | void reset(); |
| 62 | |
| 63 | /** |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 64 | * This plays the queued up draws to its GrGpu target. It also resets this object (i.e. flushing |
bsalomon@google.com | 55e4a20 | 2013-01-11 13:54:21 +0000 | [diff] [blame] | 65 | * is destructive). This buffer must not have an active reserved vertex or index source. Any |
| 66 | * reserved geometry on the target will be finalized because it's geometry source will be pushed |
| 67 | * before flushing and popped afterwards. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 68 | */ |
robertphillips@google.com | 1267fbd | 2013-07-03 18:37:27 +0000 | [diff] [blame] | 69 | void flush(); |
bsalomon@google.com | 9780538 | 2012-03-13 14:32:07 +0000 | [diff] [blame] | 70 | |
commit-bot@chromium.org | a8916ff | 2013-08-16 15:53:46 +0000 | [diff] [blame] | 71 | // tracking for draws |
| 72 | virtual DrawToken getCurrentDrawToken() { return DrawToken(this, fDrawID); } |
| 73 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 74 | // overrides from GrDrawTarget |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 75 | virtual bool geometryHints(size_t vertexStride, |
| 76 | int* vertexCount, |
bsalomon@google.com | 9780538 | 2012-03-13 14:32:07 +0000 | [diff] [blame] | 77 | int* indexCount) const SK_OVERRIDE; |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 78 | |
joshualitt | a702415 | 2014-11-03 14:16:35 -0800 | [diff] [blame] | 79 | virtual bool copySurface(GrSurface* dst, |
| 80 | GrSurface* src, |
| 81 | const SkIRect& srcRect, |
| 82 | const SkIPoint& dstPoint) SK_OVERRIDE; |
| 83 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 84 | virtual bool canCopySurface(const GrSurface* dst, |
| 85 | const GrSurface* src, |
joshualitt | a702415 | 2014-11-03 14:16:35 -0800 | [diff] [blame] | 86 | const SkIRect& srcRect, |
| 87 | const SkIPoint& dstPoint) SK_OVERRIDE; |
| 88 | |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 89 | virtual void clearStencilClip(const SkIRect& rect, |
| 90 | bool insideClip, |
| 91 | GrRenderTarget* renderTarget) SK_OVERRIDE; |
| 92 | |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 93 | virtual void discard(GrRenderTarget*) SK_OVERRIDE; |
bsalomon@google.com | 0b335c1 | 2011-04-25 19:17:44 +0000 | [diff] [blame] | 94 | |
bsalomon | f2703d8 | 2014-10-28 14:33:06 -0700 | [diff] [blame] | 95 | virtual void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_OVERRIDE; |
bsalomon@google.com | eb85117 | 2013-04-15 13:51:00 +0000 | [diff] [blame] | 96 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 97 | private: |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 98 | typedef GrClipMaskManager::ScissorState ScissorState; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 99 | enum { |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 100 | kDraw_Cmd = 1, |
| 101 | kStencilPath_Cmd = 2, |
| 102 | kSetState_Cmd = 3, |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 103 | kClear_Cmd = 4, |
| 104 | kCopySurface_Cmd = 5, |
| 105 | kDrawPath_Cmd = 6, |
| 106 | kDrawPaths_Cmd = 7, |
bsalomon@google.com | a4f6b10 | 2012-06-26 21:04:22 +0000 | [diff] [blame] | 107 | }; |
| 108 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 109 | struct Cmd : ::SkNoncopyable { |
| 110 | Cmd(uint8_t type) : fType(type) {} |
| 111 | virtual ~Cmd() {} |
| 112 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 113 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) = 0; |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 114 | |
| 115 | uint8_t fType; |
| 116 | }; |
| 117 | |
| 118 | struct Draw : public Cmd { |
joshualitt | 7eb8c7b | 2014-11-18 14:24:27 -0800 | [diff] [blame] | 119 | Draw(const DrawInfo& info, const ScissorState& scissorState) |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 120 | : Cmd(kDraw_Cmd) |
| 121 | , fInfo(info) |
joshualitt | 7eb8c7b | 2014-11-18 14:24:27 -0800 | [diff] [blame] | 122 | , fScissorState(scissorState){} |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 123 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 124 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 125 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 126 | DrawInfo fInfo; |
| 127 | ScissorState fScissorState; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 128 | }; |
| 129 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 130 | struct StencilPath : public Cmd { |
| 131 | StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {} |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 132 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 133 | const GrPath* path() const { return fPath.get(); } |
| 134 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 135 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 136 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 137 | ScissorState fScissorState; |
| 138 | GrStencilSettings fStencilSettings; |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 139 | |
| 140 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 141 | GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 142 | }; |
| 143 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 144 | struct DrawPath : public Cmd { |
| 145 | DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 146 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 147 | const GrPath* path() const { return fPath.get(); } |
| 148 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 149 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 150 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 151 | GrDeviceCoordTexture fDstCopy; |
| 152 | ScissorState fScissorState; |
| 153 | GrStencilSettings fStencilSettings; |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 154 | |
| 155 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 156 | GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 157 | }; |
| 158 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 159 | struct DrawPaths : public Cmd { |
| 160 | DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRange(pathRange) {} |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 161 | |
| 162 | const GrPathRange* pathRange() const { return fPathRange.get(); } |
| 163 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 164 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 165 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 166 | int fIndicesLocation; |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 167 | size_t fCount; |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 168 | int fTransformsLocation; |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 169 | PathTransformType fTransformsType; |
| 170 | GrDeviceCoordTexture fDstCopy; |
| 171 | ScissorState fScissorState; |
| 172 | GrStencilSettings fStencilSettings; |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 173 | |
| 174 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 175 | GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 176 | }; |
| 177 | |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 178 | // 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] | 179 | struct Clear : public Cmd { |
| 180 | Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} |
| 181 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 182 | GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 183 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 184 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 185 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 186 | SkIRect fRect; |
| 187 | GrColor fColor; |
| 188 | bool fCanIgnoreRect; |
| 189 | |
| 190 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 191 | GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
bsalomon@google.com | 0b335c1 | 2011-04-25 19:17:44 +0000 | [diff] [blame] | 192 | }; |
| 193 | |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 194 | // This command is ONLY used by the clip mask manager to clear the stencil clip bits |
| 195 | struct ClearStencilClip : public Cmd { |
| 196 | ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} |
| 197 | |
| 198 | GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
| 199 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 200 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 201 | |
| 202 | SkIRect fRect; |
| 203 | bool fInsideClip; |
| 204 | |
| 205 | private: |
| 206 | GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 207 | }; |
| 208 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 209 | struct CopySurface : public Cmd { |
| 210 | CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDst(dst), fSrc(src) {} |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 211 | |
| 212 | GrSurface* dst() const { return fDst.get(); } |
| 213 | GrSurface* src() const { return fSrc.get(); } |
| 214 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 215 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 216 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 217 | SkIPoint fDstPoint; |
| 218 | SkIRect fSrcRect; |
| 219 | |
| 220 | private: |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 221 | GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
| 222 | GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 223 | }; |
| 224 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 225 | struct SetState : public Cmd { |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 226 | SetState(const GrOptDrawState* state) : Cmd(kSetState_Cmd), fState(SkRef(state)) {} |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 227 | |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 228 | virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*); |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 229 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 230 | SkAutoTUnref<const GrOptDrawState> fState; |
| 231 | GrGpu::DrawType fDrawType; |
| 232 | GrDeviceCoordTexture fDstCopy; |
bsalomon | f0480b1 | 2014-07-02 12:11:24 -0700 | [diff] [blame] | 233 | }; |
| 234 | |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 235 | typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. |
| 236 | typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
| 237 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 238 | // overrides from GrDrawTarget |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 239 | void onDraw(const GrDrawState&, |
| 240 | const DrawInfo&, |
| 241 | const GrClipMaskManager::ScissorState&) SK_OVERRIDE; |
| 242 | void onDrawRect(GrDrawState*, |
| 243 | const SkRect& rect, |
| 244 | const SkRect* localRect, |
| 245 | const SkMatrix* localMatrix) SK_OVERRIDE; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 246 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 247 | void onStencilPath(const GrDrawState&, |
| 248 | const GrPath*, |
| 249 | const GrClipMaskManager::ScissorState&, |
| 250 | const GrStencilSettings&) SK_OVERRIDE; |
| 251 | void onDrawPath(const GrDrawState&, |
| 252 | const GrPath*, |
| 253 | const GrClipMaskManager::ScissorState&, |
| 254 | const GrStencilSettings&, |
| 255 | const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
| 256 | void onDrawPaths(const GrDrawState&, |
| 257 | const GrPathRange*, |
| 258 | const uint32_t indices[], |
| 259 | int count, |
| 260 | const float transforms[], |
| 261 | PathTransformType, |
| 262 | const GrClipMaskManager::ScissorState&, |
| 263 | const GrStencilSettings&, |
| 264 | const GrDeviceCoordTexture*) SK_OVERRIDE; |
| 265 | void onClear(const SkIRect* rect, |
| 266 | GrColor color, |
| 267 | bool canIgnoreRect, |
| 268 | GrRenderTarget* renderTarget) SK_OVERRIDE; |
| 269 | void setDrawBuffers(DrawInfo*) SK_OVERRIDE; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 270 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 271 | bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) SK_OVERRIDE; |
| 272 | bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE; |
| 273 | void releaseReservedVertexSpace() SK_OVERRIDE; |
| 274 | void releaseReservedIndexSpace() SK_OVERRIDE; |
| 275 | void geometrySourceWillPush() SK_OVERRIDE; |
| 276 | void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRIDE; |
| 277 | void willReserveVertexAndIndexSpace(int vertexCount, |
| 278 | size_t vertexStride, |
| 279 | int indexCount) SK_OVERRIDE; |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 280 | |
bsalomon@google.com | d62e88e | 2013-02-01 14:19:27 +0000 | [diff] [blame] | 281 | // Attempts to concat instances from info onto the previous draw. info must represent an |
| 282 | // instanced draw. The caller must have already recorded a new draw state and clip if necessary. |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 283 | int concatInstancedDraw(const GrDrawState&, |
| 284 | const DrawInfo&, |
| 285 | const GrClipMaskManager::ScissorState&); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 286 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 287 | // Determines whether the current draw operation requires a new GrOptDrawState and if so |
| 288 | // records it. If the draw can be skipped false is returned and no new GrOptDrawState is |
| 289 | // recorded. |
| 290 | bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, |
| 291 | GrGpu::DrawType, |
| 292 | const GrDeviceCoordTexture*); |
bsalomon | 838f62d | 2014-08-05 07:15:57 -0700 | [diff] [blame] | 293 | // 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] | 294 | void recordClipIfNecessary(); |
| 295 | // Records any trace markers for a command after adding it to the buffer. |
| 296 | void recordTraceMarkersIfNecessary(); |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 297 | |
| 298 | virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
bsalomon@google.com | 934c570 | 2012-03-20 21:17:58 +0000 | [diff] [blame] | 299 | |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 300 | // TODO: Use a single allocator for commands and records |
bsalomon@google.com | 4b90c62 | 2011-09-28 17:52:15 +0000 | [diff] [blame] | 301 | enum { |
cdalton | c4650ee | 2014-11-07 12:51:18 -0800 | [diff] [blame] | 302 | kCmdBufferInitialSizeInBytes = 8 * 1024, |
cdalton | 3fc6a2f | 2014-11-13 11:54:20 -0800 | [diff] [blame] | 303 | kPathIdxBufferMinReserve = 64, |
| 304 | kPathXformBufferMinReserve = 2 * kPathIdxBufferMinReserve, |
cdalton | 6819df3 | 2014-10-15 13:43:48 -0700 | [diff] [blame] | 305 | kGeoPoolStatePreAllocCnt = 4, |
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@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 308 | struct GeometryPoolState { |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 309 | const GrVertexBuffer* fPoolVertexBuffer; |
| 310 | int fPoolStartVertex; |
| 311 | const GrIndexBuffer* fPoolIndexBuffer; |
| 312 | int fPoolStartIndex; |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 313 | // caller may conservatively over reserve vertices / indices. |
| 314 | // we release unused space back to allocator if possible |
| 315 | // can only do this if there isn't an intervening pushGeometrySource() |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 316 | size_t fUsedPoolVertexBytes; |
| 317 | size_t fUsedPoolIndexBytes; |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 318 | }; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 319 | |
bsalomon | b3e3a95 | 2014-09-19 11:10:40 -0700 | [diff] [blame] | 320 | typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateStack; |
skia.committer@gmail.com | 7475811 | 2013-08-17 07:01:54 +0000 | [diff] [blame] | 321 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame^] | 322 | CmdBuffer fCmdBuffer; |
| 323 | SkAutoTUnref<const GrOptDrawState> fLastState; |
| 324 | SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
| 325 | GrGpu* fDstGpu; |
| 326 | GrVertexBufferAllocPool& fVertexPool; |
| 327 | GrIndexBufferAllocPool& fIndexPool; |
| 328 | SkTDArray<uint32_t> fPathIndexBuffer; |
| 329 | SkTDArray<float> fPathTransformBuffer; |
| 330 | GeoPoolStateStack fGeoPoolStateStack; |
| 331 | bool fFlushing; |
| 332 | uint32_t fDrawID; |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 333 | |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 334 | typedef GrClipTarget INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 335 | }; |
| 336 | |
| 337 | #endif |