| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ | |
| 6 #define CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "cc/base/region.h" | |
| 12 #include "cc/base/scoped_ptr_vector.h" | |
| 13 #include "cc/resources/picture_layer_tiling.h" | |
| 14 #include "ui/gfx/geometry/size.h" | |
| 15 | |
| 16 namespace base { | |
| 17 namespace trace_event { | |
| 18 class TracedValue; | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 namespace cc { | |
| 23 | |
| 24 class CC_EXPORT PictureLayerTilingSet { | |
| 25 public: | |
| 26 enum TilingRangeType { | |
| 27 HIGHER_THAN_HIGH_RES, | |
| 28 HIGH_RES, | |
| 29 BETWEEN_HIGH_AND_LOW_RES, | |
| 30 LOW_RES, | |
| 31 LOWER_THAN_LOW_RES | |
| 32 }; | |
| 33 struct TilingRange { | |
| 34 TilingRange(int start, int end) : start(start), end(end) {} | |
| 35 | |
| 36 int start; | |
| 37 int end; | |
| 38 }; | |
| 39 | |
| 40 static scoped_ptr<PictureLayerTilingSet> Create( | |
| 41 WhichTree tree, | |
| 42 PictureLayerTilingClient* client, | |
| 43 float tiling_interest_area_viewport_multiplier, | |
| 44 float skewport_target_time_in_seconds, | |
| 45 int skewport_extrapolation_limit_in_content); | |
| 46 | |
| 47 ~PictureLayerTilingSet(); | |
| 48 | |
| 49 const PictureLayerTilingClient* client() const { return client_; } | |
| 50 | |
| 51 void CleanUpTilings(float min_acceptable_high_res_scale, | |
| 52 float max_acceptable_high_res_scale, | |
| 53 const std::vector<PictureLayerTiling*>& needed_tilings, | |
| 54 bool should_have_low_res, | |
| 55 PictureLayerTilingSet* twin_set, | |
| 56 PictureLayerTilingSet* recycled_twin_set); | |
| 57 void RemoveNonIdealTilings(); | |
| 58 | |
| 59 // This function is called on the active tree during activation. | |
| 60 void UpdateTilingsToCurrentRasterSourceForActivation( | |
| 61 scoped_refptr<RasterSource> raster_source, | |
| 62 const PictureLayerTilingSet* pending_twin_set, | |
| 63 const Region& layer_invalidation, | |
| 64 float minimum_contents_scale, | |
| 65 float maximum_contents_scale); | |
| 66 | |
| 67 // This function is called on the sync tree during commit. | |
| 68 void UpdateTilingsToCurrentRasterSourceForCommit( | |
| 69 scoped_refptr<RasterSource> raster_source, | |
| 70 const Region& layer_invalidation, | |
| 71 float minimum_contents_scale, | |
| 72 float maximum_contents_scale); | |
| 73 | |
| 74 // This function is called on the sync tree right after commit. | |
| 75 void UpdateRasterSourceDueToLCDChange( | |
| 76 const scoped_refptr<RasterSource>& raster_source, | |
| 77 const Region& layer_invalidation); | |
| 78 | |
| 79 PictureLayerTiling* AddTiling(float contents_scale, | |
| 80 scoped_refptr<RasterSource> raster_source); | |
| 81 size_t num_tilings() const { return tilings_.size(); } | |
| 82 int NumHighResTilings() const; | |
| 83 PictureLayerTiling* tiling_at(size_t idx) { return tilings_[idx]; } | |
| 84 const PictureLayerTiling* tiling_at(size_t idx) const { | |
| 85 return tilings_[idx]; | |
| 86 } | |
| 87 WhichTree tree() const { return tree_; } | |
| 88 | |
| 89 PictureLayerTiling* FindTilingWithScale(float scale) const; | |
| 90 PictureLayerTiling* FindTilingWithResolution(TileResolution resolution) const; | |
| 91 | |
| 92 void MarkAllTilingsNonIdeal(); | |
| 93 | |
| 94 // If a tiling exists whose scale is within |snap_to_existing_tiling_ratio| | |
| 95 // ratio of |start_scale|, then return that tiling's scale. Otherwise, return | |
| 96 // |start_scale|. If multiple tilings match the criteria, return the one with | |
| 97 // the least ratio to |start_scale|. | |
| 98 float GetSnappedContentsScale(float start_scale, | |
| 99 float snap_to_existing_tiling_ratio) const; | |
| 100 | |
| 101 // Returns the maximum contents scale of all tilings, or 0 if no tilings | |
| 102 // exist. | |
| 103 float GetMaximumContentsScale() const; | |
| 104 | |
| 105 // Removes all tilings with a contents scale < |minimum_scale|. | |
| 106 void RemoveTilingsBelowScale(float minimum_scale); | |
| 107 | |
| 108 // Removes all tilings with a contents scale > |maximum_scale|. | |
| 109 void RemoveTilingsAboveScale(float maximum_scale); | |
| 110 | |
| 111 // Remove all tilings. | |
| 112 void RemoveAllTilings(); | |
| 113 | |
| 114 // Remove all tiles; keep all tilings. | |
| 115 void RemoveAllTiles(); | |
| 116 | |
| 117 // Update the rects and priorities for tiles based on the given information. | |
| 118 bool UpdateTilePriorities(const gfx::Rect& required_rect_in_layer_space, | |
| 119 float ideal_contents_scale, | |
| 120 double current_frame_time_in_seconds, | |
| 121 const Occlusion& occlusion_in_layer_space, | |
| 122 bool can_require_tiles_for_activation); | |
| 123 | |
| 124 void GetAllPrioritizedTilesForTracing( | |
| 125 std::vector<PrioritizedTile>* prioritized_tiles) const; | |
| 126 | |
| 127 // For a given rect, iterates through tiles that can fill it. If no | |
| 128 // set of tiles with resources can fill the rect, then it will iterate | |
| 129 // through null tiles with valid geometry_rect() until the rect is full. | |
| 130 // If all tiles have resources, the union of all geometry_rects will | |
| 131 // exactly fill rect with no overlap. | |
| 132 class CC_EXPORT CoverageIterator { | |
| 133 public: | |
| 134 CoverageIterator(const PictureLayerTilingSet* set, | |
| 135 float contents_scale, | |
| 136 const gfx::Rect& content_rect, | |
| 137 float ideal_contents_scale); | |
| 138 ~CoverageIterator(); | |
| 139 | |
| 140 // Visible rect (no borders), always in the space of rect, | |
| 141 // regardless of the relative contents scale of the tiling. | |
| 142 gfx::Rect geometry_rect() const; | |
| 143 // Texture rect (in texels) for geometry_rect | |
| 144 gfx::RectF texture_rect() const; | |
| 145 | |
| 146 Tile* operator->() const; | |
| 147 Tile* operator*() const; | |
| 148 | |
| 149 CoverageIterator& operator++(); | |
| 150 operator bool() const; | |
| 151 | |
| 152 TileResolution resolution() const; | |
| 153 PictureLayerTiling* CurrentTiling() const; | |
| 154 | |
| 155 private: | |
| 156 int NextTiling() const; | |
| 157 | |
| 158 const PictureLayerTilingSet* set_; | |
| 159 float contents_scale_; | |
| 160 float ideal_contents_scale_; | |
| 161 PictureLayerTiling::CoverageIterator tiling_iter_; | |
| 162 int current_tiling_; | |
| 163 int ideal_tiling_; | |
| 164 | |
| 165 Region current_region_; | |
| 166 Region missing_region_; | |
| 167 Region::Iterator region_iter_; | |
| 168 }; | |
| 169 | |
| 170 void AsValueInto(base::trace_event::TracedValue* array) const; | |
| 171 size_t GPUMemoryUsageInBytes() const; | |
| 172 | |
| 173 TilingRange GetTilingRange(TilingRangeType type) const; | |
| 174 | |
| 175 private: | |
| 176 explicit PictureLayerTilingSet( | |
| 177 WhichTree tree, | |
| 178 PictureLayerTilingClient* client, | |
| 179 float tiling_interest_area_viewport_multiplier, | |
| 180 float skewport_target_time_in_seconds, | |
| 181 int skewport_extrapolation_limit_in_content_pixels); | |
| 182 | |
| 183 void CopyTilingsAndPropertiesFromPendingTwin( | |
| 184 const PictureLayerTilingSet* pending_twin_set, | |
| 185 const scoped_refptr<RasterSource>& raster_source, | |
| 186 const Region& layer_invalidation); | |
| 187 | |
| 188 // Remove one tiling. | |
| 189 void Remove(PictureLayerTiling* tiling); | |
| 190 void VerifyTilings(const PictureLayerTilingSet* pending_twin_set) const; | |
| 191 | |
| 192 ScopedPtrVector<PictureLayerTiling> tilings_; | |
| 193 | |
| 194 const float tiling_interest_area_viewport_multiplier_; | |
| 195 const float skewport_target_time_in_seconds_; | |
| 196 const int skewport_extrapolation_limit_in_content_pixels_; | |
| 197 WhichTree tree_; | |
| 198 PictureLayerTilingClient* client_; | |
| 199 | |
| 200 friend class Iterator; | |
| 201 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingSet); | |
| 202 }; | |
| 203 | |
| 204 } // namespace cc | |
| 205 | |
| 206 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_SET_H_ | |
| OLD | NEW |