OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/playback/display_item_list.h" | 5 #include "cc/playback/display_item_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "cc/playback/largest_display_item.h" | 22 #include "cc/playback/largest_display_item.h" |
23 #include "cc/proto/display_item.pb.h" | 23 #include "cc/proto/display_item.pb.h" |
24 #include "cc/proto/gfx_conversions.h" | 24 #include "cc/proto/gfx_conversions.h" |
25 #include "third_party/skia/include/core/SkCanvas.h" | 25 #include "third_party/skia/include/core/SkCanvas.h" |
26 #include "third_party/skia/include/core/SkPictureRecorder.h" | 26 #include "third_party/skia/include/core/SkPictureRecorder.h" |
27 #include "third_party/skia/include/utils/SkPictureUtils.h" | 27 #include "third_party/skia/include/utils/SkPictureUtils.h" |
28 #include "ui/gfx/geometry/rect.h" | 28 #include "ui/gfx/geometry/rect.h" |
29 #include "ui/gfx/skia_util.h" | 29 #include "ui/gfx/skia_util.h" |
30 | 30 |
31 namespace cc { | 31 namespace cc { |
32 class ImageSerializationProcessor; | |
33 | 32 |
34 namespace { | 33 namespace { |
35 | 34 |
36 // We don't perform per-layer solid color analysis when there are too many skia | 35 // We don't perform per-layer solid color analysis when there are too many skia |
37 // operations. | 36 // operations. |
38 const int kOpCountThatIsOkToAnalyze = 10; | 37 const int kOpCountThatIsOkToAnalyze = 10; |
39 | 38 |
40 bool DisplayItemsTracingEnabled() { | 39 bool DisplayItemsTracingEnabled() { |
41 bool tracing_enabled; | 40 bool tracing_enabled; |
42 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 41 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
43 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items"), &tracing_enabled); | 42 TRACE_DISABLED_BY_DEFAULT("cc.debug.display_items"), &tracing_enabled); |
44 return tracing_enabled; | 43 return tracing_enabled; |
45 } | 44 } |
46 | 45 |
47 const int kDefaultNumDisplayItemsToReserve = 100; | 46 const int kDefaultNumDisplayItemsToReserve = 100; |
48 | 47 |
49 } // namespace | 48 } // namespace |
50 | 49 |
51 scoped_refptr<DisplayItemList> DisplayItemList::Create( | 50 scoped_refptr<DisplayItemList> DisplayItemList::Create( |
52 const gfx::Rect& layer_rect, | 51 const gfx::Rect& layer_rect, |
53 const DisplayItemListSettings& settings) { | 52 const DisplayItemListSettings& settings) { |
54 return make_scoped_refptr(new DisplayItemList( | 53 return make_scoped_refptr(new DisplayItemList( |
55 layer_rect, settings, | 54 layer_rect, settings, |
56 !settings.use_cached_picture || DisplayItemsTracingEnabled())); | 55 !settings.use_cached_picture || DisplayItemsTracingEnabled())); |
57 } | 56 } |
58 | 57 |
59 scoped_refptr<DisplayItemList> DisplayItemList::CreateFromProto( | 58 scoped_refptr<DisplayItemList> DisplayItemList::CreateFromProto( |
60 const proto::DisplayItemList& proto, | 59 const proto::DisplayItemList& proto, |
61 ImageSerializationProcessor* image_serialization_processor) { | 60 ClientPictureCache* client_picture_cache, |
| 61 std::vector<uint32_t>* used_engine_picture_ids) { |
62 gfx::Rect layer_rect = ProtoToRect(proto.layer_rect()); | 62 gfx::Rect layer_rect = ProtoToRect(proto.layer_rect()); |
63 scoped_refptr<DisplayItemList> list = | 63 scoped_refptr<DisplayItemList> list = |
64 DisplayItemList::Create(ProtoToRect(proto.layer_rect()), | 64 DisplayItemList::Create(ProtoToRect(proto.layer_rect()), |
65 DisplayItemListSettings(proto.settings())); | 65 DisplayItemListSettings(proto.settings())); |
66 | 66 |
67 for (int i = 0; i < proto.items_size(); i++) { | 67 for (int i = 0; i < proto.items_size(); i++) { |
68 const proto::DisplayItem& item_proto = proto.items(i); | 68 const proto::DisplayItem& item_proto = proto.items(i); |
69 DisplayItemProtoFactory::AllocateAndConstruct( | 69 DisplayItemProtoFactory::AllocateAndConstruct( |
70 layer_rect, list.get(), item_proto, image_serialization_processor); | 70 layer_rect, list.get(), item_proto, client_picture_cache, |
| 71 used_engine_picture_ids); |
71 } | 72 } |
72 | 73 |
73 list->Finalize(); | 74 list->Finalize(); |
74 | 75 |
75 return list; | 76 return list; |
76 } | 77 } |
77 | 78 |
78 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, | 79 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, |
79 const DisplayItemListSettings& settings, | 80 const DisplayItemListSettings& settings, |
80 bool retain_individual_display_items) | 81 bool retain_individual_display_items) |
(...skipping 12 matching lines...) Expand all Loading... |
93 SkCanvas* canvas = recorder_->beginRecording( | 94 SkCanvas* canvas = recorder_->beginRecording( |
94 layer_rect_.width(), layer_rect_.height(), &factory); | 95 layer_rect_.width(), layer_rect_.height(), &factory); |
95 canvas->translate(-layer_rect_.x(), -layer_rect_.y()); | 96 canvas->translate(-layer_rect_.x(), -layer_rect_.y()); |
96 canvas->clipRect(gfx::RectToSkRect(layer_rect_)); | 97 canvas->clipRect(gfx::RectToSkRect(layer_rect_)); |
97 } | 98 } |
98 } | 99 } |
99 | 100 |
100 DisplayItemList::~DisplayItemList() { | 101 DisplayItemList::~DisplayItemList() { |
101 } | 102 } |
102 | 103 |
103 void DisplayItemList::ToProtobuf( | 104 void DisplayItemList::ToProtobuf(proto::DisplayItemList* proto) { |
104 proto::DisplayItemList* proto, | |
105 ImageSerializationProcessor* image_serialization_processor) { | |
106 // The flattened SkPicture approach is going away, and the proto | 105 // The flattened SkPicture approach is going away, and the proto |
107 // doesn't currently support serializing that flattened picture. | 106 // doesn't currently support serializing that flattened picture. |
108 DCHECK(retain_individual_display_items_); | 107 DCHECK(retain_individual_display_items_); |
109 | 108 |
110 RectToProto(layer_rect_, proto->mutable_layer_rect()); | 109 RectToProto(layer_rect_, proto->mutable_layer_rect()); |
111 settings_.ToProtobuf(proto->mutable_settings()); | 110 settings_.ToProtobuf(proto->mutable_settings()); |
112 | 111 |
113 DCHECK_EQ(0, proto->items_size()); | 112 DCHECK_EQ(0, proto->items_size()); |
114 for (const auto& item : items_) | 113 for (const auto& item : items_) |
115 item.ToProtobuf(proto->add_items(), image_serialization_processor); | 114 item.ToProtobuf(proto->add_items()); |
116 } | 115 } |
117 | 116 |
118 void DisplayItemList::Raster(SkCanvas* canvas, | 117 void DisplayItemList::Raster(SkCanvas* canvas, |
119 SkPicture::AbortCallback* callback, | 118 SkPicture::AbortCallback* callback, |
120 const gfx::Rect& canvas_target_playback_rect, | 119 const gfx::Rect& canvas_target_playback_rect, |
121 float contents_scale) const { | 120 float contents_scale) const { |
122 canvas->save(); | 121 canvas->save(); |
123 | 122 |
124 if (!canvas_target_playback_rect.IsEmpty()) { | 123 if (!canvas_target_playback_rect.IsEmpty()) { |
125 // canvas_target_playback_rect is specified in device space. We can't | 124 // canvas_target_playback_rect is specified in device space. We can't |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 316 } |
318 | 317 |
319 void DisplayItemList::GetDiscardableImagesInRect( | 318 void DisplayItemList::GetDiscardableImagesInRect( |
320 const gfx::Rect& rect, | 319 const gfx::Rect& rect, |
321 float raster_scale, | 320 float raster_scale, |
322 std::vector<DrawImage>* images) { | 321 std::vector<DrawImage>* images) { |
323 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); | 322 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); |
324 } | 323 } |
325 | 324 |
326 } // namespace cc | 325 } // namespace cc |
OLD | NEW |