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

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

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_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.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 #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>
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 DCHECK_EQ(last_geometry_rect.y(), current_geometry_rect_.y()); 465 DCHECK_EQ(last_geometry_rect.y(), current_geometry_rect_.y());
466 } 466 }
467 467
468 return *this; 468 return *this;
469 } 469 }
470 470
471 gfx::Rect PictureLayerTiling::CoverageIterator::geometry_rect() const { 471 gfx::Rect PictureLayerTiling::CoverageIterator::geometry_rect() const {
472 return current_geometry_rect_; 472 return current_geometry_rect_;
473 } 473 }
474 474
475 gfx::Rect
476 PictureLayerTiling::CoverageIterator::full_tile_geometry_rect() const {
477 gfx::Rect rect = tiling_->tiling_data_.TileBoundsWithBorder(tile_i_, tile_j_);
478 rect.set_size(tiling_->tiling_data_.max_texture_size());
479 return rect;
480 }
481
482 gfx::RectF PictureLayerTiling::CoverageIterator::texture_rect() const { 475 gfx::RectF PictureLayerTiling::CoverageIterator::texture_rect() const {
483 gfx::PointF tex_origin = 476 gfx::PointF tex_origin =
484 tiling_->tiling_data_.TileBoundsWithBorder(tile_i_, tile_j_).origin(); 477 tiling_->tiling_data_.TileBoundsWithBorder(tile_i_, tile_j_).origin();
485 478
486 // Convert from dest space => content space => texture space. 479 // Convert from dest space => content space => texture space.
487 gfx::RectF texture_rect(current_geometry_rect_); 480 gfx::RectF texture_rect(current_geometry_rect_);
488 texture_rect.Scale(dest_to_content_scale_, 481 texture_rect.Scale(dest_to_content_scale_,
489 dest_to_content_scale_); 482 dest_to_content_scale_);
490 texture_rect.Intersect(gfx::Rect(tiling_->tiling_size())); 483 texture_rect.Intersect(gfx::Rect(tiling_->tiling_size()));
491 if (texture_rect.IsEmpty()) 484 if (texture_rect.IsEmpty())
492 return texture_rect; 485 return texture_rect;
493 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); 486 texture_rect.Offset(-tex_origin.OffsetFromOrigin());
494 487
495 return texture_rect; 488 return texture_rect;
496 } 489 }
497 490
498 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const {
499 return tiling_->tiling_data_.max_texture_size();
500 }
501
502 bool PictureLayerTiling::RemoveTileAt(int i, 491 bool PictureLayerTiling::RemoveTileAt(int i,
503 int j, 492 int j,
504 PictureLayerTiling* recycled_twin) { 493 PictureLayerTiling* recycled_twin) {
505 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); 494 TileMap::iterator found = tiles_.find(TileMapKey(i, j));
506 if (found == tiles_.end()) 495 if (found == tiles_.end())
507 return false; 496 return false;
508 found->second->set_shared(false); 497 found->second->set_shared(false);
509 tiles_.erase(found); 498 tiles_.erase(found);
510 if (recycled_twin) { 499 if (recycled_twin) {
511 // Recycled twin does not also have a recycled twin, so pass null. 500 // Recycled twin does not also have a recycled twin, so pass null.
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 if (resolution_ != HIGH_RESOLUTION) 783 if (resolution_ != HIGH_RESOLUTION)
795 return false; 784 return false;
796 785
797 if (IsTileOccluded(tile)) 786 if (IsTileOccluded(tile))
798 return false; 787 return false;
799 788
800 return true; 789 return true;
801 } 790 }
802 791
803 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { 792 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const {
804 UpdateTilePriority(tile); 793 WhichTree tree = client_->GetTree();
794 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE;
795
796 UpdateTilePriorityForTree(tile, tree);
805 797
806 const PictureLayerTiling* twin_tiling = 798 const PictureLayerTiling* twin_tiling =
807 client_->GetPendingOrActiveTwinTiling(this); 799 client_->GetPendingOrActiveTwinTiling(this);
808 if (!tile->is_shared() || !twin_tiling) { 800 if (!tile->is_shared() || !twin_tiling) {
809 WhichTree tree = client_->GetTree();
810 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE;
811 tile->SetPriority(twin_tree, TilePriority()); 801 tile->SetPriority(twin_tree, TilePriority());
812 tile->set_is_occluded(twin_tree, false); 802 tile->set_is_occluded(twin_tree, false);
813 if (twin_tree == PENDING_TREE) 803 if (twin_tree == PENDING_TREE)
814 tile->set_required_for_activation(false); 804 tile->set_required_for_activation(false);
815 else 805 else
816 tile->set_required_for_draw(false); 806 tile->set_required_for_draw(false);
817 return; 807 return;
818 } 808 }
819 809
820 twin_tiling->UpdateTilePriority(tile); 810 twin_tiling->UpdateTilePriorityForTree(tile, twin_tree);
821 } 811 }
822 812
823 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { 813 void PictureLayerTiling::UpdateTilePriorityForTree(Tile* tile,
814 WhichTree tree) const {
824 // TODO(vmpstr): This code should return the priority instead of setting it on 815 // TODO(vmpstr): This code should return the priority instead of setting it on
825 // the tile. This should be a part of the change to move tile priority from 816 // the tile. This should be a part of the change to move tile priority from
826 // tiles into iterators. 817 // tiles into iterators.
827 TilePriority::PriorityBin max_tile_priority_bin = 818 TilePriority::PriorityBin max_tile_priority_bin =
828 client_->GetMaxTilePriorityBin(); 819 client_->GetMaxTilePriorityBin();
829 WhichTree tree = client_->GetTree();
830 820
831 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); 821 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile);
832 gfx::Rect tile_bounds = 822 gfx::Rect tile_bounds =
833 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); 823 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index());
834 824
835 if (max_tile_priority_bin <= TilePriority::NOW && 825 if (max_tile_priority_bin <= TilePriority::NOW &&
836 current_visible_rect_.Intersects(tile_bounds)) { 826 current_visible_rect_.Intersects(tile_bounds)) {
837 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0)); 827 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0));
838 if (tree == PENDING_TREE) { 828 if (tree == PENDING_TREE) {
839 tile->set_required_for_activation( 829 tile->set_required_for_activation(
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 if (delta < event.distance) 1027 if (delta < event.distance)
1038 break; 1028 break;
1039 } 1029 }
1040 1030
1041 gfx::Rect result(origin_x, origin_y, width, height); 1031 gfx::Rect result(origin_x, origin_y, width, height);
1042 if (cache) 1032 if (cache)
1043 cache->previous_result = result; 1033 cache->previous_result = result;
1044 return result; 1034 return result;
1045 } 1035 }
1046 1036
1047 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator()
1048 : tiling_(NULL), current_tile_(NULL) {}
1049
1050 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator(
1051 PictureLayerTiling* tiling)
1052 : tiling_(tiling), phase_(VISIBLE_RECT), current_tile_(NULL) {
1053 if (!tiling_->has_visible_rect_tiles_) {
1054 AdvancePhase();
1055 return;
1056 }
1057
1058 visible_iterator_ = TilingData::Iterator(&tiling_->tiling_data_,
1059 tiling_->current_visible_rect_,
1060 false /* include_borders */);
1061 if (!visible_iterator_) {
1062 AdvancePhase();
1063 return;
1064 }
1065
1066 current_tile_ =
1067 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y());
1068 if (!current_tile_ || !TileNeedsRaster(current_tile_)) {
1069 ++(*this);
1070 return;
1071 }
1072 tiling_->UpdateTileAndTwinPriority(current_tile_);
1073 }
1074
1075 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {}
1076
1077 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() {
1078 DCHECK_LT(phase_, EVENTUALLY_RECT);
1079
1080 do {
1081 phase_ = static_cast<Phase>(phase_ + 1);
1082 switch (phase_) {
1083 case VISIBLE_RECT:
1084 NOTREACHED();
1085 return;
1086 case SKEWPORT_RECT:
1087 if (!tiling_->has_skewport_rect_tiles_)
1088 continue;
1089
1090 spiral_iterator_ = TilingData::SpiralDifferenceIterator(
1091 &tiling_->tiling_data_,
1092 tiling_->current_skewport_rect_,
1093 tiling_->current_visible_rect_,
1094 tiling_->current_visible_rect_);
1095 break;
1096 case SOON_BORDER_RECT:
1097 if (!tiling_->has_soon_border_rect_tiles_)
1098 continue;
1099
1100 spiral_iterator_ = TilingData::SpiralDifferenceIterator(
1101 &tiling_->tiling_data_,
1102 tiling_->current_soon_border_rect_,
1103 tiling_->current_skewport_rect_,
1104 tiling_->current_visible_rect_);
1105 break;
1106 case EVENTUALLY_RECT:
1107 if (!tiling_->has_eventually_rect_tiles_) {
1108 current_tile_ = NULL;
1109 return;
1110 }
1111
1112 spiral_iterator_ = TilingData::SpiralDifferenceIterator(
1113 &tiling_->tiling_data_,
1114 tiling_->current_eventually_rect_,
1115 tiling_->current_skewport_rect_,
1116 tiling_->current_soon_border_rect_);
1117 break;
1118 }
1119
1120 while (spiral_iterator_) {
1121 current_tile_ = tiling_->TileAt(spiral_iterator_.index_x(),
1122 spiral_iterator_.index_y());
1123 if (current_tile_ && TileNeedsRaster(current_tile_))
1124 break;
1125 ++spiral_iterator_;
1126 }
1127
1128 if (!spiral_iterator_ && phase_ == EVENTUALLY_RECT) {
1129 current_tile_ = NULL;
1130 break;
1131 }
1132 } while (!spiral_iterator_);
1133
1134 if (current_tile_)
1135 tiling_->UpdateTileAndTwinPriority(current_tile_);
1136 }
1137
1138 PictureLayerTiling::TilingRasterTileIterator&
1139 PictureLayerTiling::TilingRasterTileIterator::
1140 operator++() {
1141 current_tile_ = NULL;
1142 while (!current_tile_ || !TileNeedsRaster(current_tile_)) {
1143 std::pair<int, int> next_index;
1144 switch (phase_) {
1145 case VISIBLE_RECT:
1146 ++visible_iterator_;
1147 if (!visible_iterator_) {
1148 AdvancePhase();
1149 return *this;
1150 }
1151 next_index = visible_iterator_.index();
1152 break;
1153 case SKEWPORT_RECT:
1154 case SOON_BORDER_RECT:
1155 ++spiral_iterator_;
1156 if (!spiral_iterator_) {
1157 AdvancePhase();
1158 return *this;
1159 }
1160 next_index = spiral_iterator_.index();
1161 break;
1162 case EVENTUALLY_RECT:
1163 ++spiral_iterator_;
1164 if (!spiral_iterator_) {
1165 current_tile_ = NULL;
1166 return *this;
1167 }
1168 next_index = spiral_iterator_.index();
1169 break;
1170 }
1171 current_tile_ = tiling_->TileAt(next_index.first, next_index.second);
1172 }
1173
1174 if (current_tile_)
1175 tiling_->UpdateTileAndTwinPriority(current_tile_);
1176 return *this;
1177 }
1178
1179 } // namespace cc 1037 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698