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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 594 |
595 static String pointerAsString(const void* ptr) { | 595 static String pointerAsString(const void* ptr) { |
596 TextStream ts; | 596 TextStream ts; |
597 ts << ptr; | 597 ts << ptr; |
598 return ts.release(); | 598 return ts.release(); |
599 } | 599 } |
600 | 600 |
601 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSON( | 601 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSON( |
602 LayerTreeFlags flags) const { | 602 LayerTreeFlags flags) const { |
603 RenderingContextMap renderingContextMap; | 603 RenderingContextMap renderingContextMap; |
| 604 if (flags & OutputChildrenAsLayerList) { |
| 605 std::unique_ptr<JSONObject> json = JSONObject::create(); |
| 606 std::unique_ptr<JSONArray> layersArray = JSONArray::create(); |
| 607 for (auto& child : m_children) |
| 608 child->layersAsJSONArray(flags, renderingContextMap, layersArray.get()); |
| 609 json->setArray("layers", std::move(layersArray)); |
| 610 return json; |
| 611 } |
604 return layerTreeAsJSONInternal(flags, renderingContextMap); | 612 return layerTreeAsJSONInternal(flags, renderingContextMap); |
605 } | 613 } |
606 | 614 |
607 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal( | 615 std::unique_ptr<JSONObject> GraphicsLayer::layerAsJSONInternal( |
608 LayerTreeFlags flags, | 616 LayerTreeFlags flags, |
609 RenderingContextMap& renderingContextMap) const { | 617 RenderingContextMap& renderingContextMap) const { |
610 std::unique_ptr<JSONObject> json = JSONObject::create(); | 618 std::unique_ptr<JSONObject> json = JSONObject::create(); |
611 | 619 |
612 if (flags & LayerTreeIncludesDebugInfo) | 620 if (flags & LayerTreeIncludesDebugInfo) |
613 json->setString("this", pointerAsString(this)); | 621 json->setString("this", pointerAsString(this)); |
614 | 622 |
615 json->setString("name", debugName()); | 623 json->setString("name", debugName()); |
616 | 624 |
617 if (m_position != FloatPoint()) | 625 if (m_position != FloatPoint()) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 for (size_t i = 0; i < kNumberOfSquashingDisallowedReasons; ++i) { | 726 for (size_t i = 0; i < kNumberOfSquashingDisallowedReasons; ++i) { |
719 if (m_debugInfo.getSquashingDisallowedReasons() & | 727 if (m_debugInfo.getSquashingDisallowedReasons() & |
720 kSquashingDisallowedReasonStringMap[i].reason) | 728 kSquashingDisallowedReasonStringMap[i].reason) |
721 squashingDisallowedReasonsJSON->pushString( | 729 squashingDisallowedReasonsJSON->pushString( |
722 debug ? kSquashingDisallowedReasonStringMap[i].description | 730 debug ? kSquashingDisallowedReasonStringMap[i].description |
723 : kSquashingDisallowedReasonStringMap[i].shortName); | 731 : kSquashingDisallowedReasonStringMap[i].shortName); |
724 } | 732 } |
725 json->setArray("squashingDisallowedReasons", | 733 json->setArray("squashingDisallowedReasons", |
726 std::move(squashingDisallowedReasonsJSON)); | 734 std::move(squashingDisallowedReasonsJSON)); |
727 } | 735 } |
| 736 return json; |
| 737 } |
| 738 |
| 739 std::unique_ptr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal( |
| 740 LayerTreeFlags flags, |
| 741 RenderingContextMap& renderingContextMap) const { |
| 742 std::unique_ptr<JSONObject> json = |
| 743 layerAsJSONInternal(flags, renderingContextMap); |
728 | 744 |
729 if (m_children.size()) { | 745 if (m_children.size()) { |
730 std::unique_ptr<JSONArray> childrenJSON = JSONArray::create(); | 746 std::unique_ptr<JSONArray> childrenJSON = JSONArray::create(); |
731 for (size_t i = 0; i < m_children.size(); i++) | 747 for (size_t i = 0; i < m_children.size(); i++) |
732 childrenJSON->pushObject( | 748 childrenJSON->pushObject( |
733 m_children[i]->layerTreeAsJSONInternal(flags, renderingContextMap)); | 749 m_children[i]->layerTreeAsJSONInternal(flags, renderingContextMap)); |
734 json->setArray("children", std::move(childrenJSON)); | 750 json->setArray("children", std::move(childrenJSON)); |
735 } | 751 } |
736 | 752 |
737 return json; | 753 return json; |
738 } | 754 } |
739 | 755 |
| 756 void GraphicsLayer::layersAsJSONArray(LayerTreeFlags flags, |
| 757 RenderingContextMap& renderingContextMap, |
| 758 JSONArray* jsonArray) const { |
| 759 jsonArray->pushObject(layerAsJSONInternal(flags, renderingContextMap)); |
| 760 |
| 761 if (m_children.size()) { |
| 762 for (auto& child : m_children) |
| 763 child->layersAsJSONArray(flags, renderingContextMap, jsonArray); |
| 764 } |
| 765 } |
| 766 |
740 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const { | 767 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const { |
741 return layerTreeAsJSON(flags)->toPrettyJSONString(); | 768 return layerTreeAsJSON(flags)->toPrettyJSONString(); |
742 } | 769 } |
743 | 770 |
744 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) { | 771 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) { |
745 return webLayer ? webLayer->ccLayer() : nullptr; | 772 return webLayer ? webLayer->ccLayer() : nullptr; |
746 } | 773 } |
747 | 774 |
748 String GraphicsLayer::debugName(cc::Layer* layer) const { | 775 String GraphicsLayer::debugName(cc::Layer* layer) const { |
749 String name; | 776 String name; |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { | 1264 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { |
1238 if (!layer) { | 1265 if (!layer) { |
1239 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1266 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1240 return; | 1267 return; |
1241 } | 1268 } |
1242 | 1269 |
1243 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1270 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1244 fprintf(stderr, "%s\n", output.utf8().data()); | 1271 fprintf(stderr, "%s\n", output.utf8().data()); |
1245 } | 1272 } |
1246 #endif | 1273 #endif |
OLD | NEW |