OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 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 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 return; | 1127 return; |
1128 | 1128 |
1129 if (!m_scrollingContentsAreEmpty) { | 1129 if (!m_scrollingContentsAreEmpty) { |
1130 // In this case, the selection will be painted directly into m_scrolling
ContentsLayer. | 1130 // In this case, the selection will be painted directly into m_scrolling
ContentsLayer. |
1131 m_scrollingBlockSelectionLayer->setDrawsContent(false); | 1131 m_scrollingBlockSelectionLayer->setDrawsContent(false); |
1132 return; | 1132 return; |
1133 } | 1133 } |
1134 | 1134 |
1135 const IntRect blockSelectionGapsBounds = m_owningLayer.blockSelectionGapsBou
nds(); | 1135 const IntRect blockSelectionGapsBounds = m_owningLayer.blockSelectionGapsBou
nds(); |
1136 const bool shouldDrawContent = !blockSelectionGapsBounds.isEmpty(); | 1136 const bool shouldDrawContent = !blockSelectionGapsBounds.isEmpty(); |
1137 m_scrollingBlockSelectionLayer->setDrawsContent(shouldDrawContent); | 1137 m_scrollingBlockSelectionLayer->setDrawsContent(!paintsIntoCompositedAncesto
r() && shouldDrawContent); |
1138 if (!shouldDrawContent) | 1138 if (!shouldDrawContent) |
1139 return; | 1139 return; |
1140 | 1140 |
1141 const IntPoint position = blockSelectionGapsBounds.location() + m_owningLaye
r.scrollableArea()->adjustedScrollOffset(); | 1141 const IntPoint position = blockSelectionGapsBounds.location() + m_owningLaye
r.scrollableArea()->adjustedScrollOffset(); |
1142 if (m_scrollingBlockSelectionLayer->size() == blockSelectionGapsBounds.size(
) && m_scrollingBlockSelectionLayer->position() == position) | 1142 if (m_scrollingBlockSelectionLayer->size() == blockSelectionGapsBounds.size(
) && m_scrollingBlockSelectionLayer->position() == position) |
1143 return; | 1143 return; |
1144 | 1144 |
1145 m_scrollingBlockSelectionLayer->setPosition(position); | 1145 m_scrollingBlockSelectionLayer->setPosition(position); |
1146 m_scrollingBlockSelectionLayer->setSize(blockSelectionGapsBounds.size()); | 1146 m_scrollingBlockSelectionLayer->setSize(blockSelectionGapsBounds.size()); |
1147 m_scrollingBlockSelectionLayer->setOffsetFromRenderer(toIntSize(blockSelecti
onGapsBounds.location()), GraphicsLayer::SetNeedsDisplay); | 1147 m_scrollingBlockSelectionLayer->setOffsetFromRenderer(toIntSize(blockSelecti
onGapsBounds.location()), GraphicsLayer::SetNeedsDisplay); |
1148 } | 1148 } |
1149 | 1149 |
1150 void CompositedLayerMapping::updateDrawsContent() | 1150 void CompositedLayerMapping::updateDrawsContent() |
1151 { | 1151 { |
1152 bool hasPaintedContent = containsPaintedContent(); | 1152 bool hasPaintedContent = containsPaintedContent(); |
1153 m_graphicsLayer->setDrawsContent(hasPaintedContent); | 1153 m_graphicsLayer->setDrawsContent(hasPaintedContent); |
1154 | 1154 |
1155 if (m_scrollingLayer) { | 1155 if (m_scrollingLayer) { |
1156 // m_scrollingLayer never has backing store. | 1156 // m_scrollingLayer never has backing store. |
1157 // m_scrollingContentsLayer only needs backing store if the scrolled con
tents need to paint. | 1157 // m_scrollingContentsLayer only needs backing store if the scrolled con
tents need to paint. |
1158 m_scrollingContentsAreEmpty = !m_owningLayer.hasVisibleContent() || !(re
nderer()->hasBackground() || paintsChildren()); | 1158 m_scrollingContentsAreEmpty = !m_owningLayer.hasVisibleContent() || !(re
nderer()->hasBackground() || paintsChildren()); |
1159 m_scrollingContentsLayer->setDrawsContent(!m_scrollingContentsAreEmpty); | 1159 m_scrollingContentsLayer->setDrawsContent(!paintsIntoCompositedAncestor(
) && !m_scrollingContentsAreEmpty); |
1160 updateScrollingBlockSelection(); | 1160 updateScrollingBlockSelection(); |
1161 } | 1161 } |
1162 | 1162 |
1163 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { | 1163 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { |
1164 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node()
)->renderingContext(); | 1164 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node()
)->renderingContext(); |
1165 // Content layer may be null if context is lost. | 1165 // Content layer may be null if context is lost. |
1166 if (WebLayer* contentLayer = context->platformLayer()) { | 1166 if (WebLayer* contentLayer = context->platformLayer()) { |
1167 Color bgColor(Color::transparent); | 1167 Color bgColor(Color::transparent); |
1168 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { | 1168 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { |
1169 bgColor = rendererBackgroundColor(); | 1169 bgColor = rendererBackgroundColor(); |
1170 hasPaintedContent = false; | 1170 hasPaintedContent = false; |
1171 } | 1171 } |
1172 contentLayer->setBackgroundColor(bgColor.rgb()); | 1172 contentLayer->setBackgroundColor(bgColor.rgb()); |
1173 } | 1173 } |
1174 } | 1174 } |
1175 | 1175 |
1176 // FIXME: we could refine this to only allocate backings for one of these la
yers if possible. | 1176 // FIXME: we could refine this to only allocate backings for one of these la
yers if possible. |
1177 if (m_foregroundLayer) | 1177 if (m_foregroundLayer) |
1178 m_foregroundLayer->setDrawsContent(hasPaintedContent); | 1178 m_foregroundLayer->setDrawsContent(hasPaintedContent); |
1179 | 1179 |
1180 if (m_backgroundLayer) | 1180 if (m_backgroundLayer) |
1181 m_backgroundLayer->setDrawsContent(hasPaintedContent); | 1181 m_backgroundLayer->setDrawsContent(hasPaintedContent); |
| 1182 |
| 1183 if (m_maskLayer) |
| 1184 m_maskLayer->setDrawsContent(!paintsIntoCompositedAncestor()); |
| 1185 |
| 1186 if (m_childClippingMaskLayer) |
| 1187 m_childClippingMaskLayer->setDrawsContent(!paintsIntoCompositedAncestor(
)); |
1182 } | 1188 } |
1183 | 1189 |
1184 void CompositedLayerMapping::updateChildrenTransform() | 1190 void CompositedLayerMapping::updateChildrenTransform() |
1185 { | 1191 { |
1186 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) { | 1192 if (GraphicsLayer* childTransformLayer = layerForChildrenTransform()) { |
1187 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); | 1193 childTransformLayer->setTransform(owningLayer().perspectiveTransform()); |
1188 childTransformLayer->setTransformOrigin(FloatPoint3D(childTransformLayer
->size().width() * 0.5f, childTransformLayer->size().height() * 0.5f, 0.f)); | 1194 childTransformLayer->setTransformOrigin(FloatPoint3D(childTransformLayer
->size().width() * 0.5f, childTransformLayer->size().height() * 0.5f, 0.f)); |
1189 } | 1195 } |
1190 | 1196 |
1191 updateShouldFlattenTransform(); | 1197 updateShouldFlattenTransform(); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 } | 1454 } |
1449 } | 1455 } |
1450 } | 1456 } |
1451 | 1457 |
1452 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer) | 1458 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer) |
1453 { | 1459 { |
1454 bool layerChanged = false; | 1460 bool layerChanged = false; |
1455 if (needsForegroundLayer) { | 1461 if (needsForegroundLayer) { |
1456 if (!m_foregroundLayer) { | 1462 if (!m_foregroundLayer) { |
1457 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor
eground); | 1463 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor
eground); |
1458 m_foregroundLayer->setDrawsContent(true); | |
1459 m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); | 1464 m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); |
1460 layerChanged = true; | 1465 layerChanged = true; |
1461 } | 1466 } |
1462 } else if (m_foregroundLayer) { | 1467 } else if (m_foregroundLayer) { |
1463 m_foregroundLayer->removeFromParent(); | 1468 m_foregroundLayer->removeFromParent(); |
1464 m_foregroundLayer = nullptr; | 1469 m_foregroundLayer = nullptr; |
1465 layerChanged = true; | 1470 layerChanged = true; |
1466 } | 1471 } |
1467 | 1472 |
1468 return layerChanged; | 1473 return layerChanged; |
1469 } | 1474 } |
1470 | 1475 |
1471 bool CompositedLayerMapping::updateBackgroundLayer(bool needsBackgroundLayer) | 1476 bool CompositedLayerMapping::updateBackgroundLayer(bool needsBackgroundLayer) |
1472 { | 1477 { |
1473 bool layerChanged = false; | 1478 bool layerChanged = false; |
1474 if (needsBackgroundLayer) { | 1479 if (needsBackgroundLayer) { |
1475 if (!m_backgroundLayer) { | 1480 if (!m_backgroundLayer) { |
1476 m_backgroundLayer = createGraphicsLayer(CompositingReasonLayerForBac
kground); | 1481 m_backgroundLayer = createGraphicsLayer(CompositingReasonLayerForBac
kground); |
1477 m_backgroundLayer->setDrawsContent(true); | |
1478 m_backgroundLayer->setTransformOrigin(FloatPoint3D()); | 1482 m_backgroundLayer->setTransformOrigin(FloatPoint3D()); |
1479 m_backgroundLayer->setPaintingPhase(GraphicsLayerPaintBackground); | 1483 m_backgroundLayer->setPaintingPhase(GraphicsLayerPaintBackground); |
1480 #if !OS(ANDROID) | 1484 #if !OS(ANDROID) |
1481 m_backgroundLayer->contentLayer()->setDrawCheckerboardForMissingTile
s(true); | 1485 m_backgroundLayer->contentLayer()->setDrawCheckerboardForMissingTile
s(true); |
1482 m_graphicsLayer->contentLayer()->setDrawCheckerboardForMissingTiles(
false); | 1486 m_graphicsLayer->contentLayer()->setDrawCheckerboardForMissingTiles(
false); |
1483 #endif | 1487 #endif |
1484 layerChanged = true; | 1488 layerChanged = true; |
1485 } | 1489 } |
1486 } else { | 1490 } else { |
1487 if (m_backgroundLayer) { | 1491 if (m_backgroundLayer) { |
(...skipping 11 matching lines...) Expand all Loading... |
1499 | 1503 |
1500 return layerChanged; | 1504 return layerChanged; |
1501 } | 1505 } |
1502 | 1506 |
1503 bool CompositedLayerMapping::updateMaskLayer(bool needsMaskLayer) | 1507 bool CompositedLayerMapping::updateMaskLayer(bool needsMaskLayer) |
1504 { | 1508 { |
1505 bool layerChanged = false; | 1509 bool layerChanged = false; |
1506 if (needsMaskLayer) { | 1510 if (needsMaskLayer) { |
1507 if (!m_maskLayer) { | 1511 if (!m_maskLayer) { |
1508 m_maskLayer = createGraphicsLayer(CompositingReasonLayerForMask); | 1512 m_maskLayer = createGraphicsLayer(CompositingReasonLayerForMask); |
1509 m_maskLayer->setDrawsContent(true); | |
1510 m_maskLayer->setPaintingPhase(GraphicsLayerPaintMask); | 1513 m_maskLayer->setPaintingPhase(GraphicsLayerPaintMask); |
1511 layerChanged = true; | 1514 layerChanged = true; |
1512 } | 1515 } |
1513 } else if (m_maskLayer) { | 1516 } else if (m_maskLayer) { |
1514 m_maskLayer = nullptr; | 1517 m_maskLayer = nullptr; |
1515 layerChanged = true; | 1518 layerChanged = true; |
1516 } | 1519 } |
1517 | 1520 |
1518 return layerChanged; | 1521 return layerChanged; |
1519 } | 1522 } |
1520 | 1523 |
1521 bool CompositedLayerMapping::updateClippingMaskLayers(bool needsChildClippingMas
kLayer) | 1524 bool CompositedLayerMapping::updateClippingMaskLayers(bool needsChildClippingMas
kLayer) |
1522 { | 1525 { |
1523 bool layerChanged = false; | 1526 bool layerChanged = false; |
1524 if (needsChildClippingMaskLayer) { | 1527 if (needsChildClippingMaskLayer) { |
1525 if (!m_childClippingMaskLayer) { | 1528 if (!m_childClippingMaskLayer) { |
1526 m_childClippingMaskLayer = createGraphicsLayer(CompositingReasonLaye
rForClippingMask); | 1529 m_childClippingMaskLayer = createGraphicsLayer(CompositingReasonLaye
rForClippingMask); |
1527 m_childClippingMaskLayer->setDrawsContent(true); | |
1528 m_childClippingMaskLayer->setPaintingPhase(GraphicsLayerPaintChildCl
ippingMask); | 1530 m_childClippingMaskLayer->setPaintingPhase(GraphicsLayerPaintChildCl
ippingMask); |
1529 layerChanged = true; | 1531 layerChanged = true; |
1530 } | 1532 } |
1531 } else if (m_childClippingMaskLayer) { | 1533 } else if (m_childClippingMaskLayer) { |
1532 m_childClippingMaskLayer = nullptr; | 1534 m_childClippingMaskLayer = nullptr; |
1533 layerChanged = true; | 1535 layerChanged = true; |
1534 } | 1536 } |
1535 return layerChanged; | 1537 return layerChanged; |
1536 } | 1538 } |
1537 | 1539 |
1538 bool CompositedLayerMapping::updateScrollingLayers(bool needsScrollingLayers) | 1540 bool CompositedLayerMapping::updateScrollingLayers(bool needsScrollingLayers) |
1539 { | 1541 { |
1540 ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m
_owningLayer); | 1542 ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m
_owningLayer); |
1541 | 1543 |
1542 bool layerChanged = false; | 1544 bool layerChanged = false; |
1543 if (needsScrollingLayers) { | 1545 if (needsScrollingLayers) { |
1544 if (!m_scrollingLayer) { | 1546 if (!m_scrollingLayer) { |
1545 // Outer layer which corresponds with the scroll view. | 1547 // Outer layer which corresponds with the scroll view. |
1546 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro
llingContainer); | 1548 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro
llingContainer); |
1547 m_scrollingLayer->setDrawsContent(false); | 1549 m_scrollingLayer->setDrawsContent(false); |
1548 m_scrollingLayer->setMasksToBounds(true); | 1550 m_scrollingLayer->setMasksToBounds(true); |
1549 | 1551 |
1550 // Inner layer which renders the content that scrolls. | 1552 // Inner layer which renders the content that scrolls. |
1551 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye
rForScrollingContents); | 1553 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye
rForScrollingContents); |
1552 m_scrollingContentsLayer->setDrawsContent(true); | |
1553 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); | 1554 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); |
1554 | 1555 |
1555 m_scrollingBlockSelectionLayer = createGraphicsLayer(CompositingReas
onLayerForScrollingBlockSelection); | 1556 m_scrollingBlockSelectionLayer = createGraphicsLayer(CompositingReas
onLayerForScrollingBlockSelection); |
1556 m_scrollingBlockSelectionLayer->setDrawsContent(true); | 1557 m_scrollingBlockSelectionLayer->setDrawsContent(true); |
1557 m_scrollingContentsLayer->addChild(m_scrollingBlockSelectionLayer.ge
t()); | 1558 m_scrollingContentsLayer->addChild(m_scrollingBlockSelectionLayer.ge
t()); |
1558 | 1559 |
1559 layerChanged = true; | 1560 layerChanged = true; |
1560 if (scrollingCoordinator) | 1561 if (scrollingCoordinator) |
1561 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin
gLayer.scrollableArea()); | 1562 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin
gLayer.scrollableArea()); |
1562 } | 1563 } |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2350 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2351 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2351 name = "Scrolling Block Selection Layer"; | 2352 name = "Scrolling Block Selection Layer"; |
2352 } else { | 2353 } else { |
2353 ASSERT_NOT_REACHED(); | 2354 ASSERT_NOT_REACHED(); |
2354 } | 2355 } |
2355 | 2356 |
2356 return name; | 2357 return name; |
2357 } | 2358 } |
2358 | 2359 |
2359 } // namespace blink | 2360 } // namespace blink |
OLD | NEW |