OLD | NEW |
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_LAYERS_PICTURE_LAYER_IMPL_H_ | 5 #ifndef CC_LAYERS_PICTURE_LAYER_IMPL_H_ |
6 #define CC_LAYERS_PICTURE_LAYER_IMPL_H_ | 6 #define CC_LAYERS_PICTURE_LAYER_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 21 matching lines...) Expand all Loading... |
32 public: | 32 public: |
33 struct CC_EXPORT Pair { | 33 struct CC_EXPORT Pair { |
34 Pair(); | 34 Pair(); |
35 Pair(PictureLayerImpl* active_layer, PictureLayerImpl* pending_layer); | 35 Pair(PictureLayerImpl* active_layer, PictureLayerImpl* pending_layer); |
36 ~Pair(); | 36 ~Pair(); |
37 | 37 |
38 PictureLayerImpl* active; | 38 PictureLayerImpl* active; |
39 PictureLayerImpl* pending; | 39 PictureLayerImpl* pending; |
40 }; | 40 }; |
41 | 41 |
42 static scoped_ptr<PictureLayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 42 static scoped_ptr<PictureLayerImpl> Create(LayerTreeImpl* tree_impl, |
43 return make_scoped_ptr(new PictureLayerImpl(tree_impl, id)); | 43 int id, |
| 44 bool is_mask) { |
| 45 return make_scoped_ptr(new PictureLayerImpl(tree_impl, id, is_mask)); |
44 } | 46 } |
45 ~PictureLayerImpl() override; | 47 ~PictureLayerImpl() override; |
46 | 48 |
47 scoped_ptr<TilingSetEvictionQueue> CreateEvictionQueue( | 49 scoped_ptr<TilingSetEvictionQueue> CreateEvictionQueue( |
48 TreePriority tree_priority); | 50 TreePriority tree_priority); |
49 scoped_ptr<TilingSetRasterQueue> CreateRasterQueue(bool prioritize_low_res); | 51 scoped_ptr<TilingSetRasterQueue> CreateRasterQueue(bool prioritize_low_res); |
50 | 52 |
51 // LayerImpl overrides. | 53 // LayerImpl overrides. |
52 const char* LayerTypeAsString() const override; | 54 const char* LayerTypeAsString() const override; |
53 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 55 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
(...skipping 24 matching lines...) Expand all Loading... |
78 int GetSkewportExtrapolationLimitInContentPixels() const override; | 80 int GetSkewportExtrapolationLimitInContentPixels() const override; |
79 WhichTree GetTree() const override; | 81 WhichTree GetTree() const override; |
80 bool RequiresHighResToDraw() const override; | 82 bool RequiresHighResToDraw() const override; |
81 | 83 |
82 // PushPropertiesTo active tree => pending tree. | 84 // PushPropertiesTo active tree => pending tree. |
83 void SyncTiling(const PictureLayerTiling* tiling); | 85 void SyncTiling(const PictureLayerTiling* tiling); |
84 | 86 |
85 // Mask-related functions. | 87 // Mask-related functions. |
86 void GetContentsResourceId(ResourceProvider::ResourceId* resource_id, | 88 void GetContentsResourceId(ResourceProvider::ResourceId* resource_id, |
87 gfx::Size* resource_size) const override; | 89 gfx::Size* resource_size) const override; |
88 void set_is_mask(bool is_mask) { is_mask_ = is_mask; } | |
89 | 90 |
90 size_t GPUMemoryUsageInBytes() const override; | 91 size_t GPUMemoryUsageInBytes() const override; |
91 | 92 |
92 void RunMicroBenchmark(MicroBenchmarkImpl* benchmark) override; | 93 void RunMicroBenchmark(MicroBenchmarkImpl* benchmark) override; |
93 | 94 |
94 bool CanHaveTilings() const; | 95 bool CanHaveTilings() const; |
95 | 96 |
96 // Functions used by tile manager. | 97 // Functions used by tile manager. |
97 PictureLayerImpl* GetPendingOrActiveTwinLayer() const; | 98 PictureLayerImpl* GetPendingOrActiveTwinLayer() const; |
98 bool IsOnActiveOrPendingTree() const; | 99 bool IsOnActiveOrPendingTree() const; |
99 // Virtual for testing. | 100 // Virtual for testing. |
100 virtual bool HasValidTilePriorities() const; | 101 virtual bool HasValidTilePriorities() const; |
101 bool AllTilesRequiredForActivationAreReadyToDraw() const; | 102 bool AllTilesRequiredForActivationAreReadyToDraw() const; |
102 bool AllTilesRequiredForDrawAreReadyToDraw() const; | 103 bool AllTilesRequiredForDrawAreReadyToDraw() const; |
103 | 104 |
104 // Used for benchmarking | 105 // Used for benchmarking |
105 const RasterSource* GetRasterSource() const { return raster_source_.get(); } | 106 const RasterSource* GetRasterSource() const { return raster_source_.get(); } |
106 | 107 |
107 protected: | 108 protected: |
108 friend class LayerRasterTileIterator; | 109 friend class LayerRasterTileIterator; |
109 using TileRequirementCheck = bool (PictureLayerTiling::*)(const Tile*) const; | 110 using TileRequirementCheck = bool (PictureLayerTiling::*)(const Tile*) const; |
110 | 111 |
111 PictureLayerImpl(LayerTreeImpl* tree_impl, int id); | 112 PictureLayerImpl(LayerTreeImpl* tree_impl, int id, bool is_mask); |
112 PictureLayerTiling* AddTiling(float contents_scale); | 113 PictureLayerTiling* AddTiling(float contents_scale); |
113 void RemoveAllTilings(); | 114 void RemoveAllTilings(); |
114 void SyncFromActiveLayer(const PictureLayerImpl* other); | |
115 void AddTilingsForRasterScale(); | 115 void AddTilingsForRasterScale(); |
116 void UpdateTilePriorities(const Occlusion& occlusion_in_content_space); | 116 void UpdateTilePriorities(const Occlusion& occlusion_in_content_space); |
117 virtual bool ShouldAdjustRasterScale() const; | 117 virtual bool ShouldAdjustRasterScale() const; |
118 virtual void RecalculateRasterScales(); | 118 virtual void RecalculateRasterScales(); |
119 void CleanUpTilingsOnActiveLayer( | 119 void CleanUpTilingsOnActiveLayer( |
120 std::vector<PictureLayerTiling*> used_tilings); | 120 std::vector<PictureLayerTiling*> used_tilings); |
121 float MinimumContentsScale() const; | 121 float MinimumContentsScale() const; |
122 void ResetRasterScale(); | 122 void ResetRasterScale(); |
123 gfx::Rect GetViewportForTilePriorityInContentSpace() const; | 123 gfx::Rect GetViewportForTilePriorityInContentSpace() const; |
124 PictureLayerImpl* GetRecycledTwinLayer() const; | 124 PictureLayerImpl* GetRecycledTwinLayer() const; |
125 void UpdateRasterSource(scoped_refptr<RasterSource> raster_source); | 125 void UpdateRasterSource(scoped_refptr<RasterSource> raster_source, |
| 126 Region* new_invalidation, |
| 127 const PictureLayerTilingSet* pending_set); |
126 | 128 |
127 void DoPostCommitInitializationIfNeeded() { | 129 void DoPostCommitInitializationIfNeeded() { |
128 if (needs_post_commit_initialization_) | 130 if (needs_post_commit_initialization_) |
129 DoPostCommitInitialization(); | 131 DoPostCommitInitialization(); |
130 } | 132 } |
131 void DoPostCommitInitialization(); | 133 void DoPostCommitInitialization(); |
132 | 134 |
133 bool CanHaveTilingWithScale(float contents_scale) const; | 135 bool CanHaveTilingWithScale(float contents_scale) const; |
134 void SanityCheckTilingState() const; | 136 void SanityCheckTilingState() const; |
135 // Checks if all tiles required for a certain action (e.g. activation) are | 137 // Checks if all tiles required for a certain action (e.g. activation) are |
(...skipping 28 matching lines...) Expand all Loading... |
164 float raster_contents_scale_; | 166 float raster_contents_scale_; |
165 float low_res_raster_contents_scale_; | 167 float low_res_raster_contents_scale_; |
166 | 168 |
167 bool raster_source_scale_is_fixed_; | 169 bool raster_source_scale_is_fixed_; |
168 bool was_screen_space_transform_animating_; | 170 bool was_screen_space_transform_animating_; |
169 bool needs_post_commit_initialization_; | 171 bool needs_post_commit_initialization_; |
170 // A sanity state check to make sure UpdateTilePriorities only gets called | 172 // A sanity state check to make sure UpdateTilePriorities only gets called |
171 // after a CalculateContentsScale/ManageTilings. | 173 // after a CalculateContentsScale/ManageTilings. |
172 bool should_update_tile_priorities_; | 174 bool should_update_tile_priorities_; |
173 bool only_used_low_res_last_append_quads_; | 175 bool only_used_low_res_last_append_quads_; |
174 bool is_mask_; | 176 const bool is_mask_; |
175 | 177 |
176 // Any draw properties derived from |transform|, |viewport|, and |clip| | 178 // Any draw properties derived from |transform|, |viewport|, and |clip| |
177 // parameters in LayerTreeHostImpl::SetExternalDrawConstraints are not valid | 179 // parameters in LayerTreeHostImpl::SetExternalDrawConstraints are not valid |
178 // for prioritizing tiles during resourceless software draws. This is because | 180 // for prioritizing tiles during resourceless software draws. This is because |
179 // resourceless software draws can have wildly different transforms/viewports | 181 // resourceless software draws can have wildly different transforms/viewports |
180 // from regular draws. Save a copy of the required draw properties of the last | 182 // from regular draws. Save a copy of the required draw properties of the last |
181 // frame that has a valid viewport for prioritizing tiles. | 183 // frame that has a valid viewport for prioritizing tiles. |
182 gfx::Rect visible_rect_for_tile_priority_; | 184 gfx::Rect visible_rect_for_tile_priority_; |
183 | 185 |
184 friend class PictureLayer; | 186 friend class PictureLayer; |
185 DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); | 187 DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); |
186 }; | 188 }; |
187 | 189 |
188 } // namespace cc | 190 } // namespace cc |
189 | 191 |
190 #endif // CC_LAYERS_PICTURE_LAYER_IMPL_H_ | 192 #endif // CC_LAYERS_PICTURE_LAYER_IMPL_H_ |
OLD | NEW |