| 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 17 matching lines...) Expand all Loading... |
| 71 // The image can be decoded asynchronously from raster. When set, the image | 71 // The image can be decoded asynchronously from raster. When set, the image |
| 72 // is always skipped during rasterization of content that includes this | 72 // is always skipped during rasterization of content that includes this |
| 73 // image until it has been decoded using the decode service. | 73 // image until it has been decoded using the decode service. |
| 74 ASYNC, | 74 ASYNC, |
| 75 // The image has been decoded asynchronously once and should now be | 75 // The image has been decoded asynchronously once and should now be |
| 76 // synchronously rasterized with the content or the image has been | 76 // synchronously rasterized with the content or the image has been |
| 77 // permanently vetoed from being decoded async. | 77 // permanently vetoed from being decoded async. |
| 78 SYNC | 78 SYNC |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // Contains the information to construct a DrawImage from PaintImage when |
| 82 // queuing the image decode. |
| 83 struct DecodeState { |
| 84 DecodePolicy policy = DecodePolicy::SYNC; |
| 85 SkFilterQuality filter_quality = kNone_SkFilterQuality; |
| 86 SkSize scale = SkSize::MakeEmpty(); |
| 87 gfx::ColorSpace color_space; |
| 88 }; |
| 89 |
| 81 // Wrapper to unlock an image decode requested from the ImageController on | 90 // Wrapper to unlock an image decode requested from the ImageController on |
| 82 // destruction. | 91 // destruction. |
| 83 class ScopedDecodeHolder { | 92 class ScopedDecodeHolder { |
| 84 public: | 93 public: |
| 85 ScopedDecodeHolder(ImageController* controller, | 94 ScopedDecodeHolder(ImageController* controller, |
| 86 ImageController::ImageDecodeRequestId request_id) | 95 ImageController::ImageDecodeRequestId request_id) |
| 87 : controller_(controller), request_id_(request_id) {} | 96 : controller_(controller), request_id_(request_id) {} |
| 88 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); } | 97 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); } |
| 89 | 98 |
| 90 private: | 99 private: |
| 91 ImageController* controller_; | 100 ImageController* controller_; |
| 92 ImageController::ImageDecodeRequestId request_id_; | 101 ImageController::ImageDecodeRequestId request_id_; |
| 93 | 102 |
| 94 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder); | 103 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder); |
| 95 }; | 104 }; |
| 96 | 105 |
| 97 void DidFinishImageDecode(PaintImage::Id image_id, | 106 void DidFinishImageDecode(PaintImage::Id image_id, |
| 98 ImageController::ImageDecodeRequestId request_id, | 107 ImageController::ImageDecodeRequestId request_id, |
| 99 ImageController::ImageDecodeResult result); | 108 ImageController::ImageDecodeResult result); |
| 100 | 109 |
| 101 // Called when the next request in the |image_decode_queue_| should be | 110 // Called when the next request in the |image_decode_queue_| should be |
| 102 // scheduled with the image decode service. | 111 // scheduled with the image decode service. |
| 103 void ScheduleNextImageDecode(); | 112 void ScheduleNextImageDecode(); |
| 113 void UpdateDecodeState(const DrawImage& draw_image, |
| 114 PaintImage::Id paint_image_id, |
| 115 DecodeState* decode_state); |
| 104 | 116 |
| 105 ImageController* image_controller_; | 117 ImageController* image_controller_; |
| 106 CheckerImageTrackerClient* client_; | 118 CheckerImageTrackerClient* client_; |
| 107 const bool enable_checker_imaging_; | 119 const bool enable_checker_imaging_; |
| 108 | 120 |
| 109 // A set of images which have been decoded and are pending invalidation for | 121 // A set of images which have been decoded and are pending invalidation for |
| 110 // raster on the checkered tiles. | 122 // raster on the checkered tiles. |
| 111 PaintImageIdFlatSet images_pending_invalidation_; | 123 PaintImageIdFlatSet images_pending_invalidation_; |
| 112 | 124 |
| 113 // A set of images which were invalidated on the current sync tree. | 125 // A set of images which were invalidated on the current sync tree. |
| 114 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; | 126 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; |
| 115 | 127 |
| 116 // The queue of images pending decode. We maintain a queue to ensure that the | 128 // The queue of images pending decode. We maintain a queue to ensure that the |
| 117 // order in which images are decoded is aligned with the priority of the tiles | 129 // order in which images are decoded is aligned with the priority of the tiles |
| 118 // dependent on these images. | 130 // dependent on these images. |
| 119 ImageDecodeQueue image_decode_queue_; | 131 ImageDecodeQueue image_decode_queue_; |
| 120 | 132 |
| 121 // The currently outstanding image decode that has been scheduled with the | 133 // The currently outstanding image decode that has been scheduled with the |
| 122 // decode service. There can be only one outstanding decode at a time. | 134 // decode service. There can be only one outstanding decode at a time. |
| 123 base::Optional<PaintImage> outstanding_image_decode_; | 135 base::Optional<PaintImage> outstanding_image_decode_; |
| 124 | 136 |
| 125 // A map of ImageId to its DecodePolicy. | 137 // A map of ImageId to its DecodePolicy. |
| 126 std::unordered_map<PaintImage::Id, DecodePolicy> image_async_decode_state_; | 138 std::unordered_map<PaintImage::Id, DecodeState> image_async_decode_state_; |
| 127 | 139 |
| 128 // A map of image id to image decode request id for images to be unlocked. | 140 // A map of image id to image decode request id for images to be unlocked. |
| 129 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>> | 141 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>> |
| 130 image_id_to_decode_; | 142 image_id_to_decode_; |
| 131 | 143 |
| 132 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; | 144 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; |
| 133 | 145 |
| 134 DISALLOW_COPY_AND_ASSIGN(CheckerImageTracker); | 146 DISALLOW_COPY_AND_ASSIGN(CheckerImageTracker); |
| 135 }; | 147 }; |
| 136 | 148 |
| 137 } // namespace cc | 149 } // namespace cc |
| 138 | 150 |
| 139 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ | 151 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
| OLD | NEW |