blob: 0ebf81055f23680daa3520781199216a4f721bee [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
10#include "GrInOrderDrawBuffer.h"
bsalomon@google.comded4f4b2012-06-28 18:48:06 +000011#include "GrBufferAllocPool.h"
12#include "GrGpu.h"
13#include "GrIndexBuffer.h"
14#include "GrPath.h"
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000015#include "GrRenderTarget.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000016#include "GrTexture.h"
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000017#include "GrVertexBuffer.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000018
bsalomon@google.com471d4712011-08-23 15:45:25 +000019GrInOrderDrawBuffer::GrInOrderDrawBuffer(const GrGpu* gpu,
20 GrVertexBufferAllocPool* vertexPool,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000021 GrIndexBufferAllocPool* indexPool)
bsalomon@google.com97805382012-03-13 14:32:07 +000022 : fAutoFlushTarget(NULL)
23 , fClipSet(true)
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000024 , fClipProxyState(kUnknown_ClipProxyState)
robertphillips@google.com69705572012-03-21 19:46:50 +000025 , fVertexPool(*vertexPool)
26 , fIndexPool(*indexPool)
robertphillips@google.comc82a8b72012-06-21 20:15:48 +000027 , fFlushing(false) {
bsalomon@google.com18c9c192011-09-22 21:01:31 +000028
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000029 fGpu.reset(SkRef(gpu));
bsalomon@google.com18c9c192011-09-22 21:01:31 +000030 fCaps = gpu->getCaps();
31
bsalomon@google.com1c13c962011-02-14 16:51:21 +000032 GrAssert(NULL != vertexPool);
33 GrAssert(NULL != indexPool);
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000034
35 GeometryPoolState& poolState = fGeoPoolStateStack.push_back();
36 poolState.fUsedPoolVertexBytes = 0;
37 poolState.fUsedPoolIndexBytes = 0;
38#if GR_DEBUG
39 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0;
40 poolState.fPoolStartVertex = ~0;
41 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0;
42 poolState.fPoolStartIndex = ~0;
43#endif
bsalomon@google.coma4f6b102012-06-26 21:04:22 +000044 this->reset();
reed@google.comac10a2d2010-12-22 21:39:39 +000045}
46
47GrInOrderDrawBuffer::~GrInOrderDrawBuffer() {
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000048 this->reset();
bsalomon@google.com4a018bb2011-10-28 19:50:21 +000049 // This must be called by before the GrDrawTarget destructor
50 this->releaseGeometry();
bsalomon@google.com97805382012-03-13 14:32:07 +000051 GrSafeUnref(fAutoFlushTarget);
reed@google.comac10a2d2010-12-22 21:39:39 +000052}
53
bsalomon@google.com934c5702012-03-20 21:17:58 +000054////////////////////////////////////////////////////////////////////////////////
55
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000056namespace {
57void get_vertex_bounds(const void* vertices,
58 size_t vertexSize,
59 int vertexCount,
60 SkRect* bounds) {
61 GrAssert(vertexSize >= sizeof(GrPoint));
62 GrAssert(vertexCount > 0);
63 const GrPoint* point = static_cast<const GrPoint*>(vertices);
64 bounds->fLeft = bounds->fRight = point->fX;
65 bounds->fTop = bounds->fBottom = point->fY;
66 for (int i = 1; i < vertexCount; ++i) {
67 point = reinterpret_cast<GrPoint*>(reinterpret_cast<intptr_t>(point) + vertexSize);
68 bounds->growToInclude(point->fX, point->fY);
69 }
70}
bsalomon@google.com934c5702012-03-20 21:17:58 +000071}
72
bsalomon@google.comd302f142011-03-03 13:54:13 +000073void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
bsalomon@google.comb9086a02012-11-01 18:02:54 +000074 const SkMatrix* matrix,
jvanverth@google.com39768252013-02-14 15:25:44 +000075 const GrRect* srcRect,
76 const SkMatrix* srcMatrix,
77 int stage) {
bsalomon@google.comd302f142011-03-03 13:54:13 +000078
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000079 GrVertexLayout layout = 0;
80 GrDrawState::AutoColorRestore acr;
81 GrColor color = this->drawState()->getColor();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000082
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000083 // Using per-vertex colors allows batching across colors. (A lot of rects in a row differing
84 // only in color is a common occurrence in tables). However, having per-vertex colors disables
85 // blending optimizations because we don't know if the color will be solid or not. These
86 // optimizations help determine whether coverage and color can be blended correctly when
87 // dual-source blending isn't available. This comes into play when there is coverage. If colors
88 // were a stage it could take a hint that every vertex's color will be opaque.
89 if (this->getCaps().dualSourceBlendingSupport() ||
jvanverth@google.comb75b0a02013-02-05 20:33:30 +000090 this->getDrawState().hasSolidCoverage(this->getDrawState().getVertexLayout())) {
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000091 layout |= GrDrawState::kColor_VertexLayoutBit;;
92 // We set the draw state's color to white here. This is done so that any batching performed
93 // in our subclass's onDraw() won't get a false from GrDrawState::op== due to a color
94 // mismatch. TODO: Once vertex layout is owned by GrDrawState it should skip comparing the
95 // constant color in its op== when the kColor layout bit is set and then we can remove this.
96 acr.set(this->drawState(), 0xFFFFFFFF);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000097 }
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000098
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000099 uint32_t explicitCoordMask = 0;
jvanverth@google.com39768252013-02-14 15:25:44 +0000100 if (NULL != srcRect) {
101 layout |= GrDrawState::StageTexCoordVertexLayoutBit(stage);
102 explicitCoordMask = (1 << stage);
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000103 }
104
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000105 this->drawState()->setVertexLayout(layout);
106 AutoReleaseGeometry geo(this, 4, 0);
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000107 if (!geo.succeeded()) {
108 GrPrintf("Failed to get space for vertices!\n");
bsalomon@google.com934c5702012-03-20 21:17:58 +0000109 return;
110 }
111
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000112 // Go to device coords to allow batching across matrix changes
113 SkMatrix combinedMatrix;
114 if (NULL != matrix) {
115 combinedMatrix = *matrix;
116 } else {
117 combinedMatrix.reset();
118 }
119 combinedMatrix.postConcat(this->drawState()->getViewMatrix());
jvanverth@google.com39768252013-02-14 15:25:44 +0000120 // When the caller has provided an explicit source rect for a stage then we don't want to
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000121 // modify that stage's matrix. Otherwise if the effect is generating its source rect from
122 // the vertex positions then we have to account for the view matrix change.
123 GrDrawState::AutoDeviceCoordDraw adcd(this->drawState(), explicitCoordMask);
124 if (!adcd.succeeded()) {
125 return;
126 }
127
128 int stageOffsets[GrDrawState::kNumStages], colorOffset;
129 int vsize = GrDrawState::VertexSizeAndOffsetsByStage(layout, stageOffsets,
130 &colorOffset, NULL, NULL);
131
132 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vsize);
133 combinedMatrix.mapPointsWithStride(geo.positions(), vsize, 4);
134
135 SkRect devBounds;
136 // since we already computed the dev verts, set the bounds hint. This will help us avoid
137 // unnecessary clipping in our onDraw().
138 get_vertex_bounds(geo.vertices(), vsize, 4, &devBounds);
139
140 for (int i = 0; i < GrDrawState::kNumStages; ++i) {
141 if (explicitCoordMask & (1 << i)) {
reed@google.com009dfe22013-02-01 15:05:18 +0000142 GrAssert(0 != stageOffsets[i]);
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000143 GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) +
144 stageOffsets[i]);
jvanverth@google.com39768252013-02-14 15:25:44 +0000145 coords->setRectFan(srcRect->fLeft, srcRect->fTop,
146 srcRect->fRight, srcRect->fBottom,
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000147 vsize);
jvanverth@google.com39768252013-02-14 15:25:44 +0000148 if (NULL != srcMatrix) {
149 srcMatrix->mapPointsWithStride(coords, vsize, 4);
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000150 }
151 } else {
reed@google.com009dfe22013-02-01 15:05:18 +0000152 GrAssert(0 == stageOffsets[i]);
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000153 }
154 }
155
156 if (colorOffset >= 0) {
157 GrColor* vertColor = GrTCast<GrColor*>(GrTCast<intptr_t>(geo.vertices()) + colorOffset);
158 for (int i = 0; i < 4; ++i) {
159 *vertColor = color;
160 vertColor = (GrColor*) ((intptr_t) vertColor + vsize);
161 }
162 }
163
164 this->setIndexSourceToBuffer(fGpu->getQuadIndexBuffer());
165 this->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds);
166}
167
168bool GrInOrderDrawBuffer::quickInsideClip(const SkRect& devBounds) {
169 if (!this->getDrawState().isClipState()) {
170 return true;
171 }
172 if (kUnknown_ClipProxyState == fClipProxyState) {
173 SkIRect rect;
174 bool iior;
175 this->getClip()->getConservativeBounds(this->getDrawState().getRenderTarget(), &rect, &iior);
176 if (iior) {
177 // The clip is a rect. We will remember that in fProxyClip. It is common for an edge (or
178 // all edges) of the clip to be at the edge of the RT. However, we get that clipping for
179 // free via the viewport. We don't want to think that clipping must be enabled in this
180 // case. So we extend the clip outward from the edge to avoid these false negatives.
181 fClipProxyState = kValid_ClipProxyState;
182 fClipProxy = SkRect::MakeFromIRect(rect);
183
184 if (fClipProxy.fLeft <= 0) {
185 fClipProxy.fLeft = SK_ScalarMin;
186 }
187 if (fClipProxy.fTop <= 0) {
188 fClipProxy.fTop = SK_ScalarMin;
189 }
190 if (fClipProxy.fRight >= this->getDrawState().getRenderTarget()->width()) {
191 fClipProxy.fRight = SK_ScalarMax;
192 }
193 if (fClipProxy.fBottom >= this->getDrawState().getRenderTarget()->height()) {
194 fClipProxy.fBottom = SK_ScalarMax;
195 }
196 } else {
197 fClipProxyState = kInvalid_ClipProxyState;
198 }
199 }
200 if (kValid_ClipProxyState == fClipProxyState) {
201 return fClipProxy.contains(devBounds);
202 }
203 SkPoint originOffset = {SkIntToScalar(this->getClip()->fOrigin.fX),
204 SkIntToScalar(this->getClip()->fOrigin.fY)};
205 SkRect clipSpaceBounds = devBounds;
206 clipSpaceBounds.offset(originOffset);
207 return this->getClip()->fClipStack->quickContains(clipSpaceBounds);
208}
209
210int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info) {
211 GrAssert(info.isInstanced());
212
bsalomon@google.com934c5702012-03-20 21:17:58 +0000213 const GeometrySrcState& geomSrc = this->getGeomSrc();
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000214 const GrDrawState& drawState = this->getDrawState();
bsalomon@google.com934c5702012-03-20 21:17:58 +0000215
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000216 // we only attempt to concat the case when reserved verts are used with a client-specified index
217 // buffer. To make this work with client-specified VBs we'd need to know if the VB was updated
218 // between draws.
219 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc ||
220 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) {
221 return 0;
bsalomon@google.com934c5702012-03-20 21:17:58 +0000222 }
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000223 // Check if there is a draw info that is compatible that uses the same VB from the pool and
224 // the same IB
225 if (kDraw_Cmd != fCmds.back()) {
226 return 0;
227 }
228
229 DrawRecord* draw = &fDraws.back();
230 GeometryPoolState& poolState = fGeoPoolStateStack.back();
231 const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer;
232
233 if (!draw->isInstanced() ||
234 draw->verticesPerInstance() != info.verticesPerInstance() ||
235 draw->indicesPerInstance() != info.indicesPerInstance() ||
236 draw->fVertexBuffer != vertexBuffer ||
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000237 draw->fIndexBuffer != geomSrc.fIndexBuffer) {
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000238 return 0;
239 }
240 // info does not yet account for the offset from the start of the pool's VB while the previous
241 // draw record does.
242 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex();
243 if (draw->startVertex() + draw->vertexCount() != adjustedStartVertex) {
244 return 0;
245 }
246
247 GrAssert(poolState.fPoolStartVertex == draw->startVertex() + draw->vertexCount());
248
249 // how many instances can be concat'ed onto draw given the size of the index buffer
250 int instancesToConcat = this->indexCountInCurrentSource() / info.indicesPerInstance();
251 instancesToConcat -= draw->instanceCount();
252 instancesToConcat = GrMin(instancesToConcat, info.instanceCount());
253
254 // update the amount of reserved vertex data actually referenced in draws
skia.committer@gmail.comae683922013-02-06 07:01:54 +0000255 size_t vertexBytes = instancesToConcat * info.verticesPerInstance() *
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000256 drawState.getVertexSize();
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000257 poolState.fUsedPoolVertexBytes = GrMax(poolState.fUsedPoolVertexBytes, vertexBytes);
258
259 draw->adjustInstanceCount(instancesToConcat);
260 return instancesToConcat;
bsalomon@google.com934c5702012-03-20 21:17:58 +0000261}
262
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000263class AutoClipReenable {
264public:
265 AutoClipReenable() : fDrawState(NULL) {}
266 ~AutoClipReenable() {
267 if (NULL != fDrawState) {
268 fDrawState->enableState(GrDrawState::kClip_StateBit);
269 }
270 }
271 void set(GrDrawState* drawState) {
272 if (drawState->isClipState()) {
273 fDrawState = drawState;
274 drawState->disableState(GrDrawState::kClip_StateBit);
275 }
276 }
277private:
278 GrDrawState* fDrawState;
279};
280
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000281void GrInOrderDrawBuffer::onDraw(const DrawInfo& info) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000282
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000283 GeometryPoolState& poolState = fGeoPoolStateStack.back();
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000284 const GrDrawState& drawState = this->getDrawState();
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000285 AutoClipReenable acr;
286
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000287 if (drawState.isClipState() &&
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000288 NULL != info.getDevBounds() &&
289 this->quickInsideClip(*info.getDevBounds())) {
290 acr.set(this->drawState());
291 }
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000292
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000293 if (this->needsNewClip()) {
294 this->recordClip();
295 }
296 if (this->needsNewState()) {
297 this->recordState();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000298 }
299
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000300 DrawRecord* draw;
301 if (info.isInstanced()) {
302 int instancesConcated = this->concatInstancedDraw(info);
303 if (info.instanceCount() > instancesConcated) {
304 draw = this->recordDraw(info);
305 draw->adjustInstanceCount(-instancesConcated);
306 } else {
307 return;
308 }
309 } else {
310 draw = this->recordDraw(info);
311 }
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000312
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000313 switch (this->getGeomSrc().fVertexSrc) {
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000314 case kBuffer_GeometrySrcType:
315 draw->fVertexBuffer = this->getGeomSrc().fVertexBuffer;
316 break;
317 case kReserved_GeometrySrcType: // fallthrough
318 case kArray_GeometrySrcType: {
skia.committer@gmail.comae683922013-02-06 07:01:54 +0000319 size_t vertexBytes = (info.vertexCount() + info.startVertex()) *
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000320 drawState.getVertexSize();
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000321 poolState.fUsedPoolVertexBytes = GrMax(poolState.fUsedPoolVertexBytes, vertexBytes);
322 draw->fVertexBuffer = poolState.fPoolVertexBuffer;
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000323 draw->adjustStartVertex(poolState.fPoolStartVertex);
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000324 break;
325 }
326 default:
327 GrCrash("unknown geom src type");
reed@google.comac10a2d2010-12-22 21:39:39 +0000328 }
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000329 draw->fVertexBuffer->ref();
reed@google.comac10a2d2010-12-22 21:39:39 +0000330
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000331 if (info.isIndexed()) {
332 switch (this->getGeomSrc().fIndexSrc) {
333 case kBuffer_GeometrySrcType:
334 draw->fIndexBuffer = this->getGeomSrc().fIndexBuffer;
335 break;
336 case kReserved_GeometrySrcType: // fallthrough
337 case kArray_GeometrySrcType: {
338 size_t indexBytes = (info.indexCount() + info.startIndex()) * sizeof(uint16_t);
339 poolState.fUsedPoolIndexBytes = GrMax(poolState.fUsedPoolIndexBytes, indexBytes);
340 draw->fIndexBuffer = poolState.fPoolIndexBuffer;
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000341 draw->adjustStartIndex(poolState.fPoolStartIndex);
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000342 break;
343 }
344 default:
345 GrCrash("unknown geom src type");
346 }
347 draw->fIndexBuffer->ref();
348 } else {
349 draw->fIndexBuffer = NULL;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000350 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000351}
352
sugoi@google.com5f74cf82012-12-17 21:16:45 +0000353GrInOrderDrawBuffer::StencilPath::StencilPath() : fStroke(SkStrokeRec::kFill_InitStyle) {}
354
355void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, const SkStrokeRec& stroke,
sugoi@google.com12b4e272012-12-06 20:13:11 +0000356 SkPath::FillType fill) {
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000357 if (this->needsNewClip()) {
358 this->recordClip();
359 }
360 // Only compare the subset of GrDrawState relevant to path stenciling?
361 if (this->needsNewState()) {
362 this->recordState();
363 }
364 StencilPath* sp = this->recordStencilPath();
365 sp->fPath.reset(path);
366 path->ref();
367 sp->fFill = fill;
sugoi@google.com12b4e272012-12-06 20:13:11 +0000368 sp->fStroke = stroke;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +0000369}
370
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000371void GrInOrderDrawBuffer::clear(const GrIRect* rect, GrColor color, GrRenderTarget* renderTarget) {
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000372 GrIRect r;
bsalomon@google.com1b3ce472012-08-17 13:43:08 +0000373 if (NULL == renderTarget) {
374 renderTarget = this->drawState()->getRenderTarget();
375 GrAssert(NULL != renderTarget);
376 }
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000377 if (NULL == rect) {
378 // We could do something smart and remove previous draws and clears to
379 // the current render target. If we get that smart we have to make sure
380 // those draws aren't read before this clear (render-to-texture).
bsalomon@google.com1b3ce472012-08-17 13:43:08 +0000381 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height());
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000382 rect = &r;
383 }
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000384 Clear* clr = this->recordClear();
385 clr->fColor = color;
386 clr->fRect = *rect;
387 clr->fRenderTarget = renderTarget;
bsalomon@google.com1b3ce472012-08-17 13:43:08 +0000388 renderTarget->ref();
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000389}
390
reed@google.comac10a2d2010-12-22 21:39:39 +0000391void GrInOrderDrawBuffer::reset() {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000392 GrAssert(1 == fGeoPoolStateStack.count());
393 this->resetVertexSource();
394 this->resetIndexSource();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000395 int numDraws = fDraws.count();
396 for (int d = 0; d < numDraws; ++d) {
397 // we always have a VB, but not always an IB
398 GrAssert(NULL != fDraws[d].fVertexBuffer);
399 fDraws[d].fVertexBuffer->unref();
400 GrSafeUnref(fDraws[d].fIndexBuffer);
401 }
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000402 fCmds.reset();
reed@google.comac10a2d2010-12-22 21:39:39 +0000403 fDraws.reset();
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000404 fStencilPaths.reset();
reed@google.comac10a2d2010-12-22 21:39:39 +0000405 fStates.reset();
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000406 fClears.reset();
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000407 fVertexPool.reset();
408 fIndexPool.reset();
reed@google.comac10a2d2010-12-22 21:39:39 +0000409 fClips.reset();
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000410 fClipOrigins.reset();
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000411 fClipSet = true;
reed@google.comac10a2d2010-12-22 21:39:39 +0000412}
413
bsalomon@google.com55e4a202013-01-11 13:54:21 +0000414bool GrInOrderDrawBuffer::flushTo(GrDrawTarget* target) {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000415 GrAssert(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc);
416 GrAssert(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc);
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000417
reed@google.comac10a2d2010-12-22 21:39:39 +0000418 GrAssert(NULL != target);
419 GrAssert(target != this); // not considered and why?
420
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000421 int numCmds = fCmds.count();
bsalomon@google.com358e4272013-01-10 14:40:28 +0000422 if (0 == numCmds) {
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000423 return false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000424 }
425
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000426 fVertexPool.unlock();
427 fIndexPool.unlock();
reed@google.comac10a2d2010-12-22 21:39:39 +0000428
reed@google.comac10a2d2010-12-22 21:39:39 +0000429 GrDrawTarget::AutoClipRestore acr(target);
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000430 AutoGeometryAndStatePush agasp(target, kPreserve_ASRInit);
bsalomon@google.comca432082013-01-23 19:53:46 +0000431
432 GrDrawState playbackState;
bsalomon@google.coma5d056a2012-03-27 15:59:58 +0000433 GrDrawState* prevDrawState = target->drawState();
434 prevDrawState->ref();
bsalomon@google.comca432082013-01-23 19:53:46 +0000435 target->setDrawState(&playbackState);
reed@google.comac10a2d2010-12-22 21:39:39 +0000436
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000437 GrClipData clipData;
438
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000439 int currState = 0;
440 int currClip = 0;
441 int currClear = 0;
442 int currDraw = 0;
443 int currStencilPath = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +0000444
bsalomon@google.comca432082013-01-23 19:53:46 +0000445
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000446 for (int c = 0; c < numCmds; ++c) {
447 switch (fCmds[c]) {
448 case kDraw_Cmd: {
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000449 const DrawRecord& draw = fDraws[currDraw];
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000450 target->setVertexSourceToBuffer(draw.fVertexBuffer);
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000451 if (draw.isIndexed()) {
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000452 target->setIndexSourceToBuffer(draw.fIndexBuffer);
453 }
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000454 target->executeDraw(draw);
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000455
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000456 ++currDraw;
457 break;
458 }
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000459 case kStencilPath_Cmd: {
460 const StencilPath& sp = fStencilPaths[currStencilPath];
sugoi@google.com12b4e272012-12-06 20:13:11 +0000461 target->stencilPath(sp.fPath.get(), sp.fStroke, sp.fFill);
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000462 ++currStencilPath;
463 break;
464 }
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000465 case kSetState_Cmd:
bsalomon@google.comca432082013-01-23 19:53:46 +0000466 fStates[currState].restoreTo(&playbackState);
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000467 ++currState;
468 break;
469 case kSetClip_Cmd:
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000470 clipData.fClipStack = &fClips[currClip];
471 clipData.fOrigin = fClipOrigins[currClip];
472 target->setClip(&clipData);
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000473 ++currClip;
474 break;
475 case kClear_Cmd:
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000476 target->clear(&fClears[currClear].fRect,
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000477 fClears[currClear].fColor,
478 fClears[currClear].fRenderTarget);
479 ++currClear;
480 break;
reed@google.comac10a2d2010-12-22 21:39:39 +0000481 }
482 }
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000483 // we should have consumed all the states, clips, etc.
484 GrAssert(fStates.count() == currState);
485 GrAssert(fClips.count() == currClip);
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000486 GrAssert(fClipOrigins.count() == currClip);
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000487 GrAssert(fClears.count() == currClear);
488 GrAssert(fDraws.count() == currDraw);
489
bsalomon@google.coma5d056a2012-03-27 15:59:58 +0000490 target->setDrawState(prevDrawState);
491 prevDrawState->unref();
bsalomon@google.com55e4a202013-01-11 13:54:21 +0000492 this->reset();
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000493 return true;
reed@google.comac10a2d2010-12-22 21:39:39 +0000494}
495
bsalomon@google.com97805382012-03-13 14:32:07 +0000496void GrInOrderDrawBuffer::setAutoFlushTarget(GrDrawTarget* target) {
497 GrSafeAssign(fAutoFlushTarget, target);
498}
499
500void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(
bsalomon@google.com97805382012-03-13 14:32:07 +0000501 int vertexCount,
502 int indexCount) {
503 if (NULL != fAutoFlushTarget) {
504 // We use geometryHints() to know whether to flush the draw buffer. We
505 // can't flush if we are inside an unbalanced pushGeometrySource.
506 // Moreover, flushing blows away vertex and index data that was
507 // previously reserved. So if the vertex or index data is pulled from
508 // reserved space and won't be released by this request then we can't
509 // flush.
510 bool insideGeoPush = fGeoPoolStateStack.count() > 1;
511
512 bool unreleasedVertexSpace =
513 !vertexCount &&
514 kReserved_GeometrySrcType == this->getGeomSrc().fVertexSrc;
515
516 bool unreleasedIndexSpace =
517 !indexCount &&
518 kReserved_GeometrySrcType == this->getGeomSrc().fIndexSrc;
519
520 // we don't want to finalize any reserved geom on the target since
521 // we don't know that the client has finished writing to it.
522 bool targetHasReservedGeom =
523 fAutoFlushTarget->hasReservedVerticesOrIndices();
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000524
bsalomon@google.com97805382012-03-13 14:32:07 +0000525 int vcount = vertexCount;
526 int icount = indexCount;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000527
bsalomon@google.com97805382012-03-13 14:32:07 +0000528 if (!insideGeoPush &&
529 !unreleasedVertexSpace &&
530 !unreleasedIndexSpace &&
531 !targetHasReservedGeom &&
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000532 this->geometryHints(&vcount, &icount)) {
bsalomon@google.com97805382012-03-13 14:32:07 +0000533
534 this->flushTo(fAutoFlushTarget);
535 }
536 }
537}
538
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000539bool GrInOrderDrawBuffer::geometryHints(int* vertexCount,
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000540 int* indexCount) const {
541 // we will recommend a flush if the data could fit in a single
542 // preallocated buffer but none are left and it can't fit
543 // in the current buffer (which may not be prealloced).
reed@google.comac10a2d2010-12-22 21:39:39 +0000544 bool flush = false;
545 if (NULL != indexCount) {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000546 int32_t currIndices = fIndexPool.currentBufferIndices();
547 if (*indexCount > currIndices &&
548 (!fIndexPool.preallocatedBuffersRemaining() &&
549 *indexCount <= fIndexPool.preallocatedBufferIndices())) {
550
551 flush = true;
552 }
553 *indexCount = currIndices;
reed@google.comac10a2d2010-12-22 21:39:39 +0000554 }
555 if (NULL != vertexCount) {
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000556 size_t vertexSize = this->getDrawState().getVertexSize();
jvanverth@google.coma6338982013-01-31 21:34:25 +0000557 int32_t currVertices = fVertexPool.currentBufferVertices(vertexSize);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000558 if (*vertexCount > currVertices &&
559 (!fVertexPool.preallocatedBuffersRemaining() &&
jvanverth@google.coma6338982013-01-31 21:34:25 +0000560 *vertexCount <= fVertexPool.preallocatedBufferVertices(vertexSize))) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000561
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000562 flush = true;
reed@google.comac10a2d2010-12-22 21:39:39 +0000563 }
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000564 *vertexCount = currVertices;
reed@google.comac10a2d2010-12-22 21:39:39 +0000565 }
566 return flush;
567}
568
jvanverth@google.coma6338982013-01-31 21:34:25 +0000569bool GrInOrderDrawBuffer::onReserveVertexSpace(size_t vertexSize,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000570 int vertexCount,
571 void** vertices) {
572 GeometryPoolState& poolState = fGeoPoolStateStack.back();
573 GrAssert(vertexCount > 0);
574 GrAssert(NULL != vertices);
575 GrAssert(0 == poolState.fUsedPoolVertexBytes);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000576
jvanverth@google.coma6338982013-01-31 21:34:25 +0000577 *vertices = fVertexPool.makeSpace(vertexSize,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000578 vertexCount,
579 &poolState.fPoolVertexBuffer,
580 &poolState.fPoolStartVertex);
581 return NULL != *vertices;
582}
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000583
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000584bool GrInOrderDrawBuffer::onReserveIndexSpace(int indexCount, void** indices) {
585 GeometryPoolState& poolState = fGeoPoolStateStack.back();
586 GrAssert(indexCount > 0);
587 GrAssert(NULL != indices);
588 GrAssert(0 == poolState.fUsedPoolIndexBytes);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000589
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000590 *indices = fIndexPool.makeSpace(indexCount,
591 &poolState.fPoolIndexBuffer,
592 &poolState.fPoolStartIndex);
593 return NULL != *indices;
reed@google.comac10a2d2010-12-22 21:39:39 +0000594}
595
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000596void GrInOrderDrawBuffer::releaseReservedVertexSpace() {
597 GeometryPoolState& poolState = fGeoPoolStateStack.back();
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000598 const GeometrySrcState& geoSrc = this->getGeomSrc();
bsalomon@google.comd57d71a2012-08-16 16:26:33 +0000599
600 // If we get a release vertex space call then our current source should either be reserved
601 // or array (which we copied into reserved space).
602 GrAssert(kReserved_GeometrySrcType == geoSrc.fVertexSrc ||
603 kArray_GeometrySrcType == geoSrc.fVertexSrc);
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000604
605 // When the caller reserved vertex buffer space we gave it back a pointer
606 // provided by the vertex buffer pool. At each draw we tracked the largest
607 // offset into the pool's pointer that was referenced. Now we return to the
608 // pool any portion at the tail of the allocation that no draw referenced.
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000609 size_t reservedVertexBytes = geoSrc.fVertexSize * geoSrc.fVertexCount;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000610 fVertexPool.putBack(reservedVertexBytes -
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000611 poolState.fUsedPoolVertexBytes);
612 poolState.fUsedPoolVertexBytes = 0;
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000613 poolState.fPoolVertexBuffer = NULL;
614 poolState.fPoolStartVertex = 0;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000615}
616
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000617void GrInOrderDrawBuffer::releaseReservedIndexSpace() {
618 GeometryPoolState& poolState = fGeoPoolStateStack.back();
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000619 const GeometrySrcState& geoSrc = this->getGeomSrc();
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000620
bsalomon@google.comd57d71a2012-08-16 16:26:33 +0000621 // If we get a release index space call then our current source should either be reserved
622 // or array (which we copied into reserved space).
623 GrAssert(kReserved_GeometrySrcType == geoSrc.fIndexSrc ||
624 kArray_GeometrySrcType == geoSrc.fIndexSrc);
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000625
626 // Similar to releaseReservedVertexSpace we return any unused portion at
627 // the tail
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000628 size_t reservedIndexBytes = sizeof(uint16_t) * geoSrc.fIndexCount;
629 fIndexPool.putBack(reservedIndexBytes - poolState.fUsedPoolIndexBytes);
630 poolState.fUsedPoolIndexBytes = 0;
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000631 poolState.fPoolIndexBuffer = NULL;
632 poolState.fPoolStartIndex = 0;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000633}
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000634
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000635void GrInOrderDrawBuffer::onSetVertexSourceToArray(const void* vertexArray,
636 int vertexCount) {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000637
638 GeometryPoolState& poolState = fGeoPoolStateStack.back();
639 GrAssert(0 == poolState.fUsedPoolVertexBytes);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000640#if GR_DEBUG
641 bool success =
642#endif
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000643 fVertexPool.appendVertices(this->getVertexSize(),
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000644 vertexCount,
645 vertexArray,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000646 &poolState.fPoolVertexBuffer,
647 &poolState.fPoolStartVertex);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000648 GR_DEBUGASSERT(success);
649}
650
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000651void GrInOrderDrawBuffer::onSetIndexSourceToArray(const void* indexArray,
652 int indexCount) {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000653 GeometryPoolState& poolState = fGeoPoolStateStack.back();
654 GrAssert(0 == poolState.fUsedPoolIndexBytes);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000655#if GR_DEBUG
656 bool success =
657#endif
658 fIndexPool.appendIndices(indexCount,
659 indexArray,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000660 &poolState.fPoolIndexBuffer,
661 &poolState.fPoolStartIndex);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000662 GR_DEBUGASSERT(success);
reed@google.comac10a2d2010-12-22 21:39:39 +0000663}
664
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000665void GrInOrderDrawBuffer::releaseVertexArray() {
666 // When the client provides an array as the vertex source we handled it
667 // by copying their array into reserved space.
668 this->GrInOrderDrawBuffer::releaseReservedVertexSpace();
669}
670
671void GrInOrderDrawBuffer::releaseIndexArray() {
672 // When the client provides an array as the index source we handled it
673 // by copying their array into reserved space.
674 this->GrInOrderDrawBuffer::releaseReservedIndexSpace();
675}
676
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000677void GrInOrderDrawBuffer::geometrySourceWillPush() {
678 GeometryPoolState& poolState = fGeoPoolStateStack.push_back();
679 poolState.fUsedPoolVertexBytes = 0;
680 poolState.fUsedPoolIndexBytes = 0;
681#if GR_DEBUG
682 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0;
683 poolState.fPoolStartVertex = ~0;
684 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0;
685 poolState.fPoolStartIndex = ~0;
686#endif
687}
688
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000689void GrInOrderDrawBuffer::geometrySourceWillPop(
690 const GeometrySrcState& restoredState) {
691 GrAssert(fGeoPoolStateStack.count() > 1);
692 fGeoPoolStateStack.pop_back();
693 GeometryPoolState& poolState = fGeoPoolStateStack.back();
694 // we have to assume that any slack we had in our vertex/index data
695 // is now unreleasable because data may have been appended later in the
696 // pool.
697 if (kReserved_GeometrySrcType == restoredState.fVertexSrc ||
698 kArray_GeometrySrcType == restoredState.fVertexSrc) {
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000699 poolState.fUsedPoolVertexBytes = restoredState.fVertexSize * restoredState.fVertexCount;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000700 }
701 if (kReserved_GeometrySrcType == restoredState.fIndexSrc ||
702 kArray_GeometrySrcType == restoredState.fIndexSrc) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000703 poolState.fUsedPoolIndexBytes = sizeof(uint16_t) *
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000704 restoredState.fIndexCount;
705 }
706}
707
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000708bool GrInOrderDrawBuffer::needsNewState() const {
bsalomon@google.comca432082013-01-23 19:53:46 +0000709 return fStates.empty() || !fStates.back().isEqual(this->getDrawState());
reed@google.comac10a2d2010-12-22 21:39:39 +0000710}
711
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000712bool GrInOrderDrawBuffer::needsNewClip() const {
bsalomon@google.com358e4272013-01-10 14:40:28 +0000713 GrAssert(fClips.count() == fClipOrigins.count());
714 if (this->getDrawState().isClipState()) {
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000715 if (fClipSet &&
bsalomon@google.com358e4272013-01-10 14:40:28 +0000716 (fClips.empty() ||
bsalomon@google.com02ddc8b2013-01-28 15:35:28 +0000717 fClips.back() != *this->getClip()->fClipStack ||
718 fClipOrigins.back() != this->getClip()->fOrigin)) {
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000719 return true;
720 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000721 }
722 return false;
723}
bsalomon@google.comd302f142011-03-03 13:54:13 +0000724
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000725void GrInOrderDrawBuffer::recordClip() {
bsalomon@google.com02ddc8b2013-01-28 15:35:28 +0000726 fClips.push_back() = *this->getClip()->fClipStack;
727 fClipOrigins.push_back() = this->getClip()->fOrigin;
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000728 fClipSet = false;
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000729 fCmds.push_back(kSetClip_Cmd);
730}
731
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000732void GrInOrderDrawBuffer::recordState() {
bsalomon@google.comca432082013-01-23 19:53:46 +0000733 fStates.push_back().saveFrom(this->getDrawState());
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000734 fCmds.push_back(kSetState_Cmd);
735}
736
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000737GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo& info) {
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000738 fCmds.push_back(kDraw_Cmd);
739 return &fDraws.push_back(info);
bsalomon@google.com74749cd2013-01-30 16:12:41 +0000740}
741
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000742GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath() {
743 fCmds.push_back(kStencilPath_Cmd);
744 return &fStencilPaths.push_back();
745}
746
bsalomon@google.coma4f6b102012-06-26 21:04:22 +0000747GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() {
748 fCmds.push_back(kClear_Cmd);
749 return &fClears.push_back();
reed@google.comac10a2d2010-12-22 21:39:39 +0000750}
bsalomon@google.comd302f142011-03-03 13:54:13 +0000751
robertphillips@google.combeb1af72012-07-26 18:52:16 +0000752void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) {
753 INHERITED::clipWillBeSet(newClipData);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000754 fClipSet = true;
bsalomon@google.comd62e88e2013-02-01 14:19:27 +0000755 fClipProxyState = kUnknown_ClipProxyState;
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000756}