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 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2181 ClipRectsContext clipRectsContext(ancestorPaintInfo->paintLayer, UncachedCli
pRects); | 2181 ClipRectsContext clipRectsContext(ancestorPaintInfo->paintLayer, UncachedCli
pRects); |
2182 IntRect parentClipRect = pixelSnappedIntRect(paintInfo.paintLayer->clipper()
.backgroundClipRect(clipRectsContext).rect()); | 2182 IntRect parentClipRect = pixelSnappedIntRect(paintInfo.paintLayer->clipper()
.backgroundClipRect(clipRectsContext).rect()); |
2183 ASSERT(parentClipRect != LayoutRect::infiniteIntRect()); | 2183 ASSERT(parentClipRect != LayoutRect::infiniteIntRect()); |
2184 | 2184 |
2185 // Convert from ancestor to local coordinates. | 2185 // Convert from ancestor to local coordinates. |
2186 IntSize ancestorToLocalOffset = paintInfo.offsetFromLayoutObject - ancestorP
aintInfo->offsetFromLayoutObject; | 2186 IntSize ancestorToLocalOffset = paintInfo.offsetFromLayoutObject - ancestorP
aintInfo->offsetFromLayoutObject; |
2187 parentClipRect.move(ancestorToLocalOffset); | 2187 parentClipRect.move(ancestorToLocalOffset); |
2188 return parentClipRect; | 2188 return parentClipRect; |
2189 } | 2189 } |
2190 | 2190 |
2191 void CompositedLayerMapping::doPaintTask(const GraphicsLayerPaintInfo& paintInfo
, const GraphicsLayer& graphicsLayer, const PaintLayerFlags& paintLayerFlags, Gr
aphicsContext* context, | 2191 void CompositedLayerMapping::doPaintTask(const GraphicsLayerPaintInfo& paintInfo
, const GraphicsLayer& graphicsLayer, const PaintLayerFlags& paintLayerFlags, Gr
aphicsContext& context, |
2192 const IntRect& clip /* In the coords of rootLayer */) const | 2192 const IntRect& clip /* In the coords of rootLayer */) const |
2193 { | 2193 { |
2194 FontCachePurgePreventer fontCachePurgePreventer; | 2194 FontCachePurgePreventer fontCachePurgePreventer; |
2195 | 2195 |
2196 IntSize offset = paintInfo.offsetFromLayoutObject; | 2196 IntSize offset = paintInfo.offsetFromLayoutObject; |
2197 AffineTransform translation; | 2197 AffineTransform translation; |
2198 translation.translate(-offset.width(), -offset.height()); | 2198 translation.translate(-offset.width(), -offset.height()); |
2199 TransformRecorder transformRecorder(*context, graphicsLayer, translation); | 2199 TransformRecorder transformRecorder(context, graphicsLayer, translation); |
2200 | 2200 |
2201 // The dirtyRect is in the coords of the painting root. | 2201 // The dirtyRect is in the coords of the painting root. |
2202 IntRect dirtyRect(clip); | 2202 IntRect dirtyRect(clip); |
2203 dirtyRect.move(offset); | 2203 dirtyRect.move(offset); |
2204 | 2204 |
2205 if (!(paintLayerFlags & PaintLayerPaintingOverflowContents)) { | 2205 if (!(paintLayerFlags & PaintLayerPaintingOverflowContents)) { |
2206 LayoutRect bounds = paintInfo.compositedBounds; | 2206 LayoutRect bounds = paintInfo.compositedBounds; |
2207 bounds.move(paintInfo.paintLayer->subpixelAccumulation()); | 2207 bounds.move(paintInfo.paintLayer->subpixelAccumulation()); |
2208 dirtyRect.intersect(pixelSnappedIntRect(bounds)); | 2208 dirtyRect.intersect(pixelSnappedIntRect(bounds)); |
2209 } else { | 2209 } else { |
2210 dirtyRect.move(roundedIntSize(paintInfo.paintLayer->subpixelAccumulation
())); | 2210 dirtyRect.move(roundedIntSize(paintInfo.paintLayer->subpixelAccumulation
())); |
2211 } | 2211 } |
2212 | 2212 |
2213 #if ENABLE(ASSERT) | 2213 #if ENABLE(ASSERT) |
2214 paintInfo.paintLayer->layoutObject()->assertSubtreeIsLaidOut(); | 2214 paintInfo.paintLayer->layoutObject()->assertSubtreeIsLaidOut(); |
2215 #endif | 2215 #endif |
2216 | 2216 |
2217 float deviceScaleFactor = blink::deviceScaleFactor(paintInfo.paintLayer->lay
outObject()->frame()); | 2217 float deviceScaleFactor = blink::deviceScaleFactor(paintInfo.paintLayer->lay
outObject()->frame()); |
2218 context->setDeviceScaleFactor(deviceScaleFactor); | 2218 context.setDeviceScaleFactor(deviceScaleFactor); |
2219 | 2219 |
2220 if (paintInfo.paintLayer->compositingState() != PaintsIntoGroupedBacking) { | 2220 if (paintInfo.paintLayer->compositingState() != PaintsIntoGroupedBacking) { |
2221 // FIXME: GraphicsLayers need a way to split for multicol. | 2221 // FIXME: GraphicsLayers need a way to split for multicol. |
2222 PaintLayerPaintingInfo paintingInfo(paintInfo.paintLayer, LayoutRect(dir
tyRect), GlobalPaintNormalPhase, paintInfo.paintLayer->subpixelAccumulation()); | 2222 PaintLayerPaintingInfo paintingInfo(paintInfo.paintLayer, LayoutRect(dir
tyRect), GlobalPaintNormalPhase, paintInfo.paintLayer->subpixelAccumulation()); |
2223 PaintLayerPainter(*paintInfo.paintLayer).paintLayerContents(context, pai
ntingInfo, paintLayerFlags); | 2223 PaintLayerPainter(*paintInfo.paintLayer).paintLayerContents(context, pai
ntingInfo, paintLayerFlags); |
2224 | 2224 |
2225 if (paintInfo.paintLayer->containsDirtyOverlayScrollbars()) | 2225 if (paintInfo.paintLayer->containsDirtyOverlayScrollbars()) |
2226 PaintLayerPainter(*paintInfo.paintLayer).paintLayerContents(context,
paintingInfo, paintLayerFlags | PaintLayerPaintingOverlayScrollbars); | 2226 PaintLayerPainter(*paintInfo.paintLayer).paintLayerContents(context,
paintingInfo, paintLayerFlags | PaintLayerPaintingOverlayScrollbars); |
2227 } else { | 2227 } else { |
2228 PaintLayerPaintingInfo paintingInfo(paintInfo.paintLayer, LayoutRect(dir
tyRect), GlobalPaintNormalPhase, paintInfo.paintLayer->subpixelAccumulation()); | 2228 PaintLayerPaintingInfo paintingInfo(paintInfo.paintLayer, LayoutRect(dir
tyRect), GlobalPaintNormalPhase, paintInfo.paintLayer->subpixelAccumulation()); |
2229 | 2229 |
2230 // PaintLayer::paintLayer assumes that the caller clips to the passed re
ct. Squashed layers need to do this clipping in software, | 2230 // PaintLayer::paintLayer assumes that the caller clips to the passed re
ct. Squashed layers need to do this clipping in software, |
2231 // since there is no graphics layer to clip them precisely. Furthermore,
in some cases we squash layers that need clipping in software | 2231 // since there is no graphics layer to clip them precisely. Furthermore,
in some cases we squash layers that need clipping in software |
2232 // from clipping ancestors (see CompositedLayerMapping::localClipRectFor
SquashedLayer()). | 2232 // from clipping ancestors (see CompositedLayerMapping::localClipRectFor
SquashedLayer()). |
2233 // FIXME: Is it correct to clip to dirtyRect in slimming paint mode? | 2233 // FIXME: Is it correct to clip to dirtyRect in slimming paint mode? |
2234 // FIXME: Combine similar code here and LayerClipRecorder. | 2234 // FIXME: Combine similar code here and LayerClipRecorder. |
2235 dirtyRect.intersect(paintInfo.localClipRectForSquashedLayer); | 2235 dirtyRect.intersect(paintInfo.localClipRectForSquashedLayer); |
2236 context->paintController().createAndAppend<ClipDisplayItem>(graphicsLaye
r, DisplayItem::ClipLayerOverflowControls, dirtyRect); | 2236 context.paintController().createAndAppend<ClipDisplayItem>(graphicsLayer
, DisplayItem::ClipLayerOverflowControls, dirtyRect); |
2237 | 2237 |
2238 PaintLayerPainter(*paintInfo.paintLayer).paintLayer(context, paintingInf
o, paintLayerFlags); | 2238 PaintLayerPainter(*paintInfo.paintLayer).paintLayer(context, paintingInf
o, paintLayerFlags); |
2239 context->paintController().endItem<EndClipDisplayItem>(graphicsLayer, Di
splayItem::clipTypeToEndClipType(DisplayItem::ClipLayerOverflowControls)); | 2239 context.paintController().endItem<EndClipDisplayItem>(graphicsLayer, Dis
playItem::clipTypeToEndClipType(DisplayItem::ClipLayerOverflowControls)); |
2240 } | 2240 } |
2241 } | 2241 } |
2242 | 2242 |
2243 static void paintScrollbar(const Scrollbar* scrollbar, GraphicsContext& context,
const IntRect& clip) | 2243 static void paintScrollbar(const Scrollbar* scrollbar, GraphicsContext& context,
const IntRect& clip) |
2244 { | 2244 { |
2245 if (!scrollbar) | 2245 if (!scrollbar) |
2246 return; | 2246 return; |
2247 | 2247 |
2248 const IntRect& scrollbarRect = scrollbar->frameRect(); | 2248 const IntRect& scrollbarRect = scrollbar->frameRect(); |
2249 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr
anslation(-scrollbarRect.x(), -scrollbarRect.y())); | 2249 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr
anslation(-scrollbarRect.x(), -scrollbarRect.y())); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2396 || graphicsLayer == m_childClippingMaskLayer.get() | 2396 || graphicsLayer == m_childClippingMaskLayer.get() |
2397 || graphicsLayer == m_scrollingContentsLayer.get() | 2397 || graphicsLayer == m_scrollingContentsLayer.get() |
2398 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2398 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2399 | 2399 |
2400 GraphicsLayerPaintInfo paintInfo; | 2400 GraphicsLayerPaintInfo paintInfo; |
2401 paintInfo.paintLayer = &m_owningLayer; | 2401 paintInfo.paintLayer = &m_owningLayer; |
2402 paintInfo.compositedBounds = compositedBounds(); | 2402 paintInfo.compositedBounds = compositedBounds(); |
2403 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject
(); | 2403 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject
(); |
2404 | 2404 |
2405 // We have to use the same root as for hit testing, because both methods
can compute and cache clipRects. | 2405 // We have to use the same root as for hit testing, because both methods
can compute and cache clipRects. |
2406 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, &context, intere
stRect); | 2406 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context, interes
tRect); |
2407 } else if (graphicsLayer == m_squashingLayer.get()) { | 2407 } else if (graphicsLayer == m_squashingLayer.get()) { |
2408 for (size_t i = 0; i < m_squashedLayers.size(); ++i) | 2408 for (size_t i = 0; i < m_squashedLayers.size(); ++i) |
2409 doPaintTask(m_squashedLayers[i], *graphicsLayer, paintLayerFlags, &c
ontext, interestRect); | 2409 doPaintTask(m_squashedLayers[i], *graphicsLayer, paintLayerFlags, co
ntext, interestRect); |
2410 } else if (graphicsLayer == layerForHorizontalScrollbar()) { | 2410 } else if (graphicsLayer == layerForHorizontalScrollbar()) { |
2411 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co
ntext, interestRect); | 2411 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co
ntext, interestRect); |
2412 } else if (graphicsLayer == layerForVerticalScrollbar()) { | 2412 } else if (graphicsLayer == layerForVerticalScrollbar()) { |
2413 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont
ext, interestRect); | 2413 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont
ext, interestRect); |
2414 } else if (graphicsLayer == layerForScrollCorner()) { | 2414 } else if (graphicsLayer == layerForScrollCorner()) { |
2415 IntPoint scrollCornerAndResizerLocation = m_owningLayer.scrollableArea()
->scrollCornerAndResizerRect().location(); | 2415 IntPoint scrollCornerAndResizerLocation = m_owningLayer.scrollableArea()
->scrollCornerAndResizerRect().location(); |
2416 CullRect cullRect(enclosingIntRect(interestRect)); | 2416 CullRect cullRect(enclosingIntRect(interestRect)); |
2417 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintScrollCorner
(context, -scrollCornerAndResizerLocation, cullRect); | 2417 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintScrollCorner
(context, -scrollCornerAndResizerLocation, cullRect); |
2418 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintResizer(cont
ext, -scrollCornerAndResizerLocation, cullRect); | 2418 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintResizer(cont
ext, -scrollCornerAndResizerLocation, cullRect); |
2419 } | 2419 } |
2420 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay
er, &context, LayoutRect(interestRect)); | 2420 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay
er, context, LayoutRect(interestRect)); |
2421 #if ENABLE(ASSERT) | 2421 #if ENABLE(ASSERT) |
2422 if (Page* page = layoutObject()->frame()->page()) | 2422 if (Page* page = layoutObject()->frame()->page()) |
2423 page->setIsPainting(false); | 2423 page->setIsPainting(false); |
2424 #endif | 2424 #endif |
2425 } | 2425 } |
2426 | 2426 |
2427 bool CompositedLayerMapping::isTrackingPaintInvalidations() const | 2427 bool CompositedLayerMapping::isTrackingPaintInvalidations() const |
2428 { | 2428 { |
2429 GraphicsLayerClient* client = compositor(); | 2429 GraphicsLayerClient* client = compositor(); |
2430 return client ? client->isTrackingPaintInvalidations() : false; | 2430 return client ? client->isTrackingPaintInvalidations() : false; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2602 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2603 name = "Scrolling Block Selection Layer"; | 2603 name = "Scrolling Block Selection Layer"; |
2604 } else { | 2604 } else { |
2605 ASSERT_NOT_REACHED(); | 2605 ASSERT_NOT_REACHED(); |
2606 } | 2606 } |
2607 | 2607 |
2608 return name; | 2608 return name; |
2609 } | 2609 } |
2610 | 2610 |
2611 } // namespace blink | 2611 } // namespace blink |
OLD | NEW |