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 "GrClipData.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; |
22 class GrAutoScratchTexture; | |
23 class GrDrawState; | 22 class GrDrawState; |
24 class GrDrawTarget; | 23 class GrDrawTarget; |
25 class GrFontCache; | 24 class GrFontCache; |
26 class GrFragmentProcessor; | 25 class GrFragmentProcessor; |
27 class GrGpu; | 26 class GrGpu; |
28 class GrGpuTraceMarker; | 27 class GrGpuTraceMarker; |
29 class GrIndexBuffer; | 28 class GrIndexBuffer; |
30 class GrIndexBufferAllocPool; | 29 class GrIndexBufferAllocPool; |
31 class GrInOrderDrawBuffer; | 30 class GrInOrderDrawBuffer; |
32 class GrLayerCache; | 31 class GrLayerCache; |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 | 1041 |
1043 /** | 1042 /** |
1044 * This callback allows the resource cache to callback into the GrContext | 1043 * This callback allows the resource cache to callback into the GrContext |
1045 * when the cache is still overbudget after a purge. | 1044 * when the cache is still overbudget after a purge. |
1046 */ | 1045 */ |
1047 static bool OverbudgetCB(void* data); | 1046 static bool OverbudgetCB(void* data); |
1048 | 1047 |
1049 typedef SkRefCnt INHERITED; | 1048 typedef SkRefCnt INHERITED; |
1050 }; | 1049 }; |
1051 | 1050 |
1052 /** | |
1053 * This is deprecated. Don't use it. | |
1054 */ | |
1055 class SK_API GrAutoScratchTexture : public ::SkNoncopyable { | |
1056 public: | |
1057 GrAutoScratchTexture() | |
1058 : fContext(NULL) | |
1059 , fTexture(NULL) { | |
1060 } | |
1061 | |
1062 GrAutoScratchTexture(GrContext* context, | |
1063 const GrTextureDesc& desc, | |
1064 GrContext::ScratchTexMatch match = GrContext::kApprox_S
cratchTexMatch, | |
1065 bool internalFlag = false) | |
1066 : fContext(NULL) | |
1067 , fTexture(NULL) { | |
1068 this->set(context, desc, match, internalFlag); | |
1069 } | |
1070 | |
1071 ~GrAutoScratchTexture() { | |
1072 this->reset(); | |
1073 } | |
1074 | |
1075 void reset() { | |
1076 if (fContext && fTexture) { | |
1077 fTexture->unref(); | |
1078 fTexture = NULL; | |
1079 } | |
1080 } | |
1081 | |
1082 GrTexture* detach() { | |
1083 GrTexture* texture = fTexture; | |
1084 fTexture = NULL; | |
1085 return texture; | |
1086 } | |
1087 | |
1088 GrTexture* set(GrContext* context, | |
1089 const GrTextureDesc& desc, | |
1090 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch
TexMatch, | |
1091 bool internalFlag = 0) { | |
1092 this->reset(); | |
1093 | |
1094 fContext = context; | |
1095 if (fContext) { | |
1096 fTexture = fContext->refScratchTexture(desc, match, internalFlag); | |
1097 if (NULL == fTexture) { | |
1098 fContext = NULL; | |
1099 } | |
1100 return fTexture; | |
1101 } else { | |
1102 return NULL; | |
1103 } | |
1104 } | |
1105 | |
1106 GrTexture* texture() { return fTexture; } | |
1107 | |
1108 private: | |
1109 GrContext* fContext; | |
1110 GrTexture* fTexture; | |
1111 }; | |
1112 | |
1113 #endif | 1051 #endif |
OLD | NEW |