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

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

Issue 2668873002: cc: Add checker-imaging support to TileManager. (Closed)
Patch Set: rebase Created 3 years, 10 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
OLDNEW
(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 <vector>
10
11 #include "cc/base/cc_export.h"
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 CC_EXPORT CheckerImageTrackerClient {
19 public:
20 virtual ~CheckerImageTrackerClient() = default;
21
22 virtual void NeedsInvalidationForCheckerImagedTiles() = 0;
23 };
24
25 // CheckerImageTracker is used to track the set of images in a frame which are
26 // decoded asynchronously, using the ImageDecodeService, from the rasterization
27 // of tiles which depend on them. Once decoded, these images are stored for
28 // invalidation on the next sync tree. TakeImagesToInvalidateOnSyncTree will
29 // return this set and maintain a copy to keeps these images locked until the
30 // sync tree is activated.
31 // Note: It is illegal to call TakeImagesToInvalidateOnSyncTree for the next
32 // sync tree until the previous tree is activated.
33 class CC_EXPORT CheckerImageTracker {
34 public:
35 CheckerImageTracker(ImageController* image_controller,
36 CheckerImageTrackerClient* client,
37 bool enable_checker_imaging);
38 ~CheckerImageTracker();
39
40 // Given the |images| for a tile, filters the images which will be deferred
41 // asynchronously using the image decoded service, eliminating them from
42 // |images| adds them to the |checkered_images| set, so they can be skipped
43 // during the rasterization of this tile.
44 // The entries remaining in |images| are for images for which a cached decode
45 // from the image decode service is available, or which must be decoded before
46 // before this tile can be rasterized.
47 void FilterImagesForCheckeringForTile(std::vector<DrawImage>* images,
48 ImageIdFlatSet* checkered_images,
49 WhichTree tree);
50
51 // Returns the set of images to invalidate on the sync tree.
52 const std::unordered_set<ImageId>& TakeImagesToInvalidateOnSyncTree();
enne (OOO) 2017/02/16 21:41:32 It kind of seems like this should be a flat set to
Khushal 2017/02/17 19:05:38 Makes sense. Other than the once decoded images se
enne (OOO) 2017/02/17 19:12:51 Yeah, it's possible. I think we'd want to add som
53
54 void DidActivateSyncTree();
55
56 private:
57 void DidFinishImageDecode(ImageId image_id,
58 ImageController::ImageDecodeRequestId request_id);
59
60 // Returns true if the decode for |image| will be deferred to the image decode
61 // service and it should be be skipped during raster.
62 bool ShouldCheckerImage(const sk_sp<const SkImage>& image,
63 WhichTree tree) const;
64
65 void ScheduleImageDecodeIfNecessary(const sk_sp<const SkImage>& image);
66
67 ImageController* image_controller_;
68 CheckerImageTrackerClient* client_;
69 const bool enable_checker_imaging_;
70
71 // A set of images which have been decoded and are pending invalidation for
72 // raster on the checkered tiles.
73 ImageIdSet images_pending_invalidation_;
74
75 // A set of images which were invalidated on the current sync tree.
76 ImageIdSet invalidated_images_on_current_sync_tree_;
77
78 // A set of images which are currently pending decode from the image decode
79 // service.
80 // TODO(khushalsagar): This should be a queue that gets re-built each time we
81 // do a PrepareTiles? See crbug.com/689184.
82 ImageIdSet pending_image_decodes_;
83
84 // A set of images which have been decoded at least once from the
85 // ImageDecodeService and should not be checkered again.
86 // TODO(khushalsagar): Limit the size of this set.
87 ImageIdSet images_decoded_once_;
88
89 // A map of image id to image decode request id for images to be unlocked.
90 std::unordered_map<ImageId, ImageController::ImageDecodeRequestId>
91 image_id_to_decode_request_id_;
92
93 base::WeakPtrFactory<CheckerImageTracker> weak_factory_;
94 };
95
96 } // namespace cc
97
98 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698