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

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: Address review comments 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 {
vmpstr 2014/11/12 19:18:59 \o/
19 public: 18 public:
20 PicturePile(); 19 PicturePile();
21 ~PicturePile() override; 20 ~PicturePile() override;
22 21
23 bool UpdateAndExpandInvalidation( 22 bool UpdateAndExpandInvalidation(
24 ContentLayerClient* painter, 23 ContentLayerClient* painter,
25 Region* invalidation, 24 Region* invalidation,
26 SkColor background_color, 25 SkColor background_color,
27 bool contents_opaque, 26 bool contents_opaque,
28 bool contents_fill_bounds_completely, 27 bool contents_fill_bounds_completely,
29 const gfx::Size& layer_size, 28 const gfx::Size& layer_size,
30 const gfx::Rect& visible_layer_rect, 29 const gfx::Rect& visible_layer_rect,
31 int frame_number, 30 int frame_number,
32 Picture::RecordingMode recording_mode) override; 31 Picture::RecordingMode recording_mode) override;
33 gfx::Size GetSize() const override; 32 gfx::Size GetSize() const final;
vmpstr 2014/11/12 19:18:59 Why final?
hendrikw 2014/11/12 19:37:32 Early optimization :) It really doesn't matter, b
34 void SetEmptyBounds() override; 33 void SetEmptyBounds() override;
vmpstr 2014/11/12 19:18:59 Can you group all of the overrides/finals together
hendrikw 2014/11/12 19:37:32 Yes!
35 void SetMinContentsScale(float min_contents_scale) override; 34 void SetMinContentsScale(float min_contents_scale) override;
36 void SetTileGridSize(const gfx::Size& tile_grid_size) override; 35 void SetTileGridSize(const gfx::Size& tile_grid_size) override;
37 void SetSlowdownRasterScaleFactor(int factor) override; 36 void SetSlowdownRasterScaleFactor(int factor) override;
38 void SetShowDebugPictureBorders(bool show) override;
39 void SetIsMask(bool is_mask) override; 37 void SetIsMask(bool is_mask) override;
40 bool IsSuitableForGpuRasterization() const override; 38 bool IsSuitableForGpuRasterization() const override;
41 scoped_refptr<RasterSource> CreateRasterSource() const override; 39 scoped_refptr<RasterSource> CreateRasterSource() const override;
42 void SetUnsuitableForGpuRasterizationForTesting() override; 40 void SetUnsuitableForGpuRasterizationForTesting() override;
43 SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const override; 41 SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const override;
44 42
45 void SetPixelRecordDistanceForTesting(int d) { pixel_record_distance_ = d; } 43 static void ComputeTileGridInfo(const gfx::Size& tile_grid_size,
44 SkTileGridFactory::TileGridInfo* info);
46 45
47 protected: 46 protected:
47 class CC_EXPORT PictureInfo {
48 public:
49 enum { INVALIDATION_FRAMES_TRACKED = 32 };
50
51 PictureInfo();
52 ~PictureInfo();
53
54 bool Invalidate(int frame_number);
55 bool NeedsRecording(int frame_number, int distance_to_visible);
56 void SetPicture(scoped_refptr<Picture> picture);
57 const Picture* GetPicture() const;
58
59 float GetInvalidationFrequencyForTesting() const {
60 return GetInvalidationFrequency();
61 }
62
63 private:
64 void AdvanceInvalidationHistory(int frame_number);
65 float GetInvalidationFrequency() const;
66
67 int last_frame_number_;
68 scoped_refptr<const Picture> picture_;
69 std::bitset<INVALIDATION_FRAMES_TRACKED> invalidation_history_;
70 };
71
72 typedef std::pair<int, int> PictureMapKey;
73 typedef base::hash_map<PictureMapKey, PictureInfo> PictureMap;
74
48 // An internal CanRaster check that goes to the picture_map rather than 75 // An internal CanRaster check that goes to the picture_map rather than
49 // using the recorded_viewport hint. 76 // using the recorded_viewport hint.
50 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const; 77 bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const;
51 78
79 void Clear();
80
81 gfx::Rect PaddedRect(const PictureMapKey& key) const;
82 gfx::Rect PadRect(const gfx::Rect& rect) const;
83
84 int buffer_pixels() const { return tiling_.border_texels(); }
85
86 // A picture pile is a tiled set of pictures. The picture map is a map of tile
87 // indices to picture infos.
88 PictureMap picture_map_;
89 TilingData tiling_;
90
91 // If non-empty, all pictures tiles inside this rect are recorded. There may
92 // be recordings outside this rect, but everything inside the rect is
93 // recorded.
94 gfx::Rect recorded_viewport_;
95 float min_contents_scale_;
96 SkTileGridFactory::TileGridInfo tile_grid_info_;
97 SkColor background_color_;
98 int slow_down_raster_scale_factor_for_debug_;
99 bool contents_opaque_;
100 bool contents_fill_bounds_completely_;
101 bool clear_canvas_with_debug_color_;
102 // A hint about whether there are any recordings. This may be a false
103 // positive.
104 bool has_any_recordings_;
105 bool is_mask_;
106 bool is_solid_color_;
107 SkColor solid_color_;
108 int pixel_record_distance_;
109
52 private: 110 private:
53 friend class PicturePileImpl; 111 friend class PicturePileImpl;
54 112
55 void DetermineIfSolidColor(); 113 void DetermineIfSolidColor();
114 void SetBufferPixels(int buffer_pixels);
56 115
57 bool is_suitable_for_gpu_rasterization_; 116 bool is_suitable_for_gpu_rasterization_;
58 int pixel_record_distance_;
59 117
60 DISALLOW_COPY_AND_ASSIGN(PicturePile); 118 DISALLOW_COPY_AND_ASSIGN(PicturePile);
61 }; 119 };
62 120
63 } // namespace cc 121 } // namespace cc
64 122
65 #endif // CC_RESOURCES_PICTURE_PILE_H_ 123 #endif // CC_RESOURCES_PICTURE_PILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698