Chromium Code Reviews| 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 // Store the local bounds of the RenderLayer subtree before applying the offset. | 592 // Store the local bounds of the RenderLayer subtree before applying the offset. |
| 593 m_squashedLayers[i].compositedBounds = squashedBounds; | 593 m_squashedLayers[i].compositedBounds = squashedBounds; |
| 594 | 594 |
| 595 squashedBounds.move(m_squashedLayers[i].offsetFromSquashingCLM); | 595 squashedBounds.move(m_squashedLayers[i].offsetFromSquashingCLM); |
| 596 totalSquashBounds.unite(squashedBounds); | 596 totalSquashBounds.unite(squashedBounds); |
| 597 } | 597 } |
| 598 | 598 |
| 599 // The totalSquashBounds is positioned with respect to m_owningLayer of this CompositedLayerMapping. | 599 // The totalSquashBounds is positioned with respect to m_owningLayer of this CompositedLayerMapping. |
| 600 // But the squashingLayer needs to be positioned with respect to the ancesto r CompositedLayerMapping. | 600 // But the squashingLayer needs to be positioned with respect to the ancesto r CompositedLayerMapping. |
| 601 // The conversion between m_owningLayer and the ancestor CLM is already comp uted in the caller as |delta|. | 601 // The conversion between m_owningLayer and the ancestor CLM is already comp uted in the caller as |delta|. |
| 602 // FIXME: probably not the right place to round from LayoutPoint to IntPoint ? | 602 totalSquashBounds.move(m_subpixelAccumulation); |
|
chrishtr
2014/03/13 21:46:05
Why still use m_subpixelAccumulation at all? The a
ajuma
2014/03/13 21:55:48
The reason we use m_subpixelAccumulation here and
chrishtr
2014/03/17 20:20:33
Sure, but it looks like you are using that to set
| |
| 603 IntPoint squashLayerPosition = pixelSnappedIntRect(totalSquashBounds).locati on(); | 603 IntRect squashLayerBounds = enclosingIntRect(totalSquashBounds); |
| 604 squashLayerPosition.moveBy(delta); | 604 IntPoint squashLayerOrigin = squashLayerBounds.location(); |
| 605 squashLayerBounds.moveBy(delta); | |
| 605 | 606 |
| 606 m_squashingLayer->setPosition(squashLayerPosition); | 607 m_squashingLayer->setPosition(squashLayerBounds.location()); |
| 607 m_squashingLayer->setSize(totalSquashBounds.size()); | 608 m_squashingLayer->setSize(squashLayerBounds.size()); |
| 608 | 609 |
| 609 // Now that the squashing bounds are known, we can convert the RenderLayer p ainting offsets | 610 // Now that the squashing bounds are known, we can convert the RenderLayer p ainting offsets |
| 610 // from CLM owning layer space to the squashing layer space. | 611 // from CLM owning layer space to the squashing layer space. |
| 611 // | 612 // |
| 612 // The painting offset we want to compute for each squashed RenderLayer is e ssentially the position of | 613 // The painting offset we want to compute for each squashed RenderLayer is e ssentially the position of |
| 613 // the squashed RenderLayer described w.r.t. m_squashingLayer's origin. For this purpose we already cached | 614 // the squashed RenderLayer described w.r.t. m_squashingLayer's origin. For this purpose we already cached |
| 614 // offsetFromSquashingCLM before, which describes where the squashed RenderL ayer is located w.r.t. | 615 // offsetFromSquashingCLM before, which describes where the squashed RenderL ayer is located w.r.t. |
| 615 // m_owningLayer. So we just need to convert that point from m_owningLayer s pace to m_squashingLayer | 616 // m_owningLayer. So we just need to convert that point from m_owningLayer s pace to m_squashingLayer |
| 616 // space. This is simply done by subtracing totalSquashBounds... but then th e offset overall needs to be | 617 // space. This is simply done by subtracing squashLayerOrigin... but then th e offset overall needs to be |
| 617 // negated because that's the direction that the painting code expects the o ffset to be. | 618 // negated because that's the direction that the painting code expects the o ffset to be. |
| 618 for (size_t i = 0; i < m_squashedLayers.size(); ++i) { | 619 for (size_t i = 0; i < m_squashedLayers.size(); ++i) { |
| 619 m_squashedLayers[i].offsetFromRenderer = IntSize(-m_squashedLayers[i].of fsetFromSquashingCLM.width() + totalSquashBounds.x(), | 620 LayoutSize offsetFromSquashLayerOrigin = LayoutSize(m_squashedLayers[i]. offsetFromSquashingCLM.width() - squashLayerOrigin.x() + m_subpixelAccumulation. width(), |
|
chrishtr
2014/03/17 20:20:33
Isn't this wrong to use m_subpixelAccumulation? Ea
ajuma
2014/03/18 17:32:17
I've cleaned up the code (here and above) to make
| |
| 620 -m_squashedLayers[i].offsetFromSquashingCLM.height() + totalSquashBo unds.y()); | 621 m_squashedLayers[i].offsetFromSquashingCLM.height() - squashLayerOri gin.y() + m_subpixelAccumulation.height()); |
| 622 m_squashedLayers[i].offsetFromRenderer = -flooredIntSize(offsetFromSquas hLayerOrigin); | |
| 623 m_squashedLayers[i].subpixelAccumulation = offsetFromSquashLayerOrigin.f raction(); | |
| 621 | 624 |
| 622 // FIXME: find a better design to avoid this redundant value - most like ly it will make | 625 // FIXME: find a better design to avoid this redundant value - most like ly it will make |
| 623 // sense to move the paint task info into RenderLayer's m_compositingPro perties. | 626 // sense to move the paint task info into RenderLayer's m_compositingPro perties. |
| 624 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m_squ ashedLayers[i].offsetFromRenderer); | 627 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m_squ ashedLayers[i].offsetFromRenderer); |
| 625 } | 628 } |
| 626 } | 629 } |
| 627 | 630 |
| 628 GraphicsLayerUpdater::UpdateType CompositedLayerMapping::updateGraphicsLayerGeom etry(GraphicsLayerUpdater::UpdateType updateType) | 631 GraphicsLayerUpdater::UpdateType CompositedLayerMapping::updateGraphicsLayerGeom etry(GraphicsLayerUpdater::UpdateType updateType) |
| 629 { | 632 { |
| 630 // If we haven't built z-order lists yet, wait until later. | 633 // If we haven't built z-order lists yet, wait until later. |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1893 | 1896 |
| 1894 IntSize offset = paintInfo.offsetFromRenderer; | 1897 IntSize offset = paintInfo.offsetFromRenderer; |
| 1895 context->translate(-offset); | 1898 context->translate(-offset); |
| 1896 | 1899 |
| 1897 // The dirtyRect is in the coords of the painting root. | 1900 // The dirtyRect is in the coords of the painting root. |
| 1898 IntRect dirtyRect(clip); | 1901 IntRect dirtyRect(clip); |
| 1899 dirtyRect.move(offset); | 1902 dirtyRect.move(offset); |
| 1900 | 1903 |
| 1901 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) { | 1904 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) { |
| 1902 LayoutRect bounds = paintInfo.compositedBounds; | 1905 LayoutRect bounds = paintInfo.compositedBounds; |
| 1903 bounds.move(m_subpixelAccumulation); | 1906 bounds.move(paintInfo.subpixelAccumulation); |
| 1904 dirtyRect.intersect(pixelSnappedIntRect(bounds)); | 1907 dirtyRect.intersect(pixelSnappedIntRect(bounds)); |
| 1905 } else { | 1908 } else { |
| 1906 dirtyRect.move(roundedIntSize(m_subpixelAccumulation)); | 1909 dirtyRect.move(roundedIntSize(paintInfo.subpixelAccumulation)); |
| 1907 } | 1910 } |
| 1908 | 1911 |
| 1909 #ifndef NDEBUG | 1912 #ifndef NDEBUG |
| 1910 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut(); | 1913 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut(); |
| 1911 #endif | 1914 #endif |
| 1912 | 1915 |
| 1913 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) { | 1916 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) { |
| 1914 // FIXME: GraphicsLayers need a way to split for RenderRegions. | 1917 // FIXME: GraphicsLayers need a way to split for RenderRegions. |
| 1915 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, m_subpixelAccumulation); | 1918 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, paintInfo.subpixelAccumulation); |
| 1916 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags); | 1919 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags); |
| 1917 | 1920 |
| 1918 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo otBackgroundOnly); | 1921 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo otBackgroundOnly); |
| 1919 | 1922 |
| 1920 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) | 1923 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) |
| 1921 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai ntFlags | PaintLayerPaintingOverlayScrollbars); | 1924 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai ntFlags | PaintLayerPaintingOverlayScrollbars); |
| 1922 } else { | 1925 } else { |
| 1923 ASSERT(compositor()->layerSquashingEnabled()); | 1926 ASSERT(compositor()->layerSquashingEnabled()); |
| 1924 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize()); | 1927 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, paintInfo.subpixelAccumulation); |
| 1925 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags); | 1928 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags); |
| 1926 } | 1929 } |
| 1927 | 1930 |
| 1928 ASSERT(!paintInfo.renderLayer->m_usedTransparency); | 1931 ASSERT(!paintInfo.renderLayer->m_usedTransparency); |
| 1929 | 1932 |
| 1930 // Manually restore the context to its original state by applying the opposi te translation. | 1933 // Manually restore the context to its original state by applying the opposi te translation. |
| 1931 context->translate(offset); | 1934 context->translate(offset); |
| 1932 } | 1935 } |
| 1933 | 1936 |
| 1934 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) | 1937 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1963 || graphicsLayer == m_maskLayer.get() | 1966 || graphicsLayer == m_maskLayer.get() |
| 1964 || graphicsLayer == m_childClippingMaskLayer.get() | 1967 || graphicsLayer == m_childClippingMaskLayer.get() |
| 1965 || graphicsLayer == m_scrollingContentsLayer.get()) { | 1968 || graphicsLayer == m_scrollingContentsLayer.get()) { |
| 1966 | 1969 |
| 1967 GraphicsLayerPaintInfo paintInfo; | 1970 GraphicsLayerPaintInfo paintInfo; |
| 1968 paintInfo.renderLayer = &m_owningLayer; | 1971 paintInfo.renderLayer = &m_owningLayer; |
| 1969 paintInfo.compositedBounds = compositedBounds(); | 1972 paintInfo.compositedBounds = compositedBounds(); |
| 1970 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); | 1973 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); |
| 1971 paintInfo.paintingPhase = paintingPhase; | 1974 paintInfo.paintingPhase = paintingPhase; |
| 1972 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); | 1975 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); |
| 1976 paintInfo.subpixelAccumulation = m_subpixelAccumulation; | |
| 1973 | 1977 |
| 1974 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. | 1978 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. |
| 1975 doPaintTask(paintInfo, &context, clip); | 1979 doPaintTask(paintInfo, &context, clip); |
| 1976 } else if (graphicsLayer == m_squashingLayer.get()) { | 1980 } else if (graphicsLayer == m_squashingLayer.get()) { |
| 1977 ASSERT(compositor()->layerSquashingEnabled()); | 1981 ASSERT(compositor()->layerSquashingEnabled()); |
| 1978 for (size_t i = 0; i < m_squashedLayers.size(); ++i) | 1982 for (size_t i = 0; i < m_squashedLayers.size(); ++i) |
| 1979 doPaintTask(m_squashedLayers[i], &context, clip); | 1983 doPaintTask(m_squashedLayers[i], &context, clip); |
| 1980 } else if (graphicsLayer == layerForHorizontalScrollbar()) { | 1984 } else if (graphicsLayer == layerForHorizontalScrollbar()) { |
| 1981 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co ntext, clip); | 1985 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co ntext, clip); |
| 1982 } else if (graphicsLayer == layerForVerticalScrollbar()) { | 1986 } else if (graphicsLayer == layerForVerticalScrollbar()) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2032 LayoutRect CompositedLayerMapping::compositedBounds() const | 2036 LayoutRect CompositedLayerMapping::compositedBounds() const |
| 2033 { | 2037 { |
| 2034 return m_compositedBounds; | 2038 return m_compositedBounds; |
| 2035 } | 2039 } |
| 2036 | 2040 |
| 2037 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) | 2041 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) |
| 2038 { | 2042 { |
| 2039 m_compositedBounds = bounds; | 2043 m_compositedBounds = bounds; |
| 2040 } | 2044 } |
| 2041 | 2045 |
| 2042 bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* layer, IntSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex) | 2046 bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* layer, LayoutSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex) |
| 2043 { | 2047 { |
| 2044 ASSERT(compositor()->layerSquashingEnabled()); | 2048 ASSERT(compositor()->layerSquashingEnabled()); |
| 2045 | 2049 |
| 2046 GraphicsLayerPaintInfo paintInfo; | 2050 GraphicsLayerPaintInfo paintInfo; |
| 2047 paintInfo.renderLayer = layer; | 2051 paintInfo.renderLayer = layer; |
| 2048 // NOTE: composited bounds are updated elsewhere | 2052 // NOTE: composited bounds are updated elsewhere |
| 2049 // NOTE: offsetFromRenderer is updated elsewhere | 2053 // NOTE: offsetFromRenderer is updated elsewhere |
| 2050 paintInfo.offsetFromSquashingCLM = offsetFromSquashingCLM; | 2054 paintInfo.offsetFromSquashingCLM = offsetFromSquashingCLM; |
| 2051 paintInfo.paintingPhase = GraphicsLayerPaintAllWithOverflowClip; | 2055 paintInfo.paintingPhase = GraphicsLayerPaintAllWithOverflowClip; |
| 2052 paintInfo.isBackgroundLayer = false; | 2056 paintInfo.isBackgroundLayer = false; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2127 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2131 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2128 name = "Scrolling Contents Layer"; | 2132 name = "Scrolling Contents Layer"; |
| 2129 } else { | 2133 } else { |
| 2130 ASSERT_NOT_REACHED(); | 2134 ASSERT_NOT_REACHED(); |
| 2131 } | 2135 } |
| 2132 | 2136 |
| 2133 return name; | 2137 return name; |
| 2134 } | 2138 } |
| 2135 | 2139 |
| 2136 } // namespace WebCore | 2140 } // namespace WebCore |
| OLD | NEW |