Index: cc/resources/picture_pile.h |
diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h |
index 7cd22296c5f23f80e4de98cba3a7696313eb9323..ffd9b52ddb2d53c43d9cf0b2896515a678034a22 100644 |
--- a/cc/resources/picture_pile.h |
+++ b/cc/resources/picture_pile.h |
@@ -5,25 +5,21 @@ |
#ifndef CC_RESOURCES_PICTURE_PILE_H_ |
#define CC_RESOURCES_PICTURE_PILE_H_ |
+#include <bitset> |
+ |
#include "base/memory/ref_counted.h" |
-#include "cc/resources/picture_pile_base.h" |
-#include "ui/gfx/geometry/rect.h" |
+#include "cc/base/tiling_data.h" |
+#include "cc/resources/recording_source.h" |
namespace cc { |
class PicturePileImpl; |
-class Region; |
-class RenderingStatsInstrumentation; |
-class CC_EXPORT PicturePile : public PicturePileBase { |
+class CC_EXPORT PicturePile : public RecordingSource { |
public: |
PicturePile(); |
~PicturePile() override; |
- // Re-record parts of the picture that are invalid. |
- // Invalidations are in layer space, and will be expanded to cover everything |
- // that was either recorded/changed or that has no recording, leaving out only |
- // pieces that we had a recording for and it was not changed. |
- // Return true iff the pile was modified. |
+ // RecordingSource overrides. |
bool UpdateAndExpandInvalidation( |
ContentLayerClient* painter, |
Region* invalidation, |
@@ -33,35 +29,92 @@ class CC_EXPORT PicturePile : public PicturePileBase { |
const gfx::Size& layer_size, |
const gfx::Rect& visible_layer_rect, |
int frame_number, |
- Picture::RecordingMode recording_mode, |
- RenderingStatsInstrumentation* stats_instrumentation); |
- |
- void SetEmptyBounds(); |
- |
- void set_slow_down_raster_scale_factor(int factor) { |
- slow_down_raster_scale_factor_for_debug_ = factor; |
- } |
- |
- void set_show_debug_picture_borders(bool show) { |
- show_debug_picture_borders_ = show; |
- } |
- |
- bool is_suitable_for_gpu_rasterization() const { |
- return is_suitable_for_gpu_rasterization_; |
- } |
- void SetUnsuitableForGpuRasterizationForTesting() { |
- is_suitable_for_gpu_rasterization_ = false; |
- } |
- |
- void SetPixelRecordDistanceForTesting(int d) { pixel_record_distance_ = d; } |
+ Picture::RecordingMode recording_mode) override; |
+ gfx::Size GetSize() const final; |
+ void SetEmptyBounds() override; |
+ void SetMinContentsScale(float min_contents_scale) override; |
+ void SetTileGridSize(const gfx::Size& tile_grid_size) override; |
+ void SetSlowdownRasterScaleFactor(int factor) override; |
+ void SetIsMask(bool is_mask) override; |
+ bool IsSuitableForGpuRasterization() const override; |
+ scoped_refptr<RasterSource> CreateRasterSource() const override; |
+ void SetUnsuitableForGpuRasterizationForTesting() override; |
+ SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const override; |
+ |
+ static void ComputeTileGridInfo(const gfx::Size& tile_grid_size, |
+ SkTileGridFactory::TileGridInfo* info); |
+ |
+ protected: |
+ class CC_EXPORT PictureInfo { |
+ public: |
+ enum { INVALIDATION_FRAMES_TRACKED = 32 }; |
+ |
+ PictureInfo(); |
+ ~PictureInfo(); |
+ |
+ bool Invalidate(int frame_number); |
+ bool NeedsRecording(int frame_number, int distance_to_visible); |
+ void SetPicture(scoped_refptr<Picture> picture); |
+ const Picture* GetPicture() const; |
+ |
+ float GetInvalidationFrequencyForTesting() const { |
+ return GetInvalidationFrequency(); |
+ } |
+ |
+ private: |
+ void AdvanceInvalidationHistory(int frame_number); |
+ float GetInvalidationFrequency() const; |
+ |
+ int last_frame_number_; |
+ scoped_refptr<const Picture> picture_; |
+ std::bitset<INVALIDATION_FRAMES_TRACKED> invalidation_history_; |
+ }; |
+ |
+ typedef std::pair<int, int> PictureMapKey; |
+ typedef base::hash_map<PictureMapKey, PictureInfo> PictureMap; |
+ |
+ // An internal CanRaster check that goes to the picture_map rather than |
+ // using the recorded_viewport hint. |
+ bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const; |
+ |
+ void Clear(); |
+ |
+ gfx::Rect PaddedRect(const PictureMapKey& key) const; |
+ gfx::Rect PadRect(const gfx::Rect& rect) const; |
+ |
+ int buffer_pixels() const { return tiling_.border_texels(); } |
+ |
+ // A picture pile is a tiled set of pictures. The picture map is a map of tile |
+ // indices to picture infos. |
+ PictureMap picture_map_; |
+ TilingData tiling_; |
+ |
+ // If non-empty, all pictures tiles inside this rect are recorded. There may |
+ // be recordings outside this rect, but everything inside the rect is |
+ // recorded. |
+ gfx::Rect recorded_viewport_; |
+ float min_contents_scale_; |
+ SkTileGridFactory::TileGridInfo tile_grid_info_; |
+ SkColor background_color_; |
+ int slow_down_raster_scale_factor_for_debug_; |
+ bool contents_opaque_; |
+ bool contents_fill_bounds_completely_; |
+ bool clear_canvas_with_debug_color_; |
+ // A hint about whether there are any recordings. This may be a false |
+ // positive. |
+ bool has_any_recordings_; |
+ bool is_mask_; |
+ bool is_solid_color_; |
+ SkColor solid_color_; |
+ int pixel_record_distance_; |
private: |
friend class PicturePileImpl; |
void DetermineIfSolidColor(); |
+ void SetBufferPixels(int buffer_pixels); |
bool is_suitable_for_gpu_rasterization_; |
- int pixel_record_distance_; |
DISALLOW_COPY_AND_ASSIGN(PicturePile); |
}; |