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

Side by Side Diff: cc/resources/picture_layer_tiling.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
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_set.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/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 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 14 matching lines...) Expand all
25 client)); 25 client));
26 } 26 }
27 27
28 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone( 28 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone(
29 gfx::Size layer_bounds, 29 gfx::Size layer_bounds,
30 PictureLayerTilingClient* client) const { 30 PictureLayerTilingClient* client) const {
31 scoped_ptr<PictureLayerTiling> out = 31 scoped_ptr<PictureLayerTiling> out =
32 make_scoped_ptr(new PictureLayerTiling(contents_scale_, 32 make_scoped_ptr(new PictureLayerTiling(contents_scale_,
33 layer_bounds, 33 layer_bounds,
34 client)); 34 client));
35 out->resolution_ = resolution_; 35 out->resolution_ = resolution_;
enne (OOO) 2013/05/02 19:59:46 Looking at this code closer, but could this lead t
danakj 2013/05/02 20:02:04 Hmm! It's kinda weird anyway right? You should man
36 out->last_source_frame_number_ = last_source_frame_number_;
37 out->last_impl_frame_time_ = last_impl_frame_time_;
38 return out.Pass(); 36 return out.Pass();
39 } 37 }
40 38
41 PictureLayerTiling::PictureLayerTiling(float contents_scale, 39 PictureLayerTiling::PictureLayerTiling(float contents_scale,
42 gfx::Size layer_bounds, 40 gfx::Size layer_bounds,
43 PictureLayerTilingClient* client) 41 PictureLayerTilingClient* client)
44 : contents_scale_(contents_scale), 42 : contents_scale_(contents_scale),
45 layer_bounds_(layer_bounds), 43 layer_bounds_(layer_bounds),
46 resolution_(NON_IDEAL_RESOLUTION), 44 resolution_(NON_IDEAL_RESOLUTION),
47 client_(client), 45 client_(client),
48 tiling_data_(gfx::Size(), gfx::Size(), true), 46 tiling_data_(gfx::Size(), gfx::Size(), true),
49 last_source_frame_number_(0), 47 last_impl_frame_time_in_seconds_(0.0) {
50 last_impl_frame_time_(0.0) {
51 gfx::Size content_bounds = 48 gfx::Size content_bounds =
52 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); 49 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale));
53 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); 50 gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
54 51
55 tiling_data_.SetTotalSize(content_bounds); 52 tiling_data_.SetTotalSize(content_bounds);
56 tiling_data_.SetMaxTextureSize(tile_size); 53 tiling_data_.SetMaxTextureSize(tile_size);
57 } 54 }
58 55
59 PictureLayerTiling::~PictureLayerTiling() { 56 PictureLayerTiling::~PictureLayerTiling() {
60 } 57 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 WhichTree tree, 285 WhichTree tree,
289 gfx::Size device_viewport, 286 gfx::Size device_viewport,
290 const gfx::RectF& viewport_in_layer_space, 287 const gfx::RectF& viewport_in_layer_space,
291 const gfx::RectF& visible_layer_rect, 288 const gfx::RectF& visible_layer_rect,
292 gfx::Size last_layer_bounds, 289 gfx::Size last_layer_bounds,
293 gfx::Size current_layer_bounds, 290 gfx::Size current_layer_bounds,
294 float last_layer_contents_scale, 291 float last_layer_contents_scale,
295 float current_layer_contents_scale, 292 float current_layer_contents_scale,
296 const gfx::Transform& last_screen_transform, 293 const gfx::Transform& last_screen_transform,
297 const gfx::Transform& current_screen_transform, 294 const gfx::Transform& current_screen_transform,
298 int current_source_frame_number, 295 double current_frame_time_in_seconds,
299 double current_frame_time,
300 bool store_screen_space_quads_on_tiles, 296 bool store_screen_space_quads_on_tiles,
301 size_t max_tiles_for_interest_area) { 297 size_t max_tiles_for_interest_area) {
302 if (ContentRect().IsEmpty()) 298 if (ContentRect().IsEmpty())
303 return; 299 return;
300 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds))
301 return;
304 302
305 gfx::Rect viewport_in_content_space = 303 gfx::Rect viewport_in_content_space =
306 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, 304 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space,
307 contents_scale_)); 305 contents_scale_));
308 gfx::Rect visible_content_rect = 306 gfx::Rect visible_content_rect =
309 gfx::ToEnclosingRect(gfx::ScaleRect(visible_layer_rect, 307 gfx::ToEnclosingRect(gfx::ScaleRect(visible_layer_rect,
310 contents_scale_)); 308 contents_scale_));
311 309
312 gfx::Size tile_size = tiling_data_.max_texture_size(); 310 gfx::Size tile_size = tiling_data_.max_texture_size();
313 int64 interest_rect_area = 311 int64 interest_rect_area =
314 max_tiles_for_interest_area * tile_size.width() * tile_size.height(); 312 max_tiles_for_interest_area * tile_size.width() * tile_size.height();
315 313
316 gfx::Rect starting_rect = visible_content_rect.IsEmpty() 314 gfx::Rect starting_rect = visible_content_rect.IsEmpty()
317 ? viewport_in_content_space 315 ? viewport_in_content_space
318 : visible_content_rect; 316 : visible_content_rect;
319 gfx::Rect interest_rect = ExpandRectEquallyToAreaBoundedBy( 317 gfx::Rect interest_rect = ExpandRectEquallyToAreaBoundedBy(
320 starting_rect, 318 starting_rect,
321 interest_rect_area, 319 interest_rect_area,
322 ContentRect()); 320 ContentRect());
323 DCHECK(interest_rect.IsEmpty() || 321 DCHECK(interest_rect.IsEmpty() ||
324 ContentRect().Contains(interest_rect)); 322 ContentRect().Contains(interest_rect));
325 323
326 SetLiveTilesRect(interest_rect); 324 SetLiveTilesRect(interest_rect);
327 325
328 bool first_update_in_new_source_frame = 326 double time_delta = 0;
329 current_source_frame_number != last_source_frame_number_; 327 if (last_impl_frame_time_in_seconds_ != 0.0 &&
330 328 last_layer_bounds == current_layer_bounds) {
331 bool first_update_in_new_impl_frame = 329 time_delta =
332 current_frame_time != last_impl_frame_time_; 330 current_frame_time_in_seconds - last_impl_frame_time_in_seconds_;
333 331 }
334 // In pending tree, this is always called. We update priorities:
335 // - Immediately after a commit (first_update_in_new_source_frame).
336 // - On animation ticks after the first frame in the tree
337 // (first_update_in_new_impl_frame).
338 // In active tree, this is only called during draw. We update priorities:
339 // - On draw if properties were not already computed by the pending tree
340 // and activated for the frame (first_update_in_new_impl_frame).
341 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame)
342 return;
343
344 double time_delta = 0.0;
345 if (last_impl_frame_time_ != 0.0 &&
346 last_layer_bounds == current_layer_bounds)
347 time_delta = current_frame_time - last_impl_frame_time_;
348 332
349 gfx::Rect view_rect(device_viewport); 333 gfx::Rect view_rect(device_viewport);
350 float current_scale = current_layer_contents_scale / contents_scale_; 334 float current_scale = current_layer_contents_scale / contents_scale_;
351 float last_scale = last_layer_contents_scale / contents_scale_; 335 float last_scale = last_layer_contents_scale / contents_scale_;
352 336
353 // Fast path tile priority calculation when both transforms are translations. 337 // Fast path tile priority calculation when both transforms are translations.
354 if (last_screen_transform.IsIdentityOrTranslation() && 338 if (last_screen_transform.IsIdentityOrTranslation() &&
355 current_screen_transform.IsIdentityOrTranslation()) { 339 current_screen_transform.IsIdentityOrTranslation()) {
356 gfx::Vector2dF current_offset( 340 gfx::Vector2dF current_offset(
357 current_screen_transform.matrix().get(0, 3), 341 current_screen_transform.matrix().get(0, 3),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 bool clipped; 414 bool clipped;
431 priority.set_current_screen_quad( 415 priority.set_current_screen_quad(
432 MathUtil::MapQuad(current_screen_transform, 416 MathUtil::MapQuad(current_screen_transform,
433 gfx::QuadF(current_layer_content_rect), 417 gfx::QuadF(current_layer_content_rect),
434 &clipped)); 418 &clipped));
435 } 419 }
436 tile->SetPriority(tree, priority); 420 tile->SetPriority(tree, priority);
437 } 421 }
438 } 422 }
439 423
440 last_source_frame_number_ = current_source_frame_number; 424 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds;
441 last_impl_frame_time_ = current_frame_time;
442 } 425 }
443 426
444 void PictureLayerTiling::SetLiveTilesRect( 427 void PictureLayerTiling::SetLiveTilesRect(
445 gfx::Rect new_live_tiles_rect) { 428 gfx::Rect new_live_tiles_rect) {
446 DCHECK(new_live_tiles_rect.IsEmpty() || 429 DCHECK(new_live_tiles_rect.IsEmpty() ||
447 ContentRect().Contains(new_live_tiles_rect)); 430 ContentRect().Contains(new_live_tiles_rect));
448 if (live_tiles_rect_ == new_live_tiles_rect) 431 if (live_tiles_rect_ == new_live_tiles_rect)
449 return; 432 return;
450 433
451 // Iterate to delete all tiles outside of our new live_tiles rect. 434 // Iterate to delete all tiles outside of our new live_tiles rect.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 602
620 // If our delta is less then our event distance, we're done. 603 // If our delta is less then our event distance, we're done.
621 if (delta < event.distance) 604 if (delta < event.distance)
622 break; 605 break;
623 } 606 }
624 607
625 return gfx::Rect(origin_x, origin_y, width, height); 608 return gfx::Rect(origin_x, origin_y, width, height);
626 } 609 }
627 610
628 } // namespace cc 611 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698