| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #ifndef GrGpu_DEFINED | 10 #ifndef GrGpu_DEFINED |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 GrContext* getContext() { return this->INHERITED::getContext(); } | 60 GrContext* getContext() { return this->INHERITED::getContext(); } |
| 61 const GrContext* getContext() const { return this->INHERITED::getContext();
} | 61 const GrContext* getContext() const { return this->INHERITED::getContext();
} |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * The GrGpu object normally assumes that no outsider is setting state | 64 * The GrGpu object normally assumes that no outsider is setting state |
| 65 * within the underlying 3D API's context/device/whatever. This call informs | 65 * within the underlying 3D API's context/device/whatever. This call informs |
| 66 * the GrGpu that the state was modified and it shouldn't make assumptions | 66 * the GrGpu that the state was modified and it shouldn't make assumptions |
| 67 * about the state. | 67 * about the state. |
| 68 */ | 68 */ |
| 69 void markContextDirty() { fContextIsDirty = true; } | 69 void markContextDirty(GrContext::GrState state = GrContext::kGrState_ALL) { |
| 70 fContextIsDirty = true; |
| 71 fResetBits |= state; |
| 72 } |
| 70 | 73 |
| 71 void unimpl(const char[]); | 74 void unimpl(const char[]); |
| 72 | 75 |
| 73 /** | 76 /** |
| 74 * Creates a texture object. If desc width or height is not a power of | 77 * Creates a texture object. If desc width or height is not a power of |
| 75 * two but underlying API requires a power of two texture then srcData | 78 * two but underlying API requires a power of two texture then srcData |
| 76 * will be embedded in a power of two texture. The extra width and height | 79 * will be embedded in a power of two texture. The extra width and height |
| 77 * is filled as though srcData were rendered clamped into the texture. | 80 * is filled as though srcData were rendered clamped into the texture. |
| 78 * | 81 * |
| 79 * If kRenderTarget_TextureFlag is specified the GrRenderTarget is | 82 * If kRenderTarget_TextureFlag is specified the GrRenderTarget is |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void setStencilSettings(const GrStencilSettings& settings) { | 327 void setStencilSettings(const GrStencilSettings& settings) { |
| 325 fStencilSettings = settings; | 328 fStencilSettings = settings; |
| 326 } | 329 } |
| 327 void disableStencil() { fStencilSettings.setDisabled(); } | 330 void disableStencil() { fStencilSettings.setDisabled(); } |
| 328 | 331 |
| 329 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is | 332 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is |
| 330 // free to clear the remaining bits to zero if masked clears are more | 333 // free to clear the remaining bits to zero if masked clears are more |
| 331 // expensive than clearing all bits. | 334 // expensive than clearing all bits. |
| 332 virtual void clearStencilClip(const GrIRect& rect, bool insideClip) = 0; | 335 virtual void clearStencilClip(const GrIRect& rect, bool insideClip) = 0; |
| 333 | 336 |
| 337 /** |
| 338 * Only reset texture binding |
| 339 */ |
| 340 virtual void resetTextureBinding() = 0; |
| 341 |
| 334 enum PrivateDrawStateStateBits { | 342 enum PrivateDrawStateStateBits { |
| 335 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), | 343 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), |
| 336 | 344 |
| 337 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify | 345 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify |
| 338 // stencil bits used for | 346 // stencil bits used for |
| 339 // clipping. | 347 // clipping. |
| 340 }; | 348 }; |
| 341 | 349 |
| 342 protected: | 350 protected: |
| 343 enum DrawType { | 351 enum DrawType { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCou
nt) SK_OVERRIDE; | 427 virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCou
nt) SK_OVERRIDE; |
| 420 virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount)
SK_OVERRIDE; | 428 virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount)
SK_OVERRIDE; |
| 421 virtual void releaseVertexArray() SK_OVERRIDE; | 429 virtual void releaseVertexArray() SK_OVERRIDE; |
| 422 virtual void releaseIndexArray() SK_OVERRIDE; | 430 virtual void releaseIndexArray() SK_OVERRIDE; |
| 423 virtual void geometrySourceWillPush() SK_OVERRIDE; | 431 virtual void geometrySourceWillPush() SK_OVERRIDE; |
| 424 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK
_OVERRIDE; | 432 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK
_OVERRIDE; |
| 425 | 433 |
| 426 | 434 |
| 427 // called when the 3D context state is unknown. Subclass should emit any | 435 // called when the 3D context state is unknown. Subclass should emit any |
| 428 // assumed 3D context state and dirty any state cache. | 436 // assumed 3D context state and dirty any state cache. |
| 429 virtual void onResetContext() = 0; | 437 virtual void onResetContext(int resetBits) = 0; |
| 430 | 438 |
| 431 // overridden by backend-specific derived class to create objects. | 439 // overridden by backend-specific derived class to create objects. |
| 432 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, | 440 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
| 433 const void* srcData, | 441 const void* srcData, |
| 434 size_t rowBytes) = 0; | 442 size_t rowBytes) = 0; |
| 435 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; | 443 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; |
| 436 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; | 444 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; |
| 437 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) =
0; | 445 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) =
0; |
| 438 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0; | 446 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0; |
| 439 virtual GrPath* onCreatePath(const SkPath& path) = 0; | 447 virtual GrPath* onCreatePath(const SkPath& path) = 0; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 508 |
| 501 // readies the pools to provide vertex/index data. | 509 // readies the pools to provide vertex/index data. |
| 502 void prepareVertexPool(); | 510 void prepareVertexPool(); |
| 503 void prepareIndexPool(); | 511 void prepareIndexPool(); |
| 504 | 512 |
| 505 void resetContext() { | 513 void resetContext() { |
| 506 // We call this because the client may have messed with the | 514 // We call this because the client may have messed with the |
| 507 // stencil buffer. Perhaps we should detect whether it is a | 515 // stencil buffer. Perhaps we should detect whether it is a |
| 508 // internally created stencil buffer and if so skip the invalidate. | 516 // internally created stencil buffer and if so skip the invalidate. |
| 509 fClipMaskManager.invalidateStencilMask(); | 517 fClipMaskManager.invalidateStencilMask(); |
| 510 this->onResetContext(); | 518 this->onResetContext(fResetBits); |
| 519 fResetBits = 0; |
| 511 ++fResetTimestamp; | 520 ++fResetTimestamp; |
| 512 } | 521 } |
| 513 | 522 |
| 514 void handleDirtyContext() { | 523 void handleDirtyContext() { |
| 515 if (fContextIsDirty) { | 524 if (fContextIsDirty) { |
| 516 this->resetContext(); | 525 this->resetContext(); |
| 517 fContextIsDirty = false; | 526 fContextIsDirty = false; |
| 518 } | 527 } |
| 519 } | 528 } |
| 520 | 529 |
| 521 enum { | 530 enum { |
| 522 kPreallocGeomPoolStateStackCnt = 4, | 531 kPreallocGeomPoolStateStackCnt = 4, |
| 523 }; | 532 }; |
| 524 typedef SkTInternalLList<GrResource> ResourceList; | 533 typedef SkTInternalLList<GrResource> ResourceList; |
| 525 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; | 534 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; |
| 526 ResetTimestamp fResetTi
mestamp; | 535 ResetTimestamp fResetTi
mestamp; |
| 527 GrVertexBufferAllocPool* fVertexP
ool; | 536 GrVertexBufferAllocPool* fVertexP
ool; |
| 528 GrIndexBufferAllocPool* fIndexPo
ol; | 537 GrIndexBufferAllocPool* fIndexPo
ol; |
| 529 // counts number of uses of vertex/index pool in the geometry stack | 538 // counts number of uses of vertex/index pool in the geometry stack |
| 530 int fVertexP
oolUseCnt; | 539 int fVertexP
oolUseCnt; |
| 531 int fIndexPo
olUseCnt; | 540 int fIndexPo
olUseCnt; |
| 532 // these are mutable so they can be created on-demand | 541 // these are mutable so they can be created on-demand |
| 533 mutable GrIndexBuffer* fQuadInd
exBuffer; | 542 mutable GrIndexBuffer* fQuadInd
exBuffer; |
| 534 bool fContext
IsDirty; | 543 bool fContext
IsDirty; |
| 544 int fResetBi
ts; |
| 535 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his | 545 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his |
| 536 // functionality to GrResourceCache. | 546 // functionality to GrResourceCache. |
| 537 ResourceList fResourc
eList; | 547 ResourceList fResourc
eList; |
| 538 | 548 |
| 539 typedef GrDrawTarget INHERITED; | 549 typedef GrDrawTarget INHERITED; |
| 540 }; | 550 }; |
| 541 | 551 |
| 542 #endif | 552 #endif |
| OLD | NEW |