OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // This function requests that the given image be decoded and locked. Once the | 46 // This function requests that the given image be decoded and locked. Once the |
47 // callback has been issued, it is passed an ID, which should be used to | 47 // callback has been issued, it is passed an ID, which should be used to |
48 // unlock this image. It is up to the caller to ensure that the image is later | 48 // unlock this image. It is up to the caller to ensure that the image is later |
49 // unlocked using UnlockImageDecode. | 49 // unlocked using UnlockImageDecode. |
50 // Virtual for testing. | 50 // Virtual for testing. |
51 virtual ImageDecodeRequestId QueueImageDecode( | 51 virtual ImageDecodeRequestId QueueImageDecode( |
52 sk_sp<const SkImage> image, | 52 sk_sp<const SkImage> image, |
53 const ImageDecodedCallback& callback); | 53 const ImageDecodedCallback& callback); |
54 | 54 |
| 55 protected: |
| 56 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; |
| 57 |
55 private: | 58 private: |
56 struct ImageDecodeRequest { | 59 struct ImageDecodeRequest { |
57 ImageDecodeRequest(); | 60 ImageDecodeRequest(); |
58 ImageDecodeRequest(ImageDecodeRequestId id, | 61 ImageDecodeRequest(ImageDecodeRequestId id, |
59 const DrawImage& draw_image, | 62 const DrawImage& draw_image, |
60 const ImageDecodedCallback& callback, | 63 const ImageDecodedCallback& callback, |
61 scoped_refptr<TileTask> task, | 64 scoped_refptr<TileTask> task, |
62 bool need_unref); | 65 bool need_unref); |
63 ImageDecodeRequest(ImageDecodeRequest&& other); | 66 ImageDecodeRequest(ImageDecodeRequest&& other); |
64 ImageDecodeRequest(const ImageDecodeRequest& other); | 67 ImageDecodeRequest(const ImageDecodeRequest& other); |
(...skipping 16 matching lines...) Expand all Loading... |
81 | 84 |
82 void ImageDecodeCompleted(ImageDecodeRequestId id); | 85 void ImageDecodeCompleted(ImageDecodeRequestId id); |
83 | 86 |
84 ImageDecodeCache* cache_ = nullptr; | 87 ImageDecodeCache* cache_ = nullptr; |
85 std::vector<DrawImage> predecode_locked_images_; | 88 std::vector<DrawImage> predecode_locked_images_; |
86 | 89 |
87 static ImageDecodeRequestId s_next_image_decode_queue_id_; | 90 static ImageDecodeRequestId s_next_image_decode_queue_id_; |
88 std::unordered_map<ImageDecodeRequestId, DrawImage> requested_locked_images_; | 91 std::unordered_map<ImageDecodeRequestId, DrawImage> requested_locked_images_; |
89 | 92 |
90 base::SequencedTaskRunner* origin_task_runner_ = nullptr; | 93 base::SequencedTaskRunner* origin_task_runner_ = nullptr; |
91 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; | |
92 | 94 |
93 // The variables defined below this lock (aside from weak_ptr_factory_) can | 95 // The variables defined below this lock (aside from weak_ptr_factory_) can |
94 // only be accessed when the lock is acquired. | 96 // only be accessed when the lock is acquired. |
95 base::Lock lock_; | 97 base::Lock lock_; |
96 std::map<ImageDecodeRequestId, ImageDecodeRequest> image_decode_queue_; | 98 std::map<ImageDecodeRequestId, ImageDecodeRequest> image_decode_queue_; |
97 std::map<ImageDecodeRequestId, ImageDecodeRequest> | 99 std::map<ImageDecodeRequestId, ImageDecodeRequest> |
98 requests_needing_completion_; | 100 requests_needing_completion_; |
99 bool abort_tasks_ = false; | 101 bool abort_tasks_ = false; |
100 | 102 |
101 base::WeakPtrFactory<ImageController> weak_ptr_factory_; | 103 base::WeakPtrFactory<ImageController> weak_ptr_factory_; |
102 | 104 |
103 DISALLOW_COPY_AND_ASSIGN(ImageController); | 105 DISALLOW_COPY_AND_ASSIGN(ImageController); |
104 }; | 106 }; |
105 | 107 |
106 } // namespace cc | 108 } // namespace cc |
107 | 109 |
108 #endif // CC_TILES_IMAGE_CONTROLLER_H_ | 110 #endif // CC_TILES_IMAGE_CONTROLLER_H_ |
OLD | NEW |