| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 width = DebugColors::OOMTileBorderWidth(device_scale_factor); | 270 width = DebugColors::OOMTileBorderWidth(device_scale_factor); |
| 271 } else if (iter->draw_info().has_compressed_resource()) { | 271 } else if (iter->draw_info().has_compressed_resource()) { |
| 272 color = DebugColors::CompressedTileBorderColor(); | 272 color = DebugColors::CompressedTileBorderColor(); |
| 273 width = DebugColors::CompressedTileBorderWidth(device_scale_factor); | 273 width = DebugColors::CompressedTileBorderWidth(device_scale_factor); |
| 274 } else if (iter.resolution() == HIGH_RESOLUTION) { | 274 } else if (iter.resolution() == HIGH_RESOLUTION) { |
| 275 color = DebugColors::HighResTileBorderColor(); | 275 color = DebugColors::HighResTileBorderColor(); |
| 276 width = DebugColors::HighResTileBorderWidth(device_scale_factor); | 276 width = DebugColors::HighResTileBorderWidth(device_scale_factor); |
| 277 } else if (iter.resolution() == LOW_RESOLUTION) { | 277 } else if (iter.resolution() == LOW_RESOLUTION) { |
| 278 color = DebugColors::LowResTileBorderColor(); | 278 color = DebugColors::LowResTileBorderColor(); |
| 279 width = DebugColors::LowResTileBorderWidth(device_scale_factor); | 279 width = DebugColors::LowResTileBorderWidth(device_scale_factor); |
| 280 } else if (iter->contents_scale() > max_contents_scale) { | 280 } else if (iter->contents_scale_key() > max_contents_scale) { |
| 281 color = DebugColors::ExtraHighResTileBorderColor(); | 281 color = DebugColors::ExtraHighResTileBorderColor(); |
| 282 width = DebugColors::ExtraHighResTileBorderWidth(device_scale_factor); | 282 width = DebugColors::ExtraHighResTileBorderWidth(device_scale_factor); |
| 283 } else { | 283 } else { |
| 284 color = DebugColors::ExtraLowResTileBorderColor(); | 284 color = DebugColors::ExtraLowResTileBorderColor(); |
| 285 width = DebugColors::ExtraLowResTileBorderWidth(device_scale_factor); | 285 width = DebugColors::ExtraLowResTileBorderWidth(device_scale_factor); |
| 286 } | 286 } |
| 287 } else { | 287 } else { |
| 288 color = DebugColors::MissingTileBorderColor(); | 288 color = DebugColors::MissingTileBorderColor(); |
| 289 width = DebugColors::MissingTileBorderWidth(device_scale_factor); | 289 width = DebugColors::MissingTileBorderWidth(device_scale_factor); |
| 290 } | 290 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 switch (draw_info.mode()) { | 338 switch (draw_info.mode()) { |
| 339 case TileDrawInfo::RESOURCE_MODE: { | 339 case TileDrawInfo::RESOURCE_MODE: { |
| 340 gfx::RectF texture_rect = iter.texture_rect(); | 340 gfx::RectF texture_rect = iter.texture_rect(); |
| 341 | 341 |
| 342 // The raster_contents_scale_ is the best scale that the layer is | 342 // The raster_contents_scale_ is the best scale that the layer is |
| 343 // trying to produce, even though it may not be ideal. Since that's | 343 // trying to produce, even though it may not be ideal. Since that's |
| 344 // the best the layer can promise in the future, consider those as | 344 // the best the layer can promise in the future, consider those as |
| 345 // complete. But if a tile is ideal scale, we don't want to consider | 345 // complete. But if a tile is ideal scale, we don't want to consider |
| 346 // it incomplete and trying to replace it with a tile at a worse | 346 // it incomplete and trying to replace it with a tile at a worse |
| 347 // scale. | 347 // scale. |
| 348 if (iter->contents_scale() != raster_contents_scale_ && | 348 if (iter->contents_scale_key() != raster_contents_scale_ && |
| 349 iter->contents_scale() != ideal_contents_scale_ && | 349 iter->contents_scale_key() != ideal_contents_scale_ && |
| 350 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { | 350 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { |
| 351 append_quads_data->num_incomplete_tiles++; | 351 append_quads_data->num_incomplete_tiles++; |
| 352 } | 352 } |
| 353 | 353 |
| 354 TileDrawQuad* quad = | 354 TileDrawQuad* quad = |
| 355 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 355 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 356 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 356 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
| 357 visible_geometry_rect, draw_info.resource_id(), | 357 visible_geometry_rect, draw_info.resource_id(), |
| 358 texture_rect, draw_info.resource_size(), | 358 texture_rect, draw_info.resource_size(), |
| 359 draw_info.contents_swizzled(), nearest_neighbor_); | 359 draw_info.contents_swizzled(), nearest_neighbor_); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 639 |
| 640 DCHECK(!RasterSourceUsesLCDText()); | 640 DCHECK(!RasterSourceUsesLCDText()); |
| 641 } | 641 } |
| 642 | 642 |
| 643 bool PictureLayerImpl::RasterSourceUsesLCDText() const { | 643 bool PictureLayerImpl::RasterSourceUsesLCDText() const { |
| 644 return raster_source_ ? raster_source_->CanUseLCDText() | 644 return raster_source_ ? raster_source_->CanUseLCDText() |
| 645 : layer_tree_impl()->settings().can_use_lcd_text; | 645 : layer_tree_impl()->settings().can_use_lcd_text; |
| 646 } | 646 } |
| 647 | 647 |
| 648 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 648 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
| 649 if (layer_tree_impl()->IsActiveTree()) { | 649 if (layer_tree_impl()->IsActiveTree()) |
| 650 gfx::Rect layer_damage_rect = gfx::ScaleToEnclosingRect( | 650 AddDamageRect(tile->enclosing_layer_rect()); |
| 651 tile->content_rect(), 1.f / tile->contents_scale()); | |
| 652 AddDamageRect(layer_damage_rect); | |
| 653 } | |
| 654 if (tile->draw_info().NeedsRaster()) { | 651 if (tile->draw_info().NeedsRaster()) { |
| 655 PictureLayerTiling* tiling = | 652 PictureLayerTiling* tiling = |
| 656 tilings_->FindTilingWithScaleKey(tile->contents_scale()); | 653 tilings_->FindTilingWithScaleKey(tile->contents_scale_key()); |
| 657 if (tiling) | 654 if (tiling) |
| 658 tiling->set_all_tiles_done(false); | 655 tiling->set_all_tiles_done(false); |
| 659 } | 656 } |
| 660 } | 657 } |
| 661 | 658 |
| 662 void PictureLayerImpl::DidBeginTracing() { | 659 void PictureLayerImpl::DidBeginTracing() { |
| 663 raster_source_->DidBeginTracing(); | 660 raster_source_->DidBeginTracing(); |
| 664 } | 661 } |
| 665 | 662 |
| 666 void PictureLayerImpl::ReleaseResources() { | 663 void PictureLayerImpl::ReleaseResources() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 716 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
| 720 return &twin_layer->invalidation_; | 717 return &twin_layer->invalidation_; |
| 721 return nullptr; | 718 return nullptr; |
| 722 } | 719 } |
| 723 | 720 |
| 724 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( | 721 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( |
| 725 const PictureLayerTiling* tiling) const { | 722 const PictureLayerTiling* tiling) const { |
| 726 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); | 723 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); |
| 727 if (!twin_layer) | 724 if (!twin_layer) |
| 728 return nullptr; | 725 return nullptr; |
| 729 return twin_layer->tilings_->FindTilingWithScaleKey(tiling->contents_scale()); | 726 const PictureLayerTiling* twin_tiling = |
| 727 twin_layer->tilings_->FindTilingWithScaleKey( |
| 728 tiling->contents_scale_key()); |
| 729 DCHECK(tiling->raster_transform().translation() == gfx::Vector2dF()); |
| 730 DCHECK(!twin_tiling || |
| 731 twin_tiling->raster_transform().translation() == gfx::Vector2dF()); |
| 732 return twin_tiling; |
| 730 } | 733 } |
| 731 | 734 |
| 732 bool PictureLayerImpl::RequiresHighResToDraw() const { | 735 bool PictureLayerImpl::RequiresHighResToDraw() const { |
| 733 return layer_tree_impl()->RequiresHighResToDraw(); | 736 return layer_tree_impl()->RequiresHighResToDraw(); |
| 734 } | 737 } |
| 735 | 738 |
| 736 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { | 739 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { |
| 737 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); | 740 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); |
| 738 } | 741 } |
| 739 | 742 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 | 883 |
| 881 use_transformed_rasterization_ = use; | 884 use_transformed_rasterization_ = use; |
| 882 NoteLayerPropertyChanged(); | 885 NoteLayerPropertyChanged(); |
| 883 } | 886 } |
| 884 | 887 |
| 885 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 888 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
| 886 DCHECK(CanHaveTilings()); | 889 DCHECK(CanHaveTilings()); |
| 887 DCHECK_GE(contents_scale, MinimumContentsScale()); | 890 DCHECK_GE(contents_scale, MinimumContentsScale()); |
| 888 DCHECK_LE(contents_scale, MaximumContentsScale()); | 891 DCHECK_LE(contents_scale, MaximumContentsScale()); |
| 889 DCHECK(raster_source_->HasRecordings()); | 892 DCHECK(raster_source_->HasRecordings()); |
| 890 return tilings_->AddTiling(contents_scale, raster_source_); | 893 return tilings_->AddTiling( |
| 894 gfx::AxisTransform2d(contents_scale, gfx::Vector2dF()), raster_source_); |
| 891 } | 895 } |
| 892 | 896 |
| 893 void PictureLayerImpl::RemoveAllTilings() { | 897 void PictureLayerImpl::RemoveAllTilings() { |
| 894 tilings_->RemoveAllTilings(); | 898 tilings_->RemoveAllTilings(); |
| 895 // If there are no tilings, then raster scales are no longer meaningful. | 899 // If there are no tilings, then raster scales are no longer meaningful. |
| 896 ResetRasterScale(); | 900 ResetRasterScale(); |
| 897 } | 901 } |
| 898 | 902 |
| 899 void PictureLayerImpl::AddTilingsForRasterScale() { | 903 void PictureLayerImpl::AddTilingsForRasterScale() { |
| 900 // Reset all resolution enums on tilings, we'll be setting new values in this | 904 // Reset all resolution enums on tilings, we'll be setting new values in this |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 } | 1406 } |
| 1403 | 1407 |
| 1404 invalidation_.Union(invalidation); | 1408 invalidation_.Union(invalidation); |
| 1405 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); | 1409 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); |
| 1406 SetNeedsPushProperties(); | 1410 SetNeedsPushProperties(); |
| 1407 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", | 1411 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", |
| 1408 "Invalidation", invalidation.ToString()); | 1412 "Invalidation", invalidation.ToString()); |
| 1409 } | 1413 } |
| 1410 | 1414 |
| 1411 } // namespace cc | 1415 } // namespace cc |
| OLD | NEW |