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

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: Using SkSize instead of SkMatrix, some renaming + comments. 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_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 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(const ImageKey& key, 225 std::unique_ptr<DecodedImage> GetOriginalImageDecode(const ImageKey& key,
218 const SkImage& image); 226 const SkImage& image);
219 227
220 // GetScaledImageDecode is called by DecodeImageInternal when the quality 228 // GetScaledImageDecode is called by DecodeImageInternal when the quality
221 // requires the image be scaled. Like DecodeImageInternal, it should be 229 // requires the image be scaled. Like DecodeImageInternal, it should be
222 // called with no lock acquired and it returns nullptr if the decoding or 230 // called with no lock acquired and it returns nullptr if the decoding or
223 // scaling failed. 231 // scaling failed.
224 std::unique_ptr<DecodedImage> GetScaledImageDecode(const ImageKey& key, 232 std::unique_ptr<DecodedImage> GetScaledImageDecode(const ImageKey& key,
225 const SkImage& image); 233 const SkImage& image);
226 234
227 void SanityCheckState(int line, bool lock_acquired); 235 void SanityCheckState(int line, bool lock_acquired);
228 void RefImage(const ImageKey& key); 236 void RefImage(const ImageKey& key);
229 void RefAtRasterImage(const ImageKey& key); 237 void RefAtRasterImage(const ImageKey& key);
230 void UnrefAtRasterImage(const ImageKey& key); 238 void UnrefAtRasterImage(const ImageKey& key);
231 239
232 // These functions indicate whether the images can be handled and cached by
233 // ImageDecodeController or whether they will fall through to Skia (with
234 // exception of possibly prerolling them). Over time these should return
235 // "false" in less cases, as the ImageDecodeController should start handling
236 // more of them.
237 bool CanHandleImage(const ImageKey& key);
238
239 // Helper function which dumps all images in a specific ImageMRUCache. 240 // Helper function which dumps all images in a specific ImageMRUCache.
240 void DumpImageMemoryForCache(const ImageMRUCache& cache, 241 void DumpImageMemoryForCache(const ImageMRUCache& cache,
241 const char* cache_name, 242 const char* cache_name,
242 base::trace_event::ProcessMemoryDump* pmd) const; 243 base::trace_event::ProcessMemoryDump* pmd) const;
243 244
244 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash> 245 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash>
245 pending_image_tasks_; 246 pending_image_tasks_;
246 247
247 // The members below this comment can only be accessed if the lock is held to 248 // The members below this comment can only be accessed if the lock is held to
248 // ensure that they are safe to access on multiple threads. 249 // ensure that they are safe to access on multiple threads.
249 base::Lock lock_; 250 base::Lock lock_;
250 251
251 // Decoded images and ref counts (predecode path). 252 // Decoded images and ref counts (predecode path).
252 ImageMRUCache decoded_images_; 253 ImageMRUCache decoded_images_;
253 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_; 254 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_;
254 255
255 // Decoded image and ref counts (at-raster decode path). 256 // Decoded image and ref counts (at-raster decode path).
256 ImageMRUCache at_raster_decoded_images_; 257 ImageMRUCache at_raster_decoded_images_;
257 std::unordered_map<ImageKey, int, ImageKeyHash> 258 std::unordered_map<ImageKey, int, ImageKeyHash>
258 at_raster_decoded_images_ref_counts_; 259 at_raster_decoded_images_ref_counts_;
259 260
260 MemoryBudget locked_images_budget_; 261 MemoryBudget locked_images_budget_;
261 262
262 // Note that this is used for cases where the only thing we do is preroll the
263 // image the first time we see it. This mimics the previous behavior and
264 // should over time change as the compositor starts to handle more cases.
265 std::unordered_set<uint32_t> prerolled_images_;
266
267 ResourceFormat format_; 263 ResourceFormat format_;
268 264
269 // Used to uniquely identify DecodedImages for memory traces. 265 // Used to uniquely identify DecodedImages for memory traces.
270 base::AtomicSequenceNumber next_tracing_id_; 266 base::AtomicSequenceNumber next_tracing_id_;
271 }; 267 };
272 268
273 } // namespace cc 269 } // namespace cc
274 270
275 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ 271 #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