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 <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 Loading... | |
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->UpdateRasterSource(raster_source_, &invalidation_, | 133 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, tilings_.get(), |
134 tilings_.get()); | 134 gpu_raster_max_texture_size_); |
135 DCHECK(invalidation_.IsEmpty()); | 135 DCHECK(invalidation_.IsEmpty()); |
136 | 136 |
137 // After syncing a solid color layer, the active layer has no tilings. | 137 // After syncing a solid color layer, the active layer has no tilings. |
138 DCHECK_IMPLIES(raster_source_->IsSolidColor(), | 138 DCHECK_IMPLIES(raster_source_->IsSolidColor(), |
139 layer_impl->tilings_->num_tilings() == 0); | 139 layer_impl->tilings_->num_tilings() == 0); |
140 | 140 |
141 layer_impl->raster_page_scale_ = raster_page_scale_; | 141 layer_impl->raster_page_scale_ = raster_page_scale_; |
142 layer_impl->raster_device_scale_ = raster_device_scale_; | 142 layer_impl->raster_device_scale_ = raster_device_scale_; |
143 layer_impl->raster_source_scale_ = raster_source_scale_; | 143 layer_impl->raster_source_scale_ = raster_source_scale_; |
144 layer_impl->raster_contents_scale_ = raster_contents_scale_; | 144 layer_impl->raster_contents_scale_ = raster_contents_scale_; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 496 |
497 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { | 497 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { |
498 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) | 498 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) |
499 return nullptr; | 499 return nullptr; |
500 return twin_layer_; | 500 return twin_layer_; |
501 } | 501 } |
502 | 502 |
503 void PictureLayerImpl::UpdateRasterSource( | 503 void PictureLayerImpl::UpdateRasterSource( |
504 scoped_refptr<RasterSource> raster_source, | 504 scoped_refptr<RasterSource> raster_source, |
505 Region* new_invalidation, | 505 Region* new_invalidation, |
506 const PictureLayerTilingSet* pending_set) { | 506 const PictureLayerTilingSet* pending_set, |
507 gfx::Size gpu_raster_max_texture_size) { | |
508 gpu_raster_max_texture_size_ = gpu_raster_max_texture_size; | |
vmpstr
2015/03/19 23:14:39
It kind of feels like this can be a separate funct
| |
509 | |
507 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 510 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
508 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 511 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
509 DCHECK_IMPLIES(!raster_source->GetSize().IsEmpty(), | 512 DCHECK_IMPLIES(!raster_source->GetSize().IsEmpty(), |
510 bounds() == raster_source->GetSize()) | 513 bounds() == raster_source->GetSize()) |
511 << " bounds " << bounds().ToString() << " pile " | 514 << " bounds " << bounds().ToString() << " pile " |
512 << raster_source->GetSize().ToString(); | 515 << raster_source->GetSize().ToString(); |
513 | 516 |
514 // The |raster_source_| is initially null, so have to check for that for the | 517 // The |raster_source_| is initially null, so have to check for that for the |
515 // first frame. | 518 // first frame. |
516 bool could_have_tilings = raster_source_.get() && CanHaveTilings(); | 519 bool could_have_tilings = raster_source_.get() && CanHaveTilings(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 if (can_use_lcd_text() == RasterSourceUsesLCDText()) | 558 if (can_use_lcd_text() == RasterSourceUsesLCDText()) |
556 return; | 559 return; |
557 | 560 |
558 // Raster sources are considered const, so in order to update the state | 561 // Raster sources are considered const, so in order to update the state |
559 // a new one must be created and all tiles recreated. | 562 // a new one must be created and all tiles recreated. |
560 scoped_refptr<RasterSource> new_raster_source = | 563 scoped_refptr<RasterSource> new_raster_source = |
561 raster_source_->CreateCloneWithoutLCDText(); | 564 raster_source_->CreateCloneWithoutLCDText(); |
562 // Synthetically invalidate everything. | 565 // Synthetically invalidate everything. |
563 gfx::Rect bounds_rect(bounds()); | 566 gfx::Rect bounds_rect(bounds()); |
564 Region invalidation(bounds_rect); | 567 Region invalidation(bounds_rect); |
565 UpdateRasterSource(new_raster_source, &invalidation, nullptr); | 568 UpdateRasterSource(new_raster_source, &invalidation, nullptr, |
569 gpu_raster_max_texture_size_); | |
566 SetUpdateRect(bounds_rect); | 570 SetUpdateRect(bounds_rect); |
567 | 571 |
568 DCHECK(!RasterSourceUsesLCDText()); | 572 DCHECK(!RasterSourceUsesLCDText()); |
569 } | 573 } |
570 | 574 |
571 bool PictureLayerImpl::RasterSourceUsesLCDText() const { | 575 bool PictureLayerImpl::RasterSourceUsesLCDText() const { |
572 return raster_source_ ? raster_source_->CanUseLCDText() | 576 return raster_source_ ? raster_source_->CanUseLCDText() |
573 : layer_tree_impl()->settings().can_use_lcd_text; | 577 : layer_tree_impl()->settings().can_use_lcd_text; |
574 } | 578 } |
575 | 579 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 DCHECK_LE(content_bounds.height(), max_texture_size); | 682 DCHECK_LE(content_bounds.height(), max_texture_size); |
679 return content_bounds; | 683 return content_bounds; |
680 } | 684 } |
681 | 685 |
682 int default_tile_width = 0; | 686 int default_tile_width = 0; |
683 int default_tile_height = 0; | 687 int default_tile_height = 0; |
684 if (layer_tree_impl()->use_gpu_rasterization()) { | 688 if (layer_tree_impl()->use_gpu_rasterization()) { |
685 // For GPU rasterization, we pick an ideal tile size using the viewport | 689 // 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 | 690 // so we don't need any settings. The current approach uses 4 tiles |
687 // to cover the viewport vertically. | 691 // to cover the viewport vertically. |
688 int viewport_width = layer_tree_impl()->device_viewport_size().width(); | 692 int viewport_width = gpu_raster_max_texture_size_.width(); |
689 int viewport_height = layer_tree_impl()->device_viewport_size().height(); | 693 int viewport_height = gpu_raster_max_texture_size_.height(); |
690 default_tile_width = viewport_width; | 694 default_tile_width = viewport_width; |
691 // Also, increase the height proportionally as the width decreases, and | 695 // Also, increase the height proportionally as the width decreases, and |
692 // pad by our border texels to make the tiles exactly match the viewport. | 696 // pad by our border texels to make the tiles exactly match the viewport. |
693 int divisor = 4; | 697 int divisor = 4; |
694 if (content_bounds.width() <= viewport_width / 2) | 698 if (content_bounds.width() <= viewport_width / 2) |
695 divisor = 2; | 699 divisor = 2; |
696 if (content_bounds.width() <= viewport_width / 4) | 700 if (content_bounds.width() <= viewport_width / 4) |
697 divisor = 1; | 701 divisor = 1; |
698 default_tile_height = RoundUp(viewport_height, divisor) / divisor; | 702 default_tile_height = RoundUp(viewport_height, divisor) / divisor; |
699 default_tile_height += 2 * PictureLayerTiling::kBorderTexels; | 703 default_tile_height += 2 * PictureLayerTiling::kBorderTexels; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1228 | 1232 |
1229 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1233 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1230 return !layer_tree_impl()->IsRecycleTree(); | 1234 return !layer_tree_impl()->IsRecycleTree(); |
1231 } | 1235 } |
1232 | 1236 |
1233 bool PictureLayerImpl::HasValidTilePriorities() const { | 1237 bool PictureLayerImpl::HasValidTilePriorities() const { |
1234 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1238 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1235 } | 1239 } |
1236 | 1240 |
1237 } // namespace cc | 1241 } // namespace cc |
OLD | NEW |