Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 2828353003: Determine mask UVs based on texture size (Closed)
Patch Set: small fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 // Ensure that tile width and height are properly aligned. 833 // Ensure that tile width and height are properly aligned.
834 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment); 834 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment);
835 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment); 835 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment);
836 836
837 // Under no circumstance should we be larger than the max texture size. 837 // Under no circumstance should we be larger than the max texture size.
838 tile_width = std::min(tile_width, max_texture_size); 838 tile_width = std::min(tile_width, max_texture_size);
839 tile_height = std::min(tile_height, max_texture_size); 839 tile_height = std::min(tile_height, max_texture_size);
840 return gfx::Size(tile_width, tile_height); 840 return gfx::Size(tile_width, tile_height);
841 } 841 }
842 842
843 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, 843 void PictureLayerImpl::GetContentsResourceId(
844 gfx::Size* resource_size) const { 844 ResourceId* resource_id,
845 gfx::Size* resource_size,
846 gfx::SizeF* resource_uv_size) const {
845 // The bounds and the pile size may differ if the pile wasn't updated (ie. 847 // The bounds and the pile size may differ if the pile wasn't updated (ie.
846 // PictureLayer::Update didn't happen). In that case the pile will be empty. 848 // PictureLayer::Update didn't happen). In that case the pile will be empty.
847 DCHECK(raster_source_->GetSize().IsEmpty() || 849 DCHECK(raster_source_->GetSize().IsEmpty() ||
848 bounds() == raster_source_->GetSize()) 850 bounds() == raster_source_->GetSize())
849 << " bounds " << bounds().ToString() << " pile " 851 << " bounds " << bounds().ToString() << " pile "
850 << raster_source_->GetSize().ToString(); 852 << raster_source_->GetSize().ToString();
851 float dest_scale = MaximumTilingContentsScale(); 853 float dest_scale = MaximumTilingContentsScale();
852 gfx::Rect content_rect = 854 gfx::Rect content_rect =
853 gfx::ScaleToEnclosingRect(gfx::Rect(bounds()), dest_scale); 855 gfx::ScaleToEnclosingRect(gfx::Rect(bounds()), dest_scale);
854 PictureLayerTilingSet::CoverageIterator iter( 856 PictureLayerTilingSet::CoverageIterator iter(
(...skipping 12 matching lines...) Expand all
867 869
868 const TileDrawInfo& draw_info = iter->draw_info(); 870 const TileDrawInfo& draw_info = iter->draw_info();
869 if (!draw_info.IsReadyToDraw() || 871 if (!draw_info.IsReadyToDraw() ||
870 draw_info.mode() != TileDrawInfo::RESOURCE_MODE) { 872 draw_info.mode() != TileDrawInfo::RESOURCE_MODE) {
871 *resource_id = 0; 873 *resource_id = 0;
872 return; 874 return;
873 } 875 }
874 876
875 *resource_id = draw_info.resource_id(); 877 *resource_id = draw_info.resource_id();
876 *resource_size = draw_info.resource_size(); 878 *resource_size = draw_info.resource_size();
879 // |resource_uv_size| represents the range of UV coordinates that map to the
880 // content being drawn. Typically, we draw to the entire texture, so these
881 // coordinatesis are (1.0f, 1.0f). However, if we are rasterizing to an
enne (OOO) 2017/05/02 21:31:37 typo
ericrk 2017/05/04 19:23:53 Done.
882 // over-large texture, this size will be smaller, mapping to the subset of the
883 // texture being used.
884 gfx::SizeF requested_tile_size =
885 gfx::SizeF(iter->tiling()->tiling_data()->tiling_size());
enne (OOO) 2017/05/02 21:31:37 Is this the same as bounds()?
ericrk 2017/05/04 19:23:53 Most of the time, yes. In certain cases, bounds ap
886 DCHECK_LE(requested_tile_size.width(), draw_info.resource_size().width());
887 DCHECK_LE(requested_tile_size.height(), draw_info.resource_size().height());
888 *resource_uv_size = gfx::SizeF(
889 requested_tile_size.width() / draw_info.resource_size().width(),
890 requested_tile_size.height() / draw_info.resource_size().height());
877 } 891 }
878 892
879 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { 893 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) {
880 if (nearest_neighbor_ == nearest_neighbor) 894 if (nearest_neighbor_ == nearest_neighbor)
881 return; 895 return;
882 896
883 nearest_neighbor_ = nearest_neighbor; 897 nearest_neighbor_ = nearest_neighbor;
884 NoteLayerPropertyChanged(); 898 NoteLayerPropertyChanged();
885 } 899 }
886 900
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 } 1427 }
1414 1428
1415 invalidation_.Union(invalidation); 1429 invalidation_.Union(invalidation);
1416 tilings_->UpdateTilingsForImplSideInvalidation(invalidation); 1430 tilings_->UpdateTilingsForImplSideInvalidation(invalidation);
1417 SetNeedsPushProperties(); 1431 SetNeedsPushProperties();
1418 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages", 1432 TRACE_EVENT_END1("cc", "PictureLayerImpl::InvalidateRegionForImages",
1419 "Invalidation", invalidation.ToString()); 1433 "Invalidation", invalidation.ToString());
1420 } 1434 }
1421 1435
1422 } // namespace cc 1436 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698