| 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/debug/benchmark_instrumentation.h" | 7 #include "cc/debug/benchmark_instrumentation.h" |
| 8 #include "cc/debug/devtools_instrumentation.h" | 8 #include "cc/debug/devtools_instrumentation.h" |
| 9 #include "cc/layers/content_layer_client.h" |
| 9 #include "cc/layers/picture_layer_impl.h" | 10 #include "cc/layers/picture_layer_impl.h" |
| 10 #include "cc/trees/layer_tree_impl.h" | 11 #include "cc/trees/layer_tree_impl.h" |
| 11 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/rect_conversions.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { | 16 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |
| 16 return make_scoped_refptr(new PictureLayer(client)); | 17 return make_scoped_refptr(new PictureLayer(client)); |
| 17 } | 18 } |
| 18 | 19 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 124 } |
| 124 | 125 |
| 125 void PictureLayer::SetIsMask(bool is_mask) { | 126 void PictureLayer::SetIsMask(bool is_mask) { |
| 126 is_mask_ = is_mask; | 127 is_mask_ = is_mask; |
| 127 } | 128 } |
| 128 | 129 |
| 129 bool PictureLayer::SupportsLCDText() const { | 130 bool PictureLayer::SupportsLCDText() const { |
| 130 return true; | 131 return true; |
| 131 } | 132 } |
| 132 | 133 |
| 134 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { |
| 135 // We could either flatten the PicturePile into a single SkPicture, |
| 136 // or paint a fresh one depending on what we intend to do with the |
| 137 // picture. For now we just paint a fresh one to get consistent results. |
| 138 if (!DrawsContent()) |
| 139 return skia::RefPtr<SkPicture>(); |
| 140 |
| 141 int width = bounds().width(); |
| 142 int height = bounds().height(); |
| 143 gfx::RectF opaque; |
| 144 |
| 145 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); |
| 146 SkCanvas* canvas = picture->beginRecording(width, height); |
| 147 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); |
| 148 picture->endRecording(); |
| 149 return picture; |
| 150 } |
| 151 |
| 133 } // namespace cc | 152 } // namespace cc |
| OLD | NEW |