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 "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // We could either flatten the PicturePile into a single SkPicture, | 184 // We could either flatten the PicturePile into a single SkPicture, |
185 // or paint a fresh one depending on what we intend to do with the | 185 // or paint a fresh one depending on what we intend to do with the |
186 // picture. For now we just paint a fresh one to get consistent results. | 186 // picture. For now we just paint a fresh one to get consistent results. |
187 if (!DrawsContent()) | 187 if (!DrawsContent()) |
188 return skia::RefPtr<SkPicture>(); | 188 return skia::RefPtr<SkPicture>(); |
189 | 189 |
190 int width = bounds().width(); | 190 int width = bounds().width(); |
191 int height = bounds().height(); | 191 int height = bounds().height(); |
192 gfx::RectF opaque; | 192 gfx::RectF opaque; |
193 | 193 |
194 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); | 194 SkPictureRecorder recorder; |
195 SkCanvas* canvas = picture->beginRecording(width, height); | 195 SkCanvas* canvas = recorder.beginRecording(width, height); |
196 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); | 196 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); |
197 picture->endRecording(); | 197 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
198 return picture; | 198 return picture; |
199 } | 199 } |
200 | 200 |
201 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 201 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
202 benchmark->RunOnLayer(this); | 202 benchmark->RunOnLayer(this); |
203 } | 203 } |
204 | 204 |
205 } // namespace cc | 205 } // namespace cc |
OLD | NEW |