blob: 24950c4270d09360238ea24dd4d974bd973ea377 [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 2010 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
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@google.comac10a2d2010-12-22 21:39:39 +000010#include "GrGpu.h"
bsalomon@google.com558a75b2011-08-08 17:01:14 +000011
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000012#include "GrBufferAllocPool.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000013#include "GrClipIterator.h"
bsalomon@google.com558a75b2011-08-08 17:01:14 +000014#include "GrContext.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015#include "GrIndexBuffer.h"
bsalomon@google.com4043ae22011-08-02 14:19:11 +000016#include "GrPathRenderer.h"
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000017#include "GrGLStencilBuffer.h"
18#include "GrVertexBuffer.h"
bsalomon@google.com1c13c962011-02-14 16:51:21 +000019
20// probably makes no sense for this to be less than a page
bsalomon@google.comee435122011-07-01 14:57:55 +000021static const size_t VERTEX_POOL_VB_SIZE = 1 << 18;
22static const int VERTEX_POOL_VB_COUNT = 4;
bsalomon@google.com25fd36c2011-07-06 17:41:08 +000023static const size_t INDEX_POOL_IB_SIZE = 1 << 16;
24static const int INDEX_POOL_IB_COUNT = 4;
reed@google.comac10a2d2010-12-22 21:39:39 +000025
bsalomon@google.comd302f142011-03-03 13:54:13 +000026////////////////////////////////////////////////////////////////////////////////
reed@google.comac10a2d2010-12-22 21:39:39 +000027
28extern void gr_run_unittests();
29
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000030#define DEBUG_INVAL_BUFFER 0xdeadcafe
31#define DEBUG_INVAL_START_IDX -1
32
bsalomon@google.com8fe72472011-03-30 21:26:44 +000033GrGpu::GrGpu()
34 : f8bitPaletteSupport(false)
bsalomon@google.com669fdc42011-04-05 17:08:27 +000035 , fContext(NULL)
bsalomon@google.com8fe72472011-03-30 21:26:44 +000036 , fVertexPool(NULL)
37 , fIndexPool(NULL)
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000038 , fVertexPoolUseCnt(0)
39 , fIndexPoolUseCnt(0)
40 , fGeomPoolStateStack(&fGeoSrcStateStackStorage)
bsalomon@google.com8fe72472011-03-30 21:26:44 +000041 , fQuadIndexBuffer(NULL)
42 , fUnitSquareVertexBuffer(NULL)
bsalomon@google.com30085192011-08-19 15:42:31 +000043 , fPathRendererChain(NULL)
bsalomon@google.com8fe72472011-03-30 21:26:44 +000044 , fContextIsDirty(true)
bsalomon@google.com8fe72472011-03-30 21:26:44 +000045 , fResourceHead(NULL) {
bsalomon@google.com669fdc42011-04-05 17:08:27 +000046
reed@google.comac10a2d2010-12-22 21:39:39 +000047#if GR_DEBUG
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +000048 //gr_run_unittests();
reed@google.comac10a2d2010-12-22 21:39:39 +000049#endif
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000050
51 fGeomPoolStateStack.push_back();
52#if GR_DEBUG
53 GeometryPoolState& poolState = fGeomPoolStateStack.back();
54 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
55 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX;
56 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
57 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX;
58#endif
reed@google.comac10a2d2010-12-22 21:39:39 +000059 resetStats();
60}
61
62GrGpu::~GrGpu() {
bsalomon@google.com558a75b2011-08-08 17:01:14 +000063 this->releaseResources();
reed@google.comac10a2d2010-12-22 21:39:39 +000064}
65
bsalomon@google.com8fe72472011-03-30 21:26:44 +000066void GrGpu::abandonResources() {
67
68 while (NULL != fResourceHead) {
69 fResourceHead->abandon();
70 }
71
72 GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
73 GrAssert(NULL == fUnitSquareVertexBuffer ||
74 !fUnitSquareVertexBuffer->isValid());
75 GrSafeSetNull(fQuadIndexBuffer);
76 GrSafeSetNull(fUnitSquareVertexBuffer);
77 delete fVertexPool;
78 fVertexPool = NULL;
79 delete fIndexPool;
80 fIndexPool = NULL;
bsalomon@google.com30085192011-08-19 15:42:31 +000081 // in case path renderer has any GrResources, start from scratch
82 GrSafeSetNull(fPathRendererChain);
reed@google.comac10a2d2010-12-22 21:39:39 +000083}
84
bsalomon@google.com8fe72472011-03-30 21:26:44 +000085void GrGpu::releaseResources() {
86
87 while (NULL != fResourceHead) {
88 fResourceHead->release();
89 }
90
91 GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
92 GrAssert(NULL == fUnitSquareVertexBuffer ||
93 !fUnitSquareVertexBuffer->isValid());
94 GrSafeSetNull(fQuadIndexBuffer);
95 GrSafeSetNull(fUnitSquareVertexBuffer);
96 delete fVertexPool;
97 fVertexPool = NULL;
98 delete fIndexPool;
99 fIndexPool = NULL;
bsalomon@google.com30085192011-08-19 15:42:31 +0000100 // in case path renderer has any GrResources, start from scratch
101 GrSafeSetNull(fPathRendererChain);
bsalomon@google.com8fe72472011-03-30 21:26:44 +0000102}
103
104void GrGpu::insertResource(GrResource* resource) {
105 GrAssert(NULL != resource);
106 GrAssert(this == resource->getGpu());
107 GrAssert(NULL == resource->fNext);
108 GrAssert(NULL == resource->fPrevious);
109
110 resource->fNext = fResourceHead;
111 if (NULL != fResourceHead) {
112 GrAssert(NULL == fResourceHead->fPrevious);
113 fResourceHead->fPrevious = resource;
114 }
115 fResourceHead = resource;
116}
117
118void GrGpu::removeResource(GrResource* resource) {
119 GrAssert(NULL != resource);
120 GrAssert(NULL != fResourceHead);
121
122 if (fResourceHead == resource) {
123 GrAssert(NULL == resource->fPrevious);
124 fResourceHead = resource->fNext;
125 } else {
126 GrAssert(NULL != fResourceHead);
127 resource->fPrevious->fNext = resource->fNext;
128 }
129 if (NULL != resource->fNext) {
130 resource->fNext->fPrevious = resource->fPrevious;
131 }
132 resource->fNext = NULL;
133 resource->fPrevious = NULL;
134}
135
136
reed@google.comac10a2d2010-12-22 21:39:39 +0000137void GrGpu::unimpl(const char msg[]) {
bsalomon@google.com7d34d2e2011-01-24 17:41:47 +0000138#if GR_DEBUG
139 GrPrintf("--- GrGpu unimplemented(\"%s\")\n", msg);
140#endif
reed@google.comac10a2d2010-12-22 21:39:39 +0000141}
142
bsalomon@google.comd302f142011-03-03 13:54:13 +0000143////////////////////////////////////////////////////////////////////////////////
reed@google.comac10a2d2010-12-22 21:39:39 +0000144
bsalomon@google.comfea37b52011-04-25 15:51:06 +0000145GrTexture* GrGpu::createTexture(const GrTextureDesc& desc,
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000146 const void* srcData, size_t rowBytes) {
147 this->handleDirtyContext();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000148 GrTexture* tex = this->onCreateTexture(desc, srcData, rowBytes);
149 if (NULL != tex &&
150 (kRenderTarget_GrTextureFlagBit & desc.fFlags) &&
151 !(kNoStencil_GrTextureFlagBit & desc.fFlags)) {
152 GrAssert(NULL != tex->asRenderTarget());
153 // TODO: defer this and attach dynamically
154 if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget())) {
155 tex->unref();
156 return NULL;
157 }
158 }
159 return tex;
160}
161
162bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) {
bsalomon@google.com558a75b2011-08-08 17:01:14 +0000163 GrAssert(NULL == rt->getStencilBuffer());
164 GrStencilBuffer* sb =
165 this->getContext()->findStencilBuffer(rt->allocatedWidth(),
166 rt->allocatedHeight(),
167 rt->numSamples());
168 if (NULL != sb) {
169 rt->setStencilBuffer(sb);
170 bool attached = this->attachStencilBufferToRenderTarget(sb, rt);
171 if (!attached) {
172 rt->setStencilBuffer(NULL);
173 }
174 return attached;
175 }
176 if (this->createStencilBufferForRenderTarget(rt, rt->allocatedWidth(),
177 rt->allocatedHeight())) {
178 rt->getStencilBuffer()->ref();
179 rt->getStencilBuffer()->transferToCacheAndLock();
180
bsalomon@google.comedc177d2011-08-05 15:46:40 +0000181 // Right now we're clearing the stencil buffer here after it is
182 // attached to an RT for the first time. When we start matching
183 // stencil buffers with smaller color targets this will no longer
184 // be correct because it won't be guaranteed to clear the entire
185 // sb.
186 // We used to clear down in the GL subclass using a special purpose
187 // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported
188 // FBO status.
189 GrRenderTarget* oldRT = fCurrDrawState.fRenderTarget;
190 fCurrDrawState.fRenderTarget = rt;
191 this->clearStencil();
192 fCurrDrawState.fRenderTarget = oldRT;
bsalomon@google.com558a75b2011-08-08 17:01:14 +0000193 return true;
194 } else {
195 return false;
bsalomon@google.comedc177d2011-08-05 15:46:40 +0000196 }
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000197}
198
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000199GrResource* GrGpu::createPlatformSurface(const GrPlatformSurfaceDesc& desc) {
200 this->handleDirtyContext();
201 return this->onCreatePlatformSurface(desc);
202}
203
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000204GrVertexBuffer* GrGpu::createVertexBuffer(uint32_t size, bool dynamic) {
205 this->handleDirtyContext();
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000206 return this->onCreateVertexBuffer(size, dynamic);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000207}
208
209GrIndexBuffer* GrGpu::createIndexBuffer(uint32_t size, bool dynamic) {
210 this->handleDirtyContext();
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000211 return this->onCreateIndexBuffer(size, dynamic);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000212}
213
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000214void GrGpu::clear(const GrIRect* rect, GrColor color) {
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000215 this->handleDirtyContext();
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000216 this->onClear(rect, color);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000217}
218
219void GrGpu::forceRenderTargetFlush() {
220 this->handleDirtyContext();
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000221 this->onForceRenderTargetFlush();
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000222}
223
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000224bool GrGpu::readPixels(GrRenderTarget* target,
225 int left, int top, int width, int height,
226 GrPixelConfig config, void* buffer) {
227
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000228 this->handleDirtyContext();
bsalomon@google.com5877ffd2011-04-11 17:58:48 +0000229 return this->onReadPixels(target, left, top, width, height, config, buffer);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000230}
231
232////////////////////////////////////////////////////////////////////////////////
233
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000234static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1;
reed@google.comac10a2d2010-12-22 21:39:39 +0000235
reed@google.com8195f672011-01-12 18:14:28 +0000236GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535);
reed@google.comac10a2d2010-12-22 21:39:39 +0000237
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000238static inline void fill_indices(uint16_t* indices, int quadCount) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000239 for (int i = 0; i < quadCount; ++i) {
240 indices[6 * i + 0] = 4 * i + 0;
241 indices[6 * i + 1] = 4 * i + 1;
242 indices[6 * i + 2] = 4 * i + 2;
243 indices[6 * i + 3] = 4 * i + 0;
244 indices[6 * i + 4] = 4 * i + 2;
245 indices[6 * i + 5] = 4 * i + 3;
246 }
247}
248
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000249const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
reed@google.comac10a2d2010-12-22 21:39:39 +0000250 if (NULL == fQuadIndexBuffer) {
251 static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS;
252 GrGpu* me = const_cast<GrGpu*>(this);
253 fQuadIndexBuffer = me->createIndexBuffer(SIZE, false);
254 if (NULL != fQuadIndexBuffer) {
255 uint16_t* indices = (uint16_t*)fQuadIndexBuffer->lock();
256 if (NULL != indices) {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000257 fill_indices(indices, MAX_QUADS);
reed@google.comac10a2d2010-12-22 21:39:39 +0000258 fQuadIndexBuffer->unlock();
259 } else {
260 indices = (uint16_t*)GrMalloc(SIZE);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000261 fill_indices(indices, MAX_QUADS);
reed@google.comac10a2d2010-12-22 21:39:39 +0000262 if (!fQuadIndexBuffer->updateData(indices, SIZE)) {
263 fQuadIndexBuffer->unref();
264 fQuadIndexBuffer = NULL;
bsalomon@google.com6f7fbc92011-02-01 19:12:40 +0000265 GrCrash("Can't get indices into buffer!");
reed@google.comac10a2d2010-12-22 21:39:39 +0000266 }
267 GrFree(indices);
268 }
269 }
270 }
271
272 return fQuadIndexBuffer;
273}
274
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000275const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const {
bsalomon@google.com6f7fbc92011-02-01 19:12:40 +0000276 if (NULL == fUnitSquareVertexBuffer) {
277
278 static const GrPoint DATA[] = {
reed@google.com7744c202011-05-06 19:26:26 +0000279 { 0, 0 },
280 { GR_Scalar1, 0 },
281 { GR_Scalar1, GR_Scalar1 },
282 { 0, GR_Scalar1 }
283#if 0
bsalomon@google.com6f7fbc92011-02-01 19:12:40 +0000284 GrPoint(0, 0),
285 GrPoint(GR_Scalar1,0),
286 GrPoint(GR_Scalar1,GR_Scalar1),
287 GrPoint(0, GR_Scalar1)
reed@google.com7744c202011-05-06 19:26:26 +0000288#endif
bsalomon@google.com6f7fbc92011-02-01 19:12:40 +0000289 };
290 static const size_t SIZE = sizeof(DATA);
291
292 GrGpu* me = const_cast<GrGpu*>(this);
293 fUnitSquareVertexBuffer = me->createVertexBuffer(SIZE, false);
294 if (NULL != fUnitSquareVertexBuffer) {
295 if (!fUnitSquareVertexBuffer->updateData(DATA, SIZE)) {
296 fUnitSquareVertexBuffer->unref();
297 fUnitSquareVertexBuffer = NULL;
298 GrCrash("Can't get vertices into buffer!");
299 }
300 }
301 }
302
303 return fUnitSquareVertexBuffer;
304}
305
bsalomon@google.comd302f142011-03-03 13:54:13 +0000306////////////////////////////////////////////////////////////////////////////////
reed@google.comac10a2d2010-12-22 21:39:39 +0000307
bsalomon@google.comd302f142011-03-03 13:54:13 +0000308// stencil settings to use when clip is in stencil
309const GrStencilSettings GrGpu::gClipStencilSettings = {
310 kKeep_StencilOp, kKeep_StencilOp,
311 kKeep_StencilOp, kKeep_StencilOp,
312 kAlwaysIfInClip_StencilFunc, kAlwaysIfInClip_StencilFunc,
313 0, 0,
314 0, 0,
315 0, 0
316};
317
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000318// mapping of clip-respecting stencil funcs to normal stencil funcs
319// mapping depends on whether stencil-clipping is in effect.
bsalomon@google.comd302f142011-03-03 13:54:13 +0000320static const GrStencilFunc gGrClipToNormalStencilFunc[2][kClipStencilFuncCount] = {
321 {// Stencil-Clipping is DISABLED, effectively always inside the clip
322 // In the Clip Funcs
323 kAlways_StencilFunc, // kAlwaysIfInClip_StencilFunc
324 kEqual_StencilFunc, // kEqualIfInClip_StencilFunc
325 kLess_StencilFunc, // kLessIfInClip_StencilFunc
326 kLEqual_StencilFunc, // kLEqualIfInClip_StencilFunc
327 // Special in the clip func that forces user's ref to be 0.
328 kNotEqual_StencilFunc, // kNonZeroIfInClip_StencilFunc
329 // make ref 0 and do normal nequal.
330 },
331 {// Stencil-Clipping is ENABLED
332 // In the Clip Funcs
333 kEqual_StencilFunc, // kAlwaysIfInClip_StencilFunc
334 // eq stencil clip bit, mask
335 // out user bits.
336
337 kEqual_StencilFunc, // kEqualIfInClip_StencilFunc
338 // add stencil bit to mask and ref
339
340 kLess_StencilFunc, // kLessIfInClip_StencilFunc
341 kLEqual_StencilFunc, // kLEqualIfInClip_StencilFunc
342 // for both of these we can add
343 // the clip bit to the mask and
344 // ref and compare as normal
345 // Special in the clip func that forces user's ref to be 0.
346 kLess_StencilFunc, // kNonZeroIfInClip_StencilFunc
347 // make ref have only the clip bit set
348 // and make comparison be less
349 // 10..0 < 1..user_bits..
350 }
351};
352
353GrStencilFunc GrGpu::ConvertStencilFunc(bool stencilInClip, GrStencilFunc func) {
354 GrAssert(func >= 0);
355 if (func >= kBasicStencilFuncCount) {
356 GrAssert(func < kStencilFuncCount);
357 func = gGrClipToNormalStencilFunc[stencilInClip ? 1 : 0][func - kBasicStencilFuncCount];
358 GrAssert(func >= 0 && func < kBasicStencilFuncCount);
359 }
360 return func;
361}
362
363void GrGpu::ConvertStencilFuncAndMask(GrStencilFunc func,
364 bool clipInStencil,
365 unsigned int clipBit,
366 unsigned int userBits,
367 unsigned int* ref,
368 unsigned int* mask) {
369 if (func < kBasicStencilFuncCount) {
370 *mask &= userBits;
371 *ref &= userBits;
372 } else {
373 if (clipInStencil) {
374 switch (func) {
375 case kAlwaysIfInClip_StencilFunc:
376 *mask = clipBit;
377 *ref = clipBit;
378 break;
379 case kEqualIfInClip_StencilFunc:
380 case kLessIfInClip_StencilFunc:
381 case kLEqualIfInClip_StencilFunc:
382 *mask = (*mask & userBits) | clipBit;
383 *ref = (*ref & userBits) | clipBit;
384 break;
385 case kNonZeroIfInClip_StencilFunc:
386 *mask = (*mask & userBits) | clipBit;
387 *ref = clipBit;
388 break;
389 default:
390 GrCrash("Unknown stencil func");
391 }
392 } else {
393 *mask &= userBits;
394 *ref &= userBits;
395 }
396 }
397}
398
399////////////////////////////////////////////////////////////////////////////////
400
401#define VISUALIZE_COMPLEX_CLIP 0
402
403#if VISUALIZE_COMPLEX_CLIP
404 #include "GrRandom.h"
405 GrRandom gRandom;
406 #define SET_RANDOM_COLOR this->setColor(0xff000000 | gRandom.nextU());
407#else
408 #define SET_RANDOM_COLOR
409#endif
410
bsalomon@google.comffca4002011-02-22 20:34:01 +0000411bool GrGpu::setupClipAndFlushState(GrPrimitiveType type) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000412 const GrIRect* r = NULL;
bsalomon@google.comd302f142011-03-03 13:54:13 +0000413 GrIRect clipRect;
reed@google.comac10a2d2010-12-22 21:39:39 +0000414
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +0000415 // we check this early because we need a valid
416 // render target to setup stencil clipping
417 // before even going into flushGraphicsState
418 if (NULL == fCurrDrawState.fRenderTarget) {
419 GrAssert(!"No render target bound.");
420 return false;
421 }
422
reed@google.comac10a2d2010-12-22 21:39:39 +0000423 if (fCurrDrawState.fFlagBits & kClip_StateBit) {
bsalomon@google.comd302f142011-03-03 13:54:13 +0000424 GrRenderTarget& rt = *fCurrDrawState.fRenderTarget;
425
426 GrRect bounds;
427 GrRect rtRect;
428 rtRect.setLTRB(0, 0,
429 GrIntToScalar(rt.width()), GrIntToScalar(rt.height()));
bsalomon@google.com0b50b2e2011-03-08 21:07:21 +0000430 if (fClip.hasConservativeBounds()) {
431 bounds = fClip.getConservativeBounds();
reed@google.com20efde72011-05-09 17:00:02 +0000432 if (!bounds.intersect(rtRect)) {
433 bounds.setEmpty();
434 }
bsalomon@google.comd302f142011-03-03 13:54:13 +0000435 } else {
436 bounds = rtRect;
437 }
438
439 bounds.roundOut(&clipRect);
440 if (clipRect.isEmpty()) {
441 clipRect.setLTRB(0,0,0,0);
442 }
443 r = &clipRect;
444
bsalomon@google.comdea2f8d2011-08-01 15:51:05 +0000445 // use the stencil clip if we can't represent the clip as a rectangle.
446 fClipInStencil = !fClip.isRect() && !fClip.isEmpty() &&
447 !bounds.isEmpty();
reed@google.comac10a2d2010-12-22 21:39:39 +0000448
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000449 // TODO: dynamically attach a SB when needed.
450 GrStencilBuffer* stencilBuffer = rt.getStencilBuffer();
451 if (fClipInStencil && NULL == stencilBuffer) {
452 return false;
453 }
bsalomon@google.coma16d6502011-08-02 14:07:52 +0000454
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000455 if (fClipInStencil &&
456 stencilBuffer->mustRenderClip(fClip, rt.width(), rt.height())) {
457
458 stencilBuffer->setLastClip(fClip, rt.width(), rt.height());
459
bsalomon@google.comd302f142011-03-03 13:54:13 +0000460 // we set the current clip to the bounds so that our recursive
461 // draws are scissored to them. We use the copy of the complex clip
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000462 // we just stashed on the SB to render from. We set it back after
463 // we finish drawing it into the stencil.
464 const GrClip& clip = stencilBuffer->getLastClip();
bsalomon@google.comd302f142011-03-03 13:54:13 +0000465 fClip.setFromRect(bounds);
reed@google.comac10a2d2010-12-22 21:39:39 +0000466
467 AutoStateRestore asr(this);
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000468 AutoGeometryPush agp(this);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000469
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000470 this->setViewMatrix(GrMatrix::I());
bsalomon@google.com398109c2011-04-14 18:40:27 +0000471 this->clearStencilClip(clipRect);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000472 this->flushScissor(NULL);
473#if !VISUALIZE_COMPLEX_CLIP
474 this->enableState(kNoColorWrites_StateBit);
475#else
476 this->disableState(kNoColorWrites_StateBit);
477#endif
478 int count = clip.getElementCount();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000479 int clipBit = stencilBuffer->bits();
bsalomon@google.comd302f142011-03-03 13:54:13 +0000480 clipBit = (1 << (clipBit-1));
481
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +0000482 // often we'll see the first two elements of the clip are
483 // the full rt size and another element intersected with it.
484 // We can skip the first full-size rect and save a big rect draw.
485 int firstElement = 0;
bsalomon@google.com0b50b2e2011-03-08 21:07:21 +0000486 if (clip.getElementCount() > 1 &&
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +0000487 kRect_ClipType == clip.getElementType(0) &&
488 kIntersect_SetOp == clip.getOp(1)&&
489 clip.getRect(0).contains(bounds)) {
490 firstElement = 1;
491 }
bsalomon@google.com0b50b2e2011-03-08 21:07:21 +0000492
bsalomon@google.comd302f142011-03-03 13:54:13 +0000493 // walk through each clip element and perform its set op
494 // with the existing clip.
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +0000495 for (int c = firstElement; c < count; ++c) {
bsalomon@google.comd302f142011-03-03 13:54:13 +0000496 GrPathFill fill;
bsalomon@google.comee435122011-07-01 14:57:55 +0000497 bool fillInverted;
bsalomon@google.comd302f142011-03-03 13:54:13 +0000498 // enabled at bottom of loop
499 this->disableState(kModifyStencilClip_StateBit);
500
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000501 bool canRenderDirectToStencil; // can the clip element be drawn
502 // directly to the stencil buffer
503 // with a non-inverted fill rule
504 // without extra passes to
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000505 // resolve in/out status.
506
507 GrPathRenderer* pr = NULL;
reed@google.com07f3ee12011-05-16 17:21:57 +0000508 const GrPath* clipPath = NULL;
bsalomon@google.comee435122011-07-01 14:57:55 +0000509 GrPathRenderer::AutoClearPath arp;
bsalomon@google.comd302f142011-03-03 13:54:13 +0000510 if (kRect_ClipType == clip.getElementType(c)) {
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000511 canRenderDirectToStencil = true;
bsalomon@google.comd302f142011-03-03 13:54:13 +0000512 fill = kEvenOdd_PathFill;
bsalomon@google.comee435122011-07-01 14:57:55 +0000513 fillInverted = false;
bsalomon@google.comd302f142011-03-03 13:54:13 +0000514 } else {
515 fill = clip.getPathFill(c);
bsalomon@google.comee435122011-07-01 14:57:55 +0000516 fillInverted = IsFillInverted(fill);
517 fill = NonInvertedFill(fill);
reed@google.com07f3ee12011-05-16 17:21:57 +0000518 clipPath = &clip.getPath(c);
bsalomon@google.comee435122011-07-01 14:57:55 +0000519 pr = this->getClipPathRenderer(*clipPath, fill);
bsalomon@google.com30085192011-08-19 15:42:31 +0000520 if (NULL == pr) {
521 fClipInStencil = false;
522 fClip = clip;
523 return false;
524 }
bsalomon@google.com11f0b512011-03-29 20:52:23 +0000525 canRenderDirectToStencil =
bsalomon@google.comee435122011-07-01 14:57:55 +0000526 !pr->requiresStencilPass(this, *clipPath, fill);
527 arp.set(pr, this, clipPath, fill, NULL);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000528 }
529
bsalomon@google.com5aaa69e2011-03-04 20:29:08 +0000530 GrSetOp op = firstElement == c ? kReplace_SetOp : clip.getOp(c);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000531 int passes;
532 GrStencilSettings stencilSettings[GrStencilSettings::kMaxStencilClipPasses];
533
bsalomon@google.com11f0b512011-03-29 20:52:23 +0000534 bool canDrawDirectToClip; // Given the renderer, the element,
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000535 // fill rule, and set operation can
536 // we render the element directly to
537 // stencil bit used for clipping.
bsalomon@google.com11f0b512011-03-29 20:52:23 +0000538 canDrawDirectToClip =
539 GrStencilSettings::GetClipPasses(op,
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000540 canRenderDirectToStencil,
bsalomon@google.com11f0b512011-03-29 20:52:23 +0000541 clipBit,
bsalomon@google.comee435122011-07-01 14:57:55 +0000542 fillInverted,
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000543 &passes, stencilSettings);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000544
545 // draw the element to the client stencil bits if necessary
546 if (!canDrawDirectToClip) {
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000547 static const GrStencilSettings gDrawToStencil = {
548 kIncClamp_StencilOp, kIncClamp_StencilOp,
549 kIncClamp_StencilOp, kIncClamp_StencilOp,
550 kAlways_StencilFunc, kAlways_StencilFunc,
551 0xffffffff, 0xffffffff,
552 0x00000000, 0x00000000,
553 0xffffffff, 0xffffffff,
554 };
555 SET_RANDOM_COLOR
bsalomon@google.comd302f142011-03-03 13:54:13 +0000556 if (kRect_ClipType == clip.getElementType(c)) {
bsalomon@google.comd302f142011-03-03 13:54:13 +0000557 this->setStencil(gDrawToStencil);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000558 this->drawSimpleRect(clip.getRect(c), NULL, 0);
559 } else {
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000560 if (canRenderDirectToStencil) {
561 this->setStencil(gDrawToStencil);
bsalomon@google.comee435122011-07-01 14:57:55 +0000562 pr->drawPath(0);
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000563 } else {
bsalomon@google.comee435122011-07-01 14:57:55 +0000564 pr->drawPathToStencil();
bsalomon@google.com7f5875d2011-03-24 16:55:45 +0000565 }
bsalomon@google.comd302f142011-03-03 13:54:13 +0000566 }
567 }
568
569 // now we modify the clip bit by rendering either the clip
570 // element directly or a bounding rect of the entire clip.
571 this->enableState(kModifyStencilClip_StateBit);
572 for (int p = 0; p < passes; ++p) {
573 this->setStencil(stencilSettings[p]);
574 if (canDrawDirectToClip) {
575 if (kRect_ClipType == clip.getElementType(c)) {
576 SET_RANDOM_COLOR
577 this->drawSimpleRect(clip.getRect(c), NULL, 0);
578 } else {
579 SET_RANDOM_COLOR
bsalomon@google.comee435122011-07-01 14:57:55 +0000580 pr->drawPath(0);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000581 }
582 } else {
583 SET_RANDOM_COLOR
thakis@chromium.org441d7da2011-06-07 04:03:17 +0000584 this->drawSimpleRect(bounds, NULL, 0);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000585 }
586 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000587 }
bsalomon@google.comdea2f8d2011-08-01 15:51:05 +0000588 // restore clip
bsalomon@google.comd302f142011-03-03 13:54:13 +0000589 fClip = clip;
bsalomon@google.comdea2f8d2011-08-01 15:51:05 +0000590 // recusive draws would have disabled this since they drew with
591 // the clip bounds as clip.
592 fClipInStencil = true;
reed@google.comac10a2d2010-12-22 21:39:39 +0000593 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000594 }
bsalomon@google.comd302f142011-03-03 13:54:13 +0000595
reed@google.comac10a2d2010-12-22 21:39:39 +0000596 // Must flush the scissor after graphics state
bsalomon@google.comd302f142011-03-03 13:54:13 +0000597 if (!this->flushGraphicsState(type)) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000598 return false;
599 }
bsalomon@google.comd302f142011-03-03 13:54:13 +0000600 this->flushScissor(r);
reed@google.comac10a2d2010-12-22 21:39:39 +0000601 return true;
602}
603
reed@google.com07f3ee12011-05-16 17:21:57 +0000604GrPathRenderer* GrGpu::getClipPathRenderer(const GrPath& path,
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000605 GrPathFill fill) {
bsalomon@google.com30085192011-08-19 15:42:31 +0000606 if (NULL == fPathRendererChain) {
607 fPathRendererChain =
608 new GrPathRendererChain(this->getContext(),
609 GrPathRendererChain::kNonAAOnly_UsageFlag);
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000610 }
bsalomon@google.com30085192011-08-19 15:42:31 +0000611 return fPathRendererChain->getPathRenderer(this, path, fill);
bsalomon@google.comdfe75bc2011-03-25 12:31:16 +0000612}
613
614
bsalomon@google.comd302f142011-03-03 13:54:13 +0000615////////////////////////////////////////////////////////////////////////////////
reed@google.comac10a2d2010-12-22 21:39:39 +0000616
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000617void GrGpu::geometrySourceWillPush() {
618 const GeometrySrcState& geoSrc = this->getGeomSrc();
619 if (kArray_GeometrySrcType == geoSrc.fVertexSrc ||
620 kReserved_GeometrySrcType == geoSrc.fVertexSrc) {
621 this->finalizeReservedVertices();
622 }
623 if (kArray_GeometrySrcType == geoSrc.fIndexSrc ||
624 kReserved_GeometrySrcType == geoSrc.fIndexSrc) {
625 this->finalizeReservedIndices();
626 }
627 GeometryPoolState& newState = fGeomPoolStateStack.push_back();
628#if GR_DEBUG
629 newState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER;
630 newState.fPoolStartVertex = DEBUG_INVAL_START_IDX;
631 newState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
632 newState.fPoolStartIndex = DEBUG_INVAL_START_IDX;
633#endif
634}
635
636void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) {
637 // if popping last entry then pops are unbalanced with pushes
638 GrAssert(fGeomPoolStateStack.count() > 1);
639 fGeomPoolStateStack.pop_back();
640}
641
642void GrGpu::onDrawIndexed(GrPrimitiveType type,
643 int startVertex,
644 int startIndex,
645 int vertexCount,
646 int indexCount) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000647
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000648 this->handleDirtyContext();
649
650 if (!this->setupClipAndFlushState(type)) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000651 return;
652 }
653
654#if GR_COLLECT_STATS
655 fStats.fVertexCnt += vertexCount;
656 fStats.fIndexCnt += indexCount;
657 fStats.fDrawCnt += 1;
658#endif
659
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000660 int sVertex = startVertex;
661 int sIndex = startIndex;
662 setupGeometry(&sVertex, &sIndex, vertexCount, indexCount);
reed@google.comac10a2d2010-12-22 21:39:39 +0000663
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000664 this->onGpuDrawIndexed(type, sVertex, sIndex,
665 vertexCount, indexCount);
reed@google.comac10a2d2010-12-22 21:39:39 +0000666}
667
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000668void GrGpu::onDrawNonIndexed(GrPrimitiveType type,
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000669 int startVertex,
670 int vertexCount) {
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000671 this->handleDirtyContext();
672
673 if (!this->setupClipAndFlushState(type)) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000674 return;
675 }
676#if GR_COLLECT_STATS
677 fStats.fVertexCnt += vertexCount;
678 fStats.fDrawCnt += 1;
679#endif
680
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000681 int sVertex = startVertex;
682 setupGeometry(&sVertex, NULL, vertexCount, 0);
reed@google.comac10a2d2010-12-22 21:39:39 +0000683
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000684 this->onGpuDrawNonIndexed(type, sVertex, vertexCount);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000685}
686
687void GrGpu::finalizeReservedVertices() {
688 GrAssert(NULL != fVertexPool);
689 fVertexPool->unlock();
690}
691
692void GrGpu::finalizeReservedIndices() {
693 GrAssert(NULL != fIndexPool);
694 fIndexPool->unlock();
695}
696
697void GrGpu::prepareVertexPool() {
698 if (NULL == fVertexPool) {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000699 GrAssert(0 == fVertexPoolUseCnt);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000700 fVertexPool = new GrVertexBufferAllocPool(this, true,
701 VERTEX_POOL_VB_SIZE,
bsalomon@google.com7a5af8b2011-02-18 18:40:42 +0000702 VERTEX_POOL_VB_COUNT);
bsalomon@google.com11f0b512011-03-29 20:52:23 +0000703 fVertexPool->releaseGpuRef();
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000704 } else if (!fVertexPoolUseCnt) {
bsalomon@google.comd302f142011-03-03 13:54:13 +0000705 // the client doesn't have valid data in the pool
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000706 fVertexPool->reset();
707 }
708}
709
710void GrGpu::prepareIndexPool() {
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +0000711 if (NULL == fIndexPool) {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000712 GrAssert(0 == fIndexPoolUseCnt);
bsalomon@google.com25fd36c2011-07-06 17:41:08 +0000713 fIndexPool = new GrIndexBufferAllocPool(this, true,
714 INDEX_POOL_IB_SIZE,
715 INDEX_POOL_IB_COUNT);
bsalomon@google.com11f0b512011-03-29 20:52:23 +0000716 fIndexPool->releaseGpuRef();
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000717 } else if (!fIndexPoolUseCnt) {
bsalomon@google.comd302f142011-03-03 13:54:13 +0000718 // the client doesn't have valid data in the pool
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000719 fIndexPool->reset();
720 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000721}
722
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000723bool GrGpu::onReserveVertexSpace(GrVertexLayout vertexLayout,
724 int vertexCount,
725 void** vertices) {
726 GeometryPoolState& geomPoolState = fGeomPoolStateStack.back();
727
728 GrAssert(vertexCount > 0);
729 GrAssert(NULL != vertices);
730
731 this->prepareVertexPool();
732
733 *vertices = fVertexPool->makeSpace(vertexLayout,
734 vertexCount,
735 &geomPoolState.fPoolVertexBuffer,
736 &geomPoolState.fPoolStartVertex);
737 if (NULL == *vertices) {
738 return false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000739 }
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000740 ++fVertexPoolUseCnt;
reed@google.comac10a2d2010-12-22 21:39:39 +0000741 return true;
742}
743
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000744bool GrGpu::onReserveIndexSpace(int indexCount, void** indices) {
745 GeometryPoolState& geomPoolState = fGeomPoolStateStack.back();
746
747 GrAssert(indexCount > 0);
748 GrAssert(NULL != indices);
749
750 this->prepareIndexPool();
751
752 *indices = fIndexPool->makeSpace(indexCount,
753 &geomPoolState.fPoolIndexBuffer,
754 &geomPoolState.fPoolStartIndex);
755 if (NULL == *indices) {
756 return false;
757 }
758 ++fIndexPoolUseCnt;
759 return true;
760}
761
762void GrGpu::releaseReservedVertexSpace() {
763 const GeometrySrcState& geoSrc = this->getGeomSrc();
764 GrAssert(kReserved_GeometrySrcType == geoSrc.fVertexSrc);
765 size_t bytes = geoSrc.fVertexCount * VertexSize(geoSrc.fVertexLayout);
766 fVertexPool->putBack(bytes);
767 --fVertexPoolUseCnt;
768}
769
770void GrGpu::releaseReservedIndexSpace() {
771 const GeometrySrcState& geoSrc = this->getGeomSrc();
772 GrAssert(kReserved_GeometrySrcType == geoSrc.fIndexSrc);
773 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
774 fIndexPool->putBack(bytes);
775 --fIndexPoolUseCnt;
776}
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000777
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000778void GrGpu::onSetVertexSourceToArray(const void* vertexArray, int vertexCount) {
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000779 this->prepareVertexPool();
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000780 GeometryPoolState& geomPoolState = fGeomPoolStateStack.back();
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000781#if GR_DEBUG
782 bool success =
783#endif
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000784 fVertexPool->appendVertices(this->getGeomSrc().fVertexLayout,
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000785 vertexCount,
786 vertexArray,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000787 &geomPoolState.fPoolVertexBuffer,
788 &geomPoolState.fPoolStartVertex);
789 ++fVertexPoolUseCnt;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000790 GR_DEBUGASSERT(success);
791}
792
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000793void GrGpu::onSetIndexSourceToArray(const void* indexArray, int indexCount) {
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000794 this->prepareIndexPool();
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000795 GeometryPoolState& geomPoolState = fGeomPoolStateStack.back();
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000796#if GR_DEBUG
797 bool success =
798#endif
799 fIndexPool->appendIndices(indexCount,
800 indexArray,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000801 &geomPoolState.fPoolIndexBuffer,
802 &geomPoolState.fPoolStartIndex);
803 ++fIndexPoolUseCnt;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000804 GR_DEBUGASSERT(success);
reed@google.comac10a2d2010-12-22 21:39:39 +0000805}
806
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000807void GrGpu::releaseVertexArray() {
808 // if vertex source was array, we stowed data in the pool
809 const GeometrySrcState& geoSrc = this->getGeomSrc();
810 GrAssert(kArray_GeometrySrcType == geoSrc.fVertexSrc);
811 size_t bytes = geoSrc.fVertexCount * VertexSize(geoSrc.fVertexLayout);
812 fVertexPool->putBack(bytes);
813 --fVertexPoolUseCnt;
814}
815
816void GrGpu::releaseIndexArray() {
817 // if index source was array, we stowed data in the pool
818 const GeometrySrcState& geoSrc = this->getGeomSrc();
819 GrAssert(kArray_GeometrySrcType == geoSrc.fIndexSrc);
820 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t);
821 fIndexPool->putBack(bytes);
822 --fIndexPoolUseCnt;
823}
824
bsalomon@google.comd302f142011-03-03 13:54:13 +0000825////////////////////////////////////////////////////////////////////////////////
826
bsalomon@google.com05ef5102011-05-02 21:14:59 +0000827const GrGpuStats& GrGpu::getStats() const {
reed@google.comac10a2d2010-12-22 21:39:39 +0000828 return fStats;
829}
830
831void GrGpu::resetStats() {
832 memset(&fStats, 0, sizeof(fStats));
833}
834
835void GrGpu::printStats() const {
836 if (GR_COLLECT_STATS) {
837 GrPrintf(
838 "-v-------------------------GPU STATS----------------------------v-\n"
839 "Stats collection is: %s\n"
840 "Draws: %04d, Verts: %04d, Indices: %04d\n"
841 "ProgChanges: %04d, TexChanges: %04d, RTChanges: %04d\n"
842 "TexCreates: %04d, RTCreates:%04d\n"
843 "-^--------------------------------------------------------------^-\n",
844 (GR_COLLECT_STATS ? "ON" : "OFF"),
845 fStats.fDrawCnt, fStats.fVertexCnt, fStats.fIndexCnt,
846 fStats.fProgChngCnt, fStats.fTextureChngCnt, fStats.fRenderTargetChngCnt,
847 fStats.fTextureCreateCnt, fStats.fRenderTargetCreateCnt);
848 }
849}
850
851////////////////////////////////////////////////////////////////////////////////
reed@google.comac10a2d2010-12-22 21:39:39 +0000852const GrSamplerState GrSamplerState::gClampNoFilter(
853 GrSamplerState::kClamp_WrapMode,
854 GrSamplerState::kClamp_WrapMode,
855 GrSamplerState::kNormal_SampleMode,
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000856 GrMatrix::I(),
bsalomon@google.com6aef1fb2011-05-05 12:33:22 +0000857 GrSamplerState::kNearest_Filter);
reed@google.comac10a2d2010-12-22 21:39:39 +0000858
859
860
861