Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Side by Side Diff: Source/core/rendering/compositing/CompositedLayerMapping.cpp

Issue 143283011: Make squashing work with subpixel layout (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make space conversions more explicit Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 591
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
602 // FIXME: probably not the right place to round from LayoutPoint to IntPoint ? 602 // |delta| + |m_subpixelAccumulation|.
603 IntPoint squashLayerPosition = pixelSnappedIntRect(totalSquashBounds).locati on(); 603 LayoutPoint rawDelta = delta + m_subpixelAccumulation;
604 squashLayerPosition.moveBy(delta); 604 totalSquashBounds.moveBy(rawDelta);
605 IntRect squashLayerBounds = enclosingIntRect(totalSquashBounds);
606 IntPoint squashLayerOrigin = squashLayerBounds.location();
607 LayoutPoint squashLayerOriginInOwningLayerSpace = LayoutPoint(squashLayerOri gin - rawDelta);
605 608
606 m_squashingLayer->setPosition(squashLayerPosition); 609 m_squashingLayer->setPosition(squashLayerBounds.location());
607 m_squashingLayer->setSize(totalSquashBounds.size()); 610 m_squashingLayer->setSize(squashLayerBounds.size());
608 611
609 // Now that the squashing bounds are known, we can convert the RenderLayer p ainting offsets 612 // 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. 613 // from CLM owning layer space to the squashing layer space.
611 // 614 //
612 // The painting offset we want to compute for each squashed RenderLayer is e ssentially the position of 615 // 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 616 // 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. 617 // 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 618 // 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 619 // space. This is simply done by subtracing squashLayerOriginInOwningLayerSp ace, but then the offset
617 // negated because that's the direction that the painting code expects the o ffset to be. 620 // overall needs to be negated because that's the direction that the paintin g code expects the
621 // offset to be.
618 for (size_t i = 0; i < m_squashedLayers.size(); ++i) { 622 for (size_t i = 0; i < m_squashedLayers.size(); ++i) {
619 m_squashedLayers[i].offsetFromRenderer = IntSize(-m_squashedLayers[i].of fsetFromSquashingCLM.width() + totalSquashBounds.x(), 623 LayoutSize offsetFromSquashLayerOrigin = LayoutPoint(m_squashedLayers[i] .offsetFromSquashingCLM) - squashLayerOriginInOwningLayerSpace;
620 -m_squashedLayers[i].offsetFromSquashingCLM.height() + totalSquashBo unds.y()); 624 m_squashedLayers[i].offsetFromRenderer = -flooredIntSize(offsetFromSquas hLayerOrigin);
625 m_squashedLayers[i].subpixelAccumulation = offsetFromSquashLayerOrigin.f raction();
621 626
622 // FIXME: find a better design to avoid this redundant value - most like ly it will make 627 // 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. 628 // sense to move the paint task info into RenderLayer's m_compositingPro perties.
624 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m_squ ashedLayers[i].offsetFromRenderer); 629 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m_squ ashedLayers[i].offsetFromRenderer);
625 } 630 }
626 } 631 }
627 632
628 GraphicsLayerUpdater::UpdateType CompositedLayerMapping::updateGraphicsLayerGeom etry(GraphicsLayerUpdater::UpdateType updateType) 633 GraphicsLayerUpdater::UpdateType CompositedLayerMapping::updateGraphicsLayerGeom etry(GraphicsLayerUpdater::UpdateType updateType)
629 { 634 {
630 // If we haven't built z-order lists yet, wait until later. 635 // If we haven't built z-order lists yet, wait until later.
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 1898
1894 IntSize offset = paintInfo.offsetFromRenderer; 1899 IntSize offset = paintInfo.offsetFromRenderer;
1895 context->translate(-offset); 1900 context->translate(-offset);
1896 1901
1897 // The dirtyRect is in the coords of the painting root. 1902 // The dirtyRect is in the coords of the painting root.
1898 IntRect dirtyRect(clip); 1903 IntRect dirtyRect(clip);
1899 dirtyRect.move(offset); 1904 dirtyRect.move(offset);
1900 1905
1901 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) { 1906 if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) {
1902 LayoutRect bounds = paintInfo.compositedBounds; 1907 LayoutRect bounds = paintInfo.compositedBounds;
1903 bounds.move(m_subpixelAccumulation); 1908 bounds.move(paintInfo.subpixelAccumulation);
1904 dirtyRect.intersect(pixelSnappedIntRect(bounds)); 1909 dirtyRect.intersect(pixelSnappedIntRect(bounds));
1905 } else { 1910 } else {
1906 dirtyRect.move(roundedIntSize(m_subpixelAccumulation)); 1911 dirtyRect.move(roundedIntSize(paintInfo.subpixelAccumulation));
1907 } 1912 }
1908 1913
1909 #ifndef NDEBUG 1914 #ifndef NDEBUG
1910 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut(); 1915 paintInfo.renderLayer->renderer()->assertSubtreeIsLaidOut();
1911 #endif 1916 #endif
1912 1917
1913 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) { 1918 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) {
1914 // FIXME: GraphicsLayers need a way to split for RenderRegions. 1919 // FIXME: GraphicsLayers need a way to split for RenderRegions.
1915 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, m_subpixelAccumulation); 1920 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, paintInfo.subpixelAccumulation);
1916 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags); 1921 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFl ags);
1917 1922
1918 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo otBackgroundOnly); 1923 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo otBackgroundOnly);
1919 1924
1920 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) 1925 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars())
1921 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai ntFlags | PaintLayerPaintingOverlayScrollbars); 1926 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai ntFlags | PaintLayerPaintingOverlayScrollbars);
1922 } else { 1927 } else {
1923 ASSERT(compositor()->layerSquashingEnabled()); 1928 ASSERT(compositor()->layerSquashingEnabled());
1924 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, LayoutSize()); 1929 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe haviorNormal, paintInfo.subpixelAccumulation);
1925 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags); 1930 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags);
1926 } 1931 }
1927 1932
1928 ASSERT(!paintInfo.renderLayer->m_usedTransparency); 1933 ASSERT(!paintInfo.renderLayer->m_usedTransparency);
1929 1934
1930 // Manually restore the context to its original state by applying the opposi te translation. 1935 // Manually restore the context to its original state by applying the opposi te translation.
1931 context->translate(offset); 1936 context->translate(offset);
1932 } 1937 }
1933 1938
1934 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) 1939 static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip)
(...skipping 28 matching lines...) Expand all
1963 || graphicsLayer == m_maskLayer.get() 1968 || graphicsLayer == m_maskLayer.get()
1964 || graphicsLayer == m_childClippingMaskLayer.get() 1969 || graphicsLayer == m_childClippingMaskLayer.get()
1965 || graphicsLayer == m_scrollingContentsLayer.get()) { 1970 || graphicsLayer == m_scrollingContentsLayer.get()) {
1966 1971
1967 GraphicsLayerPaintInfo paintInfo; 1972 GraphicsLayerPaintInfo paintInfo;
1968 paintInfo.renderLayer = &m_owningLayer; 1973 paintInfo.renderLayer = &m_owningLayer;
1969 paintInfo.compositedBounds = compositedBounds(); 1974 paintInfo.compositedBounds = compositedBounds();
1970 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); 1975 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer();
1971 paintInfo.paintingPhase = paintingPhase; 1976 paintInfo.paintingPhase = paintingPhase;
1972 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); 1977 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer);
1978 paintInfo.subpixelAccumulation = m_subpixelAccumulation;
1973 1979
1974 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 1980 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
1975 doPaintTask(paintInfo, &context, clip); 1981 doPaintTask(paintInfo, &context, clip);
1976 } else if (graphicsLayer == m_squashingLayer.get()) { 1982 } else if (graphicsLayer == m_squashingLayer.get()) {
1977 ASSERT(compositor()->layerSquashingEnabled()); 1983 ASSERT(compositor()->layerSquashingEnabled());
1978 for (size_t i = 0; i < m_squashedLayers.size(); ++i) 1984 for (size_t i = 0; i < m_squashedLayers.size(); ++i)
1979 doPaintTask(m_squashedLayers[i], &context, clip); 1985 doPaintTask(m_squashedLayers[i], &context, clip);
1980 } else if (graphicsLayer == layerForHorizontalScrollbar()) { 1986 } else if (graphicsLayer == layerForHorizontalScrollbar()) {
1981 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co ntext, clip); 1987 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co ntext, clip);
1982 } else if (graphicsLayer == layerForVerticalScrollbar()) { 1988 } else if (graphicsLayer == layerForVerticalScrollbar()) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 LayoutRect CompositedLayerMapping::compositedBounds() const 2038 LayoutRect CompositedLayerMapping::compositedBounds() const
2033 { 2039 {
2034 return m_compositedBounds; 2040 return m_compositedBounds;
2035 } 2041 }
2036 2042
2037 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) 2043 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds)
2038 { 2044 {
2039 m_compositedBounds = bounds; 2045 m_compositedBounds = bounds;
2040 } 2046 }
2041 2047
2042 bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* layer, IntSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex) 2048 bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* layer, LayoutSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex)
2043 { 2049 {
2044 ASSERT(compositor()->layerSquashingEnabled()); 2050 ASSERT(compositor()->layerSquashingEnabled());
2045 2051
2046 GraphicsLayerPaintInfo paintInfo; 2052 GraphicsLayerPaintInfo paintInfo;
2047 paintInfo.renderLayer = layer; 2053 paintInfo.renderLayer = layer;
2048 // NOTE: composited bounds are updated elsewhere 2054 // NOTE: composited bounds are updated elsewhere
2049 // NOTE: offsetFromRenderer is updated elsewhere 2055 // NOTE: offsetFromRenderer is updated elsewhere
2050 paintInfo.offsetFromSquashingCLM = offsetFromSquashingCLM; 2056 paintInfo.offsetFromSquashingCLM = offsetFromSquashingCLM;
2051 paintInfo.paintingPhase = GraphicsLayerPaintAllWithOverflowClip; 2057 paintInfo.paintingPhase = GraphicsLayerPaintAllWithOverflowClip;
2052 paintInfo.isBackgroundLayer = false; 2058 paintInfo.isBackgroundLayer = false;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2133 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2128 name = "Scrolling Contents Layer"; 2134 name = "Scrolling Contents Layer";
2129 } else { 2135 } else {
2130 ASSERT_NOT_REACHED(); 2136 ASSERT_NOT_REACHED();
2131 } 2137 }
2132 2138
2133 return name; 2139 return name;
2134 } 2140 }
2135 2141
2136 } // namespace WebCore 2142 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698