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

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

Issue 140513006: cc: Simplify picture layer tiling update tile priorities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 #include <limits> 8 #include <limits>
9 9
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 22 matching lines...) Expand all
33 // tiling's scale if the desired scale is within this ratio. 33 // tiling's scale if the desired scale is within this ratio.
34 const float kSnapToExistingTilingRatio = 0.2f; 34 const float kSnapToExistingTilingRatio = 0.2f;
35 } 35 }
36 36
37 namespace cc { 37 namespace cc {
38 38
39 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) 39 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id)
40 : LayerImpl(tree_impl, id), 40 : LayerImpl(tree_impl, id),
41 twin_layer_(NULL), 41 twin_layer_(NULL),
42 pile_(PicturePileImpl::Create()), 42 pile_(PicturePileImpl::Create()),
43 last_content_scale_(0),
44 is_mask_(false), 43 is_mask_(false),
45 ideal_page_scale_(0.f), 44 ideal_page_scale_(0.f),
46 ideal_device_scale_(0.f), 45 ideal_device_scale_(0.f),
47 ideal_source_scale_(0.f), 46 ideal_source_scale_(0.f),
48 ideal_contents_scale_(0.f), 47 ideal_contents_scale_(0.f),
49 raster_page_scale_(0.f), 48 raster_page_scale_(0.f),
50 raster_device_scale_(0.f), 49 raster_device_scale_(0.f),
51 raster_source_scale_(0.f), 50 raster_source_scale_(0.f),
52 raster_contents_scale_(0.f), 51 raster_contents_scale_(0.f),
53 low_res_raster_contents_scale_(0.f), 52 low_res_raster_contents_scale_(0.f),
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 current_frame_time_in_seconds)) { 326 current_frame_time_in_seconds)) {
328 tiling_needs_update = true; 327 tiling_needs_update = true;
329 break; 328 break;
330 } 329 }
331 } 330 }
332 if (!tiling_needs_update) 331 if (!tiling_needs_update)
333 return; 332 return;
334 333
335 UpdateLCDTextStatus(can_use_lcd_text()); 334 UpdateLCDTextStatus(can_use_lcd_text());
336 335
337 gfx::Transform current_screen_space_transform = screen_space_transform(); 336 // Use visible_content_rect, unless it's empty. If it's empty, then
338 337 // try to inverse project the viewport into layer space and use that.
339 gfx::Size viewport_size = layer_tree_impl()->DrawViewportSize(); 338 gfx::Rect visible_rect_in_content_space = visible_content_rect();
340 gfx::Rect viewport_in_content_space; 339 if (visible_rect_in_content_space.IsEmpty()) {
341 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); 340 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization);
342 if (screen_space_transform().GetInverse(&screen_to_layer)) { 341 if (screen_space_transform().GetInverse(&screen_to_layer)) {
343 viewport_in_content_space = 342 gfx::Size viewport_size = layer_tree_impl()->DrawViewportSize();
344 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( 343 visible_rect_in_content_space =
345 screen_to_layer, gfx::Rect(viewport_size))); 344 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
345 screen_to_layer, gfx::Rect(viewport_size)));
346 }
346 } 347 }
347 348
348 WhichTree tree = 349 WhichTree tree =
349 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; 350 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE;
350 size_t max_tiles_for_interest_area = 351
351 layer_tree_impl()->settings().max_tiles_for_interest_area;
352 tilings_->UpdateTilePriorities( 352 tilings_->UpdateTilePriorities(
353 tree, 353 tree,
354 viewport_size, 354 visible_rect_in_content_space,
enne (OOO) 2014/02/04 00:38:22 This caller passes visible_rect_in_content_space b
vmpstr 2014/02/04 19:50:49 This is PictureLayerTilingSet::UpdateTilePrioritie
355 viewport_in_content_space,
356 visible_content_rect(),
357 last_bounds_,
358 bounds(),
359 last_content_scale_,
360 contents_scale_x(), 355 contents_scale_x(),
361 last_screen_space_transform_, 356 current_frame_time_in_seconds);
362 current_screen_space_transform,
363 current_frame_time_in_seconds,
364 max_tiles_for_interest_area);
365 357
366 if (layer_tree_impl()->IsPendingTree()) 358 if (layer_tree_impl()->IsPendingTree())
367 MarkVisibleResourcesAsRequired(); 359 MarkVisibleResourcesAsRequired();
368 360
369 last_screen_space_transform_ = current_screen_space_transform;
370 last_bounds_ = bounds();
371 last_content_scale_ = contents_scale_x();
372
373 // Tile priorities were modified. 361 // Tile priorities were modified.
374 layer_tree_impl()->DidModifyTilePriorities(); 362 layer_tree_impl()->DidModifyTilePriorities();
375 } 363 }
376 364
377 void PictureLayerImpl::DidBecomeActive() { 365 void PictureLayerImpl::DidBecomeActive() {
378 LayerImpl::DidBecomeActive(); 366 LayerImpl::DidBecomeActive();
379 tilings_->DidBecomeActive(); 367 tilings_->DidBecomeActive();
380 layer_tree_impl()->DidModifyTilePriorities(); 368 layer_tree_impl()->DidModifyTilePriorities();
381 } 369 }
382 370
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 if (!twin_layer_ || twin_layer_->should_use_gpu_rasterization() != 494 if (!twin_layer_ || twin_layer_->should_use_gpu_rasterization() !=
507 should_use_gpu_rasterization()) 495 should_use_gpu_rasterization())
508 return NULL; 496 return NULL;
509 for (size_t i = 0; i < twin_layer_->tilings_->num_tilings(); ++i) 497 for (size_t i = 0; i < twin_layer_->tilings_->num_tilings(); ++i)
510 if (twin_layer_->tilings_->tiling_at(i)->contents_scale() == 498 if (twin_layer_->tilings_->tiling_at(i)->contents_scale() ==
511 tiling->contents_scale()) 499 tiling->contents_scale())
512 return twin_layer_->tilings_->tiling_at(i); 500 return twin_layer_->tilings_->tiling_at(i);
513 return NULL; 501 return NULL;
514 } 502 }
515 503
504 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const {
505 return layer_tree_impl()->settings().max_tiles_for_interest_area;
506 }
507
508 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const {
509 return layer_tree_impl()->settings().skewport_target_time_in_seconds;
510 }
511
516 gfx::Size PictureLayerImpl::CalculateTileSize( 512 gfx::Size PictureLayerImpl::CalculateTileSize(
517 const gfx::Size& content_bounds) const { 513 const gfx::Size& content_bounds) const {
518 if (is_mask_) { 514 if (is_mask_) {
519 int max_size = layer_tree_impl()->MaxTextureSize(); 515 int max_size = layer_tree_impl()->MaxTextureSize();
520 return gfx::Size( 516 return gfx::Size(
521 std::min(max_size, content_bounds.width()), 517 std::min(max_size, content_bounds.width()),
522 std::min(max_size, content_bounds.height())); 518 std::min(max_size, content_bounds.height()));
523 } 519 }
524 520
525 int max_texture_size = 521 int max_texture_size =
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 continue; 712 continue;
717 } 713 }
718 for (PictureLayerTiling::CoverageIterator iter(tiling, 714 for (PictureLayerTiling::CoverageIterator iter(tiling,
719 contents_scale_x(), 715 contents_scale_x(),
720 rect); 716 rect);
721 iter; 717 iter;
722 ++iter) { 718 ++iter) {
723 if (!*iter || !iter->IsReadyToDraw()) 719 if (!*iter || !iter->IsReadyToDraw())
724 continue; 720 continue;
725 721
726 // This iteration is over the visible content rect which is potentially
727 // less conservative than projecting the viewport into the layer.
728 // Ignore tiles that are know to be outside the viewport.
729 if (iter->priority(PENDING_TREE).distance_to_visible_in_pixels != 0)
730 continue;
731
732 missing_region.Subtract(iter.geometry_rect()); 722 missing_region.Subtract(iter.geometry_rect());
733 iter->MarkRequiredForActivation(); 723 iter->MarkRequiredForActivation();
734 } 724 }
735 } 725 }
736 DCHECK(high_res) << "There must be one high res tiling"; 726 DCHECK(high_res) << "There must be one high res tiling";
737 727
738 // If these pointers are null (because no twin, no matching tiling, or the 728 // If these pointers are null (because no twin, no matching tiling, or the
739 // simpification just below), then high res tiles will be required to fill any 729 // simpification just below), then high res tiles will be required to fill any
740 // holes left by the first pass above. If the pointers are valid, then this 730 // holes left by the first pass above. If the pointers are valid, then this
741 // layer is allowed to skip any tiles that are not ready on its twin. 731 // layer is allowed to skip any tiles that are not ready on its twin.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 for (PictureLayerTiling::CoverageIterator iter(tiling, 775 for (PictureLayerTiling::CoverageIterator iter(tiling,
786 contents_scale, 776 contents_scale,
787 rect); 777 rect);
788 iter; 778 iter;
789 ++iter) { 779 ++iter) {
790 Tile* tile = *iter; 780 Tile* tile = *iter;
791 // A null tile (i.e. missing recording) can just be skipped. 781 // A null tile (i.e. missing recording) can just be skipped.
792 if (!tile) 782 if (!tile)
793 continue; 783 continue;
794 784
795 // This iteration is over the visible content rect which is potentially
796 // less conservative than projecting the viewport into the layer.
797 // Ignore tiles that are know to be outside the viewport.
798 if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels != 0)
799 continue;
800
801 // If the missing region doesn't cover it, this tile is fully 785 // If the missing region doesn't cover it, this tile is fully
802 // covered by acceptable tiles at other scales. 786 // covered by acceptable tiles at other scales.
803 if (!missing_region.Intersects(iter.geometry_rect())) 787 if (!missing_region.Intersects(iter.geometry_rect()))
804 continue; 788 continue;
805 789
806 // If the twin tile doesn't exist (i.e. missing recording or so far away 790 // If the twin tile doesn't exist (i.e. missing recording or so far away
807 // that it is outside the visible tile rect) or this tile is shared between 791 // that it is outside the visible tile rect) or this tile is shared between
808 // with the twin, then this tile isn't required to prevent flashing. 792 // with the twin, then this tile isn't required to prevent flashing.
809 if (optional_twin_tiling) { 793 if (optional_twin_tiling) {
810 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); 794 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j());
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { 1215 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const {
1232 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); 1216 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded();
1233 return tilings_->GPUMemoryUsageInBytes(); 1217 return tilings_->GPUMemoryUsageInBytes();
1234 } 1218 }
1235 1219
1236 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { 1220 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
1237 benchmark->RunOnLayer(this); 1221 benchmark->RunOnLayer(this);
1238 } 1222 }
1239 1223
1240 } // namespace cc 1224 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698