OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_CHECKER_IMAGE_TRACKER_H_ | 5 #ifndef CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
6 #define CC_TILES_CHECKER_IMAGE_TRACKER_H_ | 6 #define CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... | |
33 // sync tree until the previous tree is activated. | 33 // sync tree until the previous tree is activated. |
34 class CC_EXPORT CheckerImageTracker { | 34 class CC_EXPORT CheckerImageTracker { |
35 public: | 35 public: |
36 CheckerImageTracker(ImageController* image_controller, | 36 CheckerImageTracker(ImageController* image_controller, |
37 CheckerImageTrackerClient* client, | 37 CheckerImageTrackerClient* client, |
38 bool enable_checker_imaging); | 38 bool enable_checker_imaging); |
39 ~CheckerImageTracker(); | 39 ~CheckerImageTracker(); |
40 | 40 |
41 // Returns true if the decode for |image| will be deferred to the image decode | 41 // Returns true if the decode for |image| will be deferred to the image decode |
42 // service and it should be be skipped during raster. | 42 // service and it should be be skipped during raster. |
43 bool ShouldCheckerImage(const PaintImage& image, WhichTree tree); | 43 bool ShouldCheckerImage(const DrawImage& image, WhichTree tree); |
44 | 44 |
45 using ImageDecodeQueue = std::vector<PaintImage>; | 45 using ImageDecodeQueue = std::vector<PaintImage>; |
46 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue); | 46 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue); |
47 | 47 |
48 // Returns the set of images to invalidate on the sync tree. | 48 // Returns the set of images to invalidate on the sync tree. |
49 const PaintImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); | 49 const PaintImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); |
50 | 50 |
51 // Called when the sync tree is activated. Each call to | 51 // Called when the sync tree is activated. Each call to |
52 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the | 52 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the |
53 // invalidated sync tree is activated. | 53 // invalidated sync tree is activated. |
(...skipping 10 matching lines...) Expand all Loading... | |
64 // is always skipped during rasterization of content that includes this | 64 // is always skipped during rasterization of content that includes this |
65 // image until it has been decoded using the decode service. | 65 // image until it has been decoded using the decode service. |
66 ASYNC, | 66 ASYNC, |
67 // The image has been decoded asynchronously once and should now be | 67 // The image has been decoded asynchronously once and should now be |
68 // synchronously rasterized with the content. | 68 // synchronously rasterized with the content. |
69 SYNC_DECODED_ONCE, | 69 SYNC_DECODED_ONCE, |
70 // The image has been permanently vetoed from being decoded async. | 70 // The image has been permanently vetoed from being decoded async. |
71 SYNC_PERMANENT, | 71 SYNC_PERMANENT, |
72 }; | 72 }; |
73 | 73 |
74 // Contains the information to construct a DrawImage from PaintImage when | |
75 // queuing the image decode. | |
76 struct DecodeState { | |
77 DecodePolicy policy = DecodePolicy::SYNC_PERMANENT; | |
78 SkFilterQuality filter_quality = kNone_SkFilterQuality; | |
79 SkSize scale; | |
ericrk
2017/06/06 22:39:51
SkSize has no default constructor, I think you are
Khushal
2017/06/07 00:43:31
(0,0) it is. Since I want it to use the smallest s
| |
80 gfx::ColorSpace color_space; | |
81 }; | |
82 | |
74 // Wrapper to unlock an image decode requested from the ImageController on | 83 // Wrapper to unlock an image decode requested from the ImageController on |
75 // destruction. | 84 // destruction. |
76 class ScopedDecodeHolder { | 85 class ScopedDecodeHolder { |
77 public: | 86 public: |
78 ScopedDecodeHolder(ImageController* controller, | 87 ScopedDecodeHolder(ImageController* controller, |
79 ImageController::ImageDecodeRequestId request_id) | 88 ImageController::ImageDecodeRequestId request_id) |
80 : controller_(controller), request_id_(request_id) {} | 89 : controller_(controller), request_id_(request_id) {} |
81 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); } | 90 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); } |
82 | 91 |
83 private: | 92 private: |
84 ImageController* controller_; | 93 ImageController* controller_; |
85 ImageController::ImageDecodeRequestId request_id_; | 94 ImageController::ImageDecodeRequestId request_id_; |
86 | 95 |
87 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder); | 96 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder); |
88 }; | 97 }; |
89 | 98 |
90 void DidFinishImageDecode(PaintImage::Id image_id, | 99 void DidFinishImageDecode(PaintImage::Id image_id, |
91 ImageController::ImageDecodeRequestId request_id, | 100 ImageController::ImageDecodeRequestId request_id, |
92 ImageController::ImageDecodeResult result); | 101 ImageController::ImageDecodeResult result); |
93 | 102 |
94 // Called when the next request in the |image_decode_queue_| should be | 103 // Called when the next request in the |image_decode_queue_| should be |
95 // scheduled with the image decode service. | 104 // scheduled with the image decode service. |
96 void ScheduleNextImageDecode(); | 105 void ScheduleNextImageDecode(); |
106 void UpdateDecodeState(const DrawImage& draw_image, | |
107 PaintImage::Id paint_image_id, | |
108 DecodeState* decode_state); | |
97 | 109 |
98 ImageController* image_controller_; | 110 ImageController* image_controller_; |
99 CheckerImageTrackerClient* client_; | 111 CheckerImageTrackerClient* client_; |
100 const bool enable_checker_imaging_; | 112 const bool enable_checker_imaging_; |
101 | 113 |
102 // A set of images which have been decoded and are pending invalidation for | 114 // A set of images which have been decoded and are pending invalidation for |
103 // raster on the checkered tiles. | 115 // raster on the checkered tiles. |
104 PaintImageIdFlatSet images_pending_invalidation_; | 116 PaintImageIdFlatSet images_pending_invalidation_; |
105 | 117 |
106 // A set of images which were invalidated on the current sync tree. | 118 // A set of images which were invalidated on the current sync tree. |
107 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; | 119 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; |
108 | 120 |
109 // The queue of images pending decode. We maintain a queue to ensure that the | 121 // The queue of images pending decode. We maintain a queue to ensure that the |
110 // order in which images are decoded is aligned with the priority of the tiles | 122 // order in which images are decoded is aligned with the priority of the tiles |
111 // dependent on these images. | 123 // dependent on these images. |
112 ImageDecodeQueue image_decode_queue_; | 124 ImageDecodeQueue image_decode_queue_; |
113 | 125 |
114 // The currently outstanding image decode that has been scheduled with the | 126 // The currently outstanding image decode that has been scheduled with the |
115 // decode service. There can be only one outstanding decode at a time. | 127 // decode service. There can be only one outstanding decode at a time. |
116 base::Optional<PaintImage> outstanding_image_decode_; | 128 base::Optional<PaintImage> outstanding_image_decode_; |
117 | 129 |
118 // A map of ImageId to its DecodePolicy. | 130 // A map of ImageId to its DecodePolicy. |
119 std::unordered_map<PaintImage::Id, DecodePolicy> image_async_decode_state_; | 131 std::unordered_map<PaintImage::Id, DecodeState> image_async_decode_state_; |
120 | 132 |
121 // A map of image id to image decode request id for images to be unlocked. | 133 // A map of image id to image decode request id for images to be unlocked. |
122 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>> | 134 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>> |
123 image_id_to_decode_; | 135 image_id_to_decode_; |
124 | 136 |
125 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; | 137 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; |
126 }; | 138 }; |
127 | 139 |
128 } // namespace cc | 140 } // namespace cc |
129 | 141 |
130 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ | 142 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
OLD | NEW |