| 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_RESOURCES_PICTURE_LAYER_TILING_SET_H_ | 5 #ifndef CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ |
| 6 #define CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ | 6 #define CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 LOWER_THAN_LOW_RES | 31 LOWER_THAN_LOW_RES |
| 32 }; | 32 }; |
| 33 struct TilingRange { | 33 struct TilingRange { |
| 34 TilingRange(size_t start, size_t end) : start(start), end(end) {} | 34 TilingRange(size_t start, size_t end) : start(start), end(end) {} |
| 35 | 35 |
| 36 size_t start; | 36 size_t start; |
| 37 size_t end; | 37 size_t end; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 static scoped_ptr<PictureLayerTilingSet> Create( | 40 static scoped_ptr<PictureLayerTilingSet> Create( |
| 41 PictureLayerTilingClient* client); | 41 PictureLayerTilingClient* client, |
| 42 size_t max_tiles_for_interest_area, |
| 43 float skewport_target_time_in_seconds, |
| 44 int skewport_extrapolation_limit_in_content); |
| 42 | 45 |
| 43 ~PictureLayerTilingSet(); | 46 ~PictureLayerTilingSet(); |
| 44 | 47 |
| 45 void SetClient(PictureLayerTilingClient* client); | |
| 46 const PictureLayerTilingClient* client() const { return client_; } | 48 const PictureLayerTilingClient* client() const { return client_; } |
| 47 | 49 |
| 48 void RemoveTilesInRegion(const Region& region); | |
| 49 void CleanUpTilings(float min_acceptable_high_res_scale, | 50 void CleanUpTilings(float min_acceptable_high_res_scale, |
| 50 float max_acceptable_high_res_scale, | 51 float max_acceptable_high_res_scale, |
| 51 const std::vector<PictureLayerTiling*>& needed_tilings, | 52 const std::vector<PictureLayerTiling*>& needed_tilings, |
| 52 bool should_have_low_res, | 53 bool should_have_low_res, |
| 53 PictureLayerTilingSet* twin_set, | 54 PictureLayerTilingSet* twin_set, |
| 54 PictureLayerTilingSet* recycled_twin_set); | 55 PictureLayerTilingSet* recycled_twin_set); |
| 55 | 56 void RemoveNonIdealTilings(); |
| 56 // Make this set of tilings match the same set of content scales from |other|. | 57 // Make this set of tilings match the same set of content scales from |other|. |
| 57 // Delete any tilings that don't meet |minimum_contents_scale|. Recreate | 58 // Delete any tilings that don't meet |minimum_contents_scale|. Recreate |
| 58 // any tiles that intersect |layer_invalidation|. Update the size of all | 59 // any tiles that intersect |layer_invalidation|. Update the size of all |
| 59 // tilings to |new_layer_bounds|. | 60 // tilings to |new_layer_bounds|. |
| 60 // Returns true if we had at least one high res tiling synced. | 61 // Returns true if we had at least one high res tiling synced. |
| 61 bool SyncTilings(const PictureLayerTilingSet& other, | 62 // TODO(danakj): Remove this !!! |
| 62 const gfx::Size& new_layer_bounds, | 63 bool SyncTilingsForTesting(const PictureLayerTilingSet& other, |
| 63 const Region& layer_invalidation, | 64 const gfx::Size& new_layer_bounds, |
| 64 float minimum_contents_scale, | 65 const Region& layer_invalidation, |
| 65 RasterSource* raster_source); | 66 float minimum_contents_scale, |
| 67 RasterSource* raster_source); |
| 68 |
| 69 void UpdateTilingsToCurrentRasterSource( |
| 70 RasterSource* raster_source, |
| 71 const PictureLayerTilingSet* twin_set, |
| 72 // TODO(danakj): Don't need to pass layer bounds here, we have the raster |
| 73 // source already, and they are the same as the raster source size. |
| 74 const gfx::Size& layer_bounds, |
| 75 const Region& layer_invalidation, |
| 76 float minimum_contents_scale); |
| 66 | 77 |
| 67 PictureLayerTiling* AddTiling(float contents_scale, | 78 PictureLayerTiling* AddTiling(float contents_scale, |
| 68 const gfx::Size& layer_bounds); | 79 const gfx::Size& layer_bounds); |
| 69 size_t num_tilings() const { return tilings_.size(); } | 80 size_t num_tilings() const { return tilings_.size(); } |
| 70 int NumHighResTilings() const; | 81 int NumHighResTilings() const; |
| 71 PictureLayerTiling* tiling_at(size_t idx) { return tilings_[idx]; } | 82 PictureLayerTiling* tiling_at(size_t idx) { return tilings_[idx]; } |
| 72 const PictureLayerTiling* tiling_at(size_t idx) const { | 83 const PictureLayerTiling* tiling_at(size_t idx) const { |
| 73 return tilings_[idx]; | 84 return tilings_[idx]; |
| 74 } | 85 } |
| 75 | 86 |
| 76 PictureLayerTiling* FindTilingWithScale(float scale) const; | 87 PictureLayerTiling* FindTilingWithScale(float scale) const; |
| 77 PictureLayerTiling* FindTilingWithResolution(TileResolution resolution) const; | 88 PictureLayerTiling* FindTilingWithResolution(TileResolution resolution) const; |
| 78 | 89 |
| 79 void MarkAllTilingsNonIdeal(); | 90 void MarkAllTilingsNonIdeal(); |
| 80 | 91 |
| 81 // If a tiling exists whose scale is within |snap_to_existing_tiling_ratio| | 92 // If a tiling exists whose scale is within |snap_to_existing_tiling_ratio| |
| 82 // ratio of |start_scale|, then return that tiling's scale. Otherwise, return | 93 // ratio of |start_scale|, then return that tiling's scale. Otherwise, return |
| 83 // |start_scale|. If multiple tilings match the criteria, return the one with | 94 // |start_scale|. If multiple tilings match the criteria, return the one with |
| 84 // the least ratio to |start_scale|. | 95 // the least ratio to |start_scale|. |
| 85 float GetSnappedContentsScale(float start_scale, | 96 float GetSnappedContentsScale(float start_scale, |
| 86 float snap_to_existing_tiling_ratio) const; | 97 float snap_to_existing_tiling_ratio) const; |
| 87 | 98 |
| 88 // Returns the maximum contents scale of all tilings, or 0 if no tilings | 99 // Returns the maximum contents scale of all tilings, or 0 if no tilings |
| 89 // exist. | 100 // exist. |
| 90 float GetMaximumContentsScale() const; | 101 float GetMaximumContentsScale() const; |
| 91 | 102 |
| 103 // Removes all tilings with a contents scale < |minimum_scale|. |
| 104 void RemoveTilingsBelowScale(float minimum_scale); |
| 105 |
| 92 // Remove all tilings. | 106 // Remove all tilings. |
| 93 void RemoveAllTilings(); | 107 void RemoveAllTilings(); |
| 94 | 108 |
| 95 // Remove all tiles; keep all tilings. | 109 // Remove all tiles; keep all tilings. |
| 96 void RemoveAllTiles(); | 110 void RemoveAllTiles(); |
| 97 | 111 |
| 98 // Update the rects and priorities for tiles based on the given information. | 112 // Update the rects and priorities for tiles based on the given information. |
| 99 bool UpdateTilePriorities(const gfx::Rect& required_rect_in_layer_space, | 113 bool UpdateTilePriorities(const gfx::Rect& required_rect_in_layer_space, |
| 100 float ideal_contents_scale, | 114 float ideal_contents_scale, |
| 101 double current_frame_time_in_seconds, | 115 double current_frame_time_in_seconds, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 Region missing_region_; | 162 Region missing_region_; |
| 149 Region::Iterator region_iter_; | 163 Region::Iterator region_iter_; |
| 150 }; | 164 }; |
| 151 | 165 |
| 152 void AsValueInto(base::debug::TracedValue* array) const; | 166 void AsValueInto(base::debug::TracedValue* array) const; |
| 153 size_t GPUMemoryUsageInBytes() const; | 167 size_t GPUMemoryUsageInBytes() const; |
| 154 | 168 |
| 155 TilingRange GetTilingRange(TilingRangeType type) const; | 169 TilingRange GetTilingRange(TilingRangeType type) const; |
| 156 | 170 |
| 157 private: | 171 private: |
| 158 explicit PictureLayerTilingSet(PictureLayerTilingClient* client); | 172 explicit PictureLayerTilingSet( |
| 173 PictureLayerTilingClient* client, |
| 174 size_t max_tiles_for_interest_area, |
| 175 float skewport_target_time_in_seconds, |
| 176 int skewport_extrapolation_limit_in_content_pixels); |
| 159 | 177 |
| 160 // Remove one tiling. | 178 // Remove one tiling. |
| 161 void Remove(PictureLayerTiling* tiling); | 179 void Remove(PictureLayerTiling* tiling); |
| 162 | 180 |
| 181 ScopedPtrVector<PictureLayerTiling> tilings_; |
| 182 |
| 183 const size_t max_tiles_for_interest_area_; |
| 184 const float skewport_target_time_in_seconds_; |
| 185 const int skewport_extrapolation_limit_in_content_pixels_; |
| 163 PictureLayerTilingClient* client_; | 186 PictureLayerTilingClient* client_; |
| 164 ScopedPtrVector<PictureLayerTiling> tilings_; | |
| 165 | 187 |
| 166 friend class Iterator; | 188 friend class Iterator; |
| 167 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingSet); | 189 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingSet); |
| 168 }; | 190 }; |
| 169 | 191 |
| 170 } // namespace cc | 192 } // namespace cc |
| 171 | 193 |
| 172 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ | 194 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ |
| OLD | NEW |