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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2242 } | 2243 } |
2243 | 2244 |
2244 static const int kPixelDistanceToRecord = 4000; | 2245 static const int kPixelDistanceToRecord = 4000; |
2245 | 2246 |
2246 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph
icsLayer) const | 2247 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph
icsLayer) const |
2247 { | 2248 { |
2248 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); | 2249 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); |
2249 | 2250 |
2250 IntSize offsetFromAnchorLayoutObject; | 2251 IntSize offsetFromAnchorLayoutObject; |
2251 const LayoutBoxModelObject* anchorLayoutObject; | 2252 const LayoutBoxModelObject* anchorLayoutObject; |
2252 if (graphicsLayer == m_squashingLayer) { | 2253 if (graphicsLayer == m_squashingLayer.get()) { |
2253 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev
er, it should never be the case that | 2254 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev
er, it should never be the case that |
2254 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must
be a bug elsewhere. | 2255 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must
be a bug elsewhere. |
2255 if (m_squashedLayers.size() == 0) | 2256 if (m_squashedLayers.size() == 0) |
2256 return IntRect(); | 2257 return IntRect(); |
2257 // All squashed layers have the same clip and transform space, so we can
use the first squashed layer's | 2258 // All squashed layers have the same clip and transform space, so we can
use the first squashed layer's |
2258 // layoutObject to map the squashing layer's bounds into viewport space,
with offsetFromAnchorLayoutObject | 2259 // layoutObject to map the squashing layer's bounds into viewport space,
with offsetFromAnchorLayoutObject |
2259 // to translate squashing layer's bounds into the first squashed layer's
space. | 2260 // to translate squashing layer's bounds into the first squashed layer's
space. |
2260 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); | 2261 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); |
2261 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec
t; | 2262 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec
t; |
2262 } else { | 2263 } else { |
2263 ASSERT(graphicsLayer == m_graphicsLayer || graphicsLayer == m_scrollingC
ontentsLayer); | 2264 ASSERT(graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_scro
llingContentsLayer.get()); |
2264 anchorLayoutObject = m_owningLayer.layoutObject(); | 2265 anchorLayoutObject = m_owningLayer.layoutObject(); |
2265 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); | 2266 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); |
2266 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject
); | 2267 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject
); |
2267 } | 2268 } |
2268 | 2269 |
2269 // Start with the bounds of the graphics layer in the space of the anchor La
youtObject. | 2270 // Start with the bounds of the graphics layer in the space of the anchor La
youtObject. |
2270 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); | 2271 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); |
2271 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); | 2272 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); |
2272 // The object space means including writing mode flip. | 2273 // The object space means including writing mode flip. |
2273 if (anchorLayoutObject->isBox()) | 2274 if (anchorLayoutObject->isBox()) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2338 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, const IntRect& previousInterestRect) const | 2339 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, const IntRect& previousInterestRect) const |
2339 { | 2340 { |
2340 // Use the previous interest rect if it covers the whole layer. | 2341 // Use the previous interest rect if it covers the whole layer. |
2341 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer->
size())); | 2342 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer->
size())); |
2342 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) | 2343 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) |
2343 return previousInterestRect; | 2344 return previousInterestRect; |
2344 | 2345 |
2345 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W
ebPreferences::record_whole_document is true. | 2346 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W
ebPreferences::record_whole_document is true. |
2346 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin
gs()->mainFrameClipsContent(); | 2347 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin
gs()->mainFrameClipsContent(); |
2347 if (shouldPaintWholePage | 2348 if (shouldPaintWholePage |
2348 || (graphicsLayer != m_graphicsLayer && graphicsLayer != m_squashingLaye
r && graphicsLayer != m_squashingLayer && graphicsLayer != m_scrollingContentsLa
yer)) | 2349 || (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashi
ngLayer.get() && graphicsLayer != m_squashingLayer.get() && graphicsLayer != m_s
crollingContentsLayer.get())) |
2349 return wholeLayerRect; | 2350 return wholeLayerRect; |
2350 | 2351 |
2351 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); | 2352 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); |
2352 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect
, expandedIntSize(graphicsLayer->size()))) | 2353 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect
, expandedIntSize(graphicsLayer->size()))) |
2353 return newInterestRect; | 2354 return newInterestRect; |
2354 return previousInterestRect; | 2355 return previousInterestRect; |
2355 } | 2356 } |
2356 | 2357 |
2357 LayoutSize CompositedLayerMapping::subpixelAccumulation() const | 2358 LayoutSize CompositedLayerMapping::subpixelAccumulation() const |
2358 { | 2359 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; | 2398 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; |
2398 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) | 2399 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) |
2399 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; | 2400 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; |
2400 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) | 2401 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) |
2401 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; | 2402 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; |
2402 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) | 2403 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) |
2403 paintLayerFlags |= PaintLayerPaintingOverflowContents; | 2404 paintLayerFlags |= PaintLayerPaintingOverflowContents; |
2404 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) | 2405 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) |
2405 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; | 2406 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; |
2406 | 2407 |
2407 if (graphicsLayer == m_backgroundLayer) | 2408 if (graphicsLayer == m_backgroundLayer.get()) |
2408 paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPai
ntingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroun
dPhase to walk child layers. | 2409 paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPai
ntingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroun
dPhase to walk child layers. |
2409 else if (compositor()->fixedRootBackgroundLayer()) | 2410 else if (compositor()->fixedRootBackgroundLayer()) |
2410 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; | 2411 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; |
2411 | 2412 |
2412 if (graphicsLayer == m_graphicsLayer.get() | 2413 if (graphicsLayer == m_graphicsLayer.get() |
2413 || graphicsLayer == m_foregroundLayer.get() | 2414 || graphicsLayer == m_foregroundLayer.get() |
2414 || graphicsLayer == m_backgroundLayer.get() | 2415 || graphicsLayer == m_backgroundLayer.get() |
2415 || graphicsLayer == m_maskLayer.get() | 2416 || graphicsLayer == m_maskLayer.get() |
2416 || graphicsLayer == m_childClippingMaskLayer.get() | 2417 || graphicsLayer == m_childClippingMaskLayer.get() |
2417 || graphicsLayer == m_scrollingContentsLayer.get()) { | 2418 || graphicsLayer == m_scrollingContentsLayer.get()) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2641 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2641 name = "Scrolling Contents Layer"; | 2642 name = "Scrolling Contents Layer"; |
2642 } else { | 2643 } else { |
2643 ASSERT_NOT_REACHED(); | 2644 ASSERT_NOT_REACHED(); |
2644 } | 2645 } |
2645 | 2646 |
2646 return name; | 2647 return name; |
2647 } | 2648 } |
2648 | 2649 |
2649 } // namespace blink | 2650 } // namespace blink |
OLD | NEW |