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" |
| 12 | #include "GrAllocPool.h" |
| 13 | #include "GrAllocator.h" |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 14 | #include "GrPath.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | |
robertphillips@google.com | 641f8b1 | 2012-07-31 19:15:58 +0000 | [diff] [blame] | 16 | #include "SkClipStack.h" |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 17 | #include "SkTemplates.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 18 | #include "SkTypes.h" |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 19 | |
bsalomon@google.com | 471d471 | 2011-08-23 15:45:25 +0000 | [diff] [blame] | 20 | class GrGpu; |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 21 | class GrIndexBufferAllocPool; |
bsalomon@google.com | 471d471 | 2011-08-23 15:45:25 +0000 | [diff] [blame] | 22 | class GrVertexBufferAllocPool; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 23 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 24 | /** |
bsalomon@google.com | 55e4a20 | 2013-01-11 13:54:21 +0000 | [diff] [blame] | 25 | * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws for eventual |
| 26 | * playback into a GrGpu. In theory one draw buffer could playback into another. When index or |
| 27 | * vertex buffers are used as geometry sources it is the callers the draw buffer only holds |
| 28 | * references to the buffers. It is the callers responsibility to ensure that the data is still |
| 29 | * valid when the draw buffer is played back into a GrGpu. Similarly, it is the caller's |
| 30 | * responsibility to ensure that all referenced textures, buffers, and render-targets are associated |
| 31 | * in the GrGpu object that the buffer is played back into. The buffer requires VB and IB pools to |
| 32 | * store geometry. |
skia.committer@gmail.com | 07d3a65 | 2013-04-10 07:01:15 +0000 | [diff] [blame] | 33 | */ |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 34 | class GrInOrderDrawBuffer : public GrDrawTarget { |
| 35 | public: |
| 36 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 37 | /** |
| 38 | * Creates a GrInOrderDrawBuffer |
| 39 | * |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 40 | * @param gpu the gpu object that this draw buffer flushes to. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 41 | * @param vertexPool pool where vertices for queued draws will be saved when |
| 42 | * the vertex source is either reserved or array. |
| 43 | * @param indexPool pool where indices for queued draws will be saved when |
| 44 | * the index source is either reserved or array. |
| 45 | */ |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 46 | GrInOrderDrawBuffer(GrGpu* gpu, |
bsalomon@google.com | 471d471 | 2011-08-23 15:45:25 +0000 | [diff] [blame] | 47 | GrVertexBufferAllocPool* vertexPool, |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 48 | GrIndexBufferAllocPool* indexPool); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 49 | |
| 50 | virtual ~GrInOrderDrawBuffer(); |
| 51 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 52 | /** |
bsalomon@google.com | 55e4a20 | 2013-01-11 13:54:21 +0000 | [diff] [blame] | 53 | * Empties the draw buffer of any queued up draws. This must not be called while inside an |
| 54 | * unbalanced pushGeometrySource(). The current draw state and clip are preserved. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 55 | */ |
| 56 | void reset(); |
| 57 | |
| 58 | /** |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 59 | * 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] | 60 | * is destructive). This buffer must not have an active reserved vertex or index source. Any |
| 61 | * reserved geometry on the target will be finalized because it's geometry source will be pushed |
| 62 | * before flushing and popped afterwards. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 63 | */ |
robertphillips@google.com | 1267fbd | 2013-07-03 18:37:27 +0000 | [diff] [blame] | 64 | void flush(); |
bsalomon@google.com | 9780538 | 2012-03-13 14:32:07 +0000 | [diff] [blame] | 65 | |
commit-bot@chromium.org | a8916ff | 2013-08-16 15:53:46 +0000 | [diff] [blame] | 66 | // tracking for draws |
| 67 | virtual DrawToken getCurrentDrawToken() { return DrawToken(this, fDrawID); } |
| 68 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 69 | // overrides from GrDrawTarget |
jvanverth@google.com | b75b0a0 | 2013-02-05 20:33:30 +0000 | [diff] [blame] | 70 | virtual bool geometryHints(int* vertexCount, |
bsalomon@google.com | 9780538 | 2012-03-13 14:32:07 +0000 | [diff] [blame] | 71 | int* indexCount) const SK_OVERRIDE; |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 72 | virtual void clear(const SkIRect* rect, |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 73 | GrColor color, |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 74 | bool canIgnoreRect, |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 75 | GrRenderTarget* renderTarget) SK_OVERRIDE; |
| 76 | |
| 77 | virtual void discard(GrRenderTarget*) SK_OVERRIDE; |
bsalomon@google.com | 0b335c1 | 2011-04-25 19:17:44 +0000 | [diff] [blame] | 78 | |
bsalomon@google.com | eb85117 | 2013-04-15 13:51:00 +0000 | [diff] [blame] | 79 | virtual void initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* desc) SK_OVERRIDE; |
| 80 | |
bsalomon@google.com | 9780538 | 2012-03-13 14:32:07 +0000 | [diff] [blame] | 81 | protected: |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 82 | virtual void clipWillBeSet(const GrClipData* newClip) SK_OVERRIDE; |
| 83 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 84 | private: |
bsalomon@google.com | a4f6b10 | 2012-06-26 21:04:22 +0000 | [diff] [blame] | 85 | enum Cmd { |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 86 | kDraw_Cmd = 1, |
| 87 | kStencilPath_Cmd = 2, |
| 88 | kSetState_Cmd = 3, |
| 89 | kSetClip_Cmd = 4, |
| 90 | kClear_Cmd = 5, |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 91 | kCopySurface_Cmd = 6, |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 92 | kDrawPath_Cmd = 7, |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 93 | kDrawPaths_Cmd = 8, |
bsalomon@google.com | a4f6b10 | 2012-06-26 21:04:22 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
bsalomon@google.com | d62e88e | 2013-02-01 14:19:27 +0000 | [diff] [blame] | 96 | class DrawRecord : public DrawInfo { |
| 97 | public: |
| 98 | DrawRecord(const DrawInfo& info) : DrawInfo(info) {} |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 99 | const GrVertexBuffer* fVertexBuffer; |
| 100 | const GrIndexBuffer* fIndexBuffer; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 103 | struct StencilPath : public ::SkNoncopyable { |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 104 | StencilPath(); |
| 105 | |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 106 | SkAutoTUnref<const GrPath> fPath; |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 107 | SkPath::FillType fFill; |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 110 | struct DrawPath : public ::SkNoncopyable { |
| 111 | DrawPath(); |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 112 | |
| 113 | SkAutoTUnref<const GrPath> fPath; |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 114 | SkPath::FillType fFill; |
| 115 | GrDeviceCoordTexture fDstCopy; |
| 116 | }; |
| 117 | |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 118 | struct DrawPaths : public ::SkNoncopyable { |
| 119 | DrawPaths(); |
| 120 | ~DrawPaths(); |
| 121 | |
commit-bot@chromium.org | ecc4536 | 2014-03-28 21:31:34 +0000 | [diff] [blame] | 122 | int fPathCount; |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 123 | const GrPath** fPaths; |
| 124 | SkMatrix* fTransforms; |
| 125 | SkPath::FillType fFill; |
| 126 | SkStrokeRec::Style fStroke; |
| 127 | GrDeviceCoordTexture fDstCopy; |
| 128 | }; |
| 129 | |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 130 | // This is also used to record a discard by setting the color to GrColor_ILLEGAL |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 131 | struct Clear : public ::SkNoncopyable { |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 132 | Clear() : fRenderTarget(NULL) {} |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 133 | ~Clear() { SkSafeUnref(fRenderTarget); } |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 134 | |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 135 | SkIRect fRect; |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 136 | GrColor fColor; |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 137 | bool fCanIgnoreRect; |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 138 | GrRenderTarget* fRenderTarget; |
bsalomon@google.com | 0b335c1 | 2011-04-25 19:17:44 +0000 | [diff] [blame] | 139 | }; |
| 140 | |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 141 | struct CopySurface : public ::SkNoncopyable { |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 142 | SkAutoTUnref<GrSurface> fDst; |
| 143 | SkAutoTUnref<GrSurface> fSrc; |
| 144 | SkIRect fSrcRect; |
| 145 | SkIPoint fDstPoint; |
| 146 | }; |
| 147 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 148 | // overrides from GrDrawTarget |
bsalomon@google.com | 74749cd | 2013-01-30 16:12:41 +0000 | [diff] [blame] | 149 | virtual void onDraw(const DrawInfo&) SK_OVERRIDE; |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 150 | virtual void onDrawRect(const SkRect& rect, |
bsalomon@google.com | 0406b9e | 2013-04-02 21:00:15 +0000 | [diff] [blame] | 151 | const SkMatrix* matrix, |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 152 | const SkRect* localRect, |
bsalomon@google.com | 0406b9e | 2013-04-02 21:00:15 +0000 | [diff] [blame] | 153 | const SkMatrix* localMatrix) SK_OVERRIDE; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 154 | |
| 155 | virtual void onStencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; |
| 156 | virtual void onDrawPath(const GrPath*, SkPath::FillType, |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 157 | const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
commit-bot@chromium.org | ecc4536 | 2014-03-28 21:31:34 +0000 | [diff] [blame] | 158 | virtual void onDrawPaths(int, const GrPath**, const SkMatrix*, |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 159 | SkPath::FillType, SkStrokeRec::Style, |
| 160 | const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 161 | |
jvanverth@google.com | a633898 | 2013-01-31 21:34:25 +0000 | [diff] [blame] | 162 | virtual bool onReserveVertexSpace(size_t vertexSize, |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 163 | int vertexCount, |
bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame] | 164 | void** vertices) SK_OVERRIDE; |
| 165 | virtual bool onReserveIndexSpace(int indexCount, |
| 166 | void** indices) SK_OVERRIDE; |
| 167 | virtual void releaseReservedVertexSpace() SK_OVERRIDE; |
| 168 | virtual void releaseReservedIndexSpace() SK_OVERRIDE; |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 169 | virtual void onSetVertexSourceToArray(const void* vertexArray, |
bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame] | 170 | int vertexCount) SK_OVERRIDE; |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 171 | virtual void onSetIndexSourceToArray(const void* indexArray, |
bsalomon@google.com | 13f1b6f | 2012-05-31 12:52:43 +0000 | [diff] [blame] | 172 | int indexCount) SK_OVERRIDE; |
| 173 | virtual void releaseVertexArray() SK_OVERRIDE; |
| 174 | virtual void releaseIndexArray() SK_OVERRIDE; |
| 175 | virtual void geometrySourceWillPush() SK_OVERRIDE; |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 176 | virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRIDE; |
jvanverth@google.com | b75b0a0 | 2013-02-05 20:33:30 +0000 | [diff] [blame] | 177 | virtual void willReserveVertexAndIndexSpace(int vertexCount, |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 178 | int indexCount) SK_OVERRIDE; |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 179 | virtual bool onCopySurface(GrSurface* dst, |
| 180 | GrSurface* src, |
| 181 | const SkIRect& srcRect, |
| 182 | const SkIPoint& dstPoint) SK_OVERRIDE; |
| 183 | virtual bool onCanCopySurface(GrSurface* dst, |
| 184 | GrSurface* src, |
| 185 | const SkIRect& srcRect, |
| 186 | const SkIPoint& dstPoint) SK_OVERRIDE; |
| 187 | |
bsalomon@google.com | d62e88e | 2013-02-01 14:19:27 +0000 | [diff] [blame] | 188 | bool quickInsideClip(const SkRect& devBounds); |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 189 | |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 190 | virtual void didAddGpuTraceMarker() SK_OVERRIDE {} |
| 191 | virtual void didRemoveGpuTraceMarker() SK_OVERRIDE {} |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 192 | |
bsalomon@google.com | d62e88e | 2013-02-01 14:19:27 +0000 | [diff] [blame] | 193 | // Attempts to concat instances from info onto the previous draw. info must represent an |
| 194 | // instanced draw. The caller must have already recorded a new draw state and clip if necessary. |
| 195 | int concatInstancedDraw(const DrawInfo& info); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 196 | |
bsalomon@google.com | d62e88e | 2013-02-01 14:19:27 +0000 | [diff] [blame] | 197 | // we lazily record state and clip changes in order to skip clips and states that have no |
| 198 | // effect. |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 199 | bool needsNewState() const; |
| 200 | bool needsNewClip() const; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 201 | |
bsalomon@google.com | a4f6b10 | 2012-06-26 21:04:22 +0000 | [diff] [blame] | 202 | // these functions record a command |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 203 | void recordState(); |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 204 | void recordClip(); |
bsalomon@google.com | 74749cd | 2013-01-30 16:12:41 +0000 | [diff] [blame] | 205 | DrawRecord* recordDraw(const DrawInfo&); |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 206 | StencilPath* recordStencilPath(); |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 207 | DrawPath* recordDrawPath(); |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 208 | DrawPaths* recordDrawPaths(); |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 209 | Clear* recordClear(); |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 210 | CopySurface* recordCopySurface(); |
bsalomon@google.com | 934c570 | 2012-03-20 21:17:58 +0000 | [diff] [blame] | 211 | |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 212 | // TODO: Use a single allocator for commands and records |
bsalomon@google.com | 4b90c62 | 2011-09-28 17:52:15 +0000 | [diff] [blame] | 213 | enum { |
bsalomon@google.com | a4f6b10 | 2012-06-26 21:04:22 +0000 | [diff] [blame] | 214 | kCmdPreallocCnt = 32, |
bsalomon | bce3d6d | 2014-07-02 07:54:42 -0700 | [diff] [blame^] | 215 | kDrawPreallocCnt = 16, |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 216 | kStencilPathPreallocCnt = 8, |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 217 | kDrawPathPreallocCnt = 8, |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 218 | kDrawPathsPreallocCnt = 8, |
bsalomon@google.com | 4b90c62 | 2011-09-28 17:52:15 +0000 | [diff] [blame] | 219 | kStatePreallocCnt = 8, |
| 220 | kClipPreallocCnt = 8, |
bsalomon | bce3d6d | 2014-07-02 07:54:42 -0700 | [diff] [blame^] | 221 | kClearPreallocCnt = 8, |
bsalomon@google.com | 4b90c62 | 2011-09-28 17:52:15 +0000 | [diff] [blame] | 222 | kGeoPoolStatePreAllocCnt = 4, |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 223 | kCopySurfacePreallocCnt = 4, |
bsalomon@google.com | 4b90c62 | 2011-09-28 17:52:15 +0000 | [diff] [blame] | 224 | }; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 225 | |
bsalomon | bce3d6d | 2014-07-02 07:54:42 -0700 | [diff] [blame^] | 226 | typedef GrTAllocator<DrawRecord> DrawAllocator; |
| 227 | typedef GrTAllocator<StencilPath> StencilPathAllocator; |
| 228 | typedef GrTAllocator<DrawPath> DrawPathAllocator; |
| 229 | typedef GrTAllocator<DrawPaths> DrawPathsAllocator; |
| 230 | typedef GrTAllocator<GrDrawState::DeferredState> StateAllocator; |
| 231 | typedef GrTAllocator<Clear> ClearAllocator; |
| 232 | typedef GrTAllocator<CopySurface> CopySurfaceAllocator; |
| 233 | typedef GrTAllocator<SkClipStack> ClipAllocator; |
| 234 | typedef GrTAllocator<SkIPoint> ClipOriginAllocator; |
| 235 | |
bsalomon@google.com | 74749cd | 2013-01-30 16:12:41 +0000 | [diff] [blame] | 236 | GrSTAllocator<kDrawPreallocCnt, DrawRecord> fDraws; |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 237 | GrSTAllocator<kStencilPathPreallocCnt, StencilPath> fStencilPaths; |
| 238 | GrSTAllocator<kDrawPathPreallocCnt, DrawPath> fDrawPath; |
| 239 | GrSTAllocator<kDrawPathsPreallocCnt, DrawPaths> fDrawPaths; |
bsalomon@google.com | ca43208 | 2013-01-23 19:53:46 +0000 | [diff] [blame] | 240 | GrSTAllocator<kStatePreallocCnt, GrDrawState::DeferredState> fStates; |
| 241 | GrSTAllocator<kClearPreallocCnt, Clear> fClears; |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 242 | GrSTAllocator<kCopySurfacePreallocCnt, CopySurface> fCopySurfaces; |
| 243 | GrSTAllocator<kClipPreallocCnt, SkClipStack> fClips; |
| 244 | GrSTAllocator<kClipPreallocCnt, SkIPoint> fClipOrigins; |
bsalomon | bce3d6d | 2014-07-02 07:54:42 -0700 | [diff] [blame^] | 245 | |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 246 | SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
bsalomon@google.com | 9780538 | 2012-03-13 14:32:07 +0000 | [diff] [blame] | 247 | |
bsalomon | bce3d6d | 2014-07-02 07:54:42 -0700 | [diff] [blame^] | 248 | SkSTArray<kCmdPreallocCnt, uint8_t, true> fCmds; |
| 249 | |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 250 | GrDrawTarget* fDstGpu; |
bsalomon@google.com | 9780538 | 2012-03-13 14:32:07 +0000 | [diff] [blame] | 251 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 252 | bool fClipSet; |
| 253 | |
bsalomon@google.com | d62e88e | 2013-02-01 14:19:27 +0000 | [diff] [blame] | 254 | enum ClipProxyState { |
| 255 | kUnknown_ClipProxyState, |
| 256 | kValid_ClipProxyState, |
| 257 | kInvalid_ClipProxyState |
| 258 | }; |
| 259 | ClipProxyState fClipProxyState; |
| 260 | SkRect fClipProxy; |
| 261 | |
bsalomon@google.com | 934c570 | 2012-03-20 21:17:58 +0000 | [diff] [blame] | 262 | GrVertexBufferAllocPool& fVertexPool; |
| 263 | |
| 264 | GrIndexBufferAllocPool& fIndexPool; |
| 265 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 266 | struct GeometryPoolState { |
| 267 | const GrVertexBuffer* fPoolVertexBuffer; |
| 268 | int fPoolStartVertex; |
| 269 | const GrIndexBuffer* fPoolIndexBuffer; |
| 270 | int fPoolStartIndex; |
| 271 | // caller may conservatively over reserve vertices / indices. |
| 272 | // we release unused space back to allocator if possible |
| 273 | // can only do this if there isn't an intervening pushGeometrySource() |
| 274 | size_t fUsedPoolVertexBytes; |
| 275 | size_t fUsedPoolIndexBytes; |
| 276 | }; |
bsalomon@google.com | 9266901 | 2011-09-27 19:10:05 +0000 | [diff] [blame] | 277 | SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> fGeoPoolStateStack; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 278 | |
commit-bot@chromium.org | a8916ff | 2013-08-16 15:53:46 +0000 | [diff] [blame] | 279 | virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } |
skia.committer@gmail.com | 7475811 | 2013-08-17 07:01:54 +0000 | [diff] [blame] | 280 | |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 281 | void addToCmdBuffer(uint8_t cmd); |
| 282 | |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 283 | bool fFlushing; |
commit-bot@chromium.org | a8916ff | 2013-08-16 15:53:46 +0000 | [diff] [blame] | 284 | uint32_t fDrawID; |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 285 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 286 | typedef GrDrawTarget INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | #endif |