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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 LayoutSize offsetFromSquashLayerOrigin = LayoutPoint(m_squashedLayers[i]
.offsetFromSquashingCLM) - squashLayerOriginInOwningLayerSpace; | 594 LayoutSize offsetFromSquashLayerOrigin = LayoutPoint(m_squashedLayers[i]
.offsetFromSquashingCLM) - squashLayerOriginInOwningLayerSpace; |
595 m_squashedLayers[i].offsetFromRenderer = -flooredIntSize(offsetFromSquas
hLayerOrigin); | 595 m_squashedLayers[i].offsetFromRenderer = -flooredIntSize(offsetFromSquas
hLayerOrigin); |
596 | 596 |
597 m_squashedLayers[i].renderLayer->setSubpixelAccumulation(offsetFromSquas
hLayerOrigin.fraction()); | 597 m_squashedLayers[i].renderLayer->setSubpixelAccumulation(offsetFromSquas
hLayerOrigin.fraction()); |
598 ASSERT(m_squashedLayers[i].renderLayer->subpixelAccumulation() == | 598 ASSERT(m_squashedLayers[i].renderLayer->subpixelAccumulation() == |
599 toLayoutSize(computeOffsetFromCompositedAncestor(m_squashedLayers[i]
.renderLayer, m_squashedLayers[i].renderLayer->ancestorCompositingLayer())).frac
tion()); | 599 toLayoutSize(computeOffsetFromCompositedAncestor(m_squashedLayers[i]
.renderLayer, m_squashedLayers[i].renderLayer->ancestorCompositingLayer())).frac
tion()); |
600 | 600 |
601 // FIXME: find a better design to avoid this redundant value - most like
ly it will make | 601 // FIXME: find a better design to avoid this redundant value - most like
ly it will make |
602 // sense to move the paint task info into RenderLayer's m_compositingPro
perties. | 602 // sense to move the paint task info into RenderLayer's m_compositingPro
perties. |
603 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m_squ
ashedLayers[i].offsetFromRenderer); | 603 m_squashedLayers[i].renderLayer->setOffsetFromSquashingLayerOrigin(m_squ
ashedLayers[i].offsetFromRenderer); |
| 604 |
604 } | 605 } |
| 606 |
| 607 for (size_t i = 0; i < m_squashedLayers.size(); ++i) |
| 608 m_squashedLayers[i].localClipRectForSquashedLayer = localClipRectForSqua
shedLayer(m_squashedLayers[i]); |
605 } | 609 } |
606 | 610 |
607 void CompositedLayerMapping::updateGraphicsLayerGeometry(GraphicsLayerUpdater::U
pdateType updateType, const RenderLayer* compositingContainer) | 611 void CompositedLayerMapping::updateGraphicsLayerGeometry(GraphicsLayerUpdater::U
pdateType updateType, const RenderLayer* compositingContainer) |
608 { | 612 { |
609 // If we haven't built z-order lists yet, wait until later. | 613 // If we haven't built z-order lists yet, wait until later. |
610 if (m_owningLayer.stackingNode()->isStackingContainer() && m_owningLayer.sta
ckingNode()->zOrderListsDirty()) | 614 if (m_owningLayer.stackingNode()->isStackingContainer() && m_owningLayer.sta
ckingNode()->zOrderListsDirty()) |
611 return; | 615 return; |
612 | 616 |
613 if (!shouldUpdateGraphicsLayer(updateType)) | 617 if (!shouldUpdateGraphicsLayer(updateType)) |
614 return; | 618 return; |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1827 | 1831 |
1828 // r is in the coordinate space of the layer's render object | 1832 // r is in the coordinate space of the layer's render object |
1829 void CompositedLayerMapping::setContentsNeedDisplayInRect(const IntRect& r) | 1833 void CompositedLayerMapping::setContentsNeedDisplayInRect(const IntRect& r) |
1830 { | 1834 { |
1831 // FIXME: need to split out repaints for the background. | 1835 // FIXME: need to split out repaints for the background. |
1832 ASSERT(!paintsIntoCompositedAncestor()); | 1836 ASSERT(!paintsIntoCompositedAncestor()); |
1833 SetContentsNeedsDisplayInRectFunctor functor = { r }; | 1837 SetContentsNeedsDisplayInRectFunctor functor = { r }; |
1834 ApplyToGraphicsLayers(this, functor, ApplyToContentLayers); | 1838 ApplyToGraphicsLayers(this, functor, ApplyToContentLayers); |
1835 } | 1839 } |
1836 | 1840 |
| 1841 const GraphicsLayerPaintInfo* CompositedLayerMapping::containingSquashedLayer(co
nst RenderObject* renderObject) const |
| 1842 { |
| 1843 for (size_t i = 0; i < m_squashedLayers.size(); ++i) { |
| 1844 if (renderObject->isDescendantOf(m_squashedLayers[i].renderLayer->render
er())) { |
| 1845 return &m_squashedLayers[i]; |
| 1846 break; |
| 1847 } |
| 1848 } |
| 1849 return 0; |
| 1850 } |
| 1851 |
| 1852 IntRect CompositedLayerMapping::localClipRectForSquashedLayer(const GraphicsLaye
rPaintInfo& paintInfo) const |
| 1853 { |
| 1854 const RenderObject* clippingContainer = paintInfo.renderLayer->renderer()->c
lippingContainer(); |
| 1855 if (clippingContainer == m_owningLayer.renderer()->clippingContainer()) |
| 1856 return PaintInfo::infiniteRect(); |
| 1857 |
| 1858 ASSERT(clippingContainer); |
| 1859 |
| 1860 const GraphicsLayerPaintInfo* ancestorPaintInfo = containingSquashedLayer(cl
ippingContainer); |
| 1861 // Must be there, otherwise CompositingLayerAssigner::canSquashIntoCurrentSq
uashingOwner would have disallowed squashing. |
| 1862 ASSERT(ancestorPaintInfo); |
| 1863 |
| 1864 // FIXME: this is a potential performance issue. We shoudl consider caching
these clip rects or otherwise optimizing. |
| 1865 ClipRectsContext clipRectsContext(ancestorPaintInfo->renderLayer, TemporaryC
lipRects); |
| 1866 IntRect parentClipRect = pixelSnappedIntRect(paintInfo.renderLayer->clipper(
).backgroundClipRect(clipRectsContext).rect()); |
| 1867 ASSERT(parentClipRect != PaintInfo::infiniteRect()); |
| 1868 |
| 1869 // Convert from ancestor to local coordinates. |
| 1870 IntSize ancestorToLocalOffset = paintInfo.offsetFromRenderer - ancestorPaint
Info->offsetFromRenderer; |
| 1871 parentClipRect.move(ancestorToLocalOffset); |
| 1872 return parentClipRect; |
| 1873 } |
| 1874 |
1837 void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap
hicsContext* context, | 1875 void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap
hicsContext* context, |
1838 const IntRect& clip) // In the coords of rootLayer. | 1876 const IntRect& clip) // In the coords of rootLayer. |
1839 { | 1877 { |
1840 if (paintsIntoCompositedAncestor()) { | 1878 if (paintsIntoCompositedAncestor()) { |
1841 ASSERT_NOT_REACHED(); | 1879 ASSERT_NOT_REACHED(); |
1842 return; | 1880 return; |
1843 } | 1881 } |
1844 | 1882 |
1845 FontCachePurgePreventer fontCachePurgePreventer; | 1883 FontCachePurgePreventer fontCachePurgePreventer; |
1846 | 1884 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 | 1933 |
1896 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo
otBackgroundOnly); | 1934 ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRo
otBackgroundOnly); |
1897 | 1935 |
1898 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) | 1936 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) |
1899 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai
ntFlags | PaintLayerPaintingOverlayScrollbars); | 1937 paintInfo.renderLayer->paintLayerContents(context, paintingInfo, pai
ntFlags | PaintLayerPaintingOverlayScrollbars); |
1900 } else { | 1938 } else { |
1901 ASSERT(compositor()->layerSquashingEnabled()); | 1939 ASSERT(compositor()->layerSquashingEnabled()); |
1902 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe
haviorNormal, paintInfo.renderLayer->subpixelAccumulation()); | 1940 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe
haviorNormal, paintInfo.renderLayer->subpixelAccumulation()); |
1903 | 1941 |
1904 // RenderLayer::paintLayer assumes that the caller clips to the passed r
ect. Squashed layers need to do this clipping in software, | 1942 // RenderLayer::paintLayer assumes that the caller clips to the passed r
ect. Squashed layers need to do this clipping in software, |
1905 // since there is no graphics layer to clip them precisely. | 1943 // since there is no graphics layer to clip them precisely. Furthermore,
in some cases we squash layers that need clipping in software |
1906 // FIXME: in some cases this clip is not necessary. For example if the d
irty rect is not the same as the bounds of the layer, | 1944 // from clipping ancestors (see CompositedLayerMapping::localClipRectFor
SquashedLayer()). |
1907 // RenderLayer will clip it (see RenderLayer::clipToRect). Put in more w
ork if this becomes a performance issue. | |
1908 context->save(); | 1945 context->save(); |
| 1946 dirtyRect.intersect(paintInfo.localClipRectForSquashedLayer); |
1909 context->clip(dirtyRect); | 1947 context->clip(dirtyRect); |
1910 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags); | 1948 paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags); |
1911 context->restore(); | 1949 context->restore(); |
1912 } | 1950 } |
1913 | 1951 |
1914 ASSERT(!paintInfo.renderLayer->usedTransparency()); | 1952 ASSERT(!paintInfo.renderLayer->usedTransparency()); |
1915 | 1953 |
1916 // Manually restore the context to its original state by applying the opposi
te translation. | 1954 // Manually restore the context to its original state by applying the opposi
te translation. |
1917 context->translate(offset); | 1955 context->translate(offset); |
1918 } | 1956 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2151 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2114 name = "Scrolling Contents Layer"; | 2152 name = "Scrolling Contents Layer"; |
2115 } else { | 2153 } else { |
2116 ASSERT_NOT_REACHED(); | 2154 ASSERT_NOT_REACHED(); |
2117 } | 2155 } |
2118 | 2156 |
2119 return name; | 2157 return name; |
2120 } | 2158 } |
2121 | 2159 |
2122 } // namespace WebCore | 2160 } // namespace WebCore |
OLD | NEW |