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

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

Issue 2844273004: cc: Make images that can't possibly fit in cache not checker. (Closed)
Patch Set: Created 3 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_IMAGE_CONTROLLER_H_ 5 #ifndef CC_TILES_IMAGE_CONTROLLER_H_
6 #define CC_TILES_IMAGE_CONTROLLER_H_ 6 #define CC_TILES_IMAGE_CONTROLLER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 virtual void UnlockImageDecode(ImageDecodeRequestId id); 49 virtual void UnlockImageDecode(ImageDecodeRequestId id);
50 50
51 // This function requests that the given image be decoded and locked. Once the 51 // This function requests that the given image be decoded and locked. Once the
52 // callback has been issued, it is passed an ID, which should be used to 52 // callback has been issued, it is passed an ID, which should be used to
53 // unlock this image. It is up to the caller to ensure that the image is later 53 // unlock this image. It is up to the caller to ensure that the image is later
54 // unlocked using UnlockImageDecode. 54 // unlocked using UnlockImageDecode.
55 // Virtual for testing. 55 // Virtual for testing.
56 virtual ImageDecodeRequestId QueueImageDecode( 56 virtual ImageDecodeRequestId QueueImageDecode(
57 sk_sp<const SkImage> image, 57 sk_sp<const SkImage> image,
58 const ImageDecodedCallback& callback); 58 const ImageDecodedCallback& callback);
59 size_t image_cache_max_limit_bytes() const {
60 return image_cache_max_limit_bytes_;
Khushal 2017/04/28 00:12:53 Could this just be cache_ ? cache_->GetMaximumMemo
vmpstr 2017/04/28 17:18:30 GetMaximumMemoryLimit is virtual so I just want to
61 }
59 62
60 protected: 63 protected:
61 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; 64 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
62 65
63 private: 66 private:
64 struct ImageDecodeRequest { 67 struct ImageDecodeRequest {
65 ImageDecodeRequest(); 68 ImageDecodeRequest();
66 ImageDecodeRequest(ImageDecodeRequestId id, 69 ImageDecodeRequest(ImageDecodeRequestId id,
67 const DrawImage& draw_image, 70 const DrawImage& draw_image,
68 const ImageDecodedCallback& callback, 71 const ImageDecodedCallback& callback,
(...skipping 21 matching lines...) Expand all
90 void ImageDecodeCompleted(ImageDecodeRequestId id); 93 void ImageDecodeCompleted(ImageDecodeRequestId id);
91 void GenerateTasksForOrphanedRequests(); 94 void GenerateTasksForOrphanedRequests();
92 95
93 ImageDecodeCache* cache_ = nullptr; 96 ImageDecodeCache* cache_ = nullptr;
94 std::vector<DrawImage> predecode_locked_images_; 97 std::vector<DrawImage> predecode_locked_images_;
95 98
96 static ImageDecodeRequestId s_next_image_decode_queue_id_; 99 static ImageDecodeRequestId s_next_image_decode_queue_id_;
97 base::flat_map<ImageDecodeRequestId, DrawImage> requested_locked_images_; 100 base::flat_map<ImageDecodeRequestId, DrawImage> requested_locked_images_;
98 101
99 base::SequencedTaskRunner* origin_task_runner_ = nullptr; 102 base::SequencedTaskRunner* origin_task_runner_ = nullptr;
103 size_t image_cache_max_limit_bytes_ = 0u;
100 104
101 // The variables defined below this lock (aside from weak_ptr_factory_) can 105 // The variables defined below this lock (aside from weak_ptr_factory_) can
102 // only be accessed when the lock is acquired. 106 // only be accessed when the lock is acquired.
103 base::Lock lock_; 107 base::Lock lock_;
104 std::map<ImageDecodeRequestId, ImageDecodeRequest> image_decode_queue_; 108 std::map<ImageDecodeRequestId, ImageDecodeRequest> image_decode_queue_;
105 std::map<ImageDecodeRequestId, ImageDecodeRequest> 109 std::map<ImageDecodeRequestId, ImageDecodeRequest>
106 requests_needing_completion_; 110 requests_needing_completion_;
107 bool abort_tasks_ = false; 111 bool abort_tasks_ = false;
108 // Orphaned requests are requests that were either in queue or needed a 112 // Orphaned requests are requests that were either in queue or needed a
109 // completion callback when we set the decode cache to be nullptr. When a new 113 // completion callback when we set the decode cache to be nullptr. When a new
110 // decode cache is set, these requests are re-enqueued again with tasks 114 // decode cache is set, these requests are re-enqueued again with tasks
111 // generated by the new cache. Note that when the cache is set, then aside 115 // generated by the new cache. Note that when the cache is set, then aside
112 // from generating new tasks, this vector should be empty. 116 // from generating new tasks, this vector should be empty.
113 std::vector<ImageDecodeRequest> orphaned_decode_requests_; 117 std::vector<ImageDecodeRequest> orphaned_decode_requests_;
114 118
115 base::WeakPtrFactory<ImageController> weak_ptr_factory_; 119 base::WeakPtrFactory<ImageController> weak_ptr_factory_;
116 120
117 DISALLOW_COPY_AND_ASSIGN(ImageController); 121 DISALLOW_COPY_AND_ASSIGN(ImageController);
118 }; 122 };
119 123
120 } // namespace cc 124 } // namespace cc
121 125
122 #endif // CC_TILES_IMAGE_CONTROLLER_H_ 126 #endif // CC_TILES_IMAGE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698