| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 static const int VERTEX_POOL_VB_COUNT = 4; | 21 static const int VERTEX_POOL_VB_COUNT = 4; |
| 22 static const size_t INDEX_POOL_IB_SIZE = 1 << 16; | 22 static const size_t INDEX_POOL_IB_SIZE = 1 << 16; |
| 23 static const int INDEX_POOL_IB_COUNT = 4; | 23 static const int INDEX_POOL_IB_COUNT = 4; |
| 24 | 24 |
| 25 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 26 | 26 |
| 27 #define DEBUG_INVAL_BUFFER 0xdeadcafe | 27 #define DEBUG_INVAL_BUFFER 0xdeadcafe |
| 28 #define DEBUG_INVAL_START_IDX -1 | 28 #define DEBUG_INVAL_START_IDX -1 |
| 29 | 29 |
| 30 GrGpu::GrGpu(GrContext* context) | 30 GrGpu::GrGpu(GrContext* context) |
| 31 : GrDrawTarget(context) | 31 : INHERITED(context) |
| 32 , fResetTimestamp(kExpiredTimestamp+1) | 32 , fResetTimestamp(kExpiredTimestamp+1) |
| 33 , fResetBits(kAll_GrBackendState) | 33 , fResetBits(kAll_GrBackendState) |
| 34 , fVertexPool(NULL) | 34 , fVertexPool(NULL) |
| 35 , fIndexPool(NULL) | 35 , fIndexPool(NULL) |
| 36 , fVertexPoolUseCnt(0) | 36 , fVertexPoolUseCnt(0) |
| 37 , fIndexPoolUseCnt(0) | 37 , fIndexPoolUseCnt(0) |
| 38 , fQuadIndexBuffer(NULL) { | 38 , fQuadIndexBuffer(NULL) { |
| 39 | 39 |
| 40 fClipMaskManager.setGpu(this); | 40 fClipMaskManager.setGpu(this); |
| 41 | 41 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 renderTarget = this->getDrawState().getRenderTarget(); | 205 renderTarget = this->getDrawState().getRenderTarget(); |
| 206 } | 206 } |
| 207 if (NULL == renderTarget) { | 207 if (NULL == renderTarget) { |
| 208 SkASSERT(0); | 208 SkASSERT(0); |
| 209 return; | 209 return; |
| 210 } | 210 } |
| 211 this->handleDirtyContext(); | 211 this->handleDirtyContext(); |
| 212 this->onClear(renderTarget, rect, color, canIgnoreRect); | 212 this->onClear(renderTarget, rect, color, canIgnoreRect); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void GrGpu::clearStencilClip(const SkIRect& rect, |
| 216 bool insideClip, |
| 217 GrRenderTarget* renderTarget) { |
| 218 if (NULL == renderTarget) { |
| 219 renderTarget = this->getDrawState().getRenderTarget(); |
| 220 } |
| 221 if (NULL == renderTarget) { |
| 222 SkASSERT(0); |
| 223 return; |
| 224 } |
| 225 this->handleDirtyContext(); |
| 226 this->onClearStencilClip(renderTarget, rect, insideClip); |
| 227 } |
| 228 |
| 215 bool GrGpu::readPixels(GrRenderTarget* target, | 229 bool GrGpu::readPixels(GrRenderTarget* target, |
| 216 int left, int top, int width, int height, | 230 int left, int top, int width, int height, |
| 217 GrPixelConfig config, void* buffer, | 231 GrPixelConfig config, void* buffer, |
| 218 size_t rowBytes) { | 232 size_t rowBytes) { |
| 219 this->handleDirtyContext(); | 233 this->handleDirtyContext(); |
| 220 return this->onReadPixels(target, left, top, width, height, | 234 return this->onReadPixels(target, left, top, width, height, |
| 221 config, buffer, rowBytes); | 235 config, buffer, rowBytes); |
| 222 } | 236 } |
| 223 | 237 |
| 224 bool GrGpu::writeTexturePixels(GrTexture* texture, | 238 bool GrGpu::writeTexturePixels(GrTexture* texture, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 309 |
| 296 return fQuadIndexBuffer; | 310 return fQuadIndexBuffer; |
| 297 } | 311 } |
| 298 | 312 |
| 299 //////////////////////////////////////////////////////////////////////////////// | 313 //////////////////////////////////////////////////////////////////////////////// |
| 300 | 314 |
| 301 bool GrGpu::setupClipAndFlushState(DrawType type, | 315 bool GrGpu::setupClipAndFlushState(DrawType type, |
| 302 const GrDeviceCoordTexture* dstCopy, | 316 const GrDeviceCoordTexture* dstCopy, |
| 303 const SkRect* devBounds, | 317 const SkRect* devBounds, |
| 304 GrDrawState::AutoRestoreEffects* are) { | 318 GrDrawState::AutoRestoreEffects* are) { |
| 305 ScissorState scissorState; | 319 GrClipMaskManager::ScissorState scissorState; |
| 306 GrDrawState::AutoRestoreStencil ars; | 320 GrDrawState::AutoRestoreStencil ars; |
| 307 if (!fClipMaskManager.setupClipping(this->getClip(), | 321 if (!fClipMaskManager.setupClipping(this->getClip(), |
| 308 devBounds, | 322 devBounds, |
| 309 are, | 323 are, |
| 310 &ars, | 324 &ars, |
| 311 &scissorState)) { | 325 &scissorState)) { |
| 312 return false; | 326 return false; |
| 313 } | 327 } |
| 314 | 328 |
| 315 if (!this->flushGraphicsState(type, scissorState, dstCopy)) { | 329 if (!this->flushGraphicsState(type, scissorState, dstCopy)) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 547 } |
| 534 | 548 |
| 535 void GrGpu::releaseIndexArray() { | 549 void GrGpu::releaseIndexArray() { |
| 536 // if index source was array, we stowed data in the pool | 550 // if index source was array, we stowed data in the pool |
| 537 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 551 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 538 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 552 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
| 539 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 553 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 540 fIndexPool->putBack(bytes); | 554 fIndexPool->putBack(bytes); |
| 541 --fIndexPoolUseCnt; | 555 --fIndexPoolUseCnt; |
| 542 } | 556 } |
| OLD | NEW |