Chromium Code Reviews| 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.h" | 5 #include "cc/layers/picture_layer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "cc/layers/content_layer_client.h" | 8 #include "cc/layers/content_layer_client.h" |
| 9 #include "cc/layers/picture_layer_impl.h" | 9 #include "cc/layers/picture_layer_impl.h" |
| 10 #include "cc/trees/layer_tree_impl.h" | 10 #include "cc/trees/layer_tree_impl.h" |
| 11 #include "third_party/skia/include/core/SkPictureRecorder.h" | 11 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 12 #include "ui/gfx/geometry/rect_conversions.h" | 12 #include "ui/gfx/geometry/rect_conversions.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { | 16 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |
| 17 return make_scoped_refptr(new PictureLayer(client)); | 17 return make_scoped_refptr(new PictureLayer(client)); |
| 18 } | 18 } |
| 19 | 19 |
| 20 PictureLayer::PictureLayer(ContentLayerClient* client) | 20 PictureLayer::PictureLayer(ContentLayerClient* client) |
| 21 : client_(client), | 21 : client_(client), |
| 22 recording_source_(new PicturePile), | 22 recording_source_(new PicturePile), |
| 23 instrumentation_object_tracker_(id()), | 23 instrumentation_object_tracker_(id()), |
| 24 update_source_frame_number_(-1), | 24 update_source_frame_number_(-1), |
| 25 can_use_lcd_text_last_frame_(can_use_lcd_text()) { | 25 can_use_lcd_text_for_update_(true) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 PictureLayer::~PictureLayer() { | 28 PictureLayer::~PictureLayer() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 31 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 32 return PictureLayerImpl::Create(tree_impl, id()); | 32 return PictureLayerImpl::Create(tree_impl, id()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { | 35 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 // Workaround for http://crbug.com/235910 - to retain backwards compat | 119 // Workaround for http://crbug.com/235910 - to retain backwards compat |
| 120 // the full page content must always be provided in the picture layer. | 120 // the full page content must always be provided in the picture layer. |
| 121 visible_layer_rect = gfx::Rect(layer_size); | 121 visible_layer_rect = gfx::Rect(layer_size); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // UpdateAndExpandInvalidation will give us an invalidation that covers | 124 // UpdateAndExpandInvalidation will give us an invalidation that covers |
| 125 // anything not explicitly recorded in this frame. We give this region | 125 // anything not explicitly recorded in this frame. We give this region |
| 126 // to the impl side so that it drops tiles that may not have a recording | 126 // to the impl side so that it drops tiles that may not have a recording |
| 127 // for them. | 127 // for them. |
| 128 DCHECK(client_); | 128 DCHECK(client_); |
| 129 bool can_use_lcd_text = | |
| 130 can_use_lcd_text_for_update_ == LCD_TEXT_STATE_ALLOWED; | |
|
enne (OOO)
2014/11/12 21:47:30
Er, isn't can_use_lcd_text_for_update_ now a bool?
danakj
2014/11/12 21:47:52
Er, how did this compile?
| |
| 129 updated |= recording_source_->UpdateAndExpandInvalidation( | 131 updated |= recording_source_->UpdateAndExpandInvalidation( |
| 130 client_, &recording_invalidation_, SafeOpaqueBackgroundColor(), | 132 client_, &recording_invalidation_, SafeOpaqueBackgroundColor(), |
| 131 contents_opaque(), client_->FillsBoundsCompletely(), layer_size, | 133 contents_opaque(), client_->FillsBoundsCompletely(), can_use_lcd_text, |
| 132 visible_layer_rect, update_source_frame_number_, | 134 layer_size, visible_layer_rect, update_source_frame_number_, |
| 133 Picture::RECORD_NORMALLY); | 135 Picture::RECORD_NORMALLY); |
| 134 last_updated_visible_content_rect_ = visible_content_rect(); | 136 last_updated_visible_content_rect_ = visible_content_rect(); |
| 135 | 137 |
| 136 if (updated) { | 138 if (updated) { |
| 137 SetNeedsPushProperties(); | 139 SetNeedsPushProperties(); |
| 138 } else { | 140 } else { |
| 139 // If this invalidation did not affect the pile, then it can be cleared as | 141 // If this invalidation did not affect the pile, then it can be cleared as |
| 140 // an optimization. | 142 // an optimization. |
| 141 recording_invalidation_.Clear(); | 143 recording_invalidation_.Clear(); |
| 142 } | 144 } |
| 143 | 145 |
| 144 return updated; | 146 return updated; |
| 145 } | 147 } |
| 146 | 148 |
| 147 void PictureLayer::SetIsMask(bool is_mask) { | 149 void PictureLayer::SetIsMask(bool is_mask) { |
| 148 recording_source_->SetIsMask(is_mask); | 150 recording_source_->SetIsMask(is_mask); |
| 149 } | 151 } |
| 150 | 152 |
| 151 bool PictureLayer::SupportsLCDText() const { | 153 bool PictureLayer::SupportsLCDText() const { |
| 152 return true; | 154 return true; |
| 153 } | 155 } |
| 154 | 156 |
| 155 void PictureLayer::UpdateCanUseLCDText() { | 157 void PictureLayer::UpdateCanUseLCDText() { |
| 156 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) | 158 if (!can_use_lcd_text_for_update_) |
| 159 return; // Don't allow the LcdTextState to change once disabled. | |
| 160 if (can_use_lcd_text_for_update_ == can_use_lcd_text()) | |
| 157 return; | 161 return; |
| 158 | 162 |
| 159 can_use_lcd_text_last_frame_ = can_use_lcd_text(); | 163 can_use_lcd_text_for_update_ = can_use_lcd_text(); |
| 160 if (client_) | 164 client_->DidChangeLayerCanUseLcdText(); |
| 161 client_->DidChangeLayerCanUseLCDText(); | |
| 162 } | 165 } |
| 163 | 166 |
| 164 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { | 167 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { |
| 165 // We could either flatten the PicturePile into a single SkPicture, | 168 // We could either flatten the PicturePile into a single SkPicture, |
| 166 // or paint a fresh one depending on what we intend to do with the | 169 // or paint a fresh one depending on what we intend to do with the |
| 167 // picture. For now we just paint a fresh one to get consistent results. | 170 // picture. For now we just paint a fresh one to get consistent results. |
| 168 if (!DrawsContent()) | 171 if (!DrawsContent()) |
| 169 return skia::RefPtr<SkPicture>(); | 172 return skia::RefPtr<SkPicture>(); |
| 170 | 173 |
| 171 int width = bounds().width(); | 174 int width = bounds().width(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 191 | 194 |
| 192 bool PictureLayer::HasDrawableContent() const { | 195 bool PictureLayer::HasDrawableContent() const { |
| 193 return client_ && Layer::HasDrawableContent(); | 196 return client_ && Layer::HasDrawableContent(); |
| 194 } | 197 } |
| 195 | 198 |
| 196 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 199 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 197 benchmark->RunOnLayer(this); | 200 benchmark->RunOnLayer(this); |
| 198 } | 201 } |
| 199 | 202 |
| 200 } // namespace cc | 203 } // namespace cc |
| OLD | NEW |