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 #include "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 72 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
73 if (iter == tiles_.end()) | 73 if (iter == tiles_.end()) |
74 return NULL; | 74 return NULL; |
75 return iter->second.get(); | 75 return iter->second.get(); |
76 } | 76 } |
77 | 77 |
78 void PictureLayerTiling::CreateTile(int i, int j) { | 78 void PictureLayerTiling::CreateTile(int i, int j) { |
79 TileMapKey key(i, j); | 79 TileMapKey key(i, j); |
80 DCHECK(tiles_.find(key) == tiles_.end()); | 80 DCHECK(tiles_.find(key) == tiles_.end()); |
81 | 81 |
82 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); | 82 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); |
83 gfx::Rect tile_rect = paint_rect; | |
84 tile_rect.set_size(tiling_data_.max_texture_size()); | 83 tile_rect.set_size(tiling_data_.max_texture_size()); |
85 | 84 |
86 // Check our twin for a valid tile. | 85 // Check our twin for a valid tile. |
87 const PictureLayerTiling* twin = client_->GetTwinTiling(this); | 86 const PictureLayerTiling* twin = client_->GetTwinTiling(this); |
88 if (twin && tiling_data_.max_texture_size() == | 87 if (twin && tiling_data_.max_texture_size() == |
89 twin->tiling_data_.max_texture_size()) { | 88 twin->tiling_data_.max_texture_size()) { |
90 Tile* candidate_tile = twin->TileAt(i, j); | 89 Tile* candidate_tile = twin->TileAt(i, j); |
91 if (candidate_tile) { | 90 if (candidate_tile) { |
92 gfx::Rect rect = | 91 gfx::Rect rect = |
93 gfx::ToEnclosingRect(ScaleRect(paint_rect, 1.0f / contents_scale_)); | 92 gfx::ToEnclosingRect(ScaleRect(tile_rect, 1.0f / contents_scale_)); |
94 if (!client_->GetInvalidation()->Intersects(rect)) { | 93 if (!client_->GetInvalidation()->Intersects(rect)) { |
95 tiles_[key] = candidate_tile; | 94 tiles_[key] = candidate_tile; |
96 return; | 95 return; |
97 } | 96 } |
98 } | 97 } |
99 } | 98 } |
100 | 99 |
101 // Create a new tile because our twin didn't have a valid one. | 100 // Create a new tile because our twin didn't have a valid one. |
102 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); | 101 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); |
103 if (tile) | 102 if (tile) |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 const gfx::RectF& visible_layer_rect, | 287 const gfx::RectF& visible_layer_rect, |
289 gfx::Size last_layer_bounds, | 288 gfx::Size last_layer_bounds, |
290 gfx::Size current_layer_bounds, | 289 gfx::Size current_layer_bounds, |
291 float last_layer_contents_scale, | 290 float last_layer_contents_scale, |
292 float current_layer_contents_scale, | 291 float current_layer_contents_scale, |
293 const gfx::Transform& last_screen_transform, | 292 const gfx::Transform& last_screen_transform, |
294 const gfx::Transform& current_screen_transform, | 293 const gfx::Transform& current_screen_transform, |
295 double current_frame_time_in_seconds, | 294 double current_frame_time_in_seconds, |
296 bool store_screen_space_quads_on_tiles, | 295 bool store_screen_space_quads_on_tiles, |
297 size_t max_tiles_for_interest_area) { | 296 size_t max_tiles_for_interest_area) { |
298 if (ContentRect().IsEmpty()) | 297 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) { |
| 298 // This should never be zero for the purposes of has_ever_been_updated(). |
| 299 DCHECK_NE(current_frame_time_in_seconds, 0.0); |
299 return; | 300 return; |
300 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) | 301 } |
| 302 if (ContentRect().IsEmpty()) { |
| 303 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; |
301 return; | 304 return; |
| 305 } |
302 | 306 |
303 gfx::Rect viewport_in_content_space = | 307 gfx::Rect viewport_in_content_space = |
304 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, | 308 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, |
305 contents_scale_)); | 309 contents_scale_)); |
306 gfx::Rect visible_content_rect = | 310 gfx::Rect visible_content_rect = |
307 gfx::ToEnclosingRect(gfx::ScaleRect(visible_layer_rect, | 311 gfx::ToEnclosingRect(gfx::ScaleRect(visible_layer_rect, |
308 contents_scale_)); | 312 contents_scale_)); |
309 | 313 |
310 gfx::Size tile_size = tiling_data_.max_texture_size(); | 314 gfx::Size tile_size = tiling_data_.max_texture_size(); |
311 int64 interest_rect_area = | 315 int64 interest_rect_area = |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 | 606 |
603 // If our delta is less then our event distance, we're done. | 607 // If our delta is less then our event distance, we're done. |
604 if (delta < event.distance) | 608 if (delta < event.distance) |
605 break; | 609 break; |
606 } | 610 } |
607 | 611 |
608 return gfx::Rect(origin_x, origin_y, width, height); | 612 return gfx::Rect(origin_x, origin_y, width, height); |
609 } | 613 } |
610 | 614 |
611 } // namespace cc | 615 } // namespace cc |
OLD | NEW |