Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: include/gpu/GrTextureProvider.h

Issue 1567983002: Add guards to GrTextureProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@gpudeviceguards
Patch Set: got it Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
35 return this->createTexture(desc, budgeted, NULL, 0); 37 return this->createTexture(desc, budgeted, NULL, 0);
36 } 38 }
37 39
38 /** Assigns a unique key to the texture. The texture will be findable via th is key using 40 /** Assigns a unique key to the texture. The texture will be findable via th is key using
39 findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed. */ 41 findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed. */
40 void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) { 42 void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) {
41 this->assignUniqueKeyToResource(key, texture); 43 this->assignUniqueKeyToResource(key, texture);
42 } 44 }
43 45
44 /** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */ 46 /** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */
45 GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key) { 47 GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key);
46 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key);
47 if (resource) {
48 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture();
49 SkASSERT(texture);
50 return texture;
51 }
52 return NULL;
53 }
54 48
55 /** 49 /**
56 * Determines whether a texture is associated with the unique key. If the te xture is found it 50 * Determines whether a texture is associated with the unique key. If the te xture is found it
57 * will not be locked or returned. This call does not affect the priority of the resource for 51 * will not be locked or returned. This call does not affect the priority of the resource for
58 * deletion. 52 * deletion.
59 */ 53 */
60 bool existsTextureWithUniqueKey(const GrUniqueKey& key) const { 54 bool existsTextureWithUniqueKey(const GrUniqueKey& key) const {
61 return this->existsResourceWithUniqueKey(key); 55 return this->existsResourceWithUniqueKey(key);
62 } 56 }
63 57
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 * similar to wrapBackendTexture but can be used to draw into surfaces 121 * 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 122 * 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 123 * the client will resolve to a texture). Currently wrapped render targets
130 * always use the kBorrow_GrWrapOwnership semantics. 124 * always use the kBorrow_GrWrapOwnership semantics.
131 * 125 *
132 * @return GrTexture object or NULL on failure. 126 * @return GrTexture object or NULL on failure.
133 */ 127 */
134 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de sc); 128 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de sc);
135 129
136 protected: 130 protected:
137 GrTextureProvider(GrGpu* gpu, GrResourceCache* cache) : fCache(cache), fGpu( gpu) {} 131 GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* singleO wner);
138 132
139 /** 133 /**
140 * Assigns a unique key to a resource. If the key is associated with another resource that 134 * 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. 135 * association is removed and replaced by this resource.
142 */ 136 */
143 void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*); 137 void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*);
144 138
145 /** 139 /**
146 * Finds a resource in the cache, based on the specified key. This is intend ed for use in 140 * 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 141 * conjunction with addResourceToCache(). The return value will be NULL if n ot found. The
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 const GrGpu* gpu() const { return fGpu; } 173 const GrGpu* gpu() const { return fGpu; }
180 174
181 bool isAbandoned() const { 175 bool isAbandoned() const {
182 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); 176 SkASSERT(SkToBool(fGpu) == SkToBool(fCache));
183 return !SkToBool(fCache); 177 return !SkToBool(fCache);
184 } 178 }
185 179
186 private: 180 private:
187 GrResourceCache* fCache; 181 GrResourceCache* fCache;
188 GrGpu* fGpu; 182 GrGpu* fGpu;
183
184 // In debug builds we guard against improper thread handling
185 SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
189 }; 186 };
190 187
191 #endif 188 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698