| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrContext_DEFINED | 8 #ifndef GrContext_DEFINED |
| 9 #define GrContext_DEFINED | 9 #define GrContext_DEFINED |
| 10 | 10 |
| 11 #include "GrClipData.h" | 11 #include "GrClip.h" |
| 12 #include "GrColor.h" | 12 #include "GrColor.h" |
| 13 #include "GrPaint.h" | 13 #include "GrPaint.h" |
| 14 #include "GrPathRendererChain.h" | 14 #include "GrPathRendererChain.h" |
| 15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
| 16 #include "GrTexture.h" | 16 #include "GrTexture.h" |
| 17 #include "SkMatrix.h" | 17 #include "SkMatrix.h" |
| 18 #include "SkPathEffect.h" | 18 #include "SkPathEffect.h" |
| 19 #include "SkTypes.h" | 19 #include "SkTypes.h" |
| 20 | 20 |
| 21 class GrAARectRenderer; | 21 class GrAARectRenderer; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 * @return GrTexture object or NULL on failure. | 360 * @return GrTexture object or NULL on failure. |
| 361 */ | 361 */ |
| 362 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de
sc); | 362 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de
sc); |
| 363 | 363 |
| 364 /////////////////////////////////////////////////////////////////////////// | 364 /////////////////////////////////////////////////////////////////////////// |
| 365 // Clip state | 365 // Clip state |
| 366 /** | 366 /** |
| 367 * Gets the current clip. | 367 * Gets the current clip. |
| 368 * @return the current clip. | 368 * @return the current clip. |
| 369 */ | 369 */ |
| 370 const GrClipData* getClip() const { return fClip; } | 370 const GrClip* getClip() const { return fClip; } |
| 371 | 371 |
| 372 /** | 372 /** |
| 373 * Sets the clip. | 373 * Sets the clip. |
| 374 * @param clipData the clip to set. | 374 * @param clipData the clip to set. |
| 375 */ | 375 */ |
| 376 void setClip(const GrClipData* clipData) { fClip = clipData; } | 376 void setClip(const GrClip* clipData) { fClip = clipData; } |
| 377 | 377 |
| 378 /////////////////////////////////////////////////////////////////////////// | 378 /////////////////////////////////////////////////////////////////////////// |
| 379 // Draws | 379 // Draws |
| 380 | 380 |
| 381 /** | 381 /** |
| 382 * Clear the entire or rect of the render target, ignoring any clips. | 382 * Clear the entire or rect of the render target, ignoring any clips. |
| 383 * @param rect the rect to clear or the whole thing if rect is NULL. | 383 * @param rect the rect to clear or the whole thing if rect is NULL. |
| 384 * @param color the color to clear to. | 384 * @param color the color to clear to. |
| 385 * @param canIgnoreRect allows partial clears to be converted to whole | 385 * @param canIgnoreRect allows partial clears to be converted to whole |
| 386 * clears on platforms for which that is cheap | 386 * clears on platforms for which that is cheap |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 // This enum exists to require a caller of the constructor to acknowledg
e that the clip will | 673 // This enum exists to require a caller of the constructor to acknowledg
e that the clip will |
| 674 // initially be wide open. It also could be extended if there are other
desirable initial | 674 // initially be wide open. It also could be extended if there are other
desirable initial |
| 675 // clip states. | 675 // clip states. |
| 676 enum InitialClip { | 676 enum InitialClip { |
| 677 kWideOpen_InitialClip, | 677 kWideOpen_InitialClip, |
| 678 }; | 678 }; |
| 679 | 679 |
| 680 AutoClip(GrContext* context, InitialClip SkDEBUGCODE(initialState)) | 680 AutoClip(GrContext* context, InitialClip SkDEBUGCODE(initialState)) |
| 681 : fContext(context) { | 681 : fContext(context) { |
| 682 SkASSERT(kWideOpen_InitialClip == initialState); | 682 SkASSERT(kWideOpen_InitialClip == initialState); |
| 683 fNewClipData.fClipStack.reset(SkRef(&fNewClipStack)); | 683 fNewClipData.setClipStack(&fNewClipStack); |
| 684 | 684 |
| 685 fOldClip = context->getClip(); | 685 fOldClip = context->getClip(); |
| 686 context->setClip(&fNewClipData); | 686 context->setClip(&fNewClipData); |
| 687 } | 687 } |
| 688 | 688 |
| 689 AutoClip(GrContext* context, const SkRect& newClipRect) | 689 AutoClip(GrContext* context, const SkRect& newClipRect) |
| 690 : fContext(context) | 690 : fContext(context) |
| 691 , fNewClipStack(newClipRect) { | 691 , fNewClipStack(newClipRect) { |
| 692 fNewClipData.fClipStack.reset(SkRef(&fNewClipStack)); | 692 fNewClipData.setClipStack(&fNewClipStack); |
| 693 | 693 |
| 694 fOldClip = fContext->getClip(); | 694 fOldClip = fContext->getClip(); |
| 695 fContext->setClip(&fNewClipData); | 695 fContext->setClip(&fNewClipData); |
| 696 } | 696 } |
| 697 | 697 |
| 698 ~AutoClip() { | 698 ~AutoClip() { |
| 699 if (fContext) { | 699 if (fContext) { |
| 700 fContext->setClip(fOldClip); | 700 fContext->setClip(fOldClip); |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 private: | 703 private: |
| 704 GrContext* fContext; | 704 GrContext* fContext; |
| 705 const GrClipData* fOldClip; | 705 const GrClip* fOldClip; |
| 706 | 706 |
| 707 SkClipStack fNewClipStack; | 707 SkClipStack fNewClipStack; |
| 708 GrClipData fNewClipData; | 708 GrClip fNewClipData; |
| 709 }; | 709 }; |
| 710 | 710 |
| 711 class AutoWideOpenIdentityDraw { | 711 class AutoWideOpenIdentityDraw { |
| 712 public: | 712 public: |
| 713 AutoWideOpenIdentityDraw(GrContext* ctx) | 713 AutoWideOpenIdentityDraw(GrContext* ctx) |
| 714 : fAutoClip(ctx, AutoClip::kWideOpen_InitialClip) { | 714 : fAutoClip(ctx, AutoClip::kWideOpen_InitialClip) { |
| 715 } | 715 } |
| 716 | 716 |
| 717 private: | 717 private: |
| 718 AutoClip fAutoClip; | 718 AutoClip fAutoClip; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ | 754 /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ |
| 755 void dumpCacheStats(SkString*) const; | 755 void dumpCacheStats(SkString*) const; |
| 756 void printCacheStats() const; | 756 void printCacheStats() const; |
| 757 | 757 |
| 758 /** Prints GPU stats to the string if GR_GPU_STATS == 1. */ | 758 /** Prints GPU stats to the string if GR_GPU_STATS == 1. */ |
| 759 void dumpGpuStats(SkString*) const; | 759 void dumpGpuStats(SkString*) const; |
| 760 void printGpuStats() const; | 760 void printGpuStats() const; |
| 761 | 761 |
| 762 private: | 762 private: |
| 763 GrGpu* fGpu; | 763 GrGpu* fGpu; |
| 764 const GrClipData* fClip; // TODO: make this ref counted | 764 const GrClip* fClip; |
| 765 | 765 |
| 766 GrResourceCache* fResourceCache; | 766 GrResourceCache* fResourceCache; |
| 767 GrFontCache* fFontCache; | 767 GrFontCache* fFontCache; |
| 768 SkAutoTDelete<GrLayerCache> fLayerCache; | 768 SkAutoTDelete<GrLayerCache> fLayerCache; |
| 769 | 769 |
| 770 GrPathRendererChain* fPathRendererChain; | 770 GrPathRendererChain* fPathRendererChain; |
| 771 GrSoftwarePathRenderer* fSoftwarePathRenderer; | 771 GrSoftwarePathRenderer* fSoftwarePathRenderer; |
| 772 | 772 |
| 773 GrVertexBufferAllocPool* fDrawBufferVBAllocPool; | 773 GrVertexBufferAllocPool* fDrawBufferVBAllocPool; |
| 774 GrIndexBufferAllocPool* fDrawBufferIBAllocPool; | 774 GrIndexBufferAllocPool* fDrawBufferIBAllocPool; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 /** | 828 /** |
| 829 * This callback allows the resource cache to callback into the GrContext | 829 * This callback allows the resource cache to callback into the GrContext |
| 830 * when the cache is still over budget after a purge. | 830 * when the cache is still over budget after a purge. |
| 831 */ | 831 */ |
| 832 static void OverBudgetCB(void* data); | 832 static void OverBudgetCB(void* data); |
| 833 | 833 |
| 834 typedef SkRefCnt INHERITED; | 834 typedef SkRefCnt INHERITED; |
| 835 }; | 835 }; |
| 836 | 836 |
| 837 #endif | 837 #endif |
| OLD | NEW |