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