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

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

Issue 1869753003: Replace many skia::RefPtr with sk_sp<> in cc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
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_CONTROLLER_H_ 5 #ifndef CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_
6 #define CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ 6 #define CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/containers/mru_cache.h" 12 #include "base/containers/mru_cache.h"
13 #include "base/memory/discardable_memory.h" 13 #include "base/memory/discardable_memory.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/trace_event/memory_dump_provider.h" 15 #include "base/trace_event/memory_dump_provider.h"
16 #include "cc/base/cc_export.h" 16 #include "cc/base/cc_export.h"
17 #include "cc/resources/resource_format.h" 17 #include "cc/resources/resource_format.h"
18 #include "cc/tiles/image_decode_controller.h" 18 #include "cc/tiles/image_decode_controller.h"
19 #include "skia/ext/refptr.h"
20 19
21 class SkImageTextureData; 20 class SkImageTextureData;
22 21
23 namespace cc { 22 namespace cc {
24 23
25 class ContextProvider; 24 class ContextProvider;
26 25
27 // GpuImageDecodeController handles the decode and upload of images that will 26 // GpuImageDecodeController handles the decode and upload of images that will
28 // be used by Skia's GPU raster path. It also maintains a cache of these 27 // be used by Skia's GPU raster path. It also maintains a cache of these
29 // decoded/uploaded images for later re-use. 28 // decoded/uploaded images for later re-use.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Set to true if the image was corrupt and could not be decoded. 100 // Set to true if the image was corrupt and could not be decoded.
102 bool decode_failure; 101 bool decode_failure;
103 }; 102 };
104 103
105 // Stores the GPU-side image and supporting fields. 104 // Stores the GPU-side image and supporting fields.
106 struct UploadedImageData { 105 struct UploadedImageData {
107 UploadedImageData(); 106 UploadedImageData();
108 ~UploadedImageData(); 107 ~UploadedImageData();
109 108
110 // May be null if image not yet uploaded / prepared. 109 // May be null if image not yet uploaded / prepared.
111 skia::RefPtr<SkImage> image; 110 sk_sp<SkImage> image;
112 // True if the image is counting against our memory limits. 111 // True if the image is counting against our memory limits.
113 bool budgeted; 112 bool budgeted;
114 uint32_t ref_count; 113 uint32_t ref_count;
115 }; 114 };
116 115
117 struct ImageData { 116 struct ImageData {
118 ImageData(DecodedDataMode mode, size_t size); 117 ImageData(DecodedDataMode mode, size_t size);
119 ~ImageData(); 118 ~ImageData();
120 119
121 const DecodedDataMode mode; 120 const DecodedDataMode mode;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const DrawImage& image); 157 const DrawImage& image);
159 SkImageInfo CreateImageInfoForDrawImage(const DrawImage& draw_image) const; 158 SkImageInfo CreateImageInfoForDrawImage(const DrawImage& draw_image) const;
160 159
161 // The following two functions also require the |context_| lock to be held. 160 // The following two functions also require the |context_| lock to be held.
162 void UploadImageIfNecessary(const DrawImage& draw_image, 161 void UploadImageIfNecessary(const DrawImage& draw_image,
163 ImageData* image_data); 162 ImageData* image_data);
164 void DeletePendingImages(); 163 void DeletePendingImages();
165 164
166 const ResourceFormat format_; 165 const ResourceFormat format_;
167 ContextProvider* context_; 166 ContextProvider* context_;
168 skia::RefPtr<GrContextThreadSafeProxy> context_threadsafe_proxy_; 167 sk_sp<GrContextThreadSafeProxy> context_threadsafe_proxy_;
169 168
170 // All members below this point must only be accessed while holding |lock_|. 169 // All members below this point must only be accessed while holding |lock_|.
171 base::Lock lock_; 170 base::Lock lock_;
172 171
173 std::unordered_map<uint32_t, scoped_refptr<ImageDecodeTask>> 172 std::unordered_map<uint32_t, scoped_refptr<ImageDecodeTask>>
174 pending_image_upload_tasks_; 173 pending_image_upload_tasks_;
175 std::unordered_map<uint32_t, scoped_refptr<ImageDecodeTask>> 174 std::unordered_map<uint32_t, scoped_refptr<ImageDecodeTask>>
176 pending_image_decode_tasks_; 175 pending_image_decode_tasks_;
177 176
178 ImageDataMRUCache image_data_; 177 ImageDataMRUCache image_data_;
179 178
180 size_t cached_items_limit_; 179 size_t cached_items_limit_;
181 size_t cached_bytes_limit_; 180 size_t cached_bytes_limit_;
182 size_t bytes_used_; 181 size_t bytes_used_;
183 182
184 // We can't release GPU backed SkImages without holding the context lock, 183 // We can't release GPU backed SkImages without holding the context lock,
185 // so we add them to this list and defer deletion until the next time the lock 184 // so we add them to this list and defer deletion until the next time the lock
186 // is held. 185 // is held.
187 std::vector<skia::RefPtr<SkImage>> images_pending_deletion_; 186 std::vector<sk_sp<SkImage>> images_pending_deletion_;
188 }; 187 };
189 188
190 } // namespace cc 189 } // namespace cc
191 190
192 #endif // CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ 191 #endif // CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698