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

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

Issue 664803003: Update from chromium a8e7c94b1b79a0948d05a1fcfff53391d22ce37a (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
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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 476
477 DCHECK(raster_page_scale_); 477 DCHECK(raster_page_scale_);
478 DCHECK(raster_device_scale_); 478 DCHECK(raster_device_scale_);
479 DCHECK(raster_source_scale_); 479 DCHECK(raster_source_scale_);
480 DCHECK(raster_contents_scale_); 480 DCHECK(raster_contents_scale_);
481 DCHECK(low_res_raster_contents_scale_); 481 DCHECK(low_res_raster_contents_scale_);
482 482
483 was_screen_space_transform_animating_ = 483 was_screen_space_transform_animating_ =
484 draw_properties().screen_space_transform_is_animating; 484 draw_properties().screen_space_transform_is_animating;
485 485
486 if (draw_transform_is_animating())
487 pile_->set_likely_to_be_used_for_transform_animation();
488
486 should_update_tile_priorities_ = true; 489 should_update_tile_priorities_ = true;
487 490
488 UpdateTilePriorities(occlusion_in_content_space); 491 UpdateTilePriorities(occlusion_in_content_space);
489 } 492 }
490 493
491 void PictureLayerImpl::UpdateTilePriorities( 494 void PictureLayerImpl::UpdateTilePriorities(
492 const Occlusion& occlusion_in_content_space) { 495 const Occlusion& occlusion_in_content_space) {
493 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings()); 496 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings());
494 497
495 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); 498 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities");
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 if (!synced_high_res_tiling) 786 if (!synced_high_res_tiling)
784 ResetRasterScale(); 787 ResetRasterScale();
785 else 788 else
786 SanityCheckTilingState(); 789 SanityCheckTilingState();
787 } 790 }
788 791
789 void PictureLayerImpl::SyncTiling( 792 void PictureLayerImpl::SyncTiling(
790 const PictureLayerTiling* tiling) { 793 const PictureLayerTiling* tiling) {
791 if (!CanHaveTilingWithScale(tiling->contents_scale())) 794 if (!CanHaveTilingWithScale(tiling->contents_scale()))
792 return; 795 return;
793 tilings_->AddTiling(tiling->contents_scale()); 796 tilings_->AddTiling(tiling->contents_scale(), bounds());
794 797
795 // If this tree needs update draw properties, then the tiling will 798 // If this tree needs update draw properties, then the tiling will
796 // get updated prior to drawing or activation. If this tree does not 799 // get updated prior to drawing or activation. If this tree does not
797 // need update draw properties, then its transforms are up to date and 800 // need update draw properties, then its transforms are up to date and
798 // we can create tiles for this tiling immediately. 801 // we can create tiles for this tiling immediately.
799 if (!layer_tree_impl()->needs_update_draw_properties() && 802 if (!layer_tree_impl()->needs_update_draw_properties() &&
800 should_update_tile_priorities_) { 803 should_update_tile_priorities_) {
801 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking 804 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking
802 // when we stop using the pending tree in the browser compositor. If we want 805 // when we stop using the pending tree in the browser compositor. If we want
803 // to support occlusion tracking here, we need to dirty the draw properties 806 // to support occlusion tracking here, we need to dirty the draw properties
(...skipping 29 matching lines...) Expand all
833 836
834 *resource_id = draw_info.get_resource_id(); 837 *resource_id = draw_info.get_resource_id();
835 *resource_size = iter.texture_size(); 838 *resource_size = iter.texture_size();
836 } 839 }
837 840
838 void PictureLayerImpl::DoPostCommitInitialization() { 841 void PictureLayerImpl::DoPostCommitInitialization() {
839 DCHECK(needs_post_commit_initialization_); 842 DCHECK(needs_post_commit_initialization_);
840 DCHECK(layer_tree_impl()->IsPendingTree()); 843 DCHECK(layer_tree_impl()->IsPendingTree());
841 844
842 if (!tilings_) 845 if (!tilings_)
843 tilings_.reset(new PictureLayerTilingSet(this, bounds())); 846 tilings_ = make_scoped_ptr(new PictureLayerTilingSet(this));
844 847
845 DCHECK(!twin_layer_); 848 DCHECK(!twin_layer_);
846 twin_layer_ = static_cast<PictureLayerImpl*>( 849 twin_layer_ = static_cast<PictureLayerImpl*>(
847 layer_tree_impl()->FindActiveTreeLayerById(id())); 850 layer_tree_impl()->FindActiveTreeLayerById(id()));
848 if (twin_layer_) { 851 if (twin_layer_) {
849 DCHECK(!twin_layer_->twin_layer_); 852 DCHECK(!twin_layer_->twin_layer_);
850 twin_layer_->twin_layer_ = this; 853 twin_layer_->twin_layer_ = this;
851 // If the twin has never been pushed to, do not sync from it. 854 // If the twin has never been pushed to, do not sync from it.
852 // This can happen if this function is called during activation. 855 // This can happen if this function is called during activation.
853 if (!twin_layer_->needs_post_commit_initialization_) 856 if (!twin_layer_->needs_post_commit_initialization_)
854 SyncFromActiveLayer(twin_layer_); 857 SyncFromActiveLayer(twin_layer_);
855 } 858 }
856 859
857 needs_post_commit_initialization_ = false; 860 needs_post_commit_initialization_ = false;
858 } 861 }
859 862
860 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { 863 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
861 DCHECK(CanHaveTilingWithScale(contents_scale)) << 864 DCHECK(CanHaveTilingWithScale(contents_scale)) <<
862 "contents_scale: " << contents_scale; 865 "contents_scale: " << contents_scale;
863 866
864 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); 867 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale, bounds());
865 868
866 DCHECK(pile_->HasRecordings()); 869 DCHECK(pile_->HasRecordings());
867 870
868 if (twin_layer_) 871 if (twin_layer_)
869 twin_layer_->SyncTiling(tiling); 872 twin_layer_->SyncTiling(tiling);
870 873
871 return tiling; 874 return tiling;
872 } 875 }
873 876
874 void PictureLayerImpl::RemoveTiling(float contents_scale) { 877 void PictureLayerImpl::RemoveTiling(float contents_scale) {
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 } 1235 }
1233 if (tilings_->num_tilings() == 0) 1236 if (tilings_->num_tilings() == 0)
1234 return; 1237 return;
1235 1238
1236 // We should only have one high res tiling. 1239 // We should only have one high res tiling.
1237 DCHECK_EQ(1, tilings_->NumHighResTilings()); 1240 DCHECK_EQ(1, tilings_->NumHighResTilings());
1238 #endif 1241 #endif
1239 } 1242 }
1240 1243
1241 bool PictureLayerImpl::ShouldAdjustRasterScaleDuringScaleAnimations() const { 1244 bool PictureLayerImpl::ShouldAdjustRasterScaleDuringScaleAnimations() const {
1242 if (!layer_tree_impl()->use_gpu_rasterization()) 1245 return layer_tree_impl()->use_gpu_rasterization();
1243 return false;
1244
1245 // Re-rastering text at different scales using GPU rasterization causes
1246 // texture uploads for glyphs at each scale (see crbug.com/366225). To
1247 // workaround this performance issue, we don't re-rasterize layers with
1248 // text during scale animations.
1249 // TODO(ajuma): Remove this workaround once text can be efficiently
1250 // re-rastered at different scales (e.g. by using distance-field fonts).
1251 if (pile_->has_text())
1252 return false;
1253
1254 return true;
1255 } 1246 }
1256 1247
1257 float PictureLayerImpl::MaximumTilingContentsScale() const { 1248 float PictureLayerImpl::MaximumTilingContentsScale() const {
1258 float max_contents_scale = MinimumContentsScale(); 1249 float max_contents_scale = MinimumContentsScale();
1259 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 1250 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
1260 const PictureLayerTiling* tiling = tilings_->tiling_at(i); 1251 const PictureLayerTiling* tiling = tilings_->tiling_at(i);
1261 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); 1252 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
1262 } 1253 }
1263 return max_contents_scale; 1254 return max_contents_scale;
1264 } 1255 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 } 1434 }
1444 1435
1445 // Find high and low res tilings and initialize the iterators. 1436 // Find high and low res tilings and initialize the iterators.
1446 for (size_t i = 0; i < layer_->tilings_->num_tilings(); ++i) { 1437 for (size_t i = 0; i < layer_->tilings_->num_tilings(); ++i) {
1447 PictureLayerTiling* tiling = layer_->tilings_->tiling_at(i); 1438 PictureLayerTiling* tiling = layer_->tilings_->tiling_at(i);
1448 if (tiling->resolution() == HIGH_RESOLUTION) { 1439 if (tiling->resolution() == HIGH_RESOLUTION) {
1449 iterators_[HIGH_RES] = 1440 iterators_[HIGH_RES] =
1450 PictureLayerTiling::TilingRasterTileIterator(tiling); 1441 PictureLayerTiling::TilingRasterTileIterator(tiling);
1451 } 1442 }
1452 1443
1453 if (tiling->resolution() == LOW_RESOLUTION) { 1444 if (prioritize_low_res && tiling->resolution() == LOW_RESOLUTION) {
1454 iterators_[LOW_RES] = 1445 iterators_[LOW_RES] =
1455 PictureLayerTiling::TilingRasterTileIterator(tiling); 1446 PictureLayerTiling::TilingRasterTileIterator(tiling);
1456 } 1447 }
1457 } 1448 }
1458 1449
1459 if (prioritize_low_res) { 1450 if (prioritize_low_res) {
1460 stages_[0].iterator_type = LOW_RES; 1451 stages_[0].iterator_type = LOW_RES;
1461 stages_[0].tile_type = TilePriority::NOW; 1452 stages_[0].tile_type = TilePriority::NOW;
1462 1453
1463 stages_[1].iterator_type = HIGH_RES; 1454 stages_[1].iterator_type = HIGH_RES;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1676 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1686 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1677 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1687 return tiling_range.end - 1 - current_tiling_range_offset; 1678 return tiling_range.end - 1 - current_tiling_range_offset;
1688 } 1679 }
1689 } 1680 }
1690 NOTREACHED(); 1681 NOTREACHED();
1691 return 0; 1682 return 0;
1692 } 1683 }
1693 1684
1694 } // namespace cc 1685 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_image_layer_impl_unittest.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698