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(uint32_t state = kAll_GrBackendState) { |
| 70 fResetBits |= state; |
| 71 } |
70 | 72 |
71 void unimpl(const char[]); | 73 void unimpl(const char[]); |
72 | 74 |
73 /** | 75 /** |
74 * Creates a texture object. If desc width or height is not a power of | 76 * 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 | 77 * 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 | 78 * 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. | 79 * is filled as though srcData were rendered clamped into the texture. |
78 * | 80 * |
79 * If kRenderTarget_TextureFlag is specified the GrRenderTarget is | 81 * If kRenderTarget_TextureFlag is specified the GrRenderTarget is |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCou
nt) SK_OVERRIDE; | 421 virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCou
nt) SK_OVERRIDE; |
420 virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount)
SK_OVERRIDE; | 422 virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount)
SK_OVERRIDE; |
421 virtual void releaseVertexArray() SK_OVERRIDE; | 423 virtual void releaseVertexArray() SK_OVERRIDE; |
422 virtual void releaseIndexArray() SK_OVERRIDE; | 424 virtual void releaseIndexArray() SK_OVERRIDE; |
423 virtual void geometrySourceWillPush() SK_OVERRIDE; | 425 virtual void geometrySourceWillPush() SK_OVERRIDE; |
424 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK
_OVERRIDE; | 426 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK
_OVERRIDE; |
425 | 427 |
426 | 428 |
427 // called when the 3D context state is unknown. Subclass should emit any | 429 // called when the 3D context state is unknown. Subclass should emit any |
428 // assumed 3D context state and dirty any state cache. | 430 // assumed 3D context state and dirty any state cache. |
429 virtual void onResetContext() = 0; | 431 virtual void onResetContext(uint32_t resetBits) = 0; |
430 | 432 |
431 // overridden by backend-specific derived class to create objects. | 433 // overridden by backend-specific derived class to create objects. |
432 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, | 434 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
433 const void* srcData, | 435 const void* srcData, |
434 size_t rowBytes) = 0; | 436 size_t rowBytes) = 0; |
435 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; | 437 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; |
436 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; | 438 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; |
437 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) =
0; | 439 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) =
0; |
438 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0; | 440 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0; |
439 virtual GrPath* onCreatePath(const SkPath& path) = 0; | 441 virtual GrPath* onCreatePath(const SkPath& path) = 0; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 | 502 |
501 // readies the pools to provide vertex/index data. | 503 // readies the pools to provide vertex/index data. |
502 void prepareVertexPool(); | 504 void prepareVertexPool(); |
503 void prepareIndexPool(); | 505 void prepareIndexPool(); |
504 | 506 |
505 void resetContext() { | 507 void resetContext() { |
506 // We call this because the client may have messed with the | 508 // We call this because the client may have messed with the |
507 // stencil buffer. Perhaps we should detect whether it is a | 509 // stencil buffer. Perhaps we should detect whether it is a |
508 // internally created stencil buffer and if so skip the invalidate. | 510 // internally created stencil buffer and if so skip the invalidate. |
509 fClipMaskManager.invalidateStencilMask(); | 511 fClipMaskManager.invalidateStencilMask(); |
510 this->onResetContext(); | 512 this->onResetContext(fResetBits); |
| 513 fResetBits = 0; |
511 ++fResetTimestamp; | 514 ++fResetTimestamp; |
512 } | 515 } |
513 | 516 |
514 void handleDirtyContext() { | 517 void handleDirtyContext() { |
515 if (fContextIsDirty) { | 518 if (fResetBits) { |
516 this->resetContext(); | 519 this->resetContext(); |
517 fContextIsDirty = false; | |
518 } | 520 } |
519 } | 521 } |
520 | 522 |
521 enum { | 523 enum { |
522 kPreallocGeomPoolStateStackCnt = 4, | 524 kPreallocGeomPoolStateStackCnt = 4, |
523 }; | 525 }; |
524 typedef SkTInternalLList<GrResource> ResourceList; | 526 typedef SkTInternalLList<GrResource> ResourceList; |
525 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; | 527 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; |
526 ResetTimestamp fResetTi
mestamp; | 528 ResetTimestamp fResetTi
mestamp; |
| 529 uint32_t fResetBi
ts; |
527 GrVertexBufferAllocPool* fVertexP
ool; | 530 GrVertexBufferAllocPool* fVertexP
ool; |
528 GrIndexBufferAllocPool* fIndexPo
ol; | 531 GrIndexBufferAllocPool* fIndexPo
ol; |
529 // counts number of uses of vertex/index pool in the geometry stack | 532 // counts number of uses of vertex/index pool in the geometry stack |
530 int fVertexP
oolUseCnt; | 533 int fVertexP
oolUseCnt; |
531 int fIndexPo
olUseCnt; | 534 int fIndexPo
olUseCnt; |
532 // these are mutable so they can be created on-demand | 535 // these are mutable so they can be created on-demand |
533 mutable GrIndexBuffer* fQuadInd
exBuffer; | 536 mutable GrIndexBuffer* fQuadInd
exBuffer; |
534 bool fContext
IsDirty; | |
535 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his | 537 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his |
536 // functionality to GrResourceCache. | 538 // functionality to GrResourceCache. |
537 ResourceList fResourc
eList; | 539 ResourceList fResourc
eList; |
538 | 540 |
539 typedef GrDrawTarget INHERITED; | 541 typedef GrDrawTarget INHERITED; |
540 }; | 542 }; |
541 | 543 |
542 #endif | 544 #endif |
OLD | NEW |