simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1 | /* |
darin@apple.com | 4bca5c9 | 2011-07-01 23:13:28 +0000 | [diff] [blame] | 2 | * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | |
jamesr@google.com | bab9191 | 2010-09-03 18:38:37 +0000 | [diff] [blame] | 28 | #include "RenderLayerBacking.h" |
| 29 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 30 | #include "AnimationController.h" |
jamesr@google.com | d8c6157 | 2010-08-06 21:49:20 +0000 | [diff] [blame] | 31 | #include "CanvasRenderingContext.h" |
simon.fraser@apple.com | 99cac4b | 2009-02-04 23:56:55 +0000 | [diff] [blame] | 32 | #include "CSSPropertyNames.h" |
abarth@webkit.org | 401a379 | 2013-03-03 10:12:59 +0000 | [diff] [blame] | 33 | #include "CachedImage.h" |
darin@apple.com | 4bca5c9 | 2011-07-01 23:13:28 +0000 | [diff] [blame] | 34 | #include "Chrome.h" |
commit-queue@webkit.org | 9e58b3d | 2014-09-04 18:43:39 +0000 | [diff] [blame] | 35 | #include "FilterEffectRenderer.h" |
simon.fraser@apple.com | a43acab3 | 2011-11-02 21:02:07 +0000 | [diff] [blame] | 36 | #include "FontCache.h" |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 37 | #include "FrameView.h" |
| 38 | #include "GraphicsContext.h" |
| 39 | #include "GraphicsLayer.h" |
cmarrin@apple.com | 4e7728f | 2009-08-27 23:55:44 +0000 | [diff] [blame] | 40 | #include "HTMLCanvasElement.h" |
cmarrin@apple.com | 10c77cf | 2010-05-05 01:50:03 +0000 | [diff] [blame] | 41 | #include "HTMLIFrameElement.h" |
simon.fraser@apple.com | 6217889 | 2010-02-16 21:46:06 +0000 | [diff] [blame] | 42 | #include "HTMLMediaElement.h" |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 43 | #include "HTMLNames.h" |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 44 | #include "HTMLPlugInElement.h" |
podivilov@chromium.org | b6cd025 | 2010-10-07 09:43:02 +0000 | [diff] [blame] | 45 | #include "InspectorInstrumentation.h" |
dbates@webkit.org | 57aa8de | 2009-11-30 01:32:38 +0000 | [diff] [blame] | 46 | #include "KeyframeList.h" |
darin@apple.com | 0e83ab1 | 2013-09-28 17:19:04 +0000 | [diff] [blame] | 47 | #include "MainFrame.h" |
andersca@apple.com | f0fc23f | 2010-07-19 00:09:01 +0000 | [diff] [blame] | 48 | #include "PluginViewBase.h" |
antti@apple.com | 40d6724 | 2013-04-10 11:34:53 +0000 | [diff] [blame] | 49 | #include "ProgressTracker.h" |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 50 | #include "RenderFlowThread.h" |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 51 | #include "RenderHTMLCanvas.h" |
simon.fraser@apple.com | be8126e | 2010-05-11 05:08:18 +0000 | [diff] [blame] | 52 | #include "RenderIFrame.h" |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 53 | #include "RenderImage.h" |
| 54 | #include "RenderLayerCompositor.h" |
simon.fraser@apple.com | d6aff5e | 2010-01-12 00:15:06 +0000 | [diff] [blame] | 55 | #include "RenderEmbeddedObject.h" |
cdumez@apple.com | 8bb794b | 2014-10-21 16:46:13 +0000 | [diff] [blame] | 56 | #include "RenderMedia.h" |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 57 | #include "RenderNamedFlowFragment.h" |
| 58 | #include "RenderRegion.h" |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 59 | #include "RenderVideo.h" |
| 60 | #include "RenderView.h" |
commit-queue@webkit.org | b07824e | 2012-06-14 17:45:05 +0000 | [diff] [blame] | 61 | #include "ScrollingCoordinator.h" |
timothy_horton@apple.com | abf4b25 | 2012-08-09 07:26:35 +0000 | [diff] [blame] | 62 | #include "Settings.h" |
alexis.menard@openbossa.org | e6db2f6 | 2012-04-25 15:49:08 +0000 | [diff] [blame] | 63 | #include "StyleResolver.h" |
andersca@apple.com | 1533e93 | 2012-03-21 19:24:24 +0000 | [diff] [blame] | 64 | #include "TiledBacking.h" |
abarth@webkit.org | a40070b | 2012-08-30 08:20:03 +0000 | [diff] [blame] | 65 | #include <wtf/text/StringBuilder.h> |
timothy_horton@apple.com | 7ce2a73 | 2012-05-11 21:24:09 +0000 | [diff] [blame] | 66 | |
ddkilzer@apple.com | 7313f64 | 2011-02-15 23:59:07 +0000 | [diff] [blame] | 67 | #if ENABLE(WEBGL) || ENABLE(ACCELERATED_2D_CANVAS) |
| 68 | #include "GraphicsContext3D.h" |
| 69 | #endif |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 70 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 71 | namespace WebCore { |
| 72 | |
darin@apple.com | 5554b3a | 2009-08-17 17:30:27 +0000 | [diff] [blame] | 73 | using namespace HTMLNames; |
| 74 | |
simon.fraser@apple.com | efaa412 | 2013-12-20 03:48:10 +0000 | [diff] [blame] | 75 | CanvasCompositingStrategy canvasCompositingStrategy(const RenderObject& renderer) |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 76 | { |
simon.fraser@apple.com | efaa412 | 2013-12-20 03:48:10 +0000 | [diff] [blame] | 77 | ASSERT(renderer.isCanvas()); |
| 78 | |
cdumez@apple.com | 72754ba | 2014-09-23 22:03:15 +0000 | [diff] [blame] | 79 | const HTMLCanvasElement* canvas = downcast<HTMLCanvasElement>(renderer.node()); |
simon.fraser@apple.com | efaa412 | 2013-12-20 03:48:10 +0000 | [diff] [blame] | 80 | CanvasRenderingContext* context = canvas->renderingContext(); |
| 81 | if (!context || !context->isAccelerated()) |
| 82 | return UnacceleratedCanvas; |
| 83 | |
| 84 | if (context->is3d()) |
| 85 | return CanvasAsLayerContents; |
| 86 | |
| 87 | #if ENABLE(ACCELERATED_2D_CANVAS) |
| 88 | return CanvasAsLayerContents; |
andersca@apple.com | d576cbe | 2010-01-18 22:04:20 +0000 | [diff] [blame] | 89 | #else |
simon.fraser@apple.com | efaa412 | 2013-12-20 03:48:10 +0000 | [diff] [blame] | 90 | return CanvasPaintedToLayer; // On Mac and iOS we paint accelerated canvases into their layers. |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 91 | #endif |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 92 | } |
simon.fraser@apple.com | 699dc0b | 2009-04-07 17:45:00 +0000 | [diff] [blame] | 93 | |
simon.fraser@apple.com | e6ad1f6 | 2013-01-15 23:46:18 +0000 | [diff] [blame] | 94 | // Get the scrolling coordinator in a way that works inside RenderLayerBacking's destructor. |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 95 | static ScrollingCoordinator* scrollingCoordinatorFromLayer(RenderLayer& layer) |
simon.fraser@apple.com | e6ad1f6 | 2013-01-15 23:46:18 +0000 | [diff] [blame] | 96 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 97 | Page* page = layer.renderer().frame().page(); |
simon.fraser@apple.com | e6ad1f6 | 2013-01-15 23:46:18 +0000 | [diff] [blame] | 98 | if (!page) |
| 99 | return 0; |
| 100 | |
| 101 | return page->scrollingCoordinator(); |
| 102 | } |
| 103 | |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 104 | bool RenderLayerBacking::m_creatingPrimaryGraphicsLayer = false; |
| 105 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 106 | RenderLayerBacking::RenderLayerBacking(RenderLayer& layer) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 107 | : m_owningLayer(layer) |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 108 | , m_viewportConstrainedNodeID(0) |
| 109 | , m_scrollingNodeID(0) |
simon.fraser@apple.com | c6e466c | 2009-09-19 03:44:10 +0000 | [diff] [blame] | 110 | , m_artificiallyInflatedBounds(false) |
simon.fraser@apple.com | 5429b7f | 2011-12-13 01:05:32 +0000 | [diff] [blame] | 111 | , m_isMainFrameRenderViewLayer(false) |
| 112 | , m_usingTiledCacheLayer(false) |
simon.fraser@apple.com | b7cec68 | 2012-04-16 18:32:13 +0000 | [diff] [blame] | 113 | , m_requiresOwnBackingStore(true) |
cmarrin@apple.com | 3106ca8 | 2011-12-17 17:46:57 +0000 | [diff] [blame] | 114 | , m_canCompositeFilters(false) |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 115 | , m_backgroundLayerPaintsFixedRootBackground(false) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 116 | { |
timothy_horton@apple.com | 017ef58 | 2013-09-26 17:34:33 +0000 | [diff] [blame] | 117 | Page* page = renderer().frame().page(); |
| 118 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 119 | if (layer.isRootLayer() && page) { |
zalan@apple.com | 655863c | 2014-05-21 16:06:55 +0000 | [diff] [blame] | 120 | m_isMainFrameRenderViewLayer = renderer().frame().isMainFrame(); |
timothy_horton@apple.com | 017ef58 | 2013-09-26 17:34:33 +0000 | [diff] [blame] | 121 | m_usingTiledCacheLayer = page->chrome().client().shouldUseTiledBackingForFrameView(renderer().frame().view()); |
simon.fraser@apple.com | 5429b7f | 2011-12-13 01:05:32 +0000 | [diff] [blame] | 122 | } |
| 123 | |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 124 | createPrimaryGraphicsLayer(); |
andersca@apple.com | 1533e93 | 2012-03-21 19:24:24 +0000 | [diff] [blame] | 125 | |
timothy_horton@apple.com | 017ef58 | 2013-09-26 17:34:33 +0000 | [diff] [blame] | 126 | if (m_usingTiledCacheLayer && page) { |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 127 | TiledBacking* tiledBacking = this->tiledBacking(); |
timothy_horton@apple.com | 11ed344 | 2013-01-07 23:17:36 +0000 | [diff] [blame] | 128 | |
timothy_horton@apple.com | 017ef58 | 2013-09-26 17:34:33 +0000 | [diff] [blame] | 129 | tiledBacking->setIsInWindow(page->isInWindow()); |
timothy_horton@apple.com | 11ed344 | 2013-01-07 23:17:36 +0000 | [diff] [blame] | 130 | |
antti@apple.com | 60abb11 | 2014-04-08 20:50:47 +0000 | [diff] [blame] | 131 | if (m_isMainFrameRenderViewLayer) |
timothy_horton@apple.com | 017ef58 | 2013-09-26 17:34:33 +0000 | [diff] [blame] | 132 | tiledBacking->setUnparentsOffscreenTiles(true); |
| 133 | |
| 134 | tiledBacking->setScrollingPerformanceLoggingEnabled(page->settings().scrollingPerformanceLoggingEnabled()); |
| 135 | adjustTiledBackingCoverage(); |
andersca@apple.com | 1533e93 | 2012-03-21 19:24:24 +0000 | [diff] [blame] | 136 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | RenderLayerBacking::~RenderLayerBacking() |
| 140 | { |
zalan@apple.com | c3d7218 | 2013-09-12 14:03:21 +0000 | [diff] [blame] | 141 | updateAncestorClippingLayer(false); |
| 142 | updateDescendantClippingLayer(false); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 143 | updateOverflowControlsLayers(false, false, false); |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 144 | updateForegroundLayer(false); |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 145 | updateBackgroundLayer(false); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 146 | updateMaskLayer(false); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 147 | updateScrollingLayers(false); |
bdakin@apple.com | 0643c9f | 2012-10-09 18:47:49 +0000 | [diff] [blame] | 148 | detachFromScrollingCoordinator(); |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 149 | destroyGraphicsLayers(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 150 | } |
| 151 | |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 152 | void RenderLayerBacking::willDestroyLayer(const GraphicsLayer* layer) |
| 153 | { |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 154 | if (layer && layer->usingTiledBacking()) |
| 155 | compositor().layerTiledBackingUsageChanged(layer, false); |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 156 | } |
| 157 | |
andersca@apple.com | cc3b2dc | 2013-09-27 18:38:51 +0000 | [diff] [blame] | 158 | std::unique_ptr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String& name) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 159 | { |
andersca@apple.com | d857c85 | 2012-10-03 17:47:36 +0000 | [diff] [blame] | 160 | GraphicsLayerFactory* graphicsLayerFactory = 0; |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 161 | if (Page* page = renderer().frame().page()) |
akling@apple.com | fedaa63 | 2013-08-19 10:56:27 +0000 | [diff] [blame] | 162 | graphicsLayerFactory = page->chrome().client().graphicsLayerFactory(); |
andersca@apple.com | d857c85 | 2012-10-03 17:47:36 +0000 | [diff] [blame] | 163 | |
commit-queue@webkit.org | 65a639f | 2014-05-07 11:44:00 +0000 | [diff] [blame] | 164 | std::unique_ptr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFactory, *this); |
andersca@apple.com | d857c85 | 2012-10-03 17:47:36 +0000 | [diff] [blame] | 165 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 166 | #ifndef NDEBUG |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 167 | graphicsLayer->setName(name); |
simon.fraser@apple.com | b8fae94 | 2011-07-13 22:56:06 +0000 | [diff] [blame] | 168 | #else |
| 169 | UNUSED_PARAM(name); |
darin@apple.com | 4bca5c9 | 2011-07-01 23:13:28 +0000 | [diff] [blame] | 170 | #endif |
mitz@apple.com | 28c9d4a | 2014-02-08 22:26:50 +0000 | [diff] [blame] | 171 | #if PLATFORM(COCOA) && USE(CA) |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 172 | graphicsLayer->setAcceleratesDrawing(compositor().acceleratedDrawingEnabled()); |
simon.fraser@apple.com | 5cce05c | 2012-03-23 21:40:21 +0000 | [diff] [blame] | 173 | #endif |
| 174 | |
andersca@apple.com | cc3b2dc | 2013-09-27 18:38:51 +0000 | [diff] [blame] | 175 | return graphicsLayer; |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 176 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 177 | |
simon.fraser@apple.com | e5c278d | 2013-03-07 23:54:13 +0000 | [diff] [blame] | 178 | bool RenderLayerBacking::shouldUseTiledBacking(const GraphicsLayer*) const |
simon.fraser@apple.com | 5429b7f | 2011-12-13 01:05:32 +0000 | [diff] [blame] | 179 | { |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 180 | return m_usingTiledCacheLayer && m_creatingPrimaryGraphicsLayer; |
simon.fraser@apple.com | 5429b7f | 2011-12-13 01:05:32 +0000 | [diff] [blame] | 181 | } |
| 182 | |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 183 | void RenderLayerBacking::tiledBackingUsageChanged(const GraphicsLayer* layer, bool usingTiledBacking) |
| 184 | { |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 185 | compositor().layerTiledBackingUsageChanged(layer, usingTiledBacking); |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 186 | } |
| 187 | |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 188 | TiledBacking* RenderLayerBacking::tiledBacking() const |
| 189 | { |
| 190 | return m_graphicsLayer->tiledBacking(); |
| 191 | } |
| 192 | |
antti@apple.com | 4d3b217 | 2013-04-15 13:00:50 +0000 | [diff] [blame] | 193 | static TiledBacking::TileCoverage computeTileCoverage(RenderLayerBacking* backing) |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 194 | { |
antti@apple.com | 40d6724 | 2013-04-10 11:34:53 +0000 | [diff] [blame] | 195 | // FIXME: When we use TiledBacking for overflow, this should look at RenderView scrollability. |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 196 | FrameView& frameView = backing->owningLayer().renderer().view().frameView(); |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 197 | |
| 198 | TiledBacking::TileCoverage tileCoverage = TiledBacking::CoverageForVisibleArea; |
akling@apple.com | e4b42ff | 2013-08-24 22:50:46 +0000 | [diff] [blame] | 199 | bool useMinimalTilesDuringLiveResize = frameView.inLiveResize(); |
antti@apple.com | 091c8a9 | 2014-01-23 22:03:27 +0000 | [diff] [blame] | 200 | if (frameView.speculativeTilingEnabled() && !useMinimalTilesDuringLiveResize) { |
timothy_horton@apple.com | 50af46e | 2014-01-09 01:38:13 +0000 | [diff] [blame] | 201 | bool clipsToExposedRect = !frameView.exposedRect().isInfinite(); |
akling@apple.com | e4b42ff | 2013-08-24 22:50:46 +0000 | [diff] [blame] | 202 | if (frameView.horizontalScrollbarMode() != ScrollbarAlwaysOff || clipsToExposedRect) |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 203 | tileCoverage |= TiledBacking::CoverageForHorizontalScrolling; |
| 204 | |
akling@apple.com | e4b42ff | 2013-08-24 22:50:46 +0000 | [diff] [blame] | 205 | if (frameView.verticalScrollbarMode() != ScrollbarAlwaysOff || clipsToExposedRect) |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 206 | tileCoverage |= TiledBacking::CoverageForVerticalScrolling; |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 207 | } |
antti@apple.com | 40d6724 | 2013-04-10 11:34:53 +0000 | [diff] [blame] | 208 | return tileCoverage; |
| 209 | } |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 210 | |
antti@apple.com | 40d6724 | 2013-04-10 11:34:53 +0000 | [diff] [blame] | 211 | void RenderLayerBacking::adjustTiledBackingCoverage() |
| 212 | { |
| 213 | if (!m_usingTiledCacheLayer) |
| 214 | return; |
| 215 | |
| 216 | TiledBacking::TileCoverage tileCoverage = computeTileCoverage(this); |
simon.fraser@apple.com | 6141c31 | 2012-10-25 18:08:21 +0000 | [diff] [blame] | 217 | tiledBacking()->setTileCoverage(tileCoverage); |
| 218 | } |
| 219 | |
weinig@apple.com | 55b0ff6 | 2014-05-06 16:44:41 +0000 | [diff] [blame] | 220 | void RenderLayerBacking::setTiledBackingHasMargins(bool hasExtendedBackgroundOnLeftAndRight, bool hasExtendedBackgroundOnTopAndBottom) |
bdakin@apple.com | d99f20e | 2014-01-18 00:05:59 +0000 | [diff] [blame] | 221 | { |
| 222 | if (!m_usingTiledCacheLayer) |
| 223 | return; |
| 224 | |
weinig@apple.com | 55b0ff6 | 2014-05-06 16:44:41 +0000 | [diff] [blame] | 225 | int marginLeftAndRightSize = hasExtendedBackgroundOnLeftAndRight ? defaultTileWidth : 0; |
| 226 | int marginTopAndBottomSize = hasExtendedBackgroundOnTopAndBottom ? defaultTileHeight : 0; |
bdakin@apple.com | 8a00da9 | 2014-01-31 21:06:38 +0000 | [diff] [blame] | 227 | tiledBacking()->setTileMargins(marginTopAndBottomSize, marginTopAndBottomSize, marginLeftAndRightSize, marginLeftAndRightSize); |
bdakin@apple.com | d99f20e | 2014-01-18 00:05:59 +0000 | [diff] [blame] | 228 | } |
| 229 | |
simon.fraser@apple.com | e2605d5 | 2012-11-05 21:07:33 +0000 | [diff] [blame] | 230 | void RenderLayerBacking::updateDebugIndicators(bool showBorder, bool showRepaintCounter) |
| 231 | { |
| 232 | m_graphicsLayer->setShowDebugBorder(showBorder); |
| 233 | m_graphicsLayer->setShowRepaintCounter(showRepaintCounter); |
| 234 | |
| 235 | if (m_ancestorClippingLayer) |
| 236 | m_ancestorClippingLayer->setShowDebugBorder(showBorder); |
| 237 | |
| 238 | if (m_foregroundLayer) { |
| 239 | m_foregroundLayer->setShowDebugBorder(showBorder); |
| 240 | m_foregroundLayer->setShowRepaintCounter(showRepaintCounter); |
| 241 | } |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 242 | |
| 243 | if (m_contentsContainmentLayer) |
| 244 | m_contentsContainmentLayer->setShowDebugBorder(showBorder); |
| 245 | |
| 246 | if (m_backgroundLayer) { |
| 247 | m_backgroundLayer->setShowDebugBorder(showBorder); |
| 248 | m_backgroundLayer->setShowRepaintCounter(showRepaintCounter); |
| 249 | } |
simon.fraser@apple.com | e2605d5 | 2012-11-05 21:07:33 +0000 | [diff] [blame] | 250 | |
| 251 | if (m_maskLayer) { |
| 252 | m_maskLayer->setShowDebugBorder(showBorder); |
| 253 | m_maskLayer->setShowRepaintCounter(showRepaintCounter); |
| 254 | } |
| 255 | |
simon.fraser@apple.com | 8d8c4c1 | 2012-11-15 23:46:07 +0000 | [diff] [blame] | 256 | if (m_layerForHorizontalScrollbar) |
| 257 | m_layerForHorizontalScrollbar->setShowDebugBorder(showBorder); |
| 258 | |
| 259 | if (m_layerForVerticalScrollbar) |
| 260 | m_layerForVerticalScrollbar->setShowDebugBorder(showBorder); |
| 261 | |
| 262 | if (m_layerForScrollCorner) |
| 263 | m_layerForScrollCorner->setShowDebugBorder(showBorder); |
| 264 | |
simon.fraser@apple.com | e2605d5 | 2012-11-05 21:07:33 +0000 | [diff] [blame] | 265 | if (m_scrollingLayer) |
| 266 | m_scrollingLayer->setShowDebugBorder(showBorder); |
| 267 | |
simon.fraser@apple.com | 8d8c4c1 | 2012-11-15 23:46:07 +0000 | [diff] [blame] | 268 | if (m_scrollingContentsLayer) { |
simon.fraser@apple.com | e2605d5 | 2012-11-05 21:07:33 +0000 | [diff] [blame] | 269 | m_scrollingContentsLayer->setShowDebugBorder(showBorder); |
simon.fraser@apple.com | 8d8c4c1 | 2012-11-15 23:46:07 +0000 | [diff] [blame] | 270 | m_scrollingContentsLayer->setShowRepaintCounter(showRepaintCounter); |
| 271 | } |
simon.fraser@apple.com | e2605d5 | 2012-11-05 21:07:33 +0000 | [diff] [blame] | 272 | } |
| 273 | |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 274 | void RenderLayerBacking::createPrimaryGraphicsLayer() |
| 275 | { |
| 276 | String layerName; |
| 277 | #ifndef NDEBUG |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 278 | layerName = m_owningLayer.name(); |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 279 | #endif |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 280 | |
| 281 | // The call to createGraphicsLayer ends calling back into here as |
simon.fraser@apple.com | e5c278d | 2013-03-07 23:54:13 +0000 | [diff] [blame] | 282 | // a GraphicsLayerClient to ask if it shouldUseTiledBacking(). We only want |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 283 | // the tile cache on our main layer. This is pretty ugly, but saves us from |
| 284 | // exposing the API to all clients. |
| 285 | |
| 286 | m_creatingPrimaryGraphicsLayer = true; |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 287 | m_graphicsLayer = createGraphicsLayer(layerName); |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 288 | m_creatingPrimaryGraphicsLayer = false; |
| 289 | |
simon.fraser@apple.com | d3ca15b | 2014-03-27 03:53:31 +0000 | [diff] [blame] | 290 | if (m_usingTiledCacheLayer) { |
simon.fraser@apple.com | e5c278d | 2013-03-07 23:54:13 +0000 | [diff] [blame] | 291 | m_childContainmentLayer = createGraphicsLayer("TiledBacking Flattening Layer"); |
simon.fraser@apple.com | d3ca15b | 2014-03-27 03:53:31 +0000 | [diff] [blame] | 292 | m_graphicsLayer->addChild(m_childContainmentLayer.get()); |
| 293 | } |
simon.fraser@apple.com | 5429b7f | 2011-12-13 01:05:32 +0000 | [diff] [blame] | 294 | |
gyuyoung.kim@samsung.com | 8411ddd | 2014-08-27 07:56:09 +0000 | [diff] [blame] | 295 | #if !PLATFORM(IOS) |
andersca@apple.com | 00534a3 | 2011-12-16 23:26:31 +0000 | [diff] [blame] | 296 | if (m_isMainFrameRenderViewLayer) { |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 297 | // Page scale is applied above the RenderView on iOS. |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 298 | m_graphicsLayer->setContentsOpaque(true); |
simon.fraser@apple.com | 5429b7f | 2011-12-13 01:05:32 +0000 | [diff] [blame] | 299 | m_graphicsLayer->setAppliesPageScale(); |
andersca@apple.com | 00534a3 | 2011-12-16 23:26:31 +0000 | [diff] [blame] | 300 | } |
ryuan.choi@samsung.com | 973da22 | 2014-04-01 06:09:55 +0000 | [diff] [blame] | 301 | #endif |
simon.fraser@apple.com | 5cce05c | 2012-03-23 21:40:21 +0000 | [diff] [blame] | 302 | |
mitz@apple.com | 28c9d4a | 2014-02-08 22:26:50 +0000 | [diff] [blame] | 303 | #if PLATFORM(COCOA) && USE(CA) |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 304 | if (!compositor().acceleratedDrawingEnabled() && renderer().isCanvas()) { |
cdumez@apple.com | 72754ba | 2014-09-23 22:03:15 +0000 | [diff] [blame] | 305 | const HTMLCanvasElement* canvas = downcast<HTMLCanvasElement>(renderer().element()); |
simon.fraser@apple.com | 5cce05c | 2012-03-23 21:40:21 +0000 | [diff] [blame] | 306 | if (canvas->shouldAccelerate(canvas->size())) |
| 307 | m_graphicsLayer->setAcceleratesDrawing(true); |
| 308 | } |
| 309 | #endif |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 310 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 311 | updateOpacity(renderer().style()); |
| 312 | updateTransform(renderer().style()); |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 313 | updateFilters(renderer().style()); |
krit@webkit.org | 70a7a22 | 2012-08-21 00:35:27 +0000 | [diff] [blame] | 314 | #if ENABLE(CSS_COMPOSITING) |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 315 | updateBlendMode(renderer().style()); |
krit@webkit.org | 70a7a22 | 2012-08-21 00:35:27 +0000 | [diff] [blame] | 316 | #endif |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 317 | } |
| 318 | |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 319 | #if PLATFORM(IOS) |
| 320 | void RenderLayerBacking::layerWillBeDestroyed() |
| 321 | { |
| 322 | RenderObject& renderer = this->renderer(); |
cdumez@apple.com | 63c654d | 2014-10-09 16:45:32 +0000 | [diff] [blame] | 323 | if (is<RenderEmbeddedObject>(renderer) && downcast<RenderEmbeddedObject>(renderer).allowsAcceleratedCompositing()) { |
| 324 | PluginViewBase* pluginViewBase = downcast<PluginViewBase>(downcast<RenderWidget>(renderer).widget()); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 325 | if (pluginViewBase && m_graphicsLayer->contentsLayerForMedia()) |
| 326 | pluginViewBase->detachPluginLayer(); |
| 327 | } |
| 328 | } |
| 329 | #endif |
| 330 | |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 331 | void RenderLayerBacking::destroyGraphicsLayers() |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 332 | { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 333 | if (m_graphicsLayer) { |
| 334 | willDestroyLayer(m_graphicsLayer.get()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 335 | m_graphicsLayer->removeFromParent(); |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 336 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 337 | |
simon.fraser@apple.com | 632ced1 | 2013-01-15 23:17:01 +0000 | [diff] [blame] | 338 | m_ancestorClippingLayer = nullptr; |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 339 | m_contentsContainmentLayer = nullptr; |
abarth@webkit.org | 462d90a | 2011-04-27 21:25:22 +0000 | [diff] [blame] | 340 | m_graphicsLayer = nullptr; |
| 341 | m_foregroundLayer = nullptr; |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 342 | m_backgroundLayer = nullptr; |
simon.fraser@apple.com | 632ced1 | 2013-01-15 23:17:01 +0000 | [diff] [blame] | 343 | m_childContainmentLayer = nullptr; |
abarth@webkit.org | 462d90a | 2011-04-27 21:25:22 +0000 | [diff] [blame] | 344 | m_maskLayer = nullptr; |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 345 | |
| 346 | m_scrollingLayer = nullptr; |
| 347 | m_scrollingContentsLayer = nullptr; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 348 | } |
| 349 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 350 | void RenderLayerBacking::updateOpacity(const RenderStyle& style) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 351 | { |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 352 | m_graphicsLayer->setOpacity(compositingOpacity(style.opacity())); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 353 | } |
| 354 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 355 | void RenderLayerBacking::updateTransform(const RenderStyle& style) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 356 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 357 | // FIXME: This could use m_owningLayer.transform(), but that currently has transform-origin |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 358 | // baked into it, and we don't want that. |
| 359 | TransformationMatrix t; |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 360 | if (m_owningLayer.hasTransform()) { |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 361 | auto& renderBox = downcast<RenderBox>(renderer()); |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 362 | style.applyTransform(t, snapRectToDevicePixels(renderBox.borderBoxRect(), deviceScaleFactor()), RenderStyle::ExcludeTransformOrigin); |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 363 | makeMatrixRenderable(t, compositor().canRender3DTransforms()); |
simon.fraser@apple.com | ccf3690 | 2009-03-17 19:24:35 +0000 | [diff] [blame] | 364 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 365 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 366 | if (m_contentsContainmentLayer) { |
| 367 | m_contentsContainmentLayer->setTransform(t); |
| 368 | m_graphicsLayer->setTransform(TransformationMatrix()); |
| 369 | } else |
| 370 | m_graphicsLayer->setTransform(t); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 371 | } |
| 372 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 373 | void RenderLayerBacking::updateFilters(const RenderStyle& style) |
cmarrin@apple.com | 3106ca8 | 2011-12-17 17:46:57 +0000 | [diff] [blame] | 374 | { |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 375 | m_canCompositeFilters = m_graphicsLayer->setFilters(style.filter()); |
cmarrin@apple.com | 3106ca8 | 2011-12-17 17:46:57 +0000 | [diff] [blame] | 376 | } |
cmarrin@apple.com | 3106ca8 | 2011-12-17 17:46:57 +0000 | [diff] [blame] | 377 | |
krit@webkit.org | 70a7a22 | 2012-08-21 00:35:27 +0000 | [diff] [blame] | 378 | #if ENABLE(CSS_COMPOSITING) |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 379 | void RenderLayerBacking::updateBlendMode(const RenderStyle& style) |
krit@webkit.org | 70a7a22 | 2012-08-21 00:35:27 +0000 | [diff] [blame] | 380 | { |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 381 | // FIXME: where is the blend mode updated when m_ancestorClippingLayers come and go? |
commit-queue@webkit.org | f24a35f | 2014-03-31 21:07:39 +0000 | [diff] [blame] | 382 | if (m_ancestorClippingLayer) { |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 383 | m_ancestorClippingLayer->setBlendMode(style.blendMode()); |
commit-queue@webkit.org | f24a35f | 2014-03-31 21:07:39 +0000 | [diff] [blame] | 384 | m_graphicsLayer->setBlendMode(BlendModeNormal); |
| 385 | } else |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 386 | m_graphicsLayer->setBlendMode(style.blendMode()); |
krit@webkit.org | 70a7a22 | 2012-08-21 00:35:27 +0000 | [diff] [blame] | 387 | } |
| 388 | #endif |
| 389 | |
simon.fraser@apple.com | 2a2bd4d | 2014-04-29 23:53:57 +0000 | [diff] [blame] | 390 | // FIXME: the hasAcceleratedTouchScrolling()/needsCompositedScrolling() concepts need to be merged. |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 391 | static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer& layer) |
simon.fraser@apple.com | cc875e4 | 2010-07-15 20:08:41 +0000 | [diff] [blame] | 392 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 393 | for (RenderLayer* curr = &layer; curr; curr = curr->parent()) { |
simon.fraser@apple.com | 2a2bd4d | 2014-04-29 23:53:57 +0000 | [diff] [blame] | 394 | if (curr->hasTransform() |
| 395 | #if PLATFORM(IOS) |
simon.fraser@apple.com | 9fd8d64 | 2014-05-02 21:24:54 +0000 | [diff] [blame] | 396 | || curr->hasTouchScrollableOverflow() |
simon.fraser@apple.com | 2a2bd4d | 2014-04-29 23:53:57 +0000 | [diff] [blame] | 397 | #else |
| 398 | || curr->needsCompositedScrolling() |
| 399 | #endif |
| 400 | ) |
simon.fraser@apple.com | 3d11766 | 2010-07-27 00:21:41 +0000 | [diff] [blame] | 401 | return true; |
simon.fraser@apple.com | cc875e4 | 2010-07-15 20:08:41 +0000 | [diff] [blame] | 402 | } |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 403 | |
simon.fraser@apple.com | 3d11766 | 2010-07-27 00:21:41 +0000 | [diff] [blame] | 404 | return false; |
simon.fraser@apple.com | cc875e4 | 2010-07-15 20:08:41 +0000 | [diff] [blame] | 405 | } |
simon.fraser@apple.com | 2a2bd4d | 2014-04-29 23:53:57 +0000 | [diff] [blame] | 406 | |
andersca@apple.com | b531452 | 2012-03-07 01:25:46 +0000 | [diff] [blame] | 407 | bool RenderLayerBacking::shouldClipCompositedBounds() const |
| 408 | { |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 409 | #if !PLATFORM(IOS) |
enne@google.com | 5979acb | 2012-06-19 21:00:09 +0000 | [diff] [blame] | 410 | // Scrollbar layers use this layer for relative positioning, so don't clip. |
| 411 | if (layerForHorizontalScrollbar() || layerForVerticalScrollbar()) |
| 412 | return false; |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 413 | #endif |
enne@google.com | 5979acb | 2012-06-19 21:00:09 +0000 | [diff] [blame] | 414 | |
andersca@apple.com | b531452 | 2012-03-07 01:25:46 +0000 | [diff] [blame] | 415 | if (m_usingTiledCacheLayer) |
simon.fraser@apple.com | 199fa15 | 2012-12-12 23:33:05 +0000 | [diff] [blame] | 416 | return false; |
andersca@apple.com | b531452 | 2012-03-07 01:25:46 +0000 | [diff] [blame] | 417 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 418 | if (layerOrAncestorIsTransformedOrUsingCompositedScrolling(m_owningLayer)) |
andersca@apple.com | b531452 | 2012-03-07 01:25:46 +0000 | [diff] [blame] | 419 | return false; |
| 420 | |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 421 | if (m_owningLayer.isFlowThreadCollectingGraphicsLayersUnderRegions()) |
| 422 | return false; |
| 423 | |
andersca@apple.com | b531452 | 2012-03-07 01:25:46 +0000 | [diff] [blame] | 424 | return true; |
| 425 | } |
| 426 | |
simon.fraser@apple.com | 2a2bd4d | 2014-04-29 23:53:57 +0000 | [diff] [blame] | 427 | static bool hasNonZeroTransformOrigin(const RenderObject& renderer) |
| 428 | { |
| 429 | const RenderStyle& style = renderer.style(); |
| 430 | return (style.transformOriginX().type() == Fixed && style.transformOriginX().value()) |
| 431 | || (style.transformOriginY().type() == Fixed && style.transformOriginY().value()); |
| 432 | } |
| 433 | |
simon.fraser@apple.com | c6e466c | 2009-09-19 03:44:10 +0000 | [diff] [blame] | 434 | void RenderLayerBacking::updateCompositedBounds() |
| 435 | { |
zalan@apple.com | 1266250 | 2014-07-14 19:15:24 +0000 | [diff] [blame] | 436 | LayoutRect layerBounds = m_owningLayer.calculateLayerBounds(&m_owningLayer, LayoutSize(), RenderLayer::DefaultCalculateLayerBoundsFlags | RenderLayer::ExcludeHiddenDescendants | RenderLayer::DontConstrainForMask); |
simon.fraser@apple.com | cc875e4 | 2010-07-15 20:08:41 +0000 | [diff] [blame] | 437 | // Clip to the size of the document or enclosing overflow-scroll layer. |
simon.fraser@apple.com | 3d11766 | 2010-07-27 00:21:41 +0000 | [diff] [blame] | 438 | // If this or an ancestor is transformed, we can't currently compute the correct rect to intersect with. |
jer.noble@apple.com | c99c8cf | 2012-03-08 23:14:46 +0000 | [diff] [blame] | 439 | // We'd need RenderObject::convertContainerToLocalQuad(), which doesn't yet exist. |
andersca@apple.com | b531452 | 2012-03-07 01:25:46 +0000 | [diff] [blame] | 440 | if (shouldClipCompositedBounds()) { |
mihnea@adobe.com | 388bf22 | 2014-09-22 07:51:54 +0000 | [diff] [blame] | 441 | RenderView& view = renderer().view(); |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 442 | RenderLayer* rootLayer = view.layer(); |
simon.fraser@apple.com | cc875e4 | 2010-07-15 20:08:41 +0000 | [diff] [blame] | 443 | |
simon.fraser@apple.com | 8b54815 | 2013-02-16 01:05:20 +0000 | [diff] [blame] | 444 | LayoutRect clippingBounds; |
simon.fraser@apple.com | 2e9410a | 2014-01-31 01:47:45 +0000 | [diff] [blame] | 445 | if (renderer().style().position() == FixedPosition && renderer().container() == &view) |
simon.fraser@apple.com | 539397f | 2014-05-13 04:32:09 +0000 | [diff] [blame] | 446 | clippingBounds = view.frameView().viewportConstrainedVisibleContentRect(); |
simon.fraser@apple.com | 2e9410a | 2014-01-31 01:47:45 +0000 | [diff] [blame] | 447 | else |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 448 | clippingBounds = view.unscaledDocumentRect(); |
simon.fraser@apple.com | cc875e4 | 2010-07-15 20:08:41 +0000 | [diff] [blame] | 449 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 450 | if (&m_owningLayer != rootLayer) |
abucur@adobe.com | 7f9668a | 2014-05-16 13:22:00 +0000 | [diff] [blame] | 451 | clippingBounds.intersect(m_owningLayer.backgroundClipRect(RenderLayer::ClipRectsContext(rootLayer, AbsoluteClipRects)).rect()); // FIXME: Incorrect for CSS regions. |
simon.fraser@apple.com | 3d11766 | 2010-07-27 00:21:41 +0000 | [diff] [blame] | 452 | |
zalan@apple.com | 93ff24a | 2014-06-20 22:57:42 +0000 | [diff] [blame] | 453 | LayoutPoint delta = m_owningLayer.convertToLayerCoords(rootLayer, LayoutPoint(), RenderLayer::AdjustForColumns); |
eae@chromium.org | 53dc8b5 | 2011-06-02 06:41:17 +0000 | [diff] [blame] | 454 | clippingBounds.move(-delta.x(), -delta.y()); |
simon.fraser@apple.com | 3d11766 | 2010-07-27 00:21:41 +0000 | [diff] [blame] | 455 | |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 456 | layerBounds.intersect(clippingBounds); |
simon.fraser@apple.com | bd93c75 | 2013-08-23 00:28:48 +0000 | [diff] [blame] | 457 | } |
simon.fraser@apple.com | cc875e4 | 2010-07-15 20:08:41 +0000 | [diff] [blame] | 458 | |
simon.fraser@apple.com | c6e466c | 2009-09-19 03:44:10 +0000 | [diff] [blame] | 459 | // If the element has a transform-origin that has fixed lengths, and the renderer has zero size, |
| 460 | // then we need to ensure that the compositing layer has non-zero size so that we can apply |
| 461 | // the transform-origin via the GraphicsLayer anchorPoint (which is expressed as a fractional value). |
| 462 | if (layerBounds.isEmpty() && hasNonZeroTransformOrigin(renderer())) { |
| 463 | layerBounds.setWidth(1); |
| 464 | layerBounds.setHeight(1); |
| 465 | m_artificiallyInflatedBounds = true; |
| 466 | } else |
| 467 | m_artificiallyInflatedBounds = false; |
| 468 | |
| 469 | setCompositedBounds(layerBounds); |
| 470 | } |
| 471 | |
simon.fraser@apple.com | 0debf0a | 2010-07-09 05:33:01 +0000 | [diff] [blame] | 472 | void RenderLayerBacking::updateAfterWidgetResize() |
| 473 | { |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 474 | if (!is<RenderWidget>(renderer())) |
akling@apple.com | b95111f | 2013-09-12 05:21:14 +0000 | [diff] [blame] | 475 | return; |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 476 | if (RenderLayerCompositor* innerCompositor = RenderLayerCompositor::frameContentsCompositor(&downcast<RenderWidget>(renderer()))) { |
akling@apple.com | b95111f | 2013-09-12 05:21:14 +0000 | [diff] [blame] | 477 | innerCompositor->frameViewDidChangeSize(); |
| 478 | innerCompositor->frameViewDidChangeLocation(flooredIntPoint(contentsBox().location())); |
simon.fraser@apple.com | 0debf0a | 2010-07-09 05:33:01 +0000 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
simon.fraser@apple.com | fc75029 | 2012-12-15 22:11:27 +0000 | [diff] [blame] | 482 | void RenderLayerBacking::updateAfterLayout(UpdateAfterLayoutFlags flags) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 483 | { |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 484 | if (!compositor().compositingLayersNeedRebuild()) { |
simon.fraser@apple.com | e33dc48 | 2014-05-19 15:53:32 +0000 | [diff] [blame] | 485 | // Calling updateGeometry() here gives incorrect results, because the |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 486 | // position of this layer's GraphicsLayer depends on the position of our compositing |
| 487 | // ancestor's GraphicsLayer. That cannot be determined until all the descendant |
| 488 | // RenderLayers of that ancestor have been processed via updateLayerPositions(). |
| 489 | // |
| 490 | // The solution is to update compositing children of this layer here, |
| 491 | // via updateCompositingChildrenGeometry(). |
simon.fraser@apple.com | c6e466c | 2009-09-19 03:44:10 +0000 | [diff] [blame] | 492 | updateCompositedBounds(); |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 493 | compositor().updateCompositingDescendantGeometry(m_owningLayer, m_owningLayer, flags & CompositingChildrenOnly); |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 494 | |
simon.fraser@apple.com | fc75029 | 2012-12-15 22:11:27 +0000 | [diff] [blame] | 495 | if (flags & IsUpdateRoot) { |
simon.fraser@apple.com | e33dc48 | 2014-05-19 15:53:32 +0000 | [diff] [blame] | 496 | updateGeometry(); |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 497 | compositor().updateRootLayerPosition(); |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 498 | RenderLayer* stackingContainer = m_owningLayer.enclosingStackingContainer(); |
| 499 | if (!compositor().compositingLayersNeedRebuild() && stackingContainer && (stackingContainer != &m_owningLayer)) |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 500 | compositor().updateCompositingDescendantGeometry(*stackingContainer, *stackingContainer, flags & CompositingChildrenOnly); |
simon.fraser@apple.com | fc8f94b | 2009-07-02 06:30:05 +0000 | [diff] [blame] | 501 | } |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 502 | } |
simon.fraser@apple.com | fc75029 | 2012-12-15 22:11:27 +0000 | [diff] [blame] | 503 | |
simon.fraser@apple.com | 4baf9a3 | 2012-12-16 18:14:52 +0000 | [diff] [blame] | 504 | if (flags & NeedsFullRepaint && !paintsIntoWindow() && !paintsIntoCompositedAncestor()) |
simon.fraser@apple.com | fc75029 | 2012-12-15 22:11:27 +0000 | [diff] [blame] | 505 | setContentsNeedDisplay(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 506 | } |
| 507 | |
simon.fraser@apple.com | e33dc48 | 2014-05-19 15:53:32 +0000 | [diff] [blame] | 508 | bool RenderLayerBacking::updateConfiguration() |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 509 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 510 | m_owningLayer.updateDescendantDependentFlags(); |
| 511 | m_owningLayer.updateZOrderLists(); |
jchaffraix@webkit.org | 99e0993 | 2012-05-15 21:33:41 +0000 | [diff] [blame] | 512 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 513 | bool layerConfigChanged = false; |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 514 | setBackgroundLayerPaintsFixedRootBackground(compositor().needsFixedRootBackgroundLayer(m_owningLayer)); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 515 | |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 516 | // The background layer is currently only used for fixed root backgrounds. |
| 517 | if (updateBackgroundLayer(m_backgroundLayerPaintsFixedRootBackground)) |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 518 | layerConfigChanged = true; |
| 519 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 520 | if (updateForegroundLayer(compositor().needsContentsCompositingLayer(m_owningLayer))) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 521 | layerConfigChanged = true; |
| 522 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 523 | bool needsDescendentsClippingLayer = compositor().clipsCompositingDescendants(m_owningLayer); |
simon.fraser@apple.com | 2a2bd4d | 2014-04-29 23:53:57 +0000 | [diff] [blame] | 524 | |
simon.fraser@apple.com | 9fd8d64 | 2014-05-02 21:24:54 +0000 | [diff] [blame] | 525 | if (!renderer().view().needsLayout()) { |
| 526 | bool usesCompositedScrolling; |
| 527 | #if PLATFORM(IOS) |
| 528 | usesCompositedScrolling = m_owningLayer.hasTouchScrollableOverflow(); |
| 529 | #else |
| 530 | usesCompositedScrolling = m_owningLayer.needsCompositedScrolling(); |
| 531 | #endif |
| 532 | // Our scrolling layer will clip. |
| 533 | if (usesCompositedScrolling) |
| 534 | needsDescendentsClippingLayer = false; |
| 535 | |
| 536 | if (updateScrollingLayers(usesCompositedScrolling)) |
| 537 | layerConfigChanged = true; |
| 538 | |
| 539 | if (updateDescendantClippingLayer(needsDescendentsClippingLayer)) |
| 540 | layerConfigChanged = true; |
| 541 | } |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 542 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 543 | if (updateAncestorClippingLayer(compositor().clippedByAncestor(m_owningLayer))) |
zalan@apple.com | c3d7218 | 2013-09-12 14:03:21 +0000 | [diff] [blame] | 544 | layerConfigChanged = true; |
| 545 | |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 546 | if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), requiresVerticalScrollbarLayer(), requiresScrollCornerLayer())) |
| 547 | layerConfigChanged = true; |
| 548 | |
| 549 | if (layerConfigChanged) |
| 550 | updateInternalHierarchy(); |
| 551 | |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 552 | if (GraphicsLayer* flatteningLayer = tileCacheFlatteningLayer()) { |
andersca@apple.com | cc3b2dc | 2013-09-27 18:38:51 +0000 | [diff] [blame] | 553 | if (layerConfigChanged || flatteningLayer->parent() != m_graphicsLayer.get()) |
simon.fraser@apple.com | 32c18df | 2013-08-13 20:18:30 +0000 | [diff] [blame] | 554 | m_graphicsLayer->addChild(flatteningLayer); |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 555 | } |
| 556 | |
simon.fraser@apple.com | 0749dee | 2014-06-20 20:56:16 +0000 | [diff] [blame] | 557 | updateMaskLayer(renderer().hasMask()); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 558 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 559 | if (m_owningLayer.hasReflection()) { |
| 560 | if (m_owningLayer.reflectionLayer()->backing()) { |
| 561 | GraphicsLayer* reflectionLayer = m_owningLayer.reflectionLayer()->backing()->graphicsLayer(); |
simon.fraser@apple.com | 823f73c | 2010-01-16 05:07:42 +0000 | [diff] [blame] | 562 | m_graphicsLayer->setReplicatedByLayer(reflectionLayer); |
| 563 | } |
| 564 | } else |
| 565 | m_graphicsLayer->setReplicatedByLayer(0); |
| 566 | |
simon.fraser@apple.com | 3547efb | 2014-09-05 00:23:05 +0000 | [diff] [blame] | 567 | if (!m_owningLayer.isRootLayer()) { |
| 568 | bool isSimpleContainer = isSimpleContainerCompositingLayer(); |
| 569 | bool didUpdateContentsRect = false; |
| 570 | updateDirectlyCompositedContents(isSimpleContainer, didUpdateContentsRect); |
| 571 | } else |
| 572 | updateRootLayerConfiguration(); |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 573 | |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 574 | if (isDirectlyCompositedImage()) |
| 575 | updateImageContents(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 576 | |
cdumez@apple.com | 63c654d | 2014-10-09 16:45:32 +0000 | [diff] [blame] | 577 | if (is<RenderEmbeddedObject>(renderer()) && downcast<RenderEmbeddedObject>(renderer()).allowsAcceleratedCompositing()) { |
| 578 | PluginViewBase* pluginViewBase = downcast<PluginViewBase>(downcast<RenderWidget>(renderer()).widget()); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 579 | #if PLATFORM(IOS) |
| 580 | if (pluginViewBase && !m_graphicsLayer->contentsLayerForMedia()) { |
| 581 | pluginViewBase->detachPluginLayer(); |
| 582 | pluginViewBase->attachPluginLayer(); |
| 583 | } |
| 584 | #else |
roger_fong@apple.com | 78dd618 | 2013-07-11 23:53:40 +0000 | [diff] [blame] | 585 | if (!pluginViewBase->shouldNotAddLayer()) |
commit-queue@webkit.org | f0edcda | 2014-08-23 09:24:44 +0000 | [diff] [blame] | 586 | m_graphicsLayer->setContentsToPlatformLayer(pluginViewBase->platformLayer(), GraphicsLayer::ContentsLayerForPlugin); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 587 | #endif |
ossy@webkit.org | 497bedb | 2010-02-16 23:03:58 +0000 | [diff] [blame] | 588 | } |
| 589 | #if ENABLE(VIDEO) |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 590 | else if (renderer().isVideo()) { |
cdumez@apple.com | cd13153 | 2014-09-27 01:32:34 +0000 | [diff] [blame] | 591 | HTMLMediaElement* mediaElement = downcast<HTMLMediaElement>(renderer().element()); |
commit-queue@webkit.org | f0edcda | 2014-08-23 09:24:44 +0000 | [diff] [blame] | 592 | m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer(), GraphicsLayer::ContentsLayerForMedia); |
simon.fraser@apple.com | d6aff5e | 2010-01-12 00:15:06 +0000 | [diff] [blame] | 593 | } |
ossy@webkit.org | 497bedb | 2010-02-16 23:03:58 +0000 | [diff] [blame] | 594 | #endif |
cmarrin@apple.com | 8b28bbc | 2011-01-25 17:27:30 +0000 | [diff] [blame] | 595 | #if ENABLE(WEBGL) || ENABLE(ACCELERATED_2D_CANVAS) |
simon.fraser@apple.com | efaa412 | 2013-12-20 03:48:10 +0000 | [diff] [blame] | 596 | else if (renderer().isCanvas() && canvasCompositingStrategy(renderer()) == CanvasAsLayerContents) { |
cdumez@apple.com | 72754ba | 2014-09-23 22:03:15 +0000 | [diff] [blame] | 597 | const HTMLCanvasElement* canvas = downcast<HTMLCanvasElement>(renderer().element()); |
jamesr@google.com | d8c6157 | 2010-08-06 21:49:20 +0000 | [diff] [blame] | 598 | if (CanvasRenderingContext* context = canvas->renderingContext()) |
commit-queue@webkit.org | f0edcda | 2014-08-23 09:24:44 +0000 | [diff] [blame] | 599 | m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer(), GraphicsLayer::ContentsLayerForCanvas); |
jamesr@google.com | bab9191 | 2010-09-03 18:38:37 +0000 | [diff] [blame] | 600 | layerConfigChanged = true; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 601 | } |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 602 | #endif |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 603 | if (is<RenderWidget>(renderer())) |
| 604 | layerConfigChanged = RenderLayerCompositor::parentFrameContentLayers(&downcast<RenderWidget>(renderer())); |
simon.fraser@apple.com | c0c558c | 2010-05-11 05:44:06 +0000 | [diff] [blame] | 605 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 606 | return layerConfigChanged; |
| 607 | } |
| 608 | |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 609 | static LayoutRect clipBox(RenderBox& renderer) |
simon.fraser@apple.com | 02d5599 | 2010-06-16 19:16:17 +0000 | [diff] [blame] | 610 | { |
carlosgc@webkit.org | 60d416c | 2014-01-07 20:01:31 +0000 | [diff] [blame] | 611 | LayoutRect result = LayoutRect::infiniteRect(); |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 612 | if (renderer.hasOverflowClip()) |
| 613 | result = renderer.overflowClipRect(LayoutPoint(), 0); // FIXME: Incorrect for CSS regions. |
simon.fraser@apple.com | 02d5599 | 2010-06-16 19:16:17 +0000 | [diff] [blame] | 614 | |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 615 | if (renderer.hasClip()) |
| 616 | result.intersect(renderer.clipRect(LayoutPoint(), 0)); // FIXME: Incorrect for CSS regions. |
simon.fraser@apple.com | 02d5599 | 2010-06-16 19:16:17 +0000 | [diff] [blame] | 617 | |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 618 | return result; |
| 619 | } |
| 620 | |
| 621 | static FloatSize pixelFractionForLayerPainting(const LayoutPoint& point, float pixelSnappingFactor) |
| 622 | { |
| 623 | LayoutUnit x = point.x(); |
| 624 | LayoutUnit y = point.y(); |
| 625 | x = x >= 0 ? floorToDevicePixel(x, pixelSnappingFactor) : ceilToDevicePixel(x, pixelSnappingFactor); |
| 626 | y = y >= 0 ? floorToDevicePixel(y, pixelSnappingFactor) : ceilToDevicePixel(y, pixelSnappingFactor); |
| 627 | return point - LayoutPoint(x, y); |
| 628 | } |
| 629 | |
| 630 | static void calculateDevicePixelOffsetFromRenderer(const LayoutSize& rendererOffsetFromGraphicsLayer, FloatSize& devicePixelOffsetFromRenderer, |
| 631 | LayoutSize& devicePixelFractionFromRenderer, float deviceScaleFactor) |
| 632 | { |
| 633 | devicePixelFractionFromRenderer = LayoutSize(pixelFractionForLayerPainting(toLayoutPoint(rendererOffsetFromGraphicsLayer), deviceScaleFactor)); |
| 634 | devicePixelOffsetFromRenderer = rendererOffsetFromGraphicsLayer - devicePixelFractionFromRenderer; |
simon.fraser@apple.com | 02d5599 | 2010-06-16 19:16:17 +0000 | [diff] [blame] | 635 | } |
| 636 | |
simon.fraser@apple.com | e33dc48 | 2014-05-19 15:53:32 +0000 | [diff] [blame] | 637 | void RenderLayerBacking::updateGeometry() |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 638 | { |
| 639 | // If we haven't built z-order lists yet, wait until later. |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 640 | if (m_owningLayer.isStackingContainer() && m_owningLayer.m_zOrderListsDirty) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 641 | return; |
| 642 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 643 | const RenderStyle& style = renderer().style(); |
| 644 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 645 | // Set transform property, if it is not animating. We have to do this here because the transform |
| 646 | // is affected by the layer dimensions. |
cdumez@apple.com | bc6f740 | 2014-10-17 01:53:09 +0000 | [diff] [blame] | 647 | if (!renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitTransform, AnimationBase::Running | AnimationBase::Paused | AnimationBase::FillingFowards)) |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 648 | updateTransform(style); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 649 | |
simon.fraser@apple.com | 699dc0b | 2009-04-07 17:45:00 +0000 | [diff] [blame] | 650 | // Set opacity, if it is not animating. |
cdumez@apple.com | bc6f740 | 2014-10-17 01:53:09 +0000 | [diff] [blame] | 651 | if (!renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity, AnimationBase::Running | AnimationBase::Paused | AnimationBase::FillingFowards)) |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 652 | updateOpacity(style); |
commit-queue@webkit.org | 9e58b3d | 2014-09-04 18:43:39 +0000 | [diff] [blame] | 653 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 654 | updateFilters(style); |
krit@webkit.org | 70a7a22 | 2012-08-21 00:35:27 +0000 | [diff] [blame] | 655 | |
| 656 | #if ENABLE(CSS_COMPOSITING) |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 657 | updateBlendMode(style); |
krit@webkit.org | 70a7a22 | 2012-08-21 00:35:27 +0000 | [diff] [blame] | 658 | #endif |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 659 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 660 | m_owningLayer.updateDescendantDependentFlags(); |
shawnsingh@chromium.org | 976a608 | 2012-02-01 10:31:15 +0000 | [diff] [blame] | 661 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 662 | // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959 |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 663 | bool preserves3D = style.transformStyle3D() == TransformStyle3DPreserve3D && !renderer().hasReflection(); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 664 | m_graphicsLayer->setPreserves3D(preserves3D); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 665 | m_graphicsLayer->setBackfaceVisibility(style.backfaceVisibility() == BackfaceVisibilityVisible); |
simon.fraser@apple.com | 699dc0b | 2009-04-07 17:45:00 +0000 | [diff] [blame] | 666 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 667 | RenderLayer* compAncestor = m_owningLayer.ancestorCompositingLayer(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 668 | |
| 669 | // We compute everything relative to the enclosing compositing layer. |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 670 | LayoutRect ancestorCompositingBounds; |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 671 | if (compAncestor) { |
| 672 | ASSERT(compAncestor->backing()); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 673 | ancestorCompositingBounds = compAncestor->backing()->compositedBounds(); |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 674 | } |
| 675 | |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 676 | /* |
zalan@apple.com | c184125 | 2014-04-21 05:21:45 +0000 | [diff] [blame] | 677 | * GraphicsLayer: device pixel positioned, enclosing rect. |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 678 | * RenderLayer: subpixel positioned. |
| 679 | * Offset from renderer (GraphicsLayer <-> RenderLayer::renderer()): subpixel based offset. |
| 680 | * |
| 681 | * relativeCompositingBounds |
| 682 | * _______________________________________ |
| 683 | * |\ GraphicsLayer | |
| 684 | * | \ | |
| 685 | * | \ offset from renderer: (device pixel + subpixel) |
| 686 | * | \ | |
| 687 | * | \______________________________ | |
| 688 | * | | localCompositingBounds | | |
| 689 | * | | | | |
| 690 | * | | RenderLayer::renderer() | | |
| 691 | * | | | | |
| 692 | * |
| 693 | * localCompositingBounds: this RenderLayer relative to its renderer(). |
| 694 | * relativeCompositingBounds: this RenderLayer relative to its parent compositing layer. |
zalan@apple.com | c184125 | 2014-04-21 05:21:45 +0000 | [diff] [blame] | 695 | * enclosingRelativeCompositingBounds: this RenderLayer relative to its parent, device pixel enclosing. |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 696 | * rendererOffsetFromGraphicsLayer: RenderLayer::renderer()'s offset from its enclosing GraphicsLayer. |
| 697 | * devicePixelOffsetFromRenderer: rendererOffsetFromGraphicsLayer's device pixel part. (6.9px -> 6.5px in case of 2x display) |
| 698 | * devicePixelFractionFromRenderer: rendererOffsetFromGraphicsLayer's fractional part (6.9px -> 0.4px in case of 2x display) |
| 699 | */ |
| 700 | float deviceScaleFactor = this->deviceScaleFactor(); |
| 701 | LayoutRect localCompositingBounds = compositedBounds(); |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 702 | LayoutRect relativeCompositingBounds(localCompositingBounds); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 703 | |
zalan@apple.com | 93ff24a | 2014-06-20 22:57:42 +0000 | [diff] [blame] | 704 | LayoutPoint offsetFromParent = m_owningLayer.convertToLayerCoords(compAncestor, LayoutPoint(), RenderLayer::AdjustForColumns); |
zalan@apple.com | 8c4a9fb | 2014-03-20 14:20:22 +0000 | [diff] [blame] | 705 | // Device pixel fractions get accumulated through ancestor layers. Our painting offset is layout offset + parent's painting offset. |
| 706 | offsetFromParent = offsetFromParent + (compAncestor ? compAncestor->backing()->devicePixelFractionFromRenderer() : LayoutSize()); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 707 | relativeCompositingBounds.moveBy(offsetFromParent); |
| 708 | |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 709 | LayoutRect enclosingRelativeCompositingBounds = LayoutRect(encloseRectToDevicePixels(relativeCompositingBounds, deviceScaleFactor)); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 710 | LayoutSize subpixelOffsetAdjustment = enclosingRelativeCompositingBounds.location() - relativeCompositingBounds.location(); |
| 711 | LayoutSize rendererOffsetFromGraphicsLayer = toLayoutSize(localCompositingBounds.location()) + subpixelOffsetAdjustment; |
| 712 | |
| 713 | FloatSize devicePixelOffsetFromRenderer; |
| 714 | LayoutSize devicePixelFractionFromRenderer; |
| 715 | calculateDevicePixelOffsetFromRenderer(rendererOffsetFromGraphicsLayer, devicePixelOffsetFromRenderer, devicePixelFractionFromRenderer, deviceScaleFactor); |
zalan@apple.com | b333b3a | 2014-07-15 02:55:26 +0000 | [diff] [blame] | 716 | m_devicePixelFractionFromRenderer = LayoutSize(-devicePixelFractionFromRenderer.width(), -devicePixelFractionFromRenderer.height()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 717 | |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 718 | adjustAncestorCompositingBoundsForFlowThread(ancestorCompositingBounds, compAncestor); |
| 719 | |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 720 | LayoutPoint graphicsLayerParentLocation; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 721 | if (compAncestor && compAncestor->backing()->hasClippingLayer()) { |
| 722 | // If the compositing ancestor has a layer to clip children, we parent in that, and therefore |
| 723 | // position relative to it. |
simon.fraser@apple.com | d6d9d64 | 2014-05-01 02:15:17 +0000 | [diff] [blame] | 724 | // FIXME: need to do some pixel snapping here. |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 725 | LayoutRect clippingBox = clipBox(downcast<RenderBox>(compAncestor->renderer())); |
simon.fraser@apple.com | 02d5599 | 2010-06-16 19:16:17 +0000 | [diff] [blame] | 726 | graphicsLayerParentLocation = clippingBox.location(); |
enne@google.com | 8451595 | 2011-06-24 18:35:12 +0000 | [diff] [blame] | 727 | } else if (compAncestor) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 728 | graphicsLayerParentLocation = ancestorCompositingBounds.location(); |
enne@google.com | f1e5271 | 2011-06-24 19:16:48 +0000 | [diff] [blame] | 729 | else |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 730 | graphicsLayerParentLocation = renderer().view().documentRect().location(); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 731 | |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 732 | #if PLATFORM(IOS) |
simon.fraser@apple.com | 9fd8d64 | 2014-05-02 21:24:54 +0000 | [diff] [blame] | 733 | if (compAncestor && compAncestor->hasTouchScrollableOverflow()) { |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 734 | auto& renderBox = downcast<RenderBox>(compAncestor->renderer()); |
| 735 | LayoutRect paddingBox(renderBox.borderLeft(), renderBox.borderTop(), |
| 736 | renderBox.width() - renderBox.borderLeft() - renderBox.borderRight(), |
| 737 | renderBox.height() - renderBox.borderTop() - renderBox.borderBottom()); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 738 | |
simon.fraser@apple.com | d6d9d64 | 2014-05-01 02:15:17 +0000 | [diff] [blame] | 739 | IntSize scrollOffset = compAncestor->scrolledContentOffset(); |
| 740 | // FIXME: pixel snap the padding box. |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 741 | graphicsLayerParentLocation = paddingBox.location() - scrollOffset; |
| 742 | } |
simon.fraser@apple.com | d6d9d64 | 2014-05-01 02:15:17 +0000 | [diff] [blame] | 743 | #else |
vollick@chromium.org | 013915f | 2012-12-16 02:07:57 +0000 | [diff] [blame] | 744 | if (compAncestor && compAncestor->needsCompositedScrolling()) { |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 745 | auto& renderBox = downcast<RenderBox>(compAncestor->renderer()); |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 746 | LayoutSize scrollOffset = compAncestor->scrolledContentOffset(); |
| 747 | LayoutPoint scrollOrigin(renderBox.borderLeft(), renderBox.borderTop()); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 748 | graphicsLayerParentLocation = scrollOrigin - scrollOffset; |
| 749 | } |
simon.fraser@apple.com | d6d9d64 | 2014-05-01 02:15:17 +0000 | [diff] [blame] | 750 | #endif |
| 751 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 752 | if (compAncestor && m_ancestorClippingLayer) { |
| 753 | // Call calculateRects to get the backgroundRect which is what is used to clip the contents of this |
| 754 | // layer. Note that we call it with temporaryClipRects = true because normally when computing clip rects |
| 755 | // for a compositing layer, rootLayer is the layer itself. |
commit-queue@webkit.org | bcb0f1c | 2014-05-05 21:08:25 +0000 | [diff] [blame] | 756 | ShouldRespectOverflowClip shouldRespectOverflowClip = compAncestor->isolatesCompositedBlending() ? RespectOverflowClip : IgnoreOverflowClip; |
abucur@adobe.com | 7f9668a | 2014-05-16 13:22:00 +0000 | [diff] [blame] | 757 | RenderLayer::ClipRectsContext clipRectsContext(compAncestor, TemporaryClipRects, IgnoreOverlayScrollbarSize, shouldRespectOverflowClip); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 758 | LayoutRect parentClipRect = m_owningLayer.backgroundClipRect(clipRectsContext).rect(); // FIXME: Incorrect for CSS regions. |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 759 | ASSERT(parentClipRect != LayoutRect::infiniteRect()); |
commit-queue@webkit.org | 444304f | 2013-01-08 06:07:55 +0000 | [diff] [blame] | 760 | m_ancestorClippingLayer->setPosition(FloatPoint(parentClipRect.location() - graphicsLayerParentLocation)); |
simon.fraser@apple.com | a9214f63 | 2009-03-26 18:34:03 +0000 | [diff] [blame] | 761 | m_ancestorClippingLayer->setSize(parentClipRect.size()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 762 | |
| 763 | // backgroundRect is relative to compAncestor, so subtract deltaX/deltaY to get back to local coords. |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 764 | m_ancestorClippingLayer->setOffsetFromRenderer(parentClipRect.location() - offsetFromParent); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 765 | |
| 766 | // The primary layer is then parented in, and positioned relative to this clipping layer. |
simon.fraser@apple.com | a9214f63 | 2009-03-26 18:34:03 +0000 | [diff] [blame] | 767 | graphicsLayerParentLocation = parentClipRect.location(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 768 | } |
| 769 | |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 770 | LayoutSize contentsSize = enclosingRelativeCompositingBounds.size(); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 771 | |
| 772 | if (m_contentsContainmentLayer) { |
| 773 | m_contentsContainmentLayer->setPreserves3D(preserves3D); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 774 | m_contentsContainmentLayer->setPosition(FloatPoint(enclosingRelativeCompositingBounds.location() - graphicsLayerParentLocation)); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 775 | // Use the same size as m_graphicsLayer so transforms behave correctly. |
| 776 | m_contentsContainmentLayer->setSize(contentsSize); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 777 | graphicsLayerParentLocation = enclosingRelativeCompositingBounds.location(); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 778 | } |
| 779 | |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 780 | m_graphicsLayer->setPosition(FloatPoint(enclosingRelativeCompositingBounds.location() - graphicsLayerParentLocation)); |
simon.fraser@apple.com | bd93c75 | 2013-08-23 00:28:48 +0000 | [diff] [blame] | 781 | m_graphicsLayer->setSize(contentsSize); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 782 | if (devicePixelOffsetFromRenderer != m_graphicsLayer->offsetFromRenderer()) { |
| 783 | m_graphicsLayer->setOffsetFromRenderer(devicePixelOffsetFromRenderer); |
simon.fraser@apple.com | 1c06cdd | 2013-11-12 00:50:29 +0000 | [diff] [blame] | 784 | positionOverflowControlsLayers(); |
| 785 | } |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 786 | |
alokp@chromium.org | 1f006a4 | 2013-03-21 22:29:30 +0000 | [diff] [blame] | 787 | if (!m_isMainFrameRenderViewLayer) { |
| 788 | // For non-root layers, background is always painted by the primary graphics layer. |
| 789 | ASSERT(!m_backgroundLayer); |
zalan@apple.com | c184125 | 2014-04-21 05:21:45 +0000 | [diff] [blame] | 790 | bool hadSubpixelRounding = enclosingRelativeCompositingBounds != relativeCompositingBounds; |
simon.fraser@apple.com | ec171c6 | 2013-11-18 23:33:04 +0000 | [diff] [blame] | 791 | m_graphicsLayer->setContentsOpaque(!hadSubpixelRounding && m_owningLayer.backgroundIsKnownToBeOpaqueInRect(localCompositingBounds)); |
alokp@chromium.org | 1f006a4 | 2013-03-21 22:29:30 +0000 | [diff] [blame] | 792 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 793 | |
| 794 | // If we have a layer that clips children, position it. |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 795 | LayoutRect clippingBox; |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 796 | if (GraphicsLayer* clipLayer = clippingLayer()) { |
simon.fraser@apple.com | d6d9d64 | 2014-05-01 02:15:17 +0000 | [diff] [blame] | 797 | // FIXME: need to do some pixel snapping here. |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 798 | clippingBox = clipBox(downcast<RenderBox>(renderer())); |
commit-queue@webkit.org | 444304f | 2013-01-08 06:07:55 +0000 | [diff] [blame] | 799 | clipLayer->setPosition(FloatPoint(clippingBox.location() - localCompositingBounds.location())); |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 800 | clipLayer->setSize(clippingBox.size()); |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 801 | clipLayer->setOffsetFromRenderer(toFloatSize(clippingBox.location())); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 802 | } |
| 803 | |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 804 | if (m_maskLayer) { |
simon.fraser@apple.com | bd93c75 | 2013-08-23 00:28:48 +0000 | [diff] [blame] | 805 | m_maskLayer->setSize(m_graphicsLayer->size()); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 806 | m_maskLayer->setPosition(FloatPoint()); |
simon.fraser@apple.com | e7881fb | 2011-04-29 05:19:10 +0000 | [diff] [blame] | 807 | m_maskLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRenderer()); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 808 | } |
| 809 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 810 | if (m_owningLayer.hasTransform()) { |
zalan@apple.com | 8896507 | 2014-03-19 14:25:34 +0000 | [diff] [blame] | 811 | // Update properties that depend on layer dimensions. |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 812 | FloatPoint3D transformOrigin = computeTransformOriginForPainting(downcast<RenderBox>(renderer()).borderBoxRect()); |
simon.fraser@apple.com | 90a5664 | 2009-04-06 17:51:53 +0000 | [diff] [blame] | 813 | // Get layout bounds in the coords of compAncestor to match relativeCompositingBounds. |
zalan@apple.com | 592254d | 2014-08-28 02:34:35 +0000 | [diff] [blame] | 814 | FloatPoint layerOffset = roundPointToDevicePixels(offsetFromParent, deviceScaleFactor); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 815 | // Compute the anchor point, which is in the center of the renderer box unless transform-origin is set. |
zalan@apple.com | 8896507 | 2014-03-19 14:25:34 +0000 | [diff] [blame] | 816 | FloatPoint3D anchor(enclosingRelativeCompositingBounds.width() ? ((layerOffset.x() - enclosingRelativeCompositingBounds.x()) + transformOrigin.x()) |
| 817 | / enclosingRelativeCompositingBounds.width() : 0.5, enclosingRelativeCompositingBounds.height() ? ((layerOffset.y() - enclosingRelativeCompositingBounds.y()) |
| 818 | + transformOrigin.y()) / enclosingRelativeCompositingBounds.height() : 0.5, transformOrigin.z()); |
| 819 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 820 | if (m_contentsContainmentLayer) |
| 821 | m_contentsContainmentLayer->setAnchorPoint(anchor); |
| 822 | else |
| 823 | m_graphicsLayer->setAnchorPoint(anchor); |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 824 | |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 825 | GraphicsLayer* clipLayer = clippingLayer(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 826 | if (style.hasPerspective()) { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 827 | TransformationMatrix t = owningLayer().perspectiveTransform(); |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 828 | |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 829 | if (clipLayer) { |
| 830 | clipLayer->setChildrenTransform(t); |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 831 | m_graphicsLayer->setChildrenTransform(TransformationMatrix()); |
| 832 | } |
| 833 | else |
| 834 | m_graphicsLayer->setChildrenTransform(t); |
| 835 | } else { |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 836 | if (clipLayer) |
| 837 | clipLayer->setChildrenTransform(TransformationMatrix()); |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 838 | else |
| 839 | m_graphicsLayer->setChildrenTransform(TransformationMatrix()); |
| 840 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 841 | } else { |
zalan@apple.com | 8896507 | 2014-03-19 14:25:34 +0000 | [diff] [blame] | 842 | m_graphicsLayer->setAnchorPoint(FloatPoint3D(0.5, 0.5, 0)); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 843 | if (m_contentsContainmentLayer) |
zalan@apple.com | 8896507 | 2014-03-19 14:25:34 +0000 | [diff] [blame] | 844 | m_contentsContainmentLayer->setAnchorPoint(FloatPoint3D(0.5, 0.5, 0)); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 845 | } |
| 846 | |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 847 | if (m_foregroundLayer) { |
simon.fraser@apple.com | fdaa788 | 2009-08-18 03:31:57 +0000 | [diff] [blame] | 848 | FloatPoint foregroundPosition; |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 849 | FloatSize foregroundSize = contentsSize; |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 850 | FloatSize foregroundOffset = m_graphicsLayer->offsetFromRenderer(); |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 851 | if (hasClippingLayer()) { |
simon.fraser@apple.com | 83c504a | 2011-03-22 23:17:23 +0000 | [diff] [blame] | 852 | // If we have a clipping layer (which clips descendants), then the foreground layer is a child of it, |
| 853 | // so that it gets correctly sorted with children. In that case, position relative to the clipping layer. |
simon.fraser@apple.com | fdaa788 | 2009-08-18 03:31:57 +0000 | [diff] [blame] | 854 | foregroundSize = FloatSize(clippingBox.size()); |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 855 | foregroundOffset = toFloatSize(clippingBox.location()); |
simon.fraser@apple.com | fdaa788 | 2009-08-18 03:31:57 +0000 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | m_foregroundLayer->setPosition(foregroundPosition); |
simon.fraser@apple.com | bd93c75 | 2013-08-23 00:28:48 +0000 | [diff] [blame] | 859 | m_foregroundLayer->setSize(foregroundSize); |
simon.fraser@apple.com | fdaa788 | 2009-08-18 03:31:57 +0000 | [diff] [blame] | 860 | m_foregroundLayer->setOffsetFromRenderer(foregroundOffset); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 861 | } |
| 862 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 863 | if (m_backgroundLayer) { |
simon.fraser@apple.com | a561496 | 2013-01-19 01:20:32 +0000 | [diff] [blame] | 864 | FloatPoint backgroundPosition; |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 865 | FloatSize backgroundSize = contentsSize; |
simon.fraser@apple.com | a561496 | 2013-01-19 01:20:32 +0000 | [diff] [blame] | 866 | if (backgroundLayerPaintsFixedRootBackground()) { |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 867 | const FrameView& frameView = renderer().view().frameView(); |
simon.fraser@apple.com | eb58fa3 | 2014-03-12 18:15:06 +0000 | [diff] [blame] | 868 | backgroundPosition = toLayoutPoint(frameView.scrollOffsetForFixedPosition()); |
akling@apple.com | 61dc143 | 2013-08-23 16:34:12 +0000 | [diff] [blame] | 869 | backgroundSize = frameView.visibleContentRect().size(); |
simon.fraser@apple.com | a561496 | 2013-01-19 01:20:32 +0000 | [diff] [blame] | 870 | } |
| 871 | m_backgroundLayer->setPosition(backgroundPosition); |
simon.fraser@apple.com | bd93c75 | 2013-08-23 00:28:48 +0000 | [diff] [blame] | 872 | m_backgroundLayer->setSize(backgroundSize); |
simon.fraser@apple.com | a561496 | 2013-01-19 01:20:32 +0000 | [diff] [blame] | 873 | m_backgroundLayer->setOffsetFromRenderer(m_graphicsLayer->offsetFromRenderer()); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 874 | } |
| 875 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 876 | if (m_owningLayer.reflectionLayer() && m_owningLayer.reflectionLayer()->isComposited()) { |
| 877 | RenderLayerBacking* reflectionBacking = m_owningLayer.reflectionLayer()->backing(); |
simon.fraser@apple.com | e33dc48 | 2014-05-19 15:53:32 +0000 | [diff] [blame] | 878 | reflectionBacking->updateGeometry(); |
simon.fraser@apple.com | 823f73c | 2010-01-16 05:07:42 +0000 | [diff] [blame] | 879 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 880 | // The reflection layer has the bounds of m_owningLayer.reflectionLayer(), |
simon.fraser@apple.com | 823f73c | 2010-01-16 05:07:42 +0000 | [diff] [blame] | 881 | // but the reflected layer is the bounds of this layer, so we need to position it appropriately. |
simon.fraser@apple.com | 498c848 | 2010-01-19 22:18:22 +0000 | [diff] [blame] | 882 | FloatRect layerBounds = compositedBounds(); |
| 883 | FloatRect reflectionLayerBounds = reflectionBacking->compositedBounds(); |
commit-queue@webkit.org | 444304f | 2013-01-08 06:07:55 +0000 | [diff] [blame] | 884 | reflectionBacking->graphicsLayer()->setReplicatedLayerPosition(FloatPoint(layerBounds.location() - reflectionLayerBounds.location())); |
simon.fraser@apple.com | 823f73c | 2010-01-16 05:07:42 +0000 | [diff] [blame] | 885 | } |
| 886 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 887 | if (m_scrollingLayer) { |
| 888 | ASSERT(m_scrollingContentsLayer); |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 889 | auto& renderBox = downcast<RenderBox>(renderer()); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 890 | LayoutRect paddingBox(renderBox.borderLeft(), renderBox.borderTop(), renderBox.width() - renderBox.borderLeft() - renderBox.borderRight(), renderBox.height() - renderBox.borderTop() - renderBox.borderBottom()); |
| 891 | LayoutSize scrollOffset = m_owningLayer.scrollOffset(); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 892 | |
simon.fraser@apple.com | d6d9d64 | 2014-05-01 02:15:17 +0000 | [diff] [blame] | 893 | // FIXME: need to do some pixel snapping here. |
commit-queue@webkit.org | 444304f | 2013-01-08 06:07:55 +0000 | [diff] [blame] | 894 | m_scrollingLayer->setPosition(FloatPoint(paddingBox.location() - localCompositingBounds.location())); |
tonikitoo@webkit.org | 94cb8dd | 2012-09-04 21:10:32 +0000 | [diff] [blame] | 895 | |
simon.fraser@apple.com | d6d9d64 | 2014-05-01 02:15:17 +0000 | [diff] [blame] | 896 | IntSize pixelSnappedClientSize(renderBox.pixelSnappedClientWidth(), renderBox.pixelSnappedClientHeight()); |
| 897 | m_scrollingLayer->setSize(pixelSnappedClientSize); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 898 | #if PLATFORM(IOS) |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 899 | FloatSize oldScrollingLayerOffset = m_scrollingLayer->offsetFromRenderer(); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 900 | m_scrollingLayer->setOffsetFromRenderer(FloatPoint() - paddingBox.location()); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 901 | bool paddingBoxOffsetChanged = oldScrollingLayerOffset != m_scrollingLayer->offsetFromRenderer(); |
| 902 | |
| 903 | if (m_owningLayer.isInUserScroll()) { |
simon.fraser@apple.com | c1a4d46 | 2014-05-06 01:10:30 +0000 | [diff] [blame] | 904 | // If scrolling is happening externally, we don't want to touch the layer bounds origin here because that will cause jitter. |
| 905 | m_scrollingLayer->syncBoundsOrigin(FloatPoint(scrollOffset.width(), scrollOffset.height())); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 906 | m_owningLayer.setRequiresScrollBoundsOriginUpdate(true); |
| 907 | } else { |
| 908 | // Note that we implement the contents offset via the bounds origin on this layer, rather than a position on the sublayer. |
| 909 | m_scrollingLayer->setBoundsOrigin(FloatPoint(scrollOffset.width(), scrollOffset.height())); |
| 910 | m_owningLayer.setRequiresScrollBoundsOriginUpdate(false); |
| 911 | } |
| 912 | |
| 913 | IntSize scrollSize(m_owningLayer.scrollWidth(), m_owningLayer.scrollHeight()); |
| 914 | |
| 915 | m_scrollingContentsLayer->setPosition(FloatPoint()); |
| 916 | |
| 917 | if (scrollSize != m_scrollingContentsLayer->size() || paddingBoxOffsetChanged) |
| 918 | m_scrollingContentsLayer->setNeedsDisplay(); |
| 919 | |
| 920 | m_scrollingContentsLayer->setSize(scrollSize); |
| 921 | // Scrolling the content layer does not need to trigger a repaint. The offset will be compensated away during painting. |
| 922 | // FIXME: The paint offset and the scroll offset should really be separate concepts. |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 923 | m_scrollingContentsLayer->setOffsetFromRenderer(paddingBox.location() - IntPoint() - scrollOffset, GraphicsLayer::DontSetNeedsDisplay); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 924 | #else |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 925 | m_scrollingContentsLayer->setPosition(FloatPoint(-scrollOffset.width(), -scrollOffset.height())); |
| 926 | |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 927 | FloatSize oldScrollingLayerOffset = m_scrollingLayer->offsetFromRenderer(); |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 928 | m_scrollingLayer->setOffsetFromRenderer(-toFloatSize(paddingBox.location())); |
tonikitoo@webkit.org | 94cb8dd | 2012-09-04 21:10:32 +0000 | [diff] [blame] | 929 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 930 | bool paddingBoxOffsetChanged = oldScrollingLayerOffset != m_scrollingLayer->offsetFromRenderer(); |
| 931 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 932 | IntSize scrollSize(m_owningLayer.scrollWidth(), m_owningLayer.scrollHeight()); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 933 | if (scrollSize != m_scrollingContentsLayer->size() || paddingBoxOffsetChanged) |
| 934 | m_scrollingContentsLayer->setNeedsDisplay(); |
| 935 | |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 936 | LayoutSize scrollingContentsOffset = toLayoutSize(paddingBox.location() - scrollOffset); |
commit-queue@webkit.org | c032831 | 2012-09-04 18:54:00 +0000 | [diff] [blame] | 937 | if (scrollingContentsOffset != m_scrollingContentsLayer->offsetFromRenderer() || scrollSize != m_scrollingContentsLayer->size()) |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 938 | compositor().scrollingLayerDidChange(m_owningLayer); |
commit-queue@webkit.org | c032831 | 2012-09-04 18:54:00 +0000 | [diff] [blame] | 939 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 940 | m_scrollingContentsLayer->setSize(scrollSize); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 941 | // FIXME: The paint offset and the scroll offset should really be separate concepts. |
commit-queue@webkit.org | e7dc60c | 2012-11-14 18:51:51 +0000 | [diff] [blame] | 942 | m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 943 | #endif |
vollick@chromium.org | 0015c12 | 2013-03-07 14:00:57 +0000 | [diff] [blame] | 944 | |
| 945 | if (m_foregroundLayer) { |
simon.fraser@apple.com | bd93c75 | 2013-08-23 00:28:48 +0000 | [diff] [blame] | 946 | m_foregroundLayer->setSize(m_scrollingContentsLayer->size()); |
vollick@chromium.org | 0015c12 | 2013-03-07 14:00:57 +0000 | [diff] [blame] | 947 | m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->offsetFromRenderer()); |
| 948 | } |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 949 | } |
| 950 | |
simon.fraser@apple.com | b7cec68 | 2012-04-16 18:32:13 +0000 | [diff] [blame] | 951 | // If this layer was created just for clipping or to apply perspective, it doesn't need its own backing store. |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 952 | setRequiresOwnBackingStore(compositor().requiresOwnBackingStore(m_owningLayer, compAncestor, enclosingRelativeCompositingBounds, ancestorCompositingBounds)); |
simon.fraser@apple.com | b7cec68 | 2012-04-16 18:32:13 +0000 | [diff] [blame] | 953 | |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 954 | updateAfterWidgetResize(); |
| 955 | |
| 956 | compositor().updateScrollCoordinatedStatus(m_owningLayer); |
| 957 | } |
| 958 | |
mihnea@adobe.com | 5bdad31 | 2014-09-22 07:08:42 +0000 | [diff] [blame] | 959 | void RenderLayerBacking::updateAfterDescendants() |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 960 | { |
simon.fraser@apple.com | 3547efb | 2014-09-05 00:23:05 +0000 | [diff] [blame] | 961 | bool isSimpleContainer = false; |
| 962 | if (!m_owningLayer.isRootLayer()) { |
| 963 | bool didUpdateContentsRect = false; |
| 964 | // FIXME: this duplicates work we did in updateConfiguration(). |
| 965 | isSimpleContainer = isSimpleContainerCompositingLayer(); |
| 966 | updateDirectlyCompositedContents(isSimpleContainer, didUpdateContentsRect); |
| 967 | if (!didUpdateContentsRect && m_graphicsLayer->usesContentsLayer()) |
| 968 | resetContentsRect(); |
| 969 | } |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 970 | |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 971 | updateDrawsContent(isSimpleContainer); |
simon.fraser@apple.com | f5323c1 | 2014-01-31 05:42:27 +0000 | [diff] [blame] | 972 | |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 973 | m_graphicsLayer->setContentsVisible(m_owningLayer.hasVisibleContent() || isPaintDestinationForDescendentLayers()); |
simon.fraser@apple.com | e6ad1f6 | 2013-01-15 23:46:18 +0000 | [diff] [blame] | 974 | } |
| 975 | |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 976 | void RenderLayerBacking::adjustAncestorCompositingBoundsForFlowThread(LayoutRect& ancestorCompositingBounds, const RenderLayer* compositingAncestor) const |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 977 | { |
| 978 | if (!m_owningLayer.isInsideFlowThread()) |
| 979 | return; |
| 980 | |
hyatt@apple.com | bcde3b4 | 2014-04-29 22:59:26 +0000 | [diff] [blame] | 981 | RenderLayer* flowThreadLayer = m_owningLayer.isInsideOutOfFlowThread() ? m_owningLayer.stackingContainer() : nullptr; |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 982 | if (flowThreadLayer && flowThreadLayer->isRenderFlowThread()) { |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 983 | if (m_owningLayer.isFlowThreadCollectingGraphicsLayersUnderRegions()) { |
| 984 | // The RenderNamedFlowThread is not composited, as we need it to paint the |
| 985 | // background layer of the regions. We need to compensate for that by manually |
| 986 | // subtracting the position of the flow-thread. |
| 987 | IntPoint flowPosition; |
| 988 | flowThreadLayer->convertToPixelSnappedLayerCoords(compositingAncestor, flowPosition); |
| 989 | ancestorCompositingBounds.moveBy(flowPosition); |
| 990 | } |
| 991 | |
| 992 | // Move the ancestor position at the top of the region where the composited layer is going to display. |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 993 | RenderFlowThread& flowThread = downcast<RenderFlowThread>(flowThreadLayer->renderer()); |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 994 | RenderNamedFlowFragment* parentRegion = flowThread.cachedRegionForCompositedLayer(m_owningLayer); |
commit-queue@webkit.org | 4affaa0 | 2014-01-23 14:19:54 +0000 | [diff] [blame] | 995 | if (!parentRegion) |
| 996 | return; |
| 997 | |
| 998 | IntPoint flowDelta; |
| 999 | m_owningLayer.convertToPixelSnappedLayerCoords(flowThreadLayer, flowDelta); |
mihnea@adobe.com | 3a87758 | 2014-10-09 06:34:46 +0000 | [diff] [blame] | 1000 | parentRegion->adjustRegionBoundsFromFlowThreadPortionRect(ancestorCompositingBounds); |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 1001 | RenderBoxModelObject& layerOwner = downcast<RenderBoxModelObject>(parentRegion->layerOwner()); |
commit-queue@webkit.org | 4affaa0 | 2014-01-23 14:19:54 +0000 | [diff] [blame] | 1002 | RenderLayerBacking* layerOwnerBacking = layerOwner.layer()->backing(); |
| 1003 | if (!layerOwnerBacking) |
| 1004 | return; |
| 1005 | |
| 1006 | // Make sure that the region propagates its borders, paddings, outlines or box-shadows to layers inside it. |
| 1007 | // Note that the composited bounds of the RenderRegion are already calculated because |
| 1008 | // RenderLayerCompositor::rebuildCompositingLayerTree will only iterate on the content of the region after the |
| 1009 | // region itself is computed. |
| 1010 | ancestorCompositingBounds.moveBy(roundedIntPoint(layerOwnerBacking->compositedBounds().location())); |
| 1011 | ancestorCompositingBounds.move(-layerOwner.borderAndPaddingStart(), -layerOwner.borderAndPaddingBefore()); |
| 1012 | |
| 1013 | // If there's a clipping GraphicsLayer on the hierarchy (region graphics layer -> clipping graphics layer -> |
| 1014 | // composited content graphics layer), substract the offset of the clipping layer, since it's its parent |
| 1015 | // that positions us (the graphics layer of the region). |
| 1016 | if (layerOwnerBacking->clippingLayer()) |
| 1017 | ancestorCompositingBounds.moveBy(roundedIntPoint(layerOwnerBacking->clippingLayer()->position())); |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 1018 | } |
| 1019 | } |
| 1020 | |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1021 | void RenderLayerBacking::updateDirectlyCompositedContents(bool isSimpleContainer, bool& didUpdateContentsRect) |
| 1022 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1023 | if (!m_owningLayer.hasVisibleContent()) |
commit-queue@webkit.org | 845ae1d | 2013-05-24 16:34:46 +0000 | [diff] [blame] | 1024 | return; |
| 1025 | |
noam.rosenthal@nokia.com | 0ffc780 | 2013-05-25 09:51:25 +0000 | [diff] [blame] | 1026 | // The order of operations here matters, since the last valid type of contents needs |
| 1027 | // to also update the contentsRect. |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1028 | updateDirectlyCompositedBackgroundColor(isSimpleContainer, didUpdateContentsRect); |
noam.rosenthal@nokia.com | 0ffc780 | 2013-05-25 09:51:25 +0000 | [diff] [blame] | 1029 | updateDirectlyCompositedBackgroundImage(isSimpleContainer, didUpdateContentsRect); |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1030 | } |
| 1031 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1032 | void RenderLayerBacking::updateInternalHierarchy() |
| 1033 | { |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 1034 | // m_foregroundLayer has to be inserted in the correct order with child layers, |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1035 | // so it's not inserted here. |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1036 | if (m_ancestorClippingLayer) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1037 | m_ancestorClippingLayer->removeAllChildren(); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1038 | |
| 1039 | if (m_contentsContainmentLayer) { |
| 1040 | m_contentsContainmentLayer->removeAllChildren(); |
| 1041 | if (m_ancestorClippingLayer) |
| 1042 | m_ancestorClippingLayer->addChild(m_contentsContainmentLayer.get()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1043 | } |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1044 | |
| 1045 | if (m_backgroundLayer) |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 1046 | m_contentsContainmentLayer->addChild(m_backgroundLayer.get()); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1047 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1048 | if (m_contentsContainmentLayer) |
| 1049 | m_contentsContainmentLayer->addChild(m_graphicsLayer.get()); |
| 1050 | else if (m_ancestorClippingLayer) |
| 1051 | m_ancestorClippingLayer->addChild(m_graphicsLayer.get()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1052 | |
simon.fraser@apple.com | 632ced1 | 2013-01-15 23:17:01 +0000 | [diff] [blame] | 1053 | if (m_childContainmentLayer) { |
| 1054 | m_childContainmentLayer->removeFromParent(); |
| 1055 | m_graphicsLayer->addChild(m_childContainmentLayer.get()); |
enne@google.com | 30eba0c | 2012-06-19 03:04:50 +0000 | [diff] [blame] | 1056 | } |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1057 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1058 | if (m_scrollingLayer) { |
simon.fraser@apple.com | 632ced1 | 2013-01-15 23:17:01 +0000 | [diff] [blame] | 1059 | GraphicsLayer* superlayer = m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsLayer.get(); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1060 | m_scrollingLayer->removeFromParent(); |
| 1061 | superlayer->addChild(m_scrollingLayer.get()); |
| 1062 | } |
| 1063 | |
enne@google.com | 30eba0c | 2012-06-19 03:04:50 +0000 | [diff] [blame] | 1064 | // The clip for child layers does not include space for overflow controls, so they exist as |
| 1065 | // siblings of the clipping layer if we have one. Normal children of this layer are set as |
| 1066 | // children of the clipping layer. |
| 1067 | if (m_layerForHorizontalScrollbar) { |
| 1068 | m_layerForHorizontalScrollbar->removeFromParent(); |
| 1069 | m_graphicsLayer->addChild(m_layerForHorizontalScrollbar.get()); |
| 1070 | } |
| 1071 | if (m_layerForVerticalScrollbar) { |
| 1072 | m_layerForVerticalScrollbar->removeFromParent(); |
| 1073 | m_graphicsLayer->addChild(m_layerForVerticalScrollbar.get()); |
| 1074 | } |
| 1075 | if (m_layerForScrollCorner) { |
| 1076 | m_layerForScrollCorner->removeFromParent(); |
| 1077 | m_graphicsLayer->addChild(m_layerForScrollCorner.get()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1078 | } |
| 1079 | } |
| 1080 | |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1081 | void RenderLayerBacking::resetContentsRect() |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1082 | { |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 1083 | m_graphicsLayer->setContentsRect(snappedIntRect(contentsBox())); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1084 | |
| 1085 | LayoutRect contentsClippingRect; |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1086 | if (is<RenderBox>(renderer())) |
| 1087 | contentsClippingRect = downcast<RenderBox>(renderer()).contentBoxRect(); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1088 | |
| 1089 | contentsClippingRect.move(contentOffsetInCompostingLayer()); |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 1090 | m_graphicsLayer->setContentsClippingRect(snappedIntRect(contentsClippingRect)); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1091 | |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1092 | m_graphicsLayer->setContentsTileSize(IntSize()); |
| 1093 | m_graphicsLayer->setContentsTilePhase(IntPoint()); |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1094 | } |
| 1095 | |
simon.fraser@apple.com | c0c558c | 2010-05-11 05:44:06 +0000 | [diff] [blame] | 1096 | void RenderLayerBacking::updateDrawsContent() |
| 1097 | { |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1098 | updateDrawsContent(isSimpleContainerCompositingLayer()); |
| 1099 | } |
| 1100 | |
| 1101 | void RenderLayerBacking::updateDrawsContent(bool isSimpleContainer) |
| 1102 | { |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1103 | if (m_scrollingLayer) { |
| 1104 | // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere. |
| 1105 | // m_graphicsLayer only needs backing store if the non-scrolling parts (background, outlines, borders, shadows etc) need to paint. |
| 1106 | // m_scrollingLayer never has backing store. |
| 1107 | // m_scrollingContentsLayer only needs backing store if the scrolled contents need to paint. |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1108 | bool hasNonScrollingPaintedContent = m_owningLayer.hasVisibleContent() && m_owningLayer.hasBoxDecorationsOrBackground(); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1109 | m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); |
| 1110 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1111 | bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() && (renderer().hasBackground() || paintsChildren()); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1112 | m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); |
| 1113 | return; |
| 1114 | } |
| 1115 | |
simon.fraser@apple.com | 9ca8cf7 | 2013-06-29 20:22:19 +0000 | [diff] [blame] | 1116 | bool hasPaintedContent = containsPaintedContent(isSimpleContainer); |
simon.fraser@apple.com | c0fc313 | 2012-04-18 16:17:04 +0000 | [diff] [blame] | 1117 | |
| 1118 | // FIXME: we could refine this to only allocate backing for one of these layers if possible. |
| 1119 | m_graphicsLayer->setDrawsContent(hasPaintedContent); |
| 1120 | if (m_foregroundLayer) |
| 1121 | m_foregroundLayer->setDrawsContent(hasPaintedContent); |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 1122 | |
| 1123 | if (m_backgroundLayer) |
| 1124 | m_backgroundLayer->setDrawsContent(hasPaintedContent); |
simon.fraser@apple.com | c0c558c | 2010-05-11 05:44:06 +0000 | [diff] [blame] | 1125 | } |
| 1126 | |
zalan@apple.com | c3d7218 | 2013-09-12 14:03:21 +0000 | [diff] [blame] | 1127 | // Return true if the layer changed. |
| 1128 | bool RenderLayerBacking::updateAncestorClippingLayer(bool needsAncestorClip) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1129 | { |
| 1130 | bool layersChanged = false; |
| 1131 | |
| 1132 | if (needsAncestorClip) { |
| 1133 | if (!m_ancestorClippingLayer) { |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 1134 | m_ancestorClippingLayer = createGraphicsLayer("Ancestor clipping Layer"); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1135 | m_ancestorClippingLayer->setMasksToBounds(true); |
| 1136 | layersChanged = true; |
| 1137 | } |
zalan@apple.com | c3d7218 | 2013-09-12 14:03:21 +0000 | [diff] [blame] | 1138 | } else if (hasAncestorClippingLayer()) { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1139 | willDestroyLayer(m_ancestorClippingLayer.get()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1140 | m_ancestorClippingLayer->removeFromParent(); |
abarth@webkit.org | 462d90a | 2011-04-27 21:25:22 +0000 | [diff] [blame] | 1141 | m_ancestorClippingLayer = nullptr; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1142 | layersChanged = true; |
| 1143 | } |
| 1144 | |
zalan@apple.com | c3d7218 | 2013-09-12 14:03:21 +0000 | [diff] [blame] | 1145 | return layersChanged; |
| 1146 | } |
| 1147 | |
| 1148 | // Return true if the layer changed. |
| 1149 | bool RenderLayerBacking::updateDescendantClippingLayer(bool needsDescendantClip) |
| 1150 | { |
| 1151 | bool layersChanged = false; |
| 1152 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1153 | if (needsDescendantClip) { |
simon.fraser@apple.com | 632ced1 | 2013-01-15 23:17:01 +0000 | [diff] [blame] | 1154 | if (!m_childContainmentLayer && !m_usingTiledCacheLayer) { |
| 1155 | m_childContainmentLayer = createGraphicsLayer("Child clipping Layer"); |
| 1156 | m_childContainmentLayer->setMasksToBounds(true); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1157 | layersChanged = true; |
| 1158 | } |
dino@apple.com | eebfa906 | 2012-07-09 20:36:21 +0000 | [diff] [blame] | 1159 | } else if (hasClippingLayer()) { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1160 | willDestroyLayer(m_childContainmentLayer.get()); |
simon.fraser@apple.com | 632ced1 | 2013-01-15 23:17:01 +0000 | [diff] [blame] | 1161 | m_childContainmentLayer->removeFromParent(); |
| 1162 | m_childContainmentLayer = nullptr; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1163 | layersChanged = true; |
| 1164 | } |
| 1165 | |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1166 | return layersChanged; |
| 1167 | } |
| 1168 | |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 1169 | void RenderLayerBacking::setBackgroundLayerPaintsFixedRootBackground(bool backgroundLayerPaintsFixedRootBackground) |
| 1170 | { |
| 1171 | m_backgroundLayerPaintsFixedRootBackground = backgroundLayerPaintsFixedRootBackground; |
| 1172 | } |
| 1173 | |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1174 | bool RenderLayerBacking::requiresHorizontalScrollbarLayer() const |
| 1175 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1176 | if (!m_owningLayer.hasOverlayScrollbars() && !m_owningLayer.needsCompositedScrolling()) |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1177 | return false; |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1178 | return m_owningLayer.horizontalScrollbar(); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | bool RenderLayerBacking::requiresVerticalScrollbarLayer() const |
| 1182 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1183 | if (!m_owningLayer.hasOverlayScrollbars() && !m_owningLayer.needsCompositedScrolling()) |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1184 | return false; |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1185 | return m_owningLayer.verticalScrollbar(); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | bool RenderLayerBacking::requiresScrollCornerLayer() const |
| 1189 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1190 | if (!m_owningLayer.hasOverlayScrollbars() && !m_owningLayer.needsCompositedScrolling()) |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1191 | return false; |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1192 | return !m_owningLayer.scrollCornerAndResizerRect().isEmpty(); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | bool RenderLayerBacking::updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool needsVerticalScrollbarLayer, bool needsScrollCornerLayer) |
| 1196 | { |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1197 | bool horizontalScrollbarLayerChanged = false; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1198 | if (needsHorizontalScrollbarLayer) { |
| 1199 | if (!m_layerForHorizontalScrollbar) { |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 1200 | m_layerForHorizontalScrollbar = createGraphicsLayer("horizontal scrollbar"); |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1201 | horizontalScrollbarLayerChanged = true; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1202 | } |
| 1203 | } else if (m_layerForHorizontalScrollbar) { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1204 | willDestroyLayer(m_layerForHorizontalScrollbar.get()); |
| 1205 | m_layerForHorizontalScrollbar = nullptr; |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1206 | horizontalScrollbarLayerChanged = true; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1207 | } |
| 1208 | |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1209 | bool verticalScrollbarLayerChanged = false; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1210 | if (needsVerticalScrollbarLayer) { |
| 1211 | if (!m_layerForVerticalScrollbar) { |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 1212 | m_layerForVerticalScrollbar = createGraphicsLayer("vertical scrollbar"); |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1213 | verticalScrollbarLayerChanged = true; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1214 | } |
| 1215 | } else if (m_layerForVerticalScrollbar) { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1216 | willDestroyLayer(m_layerForVerticalScrollbar.get()); |
| 1217 | m_layerForVerticalScrollbar = nullptr; |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1218 | verticalScrollbarLayerChanged = true; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1219 | } |
| 1220 | |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1221 | bool scrollCornerLayerChanged = false; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1222 | if (needsScrollCornerLayer) { |
| 1223 | if (!m_layerForScrollCorner) { |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 1224 | m_layerForScrollCorner = createGraphicsLayer("scroll corner"); |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1225 | scrollCornerLayerChanged = true; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1226 | } |
| 1227 | } else if (m_layerForScrollCorner) { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1228 | willDestroyLayer(m_layerForScrollCorner.get()); |
| 1229 | m_layerForScrollCorner = nullptr; |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1230 | scrollCornerLayerChanged = true; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 1231 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1232 | |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1233 | if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer)) { |
| 1234 | if (horizontalScrollbarLayerChanged) |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1235 | scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(&m_owningLayer, HorizontalScrollbar); |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1236 | if (verticalScrollbarLayerChanged) |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1237 | scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(&m_owningLayer, VerticalScrollbar); |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | return horizontalScrollbarLayerChanged || verticalScrollbarLayerChanged || scrollCornerLayerChanged; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1241 | } |
| 1242 | |
simon.fraser@apple.com | 1c06cdd | 2013-11-12 00:50:29 +0000 | [diff] [blame] | 1243 | void RenderLayerBacking::positionOverflowControlsLayers() |
simon.fraser@apple.com | 4030b0a | 2012-09-08 00:48:40 +0000 | [diff] [blame] | 1244 | { |
simon.fraser@apple.com | 1c06cdd | 2013-11-12 00:50:29 +0000 | [diff] [blame] | 1245 | if (!m_owningLayer.hasScrollbars()) |
| 1246 | return; |
| 1247 | |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1248 | const IntRect borderBox = downcast<RenderBox>(renderer()).pixelSnappedBorderBoxRect(); |
simon.fraser@apple.com | 1c06cdd | 2013-11-12 00:50:29 +0000 | [diff] [blame] | 1249 | |
zalan@apple.com | 545c48a | 2014-02-20 05:02:37 +0000 | [diff] [blame] | 1250 | FloatSize offsetFromRenderer = m_graphicsLayer->offsetFromRenderer(); |
simon.fraser@apple.com | 4030b0a | 2012-09-08 00:48:40 +0000 | [diff] [blame] | 1251 | if (GraphicsLayer* layer = layerForHorizontalScrollbar()) { |
simon.fraser@apple.com | 1c06cdd | 2013-11-12 00:50:29 +0000 | [diff] [blame] | 1252 | IntRect hBarRect = m_owningLayer.rectForHorizontalScrollbar(borderBox); |
| 1253 | layer->setPosition(hBarRect.location() - offsetFromRenderer); |
| 1254 | layer->setSize(hBarRect.size()); |
simon.fraser@apple.com | ff54931 | 2014-04-19 05:31:39 +0000 | [diff] [blame] | 1255 | if (layer->usesContentsLayer()) { |
simon.fraser@apple.com | 1c06cdd | 2013-11-12 00:50:29 +0000 | [diff] [blame] | 1256 | IntRect barRect = IntRect(IntPoint(), hBarRect.size()); |
| 1257 | layer->setContentsRect(barRect); |
| 1258 | layer->setContentsClippingRect(barRect); |
simon.fraser@apple.com | 4030b0a | 2012-09-08 00:48:40 +0000 | [diff] [blame] | 1259 | } |
simon.fraser@apple.com | ff54931 | 2014-04-19 05:31:39 +0000 | [diff] [blame] | 1260 | layer->setDrawsContent(m_owningLayer.horizontalScrollbar() && !layer->usesContentsLayer()); |
simon.fraser@apple.com | 4030b0a | 2012-09-08 00:48:40 +0000 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | if (GraphicsLayer* layer = layerForVerticalScrollbar()) { |
simon.fraser@apple.com | 1c06cdd | 2013-11-12 00:50:29 +0000 | [diff] [blame] | 1264 | IntRect vBarRect = m_owningLayer.rectForVerticalScrollbar(borderBox); |
| 1265 | layer->setPosition(vBarRect.location() - offsetFromRenderer); |
| 1266 | layer->setSize(vBarRect.size()); |
simon.fraser@apple.com | ff54931 | 2014-04-19 05:31:39 +0000 | [diff] [blame] | 1267 | if (layer->usesContentsLayer()) { |
simon.fraser@apple.com | 1c06cdd | 2013-11-12 00:50:29 +0000 | [diff] [blame] | 1268 | IntRect barRect = IntRect(IntPoint(), vBarRect.size()); |
| 1269 | layer->setContentsRect(barRect); |
| 1270 | layer->setContentsClippingRect(barRect); |
simon.fraser@apple.com | 4030b0a | 2012-09-08 00:48:40 +0000 | [diff] [blame] | 1271 | } |
simon.fraser@apple.com | ff54931 | 2014-04-19 05:31:39 +0000 | [diff] [blame] | 1272 | layer->setDrawsContent(m_owningLayer.verticalScrollbar() && !layer->usesContentsLayer()); |
simon.fraser@apple.com | 4030b0a | 2012-09-08 00:48:40 +0000 | [diff] [blame] | 1273 | } |
| 1274 | |
| 1275 | if (GraphicsLayer* layer = layerForScrollCorner()) { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1276 | const LayoutRect& scrollCornerAndResizer = m_owningLayer.scrollCornerAndResizerRect(); |
simon.fraser@apple.com | 4030b0a | 2012-09-08 00:48:40 +0000 | [diff] [blame] | 1277 | layer->setPosition(scrollCornerAndResizer.location() - offsetFromRenderer); |
| 1278 | layer->setSize(scrollCornerAndResizer.size()); |
| 1279 | layer->setDrawsContent(!scrollCornerAndResizer.isEmpty()); |
| 1280 | } |
| 1281 | } |
| 1282 | |
vollick@chromium.org | 013915f | 2012-12-16 02:07:57 +0000 | [diff] [blame] | 1283 | bool RenderLayerBacking::hasUnpositionedOverflowControlsLayers() const |
| 1284 | { |
| 1285 | if (GraphicsLayer* layer = layerForHorizontalScrollbar()) |
| 1286 | if (!layer->drawsContent()) |
| 1287 | return true; |
| 1288 | |
| 1289 | if (GraphicsLayer* layer = layerForVerticalScrollbar()) |
| 1290 | if (!layer->drawsContent()) |
| 1291 | return true; |
| 1292 | |
| 1293 | if (GraphicsLayer* layer = layerForScrollCorner()) |
| 1294 | if (!layer->drawsContent()) |
| 1295 | return true; |
| 1296 | |
| 1297 | return false; |
| 1298 | } |
| 1299 | |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 1300 | bool RenderLayerBacking::updateForegroundLayer(bool needsForegroundLayer) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1301 | { |
| 1302 | bool layerChanged = false; |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 1303 | if (needsForegroundLayer) { |
| 1304 | if (!m_foregroundLayer) { |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 1305 | String layerName; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1306 | #ifndef NDEBUG |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1307 | layerName = m_owningLayer.name() + " (foreground)"; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1308 | #endif |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 1309 | m_foregroundLayer = createGraphicsLayer(layerName); |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 1310 | m_foregroundLayer->setDrawsContent(true); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1311 | m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1312 | layerChanged = true; |
| 1313 | } |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 1314 | } else if (m_foregroundLayer) { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1315 | willDestroyLayer(m_foregroundLayer.get()); |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 1316 | m_foregroundLayer->removeFromParent(); |
abarth@webkit.org | 462d90a | 2011-04-27 21:25:22 +0000 | [diff] [blame] | 1317 | m_foregroundLayer = nullptr; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1318 | layerChanged = true; |
| 1319 | } |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1320 | |
simon.fraser@apple.com | 6c21fd5 | 2013-05-16 23:57:46 +0000 | [diff] [blame] | 1321 | if (layerChanged) { |
| 1322 | m_graphicsLayer->setNeedsDisplay(); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1323 | m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer()); |
simon.fraser@apple.com | 6c21fd5 | 2013-05-16 23:57:46 +0000 | [diff] [blame] | 1324 | } |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1325 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1326 | return layerChanged; |
| 1327 | } |
| 1328 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1329 | bool RenderLayerBacking::updateBackgroundLayer(bool needsBackgroundLayer) |
| 1330 | { |
| 1331 | bool layerChanged = false; |
| 1332 | if (needsBackgroundLayer) { |
| 1333 | if (!m_backgroundLayer) { |
| 1334 | String layerName; |
| 1335 | #ifndef NDEBUG |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1336 | layerName = m_owningLayer.name() + " (background)"; |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1337 | #endif |
| 1338 | m_backgroundLayer = createGraphicsLayer(layerName); |
| 1339 | m_backgroundLayer->setDrawsContent(true); |
| 1340 | m_backgroundLayer->setAnchorPoint(FloatPoint3D()); |
| 1341 | m_backgroundLayer->setPaintingPhase(GraphicsLayerPaintBackground); |
| 1342 | layerChanged = true; |
| 1343 | } |
| 1344 | |
| 1345 | if (!m_contentsContainmentLayer) { |
| 1346 | String layerName; |
| 1347 | #ifndef NDEBUG |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1348 | layerName = m_owningLayer.name() + " (contents containment)"; |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1349 | #endif |
| 1350 | m_contentsContainmentLayer = createGraphicsLayer(layerName); |
| 1351 | m_contentsContainmentLayer->setAppliesPageScale(true); |
| 1352 | m_graphicsLayer->setAppliesPageScale(false); |
| 1353 | layerChanged = true; |
| 1354 | } |
| 1355 | } else { |
| 1356 | if (m_backgroundLayer) { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1357 | willDestroyLayer(m_backgroundLayer.get()); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1358 | m_backgroundLayer->removeFromParent(); |
| 1359 | m_backgroundLayer = nullptr; |
| 1360 | layerChanged = true; |
| 1361 | } |
| 1362 | if (m_contentsContainmentLayer) { |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1363 | willDestroyLayer(m_contentsContainmentLayer.get()); |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1364 | m_contentsContainmentLayer->removeFromParent(); |
| 1365 | m_contentsContainmentLayer = nullptr; |
| 1366 | layerChanged = true; |
| 1367 | m_graphicsLayer->setAppliesPageScale(true); |
| 1368 | } |
| 1369 | } |
simon.fraser@apple.com | a561496 | 2013-01-19 01:20:32 +0000 | [diff] [blame] | 1370 | |
| 1371 | if (layerChanged) { |
simon.fraser@apple.com | 6c21fd5 | 2013-05-16 23:57:46 +0000 | [diff] [blame] | 1372 | m_graphicsLayer->setNeedsDisplay(); |
simon.fraser@apple.com | a561496 | 2013-01-19 01:20:32 +0000 | [diff] [blame] | 1373 | // This assumes that the background layer is only used for fixed backgrounds, which is currently a correct assumption. |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 1374 | compositor().fixedRootBackgroundLayerChanged(); |
simon.fraser@apple.com | a561496 | 2013-01-19 01:20:32 +0000 | [diff] [blame] | 1375 | } |
| 1376 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1377 | return layerChanged; |
| 1378 | } |
| 1379 | |
simon.fraser@apple.com | 0749dee | 2014-06-20 20:56:16 +0000 | [diff] [blame] | 1380 | void RenderLayerBacking::updateMaskLayer(bool needsMaskLayer) |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1381 | { |
| 1382 | bool layerChanged = false; |
| 1383 | if (needsMaskLayer) { |
| 1384 | if (!m_maskLayer) { |
simon.fraser@apple.com | ec22321 | 2011-07-13 21:57:57 +0000 | [diff] [blame] | 1385 | m_maskLayer = createGraphicsLayer("Mask"); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1386 | m_maskLayer->setDrawsContent(true); |
| 1387 | m_maskLayer->setPaintingPhase(GraphicsLayerPaintMask); |
| 1388 | layerChanged = true; |
simon.fraser@apple.com | 0749dee | 2014-06-20 20:56:16 +0000 | [diff] [blame] | 1389 | m_graphicsLayer->setMaskLayer(m_maskLayer.get()); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1390 | } |
| 1391 | } else if (m_maskLayer) { |
simon.fraser@apple.com | 0749dee | 2014-06-20 20:56:16 +0000 | [diff] [blame] | 1392 | m_graphicsLayer->setMaskLayer(nullptr); |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1393 | willDestroyLayer(m_maskLayer.get()); |
abarth@webkit.org | 462d90a | 2011-04-27 21:25:22 +0000 | [diff] [blame] | 1394 | m_maskLayer = nullptr; |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1395 | layerChanged = true; |
| 1396 | } |
| 1397 | |
| 1398 | if (layerChanged) |
| 1399 | m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer()); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1400 | } |
| 1401 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1402 | bool RenderLayerBacking::updateScrollingLayers(bool needsScrollingLayers) |
| 1403 | { |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 1404 | if (needsScrollingLayers == !!m_scrollingLayer) |
| 1405 | return false; |
commit-queue@webkit.org | b93f5c8 | 2013-02-26 09:13:32 +0000 | [diff] [blame] | 1406 | |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 1407 | if (!m_scrollingLayer) { |
| 1408 | // Outer layer which corresponds with the scroll view. |
| 1409 | m_scrollingLayer = createGraphicsLayer("Scrolling container"); |
| 1410 | m_scrollingLayer->setDrawsContent(false); |
| 1411 | m_scrollingLayer->setMasksToBounds(true); |
simon.fraser@apple.com | 405bbce1 | 2014-03-26 19:36:49 +0000 | [diff] [blame] | 1412 | #if PLATFORM(IOS) |
| 1413 | m_scrollingLayer->setCustomBehavior(GraphicsLayer::CustomScrollingBehavior); |
| 1414 | #endif |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 1415 | // Inner layer which renders the content that scrolls. |
| 1416 | m_scrollingContentsLayer = createGraphicsLayer("Scrolled Contents"); |
| 1417 | m_scrollingContentsLayer->setDrawsContent(true); |
simon.fraser@apple.com | 523dffe | 2014-05-07 21:49:10 +0000 | [diff] [blame] | 1418 | #if PLATFORM(IOS) |
| 1419 | m_scrollingContentsLayer->setCustomBehavior(GraphicsLayer::CustomScrolledContentsBehavior); |
| 1420 | #endif |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 1421 | GraphicsLayerPaintingPhase paintPhase = GraphicsLayerPaintOverflowContents | GraphicsLayerPaintCompositedScroll; |
| 1422 | if (!m_foregroundLayer) |
| 1423 | paintPhase |= GraphicsLayerPaintForeground; |
| 1424 | m_scrollingContentsLayer->setPaintingPhase(paintPhase); |
| 1425 | m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); |
| 1426 | } else { |
jhoneycutt@apple.com | 84b8a85 | 2014-07-03 04:25:27 +0000 | [diff] [blame] | 1427 | compositor().willRemoveScrollingLayerWithBacking(m_owningLayer, *this); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1428 | |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 1429 | willDestroyLayer(m_scrollingLayer.get()); |
| 1430 | willDestroyLayer(m_scrollingContentsLayer.get()); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1431 | m_scrollingLayer = nullptr; |
| 1432 | m_scrollingContentsLayer = nullptr; |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1433 | } |
| 1434 | |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 1435 | m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer()); |
| 1436 | m_graphicsLayer->setNeedsDisplay(); // Because painting phases changed. |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1437 | |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 1438 | if (m_scrollingLayer) |
| 1439 | compositor().didAddScrollingLayer(m_owningLayer); |
| 1440 | |
| 1441 | return true; |
bdakin@apple.com | 0643c9f | 2012-10-09 18:47:49 +0000 | [diff] [blame] | 1442 | } |
| 1443 | |
| 1444 | void RenderLayerBacking::detachFromScrollingCoordinator() |
| 1445 | { |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 1446 | if (!m_scrollingNodeID && !m_viewportConstrainedNodeID) |
bdakin@apple.com | 0643c9f | 2012-10-09 18:47:49 +0000 | [diff] [blame] | 1447 | return; |
| 1448 | |
simon.fraser@apple.com | e6ad1f6 | 2013-01-15 23:46:18 +0000 | [diff] [blame] | 1449 | ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer); |
bdakin@apple.com | 0643c9f | 2012-10-09 18:47:49 +0000 | [diff] [blame] | 1450 | if (!scrollingCoordinator) |
| 1451 | return; |
| 1452 | |
simon.fraser@apple.com | 2cd0f45 | 2014-02-27 01:04:23 +0000 | [diff] [blame] | 1453 | if (m_scrollingNodeID) |
| 1454 | scrollingCoordinator->detachFromStateTree(m_scrollingNodeID); |
| 1455 | |
| 1456 | if (m_viewportConstrainedNodeID) |
| 1457 | scrollingCoordinator->detachFromStateTree(m_viewportConstrainedNodeID); |
| 1458 | |
| 1459 | m_scrollingNodeID = 0; |
| 1460 | m_viewportConstrainedNodeID = 0; |
bdakin@apple.com | 0643c9f | 2012-10-09 18:47:49 +0000 | [diff] [blame] | 1461 | } |
| 1462 | |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1463 | GraphicsLayerPaintingPhase RenderLayerBacking::paintingPhaseForPrimaryLayer() const |
| 1464 | { |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 1465 | unsigned phase = 0; |
| 1466 | if (!m_backgroundLayer) |
| 1467 | phase |= GraphicsLayerPaintBackground; |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1468 | if (!m_foregroundLayer) |
| 1469 | phase |= GraphicsLayerPaintForeground; |
| 1470 | if (!m_maskLayer) |
| 1471 | phase |= GraphicsLayerPaintMask; |
| 1472 | |
vollick@chromium.org | 0015c12 | 2013-03-07 14:00:57 +0000 | [diff] [blame] | 1473 | if (m_scrollingContentsLayer) { |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1474 | phase &= ~GraphicsLayerPaintForeground; |
vollick@chromium.org | 0015c12 | 2013-03-07 14:00:57 +0000 | [diff] [blame] | 1475 | phase |= GraphicsLayerPaintCompositedScroll; |
| 1476 | } |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1477 | |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 1478 | return static_cast<GraphicsLayerPaintingPhase>(phase); |
| 1479 | } |
| 1480 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1481 | float RenderLayerBacking::compositingOpacity(float rendererOpacity) const |
| 1482 | { |
| 1483 | float finalOpacity = rendererOpacity; |
| 1484 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1485 | for (RenderLayer* curr = m_owningLayer.parent(); curr; curr = curr->parent()) { |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1486 | // We only care about parents that are stacking contexts. |
| 1487 | // Recall that opacity creates stacking context. |
vollick@chromium.org | 04ba77c | 2013-01-24 01:42:08 +0000 | [diff] [blame] | 1488 | if (!curr->isStackingContainer()) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1489 | continue; |
| 1490 | |
| 1491 | // If we found a compositing layer, we want to compute opacity |
| 1492 | // relative to it. So we can break here. |
| 1493 | if (curr->isComposited()) |
| 1494 | break; |
| 1495 | |
akling@apple.com | c34ed27 | 2013-08-26 01:02:34 +0000 | [diff] [blame] | 1496 | finalOpacity *= curr->renderer().opacity(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1497 | } |
| 1498 | |
| 1499 | return finalOpacity; |
| 1500 | } |
| 1501 | |
simon.fraser@apple.com | e6e085e | 2014-09-02 18:30:06 +0000 | [diff] [blame] | 1502 | // FIXME: Code is duplicated in RenderLayer. Also, we should probably not consider filters a box decoration here. |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1503 | static inline bool hasBoxDecorations(const RenderStyle& style) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1504 | { |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1505 | return style.hasBorder() || style.hasBorderRadius() || style.hasOutline() || style.hasAppearance() || style.boxShadow() || style.hasFilter(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1506 | } |
| 1507 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1508 | static bool canCreateTiledImage(const RenderStyle& style) |
| 1509 | { |
| 1510 | const FillLayer* fillLayer = style.backgroundLayers(); |
| 1511 | if (fillLayer->next()) |
| 1512 | return false; |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1513 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1514 | if (!fillLayer->imagesAreLoaded()) |
| 1515 | return false; |
| 1516 | |
| 1517 | if (fillLayer->attachment() != ScrollBackgroundAttachment) |
| 1518 | return false; |
| 1519 | |
| 1520 | Color color = style.visitedDependentColor(CSSPropertyBackgroundColor); |
| 1521 | |
| 1522 | // FIXME: Allow color+image compositing when it makes sense. |
| 1523 | // For now bailing out. |
| 1524 | if (color.isValid() && color.alpha()) |
| 1525 | return false; |
| 1526 | |
| 1527 | StyleImage* styleImage = fillLayer->image(); |
| 1528 | |
| 1529 | // FIXME: support gradients with isGeneratedImage. |
| 1530 | if (!styleImage->isCachedImage()) |
| 1531 | return false; |
| 1532 | |
| 1533 | Image* image = styleImage->cachedImage()->image(); |
| 1534 | if (!image->isBitmapImage()) |
| 1535 | return false; |
| 1536 | |
| 1537 | return true; |
| 1538 | } |
| 1539 | |
| 1540 | static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle& style) |
simon.fraser@apple.com | 3368e1c | 2009-03-27 01:12:01 +0000 | [diff] [blame] | 1541 | { |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1542 | if (hasBoxDecorations(style)) |
| 1543 | return true; |
| 1544 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1545 | if (!style.hasBackgroundImage()) |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1546 | return false; |
| 1547 | |
| 1548 | return !GraphicsLayer::supportsContentsTiling() || !canCreateTiledImage(style); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1549 | } |
| 1550 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1551 | static inline bool hasPerspectiveOrPreserves3D(const RenderStyle& style) |
dino@apple.com | b0b80c0 | 2013-08-03 00:06:31 +0000 | [diff] [blame] | 1552 | { |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1553 | return style.hasPerspective() || style.preserves3D(); |
dino@apple.com | b0b80c0 | 2013-08-03 00:06:31 +0000 | [diff] [blame] | 1554 | } |
| 1555 | |
andreas.kling@nokia.com | 8bdba597 | 2011-10-07 16:42:54 +0000 | [diff] [blame] | 1556 | Color RenderLayerBacking::rendererBackgroundColor() const |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1557 | { |
akling@apple.com | 227f10f | 2013-12-14 12:39:40 +0000 | [diff] [blame] | 1558 | const auto& backgroundRenderer = renderer().isRoot() ? renderer().rendererForRootBackground() : renderer(); |
| 1559 | return backgroundRenderer.style().visitedDependentColor(CSSPropertyBackgroundColor); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1560 | } |
| 1561 | |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1562 | void RenderLayerBacking::updateDirectlyCompositedBackgroundColor(bool isSimpleContainer, bool& didUpdateContentsRect) |
jer.noble@apple.com | 3352b63 | 2011-06-13 18:02:13 +0000 | [diff] [blame] | 1563 | { |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1564 | if (!isSimpleContainer) { |
| 1565 | m_graphicsLayer->setContentsToSolidColor(Color()); |
| 1566 | return; |
| 1567 | } |
| 1568 | |
| 1569 | Color backgroundColor = rendererBackgroundColor(); |
simon.fraser@apple.com | fdfcc11 | 2012-12-15 19:11:44 +0000 | [diff] [blame] | 1570 | |
| 1571 | // An unset (invalid) color will remove the solid color. |
| 1572 | m_graphicsLayer->setContentsToSolidColor(backgroundColor); |
zalan@apple.com | 5b735c0 | 2014-03-09 00:14:00 +0000 | [diff] [blame] | 1573 | FloatRect contentsRect = backgroundBoxForPainting(); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1574 | m_graphicsLayer->setContentsRect(contentsRect); |
| 1575 | m_graphicsLayer->setContentsClippingRect(contentsRect); |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1576 | didUpdateContentsRect = true; |
| 1577 | } |
| 1578 | |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1579 | void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(bool isSimpleContainer, bool& didUpdateContentsRect) |
| 1580 | { |
| 1581 | if (!GraphicsLayer::supportsContentsTiling()) |
| 1582 | return; |
| 1583 | |
commit-queue@webkit.org | a68a54b | 2013-04-19 16:01:25 +0000 | [diff] [blame] | 1584 | if (isDirectlyCompositedImage()) |
| 1585 | return; |
| 1586 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1587 | const RenderStyle& style = renderer().style(); |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1588 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1589 | if (!isSimpleContainer || !style.hasBackgroundImage()) { |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1590 | m_graphicsLayer->setContentsToImage(0); |
| 1591 | return; |
| 1592 | } |
| 1593 | |
zalan@apple.com | aa00cbd | 2014-04-04 16:30:18 +0000 | [diff] [blame] | 1594 | FloatRect destRect = backgroundBoxForPainting(); |
| 1595 | FloatPoint phase; |
| 1596 | FloatSize tileSize; |
commit-queue@webkit.org | 845ae1d | 2013-05-24 16:34:46 +0000 | [diff] [blame] | 1597 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1598 | RefPtr<Image> image = style.backgroundLayers()->image()->cachedImage()->image(); |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1599 | downcast<RenderBox>(renderer()).getGeometryForBackgroundImage(&renderer(), destRect, phase, tileSize); |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1600 | m_graphicsLayer->setContentsTileSize(tileSize); |
| 1601 | m_graphicsLayer->setContentsTilePhase(phase); |
| 1602 | m_graphicsLayer->setContentsRect(destRect); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1603 | m_graphicsLayer->setContentsClippingRect(destRect); |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1604 | m_graphicsLayer->setContentsToImage(image.get()); |
| 1605 | didUpdateContentsRect = true; |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1606 | } |
| 1607 | |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 1608 | void RenderLayerBacking::updateRootLayerConfiguration() |
| 1609 | { |
| 1610 | if (!m_usingTiledCacheLayer) |
| 1611 | return; |
| 1612 | |
| 1613 | Color backgroundColor; |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 1614 | bool viewIsTransparent = compositor().viewHasTransparentBackground(&backgroundColor); |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 1615 | |
| 1616 | if (m_backgroundLayerPaintsFixedRootBackground && m_backgroundLayer) { |
| 1617 | m_backgroundLayer->setBackgroundColor(backgroundColor); |
| 1618 | m_backgroundLayer->setContentsOpaque(!viewIsTransparent); |
| 1619 | |
| 1620 | m_graphicsLayer->setBackgroundColor(Color()); |
| 1621 | m_graphicsLayer->setContentsOpaque(false); |
| 1622 | } else { |
| 1623 | m_graphicsLayer->setBackgroundColor(backgroundColor); |
| 1624 | m_graphicsLayer->setContentsOpaque(!viewIsTransparent); |
| 1625 | } |
| 1626 | } |
| 1627 | |
akling@apple.com | ac253b1 | 2013-12-26 17:58:56 +0000 | [diff] [blame] | 1628 | static bool supportsDirectBoxDecorationsComposition(const RenderLayerModelObject& renderer) |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1629 | { |
| 1630 | if (!GraphicsLayer::supportsBackgroundColorContent()) |
| 1631 | return false; |
| 1632 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1633 | const RenderStyle& style = renderer.style(); |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 1634 | if (renderer.hasClip()) |
commit-queue@webkit.org | 38aff560 | 2012-12-11 06:44:15 +0000 | [diff] [blame] | 1635 | return false; |
| 1636 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1637 | if (hasBoxDecorationsOrBackgroundImage(style)) |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1638 | return false; |
| 1639 | |
dino@apple.com | b0b80c0 | 2013-08-03 00:06:31 +0000 | [diff] [blame] | 1640 | // FIXME: We can't create a directly composited background if this |
| 1641 | // layer will have children that intersect with the background layer. |
| 1642 | // A better solution might be to introduce a flattening layer if |
| 1643 | // we do direct box decoration composition. |
| 1644 | // https://bugs.webkit.org/show_bug.cgi?id=119461 |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1645 | if (hasPerspectiveOrPreserves3D(style)) |
dino@apple.com | b0b80c0 | 2013-08-03 00:06:31 +0000 | [diff] [blame] | 1646 | return false; |
| 1647 | |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1648 | // FIXME: we should be able to allow backgroundComposite; However since this is not a common use case it has been deferred for now. |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1649 | if (style.backgroundComposite() != CompositeSourceOver) |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1650 | return false; |
| 1651 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1652 | if (style.backgroundClip() == TextFillBox) |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1653 | return false; |
| 1654 | |
| 1655 | return true; |
jer.noble@apple.com | 3352b63 | 2011-06-13 18:02:13 +0000 | [diff] [blame] | 1656 | } |
| 1657 | |
simon.fraser@apple.com | 7cfe761 | 2012-03-13 20:59:59 +0000 | [diff] [blame] | 1658 | bool RenderLayerBacking::paintsBoxDecorations() const |
| 1659 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1660 | if (!m_owningLayer.hasVisibleBoxDecorations()) |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1661 | return false; |
| 1662 | |
| 1663 | if (!supportsDirectBoxDecorationsComposition(renderer())) |
simon.fraser@apple.com | 7cfe761 | 2012-03-13 20:59:59 +0000 | [diff] [blame] | 1664 | return true; |
| 1665 | |
simon.fraser@apple.com | 7cfe761 | 2012-03-13 20:59:59 +0000 | [diff] [blame] | 1666 | return false; |
| 1667 | } |
| 1668 | |
| 1669 | bool RenderLayerBacking::paintsChildren() const |
| 1670 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1671 | if (m_owningLayer.hasVisibleContent() && m_owningLayer.hasNonEmptyChildRenderers()) |
simon.fraser@apple.com | 7cfe761 | 2012-03-13 20:59:59 +0000 | [diff] [blame] | 1672 | return true; |
commit-queue@webkit.org | 845ae1d | 2013-05-24 16:34:46 +0000 | [diff] [blame] | 1673 | |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 1674 | if (isPaintDestinationForDescendentLayers()) |
simon.fraser@apple.com | 7cfe761 | 2012-03-13 20:59:59 +0000 | [diff] [blame] | 1675 | return true; |
| 1676 | |
| 1677 | return false; |
| 1678 | } |
| 1679 | |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1680 | static bool isRestartedPlugin(RenderObject& renderer) |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 1681 | { |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1682 | if (!is<RenderEmbeddedObject>(renderer)) |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 1683 | return false; |
| 1684 | |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1685 | HTMLFrameOwnerElement& element = downcast<RenderEmbeddedObject>(renderer).frameOwnerElement(); |
cdumez@apple.com | a9c60c9 | 2014-10-02 19:39:41 +0000 | [diff] [blame] | 1686 | if (!is<HTMLPlugInElement>(element)) |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 1687 | return false; |
| 1688 | |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1689 | return downcast<HTMLPlugInElement>(element).isRestartedPlugin(); |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 1690 | } |
| 1691 | |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1692 | static bool isCompositedPlugin(RenderObject& renderer) |
simon.fraser@apple.com | 25a526b | 2012-08-08 22:17:34 +0000 | [diff] [blame] | 1693 | { |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1694 | return is<RenderEmbeddedObject>(renderer) && downcast<RenderEmbeddedObject>(renderer).allowsAcceleratedCompositing(); |
simon.fraser@apple.com | 25a526b | 2012-08-08 22:17:34 +0000 | [diff] [blame] | 1695 | } |
| 1696 | |
simon.fraser@apple.com | 699dc0b | 2009-04-07 17:45:00 +0000 | [diff] [blame] | 1697 | // A "simple container layer" is a RenderLayer which has no visible content to render. |
| 1698 | // It may have no children, or all its children may be themselves composited. |
| 1699 | // This is a useful optimization, because it allows us to avoid allocating backing store. |
| 1700 | bool RenderLayerBacking::isSimpleContainerCompositingLayer() const |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1701 | { |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1702 | if (renderer().isRenderReplaced() && (!isCompositedPlugin(renderer()) || isRestartedPlugin(renderer()))) |
simon.fraser@apple.com | 90b35d8 | 2013-01-29 04:16:56 +0000 | [diff] [blame] | 1703 | return false; |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 1704 | |
simon.fraser@apple.com | 7cfe761 | 2012-03-13 20:59:59 +0000 | [diff] [blame] | 1705 | if (paintsBoxDecorations() || paintsChildren()) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1706 | return false; |
mihnea@adobe.com | a8c9577 | 2013-02-15 13:00:03 +0000 | [diff] [blame] | 1707 | |
commit-queue@webkit.org | 83e1948 | 2013-10-21 19:38:30 +0000 | [diff] [blame] | 1708 | if (renderer().isRenderNamedFlowFragmentContainer()) |
mihnea@adobe.com | a8c9577 | 2013-02-15 13:00:03 +0000 | [diff] [blame] | 1709 | return false; |
| 1710 | |
rosca@adobe.com | 43145d5 | 2014-09-23 07:47:21 +0000 | [diff] [blame] | 1711 | if (renderer().isRoot() && m_owningLayer.isolatesCompositedBlending()) |
| 1712 | return false; |
| 1713 | |
antti@apple.com | 053c3c2 | 2013-09-09 19:21:53 +0000 | [diff] [blame] | 1714 | if (renderer().isRenderView()) { |
simon.fraser@apple.com | f757b38 | 2012-01-20 02:41:06 +0000 | [diff] [blame] | 1715 | // Look to see if the root object has a non-simple background |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 1716 | RenderObject* rootObject = renderer().document().documentElement() ? renderer().document().documentElement()->renderer() : 0; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1717 | if (!rootObject) |
| 1718 | return false; |
| 1719 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1720 | // Reject anything that has a border, a border-radius or outline, |
| 1721 | // or is not a simple background (no background, or solid color). |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1722 | if (hasBoxDecorationsOrBackgroundImage(rootObject->style())) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1723 | return false; |
| 1724 | |
| 1725 | // Now look at the body's renderer. |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 1726 | HTMLElement* body = renderer().document().body(); |
darin@apple.com | 15708b1 | 2014-03-16 16:38:58 +0000 | [diff] [blame] | 1727 | RenderObject* bodyObject = (body && body->hasTagName(bodyTag)) ? body->renderer() : 0; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1728 | if (!bodyObject) |
| 1729 | return false; |
| 1730 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1731 | if (hasBoxDecorationsOrBackgroundImage(bodyObject->style())) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1732 | return false; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1733 | } |
| 1734 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1735 | return true; |
| 1736 | } |
| 1737 | |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 1738 | static bool compositedWithOwnBackingStore(const RenderLayer* layer) |
| 1739 | { |
| 1740 | return layer->isComposited() && !layer->backing()->paintsIntoCompositedAncestor(); |
| 1741 | } |
| 1742 | |
| 1743 | static bool descendentLayerPaintsIntoAncestor(RenderLayer& parent) |
shawnsingh@chromium.org | 3a3ba16 | 2013-02-06 19:35:21 +0000 | [diff] [blame] | 1744 | { |
shawnsingh@chromium.org | c691180 | 2013-02-13 23:43:01 +0000 | [diff] [blame] | 1745 | // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512. |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1746 | parent.updateLayerListsIfNeeded(); |
shawnsingh@chromium.org | c691180 | 2013-02-13 23:43:01 +0000 | [diff] [blame] | 1747 | |
| 1748 | #if !ASSERT_DISABLED |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1749 | LayerListMutationDetector mutationChecker(&parent); |
shawnsingh@chromium.org | c691180 | 2013-02-13 23:43:01 +0000 | [diff] [blame] | 1750 | #endif |
| 1751 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1752 | if (Vector<RenderLayer*>* normalFlowList = parent.normalFlowList()) { |
shawnsingh@chromium.org | 3a3ba16 | 2013-02-06 19:35:21 +0000 | [diff] [blame] | 1753 | size_t listSize = normalFlowList->size(); |
| 1754 | for (size_t i = 0; i < listSize; ++i) { |
| 1755 | RenderLayer* curLayer = normalFlowList->at(i); |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 1756 | if (!compositedWithOwnBackingStore(curLayer) |
simon.fraser@apple.com | e6e085e | 2014-09-02 18:30:06 +0000 | [diff] [blame] | 1757 | && (curLayer->isVisuallyNonEmpty() || descendentLayerPaintsIntoAncestor(*curLayer))) |
shawnsingh@chromium.org | 3a3ba16 | 2013-02-06 19:35:21 +0000 | [diff] [blame] | 1758 | return true; |
| 1759 | } |
| 1760 | } |
| 1761 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1762 | if (parent.isStackingContainer()) { |
| 1763 | if (!parent.hasVisibleDescendant()) |
shawnsingh@chromium.org | 3a3ba16 | 2013-02-06 19:35:21 +0000 | [diff] [blame] | 1764 | return false; |
| 1765 | |
| 1766 | // Use the m_hasCompositingDescendant bit to optimize? |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1767 | if (Vector<RenderLayer*>* negZOrderList = parent.negZOrderList()) { |
shawnsingh@chromium.org | 3a3ba16 | 2013-02-06 19:35:21 +0000 | [diff] [blame] | 1768 | size_t listSize = negZOrderList->size(); |
| 1769 | for (size_t i = 0; i < listSize; ++i) { |
| 1770 | RenderLayer* curLayer = negZOrderList->at(i); |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 1771 | if (!compositedWithOwnBackingStore(curLayer) |
simon.fraser@apple.com | e6e085e | 2014-09-02 18:30:06 +0000 | [diff] [blame] | 1772 | && (curLayer->isVisuallyNonEmpty() || descendentLayerPaintsIntoAncestor(*curLayer))) |
shawnsingh@chromium.org | 3a3ba16 | 2013-02-06 19:35:21 +0000 | [diff] [blame] | 1773 | return true; |
| 1774 | } |
| 1775 | } |
| 1776 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1777 | if (Vector<RenderLayer*>* posZOrderList = parent.posZOrderList()) { |
shawnsingh@chromium.org | 3a3ba16 | 2013-02-06 19:35:21 +0000 | [diff] [blame] | 1778 | size_t listSize = posZOrderList->size(); |
| 1779 | for (size_t i = 0; i < listSize; ++i) { |
| 1780 | RenderLayer* curLayer = posZOrderList->at(i); |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 1781 | if (!compositedWithOwnBackingStore(curLayer) |
simon.fraser@apple.com | e6e085e | 2014-09-02 18:30:06 +0000 | [diff] [blame] | 1782 | && (curLayer->isVisuallyNonEmpty() || descendentLayerPaintsIntoAncestor(*curLayer))) |
shawnsingh@chromium.org | 3a3ba16 | 2013-02-06 19:35:21 +0000 | [diff] [blame] | 1783 | return true; |
| 1784 | } |
| 1785 | } |
| 1786 | } |
| 1787 | |
| 1788 | return false; |
| 1789 | } |
| 1790 | |
simon.fraser@apple.com | f757b38 | 2012-01-20 02:41:06 +0000 | [diff] [blame] | 1791 | // Conservative test for having no rendered children. |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 1792 | bool RenderLayerBacking::isPaintDestinationForDescendentLayers() const |
simon.fraser@apple.com | f757b38 | 2012-01-20 02:41:06 +0000 | [diff] [blame] | 1793 | { |
simon.fraser@apple.com | d305a89 | 2014-05-19 18:33:26 +0000 | [diff] [blame] | 1794 | return descendentLayerPaintsIntoAncestor(m_owningLayer); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1795 | } |
| 1796 | |
simon.fraser@apple.com | 9ca8cf7 | 2013-06-29 20:22:19 +0000 | [diff] [blame] | 1797 | bool RenderLayerBacking::containsPaintedContent(bool isSimpleContainer) const |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 1798 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1799 | if (isSimpleContainer || paintsIntoWindow() || paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owningLayer.isReflection()) |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 1800 | return false; |
| 1801 | |
| 1802 | if (isDirectlyCompositedImage()) |
| 1803 | return false; |
| 1804 | |
| 1805 | // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely, |
| 1806 | // and set background color on the layer in that case, instead of allocating backing store and painting. |
eric.carlson@apple.com | 402b2c0 | 2010-08-06 23:47:54 +0000 | [diff] [blame] | 1807 | #if ENABLE(VIDEO) |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1808 | if (is<RenderVideo>(renderer()) && downcast<RenderVideo>(renderer()).shouldDisplayVideo()) |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1809 | return m_owningLayer.hasBoxDecorationsOrBackground(); |
eric.carlson@apple.com | 402b2c0 | 2010-08-06 23:47:54 +0000 | [diff] [blame] | 1810 | #endif |
simon.fraser@apple.com | efaa412 | 2013-12-20 03:48:10 +0000 | [diff] [blame] | 1811 | |
| 1812 | #if ENABLE(WEBGL) || ENABLE(ACCELERATED_2D_CANVAS) |
cdumez@apple.com | 3abcc79 | 2014-10-20 03:42:03 +0000 | [diff] [blame] | 1813 | if (is<RenderHTMLCanvas>(renderer()) && canvasCompositingStrategy(renderer()) == CanvasAsLayerContents) |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 1814 | return m_owningLayer.hasBoxDecorationsOrBackground(); |
jamesr@google.com | d8c6157 | 2010-08-06 21:49:20 +0000 | [diff] [blame] | 1815 | #endif |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 1816 | |
| 1817 | return true; |
| 1818 | } |
| 1819 | |
| 1820 | // An image can be directly compositing if it's the sole content of the layer, and has no box decorations |
| 1821 | // that require painting. Direct compositing saves backing store. |
| 1822 | bool RenderLayerBacking::isDirectlyCompositedImage() const |
dino@apple.com | ce3a4e0 | 2009-03-26 01:38:52 +0000 | [diff] [blame] | 1823 | { |
cdumez@apple.com | 1b3800a | 2014-10-21 18:09:49 +0000 | [diff] [blame] | 1824 | if (!is<RenderImage>(renderer()) || m_owningLayer.hasBoxDecorationsOrBackground() || renderer().hasClip()) |
simon.fraser@apple.com | a54b1e8 | 2010-09-21 00:42:52 +0000 | [diff] [blame] | 1825 | return false; |
| 1826 | |
cdumez@apple.com | 1b3800a | 2014-10-21 18:09:49 +0000 | [diff] [blame] | 1827 | #if ENABLE(VIDEO) |
| 1828 | if (is<RenderMedia>(renderer())) |
| 1829 | return false; |
| 1830 | #endif |
| 1831 | |
cdumez@apple.com | cda2b9c | 2014-10-14 09:07:21 +0000 | [diff] [blame] | 1832 | auto& imageRenderer = downcast<RenderImage>(renderer()); |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1833 | if (CachedImage* cachedImage = imageRenderer.cachedImage()) { |
noam.rosenthal@nokia.com | 05334b3 | 2012-11-10 04:49:08 +0000 | [diff] [blame] | 1834 | if (!cachedImage->hasImage()) |
| 1835 | return false; |
| 1836 | |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1837 | Image* image = cachedImage->imageForRenderer(&imageRenderer); |
noam.rosenthal@nokia.com | 05334b3 | 2012-11-10 04:49:08 +0000 | [diff] [blame] | 1838 | if (!image->isBitmapImage()) |
| 1839 | return false; |
| 1840 | |
timothy_horton@apple.com | 9e3d9c8 | 2013-08-07 19:52:37 +0000 | [diff] [blame] | 1841 | if (image->orientationForCurrentFrame() != DefaultImageOrientation) |
| 1842 | return false; |
| 1843 | |
noam.rosenthal@nokia.com | 05334b3 | 2012-11-10 04:49:08 +0000 | [diff] [blame] | 1844 | return m_graphicsLayer->shouldDirectlyCompositeImage(image); |
simon.fraser@apple.com | a54b1e8 | 2010-09-21 00:42:52 +0000 | [diff] [blame] | 1845 | } |
| 1846 | |
| 1847 | return false; |
dino@apple.com | ce3a4e0 | 2009-03-26 01:38:52 +0000 | [diff] [blame] | 1848 | } |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 1849 | |
jchaffraix@webkit.org | 363c387 | 2012-04-17 21:51:22 +0000 | [diff] [blame] | 1850 | void RenderLayerBacking::contentChanged(ContentChangeType changeType) |
dino@apple.com | ce3a4e0 | 2009-03-26 01:38:52 +0000 | [diff] [blame] | 1851 | { |
jchaffraix@webkit.org | 363c387 | 2012-04-17 21:51:22 +0000 | [diff] [blame] | 1852 | if ((changeType == ImageChanged) && isDirectlyCompositedImage()) { |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 1853 | updateImageContents(); |
| 1854 | return; |
cmarrin@apple.com | 4e7728f | 2009-08-27 23:55:44 +0000 | [diff] [blame] | 1855 | } |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1856 | |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 1857 | if ((changeType == BackgroundImageChanged) && canCreateTiledImage(renderer().style())) |
simon.fraser@apple.com | e33dc48 | 2014-05-19 15:53:32 +0000 | [diff] [blame] | 1858 | updateGeometry(); |
commit-queue@webkit.org | e82edbf | 2013-04-11 05:47:44 +0000 | [diff] [blame] | 1859 | |
jchaffraix@webkit.org | 363c387 | 2012-04-17 21:51:22 +0000 | [diff] [blame] | 1860 | if ((changeType == MaskImageChanged) && m_maskLayer) { |
simon.fraser@apple.com | 2f5f5c8 | 2010-12-15 00:09:58 +0000 | [diff] [blame] | 1861 | // The composited layer bounds relies on box->maskClipRect(), which changes |
| 1862 | // when the mask image becomes available. |
simon.fraser@apple.com | fc75029 | 2012-12-15 22:11:27 +0000 | [diff] [blame] | 1863 | updateAfterLayout(CompositingChildrenOnly | IsUpdateRoot); |
simon.fraser@apple.com | 2f5f5c8 | 2010-12-15 00:09:58 +0000 | [diff] [blame] | 1864 | } |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 1865 | |
cmarrin@apple.com | 8b28bbc | 2011-01-25 17:27:30 +0000 | [diff] [blame] | 1866 | #if ENABLE(WEBGL) || ENABLE(ACCELERATED_2D_CANVAS) |
simon.fraser@apple.com | efaa412 | 2013-12-20 03:48:10 +0000 | [diff] [blame] | 1867 | if ((changeType == CanvasChanged || changeType == CanvasPixelsChanged) && renderer().isCanvas() && canvasCompositingStrategy(renderer()) == CanvasAsLayerContents) { |
cmarrin@apple.com | c924a5c | 2010-06-22 22:23:57 +0000 | [diff] [blame] | 1868 | m_graphicsLayer->setContentsNeedsDisplay(); |
simon.fraser@apple.com | aafddd8 | 2010-01-09 04:07:52 +0000 | [diff] [blame] | 1869 | return; |
| 1870 | } |
| 1871 | #endif |
simon.fraser@apple.com | 3368e1c | 2009-03-27 01:12:01 +0000 | [diff] [blame] | 1872 | } |
| 1873 | |
| 1874 | void RenderLayerBacking::updateImageContents() |
| 1875 | { |
cdumez@apple.com | cda2b9c | 2014-10-14 09:07:21 +0000 | [diff] [blame] | 1876 | auto& imageRenderer = downcast<RenderImage>(renderer()); |
simon.fraser@apple.com | 3368e1c | 2009-03-27 01:12:01 +0000 | [diff] [blame] | 1877 | |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1878 | CachedImage* cachedImage = imageRenderer.cachedImage(); |
simon.fraser@apple.com | 3368e1c | 2009-03-27 01:12:01 +0000 | [diff] [blame] | 1879 | if (!cachedImage) |
| 1880 | return; |
| 1881 | |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1882 | Image* image = cachedImage->imageForRenderer(&imageRenderer); |
simon.fraser@apple.com | 3368e1c | 2009-03-27 01:12:01 +0000 | [diff] [blame] | 1883 | if (!image) |
| 1884 | return; |
| 1885 | |
| 1886 | // We have to wait until the image is fully loaded before setting it on the layer. |
| 1887 | if (!cachedImage->isLoaded()) |
| 1888 | return; |
| 1889 | |
| 1890 | // This is a no-op if the layer doesn't have an inner layer for the image. |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 1891 | m_graphicsLayer->setContentsRect(snappedIntRect(contentsBox())); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1892 | |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1893 | LayoutRect contentsClippingRect = imageRenderer.contentBoxRect(); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1894 | contentsClippingRect.move(contentOffsetInCompostingLayer()); |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 1895 | m_graphicsLayer->setContentsClippingRect(snappedIntRect(contentsClippingRect)); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1896 | |
simon.fraser@apple.com | 3368e1c | 2009-03-27 01:12:01 +0000 | [diff] [blame] | 1897 | m_graphicsLayer->setContentsToImage(image); |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1898 | bool isSimpleContainer = false; |
| 1899 | updateDrawsContent(isSimpleContainer); |
simon.fraser@apple.com | 3368e1c | 2009-03-27 01:12:01 +0000 | [diff] [blame] | 1900 | |
| 1901 | // Image animation is "lazy", in that it automatically stops unless someone is drawing |
| 1902 | // the image. So we have to kick the animation each time; this has the downside that the |
| 1903 | // image will keep animating, even if its layer is not visible. |
| 1904 | image->startAnimation(); |
dino@apple.com | ce3a4e0 | 2009-03-26 01:38:52 +0000 | [diff] [blame] | 1905 | } |
| 1906 | |
zalan@apple.com | 8896507 | 2014-03-19 14:25:34 +0000 | [diff] [blame] | 1907 | FloatPoint3D RenderLayerBacking::computeTransformOriginForPainting(const LayoutRect& borderBox) const |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1908 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1909 | const RenderStyle& style = renderer().style(); |
zalan@apple.com | 93a3f39 | 2014-07-23 22:55:37 +0000 | [diff] [blame] | 1910 | float deviceScaleFactor = this->deviceScaleFactor(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1911 | |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 1912 | FloatPoint3D origin; |
zalan@apple.com | 8896507 | 2014-03-19 14:25:34 +0000 | [diff] [blame] | 1913 | origin.setX(roundToDevicePixel(floatValueForLength(style.transformOriginX(), borderBox.width()), deviceScaleFactor)); |
| 1914 | origin.setY(roundToDevicePixel(floatValueForLength(style.transformOriginY(), borderBox.height()), deviceScaleFactor)); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1915 | origin.setZ(style.transformOriginZ()); |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 1916 | |
| 1917 | return origin; |
| 1918 | } |
| 1919 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1920 | // Return the offset from the top-left of this compositing layer at which the renderer's contents are painted. |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 1921 | LayoutSize RenderLayerBacking::contentOffsetInCompostingLayer() const |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1922 | { |
zalan@apple.com | 5b735c0 | 2014-03-09 00:14:00 +0000 | [diff] [blame] | 1923 | return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()) + m_devicePixelFractionFromRenderer; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1924 | } |
| 1925 | |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 1926 | LayoutRect RenderLayerBacking::contentsBox() const |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1927 | { |
cdumez@apple.com | 2601e05 | 2014-10-10 18:02:32 +0000 | [diff] [blame] | 1928 | if (!is<RenderBox>(renderer())) |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 1929 | return LayoutRect(); |
simon.fraser@apple.com | 443915d | 2009-02-06 04:30:51 +0000 | [diff] [blame] | 1930 | |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1931 | auto& renderBox = downcast<RenderBox>(renderer()); |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 1932 | LayoutRect contentsRect; |
simon.fraser@apple.com | 98df11b | 2009-06-18 18:52:09 +0000 | [diff] [blame] | 1933 | #if ENABLE(VIDEO) |
cdumez@apple.com | 2601e05 | 2014-10-10 18:02:32 +0000 | [diff] [blame] | 1934 | if (is<RenderVideo>(renderBox)) |
| 1935 | contentsRect = downcast<RenderVideo>(renderBox).videoBox(); |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1936 | else |
simon.fraser@apple.com | 98df11b | 2009-06-18 18:52:09 +0000 | [diff] [blame] | 1937 | #endif |
cdumez@apple.com | 2601e05 | 2014-10-10 18:02:32 +0000 | [diff] [blame] | 1938 | if (is<RenderReplaced>(renderBox)) { |
| 1939 | RenderReplaced& renderReplaced = downcast<RenderReplaced>(renderBox); |
simon.fraser@apple.com | a0dfed96 | 2013-08-31 00:14:41 +0000 | [diff] [blame] | 1940 | contentsRect = renderReplaced.replacedContentRect(renderBox.intrinsicSize()); |
| 1941 | } else |
| 1942 | contentsRect = renderBox.contentBoxRect(); |
simon.fraser@apple.com | 98df11b | 2009-06-18 18:52:09 +0000 | [diff] [blame] | 1943 | |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1944 | contentsRect.move(contentOffsetInCompostingLayer()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 1945 | return contentsRect; |
| 1946 | } |
| 1947 | |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1948 | static LayoutRect backgroundRectForBox(const RenderBox& box) |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1949 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1950 | switch (box.style().backgroundClip()) { |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1951 | case BorderFillBox: |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1952 | return box.borderBoxRect(); |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1953 | case PaddingFillBox: |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1954 | return box.paddingBoxRect(); |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1955 | case ContentFillBox: |
akling@apple.com | 4c166d6 | 2013-09-01 05:29:00 +0000 | [diff] [blame] | 1956 | return box.contentBoxRect(); |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1957 | case TextFillBox: |
| 1958 | break; |
| 1959 | } |
| 1960 | |
| 1961 | ASSERT_NOT_REACHED(); |
| 1962 | return LayoutRect(); |
| 1963 | } |
| 1964 | |
zalan@apple.com | 5b735c0 | 2014-03-09 00:14:00 +0000 | [diff] [blame] | 1965 | FloatRect RenderLayerBacking::backgroundBoxForPainting() const |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1966 | { |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1967 | if (!is<RenderBox>(renderer())) |
zalan@apple.com | 5b735c0 | 2014-03-09 00:14:00 +0000 | [diff] [blame] | 1968 | return FloatRect(); |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1969 | |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1970 | LayoutRect backgroundBox = backgroundRectForBox(downcast<RenderBox>(renderer())); |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 1971 | backgroundBox.move(contentOffsetInCompostingLayer()); |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 1972 | return snapRectToDevicePixels(backgroundBox, deviceScaleFactor()); |
commit-queue@webkit.org | 90f1566 | 2012-12-08 23:46:05 +0000 | [diff] [blame] | 1973 | } |
| 1974 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1975 | GraphicsLayer* RenderLayerBacking::parentForSublayers() const |
| 1976 | { |
| 1977 | if (m_scrollingContentsLayer) |
| 1978 | return m_scrollingContentsLayer.get(); |
| 1979 | |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 1980 | #if PLATFORM(IOS) |
| 1981 | // FIXME: Can we remove this iOS-specific code path? |
| 1982 | if (GraphicsLayer* clippingLayer = this->clippingLayer()) |
| 1983 | return clippingLayer; |
| 1984 | return m_graphicsLayer.get(); |
| 1985 | #else |
simon.fraser@apple.com | 632ced1 | 2013-01-15 23:17:01 +0000 | [diff] [blame] | 1986 | return m_childContainmentLayer ? m_childContainmentLayer.get() : m_graphicsLayer.get(); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 1987 | #endif |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 1988 | } |
| 1989 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 1990 | GraphicsLayer* RenderLayerBacking::childForSuperlayers() const |
| 1991 | { |
| 1992 | if (m_ancestorClippingLayer) |
| 1993 | return m_ancestorClippingLayer.get(); |
| 1994 | |
| 1995 | if (m_contentsContainmentLayer) |
| 1996 | return m_contentsContainmentLayer.get(); |
| 1997 | |
| 1998 | return m_graphicsLayer.get(); |
| 1999 | } |
| 2000 | |
simon.fraser@apple.com | 655ac7f | 2012-04-06 22:55:45 +0000 | [diff] [blame] | 2001 | bool RenderLayerBacking::paintsIntoWindow() const |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2002 | { |
simon.fraser@apple.com | 5429b7f | 2011-12-13 01:05:32 +0000 | [diff] [blame] | 2003 | if (m_usingTiledCacheLayer) |
| 2004 | return false; |
| 2005 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2006 | if (m_owningLayer.isRootLayer()) { |
benjamin@webkit.org | 049d8b3 | 2014-01-10 20:41:20 +0000 | [diff] [blame] | 2007 | #if PLATFORM(IOS) || USE(COORDINATED_GRAPHICS) |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2008 | if (compositor().inForcedCompositingMode()) |
commit-queue@webkit.org | 3c453c4 | 2012-04-05 16:10:40 +0000 | [diff] [blame] | 2009 | return false; |
| 2010 | #endif |
| 2011 | |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2012 | return compositor().rootLayerAttachment() != RenderLayerCompositor::RootLayerAttachedViaEnclosingFrame; |
commit-queue@webkit.org | 3c453c4 | 2012-04-05 16:10:40 +0000 | [diff] [blame] | 2013 | } |
simon.fraser@apple.com | ed063f4 | 2010-05-11 05:34:48 +0000 | [diff] [blame] | 2014 | |
| 2015 | return false; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2016 | } |
| 2017 | |
simon.fraser@apple.com | 9d12790 | 2012-05-29 20:49:15 +0000 | [diff] [blame] | 2018 | void RenderLayerBacking::setRequiresOwnBackingStore(bool requiresOwnBacking) |
simon.fraser@apple.com | 297a0fb | 2012-05-25 21:17:33 +0000 | [diff] [blame] | 2019 | { |
simon.fraser@apple.com | 9d12790 | 2012-05-29 20:49:15 +0000 | [diff] [blame] | 2020 | if (requiresOwnBacking == m_requiresOwnBackingStore) |
simon.fraser@apple.com | 297a0fb | 2012-05-25 21:17:33 +0000 | [diff] [blame] | 2021 | return; |
| 2022 | |
simon.fraser@apple.com | 0afaa9d | 2012-10-16 18:29:38 +0000 | [diff] [blame] | 2023 | m_requiresOwnBackingStore = requiresOwnBacking; |
| 2024 | |
simon.fraser@apple.com | 297a0fb | 2012-05-25 21:17:33 +0000 | [diff] [blame] | 2025 | // This affects the answer to paintsIntoCompositedAncestor(), which in turn affects |
| 2026 | // cached clip rects, so when it changes we have to clear clip rects on descendants. |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2027 | m_owningLayer.clearClipRectsIncludingDescendants(PaintingClipRects); |
| 2028 | m_owningLayer.computeRepaintRectsIncludingDescendants(); |
simon.fraser@apple.com | 9d12790 | 2012-05-29 20:49:15 +0000 | [diff] [blame] | 2029 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2030 | compositor().repaintInCompositedAncestor(m_owningLayer, compositedBounds()); |
simon.fraser@apple.com | 297a0fb | 2012-05-25 21:17:33 +0000 | [diff] [blame] | 2031 | } |
| 2032 | |
bdakin@apple.com | 6e3f3f2 | 2014-01-09 20:20:26 +0000 | [diff] [blame] | 2033 | void RenderLayerBacking::setContentsNeedDisplay(GraphicsLayer::ShouldClipToLayer shouldClip) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2034 | { |
simon.fraser@apple.com | b7cec68 | 2012-04-16 18:32:13 +0000 | [diff] [blame] | 2035 | ASSERT(!paintsIntoCompositedAncestor()); |
timothy_horton@apple.com | 5251cbd | 2013-10-02 21:14:26 +0000 | [diff] [blame] | 2036 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2037 | FrameView& frameView = owningLayer().renderer().view().frameView(); |
timothy_horton@apple.com | 5251cbd | 2013-10-02 21:14:26 +0000 | [diff] [blame] | 2038 | if (m_isMainFrameRenderViewLayer && frameView.isTrackingRepaints()) |
zalan@apple.com | 268e948 | 2014-03-05 05:30:25 +0000 | [diff] [blame] | 2039 | frameView.addTrackedRepaintRect(owningLayer().absoluteBoundingBoxForPainting()); |
simon.fraser@apple.com | b7cec68 | 2012-04-16 18:32:13 +0000 | [diff] [blame] | 2040 | |
bdakin@apple.com | 6e3f3f2 | 2014-01-09 20:20:26 +0000 | [diff] [blame] | 2041 | if (m_graphicsLayer && m_graphicsLayer->drawsContent()) { |
| 2042 | // By default, setNeedsDisplay will clip to the size of the GraphicsLayer, which does not include margin tiles. |
| 2043 | // So if the TiledBacking has a margin that needs to be invalidated, we need to send in a rect to setNeedsDisplayInRect |
| 2044 | // that is large enough to include the margin. TiledBacking::bounds() includes the margin. |
| 2045 | TiledBacking* tiledBacking = this->tiledBacking(); |
| 2046 | FloatRect rectToRepaint = tiledBacking ? tiledBacking->bounds() : FloatRect(FloatPoint(0, 0), m_graphicsLayer->size()); |
| 2047 | m_graphicsLayer->setNeedsDisplayInRect(rectToRepaint, shouldClip); |
| 2048 | } |
simon.fraser@apple.com | bb04c2d | 2009-06-25 01:07:08 +0000 | [diff] [blame] | 2049 | |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 2050 | if (m_foregroundLayer && m_foregroundLayer->drawsContent()) |
| 2051 | m_foregroundLayer->setNeedsDisplay(); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 2052 | |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2053 | if (m_backgroundLayer && m_backgroundLayer->drawsContent()) |
| 2054 | m_backgroundLayer->setNeedsDisplay(); |
| 2055 | |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 2056 | if (m_maskLayer && m_maskLayer->drawsContent()) |
| 2057 | m_maskLayer->setNeedsDisplay(); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 2058 | |
| 2059 | if (m_scrollingContentsLayer && m_scrollingContentsLayer->drawsContent()) |
| 2060 | m_scrollingContentsLayer->setNeedsDisplay(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2061 | } |
| 2062 | |
| 2063 | // r is in the coordinate space of the layer's render object |
zalan@apple.com | c7b20b1 | 2014-02-12 04:50:55 +0000 | [diff] [blame] | 2064 | void RenderLayerBacking::setContentsNeedDisplayInRect(const LayoutRect& r, GraphicsLayer::ShouldClipToLayer shouldClip) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2065 | { |
simon.fraser@apple.com | b7cec68 | 2012-04-16 18:32:13 +0000 | [diff] [blame] | 2066 | ASSERT(!paintsIntoCompositedAncestor()); |
| 2067 | |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 2068 | FloatRect pixelSnappedRectForPainting = snapRectToDevicePixels(r, deviceScaleFactor()); |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2069 | FrameView& frameView = owningLayer().renderer().view().frameView(); |
timothy_horton@apple.com | 5251cbd | 2013-10-02 21:14:26 +0000 | [diff] [blame] | 2070 | if (m_isMainFrameRenderViewLayer && frameView.isTrackingRepaints()) |
zalan@apple.com | 268e948 | 2014-03-05 05:30:25 +0000 | [diff] [blame] | 2071 | frameView.addTrackedRepaintRect(pixelSnappedRectForPainting); |
timothy_horton@apple.com | 5251cbd | 2013-10-02 21:14:26 +0000 | [diff] [blame] | 2072 | |
simon.fraser@apple.com | bb04c2d | 2009-06-25 01:07:08 +0000 | [diff] [blame] | 2073 | if (m_graphicsLayer && m_graphicsLayer->drawsContent()) { |
zalan@apple.com | c7b20b1 | 2014-02-12 04:50:55 +0000 | [diff] [blame] | 2074 | FloatRect layerDirtyRect = pixelSnappedRectForPainting; |
zalan@apple.com | dc9c840 | 2014-03-04 16:17:46 +0000 | [diff] [blame] | 2075 | layerDirtyRect.move(-m_graphicsLayer->offsetFromRenderer() + m_devicePixelFractionFromRenderer); |
bdakin@apple.com | 8ce430b | 2014-01-15 23:51:25 +0000 | [diff] [blame] | 2076 | m_graphicsLayer->setNeedsDisplayInRect(layerDirtyRect, shouldClip); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2077 | } |
| 2078 | |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 2079 | if (m_foregroundLayer && m_foregroundLayer->drawsContent()) { |
zalan@apple.com | c7b20b1 | 2014-02-12 04:50:55 +0000 | [diff] [blame] | 2080 | FloatRect layerDirtyRect = pixelSnappedRectForPainting; |
zalan@apple.com | dc9c840 | 2014-03-04 16:17:46 +0000 | [diff] [blame] | 2081 | layerDirtyRect.move(-m_foregroundLayer->offsetFromRenderer() + m_devicePixelFractionFromRenderer); |
bdakin@apple.com | 8ce430b | 2014-01-15 23:51:25 +0000 | [diff] [blame] | 2082 | m_foregroundLayer->setNeedsDisplayInRect(layerDirtyRect, shouldClip); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2083 | } |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 2084 | |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2085 | // FIXME: need to split out repaints for the background. |
| 2086 | if (m_backgroundLayer && m_backgroundLayer->drawsContent()) { |
zalan@apple.com | c7b20b1 | 2014-02-12 04:50:55 +0000 | [diff] [blame] | 2087 | FloatRect layerDirtyRect = pixelSnappedRectForPainting; |
zalan@apple.com | dc9c840 | 2014-03-04 16:17:46 +0000 | [diff] [blame] | 2088 | layerDirtyRect.move(-m_backgroundLayer->offsetFromRenderer() + m_devicePixelFractionFromRenderer); |
bdakin@apple.com | 8ce430b | 2014-01-15 23:51:25 +0000 | [diff] [blame] | 2089 | m_backgroundLayer->setNeedsDisplayInRect(layerDirtyRect, shouldClip); |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2090 | } |
| 2091 | |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 2092 | if (m_maskLayer && m_maskLayer->drawsContent()) { |
zalan@apple.com | c7b20b1 | 2014-02-12 04:50:55 +0000 | [diff] [blame] | 2093 | FloatRect layerDirtyRect = pixelSnappedRectForPainting; |
zalan@apple.com | dc9c840 | 2014-03-04 16:17:46 +0000 | [diff] [blame] | 2094 | layerDirtyRect.move(-m_maskLayer->offsetFromRenderer() + m_devicePixelFractionFromRenderer); |
bdakin@apple.com | 8ce430b | 2014-01-15 23:51:25 +0000 | [diff] [blame] | 2095 | m_maskLayer->setNeedsDisplayInRect(layerDirtyRect, shouldClip); |
simon.fraser@apple.com | 9d9e298 | 2009-08-18 03:57:08 +0000 | [diff] [blame] | 2096 | } |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 2097 | |
| 2098 | if (m_scrollingContentsLayer && m_scrollingContentsLayer->drawsContent()) { |
zalan@apple.com | c7b20b1 | 2014-02-12 04:50:55 +0000 | [diff] [blame] | 2099 | FloatRect layerDirtyRect = pixelSnappedRectForPainting; |
zalan@apple.com | dc9c840 | 2014-03-04 16:17:46 +0000 | [diff] [blame] | 2100 | layerDirtyRect.move(-m_scrollingContentsLayer->offsetFromRenderer() + m_devicePixelFractionFromRenderer); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 2101 | #if PLATFORM(IOS) |
simon.fraser@apple.com | e33dc48 | 2014-05-19 15:53:32 +0000 | [diff] [blame] | 2102 | // Account for the fact that RenderLayerBacking::updateGeometry() bakes scrollOffset into offsetFromRenderer on iOS. |
zalan@apple.com | dc9c840 | 2014-03-04 16:17:46 +0000 | [diff] [blame] | 2103 | layerDirtyRect.move(-m_owningLayer.scrollOffset() + m_devicePixelFractionFromRenderer); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 2104 | #endif |
bdakin@apple.com | 8ce430b | 2014-01-15 23:51:25 +0000 | [diff] [blame] | 2105 | m_scrollingContentsLayer->setNeedsDisplayInRect(layerDirtyRect, shouldClip); |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 2106 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2107 | } |
| 2108 | |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2109 | void RenderLayerBacking::paintIntoLayer(const GraphicsLayer* graphicsLayer, GraphicsContext* context, |
zalan@apple.com | a95fd6f | 2014-02-22 07:24:45 +0000 | [diff] [blame] | 2110 | const IntRect& paintDirtyRect, // In the coords of rootLayer. |
zalan@apple.com | d1e3a0f | 2014-02-12 03:28:43 +0000 | [diff] [blame] | 2111 | PaintBehavior paintBehavior, GraphicsLayerPaintingPhase paintingPhase) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2112 | { |
simon.fraser@apple.com | b7cec68 | 2012-04-16 18:32:13 +0000 | [diff] [blame] | 2113 | if (paintsIntoWindow() || paintsIntoCompositedAncestor()) { |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 2114 | #if !PLATFORM(IOS) |
| 2115 | // FIXME: Looks like the CALayer tree is out of sync with the GraphicsLayer heirarchy |
| 2116 | // when pages are restored from the PageCache. |
| 2117 | // <rdar://problem/8712587> ASSERT: When Going Back to Page with Plugins in PageCache |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2118 | ASSERT_NOT_REACHED(); |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 2119 | #endif |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2120 | return; |
| 2121 | } |
simon.fraser@apple.com | a43acab3 | 2011-11-02 21:02:07 +0000 | [diff] [blame] | 2122 | |
| 2123 | FontCachePurgePreventer fontCachePurgePreventer; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2124 | |
achicu@adobe.com | b64dbce | 2012-01-13 09:05:22 +0000 | [diff] [blame] | 2125 | RenderLayer::PaintLayerFlags paintFlags = 0; |
| 2126 | if (paintingPhase & GraphicsLayerPaintBackground) |
| 2127 | paintFlags |= RenderLayer::PaintLayerPaintingCompositingBackgroundPhase; |
| 2128 | if (paintingPhase & GraphicsLayerPaintForeground) |
| 2129 | paintFlags |= RenderLayer::PaintLayerPaintingCompositingForegroundPhase; |
| 2130 | if (paintingPhase & GraphicsLayerPaintMask) |
| 2131 | paintFlags |= RenderLayer::PaintLayerPaintingCompositingMaskPhase; |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 2132 | if (paintingPhase & GraphicsLayerPaintOverflowContents) |
| 2133 | paintFlags |= RenderLayer::PaintLayerPaintingOverflowContents; |
vollick@chromium.org | 0015c12 | 2013-03-07 14:00:57 +0000 | [diff] [blame] | 2134 | if (paintingPhase & GraphicsLayerPaintCompositedScroll) |
| 2135 | paintFlags |= RenderLayer::PaintLayerPaintingCompositingScrollingPhase; |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2136 | |
andersca@apple.com | cc3b2dc | 2013-09-27 18:38:51 +0000 | [diff] [blame] | 2137 | if (graphicsLayer == m_backgroundLayer.get()) |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2138 | paintFlags |= (RenderLayer::PaintLayerPaintingRootBackgroundOnly | RenderLayer::PaintLayerPaintingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroundPhase to walk child layers. |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2139 | else if (compositor().fixedRootBackgroundLayer()) |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2140 | paintFlags |= RenderLayer::PaintLayerPaintingSkipRootBackground; |
simon.fraser@apple.com | 57f81ee | 2014-03-20 23:14:31 +0000 | [diff] [blame] | 2141 | |
| 2142 | #ifndef NDEBUG |
mihnea@adobe.com | 388bf22 | 2014-09-22 07:51:54 +0000 | [diff] [blame] | 2143 | RenderElement::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(&renderer()); |
simon.fraser@apple.com | 57f81ee | 2014-03-20 23:14:31 +0000 | [diff] [blame] | 2144 | #endif |
| 2145 | |
| 2146 | FrameView::PaintingState paintingState; |
| 2147 | if (m_owningLayer.isRootLayer()) |
mihnea@adobe.com | 388bf22 | 2014-09-22 07:51:54 +0000 | [diff] [blame] | 2148 | renderer().view().frameView().willPaintContents(context, paintDirtyRect, paintingState); |
simon.fraser@apple.com | 57f81ee | 2014-03-20 23:14:31 +0000 | [diff] [blame] | 2149 | |
achicu@adobe.com | b64dbce | 2012-01-13 09:05:22 +0000 | [diff] [blame] | 2150 | // FIXME: GraphicsLayers need a way to split for RenderRegions. |
zalan@apple.com | 5e034f6 | 2014-02-20 23:04:20 +0000 | [diff] [blame] | 2151 | RenderLayer::LayerPaintingInfo paintingInfo(&m_owningLayer, paintDirtyRect, paintBehavior, m_devicePixelFractionFromRenderer); |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2152 | m_owningLayer.paintLayerContents(context, paintingInfo, paintFlags); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2153 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2154 | if (m_owningLayer.containsDirtyOverlayScrollbars()) |
| 2155 | m_owningLayer.paintLayerContents(context, paintingInfo, paintFlags | RenderLayer::PaintLayerPaintingOverlayScrollbars); |
bdakin@apple.com | b7b5484 | 2012-05-11 00:31:30 +0000 | [diff] [blame] | 2156 | |
simon.fraser@apple.com | 57f81ee | 2014-03-20 23:14:31 +0000 | [diff] [blame] | 2157 | if (m_owningLayer.isRootLayer()) |
mihnea@adobe.com | 388bf22 | 2014-09-22 07:51:54 +0000 | [diff] [blame] | 2158 | renderer().view().frameView().didPaintContents(context, paintDirtyRect, paintingState); |
simon.fraser@apple.com | 57f81ee | 2014-03-20 23:14:31 +0000 | [diff] [blame] | 2159 | |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2160 | compositor().didPaintBacking(this); |
simon.fraser@apple.com | 6f987a7 | 2013-05-29 16:04:12 +0000 | [diff] [blame] | 2161 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2162 | ASSERT(!m_owningLayer.m_usedTransparency); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2163 | } |
| 2164 | |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 2165 | static void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRect& clip) |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2166 | { |
| 2167 | if (!scrollbar) |
| 2168 | return; |
| 2169 | |
| 2170 | context.save(); |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 2171 | const IntRect& scrollbarRect = scrollbar->frameRect(); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2172 | context.translate(-scrollbarRect.x(), -scrollbarRect.y()); |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 2173 | IntRect transformedClip = clip; |
leviw@chromium.org | 35e0131 | 2011-06-03 02:41:09 +0000 | [diff] [blame] | 2174 | transformedClip.moveBy(scrollbarRect.location()); |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 2175 | scrollbar->paint(&context, transformedClip); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2176 | context.restore(); |
| 2177 | } |
| 2178 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2179 | // Up-call from compositing layer drawing callback. |
zalan@apple.com | d1e3a0f | 2014-02-12 03:28:43 +0000 | [diff] [blame] | 2180 | void RenderLayerBacking::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase paintingPhase, const FloatRect& clip) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2181 | { |
fsamuel@chromium.org | 10dcfd8 | 2012-03-27 00:09:12 +0000 | [diff] [blame] | 2182 | #ifndef NDEBUG |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 2183 | if (Page* page = renderer().frame().page()) |
fsamuel@chromium.org | 10dcfd8 | 2012-03-27 00:09:12 +0000 | [diff] [blame] | 2184 | page->setIsPainting(true); |
| 2185 | #endif |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 2186 | |
zalan@apple.com | d1e3a0f | 2014-02-12 03:28:43 +0000 | [diff] [blame] | 2187 | // The dirtyRect is in the coords of the painting root. |
zalan@apple.com | b2ef5cb | 2014-07-17 01:47:10 +0000 | [diff] [blame] | 2188 | FloatRect adjustedClipRect = clip; |
| 2189 | adjustedClipRect.move(-m_devicePixelFractionFromRenderer); |
| 2190 | IntRect dirtyRect = enclosingIntRect(adjustedClipRect); |
zalan@apple.com | d1e3a0f | 2014-02-12 03:28:43 +0000 | [diff] [blame] | 2191 | |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2192 | if (graphicsLayer == m_graphicsLayer.get() |
| 2193 | || graphicsLayer == m_foregroundLayer.get() |
| 2194 | || graphicsLayer == m_backgroundLayer.get() |
| 2195 | || graphicsLayer == m_maskLayer.get() |
| 2196 | || graphicsLayer == m_scrollingContentsLayer.get()) { |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 2197 | InspectorInstrumentation::willPaint(&renderer()); |
simon.fraser@apple.com | 8afbff1 | 2009-11-19 19:03:02 +0000 | [diff] [blame] | 2198 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 2199 | if (!(paintingPhase & GraphicsLayerPaintOverflowContents)) |
bdakin@apple.com | 8af619c | 2013-11-21 21:57:53 +0000 | [diff] [blame] | 2200 | dirtyRect.intersect(enclosingIntRect(compositedBoundsIncludingMargin())); |
simon.fraser@apple.com | 8afbff1 | 2009-11-19 19:03:02 +0000 | [diff] [blame] | 2201 | |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2202 | // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2203 | paintIntoLayer(graphicsLayer, &context, dirtyRect, PaintBehaviorNormal, paintingPhase); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2204 | |
simon.fraser@apple.com | 159ad60 | 2014-08-22 19:07:17 +0000 | [diff] [blame] | 2205 | InspectorInstrumentation::didPaint(&renderer(), dirtyRect); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2206 | } else if (graphicsLayer == layerForHorizontalScrollbar()) { |
zalan@apple.com | a95fd6f | 2014-02-22 07:24:45 +0000 | [diff] [blame] | 2207 | paintScrollbar(m_owningLayer.horizontalScrollbar(), context, dirtyRect); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2208 | } else if (graphicsLayer == layerForVerticalScrollbar()) { |
zalan@apple.com | a95fd6f | 2014-02-22 07:24:45 +0000 | [diff] [blame] | 2209 | paintScrollbar(m_owningLayer.verticalScrollbar(), context, dirtyRect); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2210 | } else if (graphicsLayer == layerForScrollCorner()) { |
zalan@apple.com | 5f08e99 | 2014-01-24 23:35:07 +0000 | [diff] [blame] | 2211 | const LayoutRect& scrollCornerAndResizer = m_owningLayer.scrollCornerAndResizerRect(); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2212 | context.save(); |
| 2213 | context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y()); |
zalan@apple.com | d1e3a0f | 2014-02-12 03:28:43 +0000 | [diff] [blame] | 2214 | LayoutRect transformedClip = LayoutRect(clip); |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 2215 | transformedClip.moveBy(scrollCornerAndResizer.location()); |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 2216 | m_owningLayer.paintScrollCorner(&context, IntPoint(), snappedIntRect(transformedClip)); |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2217 | m_owningLayer.paintResizer(&context, IntPoint(), transformedClip); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 2218 | context.restore(); |
| 2219 | } |
fsamuel@chromium.org | 10dcfd8 | 2012-03-27 00:09:12 +0000 | [diff] [blame] | 2220 | #ifndef NDEBUG |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 2221 | if (Page* page = renderer().frame().page()) |
fsamuel@chromium.org | 10dcfd8 | 2012-03-27 00:09:12 +0000 | [diff] [blame] | 2222 | page->setIsPainting(false); |
| 2223 | #endif |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
simon.fraser@apple.com | 53dd08d | 2011-07-16 01:30:13 +0000 | [diff] [blame] | 2226 | float RenderLayerBacking::pageScaleFactor() const |
| 2227 | { |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2228 | return compositor().pageScaleFactor(); |
simon.fraser@apple.com | 53dd08d | 2011-07-16 01:30:13 +0000 | [diff] [blame] | 2229 | } |
| 2230 | |
antti@apple.com | 317ff43 | 2014-04-11 18:58:07 +0000 | [diff] [blame] | 2231 | float RenderLayerBacking::zoomedOutPageScaleFactor() const |
| 2232 | { |
| 2233 | return compositor().zoomedOutPageScaleFactor(); |
| 2234 | } |
| 2235 | |
aroben@apple.com | 631cb90 | 2011-08-15 13:43:29 +0000 | [diff] [blame] | 2236 | float RenderLayerBacking::deviceScaleFactor() const |
simon.fraser@apple.com | 53dd08d | 2011-07-16 01:30:13 +0000 | [diff] [blame] | 2237 | { |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2238 | return compositor().deviceScaleFactor(); |
simon.fraser@apple.com | 53dd08d | 2011-07-16 01:30:13 +0000 | [diff] [blame] | 2239 | } |
| 2240 | |
simon.fraser@apple.com | c529da0 | 2013-11-07 19:34:01 +0000 | [diff] [blame] | 2241 | float RenderLayerBacking::contentsScaleMultiplierForNewTiles(const GraphicsLayer* layer) const |
| 2242 | { |
| 2243 | return compositor().contentsScaleMultiplierForNewTiles(layer); |
| 2244 | } |
| 2245 | |
timothy_horton@apple.com | 2aa04e4 | 2014-03-19 01:51:56 +0000 | [diff] [blame] | 2246 | bool RenderLayerBacking::paintsOpaquelyAtNonIntegralScales(const GraphicsLayer*) const |
| 2247 | { |
| 2248 | return m_isMainFrameRenderViewLayer; |
| 2249 | } |
| 2250 | |
simon.fraser@apple.com | a561496 | 2013-01-19 01:20:32 +0000 | [diff] [blame] | 2251 | void RenderLayerBacking::didCommitChangesForLayer(const GraphicsLayer* layer) const |
simon.fraser@apple.com | 53dd08d | 2011-07-16 01:30:13 +0000 | [diff] [blame] | 2252 | { |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2253 | compositor().didFlushChangesForLayer(m_owningLayer, layer); |
simon.fraser@apple.com | 53dd08d | 2011-07-16 01:30:13 +0000 | [diff] [blame] | 2254 | } |
| 2255 | |
simon.fraser@apple.com | 5cabb32 | 2012-10-17 18:20:31 +0000 | [diff] [blame] | 2256 | bool RenderLayerBacking::getCurrentTransform(const GraphicsLayer* graphicsLayer, TransformationMatrix& transform) const |
| 2257 | { |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 2258 | GraphicsLayer* transformedLayer = m_contentsContainmentLayer.get() ? m_contentsContainmentLayer.get() : m_graphicsLayer.get(); |
| 2259 | if (graphicsLayer != transformedLayer) |
simon.fraser@apple.com | 5cabb32 | 2012-10-17 18:20:31 +0000 | [diff] [blame] | 2260 | return false; |
| 2261 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2262 | if (m_owningLayer.hasTransform()) { |
| 2263 | transform = m_owningLayer.currentTransform(RenderStyle::ExcludeTransformOrigin); |
simon.fraser@apple.com | 5cabb32 | 2012-10-17 18:20:31 +0000 | [diff] [blame] | 2264 | return true; |
| 2265 | } |
| 2266 | return false; |
| 2267 | } |
| 2268 | |
vollick@chromium.org | b992fd3 | 2012-11-02 19:58:52 +0000 | [diff] [blame] | 2269 | bool RenderLayerBacking::isTrackingRepaints() const |
| 2270 | { |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2271 | return static_cast<GraphicsLayerClient&>(compositor()).isTrackingRepaints(); |
vollick@chromium.org | b992fd3 | 2012-11-02 19:58:52 +0000 | [diff] [blame] | 2272 | } |
| 2273 | |
timothy_horton@apple.com | 2304bd5 | 2014-10-04 08:47:04 +0000 | [diff] [blame] | 2274 | bool RenderLayerBacking::shouldSkipLayerInDump(const GraphicsLayer* layer, LayerTreeAsTextBehavior) const |
timothy_horton@apple.com | 203cdfa | 2013-10-01 23:42:50 +0000 | [diff] [blame] | 2275 | { |
| 2276 | // Skip the root tile cache's flattening layer. |
| 2277 | return m_isMainFrameRenderViewLayer && layer && layer == m_childContainmentLayer.get(); |
| 2278 | } |
| 2279 | |
| 2280 | bool RenderLayerBacking::shouldDumpPropertyForLayer(const GraphicsLayer* layer, const char* propertyName) const |
| 2281 | { |
| 2282 | // For backwards compatibility with WebKit1 and other platforms, |
| 2283 | // skip some properties on the root tile cache. |
| 2284 | if (m_isMainFrameRenderViewLayer && layer == m_graphicsLayer.get()) { |
| 2285 | if (!strcmp(propertyName, "drawsContent")) |
| 2286 | return false; |
| 2287 | |
| 2288 | // Background color could be of interest to tests or other dumpers if it's non-white. |
| 2289 | if (!strcmp(propertyName, "backgroundColor") && layer->backgroundColor() == Color::white) |
| 2290 | return false; |
timothy_horton@apple.com | 5251cbd | 2013-10-02 21:14:26 +0000 | [diff] [blame] | 2291 | |
| 2292 | // The root tile cache's repaints will show up at the top with FrameView's, |
| 2293 | // so don't dump them twice. |
| 2294 | if (!strcmp(propertyName, "repaintRects")) |
| 2295 | return false; |
timothy_horton@apple.com | 203cdfa | 2013-10-01 23:42:50 +0000 | [diff] [blame] | 2296 | } |
| 2297 | |
| 2298 | return true; |
| 2299 | } |
| 2300 | |
timothy_horton@apple.com | 80ec561 | 2014-03-31 19:37:30 +0000 | [diff] [blame] | 2301 | bool RenderLayerBacking::shouldAggressivelyRetainTiles(const GraphicsLayer*) const |
| 2302 | { |
| 2303 | // Only the main frame TileController has enough information about in-window state to |
| 2304 | // correctly implement aggressive tile retention. |
| 2305 | if (!m_isMainFrameRenderViewLayer) |
| 2306 | return false; |
| 2307 | |
| 2308 | if (Page* page = renderer().frame().page()) |
| 2309 | return page->settings().aggressiveTileRetentionEnabled(); |
| 2310 | return false; |
| 2311 | } |
| 2312 | |
| 2313 | bool RenderLayerBacking::shouldTemporarilyRetainTileCohorts(const GraphicsLayer*) const |
| 2314 | { |
| 2315 | if (Page* page = renderer().frame().page()) |
| 2316 | return page->settings().temporaryTileCohortRetentionEnabled(); |
| 2317 | return true; |
| 2318 | } |
| 2319 | |
fsamuel@chromium.org | 10dcfd8 | 2012-03-27 00:09:12 +0000 | [diff] [blame] | 2320 | #ifndef NDEBUG |
| 2321 | void RenderLayerBacking::verifyNotPainting() |
| 2322 | { |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 2323 | ASSERT(!renderer().frame().page() || !renderer().frame().page()->isPainting()); |
fsamuel@chromium.org | 10dcfd8 | 2012-03-27 00:09:12 +0000 | [diff] [blame] | 2324 | } |
| 2325 | #endif |
| 2326 | |
simon.fraser@apple.com | d2fbbe1 | 2009-12-11 20:57:27 +0000 | [diff] [blame] | 2327 | bool RenderLayerBacking::startAnimation(double timeOffset, const Animation* anim, const KeyframeList& keyframes) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2328 | { |
| 2329 | bool hasOpacity = keyframes.containsProperty(CSSPropertyOpacity); |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 2330 | bool hasTransform = renderer().isBox() && keyframes.containsProperty(CSSPropertyWebkitTransform); |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2331 | bool hasFilter = keyframes.containsProperty(CSSPropertyWebkitFilter); |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2332 | |
| 2333 | if (!hasOpacity && !hasTransform && !hasFilter) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2334 | return false; |
| 2335 | |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 2336 | KeyframeValueList transformVector(AnimatedPropertyWebkitTransform); |
| 2337 | KeyframeValueList opacityVector(AnimatedPropertyOpacity); |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2338 | KeyframeValueList filterVector(AnimatedPropertyWebkitFilter); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2339 | |
simon.fraser@apple.com | c0065e0 | 2010-08-28 17:38:59 +0000 | [diff] [blame] | 2340 | size_t numKeyframes = keyframes.size(); |
| 2341 | for (size_t i = 0; i < numKeyframes; ++i) { |
| 2342 | const KeyframeValue& currentKeyframe = keyframes[i]; |
| 2343 | const RenderStyle* keyframeStyle = currentKeyframe.style(); |
dino@apple.com | 3b2749f | 2013-08-30 21:32:17 +0000 | [diff] [blame] | 2344 | double key = currentKeyframe.key(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2345 | |
| 2346 | if (!keyframeStyle) |
| 2347 | continue; |
| 2348 | |
bfulgham@apple.com | 55c6e0b | 2014-04-18 00:44:53 +0000 | [diff] [blame] | 2349 | TimingFunction* tf = currentKeyframe.timingFunction(keyframes.animationName()); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2350 | |
simon.fraser@apple.com | 4c723aa | 2010-10-27 16:47:46 +0000 | [diff] [blame] | 2351 | bool isFirstOrLastKeyframe = key == 0 || key == 1; |
| 2352 | if ((hasTransform && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyWebkitTransform)) |
andersca@apple.com | 963e45b | 2013-05-07 22:04:01 +0000 | [diff] [blame] | 2353 | transformVector.insert(TransformAnimationValue::create(key, keyframeStyle->transform(), tf)); |
| 2354 | |
simon.fraser@apple.com | 4c723aa | 2010-10-27 16:47:46 +0000 | [diff] [blame] | 2355 | if ((hasOpacity && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyOpacity)) |
andersca@apple.com | 963e45b | 2013-05-07 22:04:01 +0000 | [diff] [blame] | 2356 | opacityVector.insert(FloatAnimationValue::create(key, keyframeStyle->opacity(), tf)); |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2357 | |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2358 | if ((hasFilter && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyWebkitFilter)) |
commit-queue@webkit.org | 424b0fc | 2013-06-18 23:39:44 +0000 | [diff] [blame] | 2359 | filterVector.insert(FilterAnimationValue::create(key, keyframeStyle->filter(), tf)); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2360 | } |
| 2361 | |
dino@apple.com | 62700e4 | 2013-09-26 22:29:07 +0000 | [diff] [blame] | 2362 | if (renderer().frame().page() && !renderer().frame().page()->settings().acceleratedCompositedAnimationsEnabled()) |
| 2363 | return false; |
| 2364 | |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2365 | bool didAnimate = false; |
dino@apple.com | 62700e4 | 2013-09-26 22:29:07 +0000 | [diff] [blame] | 2366 | |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 2367 | if (hasTransform && m_graphicsLayer->addAnimation(transformVector, downcast<RenderBox>(renderer()).pixelSnappedBorderBoxRect().size(), anim, keyframes.animationName(), timeOffset)) |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2368 | didAnimate = true; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2369 | |
simon.fraser@apple.com | 73b2891 | 2012-05-03 18:15:41 +0000 | [diff] [blame] | 2370 | if (hasOpacity && m_graphicsLayer->addAnimation(opacityVector, IntSize(), anim, keyframes.animationName(), timeOffset)) |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2371 | didAnimate = true; |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 2372 | |
simon.fraser@apple.com | 73b2891 | 2012-05-03 18:15:41 +0000 | [diff] [blame] | 2373 | if (hasFilter && m_graphicsLayer->addAnimation(filterVector, IntSize(), anim, keyframes.animationName(), timeOffset)) |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2374 | didAnimate = true; |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2375 | |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2376 | return didAnimate; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2377 | } |
| 2378 | |
simon.fraser@apple.com | 1ae63fb | 2010-09-24 04:17:03 +0000 | [diff] [blame] | 2379 | void RenderLayerBacking::animationPaused(double timeOffset, const String& animationName) |
| 2380 | { |
| 2381 | m_graphicsLayer->pauseAnimation(animationName, timeOffset); |
| 2382 | } |
| 2383 | |
| 2384 | void RenderLayerBacking::animationFinished(const String& animationName) |
| 2385 | { |
| 2386 | m_graphicsLayer->removeAnimation(animationName); |
| 2387 | } |
| 2388 | |
alexis.menard@openbossa.org | 37efa87 | 2012-04-04 19:33:22 +0000 | [diff] [blame] | 2389 | bool RenderLayerBacking::startTransition(double timeOffset, CSSPropertyID property, const RenderStyle* fromStyle, const RenderStyle* toStyle) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2390 | { |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2391 | bool didAnimate = false; |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2392 | |
alexis.menard@openbossa.org | 37efa87 | 2012-04-04 19:33:22 +0000 | [diff] [blame] | 2393 | ASSERT(property != CSSPropertyInvalid); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2394 | |
alexis.menard@openbossa.org | 37efa87 | 2012-04-04 19:33:22 +0000 | [diff] [blame] | 2395 | if (property == CSSPropertyOpacity) { |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2396 | const Animation* opacityAnim = toStyle->transitionForProperty(CSSPropertyOpacity); |
| 2397 | if (opacityAnim && !opacityAnim->isEmptyOrZeroDuration()) { |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 2398 | KeyframeValueList opacityVector(AnimatedPropertyOpacity); |
andersca@apple.com | 963e45b | 2013-05-07 22:04:01 +0000 | [diff] [blame] | 2399 | opacityVector.insert(FloatAnimationValue::create(0, compositingOpacity(fromStyle->opacity()))); |
| 2400 | opacityVector.insert(FloatAnimationValue::create(1, compositingOpacity(toStyle->opacity()))); |
simon.fraser@apple.com | f159ab0 | 2009-09-17 20:12:50 +0000 | [diff] [blame] | 2401 | // The boxSize param is only used for transform animations (which can only run on RenderBoxes), so we pass an empty size here. |
zalan@apple.com | 1bc188e | 2014-03-09 20:27:31 +0000 | [diff] [blame] | 2402 | if (m_graphicsLayer->addAnimation(opacityVector, FloatSize(), opacityAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyOpacity), timeOffset)) { |
simon.fraser@apple.com | 99d1c05 | 2009-10-20 00:38:26 +0000 | [diff] [blame] | 2403 | // To ensure that the correct opacity is visible when the animation ends, also set the final opacity. |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 2404 | updateOpacity(*toStyle); |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2405 | didAnimate = true; |
simon.fraser@apple.com | 99d1c05 | 2009-10-20 00:38:26 +0000 | [diff] [blame] | 2406 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2407 | } |
| 2408 | } |
| 2409 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2410 | if (property == CSSPropertyWebkitTransform && m_owningLayer.hasTransform()) { |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2411 | const Animation* transformAnim = toStyle->transitionForProperty(CSSPropertyWebkitTransform); |
| 2412 | if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) { |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 2413 | KeyframeValueList transformVector(AnimatedPropertyWebkitTransform); |
andersca@apple.com | 963e45b | 2013-05-07 22:04:01 +0000 | [diff] [blame] | 2414 | transformVector.insert(TransformAnimationValue::create(0, fromStyle->transform())); |
| 2415 | transformVector.insert(TransformAnimationValue::create(1, toStyle->transform())); |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 2416 | if (m_graphicsLayer->addAnimation(transformVector, downcast<RenderBox>(renderer()).pixelSnappedBorderBoxRect().size(), transformAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitTransform), timeOffset)) { |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2417 | // To ensure that the correct transform is visible when the animation ends, also set the final transform. |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 2418 | updateTransform(*toStyle); |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2419 | didAnimate = true; |
simon.fraser@apple.com | 99d1c05 | 2009-10-20 00:38:26 +0000 | [diff] [blame] | 2420 | } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2421 | } |
| 2422 | } |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 2423 | |
akling@apple.com | c68fe75 | 2013-10-13 18:39:27 +0000 | [diff] [blame] | 2424 | if (property == CSSPropertyWebkitFilter && m_owningLayer.hasFilter()) { |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2425 | const Animation* filterAnim = toStyle->transitionForProperty(CSSPropertyWebkitFilter); |
| 2426 | if (filterAnim && !filterAnim->isEmptyOrZeroDuration()) { |
| 2427 | KeyframeValueList filterVector(AnimatedPropertyWebkitFilter); |
commit-queue@webkit.org | 424b0fc | 2013-06-18 23:39:44 +0000 | [diff] [blame] | 2428 | filterVector.insert(FilterAnimationValue::create(0, fromStyle->filter())); |
| 2429 | filterVector.insert(FilterAnimationValue::create(1, toStyle->filter())); |
zalan@apple.com | 1bc188e | 2014-03-09 20:27:31 +0000 | [diff] [blame] | 2430 | if (m_graphicsLayer->addAnimation(filterVector, FloatSize(), filterAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitFilter), timeOffset)) { |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2431 | // To ensure that the correct filter is visible when the animation ends, also set the final filter. |
simon.fraser@apple.com | 33e2545 | 2014-05-19 15:53:37 +0000 | [diff] [blame] | 2432 | updateFilters(*toStyle); |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2433 | didAnimate = true; |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2434 | } |
| 2435 | } |
| 2436 | } |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2437 | |
darin@apple.com | ac48be7 | 2013-05-07 04:31:35 +0000 | [diff] [blame] | 2438 | return didAnimate; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2439 | } |
| 2440 | |
alexis.menard@openbossa.org | 8fb368f | 2012-04-05 03:08:10 +0000 | [diff] [blame] | 2441 | void RenderLayerBacking::transitionPaused(double timeOffset, CSSPropertyID property) |
simon.fraser@apple.com | 1ae63fb | 2010-09-24 04:17:03 +0000 | [diff] [blame] | 2442 | { |
| 2443 | AnimatedPropertyID animatedProperty = cssToGraphicsLayerProperty(property); |
| 2444 | if (animatedProperty != AnimatedPropertyInvalid) |
| 2445 | m_graphicsLayer->pauseAnimation(GraphicsLayer::animationNameForTransition(animatedProperty), timeOffset); |
| 2446 | } |
| 2447 | |
alexis.menard@openbossa.org | 8fb368f | 2012-04-05 03:08:10 +0000 | [diff] [blame] | 2448 | void RenderLayerBacking::transitionFinished(CSSPropertyID property) |
simon.fraser@apple.com | 1ae63fb | 2010-09-24 04:17:03 +0000 | [diff] [blame] | 2449 | { |
| 2450 | AnimatedPropertyID animatedProperty = cssToGraphicsLayerProperty(property); |
| 2451 | if (animatedProperty != AnimatedPropertyInvalid) |
| 2452 | m_graphicsLayer->removeAnimation(GraphicsLayer::animationNameForTransition(animatedProperty)); |
| 2453 | } |
| 2454 | |
simon.fraser@apple.com | a30c96f | 2014-08-21 22:43:18 +0000 | [diff] [blame] | 2455 | void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, const String&, double time) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2456 | { |
cdumez@apple.com | bc6f740 | 2014-10-17 01:53:09 +0000 | [diff] [blame] | 2457 | renderer().animation().notifyAnimationStarted(renderer(), time); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2458 | } |
| 2459 | |
antti@apple.com | a6775c1 | 2013-04-05 21:19:56 +0000 | [diff] [blame] | 2460 | void RenderLayerBacking::notifyFlushRequired(const GraphicsLayer* layer) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2461 | { |
akling@apple.com | 32c7a6e | 2013-08-26 02:21:32 +0000 | [diff] [blame] | 2462 | if (renderer().documentBeingDestroyed()) |
antti@apple.com | a6775c1 | 2013-04-05 21:19:56 +0000 | [diff] [blame] | 2463 | return; |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2464 | compositor().scheduleLayerFlush(layer->canThrottleLayerFlush()); |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 2465 | } |
| 2466 | |
simon.fraser@apple.com | 90274bf | 2012-10-18 00:42:05 +0000 | [diff] [blame] | 2467 | void RenderLayerBacking::notifyFlushBeforeDisplayRefresh(const GraphicsLayer* layer) |
| 2468 | { |
akling@apple.com | c346604 | 2013-08-24 18:27:32 +0000 | [diff] [blame] | 2469 | compositor().notifyFlushBeforeDisplayRefresh(layer); |
simon.fraser@apple.com | 90274bf | 2012-10-18 00:42:05 +0000 | [diff] [blame] | 2470 | } |
| 2471 | |
simon.fraser@apple.com | 1ae63fb | 2010-09-24 04:17:03 +0000 | [diff] [blame] | 2472 | // This is used for the 'freeze' API, for testing only. |
simon.fraser@apple.com | 6510a13 | 2009-08-03 19:40:12 +0000 | [diff] [blame] | 2473 | void RenderLayerBacking::suspendAnimations(double time) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2474 | { |
simon.fraser@apple.com | 6510a13 | 2009-08-03 19:40:12 +0000 | [diff] [blame] | 2475 | m_graphicsLayer->suspendAnimations(time); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2476 | } |
| 2477 | |
| 2478 | void RenderLayerBacking::resumeAnimations() |
| 2479 | { |
| 2480 | m_graphicsLayer->resumeAnimations(); |
| 2481 | } |
| 2482 | |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 2483 | LayoutRect RenderLayerBacking::compositedBounds() const |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 2484 | { |
| 2485 | return m_compositedBounds; |
| 2486 | } |
| 2487 | |
allan.jensen@digia.com | d5cbc75 | 2013-08-13 17:08:19 +0000 | [diff] [blame] | 2488 | void RenderLayerBacking::setCompositedBounds(const LayoutRect& bounds) |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 2489 | { |
| 2490 | m_compositedBounds = bounds; |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 2491 | } |
simon.fraser@apple.com | ce9b3f0 | 2012-05-03 17:50:03 +0000 | [diff] [blame] | 2492 | |
bdakin@apple.com | 8af619c | 2013-11-21 21:57:53 +0000 | [diff] [blame] | 2493 | LayoutRect RenderLayerBacking::compositedBoundsIncludingMargin() const |
| 2494 | { |
| 2495 | TiledBacking* tiledBacking = this->tiledBacking(); |
| 2496 | if (!tiledBacking || !tiledBacking->hasMargins()) |
| 2497 | return compositedBounds(); |
| 2498 | |
| 2499 | LayoutRect boundsIncludingMargin = compositedBounds(); |
| 2500 | LayoutUnit leftMarginWidth = tiledBacking->leftMarginWidth(); |
| 2501 | LayoutUnit topMarginHeight = tiledBacking->topMarginHeight(); |
| 2502 | |
zalan@apple.com | a95fd6f | 2014-02-22 07:24:45 +0000 | [diff] [blame] | 2503 | boundsIncludingMargin.moveBy(LayoutPoint(-leftMarginWidth, -topMarginHeight)); |
| 2504 | boundsIncludingMargin.expand(leftMarginWidth + tiledBacking->rightMarginWidth(), topMarginHeight + tiledBacking->bottomMarginHeight()); |
bdakin@apple.com | 8af619c | 2013-11-21 21:57:53 +0000 | [diff] [blame] | 2505 | |
| 2506 | return boundsIncludingMargin; |
| 2507 | } |
| 2508 | |
alexis.menard@openbossa.org | 8fb368f | 2012-04-05 03:08:10 +0000 | [diff] [blame] | 2509 | CSSPropertyID RenderLayerBacking::graphicsLayerToCSSProperty(AnimatedPropertyID property) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2510 | { |
alexis.menard@openbossa.org | 8fb368f | 2012-04-05 03:08:10 +0000 | [diff] [blame] | 2511 | CSSPropertyID cssProperty = CSSPropertyInvalid; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2512 | switch (property) { |
| 2513 | case AnimatedPropertyWebkitTransform: |
| 2514 | cssProperty = CSSPropertyWebkitTransform; |
| 2515 | break; |
| 2516 | case AnimatedPropertyOpacity: |
| 2517 | cssProperty = CSSPropertyOpacity; |
| 2518 | break; |
| 2519 | case AnimatedPropertyBackgroundColor: |
| 2520 | cssProperty = CSSPropertyBackgroundColor; |
| 2521 | break; |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2522 | case AnimatedPropertyWebkitFilter: |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2523 | cssProperty = CSSPropertyWebkitFilter; |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2524 | break; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2525 | case AnimatedPropertyInvalid: |
| 2526 | ASSERT_NOT_REACHED(); |
| 2527 | } |
| 2528 | return cssProperty; |
| 2529 | } |
| 2530 | |
alexis.menard@openbossa.org | 8fb368f | 2012-04-05 03:08:10 +0000 | [diff] [blame] | 2531 | AnimatedPropertyID RenderLayerBacking::cssToGraphicsLayerProperty(CSSPropertyID cssProperty) |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2532 | { |
| 2533 | switch (cssProperty) { |
| 2534 | case CSSPropertyWebkitTransform: |
| 2535 | return AnimatedPropertyWebkitTransform; |
| 2536 | case CSSPropertyOpacity: |
| 2537 | return AnimatedPropertyOpacity; |
| 2538 | case CSSPropertyBackgroundColor: |
| 2539 | return AnimatedPropertyBackgroundColor; |
cmarrin@apple.com | 5b6f59f | 2012-02-10 19:41:35 +0000 | [diff] [blame] | 2540 | case CSSPropertyWebkitFilter: |
| 2541 | return AnimatedPropertyWebkitFilter; |
alexis.menard@openbossa.org | 8fb368f | 2012-04-05 03:08:10 +0000 | [diff] [blame] | 2542 | default: |
| 2543 | // It's fine if we see other css properties here; they are just not accelerated. |
| 2544 | break; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2545 | } |
| 2546 | return AnimatedPropertyInvalid; |
| 2547 | } |
| 2548 | |
simon.fraser@apple.com | b73688b | 2010-07-14 23:17:20 +0000 | [diff] [blame] | 2549 | CompositingLayerType RenderLayerBacking::compositingLayerType() const |
| 2550 | { |
simon.fraser@apple.com | ff54931 | 2014-04-19 05:31:39 +0000 | [diff] [blame] | 2551 | if (m_graphicsLayer->usesContentsLayer()) |
simon.fraser@apple.com | b73688b | 2010-07-14 23:17:20 +0000 | [diff] [blame] | 2552 | return MediaCompositingLayer; |
| 2553 | |
| 2554 | if (m_graphicsLayer->drawsContent()) |
simon.fraser@apple.com | fb15c72 | 2013-03-12 17:54:44 +0000 | [diff] [blame] | 2555 | return m_graphicsLayer->usingTiledBacking() ? TiledCompositingLayer : NormalCompositingLayer; |
simon.fraser@apple.com | b73688b | 2010-07-14 23:17:20 +0000 | [diff] [blame] | 2556 | |
| 2557 | return ContainerCompositingLayer; |
| 2558 | } |
| 2559 | |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2560 | double RenderLayerBacking::backingStoreMemoryEstimate() const |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2561 | { |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2562 | double backingMemory; |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2563 | |
simon.fraser@apple.com | ce5450e | 2013-01-16 02:01:39 +0000 | [diff] [blame] | 2564 | // m_ancestorClippingLayer, m_contentsContainmentLayer and m_childContainmentLayer are just used for masking or containment, so have no backing. |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2565 | backingMemory = m_graphicsLayer->backingStoreMemoryEstimate(); |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2566 | if (m_foregroundLayer) |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2567 | backingMemory += m_foregroundLayer->backingStoreMemoryEstimate(); |
simon.fraser@apple.com | ee9213c | 2013-01-18 00:10:53 +0000 | [diff] [blame] | 2568 | if (m_backgroundLayer) |
| 2569 | backingMemory += m_backgroundLayer->backingStoreMemoryEstimate(); |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2570 | if (m_maskLayer) |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2571 | backingMemory += m_maskLayer->backingStoreMemoryEstimate(); |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2572 | |
commit-queue@webkit.org | 45a7e93 | 2012-08-25 00:35:34 +0000 | [diff] [blame] | 2573 | if (m_scrollingContentsLayer) |
| 2574 | backingMemory += m_scrollingContentsLayer->backingStoreMemoryEstimate(); |
| 2575 | |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2576 | if (m_layerForHorizontalScrollbar) |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2577 | backingMemory += m_layerForHorizontalScrollbar->backingStoreMemoryEstimate(); |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2578 | |
| 2579 | if (m_layerForVerticalScrollbar) |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2580 | backingMemory += m_layerForVerticalScrollbar->backingStoreMemoryEstimate(); |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2581 | |
| 2582 | if (m_layerForScrollCorner) |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2583 | backingMemory += m_layerForScrollCorner->backingStoreMemoryEstimate(); |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2584 | |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 2585 | return backingMemory; |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 2586 | } |
| 2587 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 2588 | } // namespace WebCore |