 Chromium Code Reviews
 Chromium Code Reviews Issue 2668873002:
  cc: Add checker-imaging support to TileManager.  (Closed)
    
  
    Issue 2668873002:
  cc: Add checker-imaging support to TileManager.  (Closed) 
  | 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..c6f5dc118d0c72035220586eb69365bf146bdfad | 
| --- /dev/null | 
| +++ b/cc/tiles/checker_image_tracker.h | 
| @@ -0,0 +1,92 @@ | 
| +// Copyright 2017 The Chromium Authors. All rights reserved. | 
| +// 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 CheckerImageTrackerClient { | 
| + public: | 
| + virtual ~CheckerImageTrackerClient() {} | 
| 
vmpstr
2017/02/10 19:25:42
= default
 
Khushal
2017/02/10 22:09:19
Done.
 | 
| + | 
| + virtual void NeedsInvalidationForCheckerImagedTiles() = 0; | 
| +}; | 
| + | 
| +class CheckerImageTracker { | 
| + public: | 
| + CheckerImageTracker(ImageController* image_controller, | 
| + CheckerImageTrackerClient* client, | 
| + bool enable_checker_imaging); | 
| + ~CheckerImageTracker(); | 
| + | 
| + // Given the |images| for a tile, filters the images which will be deferred | 
| + // asynchronously using the image decoded service, eliminating them from | 
| + // |images| adds them to the |checkered_images| set, so they can be skipped | 
| + // during the rasterization of this tile. | 
| + // The entries remaining in |images| are for images for which a cached decode | 
| + // from the image decode service is available, or which must be decoded before | 
| + // before this tile can be rasterized. | 
| + void FilterImagesForCheckeringForTile( | 
| + std::vector<DrawImage>* images, | 
| + std::unordered_set<ImageId>* checkered_images, | 
| + WhichTree tree); | 
| + | 
| + // Returns the set of images to invalidate on the sync tree. | 
| + 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
 | 
| + | 
| + 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 ShouldCheckerImage(const sk_sp<const SkImage> image, | 
| + WhichTree tree) const; | 
| + | 
| + void ScheduleImageDecodeIfNecessary(const sk_sp<const SkImage> image); | 
| + | 
| + 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
 | 
| + CheckerImageTrackerClient* client_; | 
| + const bool enable_checker_imaging_; | 
| + | 
| + using ImageIdSet = std::unordered_set<ImageId>; | 
| + | 
| + // 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 invalidated_images_on_current_sync_tree_; | 
| + | 
| + // 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 | 
| + // do a PrepareTiles? See crbug.com/689184. | 
| + 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_; | 
| 
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
 | 
| + | 
| + // 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_ |