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

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

Issue 2566613002: [4/5] Add translated rasterization support for PictureLayerTilingSet & below (Closed)
Patch Set: still need that rebaseline Created 3 years, 8 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/test/fake_picture_layer_tiling_client.cc ('k') | cc/tiles/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_TILES_PICTURE_LAYER_TILING_H_ 5 #ifndef CC_TILES_PICTURE_LAYER_TILING_H_
6 #define CC_TILES_PICTURE_LAYER_TILING_H_ 6 #define CC_TILES_PICTURE_LAYER_TILING_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <unordered_map> 13 #include <unordered_map>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "cc/base/region.h" 18 #include "cc/base/region.h"
19 #include "cc/base/tiling_data.h" 19 #include "cc/base/tiling_data.h"
20 #include "cc/cc_export.h" 20 #include "cc/cc_export.h"
21 #include "cc/tiles/tile.h" 21 #include "cc/tiles/tile.h"
22 #include "cc/tiles/tile_priority.h" 22 #include "cc/tiles/tile_priority.h"
23 #include "cc/trees/occlusion.h" 23 #include "cc/trees/occlusion.h"
24 #include "ui/gfx/geometry/axis_transform2d.h"
24 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
25 26
26 namespace base { 27 namespace base {
27 namespace trace_event { 28 namespace trace_event {
28 class TracedValue; 29 class TracedValue;
29 } 30 }
30 } 31 }
31 32
32 namespace cc { 33 namespace cc {
33 34
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 uint16_t value2 = static_cast<uint16_t>(key.index_y); 74 uint16_t value2 = static_cast<uint16_t>(key.index_y);
74 uint32_t value1_32 = value1; 75 uint32_t value1_32 = value1;
75 return (value1_32 << 16) | value2; 76 return (value1_32 << 16) | value2;
76 } 77 }
77 }; 78 };
78 79
79 class CC_EXPORT PictureLayerTiling { 80 class CC_EXPORT PictureLayerTiling {
80 public: 81 public:
81 static const int kBorderTexels = 1; 82 static const int kBorderTexels = 1;
82 83
84 // Note on raster_transform: In general raster_transform could be arbitrary,
85 // the only restriction is that the layer bounds after transform should
86 // be positive (because the tiling logic doesn't support negative space).
87 // Also the implementation checks the transformed bounds leaves less than
88 // 1px margin on top left edges, because there is few reason to do so.
83 PictureLayerTiling(WhichTree tree, 89 PictureLayerTiling(WhichTree tree,
84 float raster_scale, 90 const gfx::AxisTransform2d& raster_transform,
85 scoped_refptr<RasterSource> raster_source, 91 scoped_refptr<RasterSource> raster_source,
86 PictureLayerTilingClient* client, 92 PictureLayerTilingClient* client,
87 float min_preraster_distance, 93 float min_preraster_distance,
88 float max_preraster_distance); 94 float max_preraster_distance);
89 ~PictureLayerTiling(); 95 ~PictureLayerTiling();
90 96
91 PictureLayerTilingClient* client() const { return client_; } 97 PictureLayerTilingClient* client() const { return client_; }
92 98
93 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); 99 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source);
94 void Invalidate(const Region& layer_invalidation); 100 void Invalidate(const Region& layer_invalidation);
(...skipping 18 matching lines...) Expand all
113 void set_can_require_tiles_for_activation(bool can_require_tiles) { 119 void set_can_require_tiles_for_activation(bool can_require_tiles) {
114 can_require_tiles_for_activation_ = can_require_tiles; 120 can_require_tiles_for_activation_ = can_require_tiles;
115 } 121 }
116 122
117 const scoped_refptr<RasterSource>& raster_source() const { 123 const scoped_refptr<RasterSource>& raster_source() const {
118 return raster_source_; 124 return raster_source_;
119 } 125 }
120 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } 126 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); }
121 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 127 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
122 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } 128 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); }
123 float contents_scale() const { return contents_scale_; } 129 // PictureLayerTilingSet uses the scale component of the raster transform
130 // as the key for indexing and sorting. In theory we can have multiple
131 // tilings with the same scale but different translation, but currently
132 // we only allow tilings with unique scale for the sake of simplicity.
133 float contents_scale_key() const { return raster_transform_.scale(); }
134 const gfx::AxisTransform2d& raster_transform() const {
135 return raster_transform_;
136 }
124 const TilingData* tiling_data() const { return &tiling_data_; } 137 const TilingData* tiling_data() const { return &tiling_data_; }
125 138
126 Tile* TileAt(int i, int j) const { 139 Tile* TileAt(int i, int j) const {
127 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 140 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
128 return iter == tiles_.end() ? nullptr : iter->second.get(); 141 return iter == tiles_.end() ? nullptr : iter->second.get();
129 } 142 }
130 143
131 bool has_tiles() const { return !tiles_.empty(); } 144 bool has_tiles() const { return !tiles_.empty(); }
132 // all_tiles_done() can return false negatives. 145 // all_tiles_done() can return false negatives.
133 bool all_tiles_done() const { return all_tiles_done_; } 146 bool all_tiles_done() const { return all_tiles_done_; }
(...skipping 28 matching lines...) Expand all
162 for (const auto& key_tile_pair : tiles_) { 175 for (const auto& key_tile_pair : tiles_) {
163 Tile* tile = key_tile_pair.second.get(); 176 Tile* tile = key_tile_pair.second.get();
164 UpdateRequiredStatesOnTile(tile); 177 UpdateRequiredStatesOnTile(tile);
165 } 178 }
166 } 179 }
167 std::map<const Tile*, PrioritizedTile> 180 std::map<const Tile*, PrioritizedTile>
168 UpdateAndGetAllPrioritizedTilesForTesting() const; 181 UpdateAndGetAllPrioritizedTilesForTesting() const;
169 182
170 void SetAllTilesOccludedForTesting() { 183 void SetAllTilesOccludedForTesting() {
171 gfx::Rect viewport_in_layer_space = 184 gfx::Rect viewport_in_layer_space =
172 ScaleToEnclosingRect(current_visible_rect_, 1.f / contents_scale_); 185 EnclosingLayerRectFromContentsRect(current_visible_rect_);
173 current_occlusion_in_layer_space_ = 186 current_occlusion_in_layer_space_ =
174 Occlusion(gfx::Transform(), 187 Occlusion(gfx::Transform(),
175 SimpleEnclosedRegion(viewport_in_layer_space), 188 SimpleEnclosedRegion(viewport_in_layer_space),
176 SimpleEnclosedRegion(viewport_in_layer_space)); 189 SimpleEnclosedRegion(viewport_in_layer_space));
177 } 190 }
178 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 191 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
179 return current_visible_rect_; 192 return current_visible_rect_;
180 } 193 }
181 void SetTilePriorityRectsForTesting( 194 void SetTilePriorityRectsForTesting(
182 const gfx::Rect& visible_rect_in_content_space, 195 const gfx::Rect& visible_rect_in_content_space,
(...skipping 30 matching lines...) Expand all
213 CoverageIterator& operator++(); 226 CoverageIterator& operator++();
214 operator bool() const { return tile_j_ <= bottom_; } 227 operator bool() const { return tile_j_ <= bottom_; }
215 228
216 int i() const { return tile_i_; } 229 int i() const { return tile_i_; }
217 int j() const { return tile_j_; } 230 int j() const { return tile_j_; }
218 231
219 private: 232 private:
220 const PictureLayerTiling* tiling_ = nullptr; 233 const PictureLayerTiling* tiling_ = nullptr;
221 gfx::Size coverage_rect_max_bounds_; 234 gfx::Size coverage_rect_max_bounds_;
222 gfx::Rect coverage_rect_; 235 gfx::Rect coverage_rect_;
223 float coverage_to_content_scale_; 236 gfx::AxisTransform2d coverage_to_content_;
224 237
225 Tile* current_tile_ = nullptr; 238 Tile* current_tile_ = nullptr;
226 gfx::Rect current_geometry_rect_; 239 gfx::Rect current_geometry_rect_;
227 int tile_i_ = 0; 240 int tile_i_ = 0;
228 int tile_j_ = 0; 241 int tile_j_ = 0;
229 int left_ = 0; 242 int left_ = 0;
230 int top_ = 0; 243 int top_ = 0;
231 int right_ = -1; 244 int right_ = -1;
232 int bottom_ = -1; 245 int bottom_ = -1;
233 246
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 return current_skewport_rect_; 336 return current_skewport_rect_;
324 } 337 }
325 const gfx::Rect& current_soon_border_rect() const { 338 const gfx::Rect& current_soon_border_rect() const {
326 return current_soon_border_rect_; 339 return current_soon_border_rect_;
327 } 340 }
328 const gfx::Rect& current_eventually_rect() const { 341 const gfx::Rect& current_eventually_rect() const {
329 return current_eventually_rect_; 342 return current_eventually_rect_;
330 } 343 }
331 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); 344 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles);
332 345
346 gfx::Rect EnclosingContentsRectFromLayerRect(
347 const gfx::Rect& layer_rect) const;
348 gfx::Rect EnclosingLayerRectFromContentsRect(
349 const gfx::Rect& contents_rect) const;
350
333 // Given properties. 351 // Given properties.
334 const float contents_scale_; 352 const gfx::AxisTransform2d raster_transform_;
335 PictureLayerTilingClient* const client_; 353 PictureLayerTilingClient* const client_;
336 const WhichTree tree_; 354 const WhichTree tree_;
337 scoped_refptr<RasterSource> raster_source_; 355 scoped_refptr<RasterSource> raster_source_;
338 const float min_preraster_distance_; 356 const float min_preraster_distance_;
339 const float max_preraster_distance_; 357 const float max_preraster_distance_;
340 TileResolution resolution_ = NON_IDEAL_RESOLUTION; 358 TileResolution resolution_ = NON_IDEAL_RESOLUTION;
341 bool may_contain_low_resolution_tiles_ = false; 359 bool may_contain_low_resolution_tiles_ = false;
342 360
343 // Internal data. 361 // Internal data.
344 TilingData tiling_data_ = TilingData(gfx::Size(), gfx::Size(), kBorderTexels); 362 TilingData tiling_data_ = TilingData(gfx::Size(), gfx::Size(), kBorderTexels);
345 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 363 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
346 gfx::Rect live_tiles_rect_; 364 gfx::Rect live_tiles_rect_;
347 365
348 bool can_require_tiles_for_activation_ = false; 366 bool can_require_tiles_for_activation_ = false;
349 367
350 // Iteration rects in content space. 368 // Iteration rects in content space.
351 gfx::Rect current_visible_rect_; 369 gfx::Rect current_visible_rect_;
352 gfx::Rect current_skewport_rect_; 370 gfx::Rect current_skewport_rect_;
353 gfx::Rect current_soon_border_rect_; 371 gfx::Rect current_soon_border_rect_;
354 gfx::Rect current_eventually_rect_; 372 gfx::Rect current_eventually_rect_;
355 // Other properties used for tile iteration and prioritization. 373 // Other properties used for tile iteration and prioritization.
356 float current_content_to_screen_scale_; 374 float current_content_to_screen_scale_ = 0.f;
357 Occlusion current_occlusion_in_layer_space_; 375 Occlusion current_occlusion_in_layer_space_;
358 float max_skewport_extent_in_screen_space_ = 0.f; 376 float max_skewport_extent_in_screen_space_ = 0.f;
359 377
360 bool has_visible_rect_tiles_ = false; 378 bool has_visible_rect_tiles_ = false;
361 bool has_skewport_rect_tiles_ = false; 379 bool has_skewport_rect_tiles_ = false;
362 bool has_soon_border_rect_tiles_ = false; 380 bool has_soon_border_rect_tiles_ = false;
363 bool has_eventually_rect_tiles_ = false; 381 bool has_eventually_rect_tiles_ = false;
364 bool all_tiles_done_ = true; 382 bool all_tiles_done_ = true;
365 383
366 private: 384 private:
367 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); 385 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling);
368 }; 386 };
369 387
370 } // namespace cc 388 } // namespace cc
371 389
372 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ 390 #endif // CC_TILES_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « cc/test/fake_picture_layer_tiling_client.cc ('k') | cc/tiles/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698