| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 GrTextureProvider_DEFINED | 8 #ifndef GrTextureProvider_DEFINED |
| 9 #define GrTextureProvider_DEFINED | 9 #define GrTextureProvider_DEFINED |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 /** | 54 /** |
| 55 * Determines whether a texture is associated with the unique key. If the te
xture is found it | 55 * Determines whether a texture is associated with the unique key. If the te
xture is found it |
| 56 * will not be locked or returned. This call does not affect the priority of
the resource for | 56 * will not be locked or returned. This call does not affect the priority of
the resource for |
| 57 * deletion. | 57 * deletion. |
| 58 */ | 58 */ |
| 59 bool existsTextureWithUniqueKey(const GrUniqueKey& key) const { | 59 bool existsTextureWithUniqueKey(const GrUniqueKey& key) const { |
| 60 return this->existsResourceWithUniqueKey(key); | 60 return this->existsResourceWithUniqueKey(key); |
| 61 } | 61 } |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * Enum that determines how closely a returned scratch texture must match | 64 * Enum that determines how closely a returned scratch resource must match |
| 65 * a provided GrSurfaceDesc. TODO: Remove this. createTexture() should be us
ed | 65 * a provided information. TODO: Remove this. createTexture()/createBuffer()
should be used |
| 66 * for exact match and refScratchTexture() should be replaced with createApp
roxTexture(). | 66 * for exact match and refScratchTexture() should be replaced with createApp
roxTexture(). |
| 67 */ | 67 */ |
| 68 enum ScratchTexMatch { | 68 enum ScratchMatch { |
| 69 /** | 69 /** |
| 70 * Finds a texture that exactly matches the descriptor. | 70 * Finds a resource that exactly matches the description. |
| 71 */ | 71 */ |
| 72 kExact_ScratchTexMatch, | 72 kExact_ScratchMatch, |
| 73 /** | 73 /** |
| 74 * Finds a texture that approximately matches the descriptor. Will be | 74 * Finds a resource that approximately matches the description. |
| 75 * at least as large in width and height as desc specifies. If desc | 75 * For textures, this will be at least as large in width and height as |
| 76 * specifies that texture is a render target then result will be a | 76 * desc specifies. If desc specifies that texture is a render target |
| 77 * render target. If desc specifies a render target and doesn't set the | 77 * then result will be a render target. If desc specifies a render |
| 78 * no stencil flag then result will have a stencil. Format and aa level | 78 * target and doesn't set the no stencil flag then result will have |
| 79 * will always match. | 79 * a stencil. Format and aa level will always match. |
| 80 */ | 80 */ |
| 81 kApprox_ScratchTexMatch | 81 kApprox_ScratchMatch |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Returns a texture matching the desc. It's contents are unknown. The calle
r | 85 * Returns a texture matching the desc. It's contents are unknown. The calle
r |
| 86 * owns a ref on the returned texture and must balance with a call to unref. | 86 * owns a ref on the returned texture and must balance with a call to unref. |
| 87 * It is guaranteed that the same texture will not be returned in subsequent | 87 * It is guaranteed that the same texture will not be returned in subsequent |
| 88 * calls until all refs to the texture are dropped. | 88 * calls until all refs to the texture are dropped. |
| 89 * | 89 * |
| 90 * internalFlag is a temporary workaround until changes in the internal | 90 * internalFlag is a temporary workaround until changes in the internal |
| 91 * architecture are complete. Use the default value. | 91 * architecture are complete. Use the default value. |
| 92 * | 92 * |
| 93 * TODO: Once internal flag can be removed, this should be replaced with | 93 * TODO: Once internal flag can be removed, this should be replaced with |
| 94 * createApproxTexture() and exact textures should be created with | 94 * createApproxTexture() and exact textures should be created with |
| 95 * createTexture(). | 95 * createTexture(). |
| 96 */ | 96 */ |
| 97 GrTexture* refScratchTexture(const GrSurfaceDesc&, ScratchTexMatch match, | 97 GrTexture* refScratchTexture(const GrSurfaceDesc&, ScratchMatch match, |
| 98 bool internalFlag = false); | 98 bool internalFlag = false); |
| 99 | 99 |
| 100 /////////////////////////////////////////////////////////////////////////// | 100 /////////////////////////////////////////////////////////////////////////// |
| 101 // Wrapped Backend Surfaces | 101 // Wrapped Backend Surfaces |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * Wraps an existing texture with a GrTexture object. | 104 * Wraps an existing texture with a GrTexture object. |
| 105 * | 105 * |
| 106 * OpenGL: if the object is a texture Gr may change its GL texture params | 106 * OpenGL: if the object is a texture Gr may change its GL texture params |
| 107 * when it is drawn. | 107 * when it is drawn. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 118 * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that | 118 * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that |
| 119 * the client will resolve to a texture). | 119 * the client will resolve to a texture). |
| 120 * | 120 * |
| 121 * @param desc description of the object to create. | 121 * @param desc description of the object to create. |
| 122 * | 122 * |
| 123 * @return GrTexture object or NULL on failure. | 123 * @return GrTexture object or NULL on failure. |
| 124 */ | 124 */ |
| 125 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de
sc); | 125 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de
sc); |
| 126 | 126 |
| 127 protected: | 127 protected: |
| 128 enum ScratchFlags { |
| 129 kExact_ScratchFlag = 0x1, |
| 130 kNoPendingIO_ScratchFlag = 0x2, |
| 131 kNoCreate_ScratchFlag = 0x4, |
| 132 }; |
| 133 |
| 128 GrTextureProvider(GrGpu* gpu, GrResourceCache* cache) : fCache(cache), fGpu(
gpu) {} | 134 GrTextureProvider(GrGpu* gpu, GrResourceCache* cache) : fCache(cache), fGpu(
gpu) {} |
| 129 | 135 |
| 130 /** | 136 /** |
| 131 * Assigns a unique key to a resource. If the key is associated with another
resource that | 137 * Assigns a unique key to a resource. If the key is associated with another
resource that |
| 132 * association is removed and replaced by this resource. | 138 * association is removed and replaced by this resource. |
| 133 */ | 139 */ |
| 134 void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*); | 140 void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*); |
| 135 | 141 |
| 136 /** | 142 /** |
| 137 * Finds a resource in the cache, based on the specified key. This is intend
ed for use in | 143 * Finds a resource in the cache, based on the specified key. This is intend
ed for use in |
| (...skipping 15 matching lines...) Expand all Loading... |
| 153 fCache = NULL; | 159 fCache = NULL; |
| 154 fGpu = NULL; | 160 fGpu = NULL; |
| 155 } | 161 } |
| 156 | 162 |
| 157 GrResourceCache* cache() { return fCache; } | 163 GrResourceCache* cache() { return fCache; } |
| 158 const GrResourceCache* cache() const { return fCache; } | 164 const GrResourceCache* cache() const { return fCache; } |
| 159 | 165 |
| 160 GrGpu* gpu() { return fGpu; } | 166 GrGpu* gpu() { return fGpu; } |
| 161 const GrGpu* gpu() const { return fGpu; } | 167 const GrGpu* gpu() const { return fGpu; } |
| 162 | 168 |
| 163 private: | |
| 164 bool isAbandoned() const { | 169 bool isAbandoned() const { |
| 165 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); | 170 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); |
| 166 return !SkToBool(fCache); | 171 return !SkToBool(fCache); |
| 167 } | 172 } |
| 168 | 173 |
| 174 private: |
| 169 GrResourceCache* fCache; | 175 GrResourceCache* fCache; |
| 170 GrGpu* fGpu; | 176 GrGpu* fGpu; |
| 171 }; | 177 }; |
| 172 | 178 |
| 173 #endif | 179 #endif |
| OLD | NEW |