| 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 12 matching lines...) Expand all Loading... |
| 66 // PictureLayerTilingClient overrides. | 68 // PictureLayerTilingClient overrides. |
| 67 scoped_refptr<Tile> CreateTile(PictureLayerTiling* tiling, | 69 scoped_refptr<Tile> CreateTile(PictureLayerTiling* tiling, |
| 68 const gfx::Rect& content_rect) override; | 70 const gfx::Rect& content_rect) override; |
| 69 gfx::Size CalculateTileSize(const gfx::Size& content_bounds) const override; | 71 gfx::Size CalculateTileSize(const gfx::Size& content_bounds) const override; |
| 70 const Region* GetPendingInvalidation() override; | 72 const Region* GetPendingInvalidation() override; |
| 71 const PictureLayerTiling* GetPendingOrActiveTwinTiling( | 73 const PictureLayerTiling* GetPendingOrActiveTwinTiling( |
| 72 const PictureLayerTiling* tiling) const override; | 74 const PictureLayerTiling* tiling) const override; |
| 73 PictureLayerTiling* GetRecycledTwinTiling( | 75 PictureLayerTiling* GetRecycledTwinTiling( |
| 74 const PictureLayerTiling* tiling) override; | 76 const PictureLayerTiling* tiling) override; |
| 75 TilePriority::PriorityBin GetMaxTilePriorityBin() const override; | 77 TilePriority::PriorityBin GetMaxTilePriorityBin() const override; |
| 76 size_t GetMaxTilesForInterestArea() const override; | |
| 77 float GetSkewportTargetTimeInSeconds() const override; | |
| 78 int GetSkewportExtrapolationLimitInContentPixels() const override; | |
| 79 WhichTree GetTree() const override; | 78 WhichTree GetTree() const override; |
| 80 bool RequiresHighResToDraw() const override; | 79 bool RequiresHighResToDraw() const override; |
| 81 | 80 |
| 82 // PushPropertiesTo active tree => pending tree. | 81 // PushPropertiesTo active tree => pending tree. |
| 83 void SyncTiling(const PictureLayerTiling* tiling); | 82 void SyncTiling(const PictureLayerTiling* tiling); |
| 84 | 83 |
| 85 // Mask-related functions. | 84 // Mask-related functions. |
| 86 void GetContentsResourceId(ResourceProvider::ResourceId* resource_id, | 85 void GetContentsResourceId(ResourceProvider::ResourceId* resource_id, |
| 87 gfx::Size* resource_size) const override; | 86 gfx::Size* resource_size) const override; |
| 88 void set_is_mask(bool is_mask) { is_mask_ = is_mask; } | 87 |
| 88 void SetNearestNeighbor(bool nearest_neighbor); |
| 89 | 89 |
| 90 size_t GPUMemoryUsageInBytes() const override; | 90 size_t GPUMemoryUsageInBytes() const override; |
| 91 | 91 |
| 92 void RunMicroBenchmark(MicroBenchmarkImpl* benchmark) override; | 92 void RunMicroBenchmark(MicroBenchmarkImpl* benchmark) override; |
| 93 | 93 |
| 94 bool CanHaveTilings() const; | 94 bool CanHaveTilings() const; |
| 95 | 95 |
| 96 // Functions used by tile manager. | 96 // Functions used by tile manager. |
| 97 PictureLayerImpl* GetPendingOrActiveTwinLayer() const; | 97 PictureLayerImpl* GetPendingOrActiveTwinLayer() const; |
| 98 bool IsOnActiveOrPendingTree() const; | 98 bool IsOnActiveOrPendingTree() const; |
| 99 // Virtual for testing. | 99 // Virtual for testing. |
| 100 virtual bool HasValidTilePriorities() const; | 100 virtual bool HasValidTilePriorities() const; |
| 101 bool AllTilesRequiredForActivationAreReadyToDraw() const; | 101 bool AllTilesRequiredForActivationAreReadyToDraw() const; |
| 102 bool AllTilesRequiredForDrawAreReadyToDraw() const; | 102 bool AllTilesRequiredForDrawAreReadyToDraw() const; |
| 103 | 103 |
| 104 // Used for benchmarking | 104 // Used for benchmarking |
| 105 const RasterSource* GetRasterSource() const { return raster_source_.get(); } | 105 const RasterSource* GetRasterSource() const { return raster_source_.get(); } |
| 106 | 106 |
| 107 protected: | 107 protected: |
| 108 friend class LayerRasterTileIterator; | 108 friend class LayerRasterTileIterator; |
| 109 using TileRequirementCheck = bool (PictureLayerTiling::*)(const Tile*) const; | 109 using TileRequirementCheck = bool (PictureLayerTiling::*)(const Tile*) const; |
| 110 | 110 |
| 111 PictureLayerImpl(LayerTreeImpl* tree_impl, int id); | 111 PictureLayerImpl(LayerTreeImpl* tree_impl, int id, bool is_mask); |
| 112 PictureLayerTiling* AddTiling(float contents_scale); | 112 PictureLayerTiling* AddTiling(float contents_scale); |
| 113 void RemoveAllTilings(); | 113 void RemoveAllTilings(); |
| 114 void SyncFromActiveLayer(const PictureLayerImpl* other); | |
| 115 void AddTilingsForRasterScale(); | 114 void AddTilingsForRasterScale(); |
| 116 void UpdateTilePriorities(const Occlusion& occlusion_in_content_space); | 115 void UpdateTilePriorities(const Occlusion& occlusion_in_content_space); |
| 117 virtual bool ShouldAdjustRasterScale() const; | 116 virtual bool ShouldAdjustRasterScale() const; |
| 118 virtual void RecalculateRasterScales(); | 117 virtual void RecalculateRasterScales(); |
| 119 void CleanUpTilingsOnActiveLayer( | 118 void CleanUpTilingsOnActiveLayer( |
| 120 std::vector<PictureLayerTiling*> used_tilings); | 119 std::vector<PictureLayerTiling*> used_tilings); |
| 121 float MinimumContentsScale() const; | 120 float MinimumContentsScale() const; |
| 122 void ResetRasterScale(); | 121 void ResetRasterScale(); |
| 123 gfx::Rect GetViewportForTilePriorityInContentSpace() const; | 122 gfx::Rect GetViewportForTilePriorityInContentSpace() const; |
| 124 PictureLayerImpl* GetRecycledTwinLayer() const; | 123 PictureLayerImpl* GetRecycledTwinLayer() const; |
| 125 void UpdateRasterSource(scoped_refptr<RasterSource> raster_source); | 124 void UpdateRasterSource(scoped_refptr<RasterSource> raster_source, |
| 125 Region* new_invalidation, |
| 126 const PictureLayerTilingSet* pending_set); |
| 126 | 127 |
| 127 void DoPostCommitInitializationIfNeeded() { | 128 void DoPostCommitInitializationIfNeeded() { |
| 128 if (needs_post_commit_initialization_) | 129 if (needs_post_commit_initialization_) |
| 129 DoPostCommitInitialization(); | 130 DoPostCommitInitialization(); |
| 130 } | 131 } |
| 131 void DoPostCommitInitialization(); | 132 void DoPostCommitInitialization(); |
| 132 | 133 |
| 133 bool CanHaveTilingWithScale(float contents_scale) const; | 134 bool CanHaveTilingWithScale(float contents_scale) const; |
| 134 void SanityCheckTilingState() const; | 135 void SanityCheckTilingState() const; |
| 135 // Checks if all tiles required for a certain action (e.g. activation) are | 136 // Checks if all tiles required for a certain action (e.g. activation) are |
| 136 // ready to draw. is_tile_required_callback gets called on all candidate | 137 // ready to draw. is_tile_required_callback gets called on all candidate |
| 137 // tiles and returns true if the tile is required for the action. | 138 // tiles and returns true if the tile is required for the action. |
| 138 bool AllTilesRequiredAreReadyToDraw( | 139 bool AllTilesRequiredAreReadyToDraw( |
| 139 TileRequirementCheck is_tile_required_callback) const; | 140 TileRequirementCheck is_tile_required_callback) const; |
| 140 | 141 |
| 141 bool ShouldAdjustRasterScaleDuringScaleAnimations() const; | 142 bool ShouldAdjustRasterScaleDuringScaleAnimations() const; |
| 142 | 143 |
| 143 void GetDebugBorderProperties(SkColor* color, float* width) const override; | 144 void GetDebugBorderProperties(SkColor* color, float* width) const override; |
| 144 void GetAllTilesForTracing(std::set<const Tile*>* tiles) const override; | 145 void GetAllTilesForTracing(std::set<const Tile*>* tiles) const override; |
| 145 void AsValueInto(base::debug::TracedValue* dict) const override; | 146 void AsValueInto(base::debug::TracedValue* dict) const override; |
| 146 | 147 |
| 147 virtual void UpdateIdealScales(); | 148 virtual void UpdateIdealScales(); |
| 148 float MaximumTilingContentsScale() const; | 149 float MaximumTilingContentsScale() const; |
| 150 scoped_ptr<PictureLayerTilingSet> CreatePictureLayerTilingSet(); |
| 149 | 151 |
| 150 PictureLayerImpl* twin_layer_; | 152 PictureLayerImpl* twin_layer_; |
| 151 | 153 |
| 152 scoped_ptr<PictureLayerTilingSet> tilings_; | 154 scoped_ptr<PictureLayerTilingSet> tilings_; |
| 153 scoped_refptr<RasterSource> raster_source_; | 155 scoped_refptr<RasterSource> raster_source_; |
| 154 Region invalidation_; | 156 Region invalidation_; |
| 155 | 157 |
| 156 float ideal_page_scale_; | 158 float ideal_page_scale_; |
| 157 float ideal_device_scale_; | 159 float ideal_device_scale_; |
| 158 float ideal_source_scale_; | 160 float ideal_source_scale_; |
| 159 float ideal_contents_scale_; | 161 float ideal_contents_scale_; |
| 160 | 162 |
| 161 float raster_page_scale_; | 163 float raster_page_scale_; |
| 162 float raster_device_scale_; | 164 float raster_device_scale_; |
| 163 float raster_source_scale_; | 165 float raster_source_scale_; |
| 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_; |
| 177 |
| 178 bool nearest_neighbor_; |
| 175 | 179 |
| 176 // Any draw properties derived from |transform|, |viewport|, and |clip| | 180 // Any draw properties derived from |transform|, |viewport|, and |clip| |
| 177 // parameters in LayerTreeHostImpl::SetExternalDrawConstraints are not valid | 181 // parameters in LayerTreeHostImpl::SetExternalDrawConstraints are not valid |
| 178 // for prioritizing tiles during resourceless software draws. This is because | 182 // for prioritizing tiles during resourceless software draws. This is because |
| 179 // resourceless software draws can have wildly different transforms/viewports | 183 // resourceless software draws can have wildly different transforms/viewports |
| 180 // from regular draws. Save a copy of the required draw properties of the last | 184 // from regular draws. Save a copy of the required draw properties of the last |
| 181 // frame that has a valid viewport for prioritizing tiles. | 185 // frame that has a valid viewport for prioritizing tiles. |
| 182 gfx::Rect visible_rect_for_tile_priority_; | 186 gfx::Rect visible_rect_for_tile_priority_; |
| 183 | 187 |
| 184 friend class PictureLayer; | 188 friend class PictureLayer; |
| 185 DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); | 189 DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); |
| 186 }; | 190 }; |
| 187 | 191 |
| 188 } // namespace cc | 192 } // namespace cc |
| 189 | 193 |
| 190 #endif // CC_LAYERS_PICTURE_LAYER_IMPL_H_ | 194 #endif // CC_LAYERS_PICTURE_LAYER_IMPL_H_ |
| OLD | NEW |