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 // protected for testing. | |
vmpstr
2017/02/16 20:59:14
You don't need this comment.
Khushal
2017/02/17 19:05:38
Done.
| |
57 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; | |
58 | |
55 private: | 59 private: |
56 struct ImageDecodeRequest { | 60 struct ImageDecodeRequest { |
57 ImageDecodeRequest(); | 61 ImageDecodeRequest(); |
58 ImageDecodeRequest(ImageDecodeRequestId id, | 62 ImageDecodeRequest(ImageDecodeRequestId id, |
59 const DrawImage& draw_image, | 63 const DrawImage& draw_image, |
60 const ImageDecodedCallback& callback, | 64 const ImageDecodedCallback& callback, |
61 scoped_refptr<TileTask> task, | 65 scoped_refptr<TileTask> task, |
62 bool need_unref); | 66 bool need_unref); |
63 ImageDecodeRequest(ImageDecodeRequest&& other); | 67 ImageDecodeRequest(ImageDecodeRequest&& other); |
64 ImageDecodeRequest(const ImageDecodeRequest& other); | 68 ImageDecodeRequest(const ImageDecodeRequest& other); |
(...skipping 16 matching lines...) Expand all Loading... | |
81 | 85 |
82 void ImageDecodeCompleted(ImageDecodeRequestId id); | 86 void ImageDecodeCompleted(ImageDecodeRequestId id); |
83 | 87 |
84 ImageDecodeCache* cache_ = nullptr; | 88 ImageDecodeCache* cache_ = nullptr; |
85 std::vector<DrawImage> predecode_locked_images_; | 89 std::vector<DrawImage> predecode_locked_images_; |
86 | 90 |
87 static ImageDecodeRequestId s_next_image_decode_queue_id_; | 91 static ImageDecodeRequestId s_next_image_decode_queue_id_; |
88 std::unordered_map<ImageDecodeRequestId, DrawImage> requested_locked_images_; | 92 std::unordered_map<ImageDecodeRequestId, DrawImage> requested_locked_images_; |
89 | 93 |
90 base::SequencedTaskRunner* origin_task_runner_ = nullptr; | 94 base::SequencedTaskRunner* origin_task_runner_ = nullptr; |
91 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; | |
92 | 95 |
93 // The variables defined below this lock (aside from weak_ptr_factory_) can | 96 // The variables defined below this lock (aside from weak_ptr_factory_) can |
94 // only be accessed when the lock is acquired. | 97 // only be accessed when the lock is acquired. |
95 base::Lock lock_; | 98 base::Lock lock_; |
96 std::map<ImageDecodeRequestId, ImageDecodeRequest> image_decode_queue_; | 99 std::map<ImageDecodeRequestId, ImageDecodeRequest> image_decode_queue_; |
97 std::map<ImageDecodeRequestId, ImageDecodeRequest> | 100 std::map<ImageDecodeRequestId, ImageDecodeRequest> |
98 requests_needing_completion_; | 101 requests_needing_completion_; |
99 bool abort_tasks_ = false; | 102 bool abort_tasks_ = false; |
100 | 103 |
101 base::WeakPtrFactory<ImageController> weak_ptr_factory_; | 104 base::WeakPtrFactory<ImageController> weak_ptr_factory_; |
102 | 105 |
103 DISALLOW_COPY_AND_ASSIGN(ImageController); | 106 DISALLOW_COPY_AND_ASSIGN(ImageController); |
104 }; | 107 }; |
105 | 108 |
106 } // namespace cc | 109 } // namespace cc |
107 | 110 |
108 #endif // CC_TILES_IMAGE_CONTROLLER_H_ | 111 #endif // CC_TILES_IMAGE_CONTROLLER_H_ |
OLD | NEW |