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

Side by Side Diff: cc/tiles/gpu_image_decode_cache.h

Issue 2836703003: Use RefCountedThreadSafe in GPU IDC (Closed)
Patch Set: Created 3 years, 8 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_TILES_GPU_IMAGE_DECODE_CACHE_H_ 5 #ifndef CC_TILES_GPU_IMAGE_DECODE_CACHE_H_
6 #define CC_TILES_GPU_IMAGE_DECODE_CACHE_H_ 6 #define CC_TILES_GPU_IMAGE_DECODE_CACHE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <vector> 10 #include <vector>
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 int ref_reached_zero_count = 0; 223 int ref_reached_zero_count = 0;
224 }; 224 };
225 225
226 void ReportUsageStats() const; 226 void ReportUsageStats() const;
227 227
228 // May be null if image not yet uploaded / prepared. 228 // May be null if image not yet uploaded / prepared.
229 sk_sp<SkImage> image_; 229 sk_sp<SkImage> image_;
230 UsageStats usage_stats_; 230 UsageStats usage_stats_;
231 }; 231 };
232 232
233 struct ImageData : public base::RefCounted<ImageData> { 233 struct ImageData : public base::RefCountedThreadSafe<ImageData> {
234 ImageData(DecodedDataMode mode, 234 ImageData(DecodedDataMode mode,
235 size_t size, 235 size_t size,
236 const gfx::ColorSpace& target_color_space, 236 const gfx::ColorSpace& target_color_space,
237 const SkImage::DeferredTextureImageUsageParams& upload_params); 237 const SkImage::DeferredTextureImageUsageParams& upload_params);
238 238
239 const DecodedDataMode mode; 239 const DecodedDataMode mode;
240 const size_t size; 240 const size_t size;
241 gfx::ColorSpace target_color_space; 241 gfx::ColorSpace target_color_space;
242 bool is_at_raster = false; 242 bool is_at_raster = false;
243 SkImage::DeferredTextureImageUsageParams upload_params; 243 SkImage::DeferredTextureImageUsageParams upload_params;
244 244
245 // If true, this image is no longer in our |persistent_cache_| and will be 245 // If true, this image is no longer in our |persistent_cache_| and will be
246 // deleted as soon as its ref count reaches zero. 246 // deleted as soon as its ref count reaches zero.
247 bool is_orphaned = false; 247 bool is_orphaned = false;
248 248
249 DecodedImageData decode; 249 DecodedImageData decode;
250 UploadedImageData upload; 250 UploadedImageData upload;
251 251
252 private: 252 private:
253 friend class base::RefCounted<ImageData>; 253 friend class base::RefCountedThreadSafe<ImageData>;
254 ~ImageData(); 254 ~ImageData();
255 }; 255 };
256 256
257 // A ref-count and ImageData, used to associate the ImageData with a specific 257 // A ref-count and ImageData, used to associate the ImageData with a specific
258 // DrawImage in the |in_use_cache_|. 258 // DrawImage in the |in_use_cache_|.
259 struct InUseCacheEntry { 259 struct InUseCacheEntry {
260 explicit InUseCacheEntry(scoped_refptr<ImageData> image_data); 260 explicit InUseCacheEntry(scoped_refptr<ImageData> image_data);
261 InUseCacheEntry(const InUseCacheEntry& other); 261 InUseCacheEntry(const InUseCacheEntry& other);
262 InUseCacheEntry(InUseCacheEntry&& other); 262 InUseCacheEntry(InUseCacheEntry&& other);
263 ~InUseCacheEntry(); 263 ~InUseCacheEntry();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 // We can't release GPU backed SkImages without holding the context lock, 369 // We can't release GPU backed SkImages without holding the context lock,
370 // so we add them to this list and defer deletion until the next time the lock 370 // so we add them to this list and defer deletion until the next time the lock
371 // is held. 371 // is held.
372 std::vector<sk_sp<SkImage>> images_pending_deletion_; 372 std::vector<sk_sp<SkImage>> images_pending_deletion_;
373 }; 373 };
374 374
375 } // namespace cc 375 } // namespace cc
376 376
377 #endif // CC_TILES_GPU_IMAGE_DECODE_CACHE_H_ 377 #endif // CC_TILES_GPU_IMAGE_DECODE_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698