2 Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
22 #if USE(UI_SIDE_COMPOSITING)
23 #include "LayerTreeHostProxy.h"
25 #include "LayerTreeHostMessages.h"
26 #include "UpdateInfo.h"
27 #include "WebCoreArgumentCoders.h"
28 #include "WebLayerTreeInfo.h"
29 #include "WebLayerTreeRenderer.h"
30 #include "WebPageProxy.h"
31 #include "WebProcessProxy.h"
35 using namespace WebCore;
37 LayerTreeHostProxy::LayerTreeHostProxy(DrawingAreaProxy* drawingAreaProxy)
38 : m_drawingAreaProxy(drawingAreaProxy)
39 #if !ENABLE(TIZEN_WEBKIT2_TILED_AC)
40 , m_renderer(adoptRef(new WebLayerTreeRenderer(this)))
42 , m_renderer(adoptRef(new WebLayerTreeRenderer(this, drawingAreaProxy)))
45 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
46 m_renderer->setActive(true);
50 LayerTreeHostProxy::~LayerTreeHostProxy()
55 void LayerTreeHostProxy::updateViewport()
57 m_drawingAreaProxy->updateViewport();
60 void LayerTreeHostProxy::dispatchUpdate(const Function<void()>& function)
62 m_renderer->appendUpdate(function);
65 void LayerTreeHostProxy::createTileForLayer(int layerID, int tileID, const IntRect& targetRect, const WebKit::SurfaceUpdateInfo& updateInfo)
67 dispatchUpdate(bind(&WebLayerTreeRenderer::createTile, m_renderer.get(), layerID, tileID, updateInfo.scaleFactor));
68 updateTileForLayer(layerID, tileID, targetRect, updateInfo);
71 void LayerTreeHostProxy::updateTileForLayer(int layerID, int tileID, const IntRect& targetRect, const WebKit::SurfaceUpdateInfo& updateInfo)
73 RefPtr<ShareableSurface> surface = ShareableSurface::create(updateInfo.surfaceHandle);
74 dispatchUpdate(bind(&WebLayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, surface, updateInfo.surfaceOffset)));
77 void LayerTreeHostProxy::removeTileForLayer(int layerID, int tileID)
79 dispatchUpdate(bind(&WebLayerTreeRenderer::removeTile, m_renderer.get(), layerID, tileID));
82 void LayerTreeHostProxy::deleteCompositingLayer(WebLayerID id)
84 dispatchUpdate(bind(&WebLayerTreeRenderer::deleteLayer, m_renderer.get(), id));
85 #if !ENABLE(TIZEN_WEBKIT2_TILED_AC)
86 // For efl port, we should not call updateViewport here immediately.
87 // This may trigger rendering with broken LayerTreeHost.
88 // And actually, we don't need to call this here, because it will be called by didRenderFrame for each update of LayerTreeHost.
93 void LayerTreeHostProxy::setRootCompositingLayer(WebLayerID id)
95 dispatchUpdate(bind(&WebLayerTreeRenderer::setRootLayerID, m_renderer.get(), id));
99 void LayerTreeHostProxy::setCompositingLayerState(WebLayerID id, const WebLayerInfo& info)
101 dispatchUpdate(bind(&WebLayerTreeRenderer::setLayerState, m_renderer.get(), id, info));
104 void LayerTreeHostProxy::setCompositingLayerChildren(WebLayerID id, const Vector<WebLayerID>& children)
106 dispatchUpdate(bind(&WebLayerTreeRenderer::setLayerChildren, m_renderer.get(), id, children));
109 #if ENABLE(CSS_FILTERS)
110 void LayerTreeHostProxy::setCompositingLayerFilters(WebLayerID id, const FilterOperations& filters)
112 dispatchUpdate(bind(&WebLayerTreeRenderer::setLayerFilters, m_renderer.get(), id, filters));
116 void LayerTreeHostProxy::didRenderFrame()
118 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
119 m_renderer->doOneShotDrawingSynchronization();
121 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
122 m_drawingAreaProxy->page()->updateLayoutAndScaleIfNeeded();
125 m_drawingAreaProxy->page()->didRenderFrame();
127 dispatchUpdate(bind(&WebLayerTreeRenderer::flushLayerChanges, m_renderer.get()));
131 void LayerTreeHostProxy::createDirectlyCompositedImage(int64_t key, const WebKit::ShareableBitmap::Handle& handle)
133 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
134 dispatchUpdate(bind(&WebLayerTreeRenderer::createImage, m_renderer.get(), key, bitmap));
137 void LayerTreeHostProxy::destroyDirectlyCompositedImage(int64_t key)
139 dispatchUpdate(bind(&WebLayerTreeRenderer::destroyImage, m_renderer.get(), key));
142 void LayerTreeHostProxy::setContentsSize(const FloatSize& contentsSize)
144 dispatchUpdate(bind(&WebLayerTreeRenderer::setContentsSize, m_renderer.get(), contentsSize));
147 void LayerTreeHostProxy::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector, const WebCore::FloatPoint& accurateVisibleContentsPosition)
149 dispatchUpdate(bind(&WebLayerTreeRenderer::setVisibleContentsRect, m_renderer.get(), rect, scale, accurateVisibleContentsPosition));
150 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentsRect(rect, scale, trajectoryVector), m_drawingAreaProxy->page()->pageID());
153 void LayerTreeHostProxy::renderNextFrame()
155 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
158 void LayerTreeHostProxy::didChangeScrollPosition(const IntPoint& position)
160 dispatchUpdate(bind(&WebLayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position));
163 void LayerTreeHostProxy::purgeBackingStores()
165 m_renderer->setActive(false);
166 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
169 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
170 void LayerTreeHostProxy::clearBackingStores()
172 m_renderer->syncRemoteContent();
173 m_renderer->clearBackingStores();
174 purgeBackingStores();
177 void LayerTreeHostProxy::restoreBackingStores()
179 m_renderer->setActive(true);
184 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
185 void LayerTreeHostProxy::setNeedsOneShotDrawingSynchronization()
187 m_renderer->setNeedsOneShotDrawingSynchronization();
190 void LayerTreeHostProxy::doOneShotDrawingSynchronization()
192 m_renderer->doOneShotDrawingSynchronization();
196 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
197 bool LayerTreeHostProxy::hasOverflowLayer() const
199 return m_renderer->scrollingContentsLayerCounts() ? true : false;
203 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
204 bool LayerTreeHostProxy::setOffsetForFocusedScrollingContentsLayer(const WebCore::FloatPoint& offset)
206 return m_renderer && m_renderer->setOffset(m_renderer->focusedLayerID(), offset);
209 void LayerTreeHostProxy::setVisibleContentsRectForScrollingContentsLayers(const WebCore::IntRect& visibleRect)
212 m_renderer->setVisibleContentsRectForScrollingContentsLayers(visibleRect);
216 #endif // USE(UI_SIDE_COMPOSITING)