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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 // Ensure that tile width and height are properly aligned. | 844 // Ensure that tile width and height are properly aligned. |
845 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment); | 845 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment); |
846 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment); | 846 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment); |
847 | 847 |
848 // Under no circumstance should we be larger than the max texture size. | 848 // Under no circumstance should we be larger than the max texture size. |
849 tile_width = std::min(tile_width, max_texture_size); | 849 tile_width = std::min(tile_width, max_texture_size); |
850 tile_height = std::min(tile_height, max_texture_size); | 850 tile_height = std::min(tile_height, max_texture_size); |
851 return gfx::Size(tile_width, tile_height); | 851 return gfx::Size(tile_width, tile_height); |
852 } | 852 } |
853 | 853 |
854 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, | 854 void PictureLayerImpl::GetContentsResourceId( |
855 gfx::Size* resource_size) const { | 855 ResourceId* resource_id, |
| 856 gfx::Size* resource_size, |
| 857 gfx::SizeF* resource_uv_size) const { |
856 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 858 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
857 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 859 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
858 DCHECK(raster_source_->GetSize().IsEmpty() || | 860 DCHECK(raster_source_->GetSize().IsEmpty() || |
859 bounds() == raster_source_->GetSize()) | 861 bounds() == raster_source_->GetSize()) |
860 << " bounds " << bounds().ToString() << " pile " | 862 << " bounds " << bounds().ToString() << " pile " |
861 << raster_source_->GetSize().ToString(); | 863 << raster_source_->GetSize().ToString(); |
862 float dest_scale = MaximumTilingContentsScale(); | 864 float dest_scale = MaximumTilingContentsScale(); |
863 gfx::Rect content_rect = | 865 gfx::Rect content_rect = |
864 gfx::ScaleToEnclosingRect(gfx::Rect(bounds()), dest_scale); | 866 gfx::ScaleToEnclosingRect(gfx::Rect(bounds()), dest_scale); |
865 PictureLayerTilingSet::CoverageIterator iter( | 867 PictureLayerTilingSet::CoverageIterator iter( |
(...skipping 12 matching lines...) Expand all Loading... |
878 | 880 |
879 const TileDrawInfo& draw_info = iter->draw_info(); | 881 const TileDrawInfo& draw_info = iter->draw_info(); |
880 if (!draw_info.IsReadyToDraw() || | 882 if (!draw_info.IsReadyToDraw() || |
881 draw_info.mode() != TileDrawInfo::RESOURCE_MODE) { | 883 draw_info.mode() != TileDrawInfo::RESOURCE_MODE) { |
882 *resource_id = 0; | 884 *resource_id = 0; |
883 return; | 885 return; |
884 } | 886 } |
885 | 887 |
886 *resource_id = draw_info.resource_id(); | 888 *resource_id = draw_info.resource_id(); |
887 *resource_size = draw_info.resource_size(); | 889 *resource_size = draw_info.resource_size(); |
| 890 // |resource_uv_size| represents the range of UV coordinates that map to the |
| 891 // content being drawn. Typically, we draw to the entire texture, so these |
| 892 // coordinates are (1.0f, 1.0f). However, if we are rasterizing to an |
| 893 // over-large texture, this size will be smaller, mapping to the subset of the |
| 894 // texture being used. |
| 895 gfx::SizeF requested_tile_size = |
| 896 gfx::SizeF(iter->tiling()->tiling_data()->tiling_size()); |
| 897 DCHECK_LE(requested_tile_size.width(), draw_info.resource_size().width()); |
| 898 DCHECK_LE(requested_tile_size.height(), draw_info.resource_size().height()); |
| 899 *resource_uv_size = gfx::SizeF( |
| 900 requested_tile_size.width() / draw_info.resource_size().width(), |
| 901 requested_tile_size.height() / draw_info.resource_size().height()); |
888 } | 902 } |
889 | 903 |
890 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { | 904 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { |
891 if (nearest_neighbor_ == nearest_neighbor) | 905 if (nearest_neighbor_ == nearest_neighbor) |
892 return; | 906 return; |
893 | 907 |
894 nearest_neighbor_ = nearest_neighbor; | 908 nearest_neighbor_ = nearest_neighbor; |
895 NoteLayerPropertyChanged(); | 909 NoteLayerPropertyChanged(); |
896 } | 910 } |
897 | 911 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 } | 1438 } |
1425 | 1439 |
1426 invalidation_.Union(invalidation); | 1440 invalidation_.Union(invalidation); |
1427 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); | 1441 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); |
1428 SetNeedsPushProperties(); | 1442 SetNeedsPushProperties(); |
1429 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", | 1443 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", |
1430 "Invalidation", invalidation.ToString()); | 1444 "Invalidation", invalidation.ToString()); |
1431 } | 1445 } |
1432 | 1446 |
1433 } // namespace cc | 1447 } // namespace cc |
OLD | NEW |