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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 , m_backfaceVisibility(true) | 117 , m_backfaceVisibility(true) |
118 , m_masksToBounds(false) | 118 , m_masksToBounds(false) |
119 , m_drawsContent(false) | 119 , m_drawsContent(false) |
120 , m_contentsVisible(true) | 120 , m_contentsVisible(true) |
121 , m_showDebugBorder(false) | 121 , m_showDebugBorder(false) |
122 , m_showRepaintCounter(false) | 122 , m_showRepaintCounter(false) |
123 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) | 123 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) |
124 , m_contentsOrientation(CompositingCoordinatesTopDown) | 124 , m_contentsOrientation(CompositingCoordinatesTopDown) |
125 , m_parent(0) | 125 , m_parent(0) |
126 , m_maskLayer(0) | 126 , m_maskLayer(0) |
| 127 , m_borderRadiusLayer(0) |
127 , m_replicaLayer(0) | 128 , m_replicaLayer(0) |
128 , m_replicatedLayer(0) | 129 , m_replicatedLayer(0) |
129 , m_repaintCount(0) | 130 , m_repaintCount(0) |
130 , m_contentsLayer(0) | 131 , m_contentsLayer(0) |
131 , m_contentsLayerId(0) | 132 , m_contentsLayerId(0) |
132 , m_linkHighlight(0) | 133 , m_linkHighlight(0) |
133 , m_contentsLayerPurpose(NoContentsLayer) | 134 , m_contentsLayerPurpose(NoContentsLayer) |
134 , m_scrollableArea(0) | 135 , m_scrollableArea(0) |
135 { | 136 { |
136 #ifndef NDEBUG | 137 #ifndef NDEBUG |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 } | 614 } |
614 | 615 |
615 void GraphicsLayer::updateContentsRect() | 616 void GraphicsLayer::updateContentsRect() |
616 { | 617 { |
617 WebLayer* contentsLayer = contentsLayerIfRegistered(); | 618 WebLayer* contentsLayer = contentsLayerIfRegistered(); |
618 if (!contentsLayer) | 619 if (!contentsLayer) |
619 return; | 620 return; |
620 | 621 |
621 contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y()
)); | 622 contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y()
)); |
622 contentsLayer->setBounds(IntSize(m_contentsRect.width(), m_contentsRect.heig
ht())); | 623 contentsLayer->setBounds(IntSize(m_contentsRect.width(), m_contentsRect.heig
ht())); |
| 624 |
| 625 if (m_borderRadiusLayer) { |
| 626 if (m_borderRadiusLayer->size() != m_contentsRect.size()) { |
| 627 m_borderRadiusLayer->setSize(m_contentsRect.size()); |
| 628 m_borderRadiusLayer->setNeedsDisplay(); |
| 629 } |
| 630 m_borderRadiusLayer->setPosition(FloatPoint()); |
| 631 m_borderRadiusLayer->setOffsetFromRenderer(offsetFromRenderer() + IntSiz
e(m_contentsRect.location().x(), m_contentsRect.location().y())); |
| 632 } |
623 } | 633 } |
624 | 634 |
625 static HashSet<int>* s_registeredLayerSet; | 635 static HashSet<int>* s_registeredLayerSet; |
626 | 636 |
627 void GraphicsLayer::registerContentsLayer(WebLayer* layer) | 637 void GraphicsLayer::registerContentsLayer(WebLayer* layer) |
628 { | 638 { |
629 if (!s_registeredLayerSet) | 639 if (!s_registeredLayerSet) |
630 s_registeredLayerSet = new HashSet<int>; | 640 s_registeredLayerSet = new HashSet<int>; |
631 if (s_registeredLayerSet->contains(layer->id())) | 641 if (s_registeredLayerSet->contains(layer->id())) |
632 CRASH(); | 642 CRASH(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 m_contentsLayer->setAnchorPoint(FloatPoint(0, 0)); | 686 m_contentsLayer->setAnchorPoint(FloatPoint(0, 0)); |
677 m_contentsLayer->setUseParentBackfaceVisibility(true); | 687 m_contentsLayer->setUseParentBackfaceVisibility(true); |
678 | 688 |
679 // It is necessary to call setDrawsContent as soon as we receive the new
contentsLayer, for | 689 // It is necessary to call setDrawsContent as soon as we receive the new
contentsLayer, for |
680 // the correctness of early exit conditions in setDrawsContent() and set
ContentsVisible(). | 690 // the correctness of early exit conditions in setDrawsContent() and set
ContentsVisible(). |
681 m_contentsLayer->setDrawsContent(m_contentsVisible); | 691 m_contentsLayer->setDrawsContent(m_contentsVisible); |
682 | 692 |
683 // Insert the content layer first. Video elements require this, because
they have | 693 // Insert the content layer first. Video elements require this, because
they have |
684 // shadow content that must display in front of the video. | 694 // shadow content that must display in front of the video. |
685 m_layer->layer()->insertChild(m_contentsLayer, 0); | 695 m_layer->layer()->insertChild(m_contentsLayer, 0); |
| 696 WebLayer* borderWebLayer = m_borderRadiusLayer ? m_borderRadiusLayer->pl
atformLayer() : 0; |
| 697 m_contentsLayer->setMaskLayer(borderWebLayer); |
686 } | 698 } |
687 updateNames(); | 699 updateNames(); |
688 } | 700 } |
689 | 701 |
690 void GraphicsLayer::clearContentsLayerIfUnregistered() | 702 void GraphicsLayer::clearContentsLayerIfUnregistered() |
691 { | 703 { |
692 if (!m_contentsLayerId || s_registeredLayerSet->contains(m_contentsLayerId)) | 704 if (!m_contentsLayerId || s_registeredLayerSet->contains(m_contentsLayerId)) |
693 return; | 705 return; |
694 | 706 |
695 m_contentsLayer = 0; | 707 m_contentsLayer = 0; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 ts << "GraphicsLayerPaintBackground\n"; | 897 ts << "GraphicsLayerPaintBackground\n"; |
886 } | 898 } |
887 if (paintingPhase() & GraphicsLayerPaintForeground) { | 899 if (paintingPhase() & GraphicsLayerPaintForeground) { |
888 writeIndent(ts, indent + 2); | 900 writeIndent(ts, indent + 2); |
889 ts << "GraphicsLayerPaintForeground\n"; | 901 ts << "GraphicsLayerPaintForeground\n"; |
890 } | 902 } |
891 if (paintingPhase() & GraphicsLayerPaintMask) { | 903 if (paintingPhase() & GraphicsLayerPaintMask) { |
892 writeIndent(ts, indent + 2); | 904 writeIndent(ts, indent + 2); |
893 ts << "GraphicsLayerPaintMask\n"; | 905 ts << "GraphicsLayerPaintMask\n"; |
894 } | 906 } |
| 907 if (paintingPhase() & GraphicsLayerPaintBorderRadiusMask) { |
| 908 writeIndent(ts, indent + 2); |
| 909 ts << "GraphicsLayerPaintBorderRadiusMask\n"; |
| 910 } |
895 if (paintingPhase() & GraphicsLayerPaintOverflowContents) { | 911 if (paintingPhase() & GraphicsLayerPaintOverflowContents) { |
896 writeIndent(ts, indent + 2); | 912 writeIndent(ts, indent + 2); |
897 ts << "GraphicsLayerPaintOverflowContents\n"; | 913 ts << "GraphicsLayerPaintOverflowContents\n"; |
898 } | 914 } |
899 if (paintingPhase() & GraphicsLayerPaintCompositedScroll) { | 915 if (paintingPhase() & GraphicsLayerPaintCompositedScroll) { |
900 writeIndent(ts, indent + 2); | 916 writeIndent(ts, indent + 2); |
901 ts << "GraphicsLayerPaintCompositedScroll\n"; | 917 ts << "GraphicsLayerPaintCompositedScroll\n"; |
902 } | 918 } |
903 writeIndent(ts, indent + 1); | 919 writeIndent(ts, indent + 1); |
904 ts << ")\n"; | 920 ts << ")\n"; |
(...skipping 20 matching lines...) Expand all Loading... |
925 dumpLayer(ts, 0, flags); | 941 dumpLayer(ts, 0, flags); |
926 return ts.release(); | 942 return ts.release(); |
927 } | 943 } |
928 | 944 |
929 void GraphicsLayer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 945 void GraphicsLayer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
930 { | 946 { |
931 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Layers); | 947 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Layers); |
932 info.addMember(m_children, "children"); | 948 info.addMember(m_children, "children"); |
933 info.addMember(m_parent, "parent"); | 949 info.addMember(m_parent, "parent"); |
934 info.addMember(m_maskLayer, "maskLayer"); | 950 info.addMember(m_maskLayer, "maskLayer"); |
| 951 info.addMember(m_borderRadiusLayer, "borderRadiusLayer"); |
935 info.addMember(m_replicaLayer, "replicaLayer"); | 952 info.addMember(m_replicaLayer, "replicaLayer"); |
936 info.addMember(m_replicatedLayer, "replicatedLayer"); | 953 info.addMember(m_replicatedLayer, "replicatedLayer"); |
937 info.ignoreMember(m_client); | 954 info.ignoreMember(m_client); |
938 info.addMember(m_name, "name"); | 955 info.addMember(m_name, "name"); |
939 info.addMember(m_nameBase, "nameBase"); | 956 info.addMember(m_nameBase, "nameBase"); |
940 info.addMember(m_layer, "layer"); | 957 info.addMember(m_layer, "layer"); |
941 info.addMember(m_imageLayer, "imageLayer"); | 958 info.addMember(m_imageLayer, "imageLayer"); |
942 info.addMember(m_contentsLayer, "contentsLayer"); | 959 info.addMember(m_contentsLayer, "contentsLayer"); |
943 info.addMember(m_linkHighlight, "linkHighlight"); | 960 info.addMember(m_linkHighlight, "linkHighlight"); |
944 info.addMember(m_opaqueRectTrackingContentLayerDelegate, "opaqueRectTracking
ContentLayerDelegate"); | 961 info.addMember(m_opaqueRectTrackingContentLayerDelegate, "opaqueRectTracking
ContentLayerDelegate"); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 void GraphicsLayer::setMaskLayer(GraphicsLayer* maskLayer) | 1080 void GraphicsLayer::setMaskLayer(GraphicsLayer* maskLayer) |
1064 { | 1081 { |
1065 if (maskLayer == m_maskLayer) | 1082 if (maskLayer == m_maskLayer) |
1066 return; | 1083 return; |
1067 | 1084 |
1068 m_maskLayer = maskLayer; | 1085 m_maskLayer = maskLayer; |
1069 WebLayer* maskWebLayer = m_maskLayer ? m_maskLayer->platformLayer() : 0; | 1086 WebLayer* maskWebLayer = m_maskLayer ? m_maskLayer->platformLayer() : 0; |
1070 m_layer->layer()->setMaskLayer(maskWebLayer); | 1087 m_layer->layer()->setMaskLayer(maskWebLayer); |
1071 } | 1088 } |
1072 | 1089 |
| 1090 void GraphicsLayer::setBorderRadiusLayer(GraphicsLayer* borderRadiusLayer) |
| 1091 { |
| 1092 if (borderRadiusLayer == m_borderRadiusLayer) |
| 1093 return; |
| 1094 |
| 1095 m_borderRadiusLayer = borderRadiusLayer; |
| 1096 WebLayer* borderRadiusWebLayer = m_borderRadiusLayer ? m_borderRadiusLayer->
platformLayer() : 0; |
| 1097 if (hasContentsLayer()) |
| 1098 contentsLayer()->setMaskLayer(borderRadiusWebLayer); |
| 1099 updateContentsRect(); |
| 1100 } |
| 1101 |
1073 void GraphicsLayer::setBackfaceVisibility(bool visible) | 1102 void GraphicsLayer::setBackfaceVisibility(bool visible) |
1074 { | 1103 { |
1075 m_backfaceVisibility = visible; | 1104 m_backfaceVisibility = visible; |
1076 m_layer->setDoubleSided(m_backfaceVisibility); | 1105 m_layer->setDoubleSided(m_backfaceVisibility); |
1077 } | 1106 } |
1078 | 1107 |
1079 void GraphicsLayer::setOpacity(float opacity) | 1108 void GraphicsLayer::setOpacity(float opacity) |
1080 { | 1109 { |
1081 float clampedOpacity = std::max(std::min(opacity, 1.0f), 0.0f); | 1110 float clampedOpacity = std::max(std::min(opacity, 1.0f), 0.0f); |
1082 m_opacity = clampedOpacity; | 1111 m_opacity = clampedOpacity; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 #ifndef NDEBUG | 1393 #ifndef NDEBUG |
1365 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) | 1394 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) |
1366 { | 1395 { |
1367 if (!layer) | 1396 if (!layer) |
1368 return; | 1397 return; |
1369 | 1398 |
1370 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); | 1399 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); |
1371 fprintf(stderr, "%s\n", output.utf8().data()); | 1400 fprintf(stderr, "%s\n", output.utf8().data()); |
1372 } | 1401 } |
1373 #endif | 1402 #endif |
OLD | NEW |