OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CC_RESOURCES_PICTURE_PILE_H_ | |
6 #define CC_RESOURCES_PICTURE_PILE_H_ | |
7 | |
8 #include <bitset> | |
9 #include <utility> | |
10 #include <vector> | |
11 | |
12 #include "base/containers/hash_tables.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "cc/base/tiling_data.h" | |
15 #include "cc/resources/picture.h" | |
16 | |
17 namespace cc { | |
18 class PicturePileImpl; | |
19 | |
20 class CC_EXPORT PicturePile : public RecordingSource { | |
21 public: | |
22 PicturePile(float min_contents_scale, const gfx::Size& tile_grid_size); | |
23 ~PicturePile() override; | |
24 | |
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 SetGatherPixelRefs(bool gather_pixel_refs) override; | |
38 void SetBackgroundColor(SkColor background_color) override; | |
39 void SetRequiresClear(bool requires_clear) override; | |
40 bool IsSuitableForGpuRasterization() const override; | |
41 void SetUnsuitableForGpuRasterizationForTesting() override; | |
42 gfx::Size GetTileGridSizeForTesting() const override; | |
43 | |
44 typedef std::pair<int, int> PictureMapKey; | |
45 typedef base::hash_map<PictureMapKey, scoped_refptr<const Picture>> | |
46 PictureMap; | |
47 | |
48 // An internal CanRaster check that goes to the picture_map rather than | |
49 // using the recorded_viewport hint. | |
50 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const; | |
51 | |
52 void Clear(); | |
53 | |
54 void SetMinContentsScale(float min_contents_scale); | |
55 void SetTileGridSize(const gfx::Size& tile_grid_size); | |
56 | |
57 gfx::Rect PaddedRect(const PictureMapKey& key) const; | |
58 gfx::Rect PadRect(const gfx::Rect& rect) const; | |
59 | |
60 int buffer_pixels() const { return tiling_.border_texels(); } | |
61 | |
62 // A picture pile is a tiled set of pictures. The picture map is a map of tile | |
63 // indices to picture infos. | |
64 PictureMap picture_map_; | |
65 TilingData tiling_; | |
66 | |
67 // If non-empty, all pictures tiles inside this rect are recorded. There may | |
68 // be recordings outside this rect, but everything inside the rect is | |
69 // recorded. | |
70 gfx::Rect recorded_viewport_; | |
71 float min_contents_scale_; | |
72 gfx::Size tile_grid_size_; | |
73 int slow_down_raster_scale_factor_for_debug_; | |
74 bool gather_pixel_refs_; | |
75 // A hint about whether there are any recordings. This may be a false | |
76 // positive. | |
77 bool has_any_recordings_; | |
78 bool clear_canvas_with_debug_color_; | |
79 bool requires_clear_; | |
80 bool is_solid_color_; | |
81 SkColor solid_color_; | |
82 SkColor background_color_; | |
83 int pixel_record_distance_; | |
84 | |
85 private: | |
86 friend class PicturePileImpl; | |
87 | |
88 void CreatePictures(ContentLayerClient* painter, | |
89 RecordingMode recording_mode, | |
90 const std::vector<gfx::Rect>& record_rects); | |
91 void GetInvalidTileRects(const gfx::Rect& interest_rect, | |
92 std::vector<gfx::Rect>* invalid_tiles); | |
93 bool ApplyInvalidationAndResize(const gfx::Rect& interest_rect, | |
94 Region* invalidation, | |
95 const gfx::Size& layer_size, | |
96 int frame_number); | |
97 void DetermineIfSolidColor(); | |
98 void SetBufferPixels(int buffer_pixels); | |
99 | |
100 bool is_suitable_for_gpu_rasterization_; | |
101 | |
102 DISALLOW_COPY_AND_ASSIGN(PicturePile); | |
103 }; | |
104 | |
105 } // namespace cc | |
106 | |
107 #endif // CC_RESOURCES_PICTURE_PILE_H_ | |
OLD | NEW |