Chromium Code Reviews| Index: cc/tiles/checker_image_tracker.h |
| diff --git a/cc/tiles/checker_image_tracker.h b/cc/tiles/checker_image_tracker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..196190730f761fb6cbb0f11d74b89baabee7d7ad |
| --- /dev/null |
| +++ b/cc/tiles/checker_image_tracker.h |
| @@ -0,0 +1,91 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
|
vmpstr
2017/02/03 23:42:32
2017
Khushal
2017/02/07 00:25:32
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
| +#define CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
| + |
| +#include <unordered_map> |
| +#include <unordered_set> |
| +#include <vector> |
| + |
| +#include "cc/playback/image_id.h" |
| +#include "cc/tiles/image_controller.h" |
| +#include "third_party/skia/include/core/SkImage.h" |
| + |
| +namespace cc { |
| +class LayerTreeImpl; |
| +class PrioritizedTile; |
| + |
| +class CheckerImageTrackerClient { |
| + public: |
| + virtual ~CheckerImageTrackerClient() {} |
| + |
| + virtual void NeedsInvalidationForCheckerImagedTiles() = 0; |
| +}; |
| + |
| +class CheckerImageTracker { |
| + public: |
| + CheckerImageTracker(ImageController* image_controller, |
| + CheckerImageTrackerClient* client, |
| + bool enable_checker_imaging); |
| + ~CheckerImageTracker(); |
| + |
| + // For the given |prioritized_tile|, populates |images| with the set of images |
| + // that must be decoded before this tile can be rastered. |
| + // |checkered_images| will be populated with set of images which will be |
| + // decoded using the Image Decode Service and must be skipped during |
| + // rasterization of this tile. |
| + void FilterImagesForCheckeringForTile( |
| + const PrioritizedTile& prioritized_tile, |
| + std::vector<DrawImage>* images, |
| + std::unordered_set<ImageId>* checkered_images); |
| + |
| + // Invalidates the region for decoded images on the sync tree. |
| + void AddInvalidationForCheckerImages(LayerTreeImpl* sync_tree); |
| + |
| + void DidActivateSyncTree(); |
| + |
| + private: |
| + void DidFinishImageDecode(ImageId image_id, |
| + ImageController::ImageDecodeRequestId request_id); |
| + |
| + // Returns true if the decode for |image| will be deferred to the image decode |
| + // service and it should be be skipped during raster. |
| + bool AnalyzeImageForCheckeringAndScheduleDecodeIfNecessary( |
| + const sk_sp<const SkImage> image, |
| + WhichTree tree); |
| + |
| + ImageController* image_controller_; |
| + CheckerImageTrackerClient* client_; |
| + const bool enable_checker_imaging_; |
| + |
| + using ImageIdSet = std::unordered_set<ImageId>; |
|
vmpstr
2017/02/03 23:42:32
I wonder if we should just use a vector. It might
Khushal
2017/02/07 00:25:32
The set was more for the look up cost. The |images
|
| + |
| + // A set of images which have been decoded and are pending invalidation for |
| + // raster on the checkered tiles. |
| + ImageIdSet images_pending_invalidation_; |
| + |
| + // A set of images which were invalidated on the current sync tree. |
| + ImageIdSet images_invalidated_on_current_sync_tree_; |
|
vmpstr
2017/02/03 23:42:32
nit: invalidated_images_
Khushal
2017/02/07 00:25:32
Done.
|
| + |
| + // A set of images which are currently pending decode from the image decode |
| + // service. |
| + // TODO(khushalsagar): This should be a queue that gets re-built each time we |
|
vmpstr
2017/02/03 23:42:32
We can file a bug as a follow up for this.
Khushal
2017/02/07 00:25:32
Done.
|
| + // do a PrepareTiles? |
| + ImageIdSet pending_image_decodes_; |
| + |
| + // A set of images which have been decoded at least once from the |
| + // ImageDecodeService and should not be checkered again. |
| + ImageIdSet images_decoded_once_; |
| + |
| + // A map of image id to image decode request id for images to be unlocked. |
| + std::unordered_map<ImageId, ImageController::ImageDecodeRequestId> |
| + image_id_to_decode_request_id_; |
| + |
| + base::WeakPtrFactory<CheckerImageTracker> weak_factory_; |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ |