OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 static String pointerAsString(const void* ptr) | 600 static String pointerAsString(const void* ptr) |
601 { | 601 { |
602 TextStream ts; | 602 TextStream ts; |
603 ts << ptr; | 603 ts << ptr; |
604 return ts.release(); | 604 return ts.release(); |
605 } | 605 } |
606 | 606 |
607 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags)
const | 607 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags)
const |
608 { | 608 { |
609 RenderingContextMap renderingContextMap; | 609 RenderingContextMap renderingContextMap; |
| 610 if (flags & OutputChildrenAsLayerList) { |
| 611 std::unique_ptr<JSONObject> json = JSONObject::create(); |
| 612 std::unique_ptr<JSONArray> layersArray = JSONArray::create(); |
| 613 for (auto& child : m_children) |
| 614 child->layersAsJSONArray(flags, renderingContextMap, layersArray.get
()); |
| 615 json->setArray("layers", std::move(layersArray)); |
| 616 return json; |
| 617 } |
610 return layerTreeAsJSONInternal(flags, renderingContextMap); | 618 return layerTreeAsJSONInternal(flags, renderingContextMap); |
611 } | 619 } |
612 | 620 |
613 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(LayerTreeFlag
s flags, RenderingContextMap& renderingContextMap) const | 621 std::unique_ptr<JSONObject> GraphicsLayer::layerAsJSONInternal(LayerTreeFlags fl
ags, RenderingContextMap& renderingContextMap) const |
614 { | 622 { |
615 std::unique_ptr<JSONObject> json = JSONObject::create(); | 623 std::unique_ptr<JSONObject> json = JSONObject::create(); |
616 | 624 |
617 if (flags & LayerTreeIncludesDebugInfo) | 625 if (flags & LayerTreeIncludesDebugInfo) |
618 json->setString("this", pointerAsString(this)); | 626 json->setString("this", pointerAsString(this)); |
619 | 627 |
620 json->setString("name", debugName()); | 628 json->setString("name", debugName()); |
621 | 629 |
622 if (m_position != FloatPoint()) | 630 if (m_position != FloatPoint()) |
623 json->setArray("position", pointAsJSONArray(m_position)); | 631 json->setArray("position", pointAsJSONArray(m_position)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 } | 715 } |
708 json->setArray("compositingReasons", std::move(compositingReasonsJSON)); | 716 json->setArray("compositingReasons", std::move(compositingReasonsJSON)); |
709 | 717 |
710 std::unique_ptr<JSONArray> squashingDisallowedReasonsJSON = JSONArray::c
reate(); | 718 std::unique_ptr<JSONArray> squashingDisallowedReasonsJSON = JSONArray::c
reate(); |
711 for (size_t i = 0; i < kNumberOfSquashingDisallowedReasons; ++i) { | 719 for (size_t i = 0; i < kNumberOfSquashingDisallowedReasons; ++i) { |
712 if (m_debugInfo.getSquashingDisallowedReasons() & kSquashingDisallow
edReasonStringMap[i].reason) | 720 if (m_debugInfo.getSquashingDisallowedReasons() & kSquashingDisallow
edReasonStringMap[i].reason) |
713 squashingDisallowedReasonsJSON->pushString(debug ? kSquashingDis
allowedReasonStringMap[i].description : kSquashingDisallowedReasonStringMap[i].s
hortName); | 721 squashingDisallowedReasonsJSON->pushString(debug ? kSquashingDis
allowedReasonStringMap[i].description : kSquashingDisallowedReasonStringMap[i].s
hortName); |
714 } | 722 } |
715 json->setArray("squashingDisallowedReasons", std::move(squashingDisallow
edReasonsJSON)); | 723 json->setArray("squashingDisallowedReasons", std::move(squashingDisallow
edReasonsJSON)); |
716 } | 724 } |
| 725 return json; |
| 726 } |
| 727 |
| 728 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(LayerTreeFlag
s flags, RenderingContextMap& renderingContextMap) const |
| 729 { |
| 730 std::unique_ptr<JSONObject> json = layerAsJSONInternal(flags, renderingConte
xtMap); |
717 | 731 |
718 if (m_children.size()) { | 732 if (m_children.size()) { |
719 std::unique_ptr<JSONArray> childrenJSON = JSONArray::create(); | 733 std::unique_ptr<JSONArray> childrenJSON = JSONArray::create(); |
720 for (size_t i = 0; i < m_children.size(); i++) | 734 for (size_t i = 0; i < m_children.size(); i++) |
721 childrenJSON->pushObject(m_children[i]->layerTreeAsJSONInternal(flag
s, renderingContextMap)); | 735 childrenJSON->pushObject(m_children[i]->layerTreeAsJSONInternal(flag
s, renderingContextMap)); |
722 json->setArray("children", std::move(childrenJSON)); | 736 json->setArray("children", std::move(childrenJSON)); |
723 } | 737 } |
724 | 738 |
725 return json; | 739 return json; |
726 } | 740 } |
727 | 741 |
| 742 void GraphicsLayer::layersAsJSONArray(LayerTreeFlags flags, RenderingContextMap&
renderingContextMap, JSONArray* jsonArray) const |
| 743 { |
| 744 jsonArray->pushObject(layerAsJSONInternal(flags, renderingContextMap)); |
| 745 |
| 746 if (m_children.size()) { |
| 747 for (auto& child : m_children) |
| 748 child->layersAsJSONArray(flags, renderingContextMap, jsonArray); |
| 749 } |
| 750 } |
| 751 |
728 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const | 752 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const |
729 { | 753 { |
730 return layerTreeAsJSON(flags)->toPrettyJSONString(); | 754 return layerTreeAsJSON(flags)->toPrettyJSONString(); |
731 } | 755 } |
732 | 756 |
733 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) | 757 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) |
734 { | 758 { |
735 return webLayer ? webLayer->ccLayer() : nullptr; | 759 return webLayer ? webLayer->ccLayer() : nullptr; |
736 } | 760 } |
737 | 761 |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 { | 1265 { |
1242 if (!layer) { | 1266 if (!layer) { |
1243 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1267 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1244 return; | 1268 return; |
1245 } | 1269 } |
1246 | 1270 |
1247 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1271 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1248 fprintf(stderr, "%s\n", output.utf8().data()); | 1272 fprintf(stderr, "%s\n", output.utf8().data()); |
1249 } | 1273 } |
1250 #endif | 1274 #endif |
OLD | NEW |