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

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

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 layer_impl->twin_layer_ = this; 123 layer_impl->twin_layer_ = this;
124 124
125 layer_impl->SetNearestNeighbor(nearest_neighbor_); 125 layer_impl->SetNearestNeighbor(nearest_neighbor_);
126 126
127 // Solid color layers have no tilings. 127 // Solid color layers have no tilings.
128 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); 128 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0);
129 // The pending tree should only have a high res (and possibly low res) tiling. 129 // The pending tree should only have a high res (and possibly low res) tiling.
130 DCHECK_LE(tilings_->num_tilings(), 130 DCHECK_LE(tilings_->num_tilings(),
131 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); 131 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u);
132 132
133 layer_impl->set_gpu_raster_max_texture_size(gpu_raster_max_texture_size_);
133 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, 134 layer_impl->UpdateRasterSource(raster_source_, &invalidation_,
134 tilings_.get()); 135 tilings_.get());
135 DCHECK(invalidation_.IsEmpty()); 136 DCHECK(invalidation_.IsEmpty());
136 137
137 // After syncing a solid color layer, the active layer has no tilings. 138 // After syncing a solid color layer, the active layer has no tilings.
138 DCHECK_IMPLIES(raster_source_->IsSolidColor(), 139 DCHECK_IMPLIES(raster_source_->IsSolidColor(),
139 layer_impl->tilings_->num_tilings() == 0); 140 layer_impl->tilings_->num_tilings() == 0);
140 141
141 layer_impl->raster_page_scale_ = raster_page_scale_; 142 layer_impl->raster_page_scale_ = raster_page_scale_;
142 layer_impl->raster_device_scale_ = raster_device_scale_; 143 layer_impl->raster_device_scale_ = raster_device_scale_;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 TilePriority::PriorityBin PictureLayerImpl::GetMaxTilePriorityBin() const { 660 TilePriority::PriorityBin PictureLayerImpl::GetMaxTilePriorityBin() const {
660 if (!HasValidTilePriorities()) 661 if (!HasValidTilePriorities())
661 return TilePriority::EVENTUALLY; 662 return TilePriority::EVENTUALLY;
662 return TilePriority::NOW; 663 return TilePriority::NOW;
663 } 664 }
664 665
665 bool PictureLayerImpl::RequiresHighResToDraw() const { 666 bool PictureLayerImpl::RequiresHighResToDraw() const {
666 return layer_tree_impl()->RequiresHighResToDraw(); 667 return layer_tree_impl()->RequiresHighResToDraw();
667 } 668 }
668 669
670 gfx::Rect PictureLayerImpl::GetEnclosingRectInTargetSpace() const {
671 return GetScaledEnclosingRectInTargetSpace(MaximumTilingContentsScale());
672 }
673
669 gfx::Size PictureLayerImpl::CalculateTileSize( 674 gfx::Size PictureLayerImpl::CalculateTileSize(
670 const gfx::Size& content_bounds) const { 675 const gfx::Size& content_bounds) const {
671 int max_texture_size = 676 int max_texture_size =
672 layer_tree_impl()->resource_provider()->max_texture_size(); 677 layer_tree_impl()->resource_provider()->max_texture_size();
673 678
674 if (is_mask_) { 679 if (is_mask_) {
675 // Masks are not tiled, so if we can't cover the whole mask with one tile, 680 // Masks are not tiled, so if we can't cover the whole mask with one tile,
676 // we shouldn't have such a tiling at all. 681 // we shouldn't have such a tiling at all.
677 DCHECK_LE(content_bounds.width(), max_texture_size); 682 DCHECK_LE(content_bounds.width(), max_texture_size);
678 DCHECK_LE(content_bounds.height(), max_texture_size); 683 DCHECK_LE(content_bounds.height(), max_texture_size);
679 return content_bounds; 684 return content_bounds;
680 } 685 }
681 686
682 int default_tile_width = 0; 687 int default_tile_width = 0;
683 int default_tile_height = 0; 688 int default_tile_height = 0;
684 if (layer_tree_impl()->use_gpu_rasterization()) { 689 if (layer_tree_impl()->use_gpu_rasterization()) {
685 // For GPU rasterization, we pick an ideal tile size using the viewport 690 // For GPU rasterization, we pick an ideal tile size using the viewport
686 // so we don't need any settings. The current approach uses 4 tiles 691 // so we don't need any settings. The current approach uses 4 tiles
687 // to cover the viewport vertically. 692 // to cover the viewport vertically.
688 int viewport_width = layer_tree_impl()->device_viewport_size().width(); 693 int viewport_width = gpu_raster_max_texture_size_.width();
689 int viewport_height = layer_tree_impl()->device_viewport_size().height(); 694 int viewport_height = gpu_raster_max_texture_size_.height();
690 default_tile_width = viewport_width; 695 default_tile_width = viewport_width;
691 // Also, increase the height proportionally as the width decreases, and 696 // Also, increase the height proportionally as the width decreases, and
692 // pad by our border texels to make the tiles exactly match the viewport. 697 // pad by our border texels to make the tiles exactly match the viewport.
693 int divisor = 4; 698 int divisor = 4;
694 if (content_bounds.width() <= viewport_width / 2) 699 if (content_bounds.width() <= viewport_width / 2)
695 divisor = 2; 700 divisor = 2;
696 if (content_bounds.width() <= viewport_width / 4) 701 if (content_bounds.width() <= viewport_width / 4)
697 divisor = 1; 702 divisor = 1;
698 default_tile_height = RoundUp(viewport_height, divisor) / divisor; 703 default_tile_height = RoundUp(viewport_height, divisor) / divisor;
699 default_tile_height += 2 * PictureLayerTiling::kBorderTexels; 704 default_tile_height += 2 * PictureLayerTiling::kBorderTexels;
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); 1166 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
1162 } 1167 }
1163 1168
1164 void PictureLayerImpl::GetDebugBorderProperties( 1169 void PictureLayerImpl::GetDebugBorderProperties(
1165 SkColor* color, 1170 SkColor* color,
1166 float* width) const { 1171 float* width) const {
1167 *color = DebugColors::TiledContentLayerBorderColor(); 1172 *color = DebugColors::TiledContentLayerBorderColor();
1168 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); 1173 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl());
1169 } 1174 }
1170 1175
1171 void PictureLayerImpl::GetAllTilesForTracing( 1176 void PictureLayerImpl::GetAllTilesAndPrioritiesForTracing(
1172 std::set<const Tile*>* tiles) const { 1177 std::map<const Tile*, TilePriority>* tile_map) const {
1173 if (!tilings_) 1178 if (!tilings_)
1174 return; 1179 return;
1175 tilings_->GetAllTilesForTracing(tiles); 1180 tilings_->GetAllTilesAndPrioritiesForTracing(tile_map);
1176 } 1181 }
1177 1182
1178 void PictureLayerImpl::AsValueInto( 1183 void PictureLayerImpl::AsValueInto(
1179 base::trace_event::TracedValue* state) const { 1184 base::trace_event::TracedValue* state) const {
1180 LayerImpl::AsValueInto(state); 1185 LayerImpl::AsValueInto(state);
1181 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 1186 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
1182 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); 1187 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale());
1183 state->BeginArray("tilings"); 1188 state->BeginArray("tilings");
1184 tilings_->AsValueInto(state); 1189 tilings_->AsValueInto(state);
1185 state->EndArray(); 1190 state->EndArray();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1233
1229 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1234 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1230 return !layer_tree_impl()->IsRecycleTree(); 1235 return !layer_tree_impl()->IsRecycleTree();
1231 } 1236 }
1232 1237
1233 bool PictureLayerImpl::HasValidTilePriorities() const { 1238 bool PictureLayerImpl::HasValidTilePriorities() const {
1234 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); 1239 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember();
1235 } 1240 }
1236 1241
1237 } // namespace cc 1242 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698