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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 * at least as large in width and height as desc specifies. If desc | 273 * at least as large in width and height as desc specifies. If desc |
274 * specifies that texture is a render target then result will be a | 274 * specifies that texture is a render target then result will be a |
275 * render target. If desc specifies a render target and doesn't set the | 275 * render target. If desc specifies a render target and doesn't set the |
276 * no stencil flag then result will have a stencil. Format and aa level | 276 * no stencil flag then result will have a stencil. Format and aa level |
277 * will always match. | 277 * will always match. |
278 */ | 278 */ |
279 kApprox_ScratchTexMatch | 279 kApprox_ScratchTexMatch |
280 }; | 280 }; |
281 | 281 |
282 /** | 282 /** |
283 * Returns a texture matching the desc. It's contents are unknown. Subsequen
t | 283 * Returns a texture matching the desc. It's contents are unknown. The calle
r |
284 * requests with the same descriptor are not guaranteed to return the same | |
285 * texture. The same texture is guaranteed not be returned again until it is | |
286 * unlocked. Call must be balanced with an unlockTexture() call. The caller | |
287 * owns a ref on the returned texture and must balance with a call to unref. | 284 * owns a ref on the returned texture and must balance with a call to unref. |
| 285 * It is guaranteed that the same texture will not be returned in subsequent |
| 286 * calls until all refs to the texture are dropped. |
288 * | 287 * |
289 * Textures created by createAndLockTexture() hide the complications of | 288 * Textures created by createTexture() hide the complications of |
290 * tiling non-power-of-two textures on APIs that don't support this (e.g. | 289 * tiling non-power-of-two textures on APIs that don't support this (e.g. |
291 * unextended GLES2). Tiling a NPOT texture created by lockScratchTexture on | 290 * unextended GLES2). NPOT scratch textures are not tilable on such APIs. |
292 * such an API will create gaps in the tiling pattern. This includes clamp | |
293 * mode. (This may be addressed in a future update.)7 | |
294 * | 291 * |
295 * internalFlag is a temporary workaround until changes in the internal | 292 * internalFlag is a temporary workaround until changes in the internal |
296 * architecture are complete. Use the default value. | 293 * architecture are complete. Use the default value. |
297 */ | 294 */ |
298 GrTexture* lockAndRefScratchTexture(const GrTextureDesc&, ScratchTexMatch ma
tch, | 295 GrTexture* refScratchTexture(const GrTextureDesc&, ScratchTexMatch match, |
299 bool internalFlag = false); | 296 bool internalFlag = false); |
300 | 297 |
301 /** | 298 /** |
302 * Creates a texture that is outside the cache. Does not count against | 299 * Creates a texture that is outside the cache. Does not count against |
303 * cache's budget. | 300 * cache's budget. |
| 301 * |
| 302 * Textures created by createTexture() hide the complications of |
| 303 * tiling non-power-of-two textures on APIs that don't support this (e.g. |
| 304 * unextended GLES2). NPOT uncached textures are not tilable on such APIs. |
304 */ | 305 */ |
305 GrTexture* createUncachedTexture(const GrTextureDesc& desc, | 306 GrTexture* createUncachedTexture(const GrTextureDesc& desc, |
306 void* srcData, | 307 void* srcData, |
307 size_t rowBytes); | 308 size_t rowBytes); |
308 | 309 |
309 /** | 310 /** |
310 * Returns true if the specified use of an indexed texture is supported. | 311 * Returns true if the specified use of an indexed texture is supported. |
311 * Support may depend upon whether the texture params indicate that the | 312 * Support may depend upon whether the texture params indicate that the |
312 * texture will be tiled. Passing NULL for the texture params indicates | 313 * texture will be tiled. Passing NULL for the texture params indicates |
313 * clamp mode. | 314 * clamp mode. |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 } | 1086 } |
1086 | 1087 |
1087 GrTexture* set(GrContext* context, | 1088 GrTexture* set(GrContext* context, |
1088 const GrTextureDesc& desc, | 1089 const GrTextureDesc& desc, |
1089 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch
TexMatch, | 1090 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch
TexMatch, |
1090 bool internalFlag = 0) { | 1091 bool internalFlag = 0) { |
1091 this->reset(); | 1092 this->reset(); |
1092 | 1093 |
1093 fContext = context; | 1094 fContext = context; |
1094 if (fContext) { | 1095 if (fContext) { |
1095 fTexture = fContext->lockAndRefScratchTexture(desc, match, internalF
lag); | 1096 fTexture = fContext->refScratchTexture(desc, match, internalFlag); |
1096 if (NULL == fTexture) { | 1097 if (NULL == fTexture) { |
1097 fContext = NULL; | 1098 fContext = NULL; |
1098 } | 1099 } |
1099 return fTexture; | 1100 return fTexture; |
1100 } else { | 1101 } else { |
1101 return NULL; | 1102 return NULL; |
1102 } | 1103 } |
1103 } | 1104 } |
1104 | 1105 |
1105 GrTexture* texture() { return fTexture; } | 1106 GrTexture* texture() { return fTexture; } |
1106 | 1107 |
1107 private: | 1108 private: |
1108 GrContext* fContext; | 1109 GrContext* fContext; |
1109 GrTexture* fTexture; | 1110 GrTexture* fTexture; |
1110 }; | 1111 }; |
1111 | 1112 |
1112 #endif | 1113 #endif |
OLD | NEW |