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 20 matching lines...) Expand all Loading... |
31 public: | 31 public: |
32 struct CC_EXPORT Pair { | 32 struct CC_EXPORT Pair { |
33 Pair(); | 33 Pair(); |
34 Pair(PictureLayerImpl* active_layer, PictureLayerImpl* pending_layer); | 34 Pair(PictureLayerImpl* active_layer, PictureLayerImpl* pending_layer); |
35 ~Pair(); | 35 ~Pair(); |
36 | 36 |
37 PictureLayerImpl* active; | 37 PictureLayerImpl* active; |
38 PictureLayerImpl* pending; | 38 PictureLayerImpl* pending; |
39 }; | 39 }; |
40 | 40 |
41 static scoped_ptr<PictureLayerImpl> Create(LayerTreeImpl* tree_impl, | 41 static scoped_ptr<PictureLayerImpl> Create( |
42 int id, | 42 LayerTreeImpl* tree_impl, |
43 bool is_mask) { | 43 int id, |
44 return make_scoped_ptr(new PictureLayerImpl(tree_impl, id, is_mask)); | 44 bool is_mask, |
| 45 scoped_refptr<SyncedScrollOffset> scroll_offset) { |
| 46 return make_scoped_ptr( |
| 47 new PictureLayerImpl(tree_impl, id, is_mask, scroll_offset)); |
45 } | 48 } |
46 ~PictureLayerImpl() override; | 49 ~PictureLayerImpl() override; |
47 | 50 |
48 bool is_mask() const { return is_mask_; } | 51 bool is_mask() const { return is_mask_; } |
49 | 52 |
50 // LayerImpl overrides. | 53 // LayerImpl overrides. |
51 const char* LayerTypeAsString() const override; | 54 const char* LayerTypeAsString() const override; |
52 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 55 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
53 void PushPropertiesTo(LayerImpl* layer) override; | 56 void PushPropertiesTo(LayerImpl* layer) override; |
54 void AppendQuads(RenderPass* render_pass, | 57 void AppendQuads(RenderPass* render_pass, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 93 |
91 bool CanHaveTilings() const; | 94 bool CanHaveTilings() const; |
92 | 95 |
93 PictureLayerTilingSet* picture_layer_tiling_set() { return tilings_.get(); } | 96 PictureLayerTilingSet* picture_layer_tiling_set() { return tilings_.get(); } |
94 | 97 |
95 // Functions used by tile manager. | 98 // Functions used by tile manager. |
96 PictureLayerImpl* GetPendingOrActiveTwinLayer() const; | 99 PictureLayerImpl* GetPendingOrActiveTwinLayer() const; |
97 bool IsOnActiveOrPendingTree() const; | 100 bool IsOnActiveOrPendingTree() const; |
98 // Virtual for testing. | 101 // Virtual for testing. |
99 virtual bool HasValidTilePriorities() const; | 102 virtual bool HasValidTilePriorities() const; |
100 bool AllTilesRequiredForActivationAreReadyToDraw() const; | |
101 bool AllTilesRequiredForDrawAreReadyToDraw() const; | |
102 | 103 |
103 // Used for benchmarking | 104 // Used for benchmarking |
104 RasterSource* GetRasterSource() const { return raster_source_.get(); } | 105 RasterSource* GetRasterSource() const { return raster_source_.get(); } |
105 | 106 |
106 protected: | 107 protected: |
107 friend class LayerRasterTileIterator; | 108 friend class LayerRasterTileIterator; |
108 using TileRequirementCheck = bool (PictureLayerTiling::*)(const Tile*) const; | 109 using TileRequirementCheck = bool (PictureLayerTiling::*)(const Tile*) const; |
109 | 110 |
110 PictureLayerImpl(LayerTreeImpl* tree_impl, int id, bool is_mask); | 111 PictureLayerImpl(LayerTreeImpl* tree_impl, |
| 112 int id, |
| 113 bool is_mask, |
| 114 scoped_refptr<SyncedScrollOffset> scroll_offset); |
111 PictureLayerTiling* AddTiling(float contents_scale); | 115 PictureLayerTiling* AddTiling(float contents_scale); |
112 void RemoveAllTilings(); | 116 void RemoveAllTilings(); |
113 void AddTilingsForRasterScale(); | 117 void AddTilingsForRasterScale(); |
114 bool UpdateTilePriorities(const Occlusion& occlusion_in_content_space); | 118 bool UpdateTilePriorities(const Occlusion& occlusion_in_content_space); |
115 virtual bool ShouldAdjustRasterScale() const; | 119 virtual bool ShouldAdjustRasterScale() const; |
116 virtual void RecalculateRasterScales(); | 120 virtual void RecalculateRasterScales(); |
117 void CleanUpTilingsOnActiveLayer( | 121 void CleanUpTilingsOnActiveLayer( |
118 std::vector<PictureLayerTiling*> used_tilings); | 122 const std::vector<PictureLayerTiling*>& used_tilings); |
119 float MinimumContentsScale() const; | 123 float MinimumContentsScale() const; |
120 float MaximumContentsScale() const; | 124 float MaximumContentsScale() const; |
121 void ResetRasterScale(); | 125 void ResetRasterScale(); |
122 void UpdateViewportRectForTilePriorityInContentSpace(); | 126 void UpdateViewportRectForTilePriorityInContentSpace(); |
123 PictureLayerImpl* GetRecycledTwinLayer() const; | 127 PictureLayerImpl* GetRecycledTwinLayer() const; |
124 | 128 |
125 void SanityCheckTilingState() const; | 129 void SanityCheckTilingState() const; |
126 // Checks if all tiles required for a certain action (e.g. activation) are | |
127 // ready to draw. is_tile_required_callback gets called on all candidate | |
128 // tiles and returns true if the tile is required for the action. | |
129 bool AllTilesRequiredAreReadyToDraw( | |
130 TileRequirementCheck is_tile_required_callback) const; | |
131 | |
132 bool ShouldAdjustRasterScaleDuringScaleAnimations() const; | 130 bool ShouldAdjustRasterScaleDuringScaleAnimations() const; |
133 | 131 |
134 void GetDebugBorderProperties(SkColor* color, float* width) const override; | 132 void GetDebugBorderProperties(SkColor* color, float* width) const override; |
135 void GetAllTilesForTracing(std::set<const Tile*>* tiles) const override; | 133 void GetAllTilesForTracing(std::set<const Tile*>* tiles) const override; |
136 void AsValueInto(base::debug::TracedValue* dict) const override; | 134 void AsValueInto(base::debug::TracedValue* dict) const override; |
137 | 135 |
138 virtual void UpdateIdealScales(); | 136 virtual void UpdateIdealScales(); |
139 float MaximumTilingContentsScale() const; | 137 float MaximumTilingContentsScale() const; |
140 scoped_ptr<PictureLayerTilingSet> CreatePictureLayerTilingSet(); | 138 scoped_ptr<PictureLayerTilingSet> CreatePictureLayerTilingSet(); |
141 | 139 |
(...skipping 23 matching lines...) Expand all Loading... |
165 | 163 |
166 // Any draw properties derived from |transform|, |viewport|, and |clip| | 164 // Any draw properties derived from |transform|, |viewport|, and |clip| |
167 // parameters in LayerTreeHostImpl::SetExternalDrawConstraints are not valid | 165 // parameters in LayerTreeHostImpl::SetExternalDrawConstraints are not valid |
168 // for prioritizing tiles during resourceless software draws. This is because | 166 // for prioritizing tiles during resourceless software draws. This is because |
169 // resourceless software draws can have wildly different transforms/viewports | 167 // resourceless software draws can have wildly different transforms/viewports |
170 // from regular draws. Save a copy of the required draw properties of the last | 168 // from regular draws. Save a copy of the required draw properties of the last |
171 // frame that has a valid viewport for prioritizing tiles. | 169 // frame that has a valid viewport for prioritizing tiles. |
172 gfx::Rect visible_rect_for_tile_priority_; | 170 gfx::Rect visible_rect_for_tile_priority_; |
173 gfx::Rect viewport_rect_for_tile_priority_in_content_space_; | 171 gfx::Rect viewport_rect_for_tile_priority_in_content_space_; |
174 | 172 |
| 173 // List of tilings that were used last time we appended quads. This can be |
| 174 // used as an optimization not to remove tilings if they are still being |
| 175 // drawn. Note that accessing this vector should only be done in the context |
| 176 // of comparing pointers, since objects pointed to are not guaranteed to |
| 177 // exist. |
| 178 std::vector<PictureLayerTiling*> last_append_quads_tilings_; |
| 179 |
175 DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); | 180 DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); |
176 }; | 181 }; |
177 | 182 |
178 } // namespace cc | 183 } // namespace cc |
179 | 184 |
180 #endif // CC_LAYERS_PICTURE_LAYER_IMPL_H_ | 185 #endif // CC_LAYERS_PICTURE_LAYER_IMPL_H_ |
OLD | NEW |