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 |
11 #include "GrTexture.h" | 11 #include "GrTexture.h" |
12 #include "SkImageFilter.h" | 12 #include "SkImageFilter.h" |
13 | 13 |
14 class GrSingleOwner; | |
15 | |
14 class SK_API GrTextureProvider { | 16 class SK_API GrTextureProvider { |
15 public: | 17 public: |
16 /////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////// |
17 // Textures | 19 // Textures |
18 | 20 |
19 /** | 21 /** |
20 * Creates a new texture in the resource cache and returns it. The caller ow ns a | 22 * Creates a new texture in the resource cache and returns it. The caller ow ns a |
21 * ref on the returned texture which must be balanced by a call to unref. | 23 * ref on the returned texture which must be balanced by a call to unref. |
22 * | 24 * |
23 * @param desc Description of the texture properties. | 25 * @param desc Description of the texture properties. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 * similar to wrapBackendTexture but can be used to draw into surfaces | 129 * similar to wrapBackendTexture but can be used to draw into surfaces |
128 * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that | 130 * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that |
129 * the client will resolve to a texture). Currently wrapped render targets | 131 * the client will resolve to a texture). Currently wrapped render targets |
130 * always use the kBorrow_GrWrapOwnership semantics. | 132 * always use the kBorrow_GrWrapOwnership semantics. |
131 * | 133 * |
132 * @return GrTexture object or NULL on failure. | 134 * @return GrTexture object or NULL on failure. |
133 */ | 135 */ |
134 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de sc); | 136 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de sc); |
135 | 137 |
136 protected: | 138 protected: |
137 GrTextureProvider(GrGpu* gpu, GrResourceCache* cache) : fCache(cache), fGpu( gpu) {} | 139 GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* singleO wner) |
140 : fCache(cache) | |
141 , fGpu(gpu) | |
142 , fSingleOwner(singleOwner) {} | |
138 | 143 |
139 /** | 144 /** |
140 * Assigns a unique key to a resource. If the key is associated with another resource that | 145 * Assigns a unique key to a resource. If the key is associated with another resource that |
141 * association is removed and replaced by this resource. | 146 * association is removed and replaced by this resource. |
142 */ | 147 */ |
143 void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*); | 148 void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*); |
144 | 149 |
145 /** | 150 /** |
146 * Finds a resource in the cache, based on the specified key. This is intend ed for use in | 151 * Finds a resource in the cache, based on the specified key. This is intend ed for use in |
147 * conjunction with addResourceToCache(). The return value will be NULL if n ot found. The | 152 * conjunction with addResourceToCache(). The return value will be NULL if n ot found. The |
(...skipping 30 matching lines...) Expand all Loading... | |
178 GrGpu* gpu() { return fGpu; } | 183 GrGpu* gpu() { return fGpu; } |
179 const GrGpu* gpu() const { return fGpu; } | 184 const GrGpu* gpu() const { return fGpu; } |
180 | 185 |
181 bool isAbandoned() const { | 186 bool isAbandoned() const { |
182 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); | 187 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); |
183 return !SkToBool(fCache); | 188 return !SkToBool(fCache); |
184 } | 189 } |
185 | 190 |
186 private: | 191 private: |
187 GrResourceCache* fCache; | 192 GrResourceCache* fCache; |
188 GrGpu* fGpu; | 193 GrGpu* fGpu; |
robertphillips
2016/01/07 19:07:02
// Guard for single-threaded access. Owned by GrCo
| |
194 GrSingleOwner* fSingleOwner; | |
189 }; | 195 }; |
190 | 196 |
191 #endif | 197 #endif |
OLD | NEW |