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