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 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/debug/trace_event_argument.h" | 13 #include "base/debug/trace_event_argument.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
16 #include "cc/resources/tile.h" | 16 #include "cc/resources/tile.h" |
17 #include "cc/resources/tile_priority.h" | 17 #include "cc/resources/tile_priority.h" |
18 #include "cc/trees/occlusion_tracker.h" | |
19 #include "ui/gfx/point_conversions.h" | 18 #include "ui/gfx/point_conversions.h" |
20 #include "ui/gfx/rect_conversions.h" | 19 #include "ui/gfx/rect_conversions.h" |
21 #include "ui/gfx/safe_integer_conversions.h" | 20 #include "ui/gfx/safe_integer_conversions.h" |
22 #include "ui/gfx/size_conversions.h" | 21 #include "ui/gfx/size_conversions.h" |
23 | 22 |
24 namespace cc { | 23 namespace cc { |
25 namespace { | 24 namespace { |
26 | 25 |
27 const float kSoonBorderDistanceInScreenPixels = 312.f; | 26 const float kSoonBorderDistanceInScreenPixels = 312.f; |
28 | 27 |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // Finally, ensure that visible rect is contained in the skewport. | 532 // Finally, ensure that visible rect is contained in the skewport. |
534 skewport.Union(visible_rect_in_content_space); | 533 skewport.Union(visible_rect_in_content_space); |
535 return skewport; | 534 return skewport; |
536 } | 535 } |
537 | 536 |
538 void PictureLayerTiling::UpdateTilePriorities( | 537 void PictureLayerTiling::UpdateTilePriorities( |
539 WhichTree tree, | 538 WhichTree tree, |
540 const gfx::Rect& visible_layer_rect, | 539 const gfx::Rect& visible_layer_rect, |
541 float ideal_contents_scale, | 540 float ideal_contents_scale, |
542 double current_frame_time_in_seconds, | 541 double current_frame_time_in_seconds, |
543 const OcclusionTracker<LayerImpl>* occlusion_tracker, | 542 const Occlusion& occlusion_in_layer_space) { |
544 const LayerImpl* render_target, | |
545 const gfx::Transform& draw_transform) { | |
546 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) { | 543 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) { |
547 // This should never be zero for the purposes of has_ever_been_updated(). | 544 // This should never be zero for the purposes of has_ever_been_updated(). |
548 DCHECK_NE(current_frame_time_in_seconds, 0.0); | 545 DCHECK_NE(current_frame_time_in_seconds, 0.0); |
549 return; | 546 return; |
550 } | 547 } |
551 | 548 |
552 gfx::Rect visible_rect_in_content_space = | 549 gfx::Rect visible_rect_in_content_space = |
553 gfx::ScaleToEnclosingRect(visible_layer_rect, contents_scale_); | 550 gfx::ScaleToEnclosingRect(visible_layer_rect, contents_scale_); |
554 | 551 |
555 if (tiling_size().IsEmpty()) { | 552 if (tiling_size().IsEmpty()) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 ++iter) { | 595 ++iter) { |
599 TileMap::iterator find = tiles_.find(iter.index()); | 596 TileMap::iterator find = tiles_.find(iter.index()); |
600 if (find == tiles_.end()) | 597 if (find == tiles_.end()) |
601 continue; | 598 continue; |
602 has_visible_rect_tiles_ = true; | 599 has_visible_rect_tiles_ = true; |
603 Tile* tile = find->second.get(); | 600 Tile* tile = find->second.get(); |
604 | 601 |
605 tile->SetPriority(tree, now_priority); | 602 tile->SetPriority(tree, now_priority); |
606 | 603 |
607 // Set whether tile is occluded or not. | 604 // Set whether tile is occluded or not. |
608 bool is_occluded = false; | 605 gfx::Rect tile_query_rect = ScaleToEnclosingRect( |
609 if (occlusion_tracker) { | 606 IntersectRects(tile->content_rect(), visible_rect_in_content_space), |
610 gfx::Rect tile_query_rect = ScaleToEnclosingRect( | 607 1.0f / contents_scale_); |
611 IntersectRects(tile->content_rect(), visible_rect_in_content_space), | 608 bool is_occluded = occlusion_in_layer_space.IsOccluded(tile_query_rect); |
612 1.0f / contents_scale_); | |
613 // TODO(vmpstr): Remove render_target and draw_transform from the | |
614 // parameters so they can be hidden from the tiling. | |
615 is_occluded = occlusion_tracker->Occluded( | |
616 render_target, tile_query_rect, draw_transform); | |
617 } | |
618 tile->set_is_occluded(tree, is_occluded); | 609 tile->set_is_occluded(tree, is_occluded); |
619 } | 610 } |
620 | 611 |
621 // Assign soon priority to skewport tiles. | 612 // Assign soon priority to skewport tiles. |
622 has_skewport_rect_tiles_ = false; | 613 has_skewport_rect_tiles_ = false; |
623 for (TilingData::DifferenceIterator iter( | 614 for (TilingData::DifferenceIterator iter( |
624 &tiling_data_, skewport, visible_rect_in_content_space); | 615 &tiling_data_, skewport, visible_rect_in_content_space); |
625 iter; | 616 iter; |
626 ++iter) { | 617 ++iter) { |
627 TileMap::iterator find = tiles_.find(iter.index()); | 618 TileMap::iterator find = tiles_.find(iter.index()); |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 DCHECK(*this); | 1191 DCHECK(*this); |
1201 do { | 1192 do { |
1202 ++current_eviction_tiles_index_; | 1193 ++current_eviction_tiles_index_; |
1203 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1194 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
1204 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1195 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
1205 | 1196 |
1206 return *this; | 1197 return *this; |
1207 } | 1198 } |
1208 | 1199 |
1209 } // namespace cc | 1200 } // namespace cc |
OLD | NEW |