OLD | NEW |
---|---|
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/debug/trace_event_argument.h" | 10 #include "base/debug/trace_event_argument.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 visible_geometry_rect, | 257 visible_geometry_rect, |
258 color, | 258 color, |
259 width); | 259 width); |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 // Keep track of the tilings that were used so that tilings that are | 263 // Keep track of the tilings that were used so that tilings that are |
264 // unused can be considered for removal. | 264 // unused can be considered for removal. |
265 std::vector<PictureLayerTiling*> seen_tilings; | 265 std::vector<PictureLayerTiling*> seen_tilings; |
266 | 266 |
267 gfx::Rect tile_rect = GetVisibleRectForTilePriorityInContentSpace(); | |
danakj
2014/08/15 22:09:08
scaled_tile_priority_rect?
enne (OOO)
2014/08/15 22:33:50
"ForTilePriority" also seems not true anymore. Is
boliu
2014/08/15 23:07:26
How about something with activation, external_acti
| |
268 tile_rect = gfx::ScaleToEnclosingRect(tile_rect, max_contents_scale); | |
269 | |
267 size_t missing_tile_count = 0u; | 270 size_t missing_tile_count = 0u; |
268 size_t on_demand_missing_tile_count = 0u; | 271 size_t on_demand_missing_tile_count = 0u; |
269 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), | 272 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), |
270 max_contents_scale, | 273 max_contents_scale, |
271 scaled_visible_content_rect, | 274 scaled_visible_content_rect, |
272 ideal_contents_scale_); | 275 ideal_contents_scale_); |
273 iter; | 276 iter; |
274 ++iter) { | 277 ++iter) { |
275 gfx::Rect geometry_rect = iter.geometry_rect(); | 278 gfx::Rect geometry_rect = iter.geometry_rect(); |
276 gfx::Rect visible_geometry_rect = occlusion_tracker.UnoccludedContentRect( | 279 gfx::Rect visible_geometry_rect = occlusion_tracker.UnoccludedContentRect( |
277 geometry_rect, scaled_draw_transform); | 280 geometry_rect, scaled_draw_transform); |
278 if (visible_geometry_rect.IsEmpty()) | 281 if (visible_geometry_rect.IsEmpty()) |
279 continue; | 282 continue; |
280 | 283 |
281 append_quads_data->visible_content_area += | 284 append_quads_data->visible_content_area += |
282 visible_geometry_rect.width() * visible_geometry_rect.height(); | 285 visible_geometry_rect.width() * visible_geometry_rect.height(); |
283 | 286 |
284 if (*iter && iter->IsReadyToDraw()) { | 287 if (*iter && iter->IsReadyToDraw()) { |
285 const ManagedTileState::TileVersion& tile_version = | 288 const ManagedTileState::TileVersion& tile_version = |
286 iter->GetTileVersionForDrawing(); | 289 iter->GetTileVersionForDrawing(); |
287 switch (tile_version.mode()) { | 290 switch (tile_version.mode()) { |
288 case ManagedTileState::TileVersion::RESOURCE_MODE: { | 291 case ManagedTileState::TileVersion::RESOURCE_MODE: { |
289 gfx::RectF texture_rect = iter.texture_rect(); | 292 gfx::RectF texture_rect = iter.texture_rect(); |
290 gfx::Rect opaque_rect = iter->opaque_rect(); | 293 gfx::Rect opaque_rect = iter->opaque_rect(); |
291 opaque_rect.Intersect(geometry_rect); | 294 opaque_rect.Intersect(geometry_rect); |
292 | 295 |
293 if (iter->contents_scale() != ideal_contents_scale_) | 296 if (iter->contents_scale() != ideal_contents_scale_ && |
297 geometry_rect.Intersects(tile_rect)) { | |
danakj
2014/08/15 21:43:44
We only iterate over the visible_content_rect in t
boliu
2014/08/15 21:56:26
Yes in chrome. No in webview.
In chrome, draw vie
danakj
2014/08/15 22:09:08
Maybe we need separate counts (or a bool) in Appen
hush (inactive)
2014/08/15 22:12:37
I'm not exactly sure about the scales of the rects
danakj
2014/08/15 22:20:45
geometry_rect is in the "geometry space" of the it
boliu
2014/08/15 22:33:42
I think we'll need a count then. One counts missin
hush (inactive)
2014/08/15 22:35:36
Thanks Dana!
So I suppose the dest_scale_ in Pictu
danakj
2014/08/15 22:36:06
Yeh
| |
294 append_quads_data->num_incomplete_tiles++; | 298 append_quads_data->num_incomplete_tiles++; |
299 } | |
295 | 300 |
296 TileDrawQuad* quad = | 301 TileDrawQuad* quad = |
297 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 302 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
298 quad->SetNew(shared_quad_state, | 303 quad->SetNew(shared_quad_state, |
299 geometry_rect, | 304 geometry_rect, |
300 opaque_rect, | 305 opaque_rect, |
301 visible_geometry_rect, | 306 visible_geometry_rect, |
302 tile_version.get_resource_id(), | 307 tile_version.get_resource_id(), |
303 texture_rect, | 308 texture_rect, |
304 iter.texture_size(), | 309 iter.texture_size(), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 SkColor color = SafeOpaqueBackgroundColor(); | 362 SkColor color = SafeOpaqueBackgroundColor(); |
358 SolidColorDrawQuad* quad = | 363 SolidColorDrawQuad* quad = |
359 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 364 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
360 quad->SetNew(shared_quad_state, | 365 quad->SetNew(shared_quad_state, |
361 geometry_rect, | 366 geometry_rect, |
362 visible_geometry_rect, | 367 visible_geometry_rect, |
363 color, | 368 color, |
364 false); | 369 false); |
365 } | 370 } |
366 | 371 |
367 append_quads_data->num_missing_tiles++; | 372 if (geometry_rect.Intersects(tile_rect)) { |
373 append_quads_data->num_missing_tiles++; | |
danakj
2014/08/15 21:43:44
num missing tiles is used for UMA metrics to tell
boliu
2014/08/15 21:56:26
In chrome, they will always intersect, so no chang
danakj
2014/08/15 22:09:08
This makes it hard to reason about when we're coun
| |
374 ++missing_tile_count; | |
375 } | |
368 append_quads_data->approximated_visible_content_area += | 376 append_quads_data->approximated_visible_content_area += |
369 visible_geometry_rect.width() * visible_geometry_rect.height(); | 377 visible_geometry_rect.width() * visible_geometry_rect.height(); |
370 ++missing_tile_count; | |
371 continue; | 378 continue; |
372 } | 379 } |
373 | 380 |
374 if (iter->priority(ACTIVE_TREE).resolution != HIGH_RESOLUTION) { | 381 if (iter->priority(ACTIVE_TREE).resolution != HIGH_RESOLUTION) { |
375 append_quads_data->approximated_visible_content_area += | 382 append_quads_data->approximated_visible_content_area += |
376 visible_geometry_rect.width() * visible_geometry_rect.height(); | 383 visible_geometry_rect.width() * visible_geometry_rect.height(); |
377 } | 384 } |
378 | 385 |
379 if (seen_tilings.empty() || seen_tilings.back() != iter.CurrentTiling()) | 386 if (seen_tilings.empty() || seen_tilings.back() != iter.CurrentTiling()) |
380 seen_tilings.push_back(iter.CurrentTiling()); | 387 seen_tilings.push_back(iter.CurrentTiling()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 472 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
466 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( | 473 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTime( |
467 current_frame_time_in_seconds)) { | 474 current_frame_time_in_seconds)) { |
468 tiling_needs_update = true; | 475 tiling_needs_update = true; |
469 break; | 476 break; |
470 } | 477 } |
471 } | 478 } |
472 if (!tiling_needs_update) | 479 if (!tiling_needs_update) |
473 return; | 480 return; |
474 | 481 |
482 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | |
483 GetVisibleRectForTilePriorityInContentSpace(), 1.f / contents_scale_x()); | |
484 WhichTree tree = | |
485 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | |
486 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
487 tilings_->tiling_at(i)->UpdateTilePriorities(tree, | |
488 visible_layer_rect, | |
489 ideal_contents_scale_, | |
490 current_frame_time_in_seconds, | |
491 occlusion_tracker, | |
492 render_target(), | |
493 draw_transform()); | |
494 } | |
495 | |
496 // Tile priorities were modified. | |
497 layer_tree_impl()->DidModifyTilePriorities(); | |
498 } | |
499 | |
500 gfx::Rect PictureLayerImpl::GetVisibleRectForTilePriorityInContentSpace() | |
501 const { | |
475 // If visible_rect_for_tile_priority_ is empty or | 502 // If visible_rect_for_tile_priority_ is empty or |
476 // viewport_rect_for_tile_priority_ is set to be different from the device | 503 // viewport_rect_for_tile_priority_ is set to be different from the device |
477 // viewport, try to inverse project the viewport into layer space and use | 504 // viewport, try to inverse project the viewport into layer space and use |
478 // that. Otherwise just use visible_rect_for_tile_priority_ | 505 // that. Otherwise just use visible_rect_for_tile_priority_ |
479 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; | 506 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; |
480 | 507 |
481 if (visible_rect_in_content_space.IsEmpty() || | 508 if (visible_rect_in_content_space.IsEmpty() || |
482 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority_) { | 509 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority_) { |
483 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); | 510 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); |
484 | 511 |
485 if (screen_space_transform_for_tile_priority_.GetInverse(&view_to_layer)) { | 512 if (screen_space_transform_for_tile_priority_.GetInverse(&view_to_layer)) { |
486 // Transform from view space to content space. | 513 // Transform from view space to content space. |
487 visible_rect_in_content_space = | 514 visible_rect_in_content_space = |
488 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 515 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
489 view_to_layer, viewport_rect_for_tile_priority_)); | 516 view_to_layer, viewport_rect_for_tile_priority_)); |
490 | 517 |
491 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); | 518 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); |
492 } | 519 } |
493 } | 520 } |
494 | 521 |
495 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 522 return visible_rect_in_content_space; |
496 visible_rect_in_content_space, 1.f / contents_scale_x()); | |
497 WhichTree tree = | |
498 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | |
499 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
500 tilings_->tiling_at(i)->UpdateTilePriorities(tree, | |
501 visible_layer_rect, | |
502 ideal_contents_scale_, | |
503 current_frame_time_in_seconds, | |
504 occlusion_tracker, | |
505 render_target(), | |
506 draw_transform()); | |
507 } | |
508 | |
509 // Tile priorities were modified. | |
510 layer_tree_impl()->DidModifyTilePriorities(); | |
511 } | 523 } |
512 | 524 |
513 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 525 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
514 if (layer_tree_impl()->IsActiveTree()) { | 526 if (layer_tree_impl()->IsActiveTree()) { |
515 gfx::RectF layer_damage_rect = | 527 gfx::RectF layer_damage_rect = |
516 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 528 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
517 AddDamageRect(layer_damage_rect); | 529 AddDamageRect(layer_damage_rect); |
518 } | 530 } |
519 } | 531 } |
520 | 532 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 | 769 |
758 // The goal of this function is to find the minimum set of tiles that need to | 770 // The goal of this function is to find the minimum set of tiles that need to |
759 // be ready to draw in order to activate without flashing content from a | 771 // be ready to draw in order to activate without flashing content from a |
760 // higher res on the active tree to a lower res on the pending tree. | 772 // higher res on the active tree to a lower res on the pending tree. |
761 | 773 |
762 // First, early out for layers with no visible content. | 774 // First, early out for layers with no visible content. |
763 if (visible_content_rect().IsEmpty()) | 775 if (visible_content_rect().IsEmpty()) |
764 return; | 776 return; |
765 | 777 |
766 gfx::Rect rect(visible_content_rect()); | 778 gfx::Rect rect(visible_content_rect()); |
779 rect.Intersect(GetVisibleRectForTilePriorityInContentSpace()); | |
hush (inactive)
2014/08/15 21:53:18
I think you need to early out when intersection is
danakj
2014/08/15 22:09:08
Why are we intersecting instead of just using the
boliu
2014/08/15 22:33:42
MarkRequiredOffscreenTiles test uses a GetVisibleR
boliu
2014/08/15 23:07:26
This is actually kinda hard to do in webview code.
| |
767 | 780 |
768 float min_acceptable_scale = | 781 float min_acceptable_scale = |
769 std::min(raster_contents_scale_, ideal_contents_scale_); | 782 std::min(raster_contents_scale_, ideal_contents_scale_); |
770 | 783 |
771 if (PictureLayerImpl* twin = twin_layer_) { | 784 if (PictureLayerImpl* twin = twin_layer_) { |
772 float twin_min_acceptable_scale = | 785 float twin_min_acceptable_scale = |
773 std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_); | 786 std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_); |
774 // Ignore 0 scale in case CalculateContentsScale() has never been | 787 // Ignore 0 scale in case CalculateContentsScale() has never been |
775 // called for active twin. | 788 // called for active twin. |
776 if (twin_min_acceptable_scale != 0.0f) { | 789 if (twin_min_acceptable_scale != 0.0f) { |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1689 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1702 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1690 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1703 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1691 return tiling_range.end - 1 - current_tiling_range_offset; | 1704 return tiling_range.end - 1 - current_tiling_range_offset; |
1692 } | 1705 } |
1693 } | 1706 } |
1694 NOTREACHED(); | 1707 NOTREACHED(); |
1695 return 0; | 1708 return 0; |
1696 } | 1709 } |
1697 | 1710 |
1698 } // namespace cc | 1711 } // namespace cc |
OLD | NEW |