This sets up API to release OutputSurface from LTHClient.
[chromium-blink-merge.git] / cc / playback / picture_pile.h
blobe0500a3d5be2f4cfebbf5ebd20625834966dd353
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;
41 void SetUnsuitableForGpuRasterizationForTesting() override;
43 typedef std::pair<int, int> PictureMapKey;
44 typedef base::hash_map<PictureMapKey, scoped_refptr<const Picture>>
45 PictureMap;
47 // An internal CanRaster check that goes to the picture_map rather than
48 // using the recorded_viewport hint.
49 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const;
51 void Clear();
53 void SetMinContentsScale(float min_contents_scale);
54 void SetTileGridSize(const gfx::Size& tile_grid_size);
56 gfx::Rect PaddedRect(const PictureMapKey& key) const;
57 gfx::Rect PadRect(const gfx::Rect& rect) const;
59 int buffer_pixels() const { return tiling_.border_texels(); }
61 // A picture pile is a tiled set of pictures. The picture map is a map of tile
62 // indices to picture infos.
63 PictureMap picture_map_;
64 TilingData tiling_;
66 // If non-empty, all pictures tiles inside this rect are recorded. There may
67 // be recordings outside this rect, but everything inside the rect is
68 // recorded.
69 gfx::Rect recorded_viewport_;
70 float min_contents_scale_;
71 gfx::Size tile_grid_size_;
72 int slow_down_raster_scale_factor_for_debug_;
73 bool gather_images_;
74 // A hint about whether there are any recordings. This may be a false
75 // positive.
76 bool has_any_recordings_;
77 bool clear_canvas_with_debug_color_;
78 bool requires_clear_;
79 bool is_solid_color_;
80 SkColor solid_color_;
81 SkColor background_color_;
82 int pixel_record_distance_;
84 private:
85 friend class PicturePileImpl;
87 void CreatePictures(ContentLayerClient* painter,
88 RecordingMode recording_mode,
89 const std::vector<gfx::Rect>& record_rects);
90 void GetInvalidTileRects(const gfx::Rect& interest_rect,
91 std::vector<gfx::Rect>* invalid_tiles);
92 bool ApplyInvalidationAndResize(const gfx::Rect& interest_rect,
93 Region* invalidation,
94 const gfx::Size& layer_size,
95 int frame_number);
96 void DetermineIfSolidColor();
97 void SetBufferPixels(int buffer_pixels);
99 bool is_suitable_for_gpu_rasterization_;
101 DISALLOW_COPY_AND_ASSIGN(PicturePile);
104 } // namespace cc
106 #endif // CC_PLAYBACK_PICTURE_PILE_H_