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" | 18 #include "cc/trees/occlusion_checker.h" |
danakj
2014/09/09 15:14:39
already in the .h
vmpstr
2014/09/09 21:56:56
Done.
| |
19 #include "ui/gfx/point_conversions.h" | 19 #include "ui/gfx/point_conversions.h" |
20 #include "ui/gfx/rect_conversions.h" | 20 #include "ui/gfx/rect_conversions.h" |
21 #include "ui/gfx/safe_integer_conversions.h" | 21 #include "ui/gfx/safe_integer_conversions.h" |
22 #include "ui/gfx/size_conversions.h" | 22 #include "ui/gfx/size_conversions.h" |
23 | 23 |
24 namespace cc { | 24 namespace cc { |
25 namespace { | 25 namespace { |
26 | 26 |
27 const float kSoonBorderDistanceInScreenPixels = 312.f; | 27 const float kSoonBorderDistanceInScreenPixels = 312.f; |
28 | 28 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 // Finally, ensure that visible rect is contained in the skewport. | 525 // Finally, ensure that visible rect is contained in the skewport. |
526 skewport.Union(visible_rect_in_content_space); | 526 skewport.Union(visible_rect_in_content_space); |
527 return skewport; | 527 return skewport; |
528 } | 528 } |
529 | 529 |
530 void PictureLayerTiling::UpdateTilePriorities( | 530 void PictureLayerTiling::UpdateTilePriorities( |
531 WhichTree tree, | 531 WhichTree tree, |
532 const gfx::Rect& visible_layer_rect, | 532 const gfx::Rect& visible_layer_rect, |
533 float ideal_contents_scale, | 533 float ideal_contents_scale, |
534 double current_frame_time_in_seconds, | 534 double current_frame_time_in_seconds, |
535 const OcclusionTracker<LayerImpl>* occlusion_tracker, | 535 const OcclusionChecker<LayerImpl>& occlusion_checker_in_layer_space) { |
536 const LayerImpl* render_target, | |
537 const gfx::Transform& draw_transform) { | |
538 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) { | 536 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) { |
539 // This should never be zero for the purposes of has_ever_been_updated(). | 537 // This should never be zero for the purposes of has_ever_been_updated(). |
540 DCHECK_NE(current_frame_time_in_seconds, 0.0); | 538 DCHECK_NE(current_frame_time_in_seconds, 0.0); |
541 return; | 539 return; |
542 } | 540 } |
543 | 541 |
544 gfx::Rect visible_rect_in_content_space = | 542 gfx::Rect visible_rect_in_content_space = |
545 gfx::ScaleToEnclosingRect(visible_layer_rect, contents_scale_); | 543 gfx::ScaleToEnclosingRect(visible_layer_rect, contents_scale_); |
546 | 544 |
547 if (tiling_size().IsEmpty()) { | 545 if (tiling_size().IsEmpty()) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 ++iter) { | 588 ++iter) { |
591 TileMap::iterator find = tiles_.find(iter.index()); | 589 TileMap::iterator find = tiles_.find(iter.index()); |
592 if (find == tiles_.end()) | 590 if (find == tiles_.end()) |
593 continue; | 591 continue; |
594 has_visible_rect_tiles_ = true; | 592 has_visible_rect_tiles_ = true; |
595 Tile* tile = find->second.get(); | 593 Tile* tile = find->second.get(); |
596 | 594 |
597 tile->SetPriority(tree, now_priority); | 595 tile->SetPriority(tree, now_priority); |
598 | 596 |
599 // Set whether tile is occluded or not. | 597 // Set whether tile is occluded or not. |
600 bool is_occluded = false; | 598 gfx::Rect tile_query_rect = ScaleToEnclosingRect( |
601 if (occlusion_tracker) { | 599 IntersectRects(tile->content_rect(), visible_rect_in_content_space), |
602 gfx::Rect tile_query_rect = ScaleToEnclosingRect( | 600 1.0f / contents_scale_); |
603 IntersectRects(tile->content_rect(), visible_rect_in_content_space), | 601 bool is_occluded = |
604 1.0f / contents_scale_); | 602 occlusion_checker_in_layer_space.Occluded(tile_query_rect); |
605 // TODO(vmpstr): Remove render_target and draw_transform from the | |
606 // parameters so they can be hidden from the tiling. | |
607 is_occluded = occlusion_tracker->Occluded( | |
608 render_target, tile_query_rect, draw_transform); | |
609 } | |
610 tile->set_is_occluded(tree, is_occluded); | 603 tile->set_is_occluded(tree, is_occluded); |
611 } | 604 } |
612 | 605 |
613 // Assign soon priority to skewport tiles. | 606 // Assign soon priority to skewport tiles. |
614 has_skewport_rect_tiles_ = false; | 607 has_skewport_rect_tiles_ = false; |
615 for (TilingData::DifferenceIterator iter( | 608 for (TilingData::DifferenceIterator iter( |
616 &tiling_data_, skewport, visible_rect_in_content_space); | 609 &tiling_data_, skewport, visible_rect_in_content_space); |
617 iter; | 610 iter; |
618 ++iter) { | 611 ++iter) { |
619 TileMap::iterator find = tiles_.find(iter.index()); | 612 TileMap::iterator find = tiles_.find(iter.index()); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1190 DCHECK(*this); | 1183 DCHECK(*this); |
1191 do { | 1184 do { |
1192 ++current_eviction_tiles_index_; | 1185 ++current_eviction_tiles_index_; |
1193 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1186 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
1194 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1187 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
1195 | 1188 |
1196 return *this; | 1189 return *this; |
1197 } | 1190 } |
1198 | 1191 |
1199 } // namespace cc | 1192 } // namespace cc |
OLD | NEW |