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/resources/display_list_recording_source.h" | 10 #include "cc/resources/display_list_recording_source.h" |
11 #include "cc/resources/picture_pile.h" | 11 #include "cc/resources/picture_pile.h" |
12 #include "cc/trees/layer_tree_impl.h" | 12 #include "cc/trees/layer_tree_impl.h" |
13 #include "third_party/skia/include/core/SkPictureRecorder.h" | 13 #include "third_party/skia/include/core/SkPictureRecorder.h" |
14 #include "ui/gfx/geometry/rect_conversions.h" | 14 #include "ui/gfx/geometry/rect_conversions.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { | 18 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |
19 return make_scoped_refptr(new PictureLayer(client)); | 19 return make_scoped_refptr(new PictureLayer(client)); |
20 } | 20 } |
21 | 21 |
22 PictureLayer::PictureLayer(ContentLayerClient* client) | 22 PictureLayer::PictureLayer(ContentLayerClient* client) |
23 : client_(client), | 23 : client_(client), |
24 instrumentation_object_tracker_(id()), | 24 instrumentation_object_tracker_(id()), |
25 update_source_frame_number_(-1), | 25 update_source_frame_number_(-1), |
26 can_use_lcd_text_for_update_(true), | 26 can_use_lcd_text_for_update_(true), |
27 is_mask_(false) { | 27 is_mask_(false), |
28 nearest_neighbor_(false) { | |
28 } | 29 } |
29 | 30 |
30 PictureLayer::PictureLayer(ContentLayerClient* client, | 31 PictureLayer::PictureLayer(ContentLayerClient* client, |
31 scoped_ptr<RecordingSource> source) | 32 scoped_ptr<RecordingSource> source) |
32 : PictureLayer(client) { | 33 : PictureLayer(client) { |
33 recording_source_ = source.Pass(); | 34 recording_source_ = source.Pass(); |
34 } | 35 } |
35 | 36 |
36 PictureLayer::~PictureLayer() { | 37 PictureLayer::~PictureLayer() { |
37 } | 38 } |
(...skipping 23 matching lines...) Expand all Loading... | |
61 // for example, even though it has resized making the recording source no | 62 // for example, even though it has resized making the recording source no |
62 // longer valid. In this case just destroy the recording source. | 63 // longer valid. In this case just destroy the recording source. |
63 recording_source_->SetEmptyBounds(); | 64 recording_source_->SetEmptyBounds(); |
64 } | 65 } |
65 | 66 |
66 // Unlike other properties, invalidation must always be set on layer_impl. | 67 // Unlike other properties, invalidation must always be set on layer_impl. |
67 // See PictureLayerImpl::PushPropertiesTo for more details. | 68 // See PictureLayerImpl::PushPropertiesTo for more details. |
68 layer_impl->invalidation_.Clear(); | 69 layer_impl->invalidation_.Clear(); |
69 layer_impl->invalidation_.Swap(&recording_invalidation_); | 70 layer_impl->invalidation_.Swap(&recording_invalidation_); |
70 layer_impl->set_is_mask(is_mask_); | 71 layer_impl->set_is_mask(is_mask_); |
72 layer_impl->SetNearestNeighbor(nearest_neighbor_); | |
71 scoped_refptr<RasterSource> raster_source = | 73 scoped_refptr<RasterSource> raster_source = |
72 recording_source_->CreateRasterSource(); | 74 recording_source_->CreateRasterSource(); |
73 raster_source->SetBackgoundColor(SafeOpaqueBackgroundColor()); | 75 raster_source->SetBackgoundColor(SafeOpaqueBackgroundColor()); |
74 raster_source->SetRequiresClear(!contents_opaque() && | 76 raster_source->SetRequiresClear(!contents_opaque() && |
75 !client_->FillsBoundsCompletely()); | 77 !client_->FillsBoundsCompletely()); |
76 layer_impl->UpdateRasterSource(raster_source); | 78 layer_impl->UpdateRasterSource(raster_source); |
77 } | 79 } |
78 | 80 |
79 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 81 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
80 Layer::SetLayerTreeHost(host); | 82 Layer::SetLayerTreeHost(host); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 | 201 |
200 bool PictureLayer::IsSuitableForGpuRasterization() const { | 202 bool PictureLayer::IsSuitableForGpuRasterization() const { |
201 return recording_source_->IsSuitableForGpuRasterization(); | 203 return recording_source_->IsSuitableForGpuRasterization(); |
202 } | 204 } |
203 | 205 |
204 void PictureLayer::ClearClient() { | 206 void PictureLayer::ClearClient() { |
205 client_ = nullptr; | 207 client_ = nullptr; |
206 UpdateDrawsContent(HasDrawableContent()); | 208 UpdateDrawsContent(HasDrawableContent()); |
207 } | 209 } |
208 | 210 |
211 void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) { | |
212 if (nearest_neighbor_ != nearest_neighbor) { | |
danakj
2014/12/09 19:44:45
if == return
jackhou1
2014/12/10 01:04:14
Done.
| |
213 nearest_neighbor_ = nearest_neighbor; | |
214 SetNeedsDisplay(); | |
danakj
2014/12/09 19:44:45
SetNeedsCommit is what you are looking for here
jackhou1
2014/12/10 01:04:14
Done.
| |
215 } | |
216 } | |
217 | |
209 bool PictureLayer::HasDrawableContent() const { | 218 bool PictureLayer::HasDrawableContent() const { |
210 return client_ && Layer::HasDrawableContent(); | 219 return client_ && Layer::HasDrawableContent(); |
211 } | 220 } |
212 | 221 |
213 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 222 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
214 benchmark->RunOnLayer(this); | 223 benchmark->RunOnLayer(this); |
215 } | 224 } |
216 | 225 |
217 } // namespace cc | 226 } // namespace cc |
OLD | NEW |