epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 10 | #include "GrGpu.h" |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 11 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 12 | #include "GrBufferAllocPool.h" |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 13 | #include "GrContext.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 14 | #include "GrIndexBuffer.h" |
tomhudson@google.com | dd182cb | 2012-02-10 21:01:00 +0000 | [diff] [blame] | 15 | #include "GrStencilBuffer.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 16 | #include "GrVertexBuffer.h" |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 17 | |
| 18 | // probably makes no sense for this to be less than a page |
bsalomon@google.com | ee43512 | 2011-07-01 14:57:55 +0000 | [diff] [blame] | 19 | static const size_t VERTEX_POOL_VB_SIZE = 1 << 18; |
| 20 | static const int VERTEX_POOL_VB_COUNT = 4; |
bsalomon@google.com | 25fd36c | 2011-07-06 17:41:08 +0000 | [diff] [blame] | 21 | static const size_t INDEX_POOL_IB_SIZE = 1 << 16; |
| 22 | static const int INDEX_POOL_IB_COUNT = 4; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 23 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 24 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 25 | |
| 26 | extern void gr_run_unittests(); |
| 27 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 28 | #define DEBUG_INVAL_BUFFER 0xdeadcafe |
| 29 | #define DEBUG_INVAL_START_IDX -1 |
| 30 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 31 | GrGpu::GrGpu() |
robertphillips@google.com | 5d8d186 | 2012-08-15 14:36:41 +0000 | [diff] [blame] | 32 | : fContext(NULL) |
bsalomon@google.com | 979432b | 2011-11-05 21:38:22 +0000 | [diff] [blame] | 33 | , fResetTimestamp(kExpiredTimestamp+1) |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 34 | , fVertexPool(NULL) |
| 35 | , fIndexPool(NULL) |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 36 | , fVertexPoolUseCnt(0) |
| 37 | , fIndexPoolUseCnt(0) |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 38 | , fQuadIndexBuffer(NULL) |
| 39 | , fUnitSquareVertexBuffer(NULL) |
robertphillips@google.com | 9474ed0 | 2012-09-04 13:34:32 +0000 | [diff] [blame] | 40 | , fContextIsDirty(true) { |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 41 | |
robertphillips@google.com | 5d8d186 | 2012-08-15 14:36:41 +0000 | [diff] [blame] | 42 | fClipMaskManager.setGpu(this); |
| 43 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 44 | #if GR_DEBUG |
bsalomon@google.com | 5aaa69e | 2011-03-04 20:29:08 +0000 | [diff] [blame] | 45 | //gr_run_unittests(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 46 | #endif |
robertphillips@google.com | 5d8d186 | 2012-08-15 14:36:41 +0000 | [diff] [blame] | 47 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 48 | fGeomPoolStateStack.push_back(); |
| 49 | #if GR_DEBUG |
| 50 | GeometryPoolState& poolState = fGeomPoolStateStack.back(); |
| 51 | poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; |
| 52 | poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX; |
| 53 | poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; |
| 54 | poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX; |
| 55 | #endif |
robertphillips@google.com | 99a5ac0 | 2012-04-10 19:26:38 +0000 | [diff] [blame] | 56 | |
| 57 | for (int i = 0; i < kGrPixelConfigCount; ++i) { |
| 58 | fConfigRenderSupport[i] = false; |
| 59 | }; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | GrGpu::~GrGpu() { |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 63 | this->releaseResources(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 64 | } |
| 65 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 66 | void GrGpu::abandonResources() { |
| 67 | |
robertphillips@google.com | f105b10 | 2012-05-14 12:18:26 +0000 | [diff] [blame] | 68 | fClipMaskManager.releaseResources(); |
| 69 | |
robertphillips@google.com | 9474ed0 | 2012-09-04 13:34:32 +0000 | [diff] [blame] | 70 | while (NULL != fResourceList.head()) { |
| 71 | fResourceList.head()->abandon(); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid()); |
| 75 | GrAssert(NULL == fUnitSquareVertexBuffer || |
| 76 | !fUnitSquareVertexBuffer->isValid()); |
| 77 | GrSafeSetNull(fQuadIndexBuffer); |
| 78 | GrSafeSetNull(fUnitSquareVertexBuffer); |
| 79 | delete fVertexPool; |
| 80 | fVertexPool = NULL; |
| 81 | delete fIndexPool; |
| 82 | fIndexPool = NULL; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 83 | } |
| 84 | |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 85 | void GrGpu::releaseResources() { |
| 86 | |
robertphillips@google.com | f105b10 | 2012-05-14 12:18:26 +0000 | [diff] [blame] | 87 | fClipMaskManager.releaseResources(); |
| 88 | |
robertphillips@google.com | 9474ed0 | 2012-09-04 13:34:32 +0000 | [diff] [blame] | 89 | while (NULL != fResourceList.head()) { |
| 90 | fResourceList.head()->release(); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid()); |
| 94 | GrAssert(NULL == fUnitSquareVertexBuffer || |
| 95 | !fUnitSquareVertexBuffer->isValid()); |
| 96 | GrSafeSetNull(fQuadIndexBuffer); |
| 97 | GrSafeSetNull(fUnitSquareVertexBuffer); |
| 98 | delete fVertexPool; |
| 99 | fVertexPool = NULL; |
| 100 | delete fIndexPool; |
| 101 | fIndexPool = NULL; |
| 102 | } |
| 103 | |
| 104 | void GrGpu::insertResource(GrResource* resource) { |
| 105 | GrAssert(NULL != resource); |
| 106 | GrAssert(this == resource->getGpu()); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 107 | |
robertphillips@google.com | 9474ed0 | 2012-09-04 13:34:32 +0000 | [diff] [blame] | 108 | fResourceList.addToHead(resource); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | void GrGpu::removeResource(GrResource* resource) { |
| 112 | GrAssert(NULL != resource); |
robertphillips@google.com | 9474ed0 | 2012-09-04 13:34:32 +0000 | [diff] [blame] | 113 | GrAssert(this == resource->getGpu()); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 114 | |
robertphillips@google.com | 9474ed0 | 2012-09-04 13:34:32 +0000 | [diff] [blame] | 115 | fResourceList.remove(resource); |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 119 | void GrGpu::unimpl(const char msg[]) { |
bsalomon@google.com | 7d34d2e | 2011-01-24 17:41:47 +0000 | [diff] [blame] | 120 | #if GR_DEBUG |
| 121 | GrPrintf("--- GrGpu unimplemented(\"%s\")\n", msg); |
| 122 | #endif |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 123 | } |
| 124 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 125 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 126 | |
bsalomon@google.com | fea37b5 | 2011-04-25 15:51:06 +0000 | [diff] [blame] | 127 | GrTexture* GrGpu::createTexture(const GrTextureDesc& desc, |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 128 | const void* srcData, size_t rowBytes) { |
| 129 | this->handleDirtyContext(); |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 130 | GrTexture* tex = this->onCreateTexture(desc, srcData, rowBytes); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 131 | if (NULL != tex && |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 132 | (kRenderTarget_GrTextureFlagBit & desc.fFlags) && |
| 133 | !(kNoStencil_GrTextureFlagBit & desc.fFlags)) { |
| 134 | GrAssert(NULL != tex->asRenderTarget()); |
| 135 | // TODO: defer this and attach dynamically |
| 136 | if (!this->attachStencilBufferToRenderTarget(tex->asRenderTarget())) { |
| 137 | tex->unref(); |
| 138 | return NULL; |
| 139 | } |
| 140 | } |
| 141 | return tex; |
| 142 | } |
| 143 | |
| 144 | bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 145 | GrAssert(NULL == rt->getStencilBuffer()); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 146 | GrStencilBuffer* sb = |
robertphillips@google.com | 9fbcad0 | 2012-09-09 14:44:15 +0000 | [diff] [blame] | 147 | this->getContext()->findStencilBuffer(rt->width(), |
| 148 | rt->height(), |
| 149 | rt->numSamples()); |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 150 | if (NULL != sb) { |
| 151 | rt->setStencilBuffer(sb); |
| 152 | bool attached = this->attachStencilBufferToRenderTarget(sb, rt); |
| 153 | if (!attached) { |
| 154 | rt->setStencilBuffer(NULL); |
| 155 | } |
| 156 | return attached; |
| 157 | } |
bsalomon@google.com | 9962108 | 2011-11-15 16:47:16 +0000 | [diff] [blame] | 158 | if (this->createStencilBufferForRenderTarget(rt, |
| 159 | rt->width(), rt->height())) { |
bsalomon@google.com | edc177d | 2011-08-05 15:46:40 +0000 | [diff] [blame] | 160 | // Right now we're clearing the stencil buffer here after it is |
| 161 | // attached to an RT for the first time. When we start matching |
| 162 | // stencil buffers with smaller color targets this will no longer |
| 163 | // be correct because it won't be guaranteed to clear the entire |
| 164 | // sb. |
| 165 | // We used to clear down in the GL subclass using a special purpose |
| 166 | // FBO. But iOS doesn't allow a stencil-only FBO. It reports unsupported |
| 167 | // FBO status. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 168 | GrDrawState::AutoRenderTargetRestore artr(this->drawState(), rt); |
bsalomon@google.com | edc177d | 2011-08-05 15:46:40 +0000 | [diff] [blame] | 169 | this->clearStencil(); |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 170 | return true; |
| 171 | } else { |
| 172 | return false; |
bsalomon@google.com | edc177d | 2011-08-05 15:46:40 +0000 | [diff] [blame] | 173 | } |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 174 | } |
| 175 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame^] | 176 | GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc) { |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 177 | this->handleDirtyContext(); |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame^] | 178 | GrTexture* tex = this->onWrapBackendTexture(desc); |
bsalomon@google.com | a14dd6d | 2012-01-03 21:08:12 +0000 | [diff] [blame] | 179 | if (NULL == tex) { |
| 180 | return NULL; |
| 181 | } |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 182 | // TODO: defer this and attach dynamically |
| 183 | GrRenderTarget* tgt = tex->asRenderTarget(); |
| 184 | if (NULL != tgt && |
| 185 | !this->attachStencilBufferToRenderTarget(tgt)) { |
| 186 | tex->unref(); |
| 187 | return NULL; |
| 188 | } else { |
| 189 | return tex; |
| 190 | } |
| 191 | } |
| 192 | |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame^] | 193 | GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) { |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 194 | this->handleDirtyContext(); |
bsalomon@google.com | 16e3dde | 2012-10-25 18:43:28 +0000 | [diff] [blame^] | 195 | return this->onWrapBackendRenderTarget(desc); |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 196 | } |
| 197 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 198 | GrVertexBuffer* GrGpu::createVertexBuffer(uint32_t size, bool dynamic) { |
| 199 | this->handleDirtyContext(); |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 200 | return this->onCreateVertexBuffer(size, dynamic); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | GrIndexBuffer* GrGpu::createIndexBuffer(uint32_t size, bool dynamic) { |
| 204 | this->handleDirtyContext(); |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 205 | return this->onCreateIndexBuffer(size, dynamic); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 206 | } |
| 207 | |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 208 | GrPath* GrGpu::createPath(const SkPath& path) { |
bsalomon@google.com | f660187 | 2012-08-28 21:11:35 +0000 | [diff] [blame] | 209 | GrAssert(fCaps.pathStencilingSupport()); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 210 | this->handleDirtyContext(); |
| 211 | return this->onCreatePath(path); |
| 212 | } |
| 213 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 214 | void GrGpu::clear(const GrIRect* rect, |
| 215 | GrColor color, |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 216 | GrRenderTarget* renderTarget) { |
bsalomon@google.com | 2e60206 | 2012-09-28 21:40:15 +0000 | [diff] [blame] | 217 | GrDrawState::AutoRenderTargetRestore art; |
| 218 | if (NULL != renderTarget) { |
| 219 | art.set(this->drawState(), renderTarget); |
robertphillips@google.com | c82a8b7 | 2012-06-21 20:15:48 +0000 | [diff] [blame] | 220 | } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 221 | if (NULL == this->getDrawState().getRenderTarget()) { |
bsalomon@google.com | 0ba52fc | 2011-11-10 22:16:06 +0000 | [diff] [blame] | 222 | return; |
| 223 | } |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 224 | this->handleDirtyContext(); |
bsalomon@google.com | 6aa25c3 | 2011-04-27 19:55:29 +0000 | [diff] [blame] | 225 | this->onClear(rect, color); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | void GrGpu::forceRenderTargetFlush() { |
| 229 | this->handleDirtyContext(); |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 230 | this->onForceRenderTargetFlush(); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 231 | } |
| 232 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 233 | bool GrGpu::readPixels(GrRenderTarget* target, |
| 234 | int left, int top, int width, int height, |
bsalomon@google.com | c698097 | 2011-11-02 19:57:21 +0000 | [diff] [blame] | 235 | GrPixelConfig config, void* buffer, |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 236 | size_t rowBytes, bool invertY) { |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 237 | this->handleDirtyContext(); |
bsalomon@google.com | c698097 | 2011-11-02 19:57:21 +0000 | [diff] [blame] | 238 | return this->onReadPixels(target, left, top, width, height, |
bsalomon@google.com | c436499 | 2011-11-07 15:54:49 +0000 | [diff] [blame] | 239 | config, buffer, rowBytes, invertY); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 240 | } |
| 241 | |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 242 | void GrGpu::writeTexturePixels(GrTexture* texture, |
| 243 | int left, int top, int width, int height, |
| 244 | GrPixelConfig config, const void* buffer, |
| 245 | size_t rowBytes) { |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 246 | this->handleDirtyContext(); |
| 247 | this->onWriteTexturePixels(texture, left, top, width, height, |
| 248 | config, buffer, rowBytes); |
| 249 | } |
| 250 | |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 251 | void GrGpu::resolveRenderTarget(GrRenderTarget* target) { |
| 252 | GrAssert(target); |
| 253 | this->handleDirtyContext(); |
| 254 | this->onResolveRenderTarget(target); |
| 255 | } |
| 256 | |
| 257 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 258 | //////////////////////////////////////////////////////////////////////////////// |
| 259 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 260 | static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 261 | |
reed@google.com | 8195f67 | 2011-01-12 18:14:28 +0000 | [diff] [blame] | 262 | GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 263 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 264 | static inline void fill_indices(uint16_t* indices, int quadCount) { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 265 | for (int i = 0; i < quadCount; ++i) { |
| 266 | indices[6 * i + 0] = 4 * i + 0; |
| 267 | indices[6 * i + 1] = 4 * i + 1; |
| 268 | indices[6 * i + 2] = 4 * i + 2; |
| 269 | indices[6 * i + 3] = 4 * i + 0; |
| 270 | indices[6 * i + 4] = 4 * i + 2; |
| 271 | indices[6 * i + 5] = 4 * i + 3; |
| 272 | } |
| 273 | } |
| 274 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 275 | const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 276 | if (NULL == fQuadIndexBuffer) { |
| 277 | static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS; |
| 278 | GrGpu* me = const_cast<GrGpu*>(this); |
| 279 | fQuadIndexBuffer = me->createIndexBuffer(SIZE, false); |
| 280 | if (NULL != fQuadIndexBuffer) { |
| 281 | uint16_t* indices = (uint16_t*)fQuadIndexBuffer->lock(); |
| 282 | if (NULL != indices) { |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 283 | fill_indices(indices, MAX_QUADS); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 284 | fQuadIndexBuffer->unlock(); |
| 285 | } else { |
| 286 | indices = (uint16_t*)GrMalloc(SIZE); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 287 | fill_indices(indices, MAX_QUADS); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 288 | if (!fQuadIndexBuffer->updateData(indices, SIZE)) { |
| 289 | fQuadIndexBuffer->unref(); |
| 290 | fQuadIndexBuffer = NULL; |
bsalomon@google.com | 6f7fbc9 | 2011-02-01 19:12:40 +0000 | [diff] [blame] | 291 | GrCrash("Can't get indices into buffer!"); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 292 | } |
| 293 | GrFree(indices); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | return fQuadIndexBuffer; |
| 299 | } |
| 300 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 301 | const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const { |
bsalomon@google.com | 6f7fbc9 | 2011-02-01 19:12:40 +0000 | [diff] [blame] | 302 | if (NULL == fUnitSquareVertexBuffer) { |
| 303 | |
| 304 | static const GrPoint DATA[] = { |
reed@google.com | 7744c20 | 2011-05-06 19:26:26 +0000 | [diff] [blame] | 305 | { 0, 0 }, |
| 306 | { GR_Scalar1, 0 }, |
| 307 | { GR_Scalar1, GR_Scalar1 }, |
| 308 | { 0, GR_Scalar1 } |
| 309 | #if 0 |
bsalomon@google.com | 6f7fbc9 | 2011-02-01 19:12:40 +0000 | [diff] [blame] | 310 | GrPoint(0, 0), |
| 311 | GrPoint(GR_Scalar1,0), |
| 312 | GrPoint(GR_Scalar1,GR_Scalar1), |
| 313 | GrPoint(0, GR_Scalar1) |
reed@google.com | 7744c20 | 2011-05-06 19:26:26 +0000 | [diff] [blame] | 314 | #endif |
bsalomon@google.com | 6f7fbc9 | 2011-02-01 19:12:40 +0000 | [diff] [blame] | 315 | }; |
| 316 | static const size_t SIZE = sizeof(DATA); |
| 317 | |
| 318 | GrGpu* me = const_cast<GrGpu*>(this); |
| 319 | fUnitSquareVertexBuffer = me->createVertexBuffer(SIZE, false); |
| 320 | if (NULL != fUnitSquareVertexBuffer) { |
| 321 | if (!fUnitSquareVertexBuffer->updateData(DATA, SIZE)) { |
| 322 | fUnitSquareVertexBuffer->unref(); |
| 323 | fUnitSquareVertexBuffer = NULL; |
| 324 | GrCrash("Can't get vertices into buffer!"); |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | return fUnitSquareVertexBuffer; |
| 330 | } |
| 331 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 332 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 333 | |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 334 | bool GrGpu::setupClipAndFlushState(DrawType type) { |
robertphillips@google.com | 730ebe5 | 2012-04-16 16:33:13 +0000 | [diff] [blame] | 335 | |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 336 | if (!fClipMaskManager.setupClipping(fClip)) { |
robertphillips@google.com | 730ebe5 | 2012-04-16 16:33:13 +0000 | [diff] [blame] | 337 | return false; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 338 | } |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 339 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 340 | if (!this->flushGraphicsState(type)) { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 341 | return false; |
| 342 | } |
robertphillips@google.com | 730ebe5 | 2012-04-16 16:33:13 +0000 | [diff] [blame] | 343 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 344 | return true; |
| 345 | } |
| 346 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 347 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 348 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 349 | void GrGpu::geometrySourceWillPush() { |
| 350 | const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 351 | if (kArray_GeometrySrcType == geoSrc.fVertexSrc || |
| 352 | kReserved_GeometrySrcType == geoSrc.fVertexSrc) { |
| 353 | this->finalizeReservedVertices(); |
| 354 | } |
| 355 | if (kArray_GeometrySrcType == geoSrc.fIndexSrc || |
| 356 | kReserved_GeometrySrcType == geoSrc.fIndexSrc) { |
| 357 | this->finalizeReservedIndices(); |
| 358 | } |
| 359 | GeometryPoolState& newState = fGeomPoolStateStack.push_back(); |
| 360 | #if GR_DEBUG |
| 361 | newState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; |
| 362 | newState.fPoolStartVertex = DEBUG_INVAL_START_IDX; |
| 363 | newState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; |
| 364 | newState.fPoolStartIndex = DEBUG_INVAL_START_IDX; |
| 365 | #endif |
| 366 | } |
| 367 | |
| 368 | void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { |
| 369 | // if popping last entry then pops are unbalanced with pushes |
| 370 | GrAssert(fGeomPoolStateStack.count() > 1); |
| 371 | fGeomPoolStateStack.pop_back(); |
| 372 | } |
| 373 | |
| 374 | void GrGpu::onDrawIndexed(GrPrimitiveType type, |
| 375 | int startVertex, |
| 376 | int startIndex, |
| 377 | int vertexCount, |
| 378 | int indexCount) { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 379 | |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 380 | this->handleDirtyContext(); |
| 381 | |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 382 | if (!this->setupClipAndFlushState(PrimTypeToDrawType(type))) { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 383 | return; |
| 384 | } |
| 385 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 386 | int sVertex = startVertex; |
| 387 | int sIndex = startIndex; |
| 388 | setupGeometry(&sVertex, &sIndex, vertexCount, indexCount); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 389 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 390 | this->onGpuDrawIndexed(type, sVertex, sIndex, |
| 391 | vertexCount, indexCount); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 392 | } |
| 393 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 394 | void GrGpu::onDrawNonIndexed(GrPrimitiveType type, |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 395 | int startVertex, |
| 396 | int vertexCount) { |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 397 | this->handleDirtyContext(); |
| 398 | |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 399 | if (!this->setupClipAndFlushState(PrimTypeToDrawType(type))) { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 400 | return; |
| 401 | } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 402 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 403 | int sVertex = startVertex; |
| 404 | setupGeometry(&sVertex, NULL, vertexCount, 0); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 405 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 406 | this->onGpuDrawNonIndexed(type, sVertex, vertexCount); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 407 | } |
| 408 | |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 409 | void GrGpu::onStencilPath(const GrPath* path, GrPathFill fill) { |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 410 | this->handleDirtyContext(); |
| 411 | |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 412 | // TODO: make this more effecient (don't copy and copy back) |
| 413 | GrAutoTRestore<GrStencilSettings> asr(this->drawState()->stencil()); |
| 414 | |
| 415 | this->setStencilPathSettings(*path, fill, this->drawState()->stencil()); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 416 | if (!this->setupClipAndFlushState(kStencilPath_DrawType)) { |
| 417 | return; |
| 418 | } |
| 419 | |
| 420 | this->onGpuStencilPath(path, fill); |
| 421 | } |
| 422 | |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 423 | void GrGpu::finalizeReservedVertices() { |
| 424 | GrAssert(NULL != fVertexPool); |
| 425 | fVertexPool->unlock(); |
| 426 | } |
| 427 | |
| 428 | void GrGpu::finalizeReservedIndices() { |
| 429 | GrAssert(NULL != fIndexPool); |
| 430 | fIndexPool->unlock(); |
| 431 | } |
| 432 | |
| 433 | void GrGpu::prepareVertexPool() { |
| 434 | if (NULL == fVertexPool) { |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 435 | GrAssert(0 == fVertexPoolUseCnt); |
tomhudson@google.com | c377baf | 2012-07-09 20:17:56 +0000 | [diff] [blame] | 436 | fVertexPool = SkNEW_ARGS(GrVertexBufferAllocPool, (this, true, |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 437 | VERTEX_POOL_VB_SIZE, |
tomhudson@google.com | c377baf | 2012-07-09 20:17:56 +0000 | [diff] [blame] | 438 | VERTEX_POOL_VB_COUNT)); |
bsalomon@google.com | 11f0b51 | 2011-03-29 20:52:23 +0000 | [diff] [blame] | 439 | fVertexPool->releaseGpuRef(); |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 440 | } else if (!fVertexPoolUseCnt) { |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 441 | // the client doesn't have valid data in the pool |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 442 | fVertexPool->reset(); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | void GrGpu::prepareIndexPool() { |
senorblanco@chromium.org | 9d18b78 | 2011-03-28 20:47:09 +0000 | [diff] [blame] | 447 | if (NULL == fIndexPool) { |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 448 | GrAssert(0 == fIndexPoolUseCnt); |
tomhudson@google.com | c377baf | 2012-07-09 20:17:56 +0000 | [diff] [blame] | 449 | fIndexPool = SkNEW_ARGS(GrIndexBufferAllocPool, (this, true, |
bsalomon@google.com | 25fd36c | 2011-07-06 17:41:08 +0000 | [diff] [blame] | 450 | INDEX_POOL_IB_SIZE, |
tomhudson@google.com | c377baf | 2012-07-09 20:17:56 +0000 | [diff] [blame] | 451 | INDEX_POOL_IB_COUNT)); |
bsalomon@google.com | 11f0b51 | 2011-03-29 20:52:23 +0000 | [diff] [blame] | 452 | fIndexPool->releaseGpuRef(); |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 453 | } else if (!fIndexPoolUseCnt) { |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 454 | // the client doesn't have valid data in the pool |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 455 | fIndexPool->reset(); |
| 456 | } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 457 | } |
| 458 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 459 | bool GrGpu::onReserveVertexSpace(GrVertexLayout vertexLayout, |
| 460 | int vertexCount, |
| 461 | void** vertices) { |
| 462 | GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 463 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 464 | GrAssert(vertexCount > 0); |
| 465 | GrAssert(NULL != vertices); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 466 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 467 | this->prepareVertexPool(); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 468 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 469 | *vertices = fVertexPool->makeSpace(vertexLayout, |
| 470 | vertexCount, |
| 471 | &geomPoolState.fPoolVertexBuffer, |
| 472 | &geomPoolState.fPoolStartVertex); |
| 473 | if (NULL == *vertices) { |
| 474 | return false; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 475 | } |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 476 | ++fVertexPoolUseCnt; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 477 | return true; |
| 478 | } |
| 479 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 480 | bool GrGpu::onReserveIndexSpace(int indexCount, void** indices) { |
| 481 | GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 482 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 483 | GrAssert(indexCount > 0); |
| 484 | GrAssert(NULL != indices); |
| 485 | |
| 486 | this->prepareIndexPool(); |
| 487 | |
| 488 | *indices = fIndexPool->makeSpace(indexCount, |
| 489 | &geomPoolState.fPoolIndexBuffer, |
| 490 | &geomPoolState.fPoolStartIndex); |
| 491 | if (NULL == *indices) { |
| 492 | return false; |
| 493 | } |
| 494 | ++fIndexPoolUseCnt; |
| 495 | return true; |
| 496 | } |
| 497 | |
| 498 | void GrGpu::releaseReservedVertexSpace() { |
| 499 | const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 500 | GrAssert(kReserved_GeometrySrcType == geoSrc.fVertexSrc); |
| 501 | size_t bytes = geoSrc.fVertexCount * VertexSize(geoSrc.fVertexLayout); |
| 502 | fVertexPool->putBack(bytes); |
| 503 | --fVertexPoolUseCnt; |
| 504 | } |
| 505 | |
| 506 | void GrGpu::releaseReservedIndexSpace() { |
| 507 | const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 508 | GrAssert(kReserved_GeometrySrcType == geoSrc.fIndexSrc); |
| 509 | size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 510 | fIndexPool->putBack(bytes); |
| 511 | --fIndexPoolUseCnt; |
| 512 | } |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 513 | |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 514 | void GrGpu::onSetVertexSourceToArray(const void* vertexArray, int vertexCount) { |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 515 | this->prepareVertexPool(); |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 516 | GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 517 | #if GR_DEBUG |
| 518 | bool success = |
| 519 | #endif |
bsalomon@google.com | e79c815 | 2012-03-29 19:07:12 +0000 | [diff] [blame] | 520 | fVertexPool->appendVertices(this->getVertexLayout(), |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 521 | vertexCount, |
| 522 | vertexArray, |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 523 | &geomPoolState.fPoolVertexBuffer, |
| 524 | &geomPoolState.fPoolStartVertex); |
| 525 | ++fVertexPoolUseCnt; |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 526 | GR_DEBUGASSERT(success); |
| 527 | } |
| 528 | |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 529 | void GrGpu::onSetIndexSourceToArray(const void* indexArray, int indexCount) { |
bsalomon@google.com | bcdbbe6 | 2011-04-12 15:40:00 +0000 | [diff] [blame] | 530 | this->prepareIndexPool(); |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 531 | GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 532 | #if GR_DEBUG |
| 533 | bool success = |
| 534 | #endif |
| 535 | fIndexPool->appendIndices(indexCount, |
| 536 | indexArray, |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 537 | &geomPoolState.fPoolIndexBuffer, |
| 538 | &geomPoolState.fPoolStartIndex); |
| 539 | ++fIndexPoolUseCnt; |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 540 | GR_DEBUGASSERT(success); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 541 | } |
| 542 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 543 | void GrGpu::releaseVertexArray() { |
| 544 | // if vertex source was array, we stowed data in the pool |
| 545 | const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 546 | GrAssert(kArray_GeometrySrcType == geoSrc.fVertexSrc); |
| 547 | size_t bytes = geoSrc.fVertexCount * VertexSize(geoSrc.fVertexLayout); |
| 548 | fVertexPool->putBack(bytes); |
| 549 | --fVertexPoolUseCnt; |
| 550 | } |
| 551 | |
| 552 | void GrGpu::releaseIndexArray() { |
| 553 | // if index source was array, we stowed data in the pool |
| 554 | const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 555 | GrAssert(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
| 556 | size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 557 | fIndexPool->putBack(bytes); |
| 558 | --fIndexPoolUseCnt; |
| 559 | } |
| 560 | |