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

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/layers/picture_layer.cc ('k') | cc/layers/picture_layer_impl_unittest.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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (could_have_tilings != CanHaveTilings()) { 166 if (could_have_tilings != CanHaveTilings()) {
167 layer_tree_impl()->set_needs_update_draw_properties(); 167 layer_tree_impl()->set_needs_update_draw_properties();
168 } 168 }
169 } 169 }
170 170
171 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, 171 void PictureLayerImpl::AppendQuads(RenderPass* render_pass,
172 const Occlusion& occlusion_in_content_space, 172 const Occlusion& occlusion_in_content_space,
173 AppendQuadsData* append_quads_data) { 173 AppendQuadsData* append_quads_data) {
174 DCHECK(!needs_post_commit_initialization_); 174 DCHECK(!needs_post_commit_initialization_);
175 // The bounds and the pile size may differ if the pile wasn't updated (ie. 175 // The bounds and the pile size may differ if the pile wasn't updated (ie.
176 // PictureLayer::Update didn't happen). But that should never be the case if 176 // PictureLayer::Update didn't happen). In that case the pile will be empty.
177 // the layer is part of the visible frame, which is why we're appending quads 177 DCHECK_IMPLIES(!pile_->tiling_size().IsEmpty(),
178 // in the first place 178 bounds() == pile_->tiling_size())
179 DCHECK_EQ(bounds().ToString(), pile_->tiling_size().ToString()); 179 << " bounds " << bounds().ToString() << " pile "
180 << pile_->tiling_size().ToString();
180 181
181 SharedQuadState* shared_quad_state = 182 SharedQuadState* shared_quad_state =
182 render_pass->CreateAndAppendSharedQuadState(); 183 render_pass->CreateAndAppendSharedQuadState();
183 184
184 if (pile_->is_solid_color()) { 185 if (pile_->is_solid_color()) {
185 PopulateSharedQuadState(shared_quad_state); 186 PopulateSharedQuadState(shared_quad_state);
186 187
187 AppendDebugBorderQuad( 188 AppendDebugBorderQuad(
188 render_pass, bounds(), shared_quad_state, append_quads_data); 189 render_pass, bounds(), shared_quad_state, append_quads_data);
189 190
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 462
462 // Aggressively remove any tilings that are not seen to save memory. Note 463 // Aggressively remove any tilings that are not seen to save memory. Note
463 // that this is at the expense of doing cause more frequent re-painting. A 464 // that this is at the expense of doing cause more frequent re-painting. A
464 // better scheme would be to maintain a tighter visible_content_rect for the 465 // better scheme would be to maintain a tighter visible_content_rect for the
465 // finer tilings. 466 // finer tilings.
466 CleanUpTilingsOnActiveLayer(seen_tilings); 467 CleanUpTilingsOnActiveLayer(seen_tilings);
467 } 468 }
468 469
469 void PictureLayerImpl::UpdateTiles(const Occlusion& occlusion_in_content_space, 470 void PictureLayerImpl::UpdateTiles(const Occlusion& occlusion_in_content_space,
470 bool resourceless_software_draw) { 471 bool resourceless_software_draw) {
471 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles");
472 DCHECK_EQ(1.f, contents_scale_x()); 472 DCHECK_EQ(1.f, contents_scale_x());
473 DCHECK_EQ(1.f, contents_scale_y()); 473 DCHECK_EQ(1.f, contents_scale_y());
474 474
475 DoPostCommitInitializationIfNeeded(); 475 DoPostCommitInitializationIfNeeded();
476 476
477 if (!resourceless_software_draw) { 477 if (!resourceless_software_draw) {
478 visible_rect_for_tile_priority_ = visible_content_rect(); 478 visible_rect_for_tile_priority_ = visible_content_rect();
479 } 479 }
480 480
481 if (!CanHaveTilings()) { 481 if (!CanHaveTilings()) {
(...skipping 27 matching lines...) Expand all
509 pile_->set_likely_to_be_used_for_transform_animation(); 509 pile_->set_likely_to_be_used_for_transform_animation();
510 510
511 should_update_tile_priorities_ = true; 511 should_update_tile_priorities_ = true;
512 512
513 UpdateTilePriorities(occlusion_in_content_space); 513 UpdateTilePriorities(occlusion_in_content_space);
514 } 514 }
515 515
516 void PictureLayerImpl::UpdateTilePriorities( 516 void PictureLayerImpl::UpdateTilePriorities(
517 const Occlusion& occlusion_in_content_space) { 517 const Occlusion& occlusion_in_content_space) {
518 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings()); 518 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings());
519
520 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities");
521
522 double current_frame_time_in_seconds = 519 double current_frame_time_in_seconds =
523 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - 520 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time -
524 base::TimeTicks()).InSecondsF(); 521 base::TimeTicks()).InSecondsF();
525 522
526 gfx::Rect viewport_rect_in_layer_space = 523 gfx::Rect viewport_rect_in_layer_space =
527 GetViewportForTilePriorityInContentSpace(); 524 GetViewportForTilePriorityInContentSpace();
528 bool tiling_needs_update = false; 525 bool tiling_needs_update = false;
529 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 526 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
530 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTimeAndViewport( 527 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTimeAndViewport(
531 current_frame_time_in_seconds, viewport_rect_in_layer_space)) { 528 current_frame_time_in_seconds, viewport_rect_in_layer_space)) {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 tile_height = std::min(tile_height, default_tile_height); 780 tile_height = std::min(tile_height, default_tile_height);
784 } 781 }
785 782
786 // Under no circumstance should we be larger than the max texture size. 783 // Under no circumstance should we be larger than the max texture size.
787 tile_width = std::min(tile_width, max_texture_size); 784 tile_width = std::min(tile_width, max_texture_size);
788 tile_height = std::min(tile_height, max_texture_size); 785 tile_height = std::min(tile_height, max_texture_size);
789 return gfx::Size(tile_width, tile_height); 786 return gfx::Size(tile_width, tile_height);
790 } 787 }
791 788
792 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { 789 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
793 TRACE_EVENT0("cc", "SyncFromActiveLayer");
794 DCHECK(!other->needs_post_commit_initialization_); 790 DCHECK(!other->needs_post_commit_initialization_);
795 DCHECK(other->tilings_); 791 DCHECK(other->tilings_);
796 792
797 if (!DrawsContent()) { 793 if (!DrawsContent()) {
798 RemoveAllTilings(); 794 RemoveAllTilings();
799 return; 795 return;
800 } 796 }
801 797
802 raster_page_scale_ = other->raster_page_scale_; 798 raster_page_scale_ = other->raster_page_scale_;
803 raster_device_scale_ = other->raster_device_scale_; 799 raster_device_scale_ = other->raster_device_scale_;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio. 1076 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio.
1081 bool zooming_out = old_raster_page_scale > ideal_page_scale_; 1077 bool zooming_out = old_raster_page_scale > ideal_page_scale_;
1082 float desired_contents_scale = 1078 float desired_contents_scale =
1083 zooming_out ? old_raster_contents_scale / kMaxScaleRatioDuringPinch 1079 zooming_out ? old_raster_contents_scale / kMaxScaleRatioDuringPinch
1084 : old_raster_contents_scale * kMaxScaleRatioDuringPinch; 1080 : old_raster_contents_scale * kMaxScaleRatioDuringPinch;
1085 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); 1081 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale);
1086 raster_page_scale_ = 1082 raster_page_scale_ =
1087 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; 1083 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_;
1088 } 1084 }
1089 1085
1090 raster_contents_scale_ =
1091 std::max(raster_contents_scale_, MinimumContentsScale());
1092
1093 // If we're not re-rasterizing during animation, rasterize at the maximum 1086 // If we're not re-rasterizing during animation, rasterize at the maximum
1094 // scale that will occur during the animation, if the maximum scale is 1087 // scale that will occur during the animation, if the maximum scale is
1095 // known. However we want to avoid excessive memory use. If the scale is 1088 // known. However we want to avoid excessive memory use. If the scale is
1096 // smaller than what we would choose otherwise, then it's always better off 1089 // smaller than what we would choose otherwise, then it's always better off
1097 // for us memory-wise. But otherwise, we don't choose a scale at which this 1090 // for us memory-wise. But otherwise, we don't choose a scale at which this
1098 // layer's rastered content would become larger than the viewport. 1091 // layer's rastered content would become larger than the viewport.
1099 if (draw_properties().screen_space_transform_is_animating && 1092 if (draw_properties().screen_space_transform_is_animating &&
1100 !ShouldAdjustRasterScaleDuringScaleAnimations()) { 1093 !ShouldAdjustRasterScaleDuringScaleAnimations()) {
1101 bool can_raster_at_maximum_scale = false; 1094 bool can_raster_at_maximum_scale = false;
1102 // TODO(ajuma): If we need to deal with scale-down animations starting right 1095 // TODO(ajuma): If we need to deal with scale-down animations starting right
(...skipping 11 matching lines...) Expand all
1114 } 1107 }
1115 // Use the computed scales for the raster scale directly, do not try to use 1108 // Use the computed scales for the raster scale directly, do not try to use
1116 // the ideal scale here. The current ideal scale may be way too large in the 1109 // the ideal scale here. The current ideal scale may be way too large in the
1117 // case of an animation with scale, and will be constantly changing. 1110 // case of an animation with scale, and will be constantly changing.
1118 if (can_raster_at_maximum_scale) 1111 if (can_raster_at_maximum_scale)
1119 raster_contents_scale_ = maximum_scale; 1112 raster_contents_scale_ = maximum_scale;
1120 else 1113 else
1121 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; 1114 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_;
1122 } 1115 }
1123 1116
1117 raster_contents_scale_ =
1118 std::max(raster_contents_scale_, MinimumContentsScale());
1119
1124 // If this layer would create zero or one tiles at this content scale, 1120 // If this layer would create zero or one tiles at this content scale,
1125 // don't create a low res tiling. 1121 // don't create a low res tiling.
1126 gfx::Size raster_bounds = gfx::ToCeiledSize( 1122 gfx::Size raster_bounds = gfx::ToCeiledSize(
1127 gfx::ScaleSize(pile_->tiling_size(), raster_contents_scale_)); 1123 gfx::ScaleSize(pile_->tiling_size(), raster_contents_scale_));
1128 gfx::Size tile_size = CalculateTileSize(raster_bounds); 1124 gfx::Size tile_size = CalculateTileSize(raster_bounds);
1129 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() && 1125 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() &&
1130 tile_size.height() >= raster_bounds.height(); 1126 tile_size.height() >= raster_bounds.height();
1131 if (tile_size.IsEmpty() || tile_covers_bounds) { 1127 if (tile_size.IsEmpty() || tile_covers_bounds) {
1132 low_res_raster_contents_scale_ = raster_contents_scale_; 1128 low_res_raster_contents_scale_ = raster_contents_scale_;
1133 return; 1129 return;
1134 } 1130 }
1135 1131
1136 float low_res_factor = 1132 float low_res_factor =
1137 layer_tree_impl()->settings().low_res_contents_scale_factor; 1133 layer_tree_impl()->settings().low_res_contents_scale_factor;
1138 low_res_raster_contents_scale_ = std::max( 1134 low_res_raster_contents_scale_ = std::max(
1139 raster_contents_scale_ * low_res_factor, 1135 raster_contents_scale_ * low_res_factor,
1140 MinimumContentsScale()); 1136 MinimumContentsScale());
1137 DCHECK_LE(low_res_raster_contents_scale_, raster_contents_scale_);
1138 DCHECK_GE(low_res_raster_contents_scale_, MinimumContentsScale());
1141 } 1139 }
1142 1140
1143 void PictureLayerImpl::CleanUpTilingsOnActiveLayer( 1141 void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
1144 std::vector<PictureLayerTiling*> used_tilings) { 1142 std::vector<PictureLayerTiling*> used_tilings) {
1145 DCHECK(layer_tree_impl()->IsActiveTree()); 1143 DCHECK(layer_tree_impl()->IsActiveTree());
1146 if (tilings_->num_tilings() == 0) 1144 if (tilings_->num_tilings() == 0)
1147 return; 1145 return;
1148 1146
1149 float min_acceptable_high_res_scale = std::min( 1147 float min_acceptable_high_res_scale = std::min(
1150 raster_contents_scale_, ideal_contents_scale_); 1148 raster_contents_scale_, ideal_contents_scale_);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 1397
1400 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1398 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1401 return !layer_tree_impl()->IsRecycleTree(); 1399 return !layer_tree_impl()->IsRecycleTree();
1402 } 1400 }
1403 1401
1404 bool PictureLayerImpl::HasValidTilePriorities() const { 1402 bool PictureLayerImpl::HasValidTilePriorities() const {
1405 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); 1403 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember();
1406 } 1404 }
1407 1405
1408 bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { 1406 bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const {
1409 TRACE_EVENT0("cc",
1410 "PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw");
1411 if (!layer_tree_impl()->IsPendingTree()) 1407 if (!layer_tree_impl()->IsPendingTree())
1412 return true; 1408 return true;
1413 1409
1414 if (!HasValidTilePriorities()) 1410 if (!HasValidTilePriorities())
1415 return true; 1411 return true;
1416 1412
1417 if (!tilings_) 1413 if (!tilings_)
1418 return true; 1414 return true;
1419 1415
1420 if (visible_rect_for_tile_priority_.IsEmpty()) 1416 if (visible_rect_for_tile_priority_.IsEmpty())
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1718 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1723 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1719 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1724 return tiling_range.end - 1 - current_tiling_range_offset; 1720 return tiling_range.end - 1 - current_tiling_range_offset;
1725 } 1721 }
1726 } 1722 }
1727 NOTREACHED(); 1723 NOTREACHED();
1728 return 0; 1724 return 0;
1729 } 1725 }
1730 1726
1731 } // namespace cc 1727 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698