Chromium Code Reviews| 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(vmpstr): Build and make use of an RTree from the visual | |
|
danakj
2015/11/05 23:54:27
put the TODO on the clear()
wkorman
2015/11/17 01:47:23
Done.
| |
| 205 // rects. For now we just clear them out since we won't ever need | |
| 206 // them to stick around post-Finalize. | |
| 207 DCHECK(items_.size() == visual_rects_.size()); | |
|
danakj
2015/11/05 23:54:27
DCHECK_EQ
wkorman
2015/11/17 01:47:23
Done, also commented out with a TODO(wkorman) so w
| |
| 208 visual_rects_.clear(); | |
| 209 | |
| 203 ProcessAppendedItems(); | 210 ProcessAppendedItems(); |
| 204 | 211 |
| 205 if (settings_.use_cached_picture) { | 212 if (settings_.use_cached_picture) { |
| 206 // Convert to an SkPicture for faster rasterization. | 213 // Convert to an SkPicture for faster rasterization. |
| 207 DCHECK(settings_.use_cached_picture); | 214 DCHECK(settings_.use_cached_picture); |
| 208 DCHECK(!picture_); | 215 DCHECK(!picture_); |
| 209 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); | 216 picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); |
| 210 DCHECK(picture_); | 217 DCHECK(picture_); |
| 211 picture_memory_usage_ = | 218 picture_memory_usage_ = |
| 212 SkPictureUtils::ApproximateBytesUsed(picture_.get()); | 219 SkPictureUtils::ApproximateBytesUsed(picture_.get()); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 } | 324 } |
| 318 | 325 |
| 319 void DisplayItemList::GetDiscardableImagesInRect( | 326 void DisplayItemList::GetDiscardableImagesInRect( |
| 320 const gfx::Rect& rect, | 327 const gfx::Rect& rect, |
| 321 float raster_scale, | 328 float raster_scale, |
| 322 std::vector<DrawImage>* images) { | 329 std::vector<DrawImage>* images) { |
| 323 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); | 330 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); |
| 324 } | 331 } |
| 325 | 332 |
| 326 } // namespace cc | 333 } // namespace cc |
| OLD | NEW |