Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / cc / playback / picture_pile.h
blobfc79e46d529730d20ef602cd2168b3abe6e8919f
1 // Copyright 2012 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.
5 #ifndef CC_PLAYBACK_PICTURE_PILE_H_
6 #define CC_PLAYBACK_PICTURE_PILE_H_
8 #include <bitset>
9 #include <utility>
10 #include <vector>
12 #include "base/containers/hash_tables.h"
13 #include "base/memory/ref_counted.h"
14 #include "cc/base/tiling_data.h"
15 #include "cc/playback/picture.h"
17 namespace cc {
18 class PicturePileImpl;
20 class CC_EXPORT PicturePile : public RecordingSource {
21 public:
22 PicturePile(float min_contents_scale, const gfx::Size& tile_grid_size);
23 ~PicturePile() override;
25 // RecordingSource overrides.
26 bool UpdateAndExpandInvalidation(ContentLayerClient* painter,
27 Region* invalidation,
28 const gfx::Size& layer_size,
29 const gfx::Rect& visible_layer_rect,
30 int frame_number,
31 RecordingMode recording_mode) override;
32 scoped_refptr<RasterSource> CreateRasterSource(
33 bool can_use_lcd_text) const override;
34 gfx::Size GetSize() const final;
35 void SetEmptyBounds() override;
36 void SetSlowdownRasterScaleFactor(int factor) override;
37 void SetGatherDiscardableImages(bool gather_images) override;
38 void SetBackgroundColor(SkColor background_color) override;
39 void SetRequiresClear(bool requires_clear) override;
40 bool IsSuitableForGpuRasterization() const override;
42 typedef std::pair<int, int> PictureMapKey;
43 typedef base::hash_map<PictureMapKey, scoped_refptr<const Picture>>
44 PictureMap;
46 // An internal CanRaster check that goes to the picture_map rather than
47 // using the recorded_viewport hint.
48 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const;
50 void Clear();
52 void SetMinContentsScale(float min_contents_scale);
53 void SetTileGridSize(const gfx::Size& tile_grid_size);
55 gfx::Rect PaddedRect(const PictureMapKey& key) const;
56 gfx::Rect PadRect(const gfx::Rect& rect) const;
58 int buffer_pixels() const { return tiling_.border_texels(); }
60 // A picture pile is a tiled set of pictures. The picture map is a map of tile
61 // indices to picture infos.
62 PictureMap picture_map_;
63 TilingData tiling_;
65 // If non-empty, all pictures tiles inside this rect are recorded. There may
66 // be recordings outside this rect, but everything inside the rect is
67 // recorded.
68 gfx::Rect recorded_viewport_;
69 float min_contents_scale_;
70 gfx::Size tile_grid_size_;
71 int slow_down_raster_scale_factor_for_debug_;
72 bool gather_images_;
73 // A hint about whether there are any recordings. This may be a false
74 // positive.
75 bool has_any_recordings_;
76 bool clear_canvas_with_debug_color_;
77 bool requires_clear_;
78 bool is_solid_color_;
79 SkColor solid_color_;
80 SkColor background_color_;
81 int pixel_record_distance_;
83 private:
84 friend class PicturePileImpl;
86 void CreatePictures(ContentLayerClient* painter,
87 RecordingMode recording_mode,
88 const std::vector<gfx::Rect>& record_rects);
89 void GetInvalidTileRects(const gfx::Rect& interest_rect,
90 std::vector<gfx::Rect>* invalid_tiles);
91 bool ApplyInvalidationAndResize(const gfx::Rect& interest_rect,
92 Region* invalidation,
93 const gfx::Size& layer_size,
94 int frame_number);
95 void DetermineIfSolidColor();
96 void SetBufferPixels(int buffer_pixels);
98 bool is_suitable_for_gpu_rasterization_;
100 DISALLOW_COPY_AND_ASSIGN(PicturePile);
103 } // namespace cc
105 #endif // CC_PLAYBACK_PICTURE_PILE_H_