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

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

Issue 12259027: cc: Simplify the logic for deciding to update tile priorities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add early-out and unit test Created 7 years, 7 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 | Annotate | Revision Log
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 8
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 255
256 void PictureLayerImpl::DumpLayerProperties(std::string*, int indent) const { 256 void PictureLayerImpl::DumpLayerProperties(std::string*, int indent) const {
257 // TODO(enne): implement me 257 // TODO(enne): implement me
258 } 258 }
259 259
260 void PictureLayerImpl::UpdateTilePriorities() { 260 void PictureLayerImpl::UpdateTilePriorities() {
261 if (!tilings_->num_tilings()) 261 if (!tilings_->num_tilings())
262 return; 262 return;
263 263
264 double current_frame_time_in_seconds =
265 (layer_tree_impl()->CurrentFrameTimeTicks() -
266 base::TimeTicks()).InSecondsF();
267
268 bool tiling_needs_update = false;
269 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
270 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime(
271 current_frame_time_in_seconds)) {
272 tiling_needs_update = true;
273 break;
274 }
275 }
276 if (!tiling_needs_update)
277 return;
278
264 UpdateLCDTextStatus(); 279 UpdateLCDTextStatus();
265 280
266 int current_source_frame_number = layer_tree_impl()->source_frame_number();
267 double current_frame_time = (layer_tree_impl()->CurrentFrameTimeTicks() -
268 base::TimeTicks()).InSecondsF();
269
270 gfx::Transform current_screen_space_transform = screen_space_transform(); 281 gfx::Transform current_screen_space_transform = screen_space_transform();
271 282
272 gfx::Rect viewport_in_content_space; 283 gfx::Rect viewport_in_content_space;
273 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); 284 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization);
274 if (screen_space_transform().GetInverse(&screen_to_layer)) { 285 if (screen_space_transform().GetInverse(&screen_to_layer)) {
275 gfx::Rect device_viewport(layer_tree_impl()->device_viewport_size()); 286 gfx::Rect device_viewport(layer_tree_impl()->device_viewport_size());
276 viewport_in_content_space = gfx::ToEnclosingRect( 287 viewport_in_content_space = gfx::ToEnclosingRect(
277 MathUtil::ProjectClippedRect(screen_to_layer, device_viewport)); 288 MathUtil::ProjectClippedRect(screen_to_layer, device_viewport));
278 } 289 }
279 290
280 WhichTree tree = 291 WhichTree tree =
281 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; 292 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE;
282 bool store_screen_space_quads_on_tiles = 293 bool store_screen_space_quads_on_tiles =
283 layer_tree_impl()->debug_state().trace_all_rendered_frames; 294 layer_tree_impl()->debug_state().trace_all_rendered_frames;
284 size_t max_tiles_for_interest_area = 295 size_t max_tiles_for_interest_area =
285 layer_tree_impl()->settings().max_tiles_for_interest_area; 296 layer_tree_impl()->settings().max_tiles_for_interest_area;
286 tilings_->UpdateTilePriorities( 297 tilings_->UpdateTilePriorities(
287 tree, 298 tree,
288 layer_tree_impl()->device_viewport_size(), 299 layer_tree_impl()->device_viewport_size(),
289 viewport_in_content_space, 300 viewport_in_content_space,
290 visible_content_rect(), 301 visible_content_rect(),
291 last_bounds_, 302 last_bounds_,
292 bounds(), 303 bounds(),
293 last_content_scale_, 304 last_content_scale_,
294 contents_scale_x(), 305 contents_scale_x(),
295 last_screen_space_transform_, 306 last_screen_space_transform_,
296 current_screen_space_transform, 307 current_screen_space_transform,
297 current_source_frame_number, 308 current_frame_time_in_seconds,
298 current_frame_time,
299 store_screen_space_quads_on_tiles, 309 store_screen_space_quads_on_tiles,
300 max_tiles_for_interest_area); 310 max_tiles_for_interest_area);
301 311
302 last_screen_space_transform_ = current_screen_space_transform; 312 last_screen_space_transform_ = current_screen_space_transform;
303 last_bounds_ = bounds(); 313 last_bounds_ = bounds();
304 last_content_scale_ = contents_scale_x(); 314 last_content_scale_ = contents_scale_x();
305 } 315 }
306 316
307 void PictureLayerImpl::DidBecomeActive() { 317 void PictureLayerImpl::DidBecomeActive() {
308 LayerImpl::DidBecomeActive(); 318 LayerImpl::DidBecomeActive();
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { 911 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const {
902 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 912 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
903 LayerImpl::AsValueInto(state.get()); 913 LayerImpl::AsValueInto(state.get());
904 914
905 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 915 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
906 state->Set("tilings", tilings_->AsValue().release()); 916 state->Set("tilings", tilings_->AsValue().release());
907 return state.PassAs<base::Value>(); 917 return state.PassAs<base::Value>();
908 } 918 }
909 919
910 } // namespace cc 920 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698