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

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

Issue 2928433003: cc: Add scaling for checkered images. (Closed)
Patch Set: comments Created 3 years, 6 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
« no previous file with comments | « no previous file | cc/tiles/checker_image_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 DecodeState();
78
79 DecodePolicy policy = DecodePolicy::SYNC_PERMANENT;
80 SkFilterQuality filter_quality = kNone_SkFilterQuality;
81 SkSize scale;
ericrk 2017/06/07 21:01:57 nit: can you just do: SkSize scale = SkSize::Make
Khushal 2017/06/07 23:21:33 I thought it would, but I guess not.
82 gfx::ColorSpace color_space;
83 };
84
74 // Wrapper to unlock an image decode requested from the ImageController on 85 // Wrapper to unlock an image decode requested from the ImageController on
75 // destruction. 86 // destruction.
76 class ScopedDecodeHolder { 87 class ScopedDecodeHolder {
77 public: 88 public:
78 ScopedDecodeHolder(ImageController* controller, 89 ScopedDecodeHolder(ImageController* controller,
79 ImageController::ImageDecodeRequestId request_id) 90 ImageController::ImageDecodeRequestId request_id)
80 : controller_(controller), request_id_(request_id) {} 91 : controller_(controller), request_id_(request_id) {}
81 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); } 92 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); }
82 93
83 private: 94 private:
84 ImageController* controller_; 95 ImageController* controller_;
85 ImageController::ImageDecodeRequestId request_id_; 96 ImageController::ImageDecodeRequestId request_id_;
86 97
87 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder); 98 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder);
88 }; 99 };
89 100
90 void DidFinishImageDecode(PaintImage::Id image_id, 101 void DidFinishImageDecode(PaintImage::Id image_id,
91 ImageController::ImageDecodeRequestId request_id, 102 ImageController::ImageDecodeRequestId request_id,
92 ImageController::ImageDecodeResult result); 103 ImageController::ImageDecodeResult result);
93 104
94 // Called when the next request in the |image_decode_queue_| should be 105 // Called when the next request in the |image_decode_queue_| should be
95 // scheduled with the image decode service. 106 // scheduled with the image decode service.
96 void ScheduleNextImageDecode(); 107 void ScheduleNextImageDecode();
108 void UpdateDecodeState(const DrawImage& draw_image,
109 PaintImage::Id paint_image_id,
110 DecodeState* decode_state);
97 111
98 ImageController* image_controller_; 112 ImageController* image_controller_;
99 CheckerImageTrackerClient* client_; 113 CheckerImageTrackerClient* client_;
100 const bool enable_checker_imaging_; 114 const bool enable_checker_imaging_;
101 115
102 // A set of images which have been decoded and are pending invalidation for 116 // A set of images which have been decoded and are pending invalidation for
103 // raster on the checkered tiles. 117 // raster on the checkered tiles.
104 PaintImageIdFlatSet images_pending_invalidation_; 118 PaintImageIdFlatSet images_pending_invalidation_;
105 119
106 // A set of images which were invalidated on the current sync tree. 120 // A set of images which were invalidated on the current sync tree.
107 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; 121 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_;
108 122
109 // The queue of images pending decode. We maintain a queue to ensure that the 123 // 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 124 // order in which images are decoded is aligned with the priority of the tiles
111 // dependent on these images. 125 // dependent on these images.
112 ImageDecodeQueue image_decode_queue_; 126 ImageDecodeQueue image_decode_queue_;
113 127
114 // The currently outstanding image decode that has been scheduled with the 128 // The currently outstanding image decode that has been scheduled with the
115 // decode service. There can be only one outstanding decode at a time. 129 // decode service. There can be only one outstanding decode at a time.
116 base::Optional<PaintImage> outstanding_image_decode_; 130 base::Optional<PaintImage> outstanding_image_decode_;
117 131
118 // A map of ImageId to its DecodePolicy. 132 // A map of ImageId to its DecodePolicy.
119 std::unordered_map<PaintImage::Id, DecodePolicy> image_async_decode_state_; 133 std::unordered_map<PaintImage::Id, DecodeState> image_async_decode_state_;
120 134
121 // A map of image id to image decode request id for images to be unlocked. 135 // 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>> 136 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>>
123 image_id_to_decode_; 137 image_id_to_decode_;
124 138
125 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; 139 base::WeakPtrFactory<CheckerImageTracker> weak_factory_;
126 }; 140 };
127 141
128 } // namespace cc 142 } // namespace cc
129 143
130 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ 144 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/checker_image_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698