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 SimpleEnclosedRegion PictureLayerImpl::VisibleOpaqueRegion() const { | 659 SimpleEnclosedRegion PictureLayerImpl::VisibleOpaqueRegion() const { |
663 if (use_transformed_rasterization_) | 660 if (use_transformed_rasterization_) |
664 return SimpleEnclosedRegion(); | 661 return SimpleEnclosedRegion(); |
665 return LayerImpl::VisibleOpaqueRegion(); | 662 return LayerImpl::VisibleOpaqueRegion(); |
666 } | 663 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 722 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
726 return &twin_layer->invalidation_; | 723 return &twin_layer->invalidation_; |
727 return nullptr; | 724 return nullptr; |
728 } | 725 } |
729 | 726 |
730 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( | 727 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( |
731 const PictureLayerTiling* tiling) const { | 728 const PictureLayerTiling* tiling) const { |
732 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); | 729 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); |
733 if (!twin_layer) | 730 if (!twin_layer) |
734 return nullptr; | 731 return nullptr; |
735 return twin_layer->tilings_->FindTilingWithScaleKey(tiling->contents_scale()); | 732 const PictureLayerTiling* twin_tiling = |
| 733 twin_layer->tilings_->FindTilingWithScaleKey( |
| 734 tiling->contents_scale_key()); |
| 735 DCHECK(tiling->raster_transform().translation() == gfx::Vector2dF()); |
| 736 DCHECK(!twin_tiling || |
| 737 twin_tiling->raster_transform().translation() == gfx::Vector2dF()); |
| 738 return twin_tiling; |
736 } | 739 } |
737 | 740 |
738 bool PictureLayerImpl::RequiresHighResToDraw() const { | 741 bool PictureLayerImpl::RequiresHighResToDraw() const { |
739 return layer_tree_impl()->RequiresHighResToDraw(); | 742 return layer_tree_impl()->RequiresHighResToDraw(); |
740 } | 743 } |
741 | 744 |
742 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { | 745 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const { |
743 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); | 746 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale()); |
744 } | 747 } |
745 | 748 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 889 |
887 use_transformed_rasterization_ = use; | 890 use_transformed_rasterization_ = use; |
888 NoteLayerPropertyChanged(); | 891 NoteLayerPropertyChanged(); |
889 } | 892 } |
890 | 893 |
891 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 894 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
892 DCHECK(CanHaveTilings()); | 895 DCHECK(CanHaveTilings()); |
893 DCHECK_GE(contents_scale, MinimumContentsScale()); | 896 DCHECK_GE(contents_scale, MinimumContentsScale()); |
894 DCHECK_LE(contents_scale, MaximumContentsScale()); | 897 DCHECK_LE(contents_scale, MaximumContentsScale()); |
895 DCHECK(raster_source_->HasRecordings()); | 898 DCHECK(raster_source_->HasRecordings()); |
896 return tilings_->AddTiling(contents_scale, raster_source_); | 899 return tilings_->AddTiling(ScaleTranslate2d(contents_scale, gfx::Vector2dF()), |
| 900 raster_source_); |
897 } | 901 } |
898 | 902 |
899 void PictureLayerImpl::RemoveAllTilings() { | 903 void PictureLayerImpl::RemoveAllTilings() { |
900 tilings_->RemoveAllTilings(); | 904 tilings_->RemoveAllTilings(); |
901 // If there are no tilings, then raster scales are no longer meaningful. | 905 // If there are no tilings, then raster scales are no longer meaningful. |
902 ResetRasterScale(); | 906 ResetRasterScale(); |
903 } | 907 } |
904 | 908 |
905 void PictureLayerImpl::AddTilingsForRasterScale() { | 909 void PictureLayerImpl::AddTilingsForRasterScale() { |
906 // Reset all resolution enums on tilings, we'll be setting new values in this | 910 // 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... |
1408 } | 1412 } |
1409 | 1413 |
1410 invalidation_.Union(invalidation); | 1414 invalidation_.Union(invalidation); |
1411 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); | 1415 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); |
1412 SetNeedsPushProperties(); | 1416 SetNeedsPushProperties(); |
1413 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", | 1417 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", |
1414 "Invalidation", invalidation.ToString()); | 1418 "Invalidation", invalidation.ToString()); |
1415 } | 1419 } |
1416 | 1420 |
1417 } // namespace cc | 1421 } // namespace cc |
OLD | NEW |