| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 , m_contentsVisible(true) | 96 , m_contentsVisible(true) |
| 97 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) | 97 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) |
| 98 , m_contentsOrientation(CompositingCoordinatesTopDown) | 98 , m_contentsOrientation(CompositingCoordinatesTopDown) |
| 99 , m_parent(0) | 99 , m_parent(0) |
| 100 , m_maskLayer(0) | 100 , m_maskLayer(0) |
| 101 , m_replicaLayer(0) | 101 , m_replicaLayer(0) |
| 102 , m_replicatedLayer(0) | 102 , m_replicatedLayer(0) |
| 103 , m_paintCount(0) | 103 , m_paintCount(0) |
| 104 , m_contentsLayer(0) | 104 , m_contentsLayer(0) |
| 105 , m_contentsLayerId(0) | 105 , m_contentsLayerId(0) |
| 106 , m_linkHighlight(0) | |
| 107 , m_contentsLayerPurpose(NoContentsLayer) | 106 , m_contentsLayerPurpose(NoContentsLayer) |
| 108 , m_scrollableArea(0) | 107 , m_scrollableArea(0) |
| 109 , m_compositingReasons(WebKit::CompositingReasonUnknown) | 108 , m_compositingReasons(WebKit::CompositingReasonUnknown) |
| 110 { | 109 { |
| 111 #ifndef NDEBUG | 110 #ifndef NDEBUG |
| 112 if (m_client) | 111 if (m_client) |
| 113 m_client->verifyNotPainting(); | 112 m_client->verifyNotPainting(); |
| 114 #endif | 113 #endif |
| 115 | 114 |
| 116 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingCo
ntentLayerDelegate(this)); | 115 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingCo
ntentLayerDelegate(this)); |
| 117 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa
yer(m_opaqueRectTrackingContentLayerDelegate.get())); | 116 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa
yer(m_opaqueRectTrackingContentLayerDelegate.get())); |
| 118 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); | 117 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); |
| 119 m_layer->layer()->setWebLayerClient(this); | 118 m_layer->layer()->setWebLayerClient(this); |
| 120 m_layer->setAutomaticallyComputeRasterScale(true); | 119 m_layer->setAutomaticallyComputeRasterScale(true); |
| 121 } | 120 } |
| 122 | 121 |
| 123 GraphicsLayer::~GraphicsLayer() | 122 GraphicsLayer::~GraphicsLayer() |
| 124 { | 123 { |
| 125 if (m_linkHighlight) { | 124 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 126 m_linkHighlight->clearCurrentGraphicsLayer(); | 125 m_linkHighlights[i]->clearCurrentGraphicsLayer(); |
| 127 m_linkHighlight = 0; | 126 m_linkHighlights.clear(); |
| 128 } | |
| 129 | 127 |
| 130 #ifndef NDEBUG | 128 #ifndef NDEBUG |
| 131 if (m_client) | 129 if (m_client) |
| 132 m_client->verifyNotPainting(); | 130 m_client->verifyNotPainting(); |
| 133 #endif | 131 #endif |
| 134 | 132 |
| 135 if (m_replicaLayer) | 133 if (m_replicaLayer) |
| 136 m_replicaLayer->setReplicatedLayer(0); | 134 m_replicaLayer->setReplicatedLayer(0); |
| 137 | 135 |
| 138 if (m_replicatedLayer) | 136 if (m_replicatedLayer) |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 394 } |
| 397 | 395 |
| 398 const Vector<GraphicsLayer*>& childLayers = children(); | 396 const Vector<GraphicsLayer*>& childLayers = children(); |
| 399 size_t numChildren = childLayers.size(); | 397 size_t numChildren = childLayers.size(); |
| 400 for (size_t i = 0; i < numChildren; ++i) { | 398 for (size_t i = 0; i < numChildren; ++i) { |
| 401 GraphicsLayer* curChild = childLayers[i]; | 399 GraphicsLayer* curChild = childLayers[i]; |
| 402 | 400 |
| 403 childHost->addChild(curChild->platformLayer()); | 401 childHost->addChild(curChild->platformLayer()); |
| 404 } | 402 } |
| 405 | 403 |
| 406 if (m_linkHighlight) | 404 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 407 childHost->addChild(m_linkHighlight->layer()); | 405 childHost->addChild(m_linkHighlights[i]->layer()); |
| 408 } | 406 } |
| 409 | 407 |
| 410 void GraphicsLayer::updateLayerIsDrawable() | 408 void GraphicsLayer::updateLayerIsDrawable() |
| 411 { | 409 { |
| 412 // For the rest of the accelerated compositor code, there is no reason to ma
ke a | 410 // For the rest of the accelerated compositor code, there is no reason to ma
ke a |
| 413 // distinction between drawsContent and contentsVisible. So, for m_layer->la
yer(), these two | 411 // distinction between drawsContent and contentsVisible. So, for m_layer->la
yer(), these two |
| 414 // flags are combined here. m_contentsLayer shouldn't receive the drawsConte
nt flag | 412 // flags are combined here. m_contentsLayer shouldn't receive the drawsConte
nt flag |
| 415 // so it is only given contentsVisible. | 413 // so it is only given contentsVisible. |
| 416 | 414 |
| 417 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); | 415 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); |
| 418 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) | 416 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) |
| 419 contentsLayer->setDrawsContent(m_contentsVisible); | 417 contentsLayer->setDrawsContent(m_contentsVisible); |
| 420 | 418 |
| 421 if (m_drawsContent) { | 419 if (m_drawsContent) { |
| 422 m_layer->layer()->invalidate(); | 420 m_layer->layer()->invalidate(); |
| 423 if (m_linkHighlight) | 421 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 424 m_linkHighlight->invalidate(); | 422 m_linkHighlights[i]->invalidate(); |
| 425 } | 423 } |
| 426 } | 424 } |
| 427 | 425 |
| 428 void GraphicsLayer::updateContentsRect() | 426 void GraphicsLayer::updateContentsRect() |
| 429 { | 427 { |
| 430 WebLayer* contentsLayer = contentsLayerIfRegistered(); | 428 WebLayer* contentsLayer = contentsLayerIfRegistered(); |
| 431 if (!contentsLayer) | 429 if (!contentsLayer) |
| 432 return; | 430 return; |
| 433 | 431 |
| 434 contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y()
)); | 432 contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y()
)); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 dumpLayer(ts, 0, flags); | 737 dumpLayer(ts, 0, flags); |
| 740 return ts.release(); | 738 return ts.release(); |
| 741 } | 739 } |
| 742 | 740 |
| 743 WebKit::WebString GraphicsLayer::debugName(WebKit::WebLayer* webLayer) | 741 WebKit::WebString GraphicsLayer::debugName(WebKit::WebLayer* webLayer) |
| 744 { | 742 { |
| 745 String name; | 743 String name; |
| 746 if (!m_client) | 744 if (!m_client) |
| 747 return name; | 745 return name; |
| 748 | 746 |
| 747 String highlightDebugName; |
| 748 for (size_t i = 0; i < m_linkHighlights.size(); ++i) { |
| 749 if (webLayer == m_linkHighlights[i]->layer()) { |
| 750 highlightDebugName = "LinkHighlight[" + String::number(i) + "] for "
+ m_client->debugName(this); |
| 751 break; |
| 752 } |
| 753 } |
| 754 |
| 749 if (webLayer == m_contentsLayer) { | 755 if (webLayer == m_contentsLayer) { |
| 750 name = "ContentsLayer for " + m_client->debugName(this); | 756 name = "ContentsLayer for " + m_client->debugName(this); |
| 751 } else if (m_linkHighlight && webLayer == m_linkHighlight->layer()) { | 757 } else if (!highlightDebugName.isEmpty()) { |
| 752 name = "LinkHighlight for " + m_client->debugName(this); | 758 name = highlightDebugName; |
| 753 } else if (webLayer == m_layer->layer()) { | 759 } else if (webLayer == m_layer->layer()) { |
| 754 name = m_client->debugName(this); | 760 name = m_client->debugName(this); |
| 755 } else { | 761 } else { |
| 756 ASSERT_NOT_REACHED(); | 762 ASSERT_NOT_REACHED(); |
| 757 } | 763 } |
| 758 return name; | 764 return name; |
| 759 } | 765 } |
| 760 | 766 |
| 761 void GraphicsLayer::setCompositingReasons(WebKit::WebCompositingReasons reasons) | 767 void GraphicsLayer::setCompositingReasons(WebKit::WebCompositingReasons reasons) |
| 762 { | 768 { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 contentsLayer->invalidate(); | 895 contentsLayer->invalidate(); |
| 890 addRepaintRect(contentsRect()); | 896 addRepaintRect(contentsRect()); |
| 891 } | 897 } |
| 892 } | 898 } |
| 893 | 899 |
| 894 void GraphicsLayer::setNeedsDisplay() | 900 void GraphicsLayer::setNeedsDisplay() |
| 895 { | 901 { |
| 896 if (drawsContent()) { | 902 if (drawsContent()) { |
| 897 m_layer->layer()->invalidate(); | 903 m_layer->layer()->invalidate(); |
| 898 addRepaintRect(FloatRect(FloatPoint(), m_size)); | 904 addRepaintRect(FloatRect(FloatPoint(), m_size)); |
| 899 if (m_linkHighlight) | 905 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 900 m_linkHighlight->invalidate(); | 906 m_linkHighlights[i]->invalidate(); |
| 901 } | 907 } |
| 902 } | 908 } |
| 903 | 909 |
| 904 void GraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect) | 910 void GraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect) |
| 905 { | 911 { |
| 906 if (drawsContent()) { | 912 if (drawsContent()) { |
| 907 m_layer->layer()->invalidateRect(rect); | 913 m_layer->layer()->invalidateRect(rect); |
| 908 addRepaintRect(rect); | 914 addRepaintRect(rect); |
| 909 if (m_linkHighlight) | 915 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 910 m_linkHighlight->invalidate(); | 916 m_linkHighlights[i]->invalidate(); |
| 911 } | 917 } |
| 912 } | 918 } |
| 913 | 919 |
| 914 void GraphicsLayer::setContentsRect(const IntRect& rect) | 920 void GraphicsLayer::setContentsRect(const IntRect& rect) |
| 915 { | 921 { |
| 916 if (rect == m_contentsRect) | 922 if (rect == m_contentsRect) |
| 917 return; | 923 return; |
| 918 | 924 |
| 919 m_contentsRect = rect; | 925 m_contentsRect = rect; |
| 920 updateContentsRect(); | 926 updateContentsRect(); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 } | 1147 } |
| 1142 | 1148 |
| 1143 void GraphicsLayer::setBackgroundFilters(const FilterOperations& filters) | 1149 void GraphicsLayer::setBackgroundFilters(const FilterOperations& filters) |
| 1144 { | 1150 { |
| 1145 OwnPtr<WebFilterOperations> webFilters = adoptPtr(Platform::current()->compo
sitorSupport()->createFilterOperations()); | 1151 OwnPtr<WebFilterOperations> webFilters = adoptPtr(Platform::current()->compo
sitorSupport()->createFilterOperations()); |
| 1146 if (!copyWebCoreFilterOperationsToWebFilterOperations(filters, *webFilters)) | 1152 if (!copyWebCoreFilterOperationsToWebFilterOperations(filters, *webFilters)) |
| 1147 return; | 1153 return; |
| 1148 m_layer->layer()->setBackgroundFilters(*webFilters); | 1154 m_layer->layer()->setBackgroundFilters(*webFilters); |
| 1149 } | 1155 } |
| 1150 | 1156 |
| 1151 void GraphicsLayer::setLinkHighlight(LinkHighlightClient* linkHighlight) | 1157 void GraphicsLayer::addLinkHighlight(LinkHighlightClient* linkHighlight) |
| 1152 { | 1158 { |
| 1153 m_linkHighlight = linkHighlight; | 1159 ASSERT(linkHighlight && !m_linkHighlights.contains(linkHighlight)); |
| 1154 if (m_linkHighlight) | 1160 m_linkHighlights.append(linkHighlight); |
| 1155 m_linkHighlight->layer()->setWebLayerClient(this); | 1161 linkHighlight->layer()->setWebLayerClient(this); |
| 1156 updateChildList(); | 1162 updateChildList(); |
| 1157 } | 1163 } |
| 1158 | 1164 |
| 1165 void GraphicsLayer::removeLinkHighlight(LinkHighlightClient* linkHighlight) |
| 1166 { |
| 1167 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight)); |
| 1168 updateChildList(); |
| 1169 } |
| 1170 |
| 1159 void GraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea, bool isMai
nFrame) | 1171 void GraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea, bool isMai
nFrame) |
| 1160 { | 1172 { |
| 1161 if (m_scrollableArea == scrollableArea) | 1173 if (m_scrollableArea == scrollableArea) |
| 1162 return; | 1174 return; |
| 1163 | 1175 |
| 1164 m_scrollableArea = scrollableArea; | 1176 m_scrollableArea = scrollableArea; |
| 1165 | 1177 |
| 1166 // Main frame scrolling may involve pinch zoom and gets routed through | 1178 // Main frame scrolling may involve pinch zoom and gets routed through |
| 1167 // WebViewImpl explicitly rather than via GraphicsLayer::didScroll. | 1179 // WebViewImpl explicitly rather than via GraphicsLayer::didScroll. |
| 1168 if (isMainFrame) | 1180 if (isMainFrame) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1199 #ifndef NDEBUG | 1211 #ifndef NDEBUG |
| 1200 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) | 1212 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) |
| 1201 { | 1213 { |
| 1202 if (!layer) | 1214 if (!layer) |
| 1203 return; | 1215 return; |
| 1204 | 1216 |
| 1205 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); | 1217 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); |
| 1206 fprintf(stderr, "%s\n", output.utf8().data()); | 1218 fprintf(stderr, "%s\n", output.utf8().data()); |
| 1207 } | 1219 } |
| 1208 #endif | 1220 #endif |
| OLD | NEW |