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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 */ | 162 */ |
163 void purgeCache(); | 163 void purgeCache(); |
164 | 164 |
165 /** | 165 /** |
166 * Purge all the unlocked resources from the cache. | 166 * Purge all the unlocked resources from the cache. |
167 * This entry point is mainly meant for timing texture uploads | 167 * This entry point is mainly meant for timing texture uploads |
168 * and is not defined in normal builds of Skia. | 168 * and is not defined in normal builds of Skia. |
169 */ | 169 */ |
170 void purgeAllUnlockedResources(); | 170 void purgeAllUnlockedResources(); |
171 | 171 |
172 /** Sets a content key on the resource. The resource must not already have a
content key and | 172 /** Sets a unique key on the resource. The resource must not already have a
unique key and the |
173 * the key must not already be in use for this to succeed. | 173 * key must not already be in use for this to succeed. |
174 */ | 174 */ |
175 bool addResourceToCache(const GrContentKey&, GrGpuResource*); | 175 bool addResourceToCache(const GrUniqueKey&, GrGpuResource*); |
176 | 176 |
177 /** | 177 /** |
178 * Finds a resource in the cache, based on the specified key. This is intend
ed for use in | 178 * Finds a resource in the cache, based on the specified key. This is intend
ed for use in |
179 * conjunction with addResourceToCache(). The return value will be NULL if n
ot found. The | 179 * conjunction with addResourceToCache(). The return value will be NULL if n
ot found. The |
180 * caller must balance with a call to unref(). | 180 * caller must balance with a call to unref(). |
181 */ | 181 */ |
182 GrGpuResource* findAndRefCachedResource(const GrContentKey&); | 182 GrGpuResource* findAndRefCachedResource(const GrUniqueKey&); |
183 | 183 |
184 /** Helper for casting resource to a texture. Caller must be sure that the r
esource cached | 184 /** Helper for casting resource to a texture. Caller must be sure that the r
esource cached |
185 with the key is either NULL or a texture and not another resource type.
*/ | 185 with the key is either NULL or a texture and not another resource type.
*/ |
186 GrTexture* findAndRefCachedTexture(const GrContentKey& key) { | 186 GrTexture* findAndRefCachedTexture(const GrUniqueKey& key) { |
187 GrGpuResource* resource = this->findAndRefCachedResource(key); | 187 GrGpuResource* resource = this->findAndRefCachedResource(key); |
188 if (resource) { | 188 if (resource) { |
189 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); | 189 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); |
190 SkASSERT(texture); | 190 SkASSERT(texture); |
191 return texture; | 191 return texture; |
192 } | 192 } |
193 return NULL; | 193 return NULL; |
194 } | 194 } |
195 | 195 |
196 /** | 196 /** |
197 * Determines whether a resource is in the cache. If the resource is found i
t | 197 * Determines whether a resource is in the cache. If the resource is found i
t |
198 * will not be locked or returned. This call does not affect the priority of | 198 * will not be locked or returned. This call does not affect the priority of |
199 * the resource for deletion. | 199 * the resource for deletion. |
200 */ | 200 */ |
201 bool isResourceInCache(const GrContentKey& key) const; | 201 bool isResourceInCache(const GrUniqueKey& key) const; |
202 | 202 |
203 /** | 203 /** |
204 * Creates a new text rendering context that is optimal for the | 204 * Creates a new text rendering context that is optimal for the |
205 * render target and the context. Caller assumes the ownership | 205 * render target and the context. Caller assumes the ownership |
206 * of the returned object. The returned object must be deleted | 206 * of the returned object. The returned object must be deleted |
207 * before the context is destroyed. | 207 * before the context is destroyed. |
208 */ | 208 */ |
209 GrTextContext* createTextContext(GrRenderTarget*, | 209 GrTextContext* createTextContext(GrRenderTarget*, |
210 const SkDeviceProperties&, | 210 const SkDeviceProperties&, |
211 bool enableDistanceFieldFonts); | 211 bool enableDistanceFieldFonts); |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 /** | 827 /** |
828 * This callback allows the resource cache to callback into the GrContext | 828 * This callback allows the resource cache to callback into the GrContext |
829 * when the cache is still over budget after a purge. | 829 * when the cache is still over budget after a purge. |
830 */ | 830 */ |
831 static void OverBudgetCB(void* data); | 831 static void OverBudgetCB(void* data); |
832 | 832 |
833 typedef SkRefCnt INHERITED; | 833 typedef SkRefCnt INHERITED; |
834 }; | 834 }; |
835 | 835 |
836 #endif | 836 #endif |
OLD | NEW |