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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "wtf/HashMap.h" | 51 #include "wtf/HashMap.h" |
52 #include "wtf/HashSet.h" | 52 #include "wtf/HashSet.h" |
53 #include "wtf/text/WTFString.h" | 53 #include "wtf/text/WTFString.h" |
54 | 54 |
55 #include <algorithm> | 55 #include <algorithm> |
56 | 56 |
57 #ifndef NDEBUG | 57 #ifndef NDEBUG |
58 #include <stdio.h> | 58 #include <stdio.h> |
59 #endif | 59 #endif |
60 | 60 |
61 using blink::Platform; | |
62 using blink::WebAnimation; | |
63 using blink::WebFilterOperations; | |
64 using blink::WebLayer; | |
65 using blink::WebPoint; | |
66 | |
67 namespace blink { | 61 namespace blink { |
68 | 62 |
69 typedef HashMap<const GraphicsLayer*, Vector<FloatRect> > RepaintMap; | 63 typedef HashMap<const GraphicsLayer*, Vector<FloatRect> > RepaintMap; |
70 static RepaintMap& repaintRectMap() | 64 static RepaintMap& repaintRectMap() |
71 { | 65 { |
72 DEFINE_STATIC_LOCAL(RepaintMap, map, ()); | 66 DEFINE_STATIC_LOCAL(RepaintMap, map, ()); |
73 return map; | 67 return map; |
74 } | 68 } |
75 | 69 |
76 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, G
raphicsLayerClient* client) | 70 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, G
raphicsLayerClient* client) |
77 { | 71 { |
78 return factory->createGraphicsLayer(client); | 72 return factory->createGraphicsLayer(client); |
79 } | 73 } |
80 | 74 |
81 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) | 75 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) |
82 : m_client(client) | 76 : m_client(client) |
83 , m_backgroundColor(Color::transparent) | 77 , m_backgroundColor(Color::transparent) |
84 , m_opacity(1) | 78 , m_opacity(1) |
85 , m_blendMode(blink::WebBlendModeNormal) | 79 , m_blendMode(WebBlendModeNormal) |
86 , m_hasTransformOrigin(false) | 80 , m_hasTransformOrigin(false) |
87 , m_contentsOpaque(false) | 81 , m_contentsOpaque(false) |
88 , m_shouldFlattenTransform(true) | 82 , m_shouldFlattenTransform(true) |
89 , m_backfaceVisibility(true) | 83 , m_backfaceVisibility(true) |
90 , m_masksToBounds(false) | 84 , m_masksToBounds(false) |
91 , m_drawsContent(false) | 85 , m_drawsContent(false) |
92 , m_contentsVisible(true) | 86 , m_contentsVisible(true) |
93 , m_isRootForIsolatedGroup(false) | 87 , m_isRootForIsolatedGroup(false) |
94 , m_hasScrollParent(false) | 88 , m_hasScrollParent(false) |
95 , m_hasClipParent(false) | 89 , m_hasClipParent(false) |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 404 |
411 m_contentsLayer = 0; | 405 m_contentsLayer = 0; |
412 m_contentsLayerId = 0; | 406 m_contentsLayerId = 0; |
413 } | 407 } |
414 | 408 |
415 GraphicsLayerDebugInfo& GraphicsLayer::debugInfo() | 409 GraphicsLayerDebugInfo& GraphicsLayer::debugInfo() |
416 { | 410 { |
417 return m_debugInfo; | 411 return m_debugInfo; |
418 } | 412 } |
419 | 413 |
420 blink::WebGraphicsLayerDebugInfo* GraphicsLayer::takeDebugInfoFor(WebLayer* laye
r) | 414 WebGraphicsLayerDebugInfo* GraphicsLayer::takeDebugInfoFor(WebLayer* layer) |
421 { | 415 { |
422 GraphicsLayerDebugInfo* clone = m_debugInfo.clone(); | 416 GraphicsLayerDebugInfo* clone = m_debugInfo.clone(); |
423 clone->setDebugName(debugName(layer)); | 417 clone->setDebugName(debugName(layer)); |
424 return clone; | 418 return clone; |
425 } | 419 } |
426 | 420 |
427 WebLayer* GraphicsLayer::contentsLayerIfRegistered() | 421 WebLayer* GraphicsLayer::contentsLayerIfRegistered() |
428 { | 422 { |
429 clearContentsLayerIfUnregistered(); | 423 clearContentsLayerIfUnregistered(); |
430 return m_contentsLayer; | 424 return m_contentsLayer; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 550 |
557 if (m_hasTransformOrigin && m_transformOrigin != FloatPoint3D(m_size.width()
* 0.5f, m_size.height() * 0.5f, 0)) | 551 if (m_hasTransformOrigin && m_transformOrigin != FloatPoint3D(m_size.width()
* 0.5f, m_size.height() * 0.5f, 0)) |
558 json->setArray("transformOrigin", pointAsJSONArray(m_transformOrigin)); | 552 json->setArray("transformOrigin", pointAsJSONArray(m_transformOrigin)); |
559 | 553 |
560 if (m_size != IntSize()) | 554 if (m_size != IntSize()) |
561 json->setArray("bounds", sizeAsJSONArray(m_size)); | 555 json->setArray("bounds", sizeAsJSONArray(m_size)); |
562 | 556 |
563 if (m_opacity != 1) | 557 if (m_opacity != 1) |
564 json->setNumber("opacity", m_opacity); | 558 json->setNumber("opacity", m_opacity); |
565 | 559 |
566 if (m_blendMode != blink::WebBlendModeNormal) | 560 if (m_blendMode != WebBlendModeNormal) |
567 json->setString("blendMode", compositeOperatorName(CompositeSourceOver,
m_blendMode)); | 561 json->setString("blendMode", compositeOperatorName(CompositeSourceOver,
m_blendMode)); |
568 | 562 |
569 if (m_isRootForIsolatedGroup) | 563 if (m_isRootForIsolatedGroup) |
570 json->setBoolean("isolate", m_isRootForIsolatedGroup); | 564 json->setBoolean("isolate", m_isRootForIsolatedGroup); |
571 | 565 |
572 if (m_contentsOpaque) | 566 if (m_contentsOpaque) |
573 json->setBoolean("contentsOpaque", m_contentsOpaque); | 567 json->setBoolean("contentsOpaque", m_contentsOpaque); |
574 | 568 |
575 if (!m_shouldFlattenTransform) | 569 if (!m_shouldFlattenTransform) |
576 json->setBoolean("shouldFlattenTransform", m_shouldFlattenTransform); | 570 json->setBoolean("shouldFlattenTransform", m_shouldFlattenTransform); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 return json; | 659 return json; |
666 } | 660 } |
667 | 661 |
668 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const | 662 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const |
669 { | 663 { |
670 RenderingContextMap renderingContextMap; | 664 RenderingContextMap renderingContextMap; |
671 RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); | 665 RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); |
672 return json->toPrettyJSONString(); | 666 return json->toPrettyJSONString(); |
673 } | 667 } |
674 | 668 |
675 String GraphicsLayer::debugName(blink::WebLayer* webLayer) const | 669 String GraphicsLayer::debugName(WebLayer* webLayer) const |
676 { | 670 { |
677 String name; | 671 String name; |
678 if (!m_client) | 672 if (!m_client) |
679 return name; | 673 return name; |
680 | 674 |
681 String highlightDebugName; | 675 String highlightDebugName; |
682 for (size_t i = 0; i < m_linkHighlights.size(); ++i) { | 676 for (size_t i = 0; i < m_linkHighlights.size(); ++i) { |
683 if (webLayer == m_linkHighlights[i]->layer()) { | 677 if (webLayer == m_linkHighlights[i]->layer()) { |
684 highlightDebugName = "LinkHighlight[" + String::number(i) + "] for "
+ m_client->debugName(this); | 678 highlightDebugName = "LinkHighlight[" + String::number(i) + "] for "
+ m_client->debugName(this); |
685 break; | 679 break; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 { | 782 { |
789 // Note carefully this early-exit is only correct because we also properly c
all | 783 // Note carefully this early-exit is only correct because we also properly c
all |
790 // WebLayer::setDrawsContent whenever m_contentsLayer is set to a new layer
in setupContentsLayer(). | 784 // WebLayer::setDrawsContent whenever m_contentsLayer is set to a new layer
in setupContentsLayer(). |
791 if (contentsVisible == m_contentsVisible) | 785 if (contentsVisible == m_contentsVisible) |
792 return; | 786 return; |
793 | 787 |
794 m_contentsVisible = contentsVisible; | 788 m_contentsVisible = contentsVisible; |
795 updateLayerIsDrawable(); | 789 updateLayerIsDrawable(); |
796 } | 790 } |
797 | 791 |
798 void GraphicsLayer::setClipParent(blink::WebLayer* parent) | 792 void GraphicsLayer::setClipParent(WebLayer* parent) |
799 { | 793 { |
800 m_hasClipParent = !!parent; | 794 m_hasClipParent = !!parent; |
801 m_layer->layer()->setClipParent(parent); | 795 m_layer->layer()->setClipParent(parent); |
802 } | 796 } |
803 | 797 |
804 void GraphicsLayer::setScrollParent(blink::WebLayer* parent) | 798 void GraphicsLayer::setScrollParent(WebLayer* parent) |
805 { | 799 { |
806 m_hasScrollParent = !!parent; | 800 m_hasScrollParent = !!parent; |
807 m_layer->layer()->setScrollParent(parent); | 801 m_layer->layer()->setScrollParent(parent); |
808 } | 802 } |
809 | 803 |
810 void GraphicsLayer::setBackgroundColor(const Color& color) | 804 void GraphicsLayer::setBackgroundColor(const Color& color) |
811 { | 805 { |
812 if (color == m_backgroundColor) | 806 if (color == m_backgroundColor) |
813 return; | 807 return; |
814 | 808 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 m_layer->setDoubleSided(m_backfaceVisibility); | 849 m_layer->setDoubleSided(m_backfaceVisibility); |
856 } | 850 } |
857 | 851 |
858 void GraphicsLayer::setOpacity(float opacity) | 852 void GraphicsLayer::setOpacity(float opacity) |
859 { | 853 { |
860 float clampedOpacity = std::max(std::min(opacity, 1.0f), 0.0f); | 854 float clampedOpacity = std::max(std::min(opacity, 1.0f), 0.0f); |
861 m_opacity = clampedOpacity; | 855 m_opacity = clampedOpacity; |
862 platformLayer()->setOpacity(opacity); | 856 platformLayer()->setOpacity(opacity); |
863 } | 857 } |
864 | 858 |
865 void GraphicsLayer::setBlendMode(blink::WebBlendMode blendMode) | 859 void GraphicsLayer::setBlendMode(WebBlendMode blendMode) |
866 { | 860 { |
867 if (m_blendMode == blendMode) | 861 if (m_blendMode == blendMode) |
868 return; | 862 return; |
869 m_blendMode = blendMode; | 863 m_blendMode = blendMode; |
870 platformLayer()->setBlendMode(blink::WebBlendMode(blendMode)); | 864 platformLayer()->setBlendMode(WebBlendMode(blendMode)); |
871 } | 865 } |
872 | 866 |
873 void GraphicsLayer::setIsRootForIsolatedGroup(bool isolated) | 867 void GraphicsLayer::setIsRootForIsolatedGroup(bool isolated) |
874 { | 868 { |
875 if (m_isRootForIsolatedGroup == isolated) | 869 if (m_isRootForIsolatedGroup == isolated) |
876 return; | 870 return; |
877 m_isRootForIsolatedGroup = isolated; | 871 m_isRootForIsolatedGroup = isolated; |
878 platformLayer()->setIsRootForIsolatedGroup(isolated); | 872 platformLayer()->setIsRootForIsolatedGroup(isolated); |
879 } | 873 } |
880 | 874 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 #ifndef NDEBUG | 1049 #ifndef NDEBUG |
1056 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) | 1050 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) |
1057 { | 1051 { |
1058 if (!layer) | 1052 if (!layer) |
1059 return; | 1053 return; |
1060 | 1054 |
1061 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1055 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1062 fprintf(stderr, "%s\n", output.utf8().data()); | 1056 fprintf(stderr, "%s\n", output.utf8().data()); |
1063 } | 1057 } |
1064 #endif | 1058 #endif |
OLD | NEW |