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: cc/tiles/software_image_decode_controller.h

Issue 1839833003: Add medium image quality to software predecode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing. Created 4 years, 7 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_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ 5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_
6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Get the decoded draw image for the given key and draw_image. Note that this 204 // Get the decoded draw image for the given key and draw_image. Note that this
205 // function has to be called with no lock acquired, since it will acquire its 205 // function has to be called with no lock acquired, since it will acquire its
206 // own locks and might call DecodeImageInternal above. Also note that this 206 // own locks and might call DecodeImageInternal above. Also note that this
207 // function will use the provided key, even if 207 // function will use the provided key, even if
208 // ImageKey::FromDrawImage(draw_image) would return a different key. 208 // ImageKey::FromDrawImage(draw_image) would return a different key.
209 // Note that when used internally, we still require that 209 // Note that when used internally, we still require that
210 // DrawWithImageFinished() is called afterwards. 210 // DrawWithImageFinished() is called afterwards.
211 DecodedDrawImage GetDecodedImageForDrawInternal(const ImageKey& key, 211 DecodedDrawImage GetDecodedImageForDrawInternal(const ImageKey& key,
212 const DrawImage& draw_image); 212 const DrawImage& draw_image);
213 213
214 // GetMediumQualityImageDecode is called by DecodeImageInternal to get the
215 // decoded and scaled image for medium quality.
216 // Like DecodeImageInternal, it should be called with no lock acquired
217 // and it also returns nullptr if the decoding or scaling failed.
218 std::unique_ptr<DecodedImage> GetMediumQualityImageDecode(
219 const ImageKey& key,
220 sk_sp<const SkImage> image);
221
214 // GetOriginalImageDecode is called by DecodeImageInternal when the quality 222 // GetOriginalImageDecode is called by DecodeImageInternal when the quality
215 // does not scale the image. Like DecodeImageInternal, it should be called 223 // does not scale the image. Like DecodeImageInternal, it should be called
216 // with no lock acquired and it returns nullptr if the decoding failed. 224 // with no lock acquired and it returns nullptr if the decoding failed.
217 std::unique_ptr<DecodedImage> GetOriginalImageDecode( 225 std::unique_ptr<DecodedImage> GetOriginalImageDecode(
218 const ImageKey& key, 226 const ImageKey& key,
219 sk_sp<const SkImage> image); 227 sk_sp<const SkImage> image);
220 228
221 // GetScaledImageDecode is called by DecodeImageInternal when the quality 229 // GetScaledImageDecode is called by DecodeImageInternal when the quality
222 // requires the image be scaled. Like DecodeImageInternal, it should be 230 // requires the image be scaled. Like DecodeImageInternal, it should be
223 // called with no lock acquired and it returns nullptr if the decoding or 231 // called with no lock acquired and it returns nullptr if the decoding or
224 // scaling failed. 232 // scaling failed.
225 std::unique_ptr<DecodedImage> GetScaledImageDecode( 233 std::unique_ptr<DecodedImage> GetScaledImageDecode(
226 const ImageKey& key, 234 const ImageKey& key,
227 sk_sp<const SkImage> image); 235 sk_sp<const SkImage> image);
228 236
229 void SanityCheckState(int line, bool lock_acquired); 237 void SanityCheckState(int line, bool lock_acquired);
230 void RefImage(const ImageKey& key); 238 void RefImage(const ImageKey& key);
231 void RefAtRasterImage(const ImageKey& key); 239 void RefAtRasterImage(const ImageKey& key);
232 void UnrefAtRasterImage(const ImageKey& key); 240 void UnrefAtRasterImage(const ImageKey& key);
233 241
234 // These functions indicate whether the images can be handled and cached by
235 // ImageDecodeController or whether they will fall through to Skia (with
236 // exception of possibly prerolling them). Over time these should return
237 // "false" in less cases, as the ImageDecodeController should start handling
238 // more of them.
239 bool CanHandleImage(const ImageKey& key);
240
241 // Helper function which dumps all images in a specific ImageMRUCache. 242 // Helper function which dumps all images in a specific ImageMRUCache.
242 void DumpImageMemoryForCache(const ImageMRUCache& cache, 243 void DumpImageMemoryForCache(const ImageMRUCache& cache,
243 const char* cache_name, 244 const char* cache_name,
244 base::trace_event::ProcessMemoryDump* pmd) const; 245 base::trace_event::ProcessMemoryDump* pmd) const;
245 246
246 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash> 247 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash>
247 pending_image_tasks_; 248 pending_image_tasks_;
248 249
249 // The members below this comment can only be accessed if the lock is held to 250 // The members below this comment can only be accessed if the lock is held to
250 // ensure that they are safe to access on multiple threads. 251 // ensure that they are safe to access on multiple threads.
251 base::Lock lock_; 252 base::Lock lock_;
252 253
253 // Decoded images and ref counts (predecode path). 254 // Decoded images and ref counts (predecode path).
254 ImageMRUCache decoded_images_; 255 ImageMRUCache decoded_images_;
255 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_; 256 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_;
256 257
257 // Decoded image and ref counts (at-raster decode path). 258 // Decoded image and ref counts (at-raster decode path).
258 ImageMRUCache at_raster_decoded_images_; 259 ImageMRUCache at_raster_decoded_images_;
259 std::unordered_map<ImageKey, int, ImageKeyHash> 260 std::unordered_map<ImageKey, int, ImageKeyHash>
260 at_raster_decoded_images_ref_counts_; 261 at_raster_decoded_images_ref_counts_;
261 262
262 MemoryBudget locked_images_budget_; 263 MemoryBudget locked_images_budget_;
263 264
264 // Note that this is used for cases where the only thing we do is preroll the
265 // image the first time we see it. This mimics the previous behavior and
266 // should over time change as the compositor starts to handle more cases.
267 std::unordered_set<uint32_t> prerolled_images_;
268
269 ResourceFormat format_; 265 ResourceFormat format_;
270 266
271 // Used to uniquely identify DecodedImages for memory traces. 267 // Used to uniquely identify DecodedImages for memory traces.
272 base::AtomicSequenceNumber next_tracing_id_; 268 base::AtomicSequenceNumber next_tracing_id_;
273 }; 269 };
274 270
275 } // namespace cc 271 } // namespace cc
276 272
277 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ 273 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/software_image_decode_controller.cc » ('j') | cc/tiles/software_image_decode_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698