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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 static IntRect backgroundRect(const LayoutObject& layoutObject) { | 104 static IntRect backgroundRect(const LayoutObject& layoutObject) { |
105 if (!layoutObject.isBox()) | 105 if (!layoutObject.isBox()) |
106 return IntRect(); | 106 return IntRect(); |
107 | 107 |
108 LayoutRect rect; | 108 LayoutRect rect; |
109 const LayoutBox& box = toLayoutBox(layoutObject); | 109 const LayoutBox& box = toLayoutBox(layoutObject); |
110 return pixelSnappedIntRect(box.backgroundRect(BackgroundClipRect)); | 110 return pixelSnappedIntRect(box.backgroundRect(BackgroundClipRect)); |
111 } | 111 } |
112 | 112 |
113 static inline bool isAcceleratedCanvas(const LayoutObject& layoutObject) { | 113 static inline bool isCompositedCanvas(const LayoutObject& layoutObject) { |
114 if (layoutObject.isCanvas()) { | 114 if (layoutObject.isCanvas()) { |
115 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); | 115 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); |
116 if (CanvasRenderingContext* context = canvas->renderingContext()) | 116 if (CanvasRenderingContext* context = canvas->renderingContext()) |
117 return context->isAccelerated(); | 117 return context->isComposited(); |
118 } | 118 } |
119 return false; | 119 return false; |
120 } | 120 } |
121 | 121 |
122 static inline bool isCanvasControlledByOffscreen( | 122 static inline bool isCanvasControlledByOffscreen( |
123 const LayoutObject& layoutObject) { | 123 const LayoutObject& layoutObject) { |
124 if (layoutObject.isCanvas()) { | 124 if (layoutObject.isCanvas()) { |
125 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); | 125 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); |
126 if (canvas->surfaceLayerBridge()) | 126 if (canvas->surfaceLayerBridge()) |
127 return true; | 127 return true; |
(...skipping 23 matching lines...) Expand all Loading... |
151 static WebLayer* platformLayerForPlugin(LayoutObject& layoutObject) { | 151 static WebLayer* platformLayerForPlugin(LayoutObject& layoutObject) { |
152 if (!layoutObject.isEmbeddedObject()) | 152 if (!layoutObject.isEmbeddedObject()) |
153 return nullptr; | 153 return nullptr; |
154 FrameViewBase* frameViewBase = toLayoutEmbeddedObject(layoutObject).widget(); | 154 FrameViewBase* frameViewBase = toLayoutEmbeddedObject(layoutObject).widget(); |
155 if (!frameViewBase || !frameViewBase->isPluginView()) | 155 if (!frameViewBase || !frameViewBase->isPluginView()) |
156 return nullptr; | 156 return nullptr; |
157 return toPluginView(frameViewBase)->platformLayer(); | 157 return toPluginView(frameViewBase)->platformLayer(); |
158 } | 158 } |
159 | 159 |
160 static inline bool isAcceleratedContents(LayoutObject& layoutObject) { | 160 static inline bool isAcceleratedContents(LayoutObject& layoutObject) { |
161 return isAcceleratedCanvas(layoutObject) || | 161 return isCompositedCanvas(layoutObject) || |
162 (layoutObject.isEmbeddedObject() && | 162 (layoutObject.isEmbeddedObject() && |
163 toLayoutEmbeddedObject(layoutObject) | 163 toLayoutEmbeddedObject(layoutObject) |
164 .requiresAcceleratedCompositing()) || | 164 .requiresAcceleratedCompositing()) || |
165 layoutObject.isVideo(); | 165 layoutObject.isVideo(); |
166 } | 166 } |
167 | 167 |
168 // Get the scrolling coordinator in a way that works inside | 168 // Get the scrolling coordinator in a way that works inside |
169 // CompositedLayerMapping's destructor. | 169 // CompositedLayerMapping's destructor. |
170 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { | 170 static ScrollingCoordinator* scrollingCoordinatorFromLayer(PaintLayer& layer) { |
171 Page* page = layer.layoutObject().frame()->page(); | 171 Page* page = layer.layoutObject().frame()->page(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 paintLocation & BackgroundPaintInGraphicsLayer; | 395 paintLocation & BackgroundPaintInGraphicsLayer; |
396 if (shouldPaintOntoGraphicsLayer != !!m_backgroundPaintsOntoGraphicsLayer) { | 396 if (shouldPaintOntoGraphicsLayer != !!m_backgroundPaintsOntoGraphicsLayer) { |
397 m_backgroundPaintsOntoGraphicsLayer = shouldPaintOntoGraphicsLayer; | 397 m_backgroundPaintsOntoGraphicsLayer = shouldPaintOntoGraphicsLayer; |
398 // The graphics layer needs to be updated for changed | 398 // The graphics layer needs to be updated for changed |
399 // m_backgroundPaintsOntoGraphicsLayer. | 399 // m_backgroundPaintsOntoGraphicsLayer. |
400 m_graphicsLayer->setNeedsDisplay(); | 400 m_graphicsLayer->setNeedsDisplay(); |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 void CompositedLayerMapping::updateContentsOpaque() { | 404 void CompositedLayerMapping::updateContentsOpaque() { |
405 if (isAcceleratedCanvas(layoutObject())) { | 405 if (isCompositedCanvas(layoutObject())) { |
406 CanvasRenderingContext* context = | 406 CanvasRenderingContext* context = |
407 toHTMLCanvasElement(layoutObject().node())->renderingContext(); | 407 toHTMLCanvasElement(layoutObject().node())->renderingContext(); |
408 WebLayer* layer = context ? context->platformLayer() : nullptr; | 408 WebLayer* layer = context ? context->platformLayer() : nullptr; |
409 // Determine whether the external texture layer covers the whole graphics | 409 // Determine whether the external texture layer covers the whole graphics |
410 // layer. This may not be the case if there are box decorations or | 410 // layer. This may not be the case if there are box decorations or |
411 // shadows. | 411 // shadows. |
412 if (layer && | 412 if (layer && |
413 layer->bounds() == m_graphicsLayer->platformLayer()->bounds()) { | 413 layer->bounds() == m_graphicsLayer->platformLayer()->bounds()) { |
414 // Determine whether the rendering context's external texture layer is | 414 // Determine whether the rendering context's external texture layer is |
415 // opaque. | 415 // opaque. |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 m_graphicsLayer->setContentsToPlatformLayer(layer); | 760 m_graphicsLayer->setContentsToPlatformLayer(layer); |
761 } | 761 } |
762 } else if (layoutObject.isVideo()) { | 762 } else if (layoutObject.isVideo()) { |
763 HTMLMediaElement* mediaElement = toHTMLMediaElement(layoutObject.node()); | 763 HTMLMediaElement* mediaElement = toHTMLMediaElement(layoutObject.node()); |
764 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer()); | 764 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer()); |
765 } else if (isCanvasControlledByOffscreen(layoutObject)) { | 765 } else if (isCanvasControlledByOffscreen(layoutObject)) { |
766 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); | 766 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); |
767 m_graphicsLayer->setContentsToPlatformLayer( | 767 m_graphicsLayer->setContentsToPlatformLayer( |
768 canvas->surfaceLayerBridge()->getWebLayer()); | 768 canvas->surfaceLayerBridge()->getWebLayer()); |
769 layerConfigChanged = true; | 769 layerConfigChanged = true; |
770 } else if (isAcceleratedCanvas(layoutObject)) { | 770 } else if (isCompositedCanvas(layoutObject)) { |
771 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); | 771 HTMLCanvasElement* canvas = toHTMLCanvasElement(layoutObject.node()); |
772 if (CanvasRenderingContext* context = canvas->renderingContext()) | 772 if (CanvasRenderingContext* context = canvas->renderingContext()) |
773 m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer()); | 773 m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer()); |
774 layerConfigChanged = true; | 774 layerConfigChanged = true; |
775 } | 775 } |
776 if (layoutObject.isLayoutPart()) { | 776 if (layoutObject.isLayoutPart()) { |
777 if (PaintLayerCompositor::attachFrameContentLayersToIframeLayer( | 777 if (PaintLayerCompositor::attachFrameContentLayersToIframeLayer( |
778 toLayoutPart(layoutObject))) | 778 toLayoutPart(layoutObject))) |
779 layerConfigChanged = true; | 779 layerConfigChanged = true; |
780 } | 780 } |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 // contents need to paint. | 1693 // contents need to paint. |
1694 m_scrollingContentsAreEmpty = | 1694 m_scrollingContentsAreEmpty = |
1695 !m_owningLayer.hasVisibleContent() || | 1695 !m_owningLayer.hasVisibleContent() || |
1696 !(layoutObject().styleRef().hasBackground() || | 1696 !(layoutObject().styleRef().hasBackground() || |
1697 layoutObject().hasBackdropFilter() || paintsChildren()); | 1697 layoutObject().hasBackdropFilter() || paintsChildren()); |
1698 m_scrollingContentsLayer->setDrawsContent(!m_scrollingContentsAreEmpty); | 1698 m_scrollingContentsLayer->setDrawsContent(!m_scrollingContentsAreEmpty); |
1699 } | 1699 } |
1700 | 1700 |
1701 m_drawsBackgroundOntoContentLayer = false; | 1701 m_drawsBackgroundOntoContentLayer = false; |
1702 | 1702 |
1703 if (hasPaintedContent && isAcceleratedCanvas(layoutObject())) { | 1703 if (hasPaintedContent && isCompositedCanvas(layoutObject())) { |
1704 CanvasRenderingContext* context = | 1704 CanvasRenderingContext* context = |
1705 toHTMLCanvasElement(layoutObject().node())->renderingContext(); | 1705 toHTMLCanvasElement(layoutObject().node())->renderingContext(); |
1706 // Content layer may be null if context is lost. | 1706 // Content layer may be null if context is lost. |
1707 if (WebLayer* contentLayer = context->platformLayer()) { | 1707 if (WebLayer* contentLayer = context->platformLayer()) { |
1708 Color bgColor(Color::transparent); | 1708 Color bgColor(Color::transparent); |
1709 if (contentLayerSupportsDirectBackgroundComposition(layoutObject())) { | 1709 if (contentLayerSupportsDirectBackgroundComposition(layoutObject())) { |
1710 bgColor = layoutObjectBackgroundColor(); | 1710 bgColor = layoutObjectBackgroundColor(); |
1711 hasPaintedContent = false; | 1711 hasPaintedContent = false; |
1712 m_drawsBackgroundOntoContentLayer = true; | 1712 m_drawsBackgroundOntoContentLayer = true; |
1713 } | 1713 } |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2609 return false; | 2609 return false; |
2610 } | 2610 } |
2611 | 2611 |
2612 void CompositedLayerMapping::contentChanged(ContentChangeType changeType) { | 2612 void CompositedLayerMapping::contentChanged(ContentChangeType changeType) { |
2613 if ((changeType == ImageChanged) && layoutObject().isImage() && | 2613 if ((changeType == ImageChanged) && layoutObject().isImage() && |
2614 isDirectlyCompositedImage()) { | 2614 isDirectlyCompositedImage()) { |
2615 updateImageContents(); | 2615 updateImageContents(); |
2616 return; | 2616 return; |
2617 } | 2617 } |
2618 | 2618 |
2619 if (changeType == CanvasChanged && isAcceleratedCanvas(layoutObject())) { | 2619 if (changeType == CanvasChanged && isCompositedCanvas(layoutObject())) { |
2620 m_graphicsLayer->setContentsNeedsDisplay(); | 2620 m_graphicsLayer->setContentsNeedsDisplay(); |
2621 return; | 2621 return; |
2622 } | 2622 } |
2623 } | 2623 } |
2624 | 2624 |
2625 void CompositedLayerMapping::updateImageContents() { | 2625 void CompositedLayerMapping::updateImageContents() { |
2626 DCHECK(layoutObject().isImage()); | 2626 DCHECK(layoutObject().isImage()); |
2627 LayoutImage& imageLayoutObject = toLayoutImage(layoutObject()); | 2627 LayoutImage& imageLayoutObject = toLayoutImage(layoutObject()); |
2628 | 2628 |
2629 ImageResourceContent* cachedImage = imageLayoutObject.cachedImage(); | 2629 ImageResourceContent* cachedImage = imageLayoutObject.cachedImage(); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3487 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { | 3487 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { |
3488 name = "Decoration Layer"; | 3488 name = "Decoration Layer"; |
3489 } else { | 3489 } else { |
3490 ASSERT_NOT_REACHED(); | 3490 ASSERT_NOT_REACHED(); |
3491 } | 3491 } |
3492 | 3492 |
3493 return name; | 3493 return name; |
3494 } | 3494 } |
3495 | 3495 |
3496 } // namespace blink | 3496 } // namespace blink |
OLD | NEW |