| 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 "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "cc/blimp/client_picture_cache.h" | 9 #include "cc/blimp/client_picture_cache.h" |
| 10 #include "cc/blimp/engine_picture_cache.h" | 10 #include "cc/blimp/engine_picture_cache.h" |
| 11 #include "cc/layers/content_layer_client.h" | 11 #include "cc/layers/content_layer_client.h" |
| 12 #include "cc/layers/picture_layer_impl.h" | 12 #include "cc/layers/picture_layer_impl.h" |
| 13 #include "cc/playback/recording_source.h" | 13 #include "cc/playback/recording_source.h" |
| 14 #include "cc/proto/cc_conversions.h" | 14 #include "cc/proto/cc_conversions.h" |
| 15 #include "cc/proto/gfx_conversions.h" | 15 #include "cc/proto/gfx_conversions.h" |
| 16 #include "cc/proto/layer.pb.h" | 16 #include "cc/proto/layer.pb.h" |
| 17 #include "cc/trees/layer_tree_host.h" | 17 #include "cc/trees/layer_tree_host.h" |
| 18 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
| 19 #include "third_party/skia/include/core/SkPictureRecorder.h" | 19 #include "skia/ext/cdl_picture_recorder.h" |
| 20 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 | 23 |
| 24 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default; | 24 PictureLayer::PictureLayerInputs::PictureLayerInputs() = default; |
| 25 | 25 |
| 26 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default; | 26 PictureLayer::PictureLayerInputs::~PictureLayerInputs() = default; |
| 27 | 27 |
| 28 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { | 28 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |
| 29 return make_scoped_refptr(new PictureLayer(client)); | 29 return make_scoped_refptr(new PictureLayer(client)); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 last_updated_invalidation_.Clear(); | 139 last_updated_invalidation_.Clear(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 return updated; | 142 return updated; |
| 143 } | 143 } |
| 144 | 144 |
| 145 void PictureLayer::SetIsMask(bool is_mask) { | 145 void PictureLayer::SetIsMask(bool is_mask) { |
| 146 is_mask_ = is_mask; | 146 is_mask_ = is_mask; |
| 147 } | 147 } |
| 148 | 148 |
| 149 sk_sp<SkPicture> PictureLayer::GetPicture() const { | 149 sk_sp<CdlPicture> PictureLayer::GetPicture() const { |
| 150 // We could either flatten the RecordingSource into a single | 150 // We could either flatten the RecordingSource into a single |
| 151 // SkPicture, or paint a fresh one depending on what we intend to do with the | 151 // CdlPicture, or paint a fresh one depending on what we intend to do with the |
| 152 // picture. For now we just paint a fresh one to get consistent results. | 152 // picture. For now we just paint a fresh one to get consistent results. |
| 153 if (!DrawsContent()) | 153 if (!DrawsContent()) |
| 154 return nullptr; | 154 return nullptr; |
| 155 | 155 |
| 156 gfx::Size layer_size = bounds(); | 156 gfx::Size layer_size = bounds(); |
| 157 RecordingSource recording_source; | 157 RecordingSource recording_source; |
| 158 Region recording_invalidation; | 158 Region recording_invalidation; |
| 159 | 159 |
| 160 gfx::Rect new_recorded_viewport = | 160 gfx::Rect new_recorded_viewport = |
| 161 picture_layer_inputs_.client->PaintableRegion(); | 161 picture_layer_inputs_.client->PaintableRegion(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 DropRecordingSourceContentIfInvalid(); | 214 DropRecordingSourceContentIfInvalid(); |
| 215 proto::PictureLayerProperties* picture = proto->mutable_picture(); | 215 proto::PictureLayerProperties* picture = proto->mutable_picture(); |
| 216 | 216 |
| 217 picture->set_nearest_neighbor(picture_layer_inputs_.nearest_neighbor); | 217 picture->set_nearest_neighbor(picture_layer_inputs_.nearest_neighbor); |
| 218 RectToProto(picture_layer_inputs_.recorded_viewport, | 218 RectToProto(picture_layer_inputs_.recorded_viewport, |
| 219 picture->mutable_recorded_viewport()); | 219 picture->mutable_recorded_viewport()); |
| 220 if (picture_layer_inputs_.display_list) { | 220 if (picture_layer_inputs_.display_list) { |
| 221 picture_layer_inputs_.display_list->ToProtobuf( | 221 picture_layer_inputs_.display_list->ToProtobuf( |
| 222 picture->mutable_display_list()); | 222 picture->mutable_display_list()); |
| 223 for (const auto& item : *picture_layer_inputs_.display_list) { | 223 for (const auto& item : *picture_layer_inputs_.display_list) { |
| 224 sk_sp<const SkPicture> picture = item.GetPicture(); | 224 sk_sp<const CdlPicture> picture = item.GetPicture(); |
| 225 // Only DrawingDisplayItems have SkPictures. | 225 // Only DrawingDisplayItems have CdlPictures. |
| 226 if (!picture) | 226 if (!picture) |
| 227 continue; | 227 continue; |
| 228 | 228 |
| 229 GetLayerTree()->engine_picture_cache()->MarkUsed(picture.get()); | 229 GetLayerTree()->engine_picture_cache()->MarkUsed(picture.get()); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 234 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 235 benchmark->RunOnLayer(this); | 235 benchmark->RunOnLayer(this); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 260 picture_layer_inputs_.display_list = nullptr; | 260 picture_layer_inputs_.display_list = nullptr; |
| 261 picture_layer_inputs_.painter_reported_memory_usage = 0; | 261 picture_layer_inputs_.painter_reported_memory_usage = 0; |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 const DisplayItemList* PictureLayer::GetDisplayItemList() { | 265 const DisplayItemList* PictureLayer::GetDisplayItemList() { |
| 266 return picture_layer_inputs_.display_list.get(); | 266 return picture_layer_inputs_.display_list.get(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace cc | 269 } // namespace cc |
| OLD | NEW |