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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 result.intersect(renderer->clipRect(LayoutPoint())); | 559 result.intersect(renderer->clipRect(LayoutPoint())); |
560 | 560 |
561 return pixelSnappedIntRect(result); | 561 return pixelSnappedIntRect(result); |
562 } | 562 } |
563 | 563 |
564 void CompositedLayerMapping::adjustBoundsForSubPixelAccumulation(const RenderLay
er* compositedAncestor, IntRect& localBounds, IntRect& relativeBounds, IntPoint&
delta) | 564 void CompositedLayerMapping::adjustBoundsForSubPixelAccumulation(const RenderLay
er* compositedAncestor, IntRect& localBounds, IntRect& relativeBounds, IntPoint&
delta) |
565 { | 565 { |
566 LayoutRect localRawCompositingBounds = compositedBounds(); | 566 LayoutRect localRawCompositingBounds = compositedBounds(); |
567 LayoutPoint rawDelta; | 567 LayoutPoint rawDelta; |
568 m_owningLayer.convertToLayerCoords(compositedAncestor, rawDelta); | 568 m_owningLayer.convertToLayerCoords(compositedAncestor, rawDelta); |
| 569 if (compositedAncestor) |
| 570 rawDelta.move(compositedAncestor->compositedLayerMapping()->subpixelAccu
mulation()); |
569 delta = flooredIntPoint(rawDelta); | 571 delta = flooredIntPoint(rawDelta); |
570 m_subpixelAccumulation = toLayoutSize(rawDelta).fraction(); | 572 m_subpixelAccumulation = toLayoutSize(rawDelta).fraction(); |
571 RELEASE_ASSERT(m_subpixelAccumulation.width() < 1 && m_subpixelAccumulation.
height() < 1); | 573 RELEASE_ASSERT(m_subpixelAccumulation.width() < 1 && m_subpixelAccumulation.
height() < 1); |
572 | 574 |
573 // Move the bounds by the subpixel accumulation so that it pixel-snaps relat
ive to absolute pixels instead of local coordinates. | 575 // Move the bounds by the subpixel accumulation so that it pixel-snaps relat
ive to absolute pixels instead of local coordinates. |
574 localRawCompositingBounds.move(m_subpixelAccumulation); | 576 localRawCompositingBounds.move(m_subpixelAccumulation); |
575 localBounds = pixelSnappedIntRect(localRawCompositingBounds); | 577 localBounds = pixelSnappedIntRect(localRawCompositingBounds); |
576 | 578 |
577 relativeBounds = localBounds; | 579 relativeBounds = localBounds; |
578 relativeBounds.moveBy(delta); | 580 relativeBounds.moveBy(delta); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 | 663 |
662 RenderStyle* style = renderer()->style(); | 664 RenderStyle* style = renderer()->style(); |
663 m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == Backfa
ceVisibilityVisible); | 665 m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == Backfa
ceVisibilityVisible); |
664 | 666 |
665 RenderLayer* compAncestor = m_owningLayer.ancestorCompositingLayer(); | 667 RenderLayer* compAncestor = m_owningLayer.ancestorCompositingLayer(); |
666 | 668 |
667 // We compute everything relative to the enclosing compositing layer. | 669 // We compute everything relative to the enclosing compositing layer. |
668 IntRect ancestorCompositingBounds; | 670 IntRect ancestorCompositingBounds; |
669 if (compAncestor) { | 671 if (compAncestor) { |
670 ASSERT(compAncestor->hasCompositedLayerMapping()); | 672 ASSERT(compAncestor->hasCompositedLayerMapping()); |
671 ancestorCompositingBounds = pixelSnappedIntRect(compAncestor->composited
LayerMapping()->compositedBounds()); | 673 ancestorCompositingBounds = compAncestor->compositedLayerMapping()->pixe
lSnappedCompositedBounds(); |
672 } | 674 } |
673 | 675 |
674 IntRect localCompositingBounds; | 676 IntRect localCompositingBounds; |
675 IntRect relativeCompositingBounds; | 677 IntRect relativeCompositingBounds; |
676 IntPoint delta; | 678 IntPoint delta; |
677 adjustBoundsForSubPixelAccumulation(compAncestor, localCompositingBounds, re
lativeCompositingBounds, delta); | 679 adjustBoundsForSubPixelAccumulation(compAncestor, localCompositingBounds, re
lativeCompositingBounds, delta); |
678 | 680 |
679 IntPoint graphicsLayerParentLocation; | 681 IntPoint graphicsLayerParentLocation; |
680 if (compAncestor && compAncestor->compositedLayerMapping()->hasClippingLayer
()) { | 682 if (compAncestor && compAncestor->compositedLayerMapping()->hasClippingLayer
()) { |
681 // If the compositing ancestor has a layer to clip children, we parent i
n that, and therefore | 683 // If the compositing ancestor has a layer to clip children, we parent i
n that, and therefore |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 if (m_maskLayer) { | 739 if (m_maskLayer) { |
738 if (m_maskLayer->size() != m_graphicsLayer->size()) { | 740 if (m_maskLayer->size() != m_graphicsLayer->size()) { |
739 m_maskLayer->setSize(m_graphicsLayer->size()); | 741 m_maskLayer->setSize(m_graphicsLayer->size()); |
740 m_maskLayer->setNeedsDisplay(); | 742 m_maskLayer->setNeedsDisplay(); |
741 } | 743 } |
742 m_maskLayer->setPosition(FloatPoint()); | 744 m_maskLayer->setPosition(FloatPoint()); |
743 m_maskLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRenderer()
); | 745 m_maskLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRenderer()
); |
744 } | 746 } |
745 | 747 |
746 if (m_owningLayer.hasTransform()) { | 748 if (m_owningLayer.hasTransform()) { |
747 const IntRect borderBox = toRenderBox(renderer())->pixelSnappedBorderBox
Rect(); | 749 const LayoutRect borderBox = toRenderBox(renderer())->borderBoxRect(); |
748 | 750 |
749 // Get layout bounds in the coords of compAncestor to match relativeComp
ositingBounds. | 751 // Get layout bounds in the coords of compAncestor to match relativeComp
ositingBounds. |
750 IntRect layerBounds(delta + roundedIntSize(m_subpixelAccumulation), bord
erBox.size()); | 752 IntRect layerBounds = pixelSnappedIntRect(toLayoutPoint(m_subpixelAccumu
lation), borderBox.size()); |
| 753 layerBounds.moveBy(delta); |
751 | 754 |
752 // Update properties that depend on layer dimensions | 755 // Update properties that depend on layer dimensions |
753 FloatPoint3D transformOrigin = computeTransformOrigin(borderBox); | 756 FloatPoint3D transformOrigin = computeTransformOrigin(IntRect(IntPoint()
, layerBounds.size())); |
754 // Compute the anchor point, which is in the center of the renderer box
unless transform-origin is set. | 757 // Compute the anchor point, which is in the center of the renderer box
unless transform-origin is set. |
755 FloatPoint3D anchor( | 758 FloatPoint3D anchor( |
756 relativeCompositingBounds.width() ? (layerBounds.x() - relativeCompo
sitingBounds.x() + transformOrigin.x()) / relativeCompositingBounds.width() : 0
.5f, | 759 relativeCompositingBounds.width() ? (layerBounds.x() - relativeCompo
sitingBounds.x() + transformOrigin.x()) / relativeCompositingBounds.width() : 0
.5f, |
757 relativeCompositingBounds.height() ? (layerBounds.y() - relativeComp
ositingBounds.y() + transformOrigin.y()) / relativeCompositingBounds.height() :
0.5f, | 760 relativeCompositingBounds.height() ? (layerBounds.y() - relativeComp
ositingBounds.y() + transformOrigin.y()) / relativeCompositingBounds.height() :
0.5f, |
758 transformOrigin.z()); | 761 transformOrigin.z()); |
759 m_graphicsLayer->setAnchorPoint(anchor); | 762 m_graphicsLayer->setAnchorPoint(anchor); |
760 } else { | 763 } else { |
761 m_graphicsLayer->setAnchorPoint(FloatPoint3D(0.5f, 0.5f, 0)); | 764 m_graphicsLayer->setAnchorPoint(FloatPoint3D(0.5f, 0.5f, 0)); |
762 } | 765 } |
763 | 766 |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 { | 2025 { |
2023 ASSERT(!renderer()->frame()->page() || !renderer()->frame()->page()->isPaint
ing()); | 2026 ASSERT(!renderer()->frame()->page() || !renderer()->frame()->page()->isPaint
ing()); |
2024 } | 2027 } |
2025 #endif | 2028 #endif |
2026 | 2029 |
2027 void CompositedLayerMapping::notifyAnimationStarted(const GraphicsLayer*, double
monotonicTime) | 2030 void CompositedLayerMapping::notifyAnimationStarted(const GraphicsLayer*, double
monotonicTime) |
2028 { | 2031 { |
2029 renderer()->node()->document().cssPendingAnimations().notifyCompositorAnimat
ionStarted(monotonicTime); | 2032 renderer()->node()->document().cssPendingAnimations().notifyCompositorAnimat
ionStarted(monotonicTime); |
2030 } | 2033 } |
2031 | 2034 |
2032 LayoutRect CompositedLayerMapping::compositedBounds() const | 2035 IntRect CompositedLayerMapping::pixelSnappedCompositedBounds() const |
2033 { | 2036 { |
2034 return m_compositedBounds; | 2037 LayoutRect bounds = m_compositedBounds; |
| 2038 bounds.move(m_subpixelAccumulation); |
| 2039 return pixelSnappedIntRect(bounds); |
2035 } | 2040 } |
2036 | 2041 |
2037 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) | 2042 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) |
2038 { | 2043 { |
2039 m_compositedBounds = bounds; | 2044 m_compositedBounds = bounds; |
2040 } | 2045 } |
2041 | 2046 |
2042 bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* layer,
IntSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex) | 2047 bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* layer,
IntSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex) |
2043 { | 2048 { |
2044 ASSERT(compositor()->layerSquashingEnabled()); | 2049 ASSERT(compositor()->layerSquashingEnabled()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2127 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2132 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2128 name = "Scrolling Contents Layer"; | 2133 name = "Scrolling Contents Layer"; |
2129 } else { | 2134 } else { |
2130 ASSERT_NOT_REACHED(); | 2135 ASSERT_NOT_REACHED(); |
2131 } | 2136 } |
2132 | 2137 |
2133 return name; | 2138 return name; |
2134 } | 2139 } |
2135 | 2140 |
2136 } // namespace WebCore | 2141 } // namespace WebCore |
OLD | NEW |