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 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 * The 'info' parameter will be stored and passed to the callback function. | 78 * The 'info' parameter will be stored and passed to the callback function. |
79 */ | 79 */ |
80 void addCleanUp(PFCleanUpFunc cleanUp, void* info) { | 80 void addCleanUp(PFCleanUpFunc cleanUp, void* info) { |
81 CleanUpData* entry = fCleanUpData.push(); | 81 CleanUpData* entry = fCleanUpData.push(); |
82 | 82 |
83 entry->fFunc = cleanUp; | 83 entry->fFunc = cleanUp; |
84 entry->fInfo = info; | 84 entry->fInfo = info; |
85 } | 85 } |
86 | 86 |
87 /** | 87 /** |
88 * Abandons all GPU resources, assumes 3D API state is unknown. Call this | 88 * Abandons all GPU resources and assumes the underlying backend 3D API |
89 * if you have lost the associated GPU context, and thus internal texture, | 89 * context is not longer usable. Call this if you have lost the associated |
90 * buffer, etc. references/IDs are now invalid. Should be called even when | 90 * GPU context, and thus internal texture, buffer, etc. references/IDs are |
91 * GrContext is no longer going to be used for two reasons: | 91 * now invalid. Should be called even when GrContext is no longer going to |
| 92 * be used for two reasons: |
92 * 1) ~GrContext will not try to free the objects in the 3D API. | 93 * 1) ~GrContext will not try to free the objects in the 3D API. |
93 * 2) If you've created GrGpuResources that outlive the GrContext they | 94 * 2) Any GrGpuResources created by this GrContext that outlive |
94 * will be marked as invalid (GrGpuResource::isValid()) and won't | 95 * will be marked as invalid (GrGpuResource::wasDestroyed()) and |
95 * attempt to free their underlying resource in the 3D API. | 96 * when they're destroyed no 3D API calls will be made. |
96 * Content drawn since the last GrContext::flush() may be lost. | 97 * Content drawn since the last GrContext::flush() may be lost. After this |
| 98 * function is called the only valid action on the GrContext or |
| 99 * GrGpuResources it created is to destroy them. |
97 */ | 100 */ |
98 void contextLost(); | 101 void abandonContext(); |
99 | 102 void contextDestroyed() { this->abandonContext(); } // legacy alias |
100 /** | |
101 * Similar to contextLost, but makes no attempt to reset state. | |
102 * Use this method when GrContext destruction is pending, but | |
103 * the graphics context is destroyed first. | |
104 */ | |
105 void contextDestroyed(); | |
106 | 103 |
107 /////////////////////////////////////////////////////////////////////////// | 104 /////////////////////////////////////////////////////////////////////////// |
108 // Resource Cache | 105 // Resource Cache |
109 | 106 |
110 /** | 107 /** |
111 * Return the current GPU resource cache limits. | 108 * Return the current GPU resource cache limits. |
112 * | 109 * |
113 * @param maxResources If non-null, returns maximum number of resources tha
t | 110 * @param maxResources If non-null, returns maximum number of resources tha
t |
114 * can be held in the cache. | 111 * can be held in the cache. |
115 * @param maxResourceBytes If non-null, returns maximum number of bytes of | 112 * @param maxResourceBytes If non-null, returns maximum number of bytes of |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 } | 1141 } |
1145 | 1142 |
1146 GrTexture* texture() { return fTexture; } | 1143 GrTexture* texture() { return fTexture; } |
1147 | 1144 |
1148 private: | 1145 private: |
1149 GrContext* fContext; | 1146 GrContext* fContext; |
1150 GrTexture* fTexture; | 1147 GrTexture* fTexture; |
1151 }; | 1148 }; |
1152 | 1149 |
1153 #endif | 1150 #endif |
OLD | NEW |