blob: 1e8b5a6d3c85bb578b320d2a146efb74fda7f1b6 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * 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.comac10a2d2010-12-22 21:39:39 +00006 */
7
reed@google.comac10a2d2010-12-22 21:39:39 +00008#ifndef GrInOrderDrawBuffer_DEFINED
9#define GrInOrderDrawBuffer_DEFINED
10
11#include "GrDrawTarget.h"
12#include "GrAllocPool.h"
13#include "GrAllocator.h"
bsalomonb3e3a952014-09-19 11:10:40 -070014#include "GrIndexBuffer.h"
15#include "GrRenderTarget.h"
bsalomon@google.comded4f4b2012-06-28 18:48:06 +000016#include "GrPath.h"
bsalomonb3e3a952014-09-19 11:10:40 -070017#include "GrPathRange.h"
18#include "GrSurface.h"
cdalton6819df32014-10-15 13:43:48 -070019#include "GrTRecorder.h"
bsalomonb3e3a952014-09-19 11:10:40 -070020#include "GrVertexBuffer.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000021
robertphillips@google.com641f8b12012-07-31 19:15:58 +000022#include "SkClipStack.h"
bsalomon@google.comded4f4b2012-06-28 18:48:06 +000023#include "SkTemplates.h"
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +000024#include "SkTypes.h"
bsalomon@google.comded4f4b2012-06-28 18:48:06 +000025
bsalomon@google.com471d4712011-08-23 15:45:25 +000026class GrGpu;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000027class GrIndexBufferAllocPool;
bsalomon@google.com471d4712011-08-23 15:45:25 +000028class GrVertexBufferAllocPool;
reed@google.comac10a2d2010-12-22 21:39:39 +000029
bsalomon@google.com1c13c962011-02-14 16:51:21 +000030/**
bsalomon@google.com55e4a202013-01-11 13:54:21 +000031 * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws for eventual
32 * playback into a GrGpu. In theory one draw buffer could playback into another. When index or
33 * vertex buffers are used as geometry sources it is the callers the draw buffer only holds
34 * references to the buffers. It is the callers responsibility to ensure that the data is still
35 * valid when the draw buffer is played back into a GrGpu. Similarly, it is the caller's
36 * responsibility to ensure that all referenced textures, buffers, and render-targets are associated
37 * in the GrGpu object that the buffer is played back into. The buffer requires VB and IB pools to
38 * store geometry.
skia.committer@gmail.com07d3a652013-04-10 07:01:15 +000039 */
joshualitt6db519c2014-10-29 08:48:18 -070040class GrInOrderDrawBuffer : public GrClipTarget {
reed@google.comac10a2d2010-12-22 21:39:39 +000041public:
42
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000043 /**
44 * Creates a GrInOrderDrawBuffer
45 *
bsalomon@google.com6e4e6502013-02-25 20:12:45 +000046 * @param gpu the gpu object that this draw buffer flushes to.
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000047 * @param vertexPool pool where vertices for queued draws will be saved when
48 * the vertex source is either reserved or array.
49 * @param indexPool pool where indices for queued draws will be saved when
50 * the index source is either reserved or array.
51 */
bsalomon@google.com6e4e6502013-02-25 20:12:45 +000052 GrInOrderDrawBuffer(GrGpu* gpu,
bsalomon@google.com471d4712011-08-23 15:45:25 +000053 GrVertexBufferAllocPool* vertexPool,
bsalomon@google.com1c13c962011-02-14 16:51:21 +000054 GrIndexBufferAllocPool* indexPool);
reed@google.comac10a2d2010-12-22 21:39:39 +000055
56 virtual ~GrInOrderDrawBuffer();
57
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000058 /**
bsalomon@google.com55e4a202013-01-11 13:54:21 +000059 * Empties the draw buffer of any queued up draws. This must not be called while inside an
60 * unbalanced pushGeometrySource(). The current draw state and clip are preserved.
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000061 */
62 void reset();
63
64 /**
bsalomon@google.com6e4e6502013-02-25 20:12:45 +000065 * This plays the queued up draws to its GrGpu target. It also resets this object (i.e. flushing
bsalomon@google.com55e4a202013-01-11 13:54:21 +000066 * is destructive). This buffer must not have an active reserved vertex or index source. Any
67 * reserved geometry on the target will be finalized because it's geometry source will be pushed
68 * before flushing and popped afterwards.
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000069 */
robertphillips@google.com1267fbd2013-07-03 18:37:27 +000070 void flush();
bsalomon@google.com97805382012-03-13 14:32:07 +000071
commit-bot@chromium.orga8916ff2013-08-16 15:53:46 +000072 // tracking for draws
73 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, fDrawID); }
74
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000075 // overrides from GrDrawTarget
jvanverth@google.comb75b0a02013-02-05 20:33:30 +000076 virtual bool geometryHints(int* vertexCount,
bsalomon@google.com97805382012-03-13 14:32:07 +000077 int* indexCount) const SK_OVERRIDE;
joshualitt6db519c2014-10-29 08:48:18 -070078
joshualitta7024152014-11-03 14:16:35 -080079 virtual bool copySurface(GrSurface* dst,
80 GrSurface* src,
81 const SkIRect& srcRect,
82 const SkIPoint& dstPoint) SK_OVERRIDE;
83
84 virtual bool canCopySurface(GrSurface* dst,
85 GrSurface* src,
86 const SkIRect& srcRect,
87 const SkIPoint& dstPoint) SK_OVERRIDE;
88
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000089 virtual void clear(const SkIRect* rect,
robertphillips@google.comc82a8b72012-06-21 20:15:48 +000090 GrColor color,
robertphillips@google.com56ce48a2013-10-31 21:44:25 +000091 bool canIgnoreRect,
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +000092 GrRenderTarget* renderTarget) SK_OVERRIDE;
93
joshualitt6db519c2014-10-29 08:48:18 -070094 virtual void clearStencilClip(const SkIRect& rect,
95 bool insideClip,
96 GrRenderTarget* renderTarget) SK_OVERRIDE;
97
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +000098 virtual void discard(GrRenderTarget*) SK_OVERRIDE;
bsalomon@google.com0b335c12011-04-25 19:17:44 +000099
bsalomonf2703d82014-10-28 14:33:06 -0700100 virtual void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) SK_OVERRIDE;
bsalomon@google.comeb851172013-04-15 13:51:00 +0000101
bsalomon@google.com97805382012-03-13 14:32:07 +0000102protected:
bsalomon@google.com02ddc8b2013-01-28 15:35:28 +0000103 virtual void clipWillBeSet(const GrClipData* newClip) SK_OVERRIDE;
104
reed@google.comac10a2d2010-12-22 21:39:39 +0000105private:
cdalton6819df32014-10-15 13:43:48 -0700106 enum {
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000107 kDraw_Cmd = 1,
108 kStencilPath_Cmd = 2,
109 kSetState_Cmd = 3,
110 kSetClip_Cmd = 4,
111 kClear_Cmd = 5,
bsalomon@google.com116ad842013-04-09 15:38:19 +0000112 kCopySurface_Cmd = 6,
commit-bot@chromium.org32184d82013-10-09 15:14:18 +0000113 kDrawPath_Cmd = 7,
commit-bot@chromium.org9b62aa12014-03-25 11:59:40 +0000114 kDrawPaths_Cmd = 8,
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000115 };
116
cdalton6819df32014-10-15 13:43:48 -0700117 struct Cmd : ::SkNoncopyable {
118 Cmd(uint8_t type) : fType(type) {}
119 virtual ~Cmd() {}
120
joshualitt6db519c2014-10-29 08:48:18 -0700121 virtual void execute(GrClipTarget*) = 0;
cdalton6819df32014-10-15 13:43:48 -0700122
123 uint8_t fType;
124 };
125
126 struct Draw : public Cmd {
bsalomonb3e3a952014-09-19 11:10:40 -0700127 Draw(const DrawInfo& info, const GrVertexBuffer* vb, const GrIndexBuffer* ib)
cdalton6819df32014-10-15 13:43:48 -0700128 : Cmd(kDraw_Cmd)
129 , fInfo(info)
bsalomon45725db2014-09-19 11:48:02 -0700130 , fVertexBuffer(vb)
131 , fIndexBuffer(ib) {}
bsalomonb3e3a952014-09-19 11:10:40 -0700132
133 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); }
134 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); }
135
joshualitt6db519c2014-10-29 08:48:18 -0700136 virtual void execute(GrClipTarget*);
cdalton6819df32014-10-15 13:43:48 -0700137
138 DrawInfo fInfo;
139
bsalomonb3e3a952014-09-19 11:10:40 -0700140 private:
bsalomonbcf0a522014-10-08 08:40:09 -0700141 GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuffer;
142 GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffer;
reed@google.comac10a2d2010-12-22 21:39:39 +0000143 };
144
cdalton6819df32014-10-15 13:43:48 -0700145 struct StencilPath : public Cmd {
146 StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {}
sugoi@google.com5f74cf82012-12-17 21:16:45 +0000147
bsalomonb3e3a952014-09-19 11:10:40 -0700148 const GrPath* path() const { return fPath.get(); }
149
joshualitt6db519c2014-10-29 08:48:18 -0700150 virtual void execute(GrClipTarget*);
cdalton6819df32014-10-15 13:43:48 -0700151
joshualitt92e496f2014-10-31 13:56:50 -0700152 GrPathRendering::FillType fFill;
bsalomonb3e3a952014-09-19 11:10:40 -0700153
154 private:
bsalomonbcf0a522014-10-08 08:40:09 -0700155 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000156 };
157
cdalton6819df32014-10-15 13:43:48 -0700158 struct DrawPath : public Cmd {
159 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {}
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000160
bsalomonb3e3a952014-09-19 11:10:40 -0700161 const GrPath* path() const { return fPath.get(); }
162
joshualitt6db519c2014-10-29 08:48:18 -0700163 virtual void execute(GrClipTarget*);
cdalton6819df32014-10-15 13:43:48 -0700164
joshualitt92e496f2014-10-31 13:56:50 -0700165 GrPathRendering::FillType fFill;
166 GrDeviceCoordTexture fDstCopy;
bsalomonb3e3a952014-09-19 11:10:40 -0700167
168 private:
bsalomonbcf0a522014-10-08 08:40:09 -0700169 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000170 };
171
cdalton6819df32014-10-15 13:43:48 -0700172 struct DrawPaths : public Cmd {
173 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRange(pathRange) {}
bsalomonb3e3a952014-09-19 11:10:40 -0700174
175 const GrPathRange* pathRange() const { return fPathRange.get(); }
cdalton6819df32014-10-15 13:43:48 -0700176 uint32_t* indices() { return reinterpret_cast<uint32_t*>(CmdBuffer::GetDataForItem(this)); }
177 float* transforms() { return reinterpret_cast<float*>(&this->indices()[fCount]); }
bsalomonb3e3a952014-09-19 11:10:40 -0700178
joshualitt6db519c2014-10-29 08:48:18 -0700179 virtual void execute(GrClipTarget*);
cdalton6819df32014-10-15 13:43:48 -0700180
joshualitt92e496f2014-10-31 13:56:50 -0700181 size_t fCount;
182 PathTransformType fTransformsType;
183 GrPathRendering::FillType fFill;
184 GrDeviceCoordTexture fDstCopy;
bsalomonb3e3a952014-09-19 11:10:40 -0700185
186 private:
bsalomonbcf0a522014-10-08 08:40:09 -0700187 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange;
commit-bot@chromium.org9b62aa12014-03-25 11:59:40 +0000188 };
189
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +0000190 // This is also used to record a discard by setting the color to GrColor_ILLEGAL
cdalton6819df32014-10-15 13:43:48 -0700191 struct Clear : public Cmd {
192 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {}
193
bsalomonb3e3a952014-09-19 11:10:40 -0700194 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
robertphillips@google.comc82a8b72012-06-21 20:15:48 +0000195
joshualitt6db519c2014-10-29 08:48:18 -0700196 virtual void execute(GrClipTarget*);
cdalton6819df32014-10-15 13:43:48 -0700197
bsalomonb3e3a952014-09-19 11:10:40 -0700198 SkIRect fRect;
199 GrColor fColor;
200 bool fCanIgnoreRect;
201
202 private:
bsalomonbcf0a522014-10-08 08:40:09 -0700203 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000204 };
205
joshualitt6db519c2014-10-29 08:48:18 -0700206 // This command is ONLY used by the clip mask manager to clear the stencil clip bits
207 struct ClearStencilClip : public Cmd {
208 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {}
209
210 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
211
212 virtual void execute(GrClipTarget*);
213
214 SkIRect fRect;
215 bool fInsideClip;
216
217 private:
218 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
219 };
220
cdalton6819df32014-10-15 13:43:48 -0700221 struct CopySurface : public Cmd {
222 CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDst(dst), fSrc(src) {}
bsalomonb3e3a952014-09-19 11:10:40 -0700223
224 GrSurface* dst() const { return fDst.get(); }
225 GrSurface* src() const { return fSrc.get(); }
226
joshualitt6db519c2014-10-29 08:48:18 -0700227 virtual void execute(GrClipTarget*);
cdalton6819df32014-10-15 13:43:48 -0700228
bsalomonb3e3a952014-09-19 11:10:40 -0700229 SkIPoint fDstPoint;
230 SkIRect fSrcRect;
231
232 private:
bsalomonbcf0a522014-10-08 08:40:09 -0700233 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst;
234 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
bsalomon@google.com116ad842013-04-09 15:38:19 +0000235 };
236
cdalton6819df32014-10-15 13:43:48 -0700237 struct SetState : public Cmd {
238 SetState(const GrDrawState& state) : Cmd(kSetState_Cmd), fState(state) {}
239
joshualitt6db519c2014-10-29 08:48:18 -0700240 virtual void execute(GrClipTarget*);
cdalton6819df32014-10-15 13:43:48 -0700241
242 GrDrawState fState;
bsalomonf0480b12014-07-02 12:11:24 -0700243 };
244
cdalton6819df32014-10-15 13:43:48 -0700245 struct SetClip : public Cmd {
246 SetClip(const GrClipData* clipData)
247 : Cmd(kSetClip_Cmd),
248 fStackStorage(*clipData->fClipStack) {
249 fClipData.fClipStack = &fStackStorage;
250 fClipData.fOrigin = clipData->fOrigin;
251 }
252
joshualitt6db519c2014-10-29 08:48:18 -0700253 virtual void execute(GrClipTarget*);
cdalton6819df32014-10-15 13:43:48 -0700254
255 GrClipData fClipData;
256
257 private:
258 SkClipStack fStackStorage;
259 };
260
261 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
262 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
263
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000264 // overrides from GrDrawTarget
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000265 virtual void onDraw(const DrawInfo&) SK_OVERRIDE;
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +0000266 virtual void onDrawRect(const SkRect& rect,
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +0000267 const SkRect* localRect,
bsalomon@google.com0406b9e2013-04-02 21:00:15 +0000268 const SkMatrix* localMatrix) SK_OVERRIDE;
commit-bot@chromium.org32184d82013-10-09 15:14:18 +0000269
joshualitt92e496f2014-10-31 13:56:50 -0700270 virtual void onStencilPath(const GrPath*, GrPathRendering::FillType) SK_OVERRIDE;
271 virtual void onDrawPath(const GrPath*, GrPathRendering::FillType,
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000272 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
cdaltonb85a0aa2014-07-21 15:32:44 -0700273 virtual void onDrawPaths(const GrPathRange*,
274 const uint32_t indices[], int count,
275 const float transforms[], PathTransformType,
joshualitt92e496f2014-10-31 13:56:50 -0700276 GrPathRendering::FillType, const GrDeviceCoordTexture*) SK_OVERRIDE;
commit-bot@chromium.org32184d82013-10-09 15:14:18 +0000277
jvanverth@google.coma6338982013-01-31 21:34:25 +0000278 virtual bool onReserveVertexSpace(size_t vertexSize,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000279 int vertexCount,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +0000280 void** vertices) SK_OVERRIDE;
281 virtual bool onReserveIndexSpace(int indexCount,
282 void** indices) SK_OVERRIDE;
283 virtual void releaseReservedVertexSpace() SK_OVERRIDE;
284 virtual void releaseReservedIndexSpace() SK_OVERRIDE;
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000285 virtual void onSetVertexSourceToArray(const void* vertexArray,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +0000286 int vertexCount) SK_OVERRIDE;
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000287 virtual void onSetIndexSourceToArray(const void* indexArray,
bsalomon@google.com13f1b6f2012-05-31 12:52:43 +0000288 int indexCount) SK_OVERRIDE;
289 virtual void releaseVertexArray() SK_OVERRIDE;
290 virtual void releaseIndexArray() SK_OVERRIDE;
291 virtual void geometrySourceWillPush() SK_OVERRIDE;
bsalomon@google.com02ddc8b2013-01-28 15:35:28 +0000292 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK_OVERRIDE;
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000293 virtual void willReserveVertexAndIndexSpace(int vertexCount,
bsalomon@google.com02ddc8b2013-01-28 15:35:28 +0000294 int indexCount) SK_OVERRIDE;
bsalomon@google.com116ad842013-04-09 15:38:19 +0000295
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000296 bool quickInsideClip(const SkRect& devBounds);
bsalomon@google.com02ddc8b2013-01-28 15:35:28 +0000297
commit-bot@chromium.org2a05de02014-03-25 15:17:32 +0000298 virtual void didAddGpuTraceMarker() SK_OVERRIDE {}
299 virtual void didRemoveGpuTraceMarker() SK_OVERRIDE {}
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000300
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000301 // Attempts to concat instances from info onto the previous draw. info must represent an
302 // instanced draw. The caller must have already recorded a new draw state and clip if necessary.
303 int concatInstancedDraw(const DrawInfo& info);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000304
bsalomon838f62d2014-08-05 07:15:57 -0700305 // Determines whether the current draw operation requieres a new drawstate and if so records it.
306 void recordStateIfNecessary();
307 // We lazily record clip changes in order to skip clips that have no effect.
cdalton6819df32014-10-15 13:43:48 -0700308 void recordClipIfNecessary();
309 // Records any trace markers for a command after adding it to the buffer.
310 void recordTraceMarkersIfNecessary();
bsalomonb3e3a952014-09-19 11:10:40 -0700311
312 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; }
bsalomon@google.com934c5702012-03-20 21:17:58 +0000313
bsalomon@google.com116ad842013-04-09 15:38:19 +0000314 // TODO: Use a single allocator for commands and records
bsalomon@google.com4b90c622011-09-28 17:52:15 +0000315 enum {
cdalton6819df32014-10-15 13:43:48 -0700316 kCmdBufferInitialSizeInBytes = 64 * 1024,
317 kGeoPoolStatePreAllocCnt = 4,
bsalomon@google.com4b90c622011-09-28 17:52:15 +0000318 };
reed@google.comac10a2d2010-12-22 21:39:39 +0000319
cdalton6819df32014-10-15 13:43:48 -0700320 CmdBuffer fCmdBuffer;
321 GrDrawState* fLastState;
322 GrClipData* fLastClip;
bsalomonbce3d6d2014-07-02 07:54:42 -0700323
cdalton6819df32014-10-15 13:43:48 -0700324 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers;
joshualitt6db519c2014-10-29 08:48:18 -0700325 GrClipTarget* fDstGpu;
cdalton6819df32014-10-15 13:43:48 -0700326 bool fClipSet;
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000327
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000328 enum ClipProxyState {
329 kUnknown_ClipProxyState,
330 kValid_ClipProxyState,
331 kInvalid_ClipProxyState
332 };
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000333
bsalomonb3e3a952014-09-19 11:10:40 -0700334 ClipProxyState fClipProxyState;
335 SkRect fClipProxy;
336 GrVertexBufferAllocPool& fVertexPool;
337 GrIndexBufferAllocPool& fIndexPool;
bsalomon@google.com934c5702012-03-20 21:17:58 +0000338
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000339 struct GeometryPoolState {
bsalomonb3e3a952014-09-19 11:10:40 -0700340 const GrVertexBuffer* fPoolVertexBuffer;
341 int fPoolStartVertex;
342 const GrIndexBuffer* fPoolIndexBuffer;
343 int fPoolStartIndex;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000344 // caller may conservatively over reserve vertices / indices.
345 // we release unused space back to allocator if possible
346 // can only do this if there isn't an intervening pushGeometrySource()
bsalomonb3e3a952014-09-19 11:10:40 -0700347 size_t fUsedPoolVertexBytes;
348 size_t fUsedPoolIndexBytes;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000349 };
reed@google.comac10a2d2010-12-22 21:39:39 +0000350
bsalomonb3e3a952014-09-19 11:10:40 -0700351 typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateStack;
skia.committer@gmail.com74758112013-08-17 07:01:54 +0000352
bsalomonb3e3a952014-09-19 11:10:40 -0700353 GeoPoolStateStack fGeoPoolStateStack;
354 bool fFlushing;
355 uint32_t fDrawID;
robertphillips@google.comc82a8b72012-06-21 20:15:48 +0000356
joshualitt6db519c2014-10-29 08:48:18 -0700357 typedef GrClipTarget INHERITED;
reed@google.comac10a2d2010-12-22 21:39:39 +0000358};
359
360#endif