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" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 return raster_source->GetFlattenedPicture(); | 198 return raster_source->GetFlattenedPicture(); |
199 } | 199 } |
200 | 200 |
201 int width = layer_size.width(); | 201 int width = layer_size.width(); |
202 int height = layer_size.height(); | 202 int height = layer_size.height(); |
203 | 203 |
204 SkPictureRecorder recorder; | 204 SkPictureRecorder recorder; |
205 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); | 205 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); |
206 client_->PaintContents(canvas, gfx::Rect(width, height), | 206 client_->PaintContents(canvas, gfx::Rect(width, height), |
207 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 207 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
208 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 208 skia::RefPtr<SkPicture> picture = |
| 209 skia::AdoptRef(recorder.endRecordingAsPicture()); |
209 return picture; | 210 return picture; |
210 } | 211 } |
211 | 212 |
212 bool PictureLayer::IsSuitableForGpuRasterization() const { | 213 bool PictureLayer::IsSuitableForGpuRasterization() const { |
213 return recording_source_->IsSuitableForGpuRasterization(); | 214 return recording_source_->IsSuitableForGpuRasterization(); |
214 } | 215 } |
215 | 216 |
216 void PictureLayer::ClearClient() { | 217 void PictureLayer::ClearClient() { |
217 client_ = nullptr; | 218 client_ = nullptr; |
218 UpdateDrawsContent(HasDrawableContent()); | 219 UpdateDrawsContent(HasDrawableContent()); |
219 } | 220 } |
220 | 221 |
221 void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) { | 222 void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) { |
222 if (nearest_neighbor_ == nearest_neighbor) | 223 if (nearest_neighbor_ == nearest_neighbor) |
223 return; | 224 return; |
224 | 225 |
225 nearest_neighbor_ = nearest_neighbor; | 226 nearest_neighbor_ = nearest_neighbor; |
226 SetNeedsCommit(); | 227 SetNeedsCommit(); |
227 } | 228 } |
228 | 229 |
229 bool PictureLayer::HasDrawableContent() const { | 230 bool PictureLayer::HasDrawableContent() const { |
230 return client_ && Layer::HasDrawableContent(); | 231 return client_ && Layer::HasDrawableContent(); |
231 } | 232 } |
232 | 233 |
233 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 234 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
234 benchmark->RunOnLayer(this); | 235 benchmark->RunOnLayer(this); |
235 } | 236 } |
236 | 237 |
237 } // namespace cc | 238 } // namespace cc |
OLD | NEW |