| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #include "platform/graphics/CompositorMutableProperties.h" | 63 #include "platform/graphics/CompositorMutableProperties.h" |
| 64 #include "platform/graphics/GraphicsContext.h" | 64 #include "platform/graphics/GraphicsContext.h" |
| 65 #include "platform/graphics/paint/ClipDisplayItem.h" | 65 #include "platform/graphics/paint/ClipDisplayItem.h" |
| 66 #include "platform/graphics/paint/CullRect.h" | 66 #include "platform/graphics/paint/CullRect.h" |
| 67 #include "platform/graphics/paint/DrawingRecorder.h" | 67 #include "platform/graphics/paint/DrawingRecorder.h" |
| 68 #include "platform/graphics/paint/PaintController.h" | 68 #include "platform/graphics/paint/PaintController.h" |
| 69 #include "platform/graphics/paint/SkPictureBuilder.h" | 69 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 70 #include "platform/graphics/paint/TransformDisplayItem.h" | 70 #include "platform/graphics/paint/TransformDisplayItem.h" |
| 71 #include "wtf/CurrentTime.h" | 71 #include "wtf/CurrentTime.h" |
| 72 #include "wtf/text/StringBuilder.h" | 72 #include "wtf/text/StringBuilder.h" |
| 73 #include <memory> |
| 73 | 74 |
| 74 namespace blink { | 75 namespace blink { |
| 75 | 76 |
| 76 using namespace HTMLNames; | 77 using namespace HTMLNames; |
| 77 | 78 |
| 78 static IntRect clipBox(LayoutBox* layoutObject); | 79 static IntRect clipBox(LayoutBox* layoutObject); |
| 79 | 80 |
| 80 static IntRect contentsRect(const LayoutObject* layoutObject) | 81 static IntRect contentsRect(const LayoutObject* layoutObject) |
| 81 { | 82 { |
| 82 if (!layoutObject->isBox()) | 83 if (!layoutObject->isBox()) |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 updateChildTransformLayer(false); | 215 updateChildTransformLayer(false); |
| 215 updateForegroundLayer(false); | 216 updateForegroundLayer(false); |
| 216 updateBackgroundLayer(false); | 217 updateBackgroundLayer(false); |
| 217 updateMaskLayer(false); | 218 updateMaskLayer(false); |
| 218 updateChildClippingMaskLayer(false); | 219 updateChildClippingMaskLayer(false); |
| 219 updateScrollingLayers(false); | 220 updateScrollingLayers(false); |
| 220 updateSquashingLayers(false); | 221 updateSquashingLayers(false); |
| 221 destroyGraphicsLayers(); | 222 destroyGraphicsLayers(); |
| 222 } | 223 } |
| 223 | 224 |
| 224 PassOwnPtr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compositin
gReasons reasons, SquashingDisallowedReasons squashingDisallowedReasons) | 225 std::unique_ptr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compo
sitingReasons reasons, SquashingDisallowedReasons squashingDisallowedReasons) |
| 225 { | 226 { |
| 226 OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(this); | 227 std::unique_ptr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(this); |
| 227 | 228 |
| 228 graphicsLayer->setCompositingReasons(reasons); | 229 graphicsLayer->setCompositingReasons(reasons); |
| 229 graphicsLayer->setSquashingDisallowedReasons(squashingDisallowedReasons); | 230 graphicsLayer->setSquashingDisallowedReasons(squashingDisallowedReasons); |
| 230 if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode()) | 231 if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode()) |
| 231 graphicsLayer->setOwnerNodeId(DOMNodeIds::idForNode(owningNode)); | 232 graphicsLayer->setOwnerNodeId(DOMNodeIds::idForNode(owningNode)); |
| 232 | 233 |
| 233 return graphicsLayer; | 234 return graphicsLayer; |
| 234 } | 235 } |
| 235 | 236 |
| 236 void CompositedLayerMapping::createPrimaryGraphicsLayer() | 237 void CompositedLayerMapping::createPrimaryGraphicsLayer() |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 layerToApplyChildClippingMask = clippingLayer(); | 495 layerToApplyChildClippingMask = clippingLayer(); |
| 495 } else if (hasScrollingLayer()) { | 496 } else if (hasScrollingLayer()) { |
| 496 layerToApplyChildClippingMask = scrollingLayer(); | 497 layerToApplyChildClippingMask = scrollingLayer(); |
| 497 } else if (isAcceleratedContents(layoutObject)) { | 498 } else if (isAcceleratedContents(layoutObject)) { |
| 498 shouldApplyChildClippingMaskOnContents = true; | 499 shouldApplyChildClippingMaskOnContents = true; |
| 499 } | 500 } |
| 500 } | 501 } |
| 501 | 502 |
| 502 updateChildClippingMaskLayer(needsChildClippingMask); | 503 updateChildClippingMaskLayer(needsChildClippingMask); |
| 503 | 504 |
| 504 if (layerToApplyChildClippingMask == m_graphicsLayer) { | 505 if (layerToApplyChildClippingMask == m_graphicsLayer.get()) { |
| 505 if (m_graphicsLayer->maskLayer() != m_childClippingMaskLayer.get()) { | 506 if (m_graphicsLayer->maskLayer() != m_childClippingMaskLayer.get()) { |
| 506 m_graphicsLayer->setMaskLayer(m_childClippingMaskLayer.get()); | 507 m_graphicsLayer->setMaskLayer(m_childClippingMaskLayer.get()); |
| 507 maskLayerChanged = true; | 508 maskLayerChanged = true; |
| 508 } | 509 } |
| 509 } else if (m_graphicsLayer->maskLayer() && m_graphicsLayer->maskLayer() != m
_maskLayer.get()) { | 510 } else if (m_graphicsLayer->maskLayer() && m_graphicsLayer->maskLayer() != m
_maskLayer.get()) { |
| 510 m_graphicsLayer->setMaskLayer(nullptr); | 511 m_graphicsLayer->setMaskLayer(nullptr); |
| 511 maskLayerChanged = true; | 512 maskLayerChanged = true; |
| 512 } | 513 } |
| 513 if (hasClippingLayer()) | 514 if (hasClippingLayer()) |
| 514 clippingLayer()->setMaskLayer(layerToApplyChildClippingMask == clippingL
ayer() ? m_childClippingMaskLayer.get() : nullptr); | 515 clippingLayer()->setMaskLayer(layerToApplyChildClippingMask == clippingL
ayer() ? m_childClippingMaskLayer.get() : nullptr); |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 } | 1323 } |
| 1323 | 1324 |
| 1324 return layersChanged; | 1325 return layersChanged; |
| 1325 } | 1326 } |
| 1326 | 1327 |
| 1327 void CompositedLayerMapping::setBackgroundLayerPaintsFixedRootBackground(bool ba
ckgroundLayerPaintsFixedRootBackground) | 1328 void CompositedLayerMapping::setBackgroundLayerPaintsFixedRootBackground(bool ba
ckgroundLayerPaintsFixedRootBackground) |
| 1328 { | 1329 { |
| 1329 m_backgroundLayerPaintsFixedRootBackground = backgroundLayerPaintsFixedRootB
ackground; | 1330 m_backgroundLayerPaintsFixedRootBackground = backgroundLayerPaintsFixedRootB
ackground; |
| 1330 } | 1331 } |
| 1331 | 1332 |
| 1332 bool CompositedLayerMapping::toggleScrollbarLayerIfNeeded(OwnPtr<GraphicsLayer>&
layer, bool needsLayer, CompositingReasons reason) | 1333 bool CompositedLayerMapping::toggleScrollbarLayerIfNeeded(std::unique_ptr<Graphi
csLayer>& layer, bool needsLayer, CompositingReasons reason) |
| 1333 { | 1334 { |
| 1334 if (needsLayer == !!layer) | 1335 if (needsLayer == !!layer) |
| 1335 return false; | 1336 return false; |
| 1336 layer = needsLayer ? createGraphicsLayer(reason) : nullptr; | 1337 layer = needsLayer ? createGraphicsLayer(reason) : nullptr; |
| 1337 | 1338 |
| 1338 if (PaintLayerScrollableArea* scrollableArea = m_owningLayer.getScrollableAr
ea()) { | 1339 if (PaintLayerScrollableArea* scrollableArea = m_owningLayer.getScrollableAr
ea()) { |
| 1339 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFro
mLayer(m_owningLayer)) { | 1340 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFro
mLayer(m_owningLayer)) { |
| 1340 if (reason == CompositingReasonLayerForHorizontalScrollbar) | 1341 if (reason == CompositingReasonLayerForHorizontalScrollbar) |
| 1341 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(scro
llableArea, HorizontalScrollbar); | 1342 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(scro
llableArea, HorizontalScrollbar); |
| 1342 else if (reason == CompositingReasonLayerForVerticalScrollbar) | 1343 else if (reason == CompositingReasonLayerForVerticalScrollbar) |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 } | 2257 } |
| 2257 | 2258 |
| 2258 static const int kPixelDistanceToRecord = 4000; | 2259 static const int kPixelDistanceToRecord = 4000; |
| 2259 | 2260 |
| 2260 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph
icsLayer) const | 2261 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph
icsLayer) const |
| 2261 { | 2262 { |
| 2262 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); | 2263 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); |
| 2263 | 2264 |
| 2264 IntSize offsetFromAnchorLayoutObject; | 2265 IntSize offsetFromAnchorLayoutObject; |
| 2265 const LayoutBoxModelObject* anchorLayoutObject; | 2266 const LayoutBoxModelObject* anchorLayoutObject; |
| 2266 if (graphicsLayer == m_squashingLayer) { | 2267 if (graphicsLayer == m_squashingLayer.get()) { |
| 2267 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev
er, it should never be the case that | 2268 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev
er, it should never be the case that |
| 2268 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must
be a bug elsewhere. | 2269 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must
be a bug elsewhere. |
| 2269 if (m_squashedLayers.size() == 0) | 2270 if (m_squashedLayers.size() == 0) |
| 2270 return IntRect(); | 2271 return IntRect(); |
| 2271 // All squashed layers have the same clip and transform space, so we can
use the first squashed layer's | 2272 // All squashed layers have the same clip and transform space, so we can
use the first squashed layer's |
| 2272 // layoutObject to map the squashing layer's bounds into viewport space,
with offsetFromAnchorLayoutObject | 2273 // layoutObject to map the squashing layer's bounds into viewport space,
with offsetFromAnchorLayoutObject |
| 2273 // to translate squashing layer's bounds into the first squashed layer's
space. | 2274 // to translate squashing layer's bounds into the first squashed layer's
space. |
| 2274 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); | 2275 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); |
| 2275 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec
t; | 2276 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec
t; |
| 2276 } else { | 2277 } else { |
| 2277 ASSERT(graphicsLayer == m_graphicsLayer || graphicsLayer == m_scrollingC
ontentsLayer); | 2278 ASSERT(graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_scro
llingContentsLayer.get()); |
| 2278 anchorLayoutObject = m_owningLayer.layoutObject(); | 2279 anchorLayoutObject = m_owningLayer.layoutObject(); |
| 2279 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); | 2280 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); |
| 2280 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject
); | 2281 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject
); |
| 2281 } | 2282 } |
| 2282 | 2283 |
| 2283 // Start with the bounds of the graphics layer in the space of the anchor La
youtObject. | 2284 // Start with the bounds of the graphics layer in the space of the anchor La
youtObject. |
| 2284 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); | 2285 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); |
| 2285 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); | 2286 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); |
| 2286 // The object space means including writing mode flip. | 2287 // The object space means including writing mode flip. |
| 2287 if (anchorLayoutObject->isBox()) | 2288 if (anchorLayoutObject->isBox()) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2352 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, const IntRect& previousInterestRect) const | 2353 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, const IntRect& previousInterestRect) const |
| 2353 { | 2354 { |
| 2354 // Use the previous interest rect if it covers the whole layer. | 2355 // Use the previous interest rect if it covers the whole layer. |
| 2355 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer->
size())); | 2356 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer->
size())); |
| 2356 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) | 2357 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) |
| 2357 return previousInterestRect; | 2358 return previousInterestRect; |
| 2358 | 2359 |
| 2359 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W
ebPreferences::record_whole_document is true. | 2360 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W
ebPreferences::record_whole_document is true. |
| 2360 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin
gs()->mainFrameClipsContent(); | 2361 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin
gs()->mainFrameClipsContent(); |
| 2361 if (shouldPaintWholePage | 2362 if (shouldPaintWholePage |
| 2362 || (graphicsLayer != m_graphicsLayer && graphicsLayer != m_squashingLaye
r && graphicsLayer != m_squashingLayer && graphicsLayer != m_scrollingContentsLa
yer)) | 2363 || (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashi
ngLayer.get() && graphicsLayer != m_squashingLayer.get() && graphicsLayer != m_s
crollingContentsLayer.get())) |
| 2363 return wholeLayerRect; | 2364 return wholeLayerRect; |
| 2364 | 2365 |
| 2365 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); | 2366 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); |
| 2366 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect
, expandedIntSize(graphicsLayer->size()))) | 2367 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect
, expandedIntSize(graphicsLayer->size()))) |
| 2367 return newInterestRect; | 2368 return newInterestRect; |
| 2368 return previousInterestRect; | 2369 return previousInterestRect; |
| 2369 } | 2370 } |
| 2370 | 2371 |
| 2371 LayoutSize CompositedLayerMapping::subpixelAccumulation() const | 2372 LayoutSize CompositedLayerMapping::subpixelAccumulation() const |
| 2372 { | 2373 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2411 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; | 2412 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; |
| 2412 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) | 2413 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) |
| 2413 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; | 2414 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; |
| 2414 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) | 2415 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) |
| 2415 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; | 2416 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; |
| 2416 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) | 2417 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) |
| 2417 paintLayerFlags |= PaintLayerPaintingOverflowContents; | 2418 paintLayerFlags |= PaintLayerPaintingOverflowContents; |
| 2418 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) | 2419 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) |
| 2419 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; | 2420 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; |
| 2420 | 2421 |
| 2421 if (graphicsLayer == m_backgroundLayer) | 2422 if (graphicsLayer == m_backgroundLayer.get()) |
| 2422 paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPai
ntingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroun
dPhase to walk child layers. | 2423 paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPai
ntingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroun
dPhase to walk child layers. |
| 2423 else if (compositor()->fixedRootBackgroundLayer()) | 2424 else if (compositor()->fixedRootBackgroundLayer()) |
| 2424 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; | 2425 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; |
| 2425 | 2426 |
| 2426 if (graphicsLayer == m_graphicsLayer.get() | 2427 if (graphicsLayer == m_graphicsLayer.get() |
| 2427 || graphicsLayer == m_foregroundLayer.get() | 2428 || graphicsLayer == m_foregroundLayer.get() |
| 2428 || graphicsLayer == m_backgroundLayer.get() | 2429 || graphicsLayer == m_backgroundLayer.get() |
| 2429 || graphicsLayer == m_maskLayer.get() | 2430 || graphicsLayer == m_maskLayer.get() |
| 2430 || graphicsLayer == m_childClippingMaskLayer.get() | 2431 || graphicsLayer == m_childClippingMaskLayer.get() |
| 2431 || graphicsLayer == m_scrollingContentsLayer.get()) { | 2432 || graphicsLayer == m_scrollingContentsLayer.get()) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2655 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2655 name = "Scrolling Contents Layer"; | 2656 name = "Scrolling Contents Layer"; |
| 2656 } else { | 2657 } else { |
| 2657 ASSERT_NOT_REACHED(); | 2658 ASSERT_NOT_REACHED(); |
| 2658 } | 2659 } |
| 2659 | 2660 |
| 2660 return name; | 2661 return name; |
| 2661 } | 2662 } |
| 2662 | 2663 |
| 2663 } // namespace blink | 2664 } // namespace blink |
| OLD | NEW |