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

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

Issue 881083002: cc: Clean up tilings in UpdateTiles as well as in AppendQuads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove dup Created 5 years, 11 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/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 <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 debug_border_quad->SetNew(shared_quad_state, 269 debug_border_quad->SetNew(shared_quad_state,
270 geometry_rect, 270 geometry_rect,
271 visible_geometry_rect, 271 visible_geometry_rect,
272 color, 272 color,
273 width); 273 width);
274 } 274 }
275 } 275 }
276 276
277 // Keep track of the tilings that were used so that tilings that are 277 // Keep track of the tilings that were used so that tilings that are
278 // unused can be considered for removal. 278 // unused can be considered for removal.
279 std::vector<PictureLayerTiling*> seen_tilings; 279 last_append_quads_tilings_.clear();
280 280
281 // Ignore missing tiles outside of viewport for tile priority. This is 281 // Ignore missing tiles outside of viewport for tile priority. This is
282 // normally the same as draw viewport but can be independently overridden by 282 // normally the same as draw viewport but can be independently overridden by
283 // embedders like Android WebView with SetExternalDrawConstraints. 283 // embedders like Android WebView with SetExternalDrawConstraints.
284 gfx::Rect scaled_viewport_for_tile_priority = gfx::ScaleToEnclosingRect( 284 gfx::Rect scaled_viewport_for_tile_priority = gfx::ScaleToEnclosingRect(
285 viewport_rect_for_tile_priority_in_content_space_, max_contents_scale); 285 viewport_rect_for_tile_priority_in_content_space_, max_contents_scale);
286 286
287 size_t missing_tile_count = 0u; 287 size_t missing_tile_count = 0u;
288 size_t on_demand_missing_tile_count = 0u; 288 size_t on_demand_missing_tile_count = 0u;
289 only_used_low_res_last_append_quads_ = true; 289 only_used_low_res_last_append_quads_ = true;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (iter.resolution() != HIGH_RESOLUTION) { 396 if (iter.resolution() != HIGH_RESOLUTION) {
397 append_quads_data->approximated_visible_content_area += 397 append_quads_data->approximated_visible_content_area +=
398 visible_geometry_rect.width() * visible_geometry_rect.height(); 398 visible_geometry_rect.width() * visible_geometry_rect.height();
399 } 399 }
400 400
401 // If we have a draw quad, but it's not low resolution, then 401 // If we have a draw quad, but it's not low resolution, then
402 // mark that we've used something other than low res to draw. 402 // mark that we've used something other than low res to draw.
403 if (iter.resolution() != LOW_RESOLUTION) 403 if (iter.resolution() != LOW_RESOLUTION)
404 only_used_low_res_last_append_quads_ = false; 404 only_used_low_res_last_append_quads_ = false;
405 405
406 if (seen_tilings.empty() || seen_tilings.back() != iter.CurrentTiling()) 406 if (last_append_quads_tilings_.empty() ||
407 seen_tilings.push_back(iter.CurrentTiling()); 407 last_append_quads_tilings_.back() != iter.CurrentTiling()) {
408 last_append_quads_tilings_.push_back(iter.CurrentTiling());
409 }
408 } 410 }
409 411
410 if (missing_tile_count) { 412 if (missing_tile_count) {
411 TRACE_EVENT_INSTANT2("cc", 413 TRACE_EVENT_INSTANT2("cc",
412 "PictureLayerImpl::AppendQuads checkerboard", 414 "PictureLayerImpl::AppendQuads checkerboard",
413 TRACE_EVENT_SCOPE_THREAD, 415 TRACE_EVENT_SCOPE_THREAD,
414 "missing_tile_count", 416 "missing_tile_count",
415 missing_tile_count, 417 missing_tile_count,
416 "on_demand_missing_tile_count", 418 "on_demand_missing_tile_count",
417 on_demand_missing_tile_count); 419 on_demand_missing_tile_count);
418 } 420 }
419 421
420 // Aggressively remove any tilings that are not seen to save memory. Note 422 // Aggressively remove any tilings that are not seen to save memory. Note
421 // that this is at the expense of doing cause more frequent re-painting. A 423 // that this is at the expense of doing cause more frequent re-painting. A
422 // better scheme would be to maintain a tighter visible_content_rect for the 424 // better scheme would be to maintain a tighter visible_content_rect for the
423 // finer tilings. 425 // finer tilings.
424 CleanUpTilingsOnActiveLayer(seen_tilings); 426 CleanUpTilingsOnActiveLayer(last_append_quads_tilings_);
425 } 427 }
426 428
427 bool PictureLayerImpl::UpdateTiles(const Occlusion& occlusion_in_content_space, 429 bool PictureLayerImpl::UpdateTiles(const Occlusion& occlusion_in_content_space,
428 bool resourceless_software_draw) { 430 bool resourceless_software_draw) {
429 DCHECK_EQ(1.f, contents_scale_x()); 431 DCHECK_EQ(1.f, contents_scale_x());
430 DCHECK_EQ(1.f, contents_scale_y()); 432 DCHECK_EQ(1.f, contents_scale_y());
431 433
432 if (!resourceless_software_draw) { 434 if (!resourceless_software_draw) {
433 visible_rect_for_tile_priority_ = visible_content_rect(); 435 visible_rect_for_tile_priority_ = visible_content_rect();
434 } 436 }
435 437
436 if (!CanHaveTilings()) { 438 if (!CanHaveTilings()) {
437 ideal_page_scale_ = 0.f; 439 ideal_page_scale_ = 0.f;
438 ideal_device_scale_ = 0.f; 440 ideal_device_scale_ = 0.f;
439 ideal_contents_scale_ = 0.f; 441 ideal_contents_scale_ = 0.f;
440 ideal_source_scale_ = 0.f; 442 ideal_source_scale_ = 0.f;
441 SanityCheckTilingState(); 443 SanityCheckTilingState();
442 return false; 444 return false;
443 } 445 }
444 446
447 // Remove any non-ideal tilings that were not used last time we generated
448 // quads to save memory and processing time. Note that pending tree should
449 // only have one or two tilings (high and low res), so only clean up the
450 // active layer. This cleans it up here in case AppendQuads didn't run.
451 // If it did run, this would not remove any additional tilings.
452 if (GetTree() == ACTIVE_TREE)
453 CleanUpTilingsOnActiveLayer(last_append_quads_tilings_);
454
445 UpdateIdealScales(); 455 UpdateIdealScales();
446 456
447 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { 457 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) {
448 RecalculateRasterScales(); 458 RecalculateRasterScales();
449 AddTilingsForRasterScale(); 459 AddTilingsForRasterScale();
450 } 460 }
451 461
452 DCHECK(raster_page_scale_); 462 DCHECK(raster_page_scale_);
453 DCHECK(raster_device_scale_); 463 DCHECK(raster_device_scale_);
454 DCHECK(raster_source_scale_); 464 DCHECK(raster_source_scale_);
455 DCHECK(raster_contents_scale_); 465 DCHECK(raster_contents_scale_);
456 DCHECK(low_res_raster_contents_scale_); 466 DCHECK(low_res_raster_contents_scale_);
457 467
458 was_screen_space_transform_animating_ = 468 was_screen_space_transform_animating_ =
459 draw_properties().screen_space_transform_is_animating; 469 draw_properties().screen_space_transform_is_animating;
460 470
461 if (draw_transform_is_animating()) 471 if (draw_transform_is_animating())
462 raster_source_->SetShouldAttemptToUseDistanceFieldText(); 472 raster_source_->SetShouldAttemptToUseDistanceFieldText();
463
464 return UpdateTilePriorities(occlusion_in_content_space); 473 return UpdateTilePriorities(occlusion_in_content_space);
465 } 474 }
466 475
467 bool PictureLayerImpl::UpdateTilePriorities( 476 bool PictureLayerImpl::UpdateTilePriorities(
468 const Occlusion& occlusion_in_content_space) { 477 const Occlusion& occlusion_in_content_space) {
469 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); 478 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0);
470 479
471 double current_frame_time_in_seconds = 480 double current_frame_time_in_seconds =
472 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - 481 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time -
473 base::TimeTicks()).InSecondsF(); 482 base::TimeTicks()).InSecondsF();
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 float low_res_factor = 994 float low_res_factor =
986 layer_tree_impl()->settings().low_res_contents_scale_factor; 995 layer_tree_impl()->settings().low_res_contents_scale_factor;
987 low_res_raster_contents_scale_ = 996 low_res_raster_contents_scale_ =
988 std::max(raster_contents_scale_ * low_res_factor, MinimumContentsScale()); 997 std::max(raster_contents_scale_ * low_res_factor, MinimumContentsScale());
989 DCHECK_LE(low_res_raster_contents_scale_, raster_contents_scale_); 998 DCHECK_LE(low_res_raster_contents_scale_, raster_contents_scale_);
990 DCHECK_GE(low_res_raster_contents_scale_, MinimumContentsScale()); 999 DCHECK_GE(low_res_raster_contents_scale_, MinimumContentsScale());
991 DCHECK_LE(low_res_raster_contents_scale_, MaximumContentsScale()); 1000 DCHECK_LE(low_res_raster_contents_scale_, MaximumContentsScale());
992 } 1001 }
993 1002
994 void PictureLayerImpl::CleanUpTilingsOnActiveLayer( 1003 void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
995 std::vector<PictureLayerTiling*> used_tilings) { 1004 const std::vector<PictureLayerTiling*>& used_tilings) {
996 DCHECK(layer_tree_impl()->IsActiveTree()); 1005 DCHECK(layer_tree_impl()->IsActiveTree());
997 if (tilings_->num_tilings() == 0) 1006 if (tilings_->num_tilings() == 0)
998 return; 1007 return;
999 1008
1000 float min_acceptable_high_res_scale = std::min( 1009 float min_acceptable_high_res_scale = std::min(
1001 raster_contents_scale_, ideal_contents_scale_); 1010 raster_contents_scale_, ideal_contents_scale_);
1002 float max_acceptable_high_res_scale = std::max( 1011 float max_acceptable_high_res_scale = std::max(
1003 raster_contents_scale_, ideal_contents_scale_); 1012 raster_contents_scale_, ideal_contents_scale_);
1004 1013
1005 PictureLayerImpl* twin = GetPendingOrActiveTwinLayer(); 1014 PictureLayerImpl* twin = GetPendingOrActiveTwinLayer();
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 1289
1281 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { 1290 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const {
1282 if (!layer_tree_impl()->IsActiveTree()) 1291 if (!layer_tree_impl()->IsActiveTree())
1283 return true; 1292 return true;
1284 1293
1285 return AllTilesRequiredAreReadyToDraw( 1294 return AllTilesRequiredAreReadyToDraw(
1286 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); 1295 &PictureLayerTiling::IsTileRequiredForDrawIfVisible);
1287 } 1296 }
1288 1297
1289 } // namespace cc 1298 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698