OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_TILES_CHECKER_IMAGE_TRACKER_H_ | |
6 #define CC_TILES_CHECKER_IMAGE_TRACKER_H_ | |
7 | |
8 #include <unordered_map> | |
9 #include <unordered_set> | |
10 #include <vector> | |
11 | |
12 #include "cc/playback/image_id.h" | |
13 #include "cc/tiles/image_controller.h" | |
14 #include "third_party/skia/include/core/SkImage.h" | |
15 | |
16 namespace cc { | |
17 | |
18 class CheckerImageTrackerClient { | |
19 public: | |
20 virtual ~CheckerImageTrackerClient() {} | |
vmpstr
2017/02/10 19:25:42
= default
Khushal
2017/02/10 22:09:19
Done.
| |
21 | |
22 virtual void NeedsInvalidationForCheckerImagedTiles() = 0; | |
23 }; | |
24 | |
25 class CheckerImageTracker { | |
26 public: | |
27 CheckerImageTracker(ImageController* image_controller, | |
28 CheckerImageTrackerClient* client, | |
29 bool enable_checker_imaging); | |
30 ~CheckerImageTracker(); | |
31 | |
32 // Given the |images| for a tile, filters the images which will be deferred | |
33 // asynchronously using the image decoded service, eliminating them from | |
34 // |images| adds them to the |checkered_images| set, so they can be skipped | |
35 // during the rasterization of this tile. | |
36 // The entries remaining in |images| are for images for which a cached decode | |
37 // from the image decode service is available, or which must be decoded before | |
38 // before this tile can be rasterized. | |
39 void FilterImagesForCheckeringForTile( | |
40 std::vector<DrawImage>* images, | |
41 std::unordered_set<ImageId>* checkered_images, | |
42 WhichTree tree); | |
43 | |
44 // Returns the set of images to invalidate on the sync tree. | |
45 const std::unordered_set<ImageId>& TakeImagesToInvalidateOnSyncTree(); | |
vmpstr
2017/02/10 19:25:42
vector? Also "take" function should probably retur
Khushal
2017/02/10 22:09:19
I'll have to copy to return a value. We have to in
| |
46 | |
47 void DidActivateSyncTree(); | |
48 | |
49 private: | |
50 void DidFinishImageDecode(ImageId image_id, | |
51 ImageController::ImageDecodeRequestId request_id); | |
52 | |
53 // Returns true if the decode for |image| will be deferred to the image decode | |
54 // service and it should be be skipped during raster. | |
55 bool ShouldCheckerImage(const sk_sp<const SkImage> image, | |
56 WhichTree tree) const; | |
57 | |
58 void ScheduleImageDecodeIfNecessary(const sk_sp<const SkImage> image); | |
59 | |
60 ImageController* image_controller_; | |
vmpstr
2017/02/10 19:25:42
It's very nice that these three lines align on the
Khushal
2017/02/10 22:09:19
I'm glad you noticed. :P
| |
61 CheckerImageTrackerClient* client_; | |
62 const bool enable_checker_imaging_; | |
63 | |
64 using ImageIdSet = std::unordered_set<ImageId>; | |
65 | |
66 // A set of images which have been decoded and are pending invalidation for | |
67 // raster on the checkered tiles. | |
68 ImageIdSet images_pending_invalidation_; | |
69 | |
70 // A set of images which were invalidated on the current sync tree. | |
71 ImageIdSet invalidated_images_on_current_sync_tree_; | |
72 | |
73 // A set of images which are currently pending decode from the image decode | |
74 // service. | |
75 // TODO(khushalsagar): This should be a queue that gets re-built each time we | |
76 // do a PrepareTiles? See crbug.com/689184. | |
77 ImageIdSet pending_image_decodes_; | |
78 | |
79 // A set of images which have been decoded at least once from the | |
80 // ImageDecodeService and should not be checkered again. | |
81 ImageIdSet images_decoded_once_; | |
vmpstr
2017/02/10 19:25:42
Can you file a TODO here. I think we might be able
Khushal
2017/02/10 22:09:19
Hmmm, we'll have to see how feasible it would be t
| |
82 | |
83 // A map of image id to image decode request id for images to be unlocked. | |
84 std::unordered_map<ImageId, ImageController::ImageDecodeRequestId> | |
85 image_id_to_decode_request_id_; | |
86 | |
87 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; | |
88 }; | |
89 | |
90 } // namespace cc | |
91 | |
92 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ | |
OLD | NEW |