Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: cc/resources/picture_pile.h

Issue 714203006: cc: Remove PicturePileBase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed comma Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_RESOURCES_PICTURE_PILE_H_ 5 #ifndef CC_RESOURCES_PICTURE_PILE_H_
6 #define CC_RESOURCES_PICTURE_PILE_H_ 6 #define CC_RESOURCES_PICTURE_PILE_H_
7 7
8 #include <bitset>
9
8 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
9 #include "cc/resources/picture_pile_base.h" 11 #include "cc/base/tiling_data.h"
10 #include "cc/resources/recording_source.h" 12 #include "cc/resources/recording_source.h"
11 13
12 namespace cc { 14 namespace cc {
13 class ContentLayerClient;
14 class PicturePileImpl; 15 class PicturePileImpl;
15 class Region;
16 class RenderingStatsInstrumentation;
17 16
18 class CC_EXPORT PicturePile : public PicturePileBase, public RecordingSource { 17 class CC_EXPORT PicturePile : public RecordingSource {
19 public: 18 public:
20 PicturePile(); 19 PicturePile();
21 ~PicturePile() override; 20 ~PicturePile() override;
22 21
22 // RecordingSource overrides.
23 bool UpdateAndExpandInvalidation( 23 bool UpdateAndExpandInvalidation(
24 ContentLayerClient* painter, 24 ContentLayerClient* painter,
25 Region* invalidation, 25 Region* invalidation,
26 SkColor background_color, 26 SkColor background_color,
27 bool contents_opaque, 27 bool contents_opaque,
28 bool contents_fill_bounds_completely, 28 bool contents_fill_bounds_completely,
29 const gfx::Size& layer_size, 29 const gfx::Size& layer_size,
30 const gfx::Rect& visible_layer_rect, 30 const gfx::Rect& visible_layer_rect,
31 int frame_number, 31 int frame_number,
32 Picture::RecordingMode recording_mode) override; 32 Picture::RecordingMode recording_mode) override;
33 gfx::Size GetSize() const override; 33 gfx::Size GetSize() const final;
34 void SetEmptyBounds() override; 34 void SetEmptyBounds() override;
35 void SetMinContentsScale(float min_contents_scale) override; 35 void SetMinContentsScale(float min_contents_scale) override;
36 void SetTileGridSize(const gfx::Size& tile_grid_size) override; 36 void SetTileGridSize(const gfx::Size& tile_grid_size) override;
37 void SetSlowdownRasterScaleFactor(int factor) override; 37 void SetSlowdownRasterScaleFactor(int factor) override;
38 void SetShowDebugPictureBorders(bool show) override;
39 void SetIsMask(bool is_mask) override; 38 void SetIsMask(bool is_mask) override;
40 bool IsSuitableForGpuRasterization() const override; 39 bool IsSuitableForGpuRasterization() const override;
41 scoped_refptr<RasterSource> CreateRasterSource() const override; 40 scoped_refptr<RasterSource> CreateRasterSource() const override;
42 void SetUnsuitableForGpuRasterizationForTesting() override; 41 void SetUnsuitableForGpuRasterizationForTesting() override;
43 SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const override; 42 SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const override;
44 43
45 void SetPixelRecordDistanceForTesting(int d) { pixel_record_distance_ = d; } 44 static void ComputeTileGridInfo(const gfx::Size& tile_grid_size,
45 SkTileGridFactory::TileGridInfo* info);
46 46
47 protected: 47 protected:
48 class CC_EXPORT PictureInfo {
49 public:
50 enum { INVALIDATION_FRAMES_TRACKED = 32 };
51
52 PictureInfo();
53 ~PictureInfo();
54
55 bool Invalidate(int frame_number);
56 bool NeedsRecording(int frame_number, int distance_to_visible);
57 void SetPicture(scoped_refptr<Picture> picture);
58 const Picture* GetPicture() const;
59
60 float GetInvalidationFrequencyForTesting() const {
61 return GetInvalidationFrequency();
62 }
63
64 private:
65 void AdvanceInvalidationHistory(int frame_number);
66 float GetInvalidationFrequency() const;
67
68 int last_frame_number_;
69 scoped_refptr<const Picture> picture_;
70 std::bitset<INVALIDATION_FRAMES_TRACKED> invalidation_history_;
71 };
72
73 typedef std::pair<int, int> PictureMapKey;
74 typedef base::hash_map<PictureMapKey, PictureInfo> PictureMap;
75
48 // An internal CanRaster check that goes to the picture_map rather than 76 // An internal CanRaster check that goes to the picture_map rather than
49 // using the recorded_viewport hint. 77 // using the recorded_viewport hint.
50 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const; 78 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const;
51 79
80 void Clear();
81
82 gfx::Rect PaddedRect(const PictureMapKey& key) const;
83 gfx::Rect PadRect(const gfx::Rect& rect) const;
84
85 int buffer_pixels() const { return tiling_.border_texels(); }
86
87 // A picture pile is a tiled set of pictures. The picture map is a map of tile
88 // indices to picture infos.
89 PictureMap picture_map_;
90 TilingData tiling_;
91
92 // If non-empty, all pictures tiles inside this rect are recorded. There may
93 // be recordings outside this rect, but everything inside the rect is
94 // recorded.
95 gfx::Rect recorded_viewport_;
96 float min_contents_scale_;
97 SkTileGridFactory::TileGridInfo tile_grid_info_;
98 SkColor background_color_;
99 int slow_down_raster_scale_factor_for_debug_;
100 bool contents_opaque_;
101 bool contents_fill_bounds_completely_;
102 bool clear_canvas_with_debug_color_;
103 // A hint about whether there are any recordings. This may be a false
104 // positive.
105 bool has_any_recordings_;
106 bool is_mask_;
107 bool is_solid_color_;
108 SkColor solid_color_;
109 int pixel_record_distance_;
110
52 private: 111 private:
53 friend class PicturePileImpl; 112 friend class PicturePileImpl;
54 113
55 void DetermineIfSolidColor(); 114 void DetermineIfSolidColor();
115 void SetBufferPixels(int buffer_pixels);
56 116
57 bool is_suitable_for_gpu_rasterization_; 117 bool is_suitable_for_gpu_rasterization_;
58 int pixel_record_distance_;
59 118
60 DISALLOW_COPY_AND_ASSIGN(PicturePile); 119 DISALLOW_COPY_AND_ASSIGN(PicturePile);
61 }; 120 };
62 121
63 } // namespace cc 122 } // namespace cc
64 123
65 #endif // CC_RESOURCES_PICTURE_PILE_H_ 124 #endif // CC_RESOURCES_PICTURE_PILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698