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 <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 ideal_contents_scale_(0.f), | 47 ideal_contents_scale_(0.f), |
48 raster_page_scale_(0.f), | 48 raster_page_scale_(0.f), |
49 raster_device_scale_(0.f), | 49 raster_device_scale_(0.f), |
50 raster_source_scale_(0.f), | 50 raster_source_scale_(0.f), |
51 raster_contents_scale_(0.f), | 51 raster_contents_scale_(0.f), |
52 low_res_raster_contents_scale_(0.f), | 52 low_res_raster_contents_scale_(0.f), |
53 raster_source_scale_was_animating_(false), | 53 raster_source_scale_was_animating_(false), |
54 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), | 54 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), |
55 needs_post_commit_initialization_(true), | 55 needs_post_commit_initialization_(true), |
56 should_update_tile_priorities_(false), | 56 should_update_tile_priorities_(false), |
57 has_gpu_rasterization_hint_(false), | |
58 should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling), | 57 should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling), |
| 58 use_gpu_rasterization_(false), |
59 layer_needs_to_register_itself_(true) {} | 59 layer_needs_to_register_itself_(true) {} |
60 | 60 |
61 PictureLayerImpl::~PictureLayerImpl() { | 61 PictureLayerImpl::~PictureLayerImpl() { |
62 if (!layer_needs_to_register_itself_) | 62 if (!layer_needs_to_register_itself_) |
63 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); | 63 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); |
64 } | 64 } |
65 | 65 |
66 const char* PictureLayerImpl::LayerTypeAsString() const { | 66 const char* PictureLayerImpl::LayerTypeAsString() const { |
67 return "cc::PictureLayerImpl"; | 67 return "cc::PictureLayerImpl"; |
68 } | 68 } |
(...skipping 20 matching lines...) Expand all Loading... |
89 | 89 |
90 LayerImpl::PushPropertiesTo(base_layer); | 90 LayerImpl::PushPropertiesTo(base_layer); |
91 | 91 |
92 // When the pending tree pushes to the active tree, the pending twin | 92 // When the pending tree pushes to the active tree, the pending twin |
93 // disappears. | 93 // disappears. |
94 layer_impl->twin_layer_ = NULL; | 94 layer_impl->twin_layer_ = NULL; |
95 twin_layer_ = NULL; | 95 twin_layer_ = NULL; |
96 | 96 |
97 layer_impl->SetIsMask(is_mask_); | 97 layer_impl->SetIsMask(is_mask_); |
98 layer_impl->pile_ = pile_; | 98 layer_impl->pile_ = pile_; |
99 layer_impl->SetHasGpuRasterizationHint(has_gpu_rasterization_hint_); | 99 layer_impl->use_gpu_rasterization_ = use_gpu_rasterization_; |
100 | 100 |
101 // Tilings would be expensive to push, so we swap. | 101 // Tilings would be expensive to push, so we swap. |
102 layer_impl->tilings_.swap(tilings_); | 102 layer_impl->tilings_.swap(tilings_); |
103 | 103 |
104 // Ensure that we don't have any tiles that are out of date. | 104 // Ensure that we don't have any tiles that are out of date. |
105 if (tilings_) | 105 if (tilings_) |
106 tilings_->RemoveTilesInRegion(invalidation_); | 106 tilings_->RemoveTilesInRegion(invalidation_); |
107 | 107 |
108 layer_impl->tilings_->SetClient(layer_impl); | 108 layer_impl->tilings_->SetClient(layer_impl); |
109 if (tilings_) | 109 if (tilings_) |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 *contents_scale_x = max_contents_scale; | 483 *contents_scale_x = max_contents_scale; |
484 *contents_scale_y = max_contents_scale; | 484 *contents_scale_y = max_contents_scale; |
485 *content_bounds = gfx::ToCeiledSize( | 485 *content_bounds = gfx::ToCeiledSize( |
486 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); | 486 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); |
487 } | 487 } |
488 | 488 |
489 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 489 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
490 return pile_->GetFlattenedPicture(); | 490 return pile_->GetFlattenedPicture(); |
491 } | 491 } |
492 | 492 |
493 void PictureLayerImpl::SetHasGpuRasterizationHint(bool has_hint) { | 493 void PictureLayerImpl::SetUseGpuRasterization(bool use_gpu) { |
494 bool old_should_use_gpu_rasterization = ShouldUseGpuRasterization(); | 494 if (use_gpu_rasterization_ == use_gpu) |
495 has_gpu_rasterization_hint_ = has_hint; | 495 return; |
496 if (ShouldUseGpuRasterization() != old_should_use_gpu_rasterization) | |
497 RemoveAllTilings(); | |
498 } | |
499 | 496 |
500 bool PictureLayerImpl::ShouldUseGpuRasterization() const { | 497 use_gpu_rasterization_ = use_gpu; |
501 switch (layer_tree_impl()->settings().rasterization_site) { | 498 RemoveAllTilings(); |
502 case LayerTreeSettings::CpuRasterization: | |
503 return false; | |
504 case LayerTreeSettings::HybridRasterization: | |
505 return has_gpu_rasterization_hint_; | |
506 case LayerTreeSettings::GpuRasterization: | |
507 return true; | |
508 } | |
509 NOTREACHED(); | |
510 return false; | |
511 } | 499 } |
512 | 500 |
513 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 501 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
514 const gfx::Rect& content_rect) { | 502 const gfx::Rect& content_rect) { |
515 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) | 503 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) |
516 return scoped_refptr<Tile>(); | 504 return scoped_refptr<Tile>(); |
517 | 505 |
518 int flags = 0; | 506 int flags = 0; |
519 if (is_using_lcd_text_) | 507 if (is_using_lcd_text_) |
520 flags |= Tile::USE_LCD_TEXT; | 508 flags |= Tile::USE_LCD_TEXT; |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 return iterator_index_ < iterators_.size(); | 1505 return iterator_index_ < iterators_.size(); |
1518 } | 1506 } |
1519 | 1507 |
1520 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1508 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1521 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1509 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1522 return it->get_type() == iteration_stage_ && | 1510 return it->get_type() == iteration_stage_ && |
1523 (**it)->required_for_activation() == required_for_activation_; | 1511 (**it)->required_for_activation() == required_for_activation_; |
1524 } | 1512 } |
1525 | 1513 |
1526 } // namespace cc | 1514 } // namespace cc |
OLD | NEW |