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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
12 #include "cc/base/math_util.h" | 12 #include "cc/base/math_util.h" |
13 #include "cc/debug/picture_debug_util.h" | 13 #include "cc/debug/picture_debug_util.h" |
14 #include "cc/debug/traced_display_item_list.h" | 14 #include "cc/debug/traced_display_item_list.h" |
15 #include "cc/debug/traced_value.h" | 15 #include "cc/debug/traced_value.h" |
16 #include "cc/playback/display_item_list_settings.h" | 16 #include "cc/playback/display_item_list_settings.h" |
17 #include "cc/playback/display_item_proto_factory.h" | 17 #include "cc/playback/display_item_proto_factory.h" |
18 #include "cc/playback/largest_display_item.h" | 18 #include "cc/playback/largest_display_item.h" |
19 #include "cc/proto/display_item.pb.h" | 19 #include "cc/proto/display_item.pb.h" |
20 #include "cc/proto/gfx_conversions.h" | 20 #include "cc/proto/gfx_conversions.h" |
21 #include "third_party/skia/include/core/SkCanvas.h" | 21 #include "third_party/skia/include/core/SkCanvas.h" |
22 #include "third_party/skia/include/core/SkPictureRecorder.h" | 22 #include "third_party/skia/include/core/SkPictureRecorder.h" |
23 #include "third_party/skia/include/utils/SkPictureUtils.h" | 23 #include "third_party/skia/include/utils/SkPictureUtils.h" |
24 #include "ui/gfx/geometry/rect.h" | |
24 #include "ui/gfx/skia_util.h" | 25 #include "ui/gfx/skia_util.h" |
25 | 26 |
26 namespace cc { | 27 namespace cc { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 // We don't perform per-layer solid color analysis when there are too many skia | 31 // We don't perform per-layer solid color analysis when there are too many skia |
31 // operations. | 32 // operations. |
32 const int kOpCountThatIsOkToAnalyze = 10; | 33 const int kOpCountThatIsOkToAnalyze = 10; |
33 | 34 |
(...skipping 18 matching lines...) Expand all Loading... | |
52 | 53 |
53 scoped_refptr<DisplayItemList> DisplayItemList::CreateFromProto( | 54 scoped_refptr<DisplayItemList> DisplayItemList::CreateFromProto( |
54 const proto::DisplayItemList& proto) { | 55 const proto::DisplayItemList& proto) { |
55 gfx::Rect layer_rect = ProtoToRect(proto.layer_rect()); | 56 gfx::Rect layer_rect = ProtoToRect(proto.layer_rect()); |
56 scoped_refptr<DisplayItemList> list = | 57 scoped_refptr<DisplayItemList> list = |
57 DisplayItemList::Create(ProtoToRect(proto.layer_rect()), | 58 DisplayItemList::Create(ProtoToRect(proto.layer_rect()), |
58 DisplayItemListSettings(proto.settings())); | 59 DisplayItemListSettings(proto.settings())); |
59 | 60 |
60 for (int i = 0; i < proto.items_size(); i++) { | 61 for (int i = 0; i < proto.items_size(); i++) { |
61 const proto::DisplayItem& item_proto = proto.items(i); | 62 const proto::DisplayItem& item_proto = proto.items(i); |
62 DisplayItem* item = | 63 DisplayItem* item = DisplayItemProtoFactory::AllocateAndConstruct( |
63 DisplayItemProtoFactory::AllocateAndConstruct(list, item_proto); | 64 layer_rect, list, item_proto); |
64 if (item) | 65 if (item) |
65 item->FromProtobuf(item_proto); | 66 item->FromProtobuf(item_proto); |
66 } | 67 } |
67 | 68 |
68 return list; | 69 return list; |
69 } | 70 } |
70 | 71 |
71 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, | 72 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, |
72 const DisplayItemListSettings& settings, | 73 const DisplayItemListSettings& settings, |
73 bool retain_individual_display_items) | 74 bool retain_individual_display_items) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 void DisplayItemList::RemoveLast() { | 194 void DisplayItemList::RemoveLast() { |
194 // We cannot remove the last item if it has been squashed into a picture. | 195 // We cannot remove the last item if it has been squashed into a picture. |
195 // The last item should not have been handled by ProcessAppendedItems, so we | 196 // The last item should not have been handled by ProcessAppendedItems, so we |
196 // don't need to remove it from approximate_op_count_, etc. | 197 // don't need to remove it from approximate_op_count_, etc. |
197 DCHECK(retain_individual_display_items_); | 198 DCHECK(retain_individual_display_items_); |
198 DCHECK(!settings_.use_cached_picture); | 199 DCHECK(!settings_.use_cached_picture); |
199 items_.RemoveLast(); | 200 items_.RemoveLast(); |
200 } | 201 } |
201 | 202 |
202 void DisplayItemList::Finalize() { | 203 void DisplayItemList::Finalize() { |
204 // TODO(wkorman): Uncomment the assert below once we've investigated | |
vmpstr
2015/11/17 23:51:38
nit: Can you reference a bug for this?
wkorman
2015/11/18 19:37:35
Done.
| |
205 // and resolved issues. | |
206 // DCHECK_EQ(items_.size(), visual_rects_.size()); | |
207 | |
208 // TODO(vmpstr): Build and make use of an RTree from the visual | |
209 // rects. For now we just clear them out since we won't ever need | |
210 // them to stick around post-Finalize. | |
vmpstr
2015/11/17 23:51:38
nit: Can you put "crbug.com/527245" in this commen
wkorman
2015/11/18 19:37:35
Done.
| |
211 visual_rects_.clear(); | |
212 | |
203 ProcessAppendedItems(); | 213 ProcessAppendedItems(); |
204 | 214 |
205 if (settings_.use_cached_picture) { | 215 if (settings_.use_cached_picture) { |
206 // Convert to an SkPicture for faster rasterization. | 216 // Convert to an SkPicture for faster rasterization. |
207 DCHECK(settings_.use_cached_picture); | 217 DCHECK(settings_.use_cached_picture); |
208 DCHECK(!picture_); | 218 DCHECK(!picture_); |
209 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); | 219 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); |
210 DCHECK(picture_); | 220 DCHECK(picture_); |
211 picture_memory_usage_ = | 221 picture_memory_usage_ = |
212 SkPictureUtils::ApproximateBytesUsed(picture_.get()); | 222 SkPictureUtils::ApproximateBytesUsed(picture_.get()); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 } | 327 } |
318 | 328 |
319 void DisplayItemList::GetDiscardableImagesInRect( | 329 void DisplayItemList::GetDiscardableImagesInRect( |
320 const gfx::Rect& rect, | 330 const gfx::Rect& rect, |
321 float raster_scale, | 331 float raster_scale, |
322 std::vector<DrawImage>* images) { | 332 std::vector<DrawImage>* images) { |
323 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); | 333 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); |
324 } | 334 } |
325 | 335 |
326 } // namespace cc | 336 } // namespace cc |
OLD | NEW |