| 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 "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrClipData.h" | 12 #include "GrClipData.h" |
| 13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
| 14 #include "GrPaint.h" | 14 #include "GrPaint.h" |
| 15 #include "GrPathRendererChain.h" | 15 #include "GrPathRendererChain.h" |
| 16 #include "GrPoint.h" | 16 #include "GrPoint.h" |
| 17 #include "GrRenderTarget.h" | 17 #include "GrRenderTarget.h" |
| 18 #include "GrRefCnt.h" | |
| 19 #include "GrTexture.h" | 18 #include "GrTexture.h" |
| 20 | 19 |
| 21 class GrAARectRenderer; | 20 class GrAARectRenderer; |
| 22 class GrAutoScratchTexture; | 21 class GrAutoScratchTexture; |
| 23 class GrDrawState; | 22 class GrDrawState; |
| 24 class GrDrawTarget; | 23 class GrDrawTarget; |
| 25 class GrEffect; | 24 class GrEffect; |
| 26 class GrFontCache; | 25 class GrFontCache; |
| 27 class GrGpu; | 26 class GrGpu; |
| 28 class GrIndexBuffer; | 27 class GrIndexBuffer; |
| 29 class GrIndexBufferAllocPool; | 28 class GrIndexBufferAllocPool; |
| 30 class GrInOrderDrawBuffer; | 29 class GrInOrderDrawBuffer; |
| 31 class GrOvalRenderer; | 30 class GrOvalRenderer; |
| 32 class GrPathRenderer; | 31 class GrPathRenderer; |
| 33 class GrResourceEntry; | 32 class GrResourceEntry; |
| 34 class GrResourceCache; | 33 class GrResourceCache; |
| 35 class GrStencilBuffer; | 34 class GrStencilBuffer; |
| 36 class GrTestTarget; | 35 class GrTestTarget; |
| 37 class GrTextureParams; | 36 class GrTextureParams; |
| 38 class GrVertexBuffer; | 37 class GrVertexBuffer; |
| 39 class GrVertexBufferAllocPool; | 38 class GrVertexBufferAllocPool; |
| 40 class GrSoftwarePathRenderer; | 39 class GrSoftwarePathRenderer; |
| 41 class SkStrokeRec; | 40 class SkStrokeRec; |
| 42 | 41 |
| 43 class SK_API GrContext : public GrRefCnt { | 42 class SK_API GrContext : public SkRefCnt { |
| 44 public: | 43 public: |
| 45 SK_DECLARE_INST_COUNT(GrContext) | 44 SK_DECLARE_INST_COUNT(GrContext) |
| 46 | 45 |
| 47 /** | 46 /** |
| 48 * Creates a GrContext for a backend context. | 47 * Creates a GrContext for a backend context. |
| 49 */ | 48 */ |
| 50 static GrContext* Create(GrBackend, GrBackendContext); | 49 static GrContext* Create(GrBackend, GrBackendContext); |
| 51 | 50 |
| 52 /** | 51 /** |
| 53 * Returns the number of GrContext instances for the current thread. | 52 * Returns the number of GrContext instances for the current thread. |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 */ | 627 */ |
| 629 void resolveRenderTarget(GrRenderTarget* target); | 628 void resolveRenderTarget(GrRenderTarget* target); |
| 630 | 629 |
| 631 /////////////////////////////////////////////////////////////////////////// | 630 /////////////////////////////////////////////////////////////////////////// |
| 632 // Helpers | 631 // Helpers |
| 633 | 632 |
| 634 class AutoRenderTarget : public ::GrNoncopyable { | 633 class AutoRenderTarget : public ::GrNoncopyable { |
| 635 public: | 634 public: |
| 636 AutoRenderTarget(GrContext* context, GrRenderTarget* target) { | 635 AutoRenderTarget(GrContext* context, GrRenderTarget* target) { |
| 637 fPrevTarget = context->getRenderTarget(); | 636 fPrevTarget = context->getRenderTarget(); |
| 638 GrSafeRef(fPrevTarget); | 637 SkSafeRef(fPrevTarget); |
| 639 context->setRenderTarget(target); | 638 context->setRenderTarget(target); |
| 640 fContext = context; | 639 fContext = context; |
| 641 } | 640 } |
| 642 AutoRenderTarget(GrContext* context) { | 641 AutoRenderTarget(GrContext* context) { |
| 643 fPrevTarget = context->getRenderTarget(); | 642 fPrevTarget = context->getRenderTarget(); |
| 644 GrSafeRef(fPrevTarget); | 643 SkSafeRef(fPrevTarget); |
| 645 fContext = context; | 644 fContext = context; |
| 646 } | 645 } |
| 647 ~AutoRenderTarget() { | 646 ~AutoRenderTarget() { |
| 648 if (NULL != fContext) { | 647 if (NULL != fContext) { |
| 649 fContext->setRenderTarget(fPrevTarget); | 648 fContext->setRenderTarget(fPrevTarget); |
| 650 } | 649 } |
| 651 GrSafeUnref(fPrevTarget); | 650 SkSafeUnref(fPrevTarget); |
| 652 } | 651 } |
| 653 private: | 652 private: |
| 654 GrContext* fContext; | 653 GrContext* fContext; |
| 655 GrRenderTarget* fPrevTarget; | 654 GrRenderTarget* fPrevTarget; |
| 656 }; | 655 }; |
| 657 | 656 |
| 658 /** | 657 /** |
| 659 * Save/restore the view-matrix in the context. It can optionally adjust a p
aint to account | 658 * Save/restore the view-matrix in the context. It can optionally adjust a p
aint to account |
| 660 * for a coordinate system change. Here is an example of how the paint param
can be used: | 659 * for a coordinate system change. Here is an example of how the paint param
can be used: |
| 661 * | 660 * |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 const GrEffectRef* createUPMToPMEffect(GrTexture* texture, | 926 const GrEffectRef* createUPMToPMEffect(GrTexture* texture, |
| 928 bool swapRAndB, | 927 bool swapRAndB, |
| 929 const SkMatrix& matrix); | 928 const SkMatrix& matrix); |
| 930 | 929 |
| 931 /** | 930 /** |
| 932 * This callback allows the resource cache to callback into the GrContext | 931 * This callback allows the resource cache to callback into the GrContext |
| 933 * when the cache is still overbudget after a purge. | 932 * when the cache is still overbudget after a purge. |
| 934 */ | 933 */ |
| 935 static bool OverbudgetCB(void* data); | 934 static bool OverbudgetCB(void* data); |
| 936 | 935 |
| 937 typedef GrRefCnt INHERITED; | 936 typedef SkRefCnt INHERITED; |
| 938 }; | 937 }; |
| 939 | 938 |
| 940 /** | 939 /** |
| 941 * Gets and locks a scratch texture from a descriptor using either exact or appr
oximate criteria. | 940 * Gets and locks a scratch texture from a descriptor using either exact or appr
oximate criteria. |
| 942 * Unlocks texture in the destructor. | 941 * Unlocks texture in the destructor. |
| 943 */ | 942 */ |
| 944 class GrAutoScratchTexture : ::GrNoncopyable { | 943 class GrAutoScratchTexture : ::GrNoncopyable { |
| 945 public: | 944 public: |
| 946 GrAutoScratchTexture() | 945 GrAutoScratchTexture() |
| 947 : fContext(NULL) | 946 : fContext(NULL) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 } | 1016 } |
| 1018 | 1017 |
| 1019 GrTexture* texture() { return fTexture; } | 1018 GrTexture* texture() { return fTexture; } |
| 1020 | 1019 |
| 1021 private: | 1020 private: |
| 1022 GrContext* fContext; | 1021 GrContext* fContext; |
| 1023 GrTexture* fTexture; | 1022 GrTexture* fTexture; |
| 1024 }; | 1023 }; |
| 1025 | 1024 |
| 1026 #endif | 1025 #endif |
| OLD | NEW |