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

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: 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 | « no previous file | 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698