| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/content_layer.h" | 5 #include "cc/layers/content_layer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 void ContentLayer::SetTexturePriorities( | 62 void ContentLayer::SetTexturePriorities( |
| 63 const PriorityCalculator& priority_calc) { | 63 const PriorityCalculator& priority_calc) { |
| 64 // Update the tile data before creating all the layer's tiles. | 64 // Update the tile data before creating all the layer's tiles. |
| 65 UpdateTileSizeAndTilingOption(); | 65 UpdateTileSizeAndTilingOption(); |
| 66 | 66 |
| 67 TiledLayer::SetTexturePriorities(priority_calc); | 67 TiledLayer::SetTexturePriorities(priority_calc); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ContentLayer::Update(ResourceUpdateQueue* queue, | 70 void ContentLayer::Update(ResourceUpdateQueue* queue, |
| 71 const OcclusionTracker* occlusion, | 71 const OcclusionTracker* occlusion) { |
| 72 RenderingStats* stats) { | |
| 73 { | 72 { |
| 74 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, | 73 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, |
| 75 true); | 74 true); |
| 76 | 75 |
| 77 CreateUpdaterIfNeeded(); | 76 CreateUpdaterIfNeeded(); |
| 78 UpdateCanUseLCDText(); | 77 UpdateCanUseLCDText(); |
| 79 } | 78 } |
| 80 | 79 |
| 81 TiledLayer::Update(queue, occlusion, stats); | 80 TiledLayer::Update(queue, occlusion); |
| 82 needs_display_ = false; | 81 needs_display_ = false; |
| 83 } | 82 } |
| 84 | 83 |
| 85 bool ContentLayer::NeedMoreUpdates() { | 84 bool ContentLayer::NeedMoreUpdates() { |
| 86 return NeedsIdlePaint(); | 85 return NeedsIdlePaint(); |
| 87 } | 86 } |
| 88 | 87 |
| 89 LayerUpdater* ContentLayer::Updater() const { | 88 LayerUpdater* ContentLayer::Updater() const { |
| 90 return updater_.get(); | 89 return updater_.get(); |
| 91 } | 90 } |
| 92 | 91 |
| 93 void ContentLayer::CreateUpdaterIfNeeded() { | 92 void ContentLayer::CreateUpdaterIfNeeded() { |
| 94 if (updater_) | 93 if (updater_) |
| 95 return; | 94 return; |
| 96 scoped_ptr<LayerPainter> painter = | 95 scoped_ptr<LayerPainter> painter = |
| 97 ContentLayerPainter::Create(client_).PassAs<LayerPainter>(); | 96 ContentLayerPainter::Create(client_).PassAs<LayerPainter>(); |
| 98 if (layer_tree_host()->settings().accelerate_painting) | 97 if (layer_tree_host()->settings().accelerate_painting) |
| 99 updater_ = SkPictureContentLayerUpdater::Create(painter.Pass()); | 98 updater_ = SkPictureContentLayerUpdater::Create( |
| 99 painter.Pass(), |
| 100 rendering_stats_instrumentation()); |
| 100 else if (layer_tree_host()->settings().per_tile_painting_enabled) | 101 else if (layer_tree_host()->settings().per_tile_painting_enabled) |
| 101 updater_ = BitmapSkPictureContentLayerUpdater::Create(painter.Pass()); | 102 updater_ = BitmapSkPictureContentLayerUpdater::Create( |
| 103 painter.Pass(), |
| 104 rendering_stats_instrumentation()); |
| 102 else | 105 else |
| 103 updater_ = BitmapContentLayerUpdater::Create(painter.Pass()); | 106 updater_ = BitmapContentLayerUpdater::Create( |
| 107 painter.Pass(), |
| 108 rendering_stats_instrumentation()); |
| 104 updater_->SetOpaque(contents_opaque()); | 109 updater_->SetOpaque(contents_opaque()); |
| 105 | 110 |
| 106 unsigned texture_format = | 111 unsigned texture_format = |
| 107 layer_tree_host()->GetRendererCapabilities().best_texture_format; | 112 layer_tree_host()->GetRendererCapabilities().best_texture_format; |
| 108 SetTextureFormat(texture_format); | 113 SetTextureFormat(texture_format); |
| 109 } | 114 } |
| 110 | 115 |
| 111 void ContentLayer::SetContentsOpaque(bool opaque) { | 116 void ContentLayer::SetContentsOpaque(bool opaque) { |
| 112 Layer::SetContentsOpaque(opaque); | 117 Layer::SetContentsOpaque(opaque); |
| 113 if (updater_) | 118 if (updater_) |
| 114 updater_->SetOpaque(opaque); | 119 updater_->SetOpaque(opaque); |
| 115 } | 120 } |
| 116 | 121 |
| 117 void ContentLayer::UpdateCanUseLCDText() { | 122 void ContentLayer::UpdateCanUseLCDText() { |
| 118 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) | 123 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) |
| 119 return; | 124 return; |
| 120 | 125 |
| 121 can_use_lcd_text_last_frame_ = can_use_lcd_text(); | 126 can_use_lcd_text_last_frame_ = can_use_lcd_text(); |
| 122 if (client_) | 127 if (client_) |
| 123 client_->DidChangeLayerCanUseLCDText(); | 128 client_->DidChangeLayerCanUseLCDText(); |
| 124 } | 129 } |
| 125 | 130 |
| 126 } // namespace cc | 131 } // namespace cc |
| OLD | NEW |