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

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

Issue 1839143004: Limit image filtering during scale animations Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/layers/picture_layer_impl.h ('k') | cc/playback/display_list_raster_source.h » ('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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 tilings_(CreatePictureLayerTilingSet()), 67 tilings_(CreatePictureLayerTilingSet()),
68 ideal_page_scale_(0.f), 68 ideal_page_scale_(0.f),
69 ideal_device_scale_(0.f), 69 ideal_device_scale_(0.f),
70 ideal_source_scale_(0.f), 70 ideal_source_scale_(0.f),
71 ideal_contents_scale_(0.f), 71 ideal_contents_scale_(0.f),
72 raster_page_scale_(0.f), 72 raster_page_scale_(0.f),
73 raster_device_scale_(0.f), 73 raster_device_scale_(0.f),
74 raster_source_scale_(0.f), 74 raster_source_scale_(0.f),
75 raster_contents_scale_(0.f), 75 raster_contents_scale_(0.f),
76 low_res_raster_contents_scale_(0.f), 76 low_res_raster_contents_scale_(0.f),
77 source_scale_has_changed_(false),
77 was_screen_space_transform_animating_(false), 78 was_screen_space_transform_animating_(false),
78 only_used_low_res_last_append_quads_(false), 79 only_used_low_res_last_append_quads_(false),
79 is_mask_(is_mask), 80 is_mask_(is_mask),
80 nearest_neighbor_(false) { 81 nearest_neighbor_(false) {
81 layer_tree_impl()->RegisterPictureLayerImpl(this); 82 layer_tree_impl()->RegisterPictureLayerImpl(this);
82 } 83 }
83 84
84 PictureLayerImpl::~PictureLayerImpl() { 85 PictureLayerImpl::~PictureLayerImpl() {
85 if (twin_layer_) 86 if (twin_layer_)
86 twin_layer_->twin_layer_ = nullptr; 87 twin_layer_->twin_layer_ = nullptr;
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 539
539 // The |raster_source_| is initially null, so have to check for that for the 540 // The |raster_source_| is initially null, so have to check for that for the
540 // first frame. 541 // first frame.
541 bool could_have_tilings = raster_source_.get() && CanHaveTilings(); 542 bool could_have_tilings = raster_source_.get() && CanHaveTilings();
542 raster_source_.swap(raster_source); 543 raster_source_.swap(raster_source);
543 544
544 // Only set the image decode controller when we're committing. 545 // Only set the image decode controller when we're committing.
545 if (!pending_set) { 546 if (!pending_set) {
546 raster_source_->SetImageDecodeController( 547 raster_source_->SetImageDecodeController(
547 layer_tree_impl()->image_decode_controller()); 548 layer_tree_impl()->image_decode_controller());
549 raster_source_->SetImageScalingOptimization(
550 source_scale_has_changed_
551 ? DisplayListRasterSource::ImageScalingOptimization::Animation
552 : DisplayListRasterSource::ImageScalingOptimization::Static);
548 } 553 }
549 554
550 // The |new_invalidation| must be cleared before updating tilings since they 555 // The |new_invalidation| must be cleared before updating tilings since they
551 // access the invalidation through the PictureLayerTilingClient interface. 556 // access the invalidation through the PictureLayerTilingClient interface.
552 invalidation_.Clear(); 557 invalidation_.Clear();
553 invalidation_.Swap(new_invalidation); 558 invalidation_.Swap(new_invalidation);
554 559
555 bool can_have_tilings = CanHaveTilings(); 560 bool can_have_tilings = CanHaveTilings();
556 DCHECK(!pending_set || 561 DCHECK(!pending_set ||
557 can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings()); 562 can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings());
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 if (!is_pinching && !is_animating) { 944 if (!is_pinching && !is_animating) {
940 if (!low_res) 945 if (!low_res)
941 low_res = AddTiling(low_res_raster_contents_scale_); 946 low_res = AddTiling(low_res_raster_contents_scale_);
942 low_res->set_resolution(LOW_RESOLUTION); 947 low_res->set_resolution(LOW_RESOLUTION);
943 } 948 }
944 } 949 }
945 950
946 void PictureLayerImpl::RecalculateRasterScales() { 951 void PictureLayerImpl::RecalculateRasterScales() {
947 const float old_raster_contents_scale = raster_contents_scale_; 952 const float old_raster_contents_scale = raster_contents_scale_;
948 const float old_raster_page_scale = raster_page_scale_; 953 const float old_raster_page_scale = raster_page_scale_;
954 const float old_raster_source_scale = raster_source_scale_;
949 955
950 raster_device_scale_ = ideal_device_scale_; 956 raster_device_scale_ = ideal_device_scale_;
951 raster_page_scale_ = ideal_page_scale_; 957 raster_page_scale_ = ideal_page_scale_;
952 raster_source_scale_ = ideal_source_scale_; 958 raster_source_scale_ = ideal_source_scale_;
953 raster_contents_scale_ = ideal_contents_scale_; 959 raster_contents_scale_ = ideal_contents_scale_;
954 960
961 // If we're not animating, or leaving an animation, and the
962 // ideal_source_scale_ changes, then things are unpredictable, and we
963 // may need to tweak some source rasterization params.
964 // TODO(fmalita): this should be generalized for screen transform changes.
965 if (old_raster_source_scale &&
966 !draw_properties().screen_space_transform_is_animating &&
967 !was_screen_space_transform_animating_ &&
968 old_raster_source_scale != ideal_source_scale_)
969 source_scale_has_changed_ = true;
970
955 // During pinch we completely ignore the current ideal scale, and just use 971 // During pinch we completely ignore the current ideal scale, and just use
956 // a multiple of the previous scale. 972 // a multiple of the previous scale.
957 bool is_pinching = layer_tree_impl()->PinchGestureActive(); 973 bool is_pinching = layer_tree_impl()->PinchGestureActive();
958 if (is_pinching && old_raster_contents_scale) { 974 if (is_pinching && old_raster_contents_scale) {
959 // See ShouldAdjustRasterScale: 975 // See ShouldAdjustRasterScale:
960 // - When zooming out, preemptively create new tiling at lower resolution. 976 // - When zooming out, preemptively create new tiling at lower resolution.
961 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio. 977 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio.
962 bool zooming_out = old_raster_page_scale > ideal_page_scale_; 978 bool zooming_out = old_raster_page_scale > ideal_page_scale_;
963 float desired_contents_scale = old_raster_contents_scale; 979 float desired_contents_scale = old_raster_contents_scale;
964 if (zooming_out) { 980 if (zooming_out) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 // up larger than |max_texture_size|. 1131 // up larger than |max_texture_size|.
1116 return nextafterf(max_scale, 0.f); 1132 return nextafterf(max_scale, 0.f);
1117 } 1133 }
1118 1134
1119 void PictureLayerImpl::ResetRasterScale() { 1135 void PictureLayerImpl::ResetRasterScale() {
1120 raster_page_scale_ = 0.f; 1136 raster_page_scale_ = 0.f;
1121 raster_device_scale_ = 0.f; 1137 raster_device_scale_ = 0.f;
1122 raster_source_scale_ = 0.f; 1138 raster_source_scale_ = 0.f;
1123 raster_contents_scale_ = 0.f; 1139 raster_contents_scale_ = 0.f;
1124 low_res_raster_contents_scale_ = 0.f; 1140 low_res_raster_contents_scale_ = 0.f;
1141 source_scale_has_changed_ = false;
1125 } 1142 }
1126 1143
1127 bool PictureLayerImpl::CanHaveTilings() const { 1144 bool PictureLayerImpl::CanHaveTilings() const {
1128 if (raster_source_->IsSolidColor()) 1145 if (raster_source_->IsSolidColor())
1129 return false; 1146 return false;
1130 if (!DrawsContent()) 1147 if (!DrawsContent())
1131 return false; 1148 return false;
1132 if (!raster_source_->HasRecordings()) 1149 if (!raster_source_->HasRecordings())
1133 return false; 1150 return false;
1134 // If the |raster_source_| has a recording it should have non-empty bounds. 1151 // If the |raster_source_| has a recording it should have non-empty bounds.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 return; 1217 return;
1201 tilings_->GetAllPrioritizedTilesForTracing(prioritized_tiles); 1218 tilings_->GetAllPrioritizedTilesForTracing(prioritized_tiles);
1202 } 1219 }
1203 1220
1204 void PictureLayerImpl::AsValueInto( 1221 void PictureLayerImpl::AsValueInto(
1205 base::trace_event::TracedValue* state) const { 1222 base::trace_event::TracedValue* state) const {
1206 LayerImpl::AsValueInto(state); 1223 LayerImpl::AsValueInto(state);
1207 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 1224 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
1208 state->SetDouble("raster_contents_scale", raster_contents_scale_); 1225 state->SetDouble("raster_contents_scale", raster_contents_scale_);
1209 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); 1226 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale());
1227 state->SetBoolean("source_scale_changed", source_scale_has_changed_);
1210 state->BeginArray("tilings"); 1228 state->BeginArray("tilings");
1211 tilings_->AsValueInto(state); 1229 tilings_->AsValueInto(state);
1212 state->EndArray(); 1230 state->EndArray();
1213 1231
1214 MathUtil::AddToTracedValue("tile_priority_rect", 1232 MathUtil::AddToTracedValue("tile_priority_rect",
1215 viewport_rect_for_tile_priority_in_content_space_, 1233 viewport_rect_for_tile_priority_in_content_space_,
1216 state); 1234 state);
1217 MathUtil::AddToTracedValue("visible_rect", visible_layer_rect(), state); 1235 MathUtil::AddToTracedValue("visible_rect", visible_layer_rect(), state);
1218 1236
1219 state->BeginArray("pictures"); 1237 state->BeginArray("pictures");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 1273
1256 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1274 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1257 return !layer_tree_impl()->IsRecycleTree(); 1275 return !layer_tree_impl()->IsRecycleTree();
1258 } 1276 }
1259 1277
1260 bool PictureLayerImpl::HasValidTilePriorities() const { 1278 bool PictureLayerImpl::HasValidTilePriorities() const {
1261 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); 1279 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember();
1262 } 1280 }
1263 1281
1264 } // namespace cc 1282 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/playback/display_list_raster_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698