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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 /** | 172 /** |
173 * Stores a custom resource in the cache, based on the specified key. | 173 * Stores a custom resource in the cache, based on the specified key. |
174 */ | 174 */ |
175 void addResourceToCache(const GrResourceKey&, GrGpuResource*); | 175 void addResourceToCache(const GrContentKey&, 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 GrResourceKey&); | 182 GrGpuResource* findAndRefCachedResource(const GrContentKey&); |
183 | 183 |
184 /** | 184 /** |
185 * Creates a new text rendering context that is optimal for the | 185 * Creates a new text rendering context that is optimal for the |
186 * render target and the context. Caller assumes the ownership | 186 * render target and the context. Caller assumes the ownership |
187 * of the returned object. The returned object must be deleted | 187 * of the returned object. The returned object must be deleted |
188 * before the context is destroyed. | 188 * before the context is destroyed. |
189 */ | 189 */ |
190 GrTextContext* createTextContext(GrRenderTarget*, | 190 GrTextContext* createTextContext(GrRenderTarget*, |
191 const SkDeviceProperties&, | 191 const SkDeviceProperties&, |
192 bool enableDistanceFieldFonts); | 192 bool enableDistanceFieldFonts); |
193 | 193 |
194 /////////////////////////////////////////////////////////////////////////// | 194 /////////////////////////////////////////////////////////////////////////// |
195 // Textures | 195 // Textures |
196 | 196 |
197 /** | 197 /** |
198 * Creates a new entry, based on the specified key and texture and returns i
t. The caller owns a | 198 * Creates a new entry, based on the specified key and texture and returns i
t. The caller owns a |
199 * ref on the returned texture which must be balanced by a call to unref. | 199 * ref on the returned texture which must be balanced by a call to unref. |
200 * | 200 * |
| 201 * TODO: Move resizing logic out of GrContext and have the caller set the co
ntent key on the |
| 202 * returned texture rather than take it as a param. |
| 203 * |
201 * @param params The texture params used to draw a texture may help deter
mine | 204 * @param params The texture params used to draw a texture may help deter
mine |
202 * the cache entry used. (e.g. different versions may exist | 205 * the cache entry used. (e.g. different versions may exist |
203 * for different wrap modes on GPUs with limited NPOT | 206 * for different wrap modes on GPUs with limited NPOT |
204 * texture support). NULL implies clamp wrap modes. | 207 * texture support). NULL implies clamp wrap modes. |
205 * @param desc Description of the texture properties. | 208 * @param desc Description of the texture properties. |
206 * @param cacheID Cache-specific properties (e.g., texture gen ID) | 209 * @param key Key to associate with the texture. |
207 * @param srcData Pointer to the pixel values. | 210 * @param srcData Pointer to the pixel values. |
208 * @param rowBytes The number of bytes between rows of the texture. Zero | 211 * @param rowBytes The number of bytes between rows of the texture. Zero |
209 * implies tightly packed rows. For compressed pixel config
s, this | 212 * implies tightly packed rows. For compressed pixel config
s, this |
210 * field is ignored. | 213 * field is ignored. |
211 * @param cacheKey (optional) If non-NULL, we'll write the cache key we use
d to cacheKey. | 214 * @param outKey (optional) If non-NULL, we'll write the cache key we use
d to cacheKey. this |
| 215 * may differ from key on GPUs that don't support tiling NP
OT textures. |
212 */ | 216 */ |
213 GrTexture* createTexture(const GrTextureParams* params, | 217 GrTexture* createTexture(const GrTextureParams* params, |
214 const GrSurfaceDesc& desc, | 218 const GrSurfaceDesc& desc, |
215 const GrCacheID& cacheID, | 219 const GrContentKey& key, |
216 const void* srcData, | 220 const void* srcData, |
217 size_t rowBytes, | 221 size_t rowBytes, |
218 GrResourceKey* cacheKey = NULL); | 222 GrContentKey* outKey = NULL); |
219 /** | 223 /** |
220 * Search for an entry based on key and dimensions. If found, ref it and ret
urn it. The return | 224 * Search for an entry based on key and dimensions. If found, ref it and ret
urn it. The return |
221 * value will be NULL if not found. The caller must balance with a call to u
nref. | 225 * value will be NULL if not found. The caller must balance with a call to u
nref. |
222 * | 226 * |
| 227 * TODO: Remove this function and do lookups generically. |
| 228 * |
223 * @param desc Description of the texture properties. | 229 * @param desc Description of the texture properties. |
224 * @param cacheID Cache-specific properties (e.g., texture gen ID) | 230 * @param key key to use for texture look up. |
225 * @param params The texture params used to draw a texture may help deter
mine | 231 * @param params The texture params used to draw a texture may help deter
mine |
226 * the cache entry used. (e.g. different versions may exist | 232 * the cache entry used. (e.g. different versions may exist |
227 * for different wrap modes on GPUs with limited NPOT | 233 * for different wrap modes on GPUs with limited NPOT |
228 * texture support). NULL implies clamp wrap modes. | 234 * texture support). NULL implies clamp wrap modes. |
229 */ | 235 */ |
230 GrTexture* findAndRefTexture(const GrSurfaceDesc& desc, | 236 GrTexture* findAndRefTexture(const GrSurfaceDesc& desc, |
231 const GrCacheID& cacheID, | 237 const GrContentKey& key, |
232 const GrTextureParams* params); | 238 const GrTextureParams* params); |
233 /** | 239 /** |
234 * Determines whether a texture is in the cache. If the texture is found it | 240 * Determines whether a texture is in the cache. If the texture is found it |
235 * will not be locked or returned. This call does not affect the priority of | 241 * will not be locked or returned. This call does not affect the priority of |
236 * the texture for deletion. | 242 * the texture for deletion. |
| 243 * |
| 244 * TODO: Remove this function and do cache checks generically. |
237 */ | 245 */ |
238 bool isTextureInCache(const GrSurfaceDesc& desc, | 246 bool isTextureInCache(const GrSurfaceDesc& desc, |
239 const GrCacheID& cacheID, | 247 const GrContentKey& key, |
240 const GrTextureParams* params) const; | 248 const GrTextureParams* params) const; |
241 | 249 |
242 /** | 250 /** |
243 * Enum that determines how closely a returned scratch texture must match | 251 * Enum that determines how closely a returned scratch texture must match |
244 * a provided GrSurfaceDesc. | 252 * a provided GrSurfaceDesc. |
245 */ | 253 */ |
246 enum ScratchTexMatch { | 254 enum ScratchTexMatch { |
247 /** | 255 /** |
248 * Finds a texture that exactly matches the descriptor. | 256 * Finds a texture that exactly matches the descriptor. |
249 */ | 257 */ |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 GrDrawTarget* prepareToDraw(GrPipelineBuilder*, const GrPaint* paint, const
AutoCheckFlush*); | 872 GrDrawTarget* prepareToDraw(GrPipelineBuilder*, const GrPaint* paint, const
AutoCheckFlush*); |
865 | 873 |
866 void internalDrawPath(GrDrawTarget*, | 874 void internalDrawPath(GrDrawTarget*, |
867 GrPipelineBuilder*, | 875 GrPipelineBuilder*, |
868 const SkMatrix& viewMatrix, | 876 const SkMatrix& viewMatrix, |
869 GrColor, | 877 GrColor, |
870 bool useAA, | 878 bool useAA, |
871 const SkPath&, | 879 const SkPath&, |
872 const GrStrokeInfo&); | 880 const GrStrokeInfo&); |
873 | 881 |
874 GrTexture* createResizedTexture(const GrSurfaceDesc& desc, | 882 // TODO: Move this out of GrContext. |
875 const GrCacheID& cacheID, | 883 GrTexture* createResizedTexture(const GrSurfaceDesc&, |
| 884 const GrContentKey& origKey, |
876 const void* srcData, | 885 const void* srcData, |
877 size_t rowBytes, | 886 size_t rowBytes, |
878 bool filter); | 887 bool filter); |
879 | 888 |
880 /** | 889 /** |
881 * These functions create premul <-> unpremul effects if it is possible to g
enerate a pair | 890 * These functions create premul <-> unpremul effects if it is possible to g
enerate a pair |
882 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O
therwise, they | 891 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O
therwise, they |
883 * return NULL. | 892 * return NULL. |
884 */ | 893 */ |
885 const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, c
onst SkMatrix&); | 894 const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, c
onst SkMatrix&); |
886 const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, c
onst SkMatrix&); | 895 const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, c
onst SkMatrix&); |
887 | 896 |
888 /** | 897 /** |
889 * This callback allows the resource cache to callback into the GrContext | 898 * This callback allows the resource cache to callback into the GrContext |
890 * when the cache is still over budget after a purge. | 899 * when the cache is still over budget after a purge. |
891 */ | 900 */ |
892 static void OverBudgetCB(void* data); | 901 static void OverBudgetCB(void* data); |
893 | 902 |
894 typedef SkRefCnt INHERITED; | 903 typedef SkRefCnt INHERITED; |
895 }; | 904 }; |
896 | 905 |
897 #endif | 906 #endif |
OLD | NEW |