| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 406 } |
| 407 | 407 |
| 408 // Aggressively remove any tilings that are not seen to save memory. Note | 408 // Aggressively remove any tilings that are not seen to save memory. Note |
| 409 // that this is at the expense of doing cause more frequent re-painting. A | 409 // that this is at the expense of doing cause more frequent re-painting. A |
| 410 // better scheme would be to maintain a tighter visible_layer_rect for the | 410 // better scheme would be to maintain a tighter visible_layer_rect for the |
| 411 // finer tilings. | 411 // finer tilings. |
| 412 CleanUpTilingsOnActiveLayer(last_append_quads_tilings_); | 412 CleanUpTilingsOnActiveLayer(last_append_quads_tilings_); |
| 413 } | 413 } |
| 414 | 414 |
| 415 bool PictureLayerImpl::UpdateTiles(bool resourceless_software_draw) { | 415 bool PictureLayerImpl::UpdateTiles(bool resourceless_software_draw) { |
| 416 if (!resourceless_software_draw) { | |
| 417 visible_rect_for_tile_priority_ = visible_layer_rect(); | |
| 418 screen_space_transform_for_tile_priority_ = ScreenSpaceTransform(); | |
| 419 } | |
| 420 | |
| 421 if (!CanHaveTilings()) { | 416 if (!CanHaveTilings()) { |
| 422 ideal_page_scale_ = 0.f; | 417 ideal_page_scale_ = 0.f; |
| 423 ideal_device_scale_ = 0.f; | 418 ideal_device_scale_ = 0.f; |
| 424 ideal_contents_scale_ = 0.f; | 419 ideal_contents_scale_ = 0.f; |
| 425 ideal_source_scale_ = 0.f; | 420 ideal_source_scale_ = 0.f; |
| 426 SanityCheckTilingState(); | 421 SanityCheckTilingState(); |
| 427 return false; | 422 return false; |
| 428 } | 423 } |
| 429 | 424 |
| 430 // Remove any non-ideal tilings that were not used last time we generated | 425 // Remove any non-ideal tilings that were not used last time we generated |
| 431 // quads to save memory and processing time. Note that pending tree should | 426 // quads to save memory and processing time. Note that pending tree should |
| 432 // only have one or two tilings (high and low res), so only clean up the | 427 // only have one or two tilings (high and low res), so only clean up the |
| 433 // active layer. This cleans it up here in case AppendQuads didn't run. | 428 // active layer. This cleans it up here in case AppendQuads didn't run. |
| 434 // If it did run, this would not remove any additional tilings. | 429 // If it did run, this would not remove any additional tilings. |
| 435 if (layer_tree_impl()->IsActiveTree()) | 430 if (layer_tree_impl()->IsActiveTree()) |
| 436 CleanUpTilingsOnActiveLayer(last_append_quads_tilings_); | 431 CleanUpTilingsOnActiveLayer(last_append_quads_tilings_); |
| 437 | 432 |
| 433 if (resourceless_software_draw) |
| 434 return false; |
| 435 |
| 438 UpdateIdealScales(); | 436 UpdateIdealScales(); |
| 439 | 437 |
| 440 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { | 438 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { |
| 441 RecalculateRasterScales(); | 439 RecalculateRasterScales(); |
| 442 AddTilingsForRasterScale(); | 440 AddTilingsForRasterScale(); |
| 443 } | 441 } |
| 444 | 442 |
| 445 if (layer_tree_impl()->IsActiveTree()) | 443 if (layer_tree_impl()->IsActiveTree()) |
| 446 AddLowResolutionTilingIfNeeded(); | 444 AddLowResolutionTilingIfNeeded(); |
| 447 | 445 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // Pass |occlusion_in_content_space| for |occlusion_in_layer_space| since | 485 // Pass |occlusion_in_content_space| for |occlusion_in_layer_space| since |
| 488 // they are the same space in picture layer, as contents scale is always 1. | 486 // they are the same space in picture layer, as contents scale is always 1. |
| 489 bool updated = tilings_->UpdateTilePriorities( | 487 bool updated = tilings_->UpdateTilePriorities( |
| 490 viewport_rect_for_tile_priority_in_content_space_, ideal_contents_scale_, | 488 viewport_rect_for_tile_priority_in_content_space_, ideal_contents_scale_, |
| 491 current_frame_time_in_seconds, occlusion_in_content_space, | 489 current_frame_time_in_seconds, occlusion_in_content_space, |
| 492 can_require_tiles_for_activation); | 490 can_require_tiles_for_activation); |
| 493 return updated; | 491 return updated; |
| 494 } | 492 } |
| 495 | 493 |
| 496 void PictureLayerImpl::UpdateViewportRectForTilePriorityInContentSpace() { | 494 void PictureLayerImpl::UpdateViewportRectForTilePriorityInContentSpace() { |
| 497 // If visible_rect_for_tile_priority_ is empty or | 495 // If visible_layer_rect() is empty or viewport_rect_for_tile_priority is |
| 498 // viewport_rect_for_tile_priority is set to be different from the device | 496 // set to be different from the device viewport, try to inverse project the |
| 499 // viewport, try to inverse project the viewport into layer space and use | 497 // viewport into layer space and use that. Otherwise just use |
| 500 // that. Otherwise just use visible_rect_for_tile_priority_ | 498 // visible_layer_rect(). |
| 501 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; | 499 gfx::Rect visible_rect_in_content_space = visible_layer_rect(); |
| 502 gfx::Rect viewport_rect_for_tile_priority = | 500 gfx::Rect viewport_rect_for_tile_priority = |
| 503 layer_tree_impl()->ViewportRectForTilePriority(); | 501 layer_tree_impl()->ViewportRectForTilePriority(); |
| 504 if (visible_rect_in_content_space.IsEmpty() || | 502 if (visible_rect_in_content_space.IsEmpty() || |
| 505 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority) { | 503 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority) { |
| 506 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); | 504 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); |
| 507 if (screen_space_transform_for_tile_priority_.GetInverse(&view_to_layer)) { | 505 if (ScreenSpaceTransform().GetInverse(&view_to_layer)) { |
| 508 // Transform from view space to content space. | 506 // Transform from view space to content space. |
| 509 visible_rect_in_content_space = MathUtil::ProjectEnclosingClippedRect( | 507 visible_rect_in_content_space = MathUtil::ProjectEnclosingClippedRect( |
| 510 view_to_layer, viewport_rect_for_tile_priority); | 508 view_to_layer, viewport_rect_for_tile_priority); |
| 511 | 509 |
| 512 // We have to allow for a viewport that is outside of the layer bounds in | 510 // We have to allow for a viewport that is outside of the layer bounds in |
| 513 // order to compute tile priorities correctly for offscreen content that | 511 // order to compute tile priorities correctly for offscreen content that |
| 514 // is going to make it on screen. However, we also have to limit the | 512 // is going to make it on screen. However, we also have to limit the |
| 515 // viewport since it can be very large due to screen_space_transforms. As | 513 // viewport since it can be very large due to screen_space_transforms. As |
| 516 // a heuristic, we clip to bounds padded by skewport_extrapolation_limit * | 514 // a heuristic, we clip to bounds padded by skewport_extrapolation_limit * |
| 517 // maximum tiling scale, since this should allow sufficient room for | 515 // maximum tiling scale, since this should allow sufficient room for |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 | 1253 |
| 1256 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1254 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
| 1257 return !layer_tree_impl()->IsRecycleTree(); | 1255 return !layer_tree_impl()->IsRecycleTree(); |
| 1258 } | 1256 } |
| 1259 | 1257 |
| 1260 bool PictureLayerImpl::HasValidTilePriorities() const { | 1258 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1261 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1259 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
| 1262 } | 1260 } |
| 1263 | 1261 |
| 1264 } // namespace cc | 1262 } // namespace cc |
| OLD | NEW |