Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: cc/resources/picture_layer_tiling.h

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/picture.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_H_ 5 #ifndef CC_RESOURCES_PICTURE_LAYER_TILING_H_
6 #define CC_RESOURCES_PICTURE_LAYER_TILING_H_ 6 #define CC_RESOURCES_PICTURE_LAYER_TILING_H_
7 7
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 virtual bool RequiresHighResToDraw() const = 0; 51 virtual bool RequiresHighResToDraw() const = 0;
52 52
53 protected: 53 protected:
54 virtual ~PictureLayerTilingClient() {} 54 virtual ~PictureLayerTilingClient() {}
55 }; 55 };
56 56
57 class CC_EXPORT PictureLayerTiling { 57 class CC_EXPORT PictureLayerTiling {
58 public: 58 public:
59 static const int kBorderTexels = 1; 59 static const int kBorderTexels = 1;
60 60
61 class CC_EXPORT TilingRasterTileIterator {
62 public:
63 TilingRasterTileIterator();
64 explicit TilingRasterTileIterator(PictureLayerTiling* tiling);
65 ~TilingRasterTileIterator();
66
67 operator bool() const { return !!current_tile_; }
68 const Tile* operator*() const { return current_tile_; }
69 Tile* operator*() { return current_tile_; }
70 TilePriority::PriorityBin get_type() const {
71 switch (phase_) {
72 case VISIBLE_RECT:
73 return TilePriority::NOW;
74 case SKEWPORT_RECT:
75 case SOON_BORDER_RECT:
76 return TilePriority::SOON;
77 case EVENTUALLY_RECT:
78 return TilePriority::EVENTUALLY;
79 }
80 NOTREACHED();
81 return TilePriority::EVENTUALLY;
82 }
83
84 TilingRasterTileIterator& operator++();
85
86 private:
87 enum Phase {
88 VISIBLE_RECT,
89 SKEWPORT_RECT,
90 SOON_BORDER_RECT,
91 EVENTUALLY_RECT
92 };
93
94 void AdvancePhase();
95 bool TileNeedsRaster(Tile* tile) const {
96 return tile->NeedsRaster() && !tiling_->IsTileOccluded(tile);
97 }
98
99 PictureLayerTiling* tiling_;
100
101 Phase phase_;
102
103 Tile* current_tile_;
104 TilingData::Iterator visible_iterator_;
105 TilingData::SpiralDifferenceIterator spiral_iterator_;
106 };
107
108 ~PictureLayerTiling(); 61 ~PictureLayerTiling();
109 62
110 // Create a tiling with no tiles. CreateTile() must be called to add some. 63 // Create a tiling with no tiles. CreateTile() must be called to add some.
111 static scoped_ptr<PictureLayerTiling> Create( 64 static scoped_ptr<PictureLayerTiling> Create(
112 float contents_scale, 65 float contents_scale,
113 scoped_refptr<RasterSource> raster_source, 66 scoped_refptr<RasterSource> raster_source,
114 PictureLayerTilingClient* client, 67 PictureLayerTilingClient* client,
115 size_t max_tiles_for_interest_area, 68 size_t max_tiles_for_interest_area,
116 float skewport_target_time_in_seconds, 69 float skewport_target_time_in_seconds,
117 int skewport_extrapolation_limit_in_content_pixels); 70 int skewport_extrapolation_limit_in_content_pixels);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 128 }
176 129
177 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 130 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
178 return current_visible_rect_; 131 return current_visible_rect_;
179 } 132 }
180 133
181 bool IsTileOccluded(const Tile* tile) const; 134 bool IsTileOccluded(const Tile* tile) const;
182 bool IsTileRequiredForActivationIfVisible(const Tile* tile) const; 135 bool IsTileRequiredForActivationIfVisible(const Tile* tile) const;
183 bool IsTileRequiredForDrawIfVisible(const Tile* tile) const; 136 bool IsTileRequiredForDrawIfVisible(const Tile* tile) const;
184 137
138 void UpdateTileAndTwinPriority(Tile* tile) const;
139 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; }
140 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; }
141 bool has_soon_border_rect_tiles() const {
142 return has_soon_border_rect_tiles_;
143 }
144 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; }
145
146 const gfx::Rect& current_visible_rect() const {
147 return current_visible_rect_;
148 }
149 const gfx::Rect& current_skewport_rect() const {
150 return current_skewport_rect_;
151 }
152 const gfx::Rect& current_soon_border_rect() const {
153 return current_soon_border_rect_;
154 }
155 const gfx::Rect& current_eventually_rect() const {
156 return current_eventually_rect_;
157 }
158
185 // Iterate over all tiles to fill content_rect. Even if tiles are invalid 159 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
186 // (i.e. no valid resource) this tiling should still iterate over them. 160 // (i.e. no valid resource) this tiling should still iterate over them.
187 // The union of all geometry_rect calls for each element iterated over should 161 // The union of all geometry_rect calls for each element iterated over should
188 // exactly equal content_rect and no two geometry_rects should intersect. 162 // exactly equal content_rect and no two geometry_rects should intersect.
189 class CC_EXPORT CoverageIterator { 163 class CC_EXPORT CoverageIterator {
190 public: 164 public:
191 CoverageIterator(); 165 CoverageIterator();
192 CoverageIterator(const PictureLayerTiling* tiling, 166 CoverageIterator(const PictureLayerTiling* tiling,
193 float dest_scale, 167 float dest_scale,
194 const gfx::Rect& rect); 168 const gfx::Rect& rect);
195 ~CoverageIterator(); 169 ~CoverageIterator();
196 170
197 // Visible rect (no borders), always in the space of content_rect, 171 // Visible rect (no borders), always in the space of content_rect,
198 // regardless of the contents scale of the tiling. 172 // regardless of the contents scale of the tiling.
199 gfx::Rect geometry_rect() const; 173 gfx::Rect geometry_rect() const;
200 // Texture rect (in texels) for geometry_rect 174 // Texture rect (in texels) for geometry_rect
201 gfx::RectF texture_rect() const; 175 gfx::RectF texture_rect() const;
202 gfx::Size texture_size() const;
203
204 // Full rect (including borders) of the current tile, always in the space
205 // of content_rect, regardless of the contents scale of the tiling.
206 gfx::Rect full_tile_geometry_rect() const;
207 176
208 Tile* operator->() const { return current_tile_; } 177 Tile* operator->() const { return current_tile_; }
209 Tile* operator*() const { return current_tile_; } 178 Tile* operator*() const { return current_tile_; }
210 179
211 CoverageIterator& operator++(); 180 CoverageIterator& operator++();
212 operator bool() const { return tile_j_ <= bottom_; } 181 operator bool() const { return tile_j_ <= bottom_; }
213 182
214 int i() const { return tile_i_; } 183 int i() const { return tile_i_; }
215 int j() const { return tile_j_; } 184 int j() const { return tile_j_; }
216 185
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 int64 target_area, 226 int64 target_area,
258 const gfx::Rect& bounding_rect, 227 const gfx::Rect& bounding_rect,
259 RectExpansionCache* cache); 228 RectExpansionCache* cache);
260 229
261 bool has_ever_been_updated() const { 230 bool has_ever_been_updated() const {
262 return last_impl_frame_time_in_seconds_ != 0.0; 231 return last_impl_frame_time_in_seconds_ != 0.0;
263 } 232 }
264 233
265 protected: 234 protected:
266 friend class CoverageIterator; 235 friend class CoverageIterator;
267 friend class TilingRasterTileIterator; 236 friend class TilingSetRasterQueue;
268 friend class TilingSetEvictionQueue; 237 friend class TilingSetEvictionQueue;
269 238
270 typedef std::pair<int, int> TileMapKey; 239 typedef std::pair<int, int> TileMapKey;
271 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; 240 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap;
272 241
273 PictureLayerTiling(float contents_scale, 242 PictureLayerTiling(float contents_scale,
274 scoped_refptr<RasterSource> raster_source, 243 scoped_refptr<RasterSource> raster_source,
275 PictureLayerTilingClient* client, 244 PictureLayerTilingClient* client,
276 size_t max_tiles_for_interest_area, 245 size_t max_tiles_for_interest_area,
277 float skewport_target_time_in_seconds, 246 float skewport_target_time_in_seconds,
(...skipping 16 matching lines...) Expand all
294 const; 263 const;
295 264
296 // Save the required data for computing tile priorities later. 265 // Save the required data for computing tile priorities later.
297 void UpdateTilePriorityRects(float content_to_screen_scale_, 266 void UpdateTilePriorityRects(float content_to_screen_scale_,
298 const gfx::Rect& visible_rect_in_content_space, 267 const gfx::Rect& visible_rect_in_content_space,
299 const gfx::Rect& skewport, 268 const gfx::Rect& skewport,
300 const gfx::Rect& soon_border_rect, 269 const gfx::Rect& soon_border_rect,
301 const gfx::Rect& eventually_rect, 270 const gfx::Rect& eventually_rect,
302 const Occlusion& occlusion_in_layer_space); 271 const Occlusion& occlusion_in_layer_space);
303 272
304 void UpdateTileAndTwinPriority(Tile* tile) const; 273 void UpdateTilePriorityForTree(Tile* tile, WhichTree tree) const;
305 void UpdateTilePriority(Tile* tile) const;
306 bool NeedsUpdateForFrameAtTimeAndViewport( 274 bool NeedsUpdateForFrameAtTimeAndViewport(
307 double frame_time_in_seconds, 275 double frame_time_in_seconds,
308 const gfx::Rect& viewport_in_layer_space) { 276 const gfx::Rect& viewport_in_layer_space) {
309 return frame_time_in_seconds != last_impl_frame_time_in_seconds_ || 277 return frame_time_in_seconds != last_impl_frame_time_in_seconds_ ||
310 viewport_in_layer_space != last_viewport_in_layer_space_; 278 viewport_in_layer_space != last_viewport_in_layer_space_;
311 } 279 }
312 280
313 const size_t max_tiles_for_interest_area_; 281 const size_t max_tiles_for_interest_area_;
314 const float skewport_target_time_in_seconds_; 282 const float skewport_target_time_in_seconds_;
315 const int skewport_extrapolation_limit_in_content_pixels_; 283 const int skewport_extrapolation_limit_in_content_pixels_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 316
349 private: 317 private:
350 DISALLOW_ASSIGN(PictureLayerTiling); 318 DISALLOW_ASSIGN(PictureLayerTiling);
351 319
352 RectExpansionCache expansion_cache_; 320 RectExpansionCache expansion_cache_;
353 }; 321 };
354 322
355 } // namespace cc 323 } // namespace cc
356 324
357 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 325 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « cc/resources/picture.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698