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 "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/picture_layer_impl.h" | 8 #include "cc/layers/picture_layer_impl.h" |
9 #include "cc/trees/layer_tree_impl.h" | 9 #include "cc/trees/layer_tree_impl.h" |
10 #include "third_party/skia/include/core/SkPictureRecorder.h" | 10 #include "third_party/skia/include/core/SkPictureRecorder.h" |
11 #include "ui/gfx/rect_conversions.h" | 11 #include "ui/gfx/rect_conversions.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { | 15 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |
16 return make_scoped_refptr(new PictureLayer(client)); | 16 return make_scoped_refptr(new PictureLayer(client)); |
17 } | 17 } |
18 | 18 |
19 PictureLayer::PictureLayer(ContentLayerClient* client) | 19 PictureLayer::PictureLayer(ContentLayerClient* client) |
20 : client_(client), | 20 : client_(client), |
21 pile_(make_scoped_refptr(new PicturePile())), | 21 pile_(make_scoped_refptr(new PicturePile())), |
22 instrumentation_object_tracker_(id()), | 22 instrumentation_object_tracker_(id()), |
23 is_mask_(false), | 23 is_mask_(false), |
24 update_source_frame_number_(-1) {} | 24 update_source_frame_number_(-1), |
| 25 can_use_lcd_text_last_frame_(can_use_lcd_text()) { |
| 26 } |
25 | 27 |
26 PictureLayer::~PictureLayer() { | 28 PictureLayer::~PictureLayer() { |
27 } | 29 } |
28 | 30 |
29 bool PictureLayer::DrawsContent() const { | 31 bool PictureLayer::DrawsContent() const { |
30 return Layer::DrawsContent() && client_; | 32 return Layer::DrawsContent() && client_; |
31 } | 33 } |
32 | 34 |
33 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 35 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
34 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 36 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 pending_invalidation_.Union(rect); | 83 pending_invalidation_.Union(rect); |
82 } | 84 } |
83 Layer::SetNeedsDisplayRect(layer_rect); | 85 Layer::SetNeedsDisplayRect(layer_rect); |
84 } | 86 } |
85 | 87 |
86 bool PictureLayer::Update(ResourceUpdateQueue* queue, | 88 bool PictureLayer::Update(ResourceUpdateQueue* queue, |
87 const OcclusionTracker<Layer>* occlusion) { | 89 const OcclusionTracker<Layer>* occlusion) { |
88 update_source_frame_number_ = layer_tree_host()->source_frame_number(); | 90 update_source_frame_number_ = layer_tree_host()->source_frame_number(); |
89 bool updated = Layer::Update(queue, occlusion); | 91 bool updated = Layer::Update(queue, occlusion); |
90 | 92 |
| 93 UpdateCanUseLCDText(); |
| 94 |
91 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 95 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
92 visible_content_rect(), 1.f / contents_scale_x()); | 96 visible_content_rect(), 1.f / contents_scale_x()); |
93 | 97 |
94 gfx::Rect layer_rect = gfx::Rect(paint_properties().bounds); | 98 gfx::Rect layer_rect = gfx::Rect(paint_properties().bounds); |
95 | 99 |
96 if (last_updated_visible_content_rect_ == visible_content_rect() && | 100 if (last_updated_visible_content_rect_ == visible_content_rect() && |
97 pile_->tiling_rect() == layer_rect && pending_invalidation_.IsEmpty()) { | 101 pile_->tiling_rect() == layer_rect && pending_invalidation_.IsEmpty()) { |
98 // Only early out if the visible content rect of this layer hasn't changed. | 102 // Only early out if the visible content rect of this layer hasn't changed. |
99 return updated; | 103 return updated; |
100 } | 104 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return Picture::RECORD_WITH_SKRECORD; | 154 return Picture::RECORD_WITH_SKRECORD; |
151 } | 155 } |
152 NOTREACHED(); | 156 NOTREACHED(); |
153 return Picture::RECORD_NORMALLY; | 157 return Picture::RECORD_NORMALLY; |
154 } | 158 } |
155 | 159 |
156 bool PictureLayer::SupportsLCDText() const { | 160 bool PictureLayer::SupportsLCDText() const { |
157 return true; | 161 return true; |
158 } | 162 } |
159 | 163 |
| 164 void PictureLayer::UpdateCanUseLCDText() { |
| 165 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) |
| 166 return; |
| 167 |
| 168 can_use_lcd_text_last_frame_ = can_use_lcd_text(); |
| 169 if (client_) |
| 170 client_->DidChangeLayerCanUseLCDText(); |
| 171 } |
| 172 |
160 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { | 173 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { |
161 // We could either flatten the PicturePile into a single SkPicture, | 174 // We could either flatten the PicturePile into a single SkPicture, |
162 // or paint a fresh one depending on what we intend to do with the | 175 // or paint a fresh one depending on what we intend to do with the |
163 // picture. For now we just paint a fresh one to get consistent results. | 176 // picture. For now we just paint a fresh one to get consistent results. |
164 if (!DrawsContent()) | 177 if (!DrawsContent()) |
165 return skia::RefPtr<SkPicture>(); | 178 return skia::RefPtr<SkPicture>(); |
166 | 179 |
167 int width = bounds().width(); | 180 int width = bounds().width(); |
168 int height = bounds().height(); | 181 int height = bounds().height(); |
169 gfx::RectF opaque; | 182 gfx::RectF opaque; |
(...skipping 10 matching lines...) Expand all Loading... |
180 | 193 |
181 bool PictureLayer::IsSuitableForGpuRasterization() const { | 194 bool PictureLayer::IsSuitableForGpuRasterization() const { |
182 return pile_->is_suitable_for_gpu_rasterization(); | 195 return pile_->is_suitable_for_gpu_rasterization(); |
183 } | 196 } |
184 | 197 |
185 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 198 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
186 benchmark->RunOnLayer(this); | 199 benchmark->RunOnLayer(this); |
187 } | 200 } |
188 | 201 |
189 } // namespace cc | 202 } // namespace cc |
OLD | NEW |