| 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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 if (a.y() != b.y()) | 573 if (a.y() != b.y()) |
| 574 return a.y() > b.y(); | 574 return a.y() > b.y(); |
| 575 if (a.width() != b.width()) | 575 if (a.width() != b.width()) |
| 576 return a.width() > b.width(); | 576 return a.width() > b.width(); |
| 577 return a.height() > b.height(); | 577 return a.height() > b.height(); |
| 578 } | 578 } |
| 579 | 579 |
| 580 template <typename T> | 580 template <typename T> |
| 581 static PassRefPtr<JSONArray> pointAsJSONArray(const T& point) | 581 static PassRefPtr<JSONArray> pointAsJSONArray(const T& point) |
| 582 { | 582 { |
| 583 RefPtr<JSONArray> array = JSONArray::create(); | 583 RefPtr<JSONArray> array = adoptRef(new JSONArray); |
| 584 array->pushNumber(point.x()); | 584 array->pushNumber(point.x()); |
| 585 array->pushNumber(point.y()); | 585 array->pushNumber(point.y()); |
| 586 return array; | 586 return array; |
| 587 } | 587 } |
| 588 | 588 |
| 589 template <typename T> | 589 template <typename T> |
| 590 static PassRefPtr<JSONArray> sizeAsJSONArray(const T& size) | 590 static PassRefPtr<JSONArray> sizeAsJSONArray(const T& size) |
| 591 { | 591 { |
| 592 RefPtr<JSONArray> array = JSONArray::create(); | 592 RefPtr<JSONArray> array = adoptRef(new JSONArray); |
| 593 array->pushNumber(size.width()); | 593 array->pushNumber(size.width()); |
| 594 array->pushNumber(size.height()); | 594 array->pushNumber(size.height()); |
| 595 return array; | 595 return array; |
| 596 } | 596 } |
| 597 | 597 |
| 598 template <typename T> | 598 template <typename T> |
| 599 static PassRefPtr<JSONArray> rectAsJSONArray(const T& rect) | 599 static PassRefPtr<JSONArray> rectAsJSONArray(const T& rect) |
| 600 { | 600 { |
| 601 RefPtr<JSONArray> array = JSONArray::create(); | 601 RefPtr<JSONArray> array = adoptRef(new JSONArray); |
| 602 array->pushNumber(rect.x()); | 602 array->pushNumber(rect.x()); |
| 603 array->pushNumber(rect.y()); | 603 array->pushNumber(rect.y()); |
| 604 array->pushNumber(rect.width()); | 604 array->pushNumber(rect.width()); |
| 605 array->pushNumber(rect.height()); | 605 array->pushNumber(rect.height()); |
| 606 return array; | 606 return array; |
| 607 } | 607 } |
| 608 | 608 |
| 609 static double roundCloseToZero(double number) | 609 static double roundCloseToZero(double number) |
| 610 { | 610 { |
| 611 return std::abs(number) < 1e-7 ? 0 : number; | 611 return std::abs(number) < 1e-7 ? 0 : number; |
| 612 } | 612 } |
| 613 | 613 |
| 614 static PassRefPtr<JSONArray> transformAsJSONArray(const TransformationMatrix& t) | 614 static PassRefPtr<JSONArray> transformAsJSONArray(const TransformationMatrix& t) |
| 615 { | 615 { |
| 616 RefPtr<JSONArray> array = JSONArray::create(); | 616 RefPtr<JSONArray> array = adoptRef(new JSONArray); |
| 617 { | 617 { |
| 618 RefPtr<JSONArray> row = JSONArray::create(); | 618 RefPtr<JSONArray> row = adoptRef(new JSONArray); |
| 619 row->pushNumber(roundCloseToZero(t.m11())); | 619 row->pushNumber(roundCloseToZero(t.m11())); |
| 620 row->pushNumber(roundCloseToZero(t.m12())); | 620 row->pushNumber(roundCloseToZero(t.m12())); |
| 621 row->pushNumber(roundCloseToZero(t.m13())); | 621 row->pushNumber(roundCloseToZero(t.m13())); |
| 622 row->pushNumber(roundCloseToZero(t.m14())); | 622 row->pushNumber(roundCloseToZero(t.m14())); |
| 623 array->pushArray(row); | 623 array->pushArray(row); |
| 624 } | 624 } |
| 625 { | 625 { |
| 626 RefPtr<JSONArray> row = JSONArray::create(); | 626 RefPtr<JSONArray> row = adoptRef(new JSONArray); |
| 627 row->pushNumber(roundCloseToZero(t.m21())); | 627 row->pushNumber(roundCloseToZero(t.m21())); |
| 628 row->pushNumber(roundCloseToZero(t.m22())); | 628 row->pushNumber(roundCloseToZero(t.m22())); |
| 629 row->pushNumber(roundCloseToZero(t.m23())); | 629 row->pushNumber(roundCloseToZero(t.m23())); |
| 630 row->pushNumber(roundCloseToZero(t.m24())); | 630 row->pushNumber(roundCloseToZero(t.m24())); |
| 631 array->pushArray(row); | 631 array->pushArray(row); |
| 632 } | 632 } |
| 633 { | 633 { |
| 634 RefPtr<JSONArray> row = JSONArray::create(); | 634 RefPtr<JSONArray> row = adoptRef(new JSONArray); |
| 635 row->pushNumber(roundCloseToZero(t.m31())); | 635 row->pushNumber(roundCloseToZero(t.m31())); |
| 636 row->pushNumber(roundCloseToZero(t.m32())); | 636 row->pushNumber(roundCloseToZero(t.m32())); |
| 637 row->pushNumber(roundCloseToZero(t.m33())); | 637 row->pushNumber(roundCloseToZero(t.m33())); |
| 638 row->pushNumber(roundCloseToZero(t.m34())); | 638 row->pushNumber(roundCloseToZero(t.m34())); |
| 639 array->pushArray(row); | 639 array->pushArray(row); |
| 640 } | 640 } |
| 641 { | 641 { |
| 642 RefPtr<JSONArray> row = JSONArray::create(); | 642 RefPtr<JSONArray> row = adoptRef(new JSONArray); |
| 643 row->pushNumber(roundCloseToZero(t.m41())); | 643 row->pushNumber(roundCloseToZero(t.m41())); |
| 644 row->pushNumber(roundCloseToZero(t.m42())); | 644 row->pushNumber(roundCloseToZero(t.m42())); |
| 645 row->pushNumber(roundCloseToZero(t.m43())); | 645 row->pushNumber(roundCloseToZero(t.m43())); |
| 646 row->pushNumber(roundCloseToZero(t.m44())); | 646 row->pushNumber(roundCloseToZero(t.m44())); |
| 647 array->pushArray(row); | 647 array->pushArray(row); |
| 648 } | 648 } |
| 649 return array; | 649 return array; |
| 650 } | 650 } |
| 651 | 651 |
| 652 static String pointerAsString(const void* ptr) | 652 static String pointerAsString(const void* ptr) |
| 653 { | 653 { |
| 654 TextStream ts; | 654 TextStream ts; |
| 655 ts << ptr; | 655 ts << ptr; |
| 656 return ts.release(); | 656 return ts.release(); |
| 657 } | 657 } |
| 658 | 658 |
| 659 PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags, Rend
eringContextMap& renderingContextMap) const | 659 PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags, Rend
eringContextMap& renderingContextMap) const |
| 660 { | 660 { |
| 661 RefPtr<JSONObject> json = JSONObject::create(); | 661 RefPtr<JSONObject> json = adoptRef(new JSONObject); |
| 662 | 662 |
| 663 if (flags & LayerTreeIncludesDebugInfo) { | 663 if (flags & LayerTreeIncludesDebugInfo) { |
| 664 json->setString("this", pointerAsString(this)); | 664 json->setString("this", pointerAsString(this)); |
| 665 json->setString("debugName", m_client->debugName(this)); | 665 json->setString("debugName", m_client->debugName(this)); |
| 666 } | 666 } |
| 667 | 667 |
| 668 if (m_position != FloatPoint()) | 668 if (m_position != FloatPoint()) |
| 669 json->setArray("position", pointAsJSONArray(m_position)); | 669 json->setArray("position", pointAsJSONArray(m_position)); |
| 670 | 670 |
| 671 if (m_hasTransformOrigin && m_transformOrigin != FloatPoint3D(m_size.width()
* 0.5f, m_size.height() * 0.5f, 0)) | 671 if (m_hasTransformOrigin && m_transformOrigin != FloatPoint3D(m_size.width()
* 0.5f, m_size.height() * 0.5f, 0)) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 | 723 |
| 724 if (m_replicatedLayer) | 724 if (m_replicatedLayer) |
| 725 json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ?
pointerAsString(m_replicatedLayer) : ""); | 725 json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ?
pointerAsString(m_replicatedLayer) : ""); |
| 726 | 726 |
| 727 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); | 727 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); |
| 728 if (it != paintInvalidationTrackingMap().end()) { | 728 if (it != paintInvalidationTrackingMap().end()) { |
| 729 if (flags & LayerTreeIncludesPaintInvalidationRects) { | 729 if (flags & LayerTreeIncludesPaintInvalidationRects) { |
| 730 Vector<FloatRect>& rects = it->value.invalidationRects; | 730 Vector<FloatRect>& rects = it->value.invalidationRects; |
| 731 if (!rects.isEmpty()) { | 731 if (!rects.isEmpty()) { |
| 732 std::sort(rects.begin(), rects.end(), &compareFloatRects); | 732 std::sort(rects.begin(), rects.end(), &compareFloatRects); |
| 733 RefPtr<JSONArray> rectsJSON = JSONArray::create(); | 733 RefPtr<JSONArray> rectsJSON = adoptRef(new JSONArray); |
| 734 for (auto& rect : rects) { | 734 for (auto& rect : rects) { |
| 735 if (rect.isEmpty()) | 735 if (rect.isEmpty()) |
| 736 continue; | 736 continue; |
| 737 rectsJSON->pushArray(rectAsJSONArray(rect)); | 737 rectsJSON->pushArray(rectAsJSONArray(rect)); |
| 738 } | 738 } |
| 739 json->setArray("repaintRects", rectsJSON); | 739 json->setArray("repaintRects", rectsJSON); |
| 740 } | 740 } |
| 741 } | 741 } |
| 742 | 742 |
| 743 if (flags & LayerTreeIncludesPaintInvalidationObjects) { | 743 if (flags & LayerTreeIncludesPaintInvalidationObjects) { |
| 744 Vector<String>& clients = it->value.invalidationObjects; | 744 Vector<String>& clients = it->value.invalidationObjects; |
| 745 if (!clients.isEmpty()) { | 745 if (!clients.isEmpty()) { |
| 746 RefPtr<JSONArray> clientsJSON = JSONArray::create(); | 746 RefPtr<JSONArray> clientsJSON = adoptRef(new JSONArray); |
| 747 for (auto& clientString : clients) | 747 for (auto& clientString : clients) |
| 748 clientsJSON->pushString(clientString); | 748 clientsJSON->pushString(clientString); |
| 749 json->setArray("paintInvalidationClients", clientsJSON); | 749 json->setArray("paintInvalidationClients", clientsJSON); |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 | 753 |
| 754 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { | 754 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { |
| 755 RefPtr<JSONArray> paintingPhasesJSON = JSONArray::create(); | 755 RefPtr<JSONArray> paintingPhasesJSON = adoptRef(new JSONArray); |
| 756 if (m_paintingPhase & GraphicsLayerPaintBackground) | 756 if (m_paintingPhase & GraphicsLayerPaintBackground) |
| 757 paintingPhasesJSON->pushString("GraphicsLayerPaintBackground"); | 757 paintingPhasesJSON->pushString("GraphicsLayerPaintBackground"); |
| 758 if (m_paintingPhase & GraphicsLayerPaintForeground) | 758 if (m_paintingPhase & GraphicsLayerPaintForeground) |
| 759 paintingPhasesJSON->pushString("GraphicsLayerPaintForeground"); | 759 paintingPhasesJSON->pushString("GraphicsLayerPaintForeground"); |
| 760 if (m_paintingPhase & GraphicsLayerPaintMask) | 760 if (m_paintingPhase & GraphicsLayerPaintMask) |
| 761 paintingPhasesJSON->pushString("GraphicsLayerPaintMask"); | 761 paintingPhasesJSON->pushString("GraphicsLayerPaintMask"); |
| 762 if (m_paintingPhase & GraphicsLayerPaintChildClippingMask) | 762 if (m_paintingPhase & GraphicsLayerPaintChildClippingMask) |
| 763 paintingPhasesJSON->pushString("GraphicsLayerPaintChildClippingMask"
); | 763 paintingPhasesJSON->pushString("GraphicsLayerPaintChildClippingMask"
); |
| 764 if (m_paintingPhase & GraphicsLayerPaintOverflowContents) | 764 if (m_paintingPhase & GraphicsLayerPaintOverflowContents) |
| 765 paintingPhasesJSON->pushString("GraphicsLayerPaintOverflowContents")
; | 765 paintingPhasesJSON->pushString("GraphicsLayerPaintOverflowContents")
; |
| 766 if (m_paintingPhase & GraphicsLayerPaintCompositedScroll) | 766 if (m_paintingPhase & GraphicsLayerPaintCompositedScroll) |
| 767 paintingPhasesJSON->pushString("GraphicsLayerPaintCompositedScroll")
; | 767 paintingPhasesJSON->pushString("GraphicsLayerPaintCompositedScroll")
; |
| 768 json->setArray("paintingPhases", paintingPhasesJSON); | 768 json->setArray("paintingPhases", paintingPhasesJSON); |
| 769 } | 769 } |
| 770 | 770 |
| 771 if (flags & LayerTreeIncludesClipAndScrollParents) { | 771 if (flags & LayerTreeIncludesClipAndScrollParents) { |
| 772 if (m_hasScrollParent) | 772 if (m_hasScrollParent) |
| 773 json->setBoolean("hasScrollParent", true); | 773 json->setBoolean("hasScrollParent", true); |
| 774 if (m_hasClipParent) | 774 if (m_hasClipParent) |
| 775 json->setBoolean("hasClipParent", true); | 775 json->setBoolean("hasClipParent", true); |
| 776 } | 776 } |
| 777 | 777 |
| 778 if (flags & (LayerTreeIncludesDebugInfo | LayerTreeIncludesCompositingReason
s)) { | 778 if (flags & (LayerTreeIncludesDebugInfo | LayerTreeIncludesCompositingReason
s)) { |
| 779 bool debug = flags & LayerTreeIncludesDebugInfo; | 779 bool debug = flags & LayerTreeIncludesDebugInfo; |
| 780 RefPtr<JSONArray> compositingReasonsJSON = JSONArray::create(); | 780 RefPtr<JSONArray> compositingReasonsJSON = adoptRef(new JSONArray); |
| 781 for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { | 781 for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { |
| 782 if (m_debugInfo.compositingReasons() & kCompositingReasonStringMap[i
].reason) | 782 if (m_debugInfo.compositingReasons() & kCompositingReasonStringMap[i
].reason) |
| 783 compositingReasonsJSON->pushString(debug ? kCompositingReasonStr
ingMap[i].description : kCompositingReasonStringMap[i].shortName); | 783 compositingReasonsJSON->pushString(debug ? kCompositingReasonStr
ingMap[i].description : kCompositingReasonStringMap[i].shortName); |
| 784 } | 784 } |
| 785 json->setArray("compositingReasons", compositingReasonsJSON); | 785 json->setArray("compositingReasons", compositingReasonsJSON); |
| 786 } | 786 } |
| 787 | 787 |
| 788 if (m_children.size()) { | 788 if (m_children.size()) { |
| 789 RefPtr<JSONArray> childrenJSON = JSONArray::create(); | 789 RefPtr<JSONArray> childrenJSON = adoptRef(new JSONArray); |
| 790 for (size_t i = 0; i < m_children.size(); i++) | 790 for (size_t i = 0; i < m_children.size(); i++) |
| 791 childrenJSON->pushObject(m_children[i]->layerTreeAsJSON(flags, rende
ringContextMap)); | 791 childrenJSON->pushObject(m_children[i]->layerTreeAsJSON(flags, rende
ringContextMap)); |
| 792 json->setArray("children", childrenJSON); | 792 json->setArray("children", childrenJSON); |
| 793 } | 793 } |
| 794 | 794 |
| 795 return json; | 795 return json; |
| 796 } | 796 } |
| 797 | 797 |
| 798 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const | 798 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const |
| 799 { | 799 { |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 { | 1259 { |
| 1260 if (!layer) { | 1260 if (!layer) { |
| 1261 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1261 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
| 1262 return; | 1262 return; |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1265 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
| 1266 fprintf(stderr, "%s\n", output.utf8().data()); | 1266 fprintf(stderr, "%s\n", output.utf8().data()); |
| 1267 } | 1267 } |
| 1268 #endif | 1268 #endif |
| OLD | NEW |