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> | |
74 | 73 |
75 namespace blink { | 74 namespace blink { |
76 | 75 |
77 using namespace HTMLNames; | 76 using namespace HTMLNames; |
78 | 77 |
79 static IntRect clipBox(LayoutBox* layoutObject); | 78 static IntRect clipBox(LayoutBox* layoutObject); |
80 | 79 |
81 static IntRect contentsRect(const LayoutObject* layoutObject) | 80 static IntRect contentsRect(const LayoutObject* layoutObject) |
82 { | 81 { |
83 if (!layoutObject->isBox()) | 82 if (!layoutObject->isBox()) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 updateChildTransformLayer(false); | 214 updateChildTransformLayer(false); |
216 updateForegroundLayer(false); | 215 updateForegroundLayer(false); |
217 updateBackgroundLayer(false); | 216 updateBackgroundLayer(false); |
218 updateMaskLayer(false); | 217 updateMaskLayer(false); |
219 updateChildClippingMaskLayer(false); | 218 updateChildClippingMaskLayer(false); |
220 updateScrollingLayers(false); | 219 updateScrollingLayers(false); |
221 updateSquashingLayers(false); | 220 updateSquashingLayers(false); |
222 destroyGraphicsLayers(); | 221 destroyGraphicsLayers(); |
223 } | 222 } |
224 | 223 |
225 std::unique_ptr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compo
sitingReasons reasons, SquashingDisallowedReasons squashingDisallowedReasons) | 224 PassOwnPtr<GraphicsLayer> CompositedLayerMapping::createGraphicsLayer(Compositin
gReasons reasons, SquashingDisallowedReasons squashingDisallowedReasons) |
226 { | 225 { |
227 std::unique_ptr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(this); | 226 OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(this); |
228 | 227 |
229 graphicsLayer->setCompositingReasons(reasons); | 228 graphicsLayer->setCompositingReasons(reasons); |
230 graphicsLayer->setSquashingDisallowedReasons(squashingDisallowedReasons); | 229 graphicsLayer->setSquashingDisallowedReasons(squashingDisallowedReasons); |
231 if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode()) | 230 if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode()) |
232 graphicsLayer->setOwnerNodeId(DOMNodeIds::idForNode(owningNode)); | 231 graphicsLayer->setOwnerNodeId(DOMNodeIds::idForNode(owningNode)); |
233 | 232 |
234 return graphicsLayer; | 233 return graphicsLayer; |
235 } | 234 } |
236 | 235 |
237 void CompositedLayerMapping::createPrimaryGraphicsLayer() | 236 void CompositedLayerMapping::createPrimaryGraphicsLayer() |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 layerToApplyChildClippingMask = clippingLayer(); | 494 layerToApplyChildClippingMask = clippingLayer(); |
496 } else if (hasScrollingLayer()) { | 495 } else if (hasScrollingLayer()) { |
497 layerToApplyChildClippingMask = scrollingLayer(); | 496 layerToApplyChildClippingMask = scrollingLayer(); |
498 } else if (isAcceleratedContents(layoutObject)) { | 497 } else if (isAcceleratedContents(layoutObject)) { |
499 shouldApplyChildClippingMaskOnContents = true; | 498 shouldApplyChildClippingMaskOnContents = true; |
500 } | 499 } |
501 } | 500 } |
502 | 501 |
503 updateChildClippingMaskLayer(needsChildClippingMask); | 502 updateChildClippingMaskLayer(needsChildClippingMask); |
504 | 503 |
505 if (layerToApplyChildClippingMask == m_graphicsLayer.get()) { | 504 if (layerToApplyChildClippingMask == m_graphicsLayer) { |
506 if (m_graphicsLayer->maskLayer() != m_childClippingMaskLayer.get()) { | 505 if (m_graphicsLayer->maskLayer() != m_childClippingMaskLayer.get()) { |
507 m_graphicsLayer->setMaskLayer(m_childClippingMaskLayer.get()); | 506 m_graphicsLayer->setMaskLayer(m_childClippingMaskLayer.get()); |
508 maskLayerChanged = true; | 507 maskLayerChanged = true; |
509 } | 508 } |
510 } else if (m_graphicsLayer->maskLayer() && m_graphicsLayer->maskLayer() != m
_maskLayer.get()) { | 509 } else if (m_graphicsLayer->maskLayer() && m_graphicsLayer->maskLayer() != m
_maskLayer.get()) { |
511 m_graphicsLayer->setMaskLayer(nullptr); | 510 m_graphicsLayer->setMaskLayer(nullptr); |
512 maskLayerChanged = true; | 511 maskLayerChanged = true; |
513 } | 512 } |
514 if (hasClippingLayer()) | 513 if (hasClippingLayer()) |
515 clippingLayer()->setMaskLayer(layerToApplyChildClippingMask == clippingL
ayer() ? m_childClippingMaskLayer.get() : nullptr); | 514 clippingLayer()->setMaskLayer(layerToApplyChildClippingMask == clippingL
ayer() ? m_childClippingMaskLayer.get() : nullptr); |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 } | 1322 } |
1324 | 1323 |
1325 return layersChanged; | 1324 return layersChanged; |
1326 } | 1325 } |
1327 | 1326 |
1328 void CompositedLayerMapping::setBackgroundLayerPaintsFixedRootBackground(bool ba
ckgroundLayerPaintsFixedRootBackground) | 1327 void CompositedLayerMapping::setBackgroundLayerPaintsFixedRootBackground(bool ba
ckgroundLayerPaintsFixedRootBackground) |
1329 { | 1328 { |
1330 m_backgroundLayerPaintsFixedRootBackground = backgroundLayerPaintsFixedRootB
ackground; | 1329 m_backgroundLayerPaintsFixedRootBackground = backgroundLayerPaintsFixedRootB
ackground; |
1331 } | 1330 } |
1332 | 1331 |
1333 bool CompositedLayerMapping::toggleScrollbarLayerIfNeeded(std::unique_ptr<Graphi
csLayer>& layer, bool needsLayer, CompositingReasons reason) | 1332 bool CompositedLayerMapping::toggleScrollbarLayerIfNeeded(OwnPtr<GraphicsLayer>&
layer, bool needsLayer, CompositingReasons reason) |
1334 { | 1333 { |
1335 if (needsLayer == !!layer) | 1334 if (needsLayer == !!layer) |
1336 return false; | 1335 return false; |
1337 layer = needsLayer ? createGraphicsLayer(reason) : nullptr; | 1336 layer = needsLayer ? createGraphicsLayer(reason) : nullptr; |
1338 | 1337 |
1339 if (PaintLayerScrollableArea* scrollableArea = m_owningLayer.getScrollableAr
ea()) { | 1338 if (PaintLayerScrollableArea* scrollableArea = m_owningLayer.getScrollableAr
ea()) { |
1340 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFro
mLayer(m_owningLayer)) { | 1339 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFro
mLayer(m_owningLayer)) { |
1341 if (reason == CompositingReasonLayerForHorizontalScrollbar) | 1340 if (reason == CompositingReasonLayerForHorizontalScrollbar) |
1342 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(scro
llableArea, HorizontalScrollbar); | 1341 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(scro
llableArea, HorizontalScrollbar); |
1343 else if (reason == CompositingReasonLayerForVerticalScrollbar) | 1342 else if (reason == CompositingReasonLayerForVerticalScrollbar) |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 } | 2242 } |
2244 | 2243 |
2245 static const int kPixelDistanceToRecord = 4000; | 2244 static const int kPixelDistanceToRecord = 4000; |
2246 | 2245 |
2247 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph
icsLayer) const | 2246 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph
icsLayer) const |
2248 { | 2247 { |
2249 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); | 2248 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); |
2250 | 2249 |
2251 IntSize offsetFromAnchorLayoutObject; | 2250 IntSize offsetFromAnchorLayoutObject; |
2252 const LayoutBoxModelObject* anchorLayoutObject; | 2251 const LayoutBoxModelObject* anchorLayoutObject; |
2253 if (graphicsLayer == m_squashingLayer.get()) { | 2252 if (graphicsLayer == m_squashingLayer) { |
2254 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev
er, it should never be the case that | 2253 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev
er, it should never be the case that |
2255 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must
be a bug elsewhere. | 2254 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must
be a bug elsewhere. |
2256 if (m_squashedLayers.size() == 0) | 2255 if (m_squashedLayers.size() == 0) |
2257 return IntRect(); | 2256 return IntRect(); |
2258 // All squashed layers have the same clip and transform space, so we can
use the first squashed layer's | 2257 // All squashed layers have the same clip and transform space, so we can
use the first squashed layer's |
2259 // layoutObject to map the squashing layer's bounds into viewport space,
with offsetFromAnchorLayoutObject | 2258 // layoutObject to map the squashing layer's bounds into viewport space,
with offsetFromAnchorLayoutObject |
2260 // to translate squashing layer's bounds into the first squashed layer's
space. | 2259 // to translate squashing layer's bounds into the first squashed layer's
space. |
2261 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); | 2260 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); |
2262 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec
t; | 2261 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec
t; |
2263 } else { | 2262 } else { |
2264 ASSERT(graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_scro
llingContentsLayer.get()); | 2263 ASSERT(graphicsLayer == m_graphicsLayer || graphicsLayer == m_scrollingC
ontentsLayer); |
2265 anchorLayoutObject = m_owningLayer.layoutObject(); | 2264 anchorLayoutObject = m_owningLayer.layoutObject(); |
2266 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); | 2265 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); |
2267 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject
); | 2266 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject
); |
2268 } | 2267 } |
2269 | 2268 |
2270 // Start with the bounds of the graphics layer in the space of the anchor La
youtObject. | 2269 // Start with the bounds of the graphics layer in the space of the anchor La
youtObject. |
2271 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); | 2270 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); |
2272 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); | 2271 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); |
2273 // The object space means including writing mode flip. | 2272 // The object space means including writing mode flip. |
2274 if (anchorLayoutObject->isBox()) | 2273 if (anchorLayoutObject->isBox()) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2339 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, const IntRect& previousInterestRect) const | 2338 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, const IntRect& previousInterestRect) const |
2340 { | 2339 { |
2341 // Use the previous interest rect if it covers the whole layer. | 2340 // Use the previous interest rect if it covers the whole layer. |
2342 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer->
size())); | 2341 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer->
size())); |
2343 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) | 2342 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) |
2344 return previousInterestRect; | 2343 return previousInterestRect; |
2345 | 2344 |
2346 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W
ebPreferences::record_whole_document is true. | 2345 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W
ebPreferences::record_whole_document is true. |
2347 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin
gs()->mainFrameClipsContent(); | 2346 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin
gs()->mainFrameClipsContent(); |
2348 if (shouldPaintWholePage | 2347 if (shouldPaintWholePage |
2349 || (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashi
ngLayer.get() && graphicsLayer != m_squashingLayer.get() && graphicsLayer != m_s
crollingContentsLayer.get())) | 2348 || (graphicsLayer != m_graphicsLayer && graphicsLayer != m_squashingLaye
r && graphicsLayer != m_squashingLayer && graphicsLayer != m_scrollingContentsLa
yer)) |
2350 return wholeLayerRect; | 2349 return wholeLayerRect; |
2351 | 2350 |
2352 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); | 2351 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); |
2353 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect
, expandedIntSize(graphicsLayer->size()))) | 2352 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect
, expandedIntSize(graphicsLayer->size()))) |
2354 return newInterestRect; | 2353 return newInterestRect; |
2355 return previousInterestRect; | 2354 return previousInterestRect; |
2356 } | 2355 } |
2357 | 2356 |
2358 LayoutSize CompositedLayerMapping::subpixelAccumulation() const | 2357 LayoutSize CompositedLayerMapping::subpixelAccumulation() const |
2359 { | 2358 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2398 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; | 2397 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; |
2399 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) | 2398 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) |
2400 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; | 2399 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; |
2401 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) | 2400 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) |
2402 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; | 2401 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; |
2403 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) | 2402 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) |
2404 paintLayerFlags |= PaintLayerPaintingOverflowContents; | 2403 paintLayerFlags |= PaintLayerPaintingOverflowContents; |
2405 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) | 2404 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) |
2406 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; | 2405 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; |
2407 | 2406 |
2408 if (graphicsLayer == m_backgroundLayer.get()) | 2407 if (graphicsLayer == m_backgroundLayer) |
2409 paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPai
ntingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroun
dPhase to walk child layers. | 2408 paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPai
ntingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroun
dPhase to walk child layers. |
2410 else if (compositor()->fixedRootBackgroundLayer()) | 2409 else if (compositor()->fixedRootBackgroundLayer()) |
2411 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; | 2410 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; |
2412 | 2411 |
2413 if (graphicsLayer == m_graphicsLayer.get() | 2412 if (graphicsLayer == m_graphicsLayer.get() |
2414 || graphicsLayer == m_foregroundLayer.get() | 2413 || graphicsLayer == m_foregroundLayer.get() |
2415 || graphicsLayer == m_backgroundLayer.get() | 2414 || graphicsLayer == m_backgroundLayer.get() |
2416 || graphicsLayer == m_maskLayer.get() | 2415 || graphicsLayer == m_maskLayer.get() |
2417 || graphicsLayer == m_childClippingMaskLayer.get() | 2416 || graphicsLayer == m_childClippingMaskLayer.get() |
2418 || graphicsLayer == m_scrollingContentsLayer.get()) { | 2417 || graphicsLayer == m_scrollingContentsLayer.get()) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2641 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2640 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2642 name = "Scrolling Contents Layer"; | 2641 name = "Scrolling Contents Layer"; |
2643 } else { | 2642 } else { |
2644 ASSERT_NOT_REACHED(); | 2643 ASSERT_NOT_REACHED(); |
2645 } | 2644 } |
2646 | 2645 |
2647 return name; | 2646 return name; |
2648 } | 2647 } |
2649 | 2648 |
2650 } // namespace blink | 2649 } // namespace blink |
OLD | NEW |