summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/CoordinatedGraphics
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/WebKit2/UIProcess/CoordinatedGraphics
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit2/UIProcess/CoordinatedGraphics')
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp195
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.h87
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp103
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h75
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in27
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp256
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h115
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in59
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp744
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h209
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h60
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/WebPageProxyCoordinatedGraphics.cpp55
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp515
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h206
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/WebViewClient.cpp146
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/WebViewClient.h71
16 files changed, 1258 insertions, 1665 deletions
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp
deleted file mode 100644
index 17c18bd1a..000000000
--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "CoordinatedBackingStore.h"
-
-#if USE(COORDINATED_GRAPHICS)
-#include "GraphicsLayer.h"
-#include "ShareableSurface.h"
-#include "TextureMapper.h"
-#include "TextureMapperGL.h"
-
-using namespace WebCore;
-
-namespace WebKit {
-
-void CoordinatedBackingStoreTile::swapBuffers(WebCore::TextureMapper* textureMapper)
-{
- if (!m_surface)
- return;
-
- FloatRect tileRect(m_tileRect);
- tileRect.scale(1. / m_scale);
- bool shouldReset = false;
- if (tileRect != rect()) {
- setRect(tileRect);
- shouldReset = true;
- }
- RefPtr<BitmapTexture> texture = this->texture();
- if (!texture) {
- texture = textureMapper->createTexture();
- setTexture(texture.get());
- shouldReset = true;
- }
-
- ASSERT(textureMapper->maxTextureSize().width() >= m_tileRect.size().width() && textureMapper->maxTextureSize().height() >= m_tileRect.size().height());
- if (shouldReset)
- texture->reset(m_tileRect.size(), m_surface->flags() & ShareableBitmap::SupportsAlpha ? BitmapTexture::SupportsAlpha : 0);
-
- m_surface->copyToTexture(texture, m_sourceRect, m_surfaceOffset);
- m_surface.clear();
-}
-
-void CoordinatedBackingStoreTile::setBackBuffer(const IntRect& tileRect, const IntRect& sourceRect, PassRefPtr<ShareableSurface> buffer, const IntPoint& offset)
-{
- m_sourceRect = sourceRect;
- m_tileRect = tileRect;
- m_surfaceOffset = offset;
- m_surface = buffer;
-}
-
-void CoordinatedBackingStore::createTile(int id, float scale)
-{
- m_tiles.add(id, CoordinatedBackingStoreTile(scale));
- m_scale = scale;
-}
-
-void CoordinatedBackingStore::removeTile(int id)
-{
- ASSERT(m_tiles.contains(id));
- m_tilesToRemove.add(id);
-}
-
-void CoordinatedBackingStore::removeAllTiles()
-{
- HashMap<int, CoordinatedBackingStoreTile>::iterator end = m_tiles.end();
- for (HashMap<int, CoordinatedBackingStoreTile>::iterator it = m_tiles.begin(); it != end; ++it)
- m_tilesToRemove.add(it->key);
-}
-
-void CoordinatedBackingStore::updateTile(int id, const IntRect& sourceRect, const IntRect& tileRect, PassRefPtr<ShareableSurface> backBuffer, const IntPoint& offset)
-{
- HashMap<int, CoordinatedBackingStoreTile>::iterator it = m_tiles.find(id);
- ASSERT(it != m_tiles.end());
- it->value.incrementRepaintCount();
- it->value.setBackBuffer(tileRect, sourceRect, backBuffer, offset);
-}
-
-PassRefPtr<BitmapTexture> CoordinatedBackingStore::texture() const
-{
- HashMap<int, CoordinatedBackingStoreTile>::const_iterator end = m_tiles.end();
- for (HashMap<int, CoordinatedBackingStoreTile>::const_iterator it = m_tiles.begin(); it != end; ++it) {
- RefPtr<BitmapTexture> texture = it->value.texture();
- if (texture)
- return texture;
- }
-
- return PassRefPtr<BitmapTexture>();
-}
-
-void CoordinatedBackingStore::setSize(const WebCore::FloatSize& size)
-{
- m_pendingSize = size;
-}
-
-static bool shouldShowTileDebugVisuals()
-{
-#if PLATFORM(QT)
- return (qgetenv("QT_WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS") == "1");
-#elif USE(CAIRO)
- return (String(getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS")) == "1");
-#endif
- return false;
-}
-
-void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, BitmapTexture* mask, const FloatRect& rect)
-{
- for (size_t i = 0; i < tiles.size(); ++i) {
- TextureMapperTile* tile = tiles[i];
- tile->paint(textureMapper, transform, opacity, mask, calculateExposedTileEdges(rect, tile->rect()));
- static bool shouldDebug = shouldShowTileDebugVisuals();
- if (!shouldDebug)
- continue;
-
- textureMapper->drawBorder(Color(0xFF, 0, 0), 2, tile->rect(), transform);
- textureMapper->drawRepaintCounter(static_cast<CoordinatedBackingStoreTile*>(tile)->repaintCount(), 8, tile->rect().location(), transform);
- }
-}
-
-void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
-{
- if (m_tiles.isEmpty())
- return;
- ASSERT(!m_size.isZero());
-
- Vector<TextureMapperTile*> tilesToPaint;
- Vector<TextureMapperTile*> previousTilesToPaint;
-
- // We have to do this every time we paint, in case the opacity has changed.
- HashMap<int, CoordinatedBackingStoreTile>::iterator end = m_tiles.end();
- FloatRect coveredRect;
- for (HashMap<int, CoordinatedBackingStoreTile>::iterator it = m_tiles.begin(); it != end; ++it) {
- CoordinatedBackingStoreTile& tile = it->value;
- if (!tile.texture())
- continue;
-
- if (tile.scale() == m_scale) {
- tilesToPaint.append(&tile);
- coveredRect.unite(tile.rect());
- continue;
- }
-
- // Only show the previous tile if the opacity is high, otherwise effect looks like a bug.
- // We show the previous-scale tile anyway if it doesn't intersect with any current-scale tile.
- if (opacity < 0.95 && coveredRect.intersects(tile.rect()))
- continue;
-
- previousTilesToPaint.append(&tile);
- }
-
- FloatRect rectOnContents(FloatPoint::zero(), m_size);
- TransformationMatrix adjustedTransform = transform;
- // targetRect is on the contents coordinate system, so we must compare two rects on the contents coordinate system.
- // See TiledBackingStore.
- adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
-
- paintTilesToTextureMapper(previousTilesToPaint, textureMapper, adjustedTransform, opacity, mask, rectOnContents);
- paintTilesToTextureMapper(tilesToPaint, textureMapper, adjustedTransform, opacity, mask, rectOnContents);
-}
-
-void CoordinatedBackingStore::commitTileOperations(TextureMapper* textureMapper)
-{
- HashSet<int>::iterator tilesToRemoveEnd = m_tilesToRemove.end();
- if (!m_pendingSize.isZero()) {
- m_size = m_pendingSize;
- m_pendingSize = FloatSize();
- }
-
- for (HashSet<int>::iterator it = m_tilesToRemove.begin(); it != tilesToRemoveEnd; ++it)
- m_tiles.remove(*it);
- m_tilesToRemove.clear();
-
- HashMap<int, CoordinatedBackingStoreTile>::iterator tilesEnd = m_tiles.end();
- for (HashMap<int, CoordinatedBackingStoreTile>::iterator it = m_tiles.begin(); it != tilesEnd; ++it)
- it->value.swapBuffers(textureMapper);
-}
-
-} // namespace WebKit
-#endif
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.h
deleted file mode 100644
index 3b747372d..000000000
--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
- */
-
-#ifndef CoordinatedBackingStore_h
-#define CoordinatedBackingStore_h
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include "TextureMapper.h"
-#include "TextureMapperBackingStore.h"
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-
-namespace WebKit {
-
-class ShareableSurface;
-
-class CoordinatedBackingStoreTile : public WebCore::TextureMapperTile {
-public:
- explicit CoordinatedBackingStoreTile(float scale = 1)
- : TextureMapperTile(WebCore::FloatRect())
- , m_scale(scale)
- , m_repaintCount(0)
- {
- }
-
- inline float scale() const { return m_scale; }
- inline void incrementRepaintCount() { ++m_repaintCount; }
- inline int repaintCount() const { return m_repaintCount; }
- void swapBuffers(WebCore::TextureMapper*);
- void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableSurface> buffer, const WebCore::IntPoint&);
-
-private:
- RefPtr<ShareableSurface> m_surface;
- WebCore::IntRect m_sourceRect;
- WebCore::IntRect m_tileRect;
- WebCore::IntPoint m_surfaceOffset;
- float m_scale;
- int m_repaintCount;
-};
-
-class CoordinatedBackingStore : public WebCore::TextureMapperBackingStore {
-public:
- void createTile(int, float);
- void removeTile(int);
- void removeAllTiles();
- void updateTile(int, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableSurface>, const WebCore::IntPoint&);
- static PassRefPtr<CoordinatedBackingStore> create() { return adoptRef(new CoordinatedBackingStore); }
- void commitTileOperations(WebCore::TextureMapper*);
- PassRefPtr<WebCore::BitmapTexture> texture() const;
- void setSize(const WebCore::FloatSize&);
- virtual void paintToTextureMapper(WebCore::TextureMapper*, const WebCore::FloatRect&, const WebCore::TransformationMatrix&, float, WebCore::BitmapTexture*);
-
-private:
- CoordinatedBackingStore()
- : m_scale(1.)
- { }
- void paintTilesToTextureMapper(Vector<WebCore::TextureMapperTile*>&, WebCore::TextureMapper*, const WebCore::TransformationMatrix&, float, WebCore::BitmapTexture*, const WebCore::FloatRect&);
-
- HashMap<int, CoordinatedBackingStoreTile> m_tiles;
- HashSet<int> m_tilesToRemove;
- WebCore::FloatSize m_size;
- float m_scale;
- // FIXME: m_pendingSize should be removed after the following bug is fixed: https://bugs.webkit.org/show_bug.cgi?id=108294
- WebCore::FloatSize m_pendingSize;
-};
-
-} // namespace WebKit
-#endif
-
-#endif // CoordinatedBackingStore_h
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp
new file mode 100644
index 000000000..d42dcfdf3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp
@@ -0,0 +1,103 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2013 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedLayerTreeHostProxy.h"
+
+#include "CoordinatedLayerTreeHostMessages.h"
+#include "CoordinatedLayerTreeHostProxyMessages.h"
+#include "DrawingAreaProxy.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include <WebCore/CoordinatedGraphicsState.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+CoordinatedLayerTreeHostProxy::CoordinatedLayerTreeHostProxy(DrawingAreaProxy* drawingAreaProxy)
+ : m_drawingAreaProxy(drawingAreaProxy)
+ , m_scene(adoptRef(new CoordinatedGraphicsScene(this)))
+{
+ m_drawingAreaProxy->page()->process()->addMessageReceiver(Messages::CoordinatedLayerTreeHostProxy::messageReceiverName(), m_drawingAreaProxy->page()->pageID(), this);
+}
+
+CoordinatedLayerTreeHostProxy::~CoordinatedLayerTreeHostProxy()
+{
+ m_drawingAreaProxy->page()->process()->removeMessageReceiver(Messages::CoordinatedLayerTreeHostProxy::messageReceiverName(), m_drawingAreaProxy->page()->pageID());
+ m_scene->detach();
+}
+
+void CoordinatedLayerTreeHostProxy::updateViewport()
+{
+ m_drawingAreaProxy->updateViewport();
+}
+
+void CoordinatedLayerTreeHostProxy::dispatchUpdate(const Function<void()>& function)
+{
+ m_scene->appendUpdate(function);
+}
+
+void CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState(const CoordinatedGraphicsState& graphicsState)
+{
+ dispatchUpdate(bind(&CoordinatedGraphicsScene::commitSceneState, m_scene.get(), graphicsState));
+ updateViewport();
+#if USE(TILED_BACKING_STORE)
+ m_drawingAreaProxy->page()->didRenderFrame(graphicsState.contentsSize, graphicsState.coveredRect);
+#endif
+}
+
+void CoordinatedLayerTreeHostProxy::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
+{
+ // Inform the renderer to adjust viewport-fixed layers.
+ dispatchUpdate(bind(&CoordinatedGraphicsScene::setScrollPosition, m_scene.get(), rect.location()));
+
+ if (rect == m_lastSentVisibleRect && trajectoryVector == m_lastSentTrajectoryVector)
+ return;
+
+ m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::SetVisibleContentsRect(rect, trajectoryVector), m_drawingAreaProxy->page()->pageID());
+ m_lastSentVisibleRect = rect;
+ m_lastSentTrajectoryVector = trajectoryVector;
+}
+
+void CoordinatedLayerTreeHostProxy::renderNextFrame()
+{
+ m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
+}
+
+void CoordinatedLayerTreeHostProxy::purgeBackingStores()
+{
+ m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
+}
+
+void CoordinatedLayerTreeHostProxy::setBackgroundColor(const Color& color)
+{
+ dispatchUpdate(bind(&CoordinatedGraphicsScene::setBackgroundColor, m_scene.get(), color));
+}
+
+void CoordinatedLayerTreeHostProxy::commitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+ m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::CommitScrollOffset(layerID, offset), m_drawingAreaProxy->page()->pageID());
+}
+
+}
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h
new file mode 100644
index 000000000..2fb17b3ed
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h
@@ -0,0 +1,75 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2013 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CoordinatedLayerTreeHostProxy_h
+#define CoordinatedLayerTreeHostProxy_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "CoordinatedGraphicsArgumentCoders.h"
+#include "MessageReceiver.h"
+#include <WebCore/CoordinatedGraphicsScene.h>
+#include <wtf/Functional.h>
+
+namespace WebCore {
+class CoordinatedGraphicsState;
+class IntSize;
+}
+
+namespace WebKit {
+
+class DrawingAreaProxy;
+
+class CoordinatedLayerTreeHostProxy : public WebCore::CoordinatedGraphicsSceneClient, public CoreIPC::MessageReceiver {
+ WTF_MAKE_NONCOPYABLE(CoordinatedLayerTreeHostProxy);
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ explicit CoordinatedLayerTreeHostProxy(DrawingAreaProxy*);
+ virtual ~CoordinatedLayerTreeHostProxy();
+
+ void commitCoordinatedGraphicsState(const WebCore::CoordinatedGraphicsState&);
+ void setBackgroundColor(const WebCore::Color&);
+
+ void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint& trajectoryVector);
+ WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene() const { return m_scene.get(); }
+
+ virtual void updateViewport() OVERRIDE;
+ virtual void renderNextFrame() OVERRIDE;
+ virtual void purgeBackingStores() OVERRIDE;
+
+ virtual void commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);
+
+protected:
+ void dispatchUpdate(const Function<void()>&);
+
+ // CoreIPC::MessageReceiver
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
+
+ DrawingAreaProxy* m_drawingAreaProxy;
+ RefPtr<WebCore::CoordinatedGraphicsScene> m_scene;
+ WebCore::FloatRect m_lastSentVisibleRect;
+ WebCore::FloatPoint m_lastSentTrajectoryVector;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedLayerTreeHostProxy_h
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in
new file mode 100644
index 000000000..ae84b4395
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in
@@ -0,0 +1,27 @@
+#
+# Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+# Copyright (C) 2013 Company 100, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+
+#if USE(COORDINATED_GRAPHICS)
+messages -> CoordinatedLayerTreeHostProxy {
+
+ CommitCoordinatedGraphicsState(WebCore::CoordinatedGraphicsState state)
+ SetBackgroundColor(WebCore::Color color)
+}
+#endif
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp
deleted file mode 100644
index 9cb2c1bc5..000000000
--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if USE(COORDINATED_GRAPHICS)
-#include "LayerTreeCoordinatorProxy.h"
-
-#include "LayerTreeCoordinatorMessages.h"
-#include "LayerTreeRenderer.h"
-#include "UpdateInfo.h"
-#include "WebCoreArgumentCoders.h"
-#include "WebLayerTreeInfo.h"
-#include "WebPageProxy.h"
-#include "WebProcessProxy.h"
-#include <WebCore/GraphicsSurface.h>
-
-#if ENABLE(CSS_SHADERS)
-#include "CustomFilterProgramInfo.h"
-#endif
-
-namespace WebKit {
-
-using namespace WebCore;
-
-LayerTreeCoordinatorProxy::LayerTreeCoordinatorProxy(DrawingAreaProxy* drawingAreaProxy)
- : m_drawingAreaProxy(drawingAreaProxy)
- , m_renderer(adoptRef(new LayerTreeRenderer(this)))
- , m_lastSentScale(0)
-{
-}
-
-LayerTreeCoordinatorProxy::~LayerTreeCoordinatorProxy()
-{
- m_renderer->detach();
-}
-
-void LayerTreeCoordinatorProxy::updateViewport()
-{
- m_drawingAreaProxy->updateViewport();
-}
-
-float LayerTreeCoordinatorProxy::deviceScaleFactor() const
-{
- return m_drawingAreaProxy->page()->deviceScaleFactor();
-}
-
-void LayerTreeCoordinatorProxy::dispatchUpdate(const Function<void()>& function)
-{
- m_renderer->appendUpdate(function);
-}
-
-void LayerTreeCoordinatorProxy::createTileForLayer(int layerID, int tileID, const WebCore::IntRect& tileRect, const WebKit::SurfaceUpdateInfo& updateInfo)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::createTile, m_renderer.get(), layerID, tileID, updateInfo.scaleFactor));
- updateTileForLayer(layerID, tileID, tileRect, updateInfo);
-}
-
-void LayerTreeCoordinatorProxy::updateTileForLayer(int layerID, int tileID, const IntRect& tileRect, const WebKit::SurfaceUpdateInfo& updateInfo)
-{
- SurfaceMap::iterator it = m_surfaces.find(updateInfo.atlasID);
- ASSERT(it != m_surfaces.end());
- dispatchUpdate(bind(&LayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, LayerTreeRenderer::TileUpdate(updateInfo.updateRect, tileRect, it->value, updateInfo.surfaceOffset)));
-}
-
-void LayerTreeCoordinatorProxy::removeTileForLayer(int layerID, int tileID)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::removeTile, m_renderer.get(), layerID, tileID));
-}
-
-void LayerTreeCoordinatorProxy::createUpdateAtlas(int atlasID, const ShareableSurface::Handle& handle)
-{
- ASSERT(!m_surfaces.contains(atlasID));
- m_surfaces.add(atlasID, ShareableSurface::create(handle));
-}
-
-void LayerTreeCoordinatorProxy::removeUpdateAtlas(int atlasID)
-{
- ASSERT(m_surfaces.contains(atlasID));
- m_surfaces.remove(atlasID);
-}
-
-void LayerTreeCoordinatorProxy::deleteCompositingLayer(WebLayerID id)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::deleteLayer, m_renderer.get(), id));
- updateViewport();
-}
-
-void LayerTreeCoordinatorProxy::setRootCompositingLayer(WebLayerID id)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::setRootLayerID, m_renderer.get(), id));
- updateViewport();
-}
-
-void LayerTreeCoordinatorProxy::setCompositingLayerState(WebLayerID id, const WebLayerInfo& info)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::setLayerState, m_renderer.get(), id, info));
-}
-
-void LayerTreeCoordinatorProxy::setCompositingLayerChildren(WebLayerID id, const Vector<WebLayerID>& children)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::setLayerChildren, m_renderer.get(), id, children));
-}
-
-#if ENABLE(CSS_FILTERS)
-void LayerTreeCoordinatorProxy::setCompositingLayerFilters(WebLayerID id, const FilterOperations& filters)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::setLayerFilters, m_renderer.get(), id, filters));
-}
-#endif
-
-#if ENABLE(CSS_SHADERS)
-void LayerTreeCoordinatorProxy::removeCustomFilterProgram(int id)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::removeCustomFilterProgram, m_renderer.get(), id));
-}
-void LayerTreeCoordinatorProxy::createCustomFilterProgram(int id, const WebCore::CustomFilterProgramInfo& programInfo)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::createCustomFilterProgram, m_renderer.get(), id, programInfo));
-}
-#endif
-
-void LayerTreeCoordinatorProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::flushLayerChanges, m_renderer.get()));
- updateViewport();
-#if USE(TILED_BACKING_STORE)
- m_drawingAreaProxy->page()->didRenderFrame(contentsSize, coveredRect);
-#else
- UNUSED_PARAM(contentsSize);
- UNUSED_PARAM(coveredRect);
-#endif
-}
-
-void LayerTreeCoordinatorProxy::createImageBacking(CoordinatedImageBackingID imageID)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::createImageBacking, m_renderer.get(), imageID));
-}
-
-void LayerTreeCoordinatorProxy::updateImageBacking(CoordinatedImageBackingID imageID, const ShareableSurface::Handle& handle)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::updateImageBacking, m_renderer.get(), imageID, ShareableSurface::create(handle)));
-}
-
-void LayerTreeCoordinatorProxy::clearImageBackingContents(CoordinatedImageBackingID imageID)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::clearImageBackingContents, m_renderer.get(), imageID));
-}
-
-void LayerTreeCoordinatorProxy::removeImageBacking(CoordinatedImageBackingID imageID)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::removeImageBacking, m_renderer.get(), imageID));
-}
-
-void LayerTreeCoordinatorProxy::setContentsSize(const FloatSize& contentsSize)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::setContentsSize, m_renderer.get(), contentsSize));
-}
-
-void LayerTreeCoordinatorProxy::setLayerAnimations(WebLayerID id, const GraphicsLayerAnimations& animations)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::setLayerAnimations, m_renderer.get(), id, animations));
-}
-
-void LayerTreeCoordinatorProxy::setAnimationsLocked(bool locked)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::setAnimationsLocked, m_renderer.get(), locked));
-}
-
-void LayerTreeCoordinatorProxy::setVisibleContentsRect(const FloatRect& rect, float pageScaleFactor, const FloatPoint& trajectoryVector)
-{
- // Inform the renderer to adjust viewport-fixed layers.
- dispatchUpdate(bind(&LayerTreeRenderer::setVisibleContentsRect, m_renderer.get(), rect));
-
- // Round the rect instead of enclosing it to make sure that its size stays the same while panning. This can have nasty effects on layout.
- IntRect roundedRect = roundedIntRect(rect);
- const float effectiveScale = deviceScaleFactor() * pageScaleFactor;
- if (roundedRect == m_lastSentVisibleRect && effectiveScale == m_lastSentScale && trajectoryVector == m_lastSentTrajectoryVector)
- return;
-
- m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::SetVisibleContentsRect(roundedRect, effectiveScale, trajectoryVector), m_drawingAreaProxy->page()->pageID());
- m_lastSentVisibleRect = roundedRect;
- m_lastSentScale = effectiveScale;
- m_lastSentTrajectoryVector = trajectoryVector;
-}
-
-void LayerTreeCoordinatorProxy::renderNextFrame()
-{
- m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
-}
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-void LayerTreeCoordinatorProxy::requestAnimationFrame()
-{
- dispatchUpdate(bind(&LayerTreeRenderer::requestAnimationFrame, m_renderer.get()));
- updateViewport();
-}
-
-void LayerTreeCoordinatorProxy::animationFrameReady()
-{
- m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::AnimationFrameReady(), m_drawingAreaProxy->page()->pageID());
-}
-#endif
-
-void LayerTreeCoordinatorProxy::didChangeScrollPosition(const IntPoint& position)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position));
-}
-
-#if USE(GRAPHICS_SURFACE)
-void LayerTreeCoordinatorProxy::createCanvas(WebLayerID id, const IntSize& canvasSize, const GraphicsSurfaceToken& token)
-{
- GraphicsSurface::Flags surfaceFlags = GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
- dispatchUpdate(bind(&LayerTreeRenderer::createCanvas, m_renderer.get(), id, canvasSize, GraphicsSurface::create(canvasSize, surfaceFlags, token)));
-}
-
-void LayerTreeCoordinatorProxy::syncCanvas(WebLayerID id, uint32_t frontBuffer)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::syncCanvas, m_renderer.get(), id, frontBuffer));
-}
-
-void LayerTreeCoordinatorProxy::destroyCanvas(WebLayerID id)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::destroyCanvas, m_renderer.get(), id));
-}
-#endif
-
-void LayerTreeCoordinatorProxy::purgeBackingStores()
-{
- m_surfaces.clear();
- m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
-}
-
-void LayerTreeCoordinatorProxy::setBackgroundColor(const WebCore::Color& color)
-{
- dispatchUpdate(bind(&LayerTreeRenderer::setBackgroundColor, m_renderer.get(), color));
-}
-
-}
-#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h
deleted file mode 100644
index a3961ffef..000000000
--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef LayerTreeCoordinatorProxy_h
-#define LayerTreeCoordinatorProxy_h
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include "BackingStore.h"
-#include "CoordinatedGraphicsArgumentCoders.h"
-#include "DrawingAreaProxy.h"
-#include "Region.h"
-#include "ShareableSurface.h"
-#include "SurfaceUpdateInfo.h"
-#include "WebLayerTreeInfo.h"
-#include <WebCore/GraphicsContext.h>
-#include <WebCore/GraphicsLayer.h>
-#include <WebCore/GraphicsLayerAnimation.h>
-#include <WebCore/GraphicsSurfaceToken.h>
-#include <WebCore/IntRect.h>
-#include <WebCore/IntSize.h>
-#include <WebCore/RunLoop.h>
-#include <WebCore/Timer.h>
-#include <wtf/Functional.h>
-#include <wtf/HashSet.h>
-
-namespace WebKit {
-
-class WebLayerInfo;
-class LayerTreeRenderer;
-class WebLayerUpdateInfo;
-
-class LayerTreeCoordinatorProxy {
- WTF_MAKE_NONCOPYABLE(LayerTreeCoordinatorProxy);
- WTF_MAKE_FAST_ALLOCATED;
-public:
- explicit LayerTreeCoordinatorProxy(DrawingAreaProxy*);
- ~LayerTreeCoordinatorProxy();
- void setCompositingLayerState(WebLayerID, const WebLayerInfo&);
- void setCompositingLayerChildren(WebLayerID, const Vector<WebLayerID>&);
-#if ENABLE(CSS_FILTERS)
- void setCompositingLayerFilters(WebLayerID, const WebCore::FilterOperations&);
-#endif
-#if ENABLE(CSS_SHADERS)
- void createCustomFilterProgram(int id, const WebCore::CustomFilterProgramInfo&);
- void removeCustomFilterProgram(int id);
-#endif
- void deleteCompositingLayer(WebLayerID);
- void setRootCompositingLayer(WebLayerID);
- void setContentsSize(const WebCore::FloatSize&);
- void setVisibleContentsRect(const WebCore::FloatRect&, float pageScaleFactor, const WebCore::FloatPoint& trajectoryVector);
- void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect);
- void createTileForLayer(int layerID, int tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&);
- void updateTileForLayer(int layerID, int tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&);
- void removeTileForLayer(int layerID, int tileID);
- void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&);
- void removeUpdateAtlas(int atlasID);
- void createImageBacking(CoordinatedImageBackingID);
- void updateImageBacking(CoordinatedImageBackingID, const ShareableSurface::Handle&);
- void clearImageBackingContents(CoordinatedImageBackingID);
- void removeImageBacking(CoordinatedImageBackingID);
- void didReceiveLayerTreeCoordinatorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
- void updateViewport();
- void renderNextFrame();
- void didChangeScrollPosition(const WebCore::IntPoint& position);
-#if USE(GRAPHICS_SURFACE)
- void createCanvas(WebLayerID, const WebCore::IntSize&, const WebCore::GraphicsSurfaceToken&);
- void syncCanvas(WebLayerID, uint32_t frontBuffer);
- void destroyCanvas(WebLayerID);
-#endif
- void purgeBackingStores();
- LayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); }
- void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&);
- void setAnimationsLocked(bool);
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- void requestAnimationFrame();
- void animationFrameReady();
-#endif
- void setBackgroundColor(const WebCore::Color&);
-
- float deviceScaleFactor() const;
-
-protected:
- void dispatchUpdate(const Function<void()>&);
-
- DrawingAreaProxy* m_drawingAreaProxy;
- RefPtr<LayerTreeRenderer> m_renderer;
- WebCore::IntRect m_lastSentVisibleRect;
- float m_lastSentScale;
- WebCore::FloatPoint m_lastSentTrajectoryVector;
- typedef HashMap<int /* atlasID */, RefPtr<ShareableSurface> > SurfaceMap;
- SurfaceMap m_surfaces;
-};
-
-}
-
-#endif
-
-#endif // LayerTreeCoordinatorProxy_h
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in
deleted file mode 100644
index 42c69bbef..000000000
--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public License
-# along with this library; see the file COPYING.LIB. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-# Boston, MA 02110-1301, USA.
-#
-
-#if USE(COORDINATED_GRAPHICS)
-messages -> LayerTreeCoordinatorProxy {
- SetCompositingLayerState(uint32_t id, WebKit::WebLayerInfo layerInfo)
- SetCompositingLayerChildren(uint32_t id, Vector<uint32_t> children)
-#if ENABLE(CSS_FILTERS)
- SetCompositingLayerFilters(uint32_t id, WebCore::FilterOperations filters)
-#endif
-#if ENABLE(CSS_SHADERS)
- CreateCustomFilterProgram(int id, WebCore::CustomFilterProgramInfo programInfo)
- RemoveCustomFilterProgram(int id)
-#endif
- SetRootCompositingLayer(uint32_t id)
- DeleteCompositingLayer(uint32_t id)
- CreateTileForLayer(uint32_t layerID, int tileID, WebCore::IntRect tileRect, WebKit::SurfaceUpdateInfo updateInfo)
- UpdateTileForLayer(uint32_t layerID, int tileID, WebCore::IntRect tileRect, WebKit::SurfaceUpdateInfo updateInfo)
- RemoveTileForLayer(uint32_t layerID, int tileID)
- CreateUpdateAtlas(int atlasID, WebKit::ShareableSurface::Handle handle)
- RemoveUpdateAtlas(int atlasID)
- CreateImageBacking(uint64_t imageID)
- UpdateImageBacking(uint64_t imageID, WebKit::ShareableSurface::Handle handle)
- ClearImageBackingContents(uint64_t imageID)
- RemoveImageBacking(uint64_t imageID)
- DidRenderFrame(WebCore::IntSize contentsSize, WebCore::IntRect coveredRect)
- DidChangeScrollPosition(WebCore::IntPoint position)
- SetLayerAnimations(uint32_t id, WebCore::GraphicsLayerAnimations animations)
- SetAnimationsLocked(bool locked)
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- RequestAnimationFrame()
-#endif
-
-#if USE(GRAPHICS_SURFACE)
- CreateCanvas(uint32_t id, WebCore::IntSize canvasSize, WebCore::GraphicsSurfaceToken token)
- SyncCanvas(uint32_t id, uint32_t frontBuffer)
- DestroyCanvas(uint32_t id)
-#endif
-
- SetBackgroundColor(WebCore::Color color)
-}
-#endif
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp
deleted file mode 100644
index 6ed1b12fd..000000000
--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- Copyright (C) 2012 Company 100, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include "LayerTreeRenderer.h"
-
-#include "CoordinatedBackingStore.h"
-#include "GraphicsLayerTextureMapper.h"
-#include "LayerTreeCoordinatorProxy.h"
-#include "MessageID.h"
-#include "TextureMapper.h"
-#include "TextureMapperBackingStore.h"
-#include "TextureMapperGL.h"
-#include "TextureMapperLayer.h"
-#include "UpdateInfo.h"
-#include <OpenGLShims.h>
-#include <wtf/Atomics.h>
-#include <wtf/MainThread.h>
-
-#if ENABLE(CSS_SHADERS)
-#include "CustomFilterProgram.h"
-#include "CustomFilterProgramInfo.h"
-#include "WebCustomFilterOperation.h"
-#include "WebCustomFilterProgram.h"
-#endif
-
-namespace WebKit {
-
-using namespace WebCore;
-
-void LayerTreeRenderer::dispatchOnMainThread(const Function<void()>& function)
-{
- if (isMainThread())
- function();
- else
- callOnMainThread(function);
-}
-
-static FloatPoint boundedScrollPosition(const FloatPoint& scrollPosition, const FloatRect& visibleContentRect, const FloatSize& contentSize)
-{
- float scrollPositionX = std::max(scrollPosition.x(), 0.0f);
- scrollPositionX = std::min(scrollPositionX, contentSize.width() - visibleContentRect.width());
-
- float scrollPositionY = std::max(scrollPosition.y(), 0.0f);
- scrollPositionY = std::min(scrollPositionY, contentSize.height() - visibleContentRect.height());
- return FloatPoint(scrollPositionX, scrollPositionY);
-}
-
-static bool layerShouldHaveBackingStore(GraphicsLayer* layer)
-{
- return layer->drawsContent() && layer->contentsAreVisible() && !layer->size().isEmpty();
-}
-
-LayerTreeRenderer::LayerTreeRenderer(LayerTreeCoordinatorProxy* layerTreeCoordinatorProxy)
- : m_layerTreeCoordinatorProxy(layerTreeCoordinatorProxy)
- , m_isActive(false)
- , m_rootLayerID(InvalidWebLayerID)
- , m_animationsLocked(false)
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- , m_animationFrameRequested(false)
-#endif
- , m_backgroundColor(Color::white)
- , m_setDrawsBackground(false)
-{
- ASSERT(isMainThread());
-}
-
-LayerTreeRenderer::~LayerTreeRenderer()
-{
-}
-
-PassOwnPtr<GraphicsLayer> LayerTreeRenderer::createLayer(WebLayerID)
-{
- GraphicsLayerTextureMapper* newLayer = new GraphicsLayerTextureMapper(this);
- newLayer->setHasOwnBackingStore(false);
- return adoptPtr(newLayer);
-}
-
-void LayerTreeRenderer::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, TextureMapper::PaintFlags PaintFlags)
-{
- if (!m_textureMapper) {
- m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);
- static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
- }
-
- ASSERT(m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode);
- syncRemoteContent();
-
- adjustPositionForFixedLayers();
- GraphicsLayer* currentRootLayer = rootLayer();
- if (!currentRootLayer)
- return;
-
- TextureMapperLayer* layer = toTextureMapperLayer(currentRootLayer);
-
- if (!layer)
- return;
-
- layer->setTextureMapper(m_textureMapper.get());
- if (!m_animationsLocked)
- layer->applyAnimationsRecursively();
- m_textureMapper->beginPainting(PaintFlags);
- m_textureMapper->beginClip(TransformationMatrix(), clipRect);
-
- if (m_setDrawsBackground) {
- RGBA32 rgba = makeRGBA32FromFloats(m_backgroundColor.red(),
- m_backgroundColor.green(), m_backgroundColor.blue(),
- m_backgroundColor.alpha() * opacity);
- m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba));
- }
-
- if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) {
- currentRootLayer->setOpacity(opacity);
- currentRootLayer->setTransform(matrix);
- currentRootLayer->flushCompositingStateForThisLayerOnly();
- }
-
- layer->paint();
- m_textureMapper->endClip();
- m_textureMapper->endPainting();
-
- if (layer->descendantsOrSelfHaveRunningAnimations())
- dispatchOnMainThread(bind(&LayerTreeRenderer::updateViewport, this));
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- if (m_animationFrameRequested) {
- m_animationFrameRequested = false;
- dispatchOnMainThread(bind(&LayerTreeRenderer::animationFrameReady, this));
- }
-#endif
-}
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-void LayerTreeRenderer::animationFrameReady()
-{
- ASSERT(isMainThread());
- if (m_layerTreeCoordinatorProxy)
- m_layerTreeCoordinatorProxy->animationFrameReady();
-}
-
-void LayerTreeRenderer::requestAnimationFrame()
-{
- m_animationFrameRequested = true;
-}
-#endif
-
-void LayerTreeRenderer::paintToGraphicsContext(BackingStore::PlatformGraphicsContext painter)
-{
- if (!m_textureMapper)
- m_textureMapper = TextureMapper::create();
- ASSERT(m_textureMapper->accelerationMode() == TextureMapper::SoftwareMode);
- syncRemoteContent();
- TextureMapperLayer* layer = toTextureMapperLayer(rootLayer());
-
- if (!layer)
- return;
-
- GraphicsContext graphicsContext(painter);
- m_textureMapper->setGraphicsContext(&graphicsContext);
- m_textureMapper->beginPainting();
-
- if (m_setDrawsBackground)
- m_textureMapper->drawSolidColor(graphicsContext.clipBounds(), TransformationMatrix(), m_backgroundColor);
-
- layer->paint();
- m_textureMapper->endPainting();
- m_textureMapper->setGraphicsContext(0);
-}
-
-void LayerTreeRenderer::setContentsSize(const WebCore::FloatSize& contentsSize)
-{
- m_contentsSize = contentsSize;
-}
-
-void LayerTreeRenderer::setVisibleContentsRect(const FloatRect& rect)
-{
- m_visibleContentsRect = rect;
-}
-
-void LayerTreeRenderer::updateViewport()
-{
- ASSERT(isMainThread());
- if (m_layerTreeCoordinatorProxy)
- m_layerTreeCoordinatorProxy->updateViewport();
-}
-
-void LayerTreeRenderer::adjustPositionForFixedLayers()
-{
- if (m_fixedLayers.isEmpty())
- return;
-
- // Fixed layer positions are updated by the web process when we update the visible contents rect / scroll position.
- // If we want those layers to follow accurately the viewport when we move between the web process updates, we have to offset
- // them by the delta between the current position and the position of the viewport used for the last layout.
- FloatPoint scrollPosition = boundedScrollPosition(m_visibleContentsRect.location(), m_visibleContentsRect, m_contentsSize);
- FloatPoint renderedScrollPosition = boundedScrollPosition(m_renderedContentsScrollPosition, m_visibleContentsRect, m_contentsSize);
- FloatSize delta = scrollPosition - renderedScrollPosition;
-
- LayerRawPtrMap::iterator end = m_fixedLayers.end();
- for (LayerRawPtrMap::iterator it = m_fixedLayers.begin(); it != end; ++it)
- toTextureMapperLayer(it->value)->setScrollPositionDeltaIfNeeded(delta);
-}
-
-void LayerTreeRenderer::didChangeScrollPosition(const IntPoint& position)
-{
- m_pendingRenderedContentsScrollPosition = position;
-}
-
-#if USE(GRAPHICS_SURFACE)
-void LayerTreeRenderer::createCanvas(WebLayerID id, const WebCore::IntSize& canvasSize, PassRefPtr<GraphicsSurface> surface)
-{
- ASSERT(m_textureMapper);
- GraphicsLayer* layer = layerByID(id);
- ASSERT(layer);
- ASSERT(!m_surfaceBackingStores.contains(id));
-
- RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore(TextureMapperSurfaceBackingStore::create());
- m_surfaceBackingStores.set(id, canvasBackingStore);
-
- canvasBackingStore->setGraphicsSurface(surface);
- layer->setContentsToMedia(canvasBackingStore.get());
-}
-
-void LayerTreeRenderer::syncCanvas(WebLayerID id, uint32_t frontBuffer)
-{
- ASSERT(m_textureMapper);
- ASSERT(m_surfaceBackingStores.contains(id));
-
- SurfaceBackingStoreMap::iterator it = m_surfaceBackingStores.find(id);
- RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore = it->value;
-
- canvasBackingStore->swapBuffersIfNeeded(frontBuffer);
-}
-
-void LayerTreeRenderer::destroyCanvas(WebLayerID id)
-{
- ASSERT(m_textureMapper);
- GraphicsLayer* layer = layerByID(id);
- ASSERT(layer);
- ASSERT(m_surfaceBackingStores.contains(id));
-
- m_surfaceBackingStores.remove(id);
- layer->setContentsToMedia(0);
-}
-#endif
-
-void LayerTreeRenderer::setLayerChildren(WebLayerID id, const Vector<WebLayerID>& childIDs)
-{
- GraphicsLayer* layer = ensureLayer(id);
- Vector<GraphicsLayer*> children;
-
- for (size_t i = 0; i < childIDs.size(); ++i) {
- WebLayerID childID = childIDs[i];
- GraphicsLayer* child = layerByID(childID);
- if (!child) {
- OwnPtr<GraphicsLayer*> newChild = createLayer(childID);
- child = newChild.get();
- m_layers.add(childID, newChild.release());
- }
- children.append(child);
- }
- layer->setChildren(children);
-}
-
-#if ENABLE(CSS_FILTERS)
-void LayerTreeRenderer::setLayerFilters(WebLayerID id, const FilterOperations& filters)
-{
- GraphicsLayer* layer = ensureLayer(id);
-
-#if ENABLE(CSS_SHADERS)
- injectCachedCustomFilterPrograms(filters);
-#endif
- layer->setFilters(filters);
-}
-#endif
-
-#if ENABLE(CSS_SHADERS)
-void LayerTreeRenderer::injectCachedCustomFilterPrograms(const FilterOperations& filters) const
-{
- for (size_t i = 0; i < filters.size(); ++i) {
- FilterOperation* operation = filters.operations().at(i).get();
- if (operation->getOperationType() != FilterOperation::CUSTOM)
- continue;
-
- WebCustomFilterOperation* customOperation = static_cast<WebCustomFilterOperation*>(operation);
- ASSERT(!customOperation->program());
- CustomFilterProgramMap::const_iterator iter = m_customFilterPrograms.find(customOperation->programID());
- ASSERT(iter != m_customFilterPrograms.end());
- customOperation->setProgram(iter->value.get());
- }
-}
-
-void LayerTreeRenderer::createCustomFilterProgram(int id, const WebCore::CustomFilterProgramInfo& programInfo)
-{
- ASSERT(!m_customFilterPrograms.contains(id));
- m_customFilterPrograms.set(id, WebCustomFilterProgram::create(programInfo.vertexShaderString(), programInfo.fragmentShaderString(), programInfo.programType(), programInfo.mixSettings(), programInfo.meshType()));
-}
-
-void LayerTreeRenderer::removeCustomFilterProgram(int id)
-{
- CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(id);
- ASSERT(iter != m_customFilterPrograms.end());
- if (m_textureMapper)
- m_textureMapper->removeCachedCustomFilterProgram(iter->value.get());
- m_customFilterPrograms.remove(iter);
-}
-#endif // ENABLE(CSS_SHADERS)
-
-void LayerTreeRenderer::setLayerState(WebLayerID id, const WebLayerInfo& layerInfo)
-{
- GraphicsLayer* layer = ensureLayer(id);
-
- layer->setReplicatedByLayer(layerByID(layerInfo.replica));
- layer->setMaskLayer(layerByID(layerInfo.mask));
-
- layer->setPosition(layerInfo.pos);
- layer->setSize(layerInfo.size);
- layer->setTransform(layerInfo.transform);
- layer->setAnchorPoint(layerInfo.anchorPoint);
- layer->setChildrenTransform(layerInfo.childrenTransform);
- layer->setBackfaceVisibility(layerInfo.backfaceVisible);
- layer->setContentsOpaque(layerInfo.contentsOpaque);
- layer->setContentsRect(layerInfo.contentsRect);
- layer->setDrawsContent(layerInfo.drawsContent);
- layer->setContentsVisible(layerInfo.contentsVisible);
- toGraphicsLayerTextureMapper(layer)->setFixedToViewport(layerInfo.fixedToViewport);
-
- if (layerInfo.fixedToViewport)
- m_fixedLayers.add(id, layer);
- else
- m_fixedLayers.remove(id);
-
- assignImageBackingToLayer(layer, layerInfo.imageID);
- prepareContentBackingStore(layer);
-
- // Never make the root layer clip.
- layer->setMasksToBounds(layerInfo.isRootLayer ? false : layerInfo.masksToBounds);
- layer->setOpacity(layerInfo.opacity);
- layer->setPreserves3D(layerInfo.preserves3D);
- if (layerInfo.isRootLayer && m_rootLayerID != id)
- setRootLayerID(id);
-}
-
-void LayerTreeRenderer::deleteLayer(WebLayerID layerID)
-{
- OwnPtr<GraphicsLayer> layer = m_layers.take(layerID);
- if (!layer)
- return;
-
- layer->removeFromParent();
- m_fixedLayers.remove(layerID);
-#if USE(GRAPHICS_SURFACE)
- m_surfaceBackingStores.remove(layerID);
-#endif
-}
-
-
-WebCore::GraphicsLayer* LayerTreeRenderer::ensureLayer(WebLayerID id)
-{
- LayerMap::iterator it = m_layers.find(id);
- if (it != m_layers.end())
- return it->value.get();
-
- OwnPtr<WebCore::GraphicsLayer> newLayer = createLayer(id);
- WebCore::GraphicsLayer* layer = newLayer.get();
- m_layers.add(id, newLayer.release());
-
- return layer;
-}
-
-void LayerTreeRenderer::setRootLayerID(WebLayerID layerID)
-{
- if (layerID == m_rootLayerID)
- return;
-
- m_rootLayerID = layerID;
-
- m_rootLayer->removeAllChildren();
-
- if (!layerID)
- return;
-
- GraphicsLayer* layer = layerByID(layerID);
- if (!layer)
- return;
-
- m_rootLayer->addChild(layer);
-}
-
-CoordinatedBackingStore* LayerTreeRenderer::getBackingStore(GraphicsLayer* graphicsLayer)
-{
- TextureMapperLayer* layer = toTextureMapperLayer(graphicsLayer);
- ASSERT(layer);
- CoordinatedBackingStore* backingStore = static_cast<CoordinatedBackingStore*>(layer->backingStore().get());
-
- BackingStoreMap::iterator it = m_pendingSyncBackingStores.find(layer);
- if (it != m_pendingSyncBackingStores.end())
- backingStore = it->value.get();
- return backingStore;
-}
-
-void LayerTreeRenderer::prepareContentBackingStore(GraphicsLayer* graphicsLayer)
-{
- if (!layerShouldHaveBackingStore(graphicsLayer)) {
- removeBackingStoreIfNeeded(graphicsLayer);
- return;
- }
-
- createBackingStoreIfNeeded(graphicsLayer);
- resetBackingStoreSizeToLayerSize(graphicsLayer);
-}
-
-void LayerTreeRenderer::createBackingStoreIfNeeded(GraphicsLayer* graphicsLayer)
-{
- TextureMapperLayer* layer = toTextureMapperLayer(graphicsLayer);
- ASSERT(layer);
-
- // Make sure the layer does not already have a backing store (committed or pending).
- BackingStoreMap::iterator it = m_pendingSyncBackingStores.find(layer);
- if (it != m_pendingSyncBackingStores.end()) {
- if (!it->value) {
- // There is a pending removal, cancel it.
- m_pendingSyncBackingStores.remove(it);
- }
- // There is already a pending addition.
- return;
- }
- if (layer->backingStore())
- return; // The layer already has a backing store (and no pending removal).
-
- RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create());
- ASSERT(!m_pendingSyncBackingStores.contains(layer));
- m_pendingSyncBackingStores.add(layer, backingStore);
-}
-
-void LayerTreeRenderer::removeBackingStoreIfNeeded(GraphicsLayer* graphicsLayer)
-{
- TextureMapperLayer* layer = toTextureMapperLayer(graphicsLayer);
- ASSERT(layer);
-
- // Check if the layout already has a backing store (committed or pending).
- BackingStoreMap::iterator it = m_pendingSyncBackingStores.find(layer);
- if (it != m_pendingSyncBackingStores.end()) {
- if (it->value) {
- // There is a pending addition, cancel it.
- m_pendingSyncBackingStores.remove(it);
- }
- // There is already a pending removal.
- return;
- }
-
- if (!layer->backingStore())
- return; // The layer has no backing store (and no pending addition).
-
- ASSERT(!m_pendingSyncBackingStores.contains(layer));
- m_pendingSyncBackingStores.add(layer, 0);
-}
-
-void LayerTreeRenderer::resetBackingStoreSizeToLayerSize(GraphicsLayer* graphicsLayer)
-{
- CoordinatedBackingStore* backingStore = getBackingStore(graphicsLayer);
- ASSERT(backingStore);
- backingStore->setSize(graphicsLayer->size());
- m_backingStoresWithPendingBuffers.add(backingStore);
-}
-
-void LayerTreeRenderer::createTile(WebLayerID layerID, int tileID, float scale)
-{
- GraphicsLayer* layer = layerByID(layerID);
- ASSERT(layer);
- CoordinatedBackingStore* backingStore = getBackingStore(layer);
- ASSERT(backingStore);
- backingStore->createTile(tileID, scale);
-}
-
-void LayerTreeRenderer::removeTile(WebLayerID layerID, int tileID)
-{
- GraphicsLayer* layer = layerByID(layerID);
- ASSERT(layer);
- CoordinatedBackingStore* backingStore = getBackingStore(layer);
- if (!backingStore)
- return;
-
- backingStore->removeTile(tileID);
- m_backingStoresWithPendingBuffers.add(backingStore);
-}
-
-void LayerTreeRenderer::updateTile(WebLayerID layerID, int tileID, const TileUpdate& update)
-{
- GraphicsLayer* layer = layerByID(layerID);
- ASSERT(layer);
- RefPtr<CoordinatedBackingStore> backingStore = getBackingStore(layer);
- ASSERT(backingStore);
- backingStore->updateTile(tileID, update.sourceRect, update.tileRect, update.surface, update.offset);
- m_backingStoresWithPendingBuffers.add(backingStore);
-}
-
-void LayerTreeRenderer::createImageBacking(CoordinatedImageBackingID imageID)
-{
- ASSERT(!m_imageBackings.contains(imageID));
- RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create());
- m_imageBackings.add(imageID, backingStore.release());
-}
-
-void LayerTreeRenderer::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<ShareableSurface> surface)
-{
- ASSERT(m_imageBackings.contains(imageID));
- ImageBackingMap::iterator it = m_imageBackings.find(imageID);
- RefPtr<CoordinatedBackingStore> backingStore = it->value;
-
- // CoordinatedImageBacking is realized to CoordinatedBackingStore with only one tile in UI Process.
- backingStore->createTile(1 /* id */, 1 /* scale */);
- IntRect rect(IntPoint::zero(), surface->size());
- // See CoordinatedGraphicsLayer::shouldDirectlyCompositeImage()
- ASSERT(2000 >= std::max(rect.width(), rect.height()));
- backingStore->setSize(rect.size());
- backingStore->updateTile(1 /* id */, rect, rect, surface, rect.location());
-
- m_backingStoresWithPendingBuffers.add(backingStore);
-}
-
-void LayerTreeRenderer::clearImageBackingContents(CoordinatedImageBackingID imageID)
-{
- ASSERT(m_imageBackings.contains(imageID));
- ImageBackingMap::iterator it = m_imageBackings.find(imageID);
- RefPtr<CoordinatedBackingStore> backingStore = it->value;
- backingStore->removeAllTiles();
- m_backingStoresWithPendingBuffers.add(backingStore);
-}
-
-void LayerTreeRenderer::removeImageBacking(CoordinatedImageBackingID imageID)
-{
- ASSERT(m_imageBackings.contains(imageID));
-
- // We don't want TextureMapperLayer refers a dangling pointer.
- ImageBackingMap::iterator it = m_imageBackings.find(imageID);
- m_releasedImageBackings.append(it->value);
- m_imageBackings.remove(imageID);
-}
-
-void LayerTreeRenderer::assignImageBackingToLayer(GraphicsLayer* layer, CoordinatedImageBackingID imageID)
-{
- if (imageID == InvalidCoordinatedImageBackingID) {
- layer->setContentsToMedia(0);
- return;
- }
- ImageBackingMap::iterator it = m_imageBackings.find(imageID);
- ASSERT(it != m_imageBackings.end());
- layer->setContentsToMedia(it->value.get());
-}
-
-void LayerTreeRenderer::removeReleasedImageBackingsIfNeeded()
-{
- m_releasedImageBackings.clear();
-}
-
-void LayerTreeRenderer::commitPendingBackingStoreOperations()
-{
- HashSet<RefPtr<CoordinatedBackingStore> >::iterator end = m_backingStoresWithPendingBuffers.end();
- for (HashSet<RefPtr<CoordinatedBackingStore> >::iterator it = m_backingStoresWithPendingBuffers.begin(); it != end; ++it)
- (*it)->commitTileOperations(m_textureMapper.get());
-
- m_backingStoresWithPendingBuffers.clear();
-
- {
- BackingStoreMap::iterator end = m_pendingSyncBackingStores.end();
- BackingStoreMap::iterator it = m_pendingSyncBackingStores.begin();
- for (;it != end; ++it)
- it->key->setBackingStore(it->value);
-
- m_pendingSyncBackingStores.clear();
- }
-}
-
-void LayerTreeRenderer::flushLayerChanges()
-{
- m_renderedContentsScrollPosition = m_pendingRenderedContentsScrollPosition;
-
- // Since the frame has now been rendered, we can safely unlock the animations until the next layout.
- setAnimationsLocked(false);
-
- m_rootLayer->flushCompositingState(FloatRect());
- commitPendingBackingStoreOperations();
- removeReleasedImageBackingsIfNeeded();
-
- // The pending tiles state is on its way for the screen, tell the web process to render the next one.
- dispatchOnMainThread(bind(&LayerTreeRenderer::renderNextFrame, this));
-}
-
-void LayerTreeRenderer::renderNextFrame()
-{
- if (m_layerTreeCoordinatorProxy)
- m_layerTreeCoordinatorProxy->renderNextFrame();
-}
-
-void LayerTreeRenderer::ensureRootLayer()
-{
- if (m_rootLayer)
- return;
-
- m_rootLayer = createLayer(InvalidWebLayerID);
- m_rootLayer->setMasksToBounds(false);
- m_rootLayer->setDrawsContent(false);
- m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
-
- // The root layer should not have zero size, or it would be optimized out.
- m_rootLayer->setSize(FloatSize(1.0, 1.0));
-
- ASSERT(m_textureMapper);
- toTextureMapperLayer(m_rootLayer.get())->setTextureMapper(m_textureMapper.get());
-}
-
-void LayerTreeRenderer::syncRemoteContent()
-{
- // We enqueue messages and execute them during paint, as they require an active GL context.
- ensureRootLayer();
-
- Vector<Function<void()> > renderQueue;
- bool calledOnMainThread = WTF::isMainThread();
- if (!calledOnMainThread)
- m_renderQueueMutex.lock();
- renderQueue.swap(m_renderQueue);
- if (!calledOnMainThread)
- m_renderQueueMutex.unlock();
-
- for (size_t i = 0; i < renderQueue.size(); ++i)
- renderQueue[i]();
-}
-
-void LayerTreeRenderer::purgeGLResources()
-{
- TextureMapperLayer* layer = toTextureMapperLayer(rootLayer());
-
- if (layer)
- layer->clearBackingStoresRecursive();
-
- m_imageBackings.clear();
-#if USE(GRAPHICS_SURFACE)
- m_surfaceBackingStores.clear();
-#endif
-
- if (m_rootLayer) {
- m_rootLayer->removeAllChildren();
- }
- m_rootLayer.clear();
- m_rootLayerID = InvalidWebLayerID;
- m_layers.clear();
- m_fixedLayers.clear();
- m_textureMapper.clear();
- m_pendingSyncBackingStores.clear();
- m_backingStoresWithPendingBuffers.clear();
-
- setActive(false);
- dispatchOnMainThread(bind(&LayerTreeRenderer::purgeBackingStores, this));
-}
-
-void LayerTreeRenderer::purgeBackingStores()
-{
- if (m_layerTreeCoordinatorProxy)
- m_layerTreeCoordinatorProxy->purgeBackingStores();
-}
-
-void LayerTreeRenderer::setLayerAnimations(WebLayerID id, const GraphicsLayerAnimations& animations)
-{
- GraphicsLayerTextureMapper* layer = toGraphicsLayerTextureMapper(layerByID(id));
- if (!layer)
- return;
-#if ENABLE(CSS_SHADERS)
- for (size_t i = 0; i < animations.animations().size(); ++i) {
- const KeyframeValueList& keyframes = animations.animations().at(i).keyframes();
- if (keyframes.property() != AnimatedPropertyWebkitFilter)
- continue;
- for (size_t j = 0; j < keyframes.size(); ++j) {
- const FilterAnimationValue* filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i));
- injectCachedCustomFilterPrograms(*filterValue->value());
- }
- }
-#endif
- layer->setAnimations(animations);
-}
-
-void LayerTreeRenderer::setAnimationsLocked(bool locked)
-{
- m_animationsLocked = locked;
-}
-
-void LayerTreeRenderer::detach()
-{
- ASSERT(isMainThread());
- m_layerTreeCoordinatorProxy = 0;
-}
-
-void LayerTreeRenderer::appendUpdate(const Function<void()>& function)
-{
- if (!m_isActive)
- return;
-
- ASSERT(isMainThread());
- MutexLocker locker(m_renderQueueMutex);
- m_renderQueue.append(function);
-}
-
-void LayerTreeRenderer::setActive(bool active)
-{
- if (m_isActive == active)
- return;
-
- // Have to clear render queue in both cases.
- // If there are some updates in queue during activation then those updates are from previous instance of paint node
- // and cannot be applied to the newly created instance.
- m_renderQueue.clear();
- m_isActive = active;
- if (m_isActive)
- dispatchOnMainThread(bind(&LayerTreeRenderer::renderNextFrame, this));
-}
-
-void LayerTreeRenderer::setBackgroundColor(const WebCore::Color& color)
-{
- m_backgroundColor = color;
-}
-
-} // namespace WebKit
-
-#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h
deleted file mode 100644
index 946ac6d49..000000000
--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef LayerTreeRenderer_h
-#define LayerTreeRenderer_h
-
-#if USE(COORDINATED_GRAPHICS)
-#include "BackingStore.h"
-#include "ShareableSurface.h"
-#include "TextureMapper.h"
-#include "TextureMapperBackingStore.h"
-#include "WebLayerTreeInfo.h"
-#include <WebCore/GraphicsContext.h>
-#include <WebCore/GraphicsLayer.h>
-#include <WebCore/GraphicsLayerAnimation.h>
-#include <WebCore/GraphicsSurface.h>
-#include <WebCore/IntRect.h>
-#include <WebCore/IntSize.h>
-#include <WebCore/RunLoop.h>
-#include <WebCore/Timer.h>
-#include <wtf/Functional.h>
-#include <wtf/HashSet.h>
-#include <wtf/ThreadingPrimitives.h>
-
-namespace WebCore {
-class CustomFilterProgram;
-class CustomFilterProgramInfo;
-class TextureMapperLayer;
-}
-
-namespace WebKit {
-
-class CoordinatedBackingStore;
-class LayerTreeCoordinatorProxy;
-class WebLayerInfo;
-class WebLayerUpdateInfo;
-
-class LayerTreeRenderer : public ThreadSafeRefCounted<LayerTreeRenderer>, public WebCore::GraphicsLayerClient {
-public:
- struct TileUpdate {
- WebCore::IntRect sourceRect;
- WebCore::IntRect tileRect;
- RefPtr<ShareableSurface> surface;
- WebCore::IntPoint offset;
- TileUpdate(const WebCore::IntRect& source, const WebCore::IntRect& tile, PassRefPtr<ShareableSurface> newSurface, const WebCore::IntPoint& newOffset)
- : sourceRect(source)
- , tileRect(tile)
- , surface(newSurface)
- , offset(newOffset)
- {
- }
- };
- explicit LayerTreeRenderer(LayerTreeCoordinatorProxy*);
- virtual ~LayerTreeRenderer();
- void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&, WebCore::TextureMapper::PaintFlags = 0);
- void paintToGraphicsContext(BackingStore::PlatformGraphicsContext);
- void setContentsSize(const WebCore::FloatSize&);
- void setVisibleContentsRect(const WebCore::FloatRect&);
- void didChangeScrollPosition(const WebCore::IntPoint& position);
-#if USE(GRAPHICS_SURFACE)
- void createCanvas(WebLayerID, const WebCore::IntSize&, PassRefPtr<WebCore::GraphicsSurface>);
- void syncCanvas(WebLayerID, uint32_t frontBuffer);
- void destroyCanvas(WebLayerID);
-#endif
-
- void detach();
- void appendUpdate(const Function<void()>&);
-
- // The painting thread must lock the main thread to use below two methods, because two methods access members that the main thread manages. See m_layerTreeCoordinatorProxy.
- // Currently, QQuickWebPage::updatePaintNode() locks the main thread before calling both methods.
- void purgeGLResources();
- void setActive(bool);
-
- void deleteLayer(WebLayerID);
- void setRootLayerID(WebLayerID);
- void setLayerChildren(WebLayerID, const Vector<WebLayerID>&);
- void setLayerState(WebLayerID, const WebLayerInfo&);
-#if ENABLE(CSS_FILTERS)
- void setLayerFilters(WebLayerID, const WebCore::FilterOperations&);
-#endif
-#if ENABLE(CSS_SHADERS)
- void injectCachedCustomFilterPrograms(const WebCore::FilterOperations& filters) const;
- void createCustomFilterProgram(int id, const WebCore::CustomFilterProgramInfo&);
- void removeCustomFilterProgram(int id);
-#endif
-
- void createTile(WebLayerID, int, float scale);
- void removeTile(WebLayerID, int);
- void updateTile(WebLayerID, int, const TileUpdate&);
- void flushLayerChanges();
- void createImageBacking(CoordinatedImageBackingID);
- void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<ShareableSurface>);
- void clearImageBackingContents(CoordinatedImageBackingID);
- void removeImageBacking(CoordinatedImageBackingID);
- void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&);
- void setAnimationsLocked(bool);
- void setBackgroundColor(const WebCore::Color&);
- void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- void requestAnimationFrame();
-#endif
-
-private:
- PassOwnPtr<WebCore::GraphicsLayer> createLayer(WebLayerID);
-
- WebCore::GraphicsLayer* layerByID(WebLayerID id) { return (id == InvalidWebLayerID) ? 0 : m_layers.get(id); }
- WebCore::GraphicsLayer* rootLayer() { return m_rootLayer.get(); }
-
- void syncRemoteContent();
- void adjustPositionForFixedLayers();
-
- // Reimplementations from WebCore::GraphicsLayerClient.
- virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double) { }
- virtual void notifyFlushRequired(const WebCore::GraphicsLayer*) { }
- virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&) OVERRIDE { }
-
- void dispatchOnMainThread(const Function<void()>&);
- void updateViewport();
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- void animationFrameReady();
-#endif
- void renderNextFrame();
- void purgeBackingStores();
-
- void assignImageBackingToLayer(WebCore::GraphicsLayer*, CoordinatedImageBackingID);
- void removeReleasedImageBackingsIfNeeded();
- void ensureRootLayer();
- WebCore::GraphicsLayer* ensureLayer(WebLayerID);
- void commitPendingBackingStoreOperations();
-
- CoordinatedBackingStore* getBackingStore(WebCore::GraphicsLayer*);
- void prepareContentBackingStore(WebCore::GraphicsLayer*);
- void createBackingStoreIfNeeded(WebCore::GraphicsLayer*);
- void removeBackingStoreIfNeeded(WebCore::GraphicsLayer*);
- void resetBackingStoreSizeToLayerSize(WebCore::GraphicsLayer*);
-
- WebCore::FloatSize m_contentsSize;
- WebCore::FloatRect m_visibleContentsRect;
-
- // Render queue can be accessed ony from main thread or updatePaintNode call stack!
- Vector<Function<void()> > m_renderQueue;
- Mutex m_renderQueueMutex;
-
- OwnPtr<WebCore::TextureMapper> m_textureMapper;
-
- typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedBackingStore> > ImageBackingMap;
- ImageBackingMap m_imageBackings;
- Vector<RefPtr<CoordinatedBackingStore> > m_releasedImageBackings;
-
- typedef HashMap<WebCore::TextureMapperLayer*, RefPtr<CoordinatedBackingStore> > BackingStoreMap;
- BackingStoreMap m_pendingSyncBackingStores;
-
- HashSet<RefPtr<CoordinatedBackingStore> > m_backingStoresWithPendingBuffers;
-
-#if USE(GRAPHICS_SURFACE)
- typedef HashMap<WebLayerID, RefPtr<WebCore::TextureMapperSurfaceBackingStore> > SurfaceBackingStoreMap;
- SurfaceBackingStoreMap m_surfaceBackingStores;
-#endif
-
- // Below two members are accessed by only the main thread. The painting thread must lock the main thread to access both members.
- LayerTreeCoordinatorProxy* m_layerTreeCoordinatorProxy;
- bool m_isActive;
-
- OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
-
- typedef HashMap<WebLayerID, OwnPtr<WebCore::GraphicsLayer> > LayerMap;
- LayerMap m_layers;
- typedef HashMap<WebLayerID, WebCore::GraphicsLayer*> LayerRawPtrMap;
- LayerRawPtrMap m_fixedLayers;
- WebLayerID m_rootLayerID;
- WebCore::IntPoint m_renderedContentsScrollPosition;
- WebCore::IntPoint m_pendingRenderedContentsScrollPosition;
- bool m_animationsLocked;
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- bool m_animationFrameRequested;
-#endif
- WebCore::Color m_backgroundColor;
- bool m_setDrawsBackground;
-
-#if ENABLE(CSS_SHADERS)
- typedef HashMap<int, RefPtr<WebCore::CustomFilterProgram> > CustomFilterProgramMap;
- CustomFilterProgramMap m_customFilterPrograms;
-#endif
-};
-
-};
-
-#endif // USE(COORDINATED_GRAPHICS)
-
-#endif // LayerTreeRenderer_h
-
-
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h
new file mode 100644
index 000000000..fc9f0d608
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/WKCoordinatedSceneAPICast.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WKCoordinatedSceneAPICast_h
+#define WKCoordinatedSceneAPICast_h
+
+#include <WebKit2/WKCoordinatedScene.h>
+
+namespace WebCore {
+
+class CoordinatedGraphicsScene;
+class TextureMapperLayer;
+
+} // namespace WebCore
+
+inline WebCore::CoordinatedGraphicsScene* toImpl(WKCoordinatedScene scene)
+{
+ return reinterpret_cast<WebCore::CoordinatedGraphicsScene*>(scene);
+}
+
+inline WKCoordinatedScene toAPI(WebCore::CoordinatedGraphicsScene* scene)
+{
+ return reinterpret_cast<WKCoordinatedScene>(scene);
+}
+
+inline WebCore::TextureMapperLayer* toImpl(WKCoordinatedSceneLayer layer)
+{
+ return reinterpret_cast<WebCore::TextureMapperLayer*>(layer);
+}
+
+inline WKCoordinatedSceneLayer toAPI(WebCore::TextureMapperLayer* layer)
+{
+ return reinterpret_cast<WKCoordinatedSceneLayer>(layer);
+}
+
+#endif // WKCoordinatedSceneAPICast_h
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebPageProxyCoordinatedGraphics.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebPageProxyCoordinatedGraphics.cpp
new file mode 100644
index 000000000..e34a9b338
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebPageProxyCoordinatedGraphics.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if USE(COORDINATED_GRAPHICS)
+
+#include "WebPageProxy.h"
+
+#include "PageClient.h"
+#include "WebPageMessages.h"
+#include "WebProcessProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebPageProxy::findZoomableAreaForPoint(const IntPoint& point, const IntSize& area)
+{
+ if (!isValid())
+ return;
+
+ m_process->send(Messages::WebPage::FindZoomableAreaForPoint(point, area), m_pageID);
+}
+
+void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
+{
+ m_pageClient->didFindZoomableArea(target, area);
+}
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp
new file mode 100644
index 000000000..293745e48
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.cpp
@@ -0,0 +1,515 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if USE(COORDINATED_GRAPHICS)
+
+#include "WebView.h"
+
+#include "CoordinatedLayerTreeHostProxy.h"
+#include "DrawingAreaProxyImpl.h"
+#include "NotImplemented.h"
+#include "WebContextMenuProxy.h"
+#include "WebPageProxy.h"
+#include <WebCore/CoordinatedGraphicsScene.h>
+
+#if ENABLE(FULLSCREEN_API)
+#include "WebFullScreenManagerProxy.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebView::WebView(WebContext* context, WebPageGroup* pageGroup)
+ : m_focused(false)
+ , m_visible(false)
+ , m_contentScaleFactor(1.0)
+ , m_opacity(1.0)
+{
+ // Need to call createWebPage after other data members, specifically m_visible, are initialized.
+ m_page = context->createWebPage(this, pageGroup);
+
+ m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
+ m_page->pageGroup()->preferences()->setForceCompositingMode(true);
+
+ char* debugVisualsEnvironment = getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS");
+ bool showDebugVisuals = debugVisualsEnvironment && !strcmp(debugVisualsEnvironment, "1");
+ m_page->pageGroup()->preferences()->setCompositingBordersVisible(showDebugVisuals);
+ m_page->pageGroup()->preferences()->setCompositingRepaintCountersVisible(showDebugVisuals);
+}
+
+WebView::~WebView()
+{
+ if (m_page->isClosed())
+ return;
+
+ m_page->close();
+}
+
+void WebView::initialize()
+{
+ m_page->initializeWebPage();
+ if (CoordinatedGraphicsScene* scene = coordinatedGraphicsScene())
+ scene->setActive(true);
+}
+
+void WebView::setSize(const WebCore::IntSize& size)
+{
+ if (m_size == size)
+ return;
+
+ m_size = size;
+
+ updateViewportSize();
+}
+
+void WebView::setFocused(bool focused)
+{
+ if (m_focused == focused)
+ return;
+
+ m_focused = focused;
+ m_page->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
+}
+
+void WebView::setVisible(bool visible)
+{
+ if (m_visible == visible)
+ return;
+
+ m_visible = visible;
+ m_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+void WebView::setUserViewportTranslation(double tx, double ty)
+{
+ m_userViewportTransform = TransformationMatrix().translate(tx, ty);
+}
+
+IntPoint WebView::userViewportToContents(const IntPoint& point) const
+{
+ return transformFromScene().mapPoint(point);
+}
+
+IntPoint WebView::userViewportToScene(const WebCore::IntPoint& point) const
+{
+ return m_userViewportTransform.mapPoint(point);
+}
+
+IntPoint WebView::contentsToUserViewport(const IntPoint& point) const
+{
+ return transformToScene().mapPoint(point);
+}
+
+void WebView::paintToCurrentGLContext()
+{
+ CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
+ if (!scene)
+ return;
+
+ // FIXME: We need to clean up this code as it is split over CoordGfx and Page.
+ scene->setDrawsBackground(m_page->drawsBackground());
+ const FloatRect& viewport = m_userViewportTransform.mapRect(IntRect(IntPoint(), m_size));
+
+ scene->paintToCurrentGLContext(transformToScene().toTransformationMatrix(), m_opacity, viewport);
+}
+
+void WebView::setDrawsBackground(bool drawsBackground)
+{
+ m_page->setDrawsBackground(drawsBackground);
+}
+
+bool WebView::drawsBackground() const
+{
+ return m_page->drawsBackground();
+}
+
+void WebView::setDrawsTransparentBackground(bool transparentBackground)
+{
+ m_page->setDrawsTransparentBackground(transparentBackground);
+}
+
+bool WebView::drawsTransparentBackground() const
+{
+ return m_page->drawsTransparentBackground();
+}
+
+void WebView::suspendActiveDOMObjectsAndAnimations()
+{
+ m_page->suspendActiveDOMObjectsAndAnimations();
+}
+
+void WebView::resumeActiveDOMObjectsAndAnimations()
+{
+ m_page->resumeActiveDOMObjectsAndAnimations();
+}
+
+void WebView::setShowsAsSource(bool showsAsSource)
+{
+ m_page->setMainFrameInViewSourceMode(showsAsSource);
+}
+
+bool WebView::showsAsSource() const
+{
+ return m_page->mainFrameInViewSourceMode();
+}
+
+#if ENABLE(FULLSCREEN_API)
+bool WebView::exitFullScreen()
+{
+#if PLATFORM(EFL)
+ // FIXME: Implement this for other platforms.
+ if (!m_page->fullScreenManager()->isFullScreen())
+ return false;
+#endif
+ m_page->fullScreenManager()->requestExitFullScreen();
+ return true;
+}
+#endif
+
+void WebView::initializeClient(const WKViewClient* client)
+{
+ m_client.initialize(client);
+}
+
+void WebView::didChangeContentsSize(const WebCore::IntSize& size)
+{
+ if (m_contentsSize == size)
+ return;
+
+ m_contentsSize = size;
+ m_client.didChangeContentsSize(this, size);
+
+ updateViewportSize();
+}
+
+void WebView::didFindZoomableArea(const WebCore::IntPoint& target, const WebCore::IntRect& area)
+{
+ m_client.didFindZoomableArea(this, target, area);
+}
+
+AffineTransform WebView::transformFromScene() const
+{
+ return transformToScene().inverse();
+}
+
+AffineTransform WebView::transformToScene() const
+{
+ FloatPoint position = -m_contentPosition;
+ float effectiveScale = m_contentScaleFactor * m_page->deviceScaleFactor();
+ position.scale(effectiveScale, effectiveScale);
+
+ TransformationMatrix transform = m_userViewportTransform;
+ transform.translate(position.x(), position.y());
+ transform.scale(effectiveScale);
+
+ return transform.toAffineTransform();
+}
+
+CoordinatedGraphicsScene* WebView::coordinatedGraphicsScene()
+{
+ DrawingAreaProxy* drawingArea = m_page->drawingArea();
+ if (!drawingArea)
+ return 0;
+
+ WebKit::CoordinatedLayerTreeHostProxy* layerTreeHostProxy = drawingArea->coordinatedLayerTreeHostProxy();
+ if (!layerTreeHostProxy)
+ return 0;
+
+ return layerTreeHostProxy->coordinatedGraphicsScene();
+}
+
+void WebView::updateViewportSize()
+{
+ if (DrawingAreaProxy* drawingArea = page()->drawingArea()) {
+ // Web Process expects sizes in UI units, and not raw device units.
+ drawingArea->setSize(roundedIntSize(dipSize()), IntSize(), IntSize());
+ FloatRect visibleContentsRect(contentPosition(), visibleContentsSize());
+ visibleContentsRect.intersect(FloatRect(FloatPoint(), contentsSize()));
+ drawingArea->setVisibleContentsRect(visibleContentsRect, FloatPoint());
+ }
+}
+
+inline WebCore::FloatSize WebView::dipSize() const
+{
+ FloatSize dipSize(size());
+ dipSize.scale(1 / m_page->deviceScaleFactor());
+
+ return dipSize;
+}
+
+WebCore::FloatSize WebView::visibleContentsSize() const
+{
+ FloatSize visibleContentsSize(dipSize());
+ visibleContentsSize.scale(1 / m_contentScaleFactor);
+
+ return visibleContentsSize;
+}
+
+// Page Client
+
+PassOwnPtr<DrawingAreaProxy> WebView::createDrawingAreaProxy()
+{
+ OwnPtr<DrawingAreaProxy> drawingArea = DrawingAreaProxyImpl::create(page());
+ return drawingArea.release();
+}
+
+void WebView::setViewNeedsDisplay(const WebCore::IntRect& area)
+{
+ m_client.viewNeedsDisplay(this, area);
+}
+
+void WebView::displayView()
+{
+ notImplemented();
+}
+
+void WebView::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
+{
+ setViewNeedsDisplay(scrollRect);
+}
+
+WebCore::IntSize WebView::viewSize()
+{
+ return roundedIntSize(dipSize());
+}
+
+bool WebView::isViewWindowActive()
+{
+ notImplemented();
+ return true;
+}
+
+bool WebView::isViewFocused()
+{
+ return isFocused();
+}
+
+bool WebView::isViewVisible()
+{
+ return isVisible();
+}
+
+bool WebView::isViewInWindow()
+{
+ notImplemented();
+ return true;
+}
+
+void WebView::processDidCrash()
+{
+ m_client.webProcessCrashed(this, m_page->urlAtProcessExit());
+}
+
+void WebView::didRelaunchProcess()
+{
+ m_client.webProcessDidRelaunch(this);
+}
+
+void WebView::pageClosed()
+{
+ notImplemented();
+}
+
+void WebView::preferencesDidChange()
+{
+ notImplemented();
+}
+
+void WebView::toolTipChanged(const String&, const String& newToolTip)
+{
+ m_client.didChangeTooltip(this, newToolTip);
+}
+
+void WebView::setCursor(const WebCore::Cursor&)
+{
+ notImplemented();
+}
+
+void WebView::setCursorHiddenUntilMouseMoves(bool)
+{
+ notImplemented();
+}
+
+void WebView::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ m_undoController.registerEditCommand(command, undoOrRedo);
+}
+
+void WebView::clearAllEditCommands()
+{
+ m_undoController.clearAllEditCommands();
+}
+
+bool WebView::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ return m_undoController.canUndoRedo(undoOrRedo);
+}
+
+void WebView::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ m_undoController.executeUndoRedo(undoOrRedo);
+}
+
+IntPoint WebView::screenToWindow(const IntPoint& point)
+{
+ notImplemented();
+ return point;
+}
+
+IntRect WebView::windowToScreen(const IntRect&)
+{
+ notImplemented();
+ return IntRect();
+}
+
+void WebView::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
+{
+ notImplemented();
+}
+
+#if ENABLE(TOUCH_EVENTS)
+void WebView::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
+{
+ m_client.doneWithTouchEvent(this, event, wasEventHandled);
+}
+#endif
+
+PassRefPtr<WebPopupMenuProxy> WebView::createPopupMenuProxy(WebPageProxy*)
+{
+ notImplemented();
+ return 0;
+}
+
+PassRefPtr<WebContextMenuProxy> WebView::createContextMenuProxy(WebPageProxy*)
+{
+ notImplemented();
+ return 0;
+}
+
+#if ENABLE(INPUT_TYPE_COLOR)
+PassRefPtr<WebColorPicker> WebView::createColorPicker(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&)
+{
+ notImplemented();
+ return 0;
+}
+#endif
+
+void WebView::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
+{
+ notImplemented();
+}
+
+void WebView::enterAcceleratedCompositingMode(const LayerTreeContext&)
+{
+ if (CoordinatedGraphicsScene* scene = coordinatedGraphicsScene())
+ scene->setActive(true);
+}
+
+void WebView::exitAcceleratedCompositingMode()
+{
+ if (CoordinatedGraphicsScene* scene = coordinatedGraphicsScene())
+ scene->setActive(false);
+}
+
+void WebView::updateAcceleratedCompositingMode(const LayerTreeContext&)
+{
+ notImplemented();
+}
+
+void WebView::flashBackingStoreUpdates(const Vector<IntRect>&)
+{
+ notImplemented();
+}
+
+void WebView::updateTextInputState()
+{
+ notImplemented();
+}
+
+void WebView::handleDownloadRequest(DownloadProxy*)
+{
+ notImplemented();
+}
+
+FloatRect WebView::convertToDeviceSpace(const FloatRect& userRect)
+{
+ if (m_page->useFixedLayout()) {
+ FloatRect result = userRect;
+ result.scale(m_page->deviceScaleFactor());
+ return result;
+ }
+ // Legacy mode.
+ notImplemented();
+ return userRect;
+}
+
+FloatRect WebView::convertToUserSpace(const FloatRect& deviceRect)
+{
+ if (m_page->useFixedLayout()) {
+ FloatRect result = deviceRect;
+ result.scale(1 / m_page->deviceScaleFactor());
+ return result;
+ }
+ // Legacy mode.
+ notImplemented();
+ return deviceRect;
+}
+
+void WebView::didChangeViewportProperties(const WebCore::ViewportAttributes& attr)
+{
+ m_client.didChangeViewportAttributes(this, attr);
+}
+
+void WebView::pageDidRequestScroll(const IntPoint& position)
+{
+ FloatPoint uiPosition(position);
+ uiPosition.scale(contentScaleFactor(), contentScaleFactor());
+ setContentPosition(uiPosition);
+
+ m_client.didChangeContentsPosition(this, position);
+}
+
+void WebView::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect)
+{
+ m_client.didRenderFrame(this, contentsSize, coveredRect);
+}
+
+void WebView::pageTransitionViewportReady()
+{
+ m_client.didCompletePageTransition(this);
+}
+
+void WebView::findZoomableAreaForPoint(const IntPoint& point, const IntSize& size)
+{
+ m_page->findZoomableAreaForPoint(transformFromScene().mapPoint(point), transformFromScene().mapSize(size));
+}
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h
new file mode 100644
index 000000000..e79a238e3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebView_h
+#define WebView_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "APIObject.h"
+#include "DefaultUndoController.h"
+#include "PageClient.h"
+#include "WebContext.h"
+#include "WebGeometry.h"
+#include "WebPageGroup.h"
+#include "WebPageProxy.h"
+#include "WebPreferences.h"
+#include "WebViewClient.h"
+#include <WebCore/TransformationMatrix.h>
+
+namespace WebCore {
+class CoordinatedGraphicsScene;
+}
+
+namespace WebKit {
+
+class WebView : public TypedAPIObject<APIObject::TypeView>, public PageClient {
+public:
+ virtual ~WebView();
+
+ static PassRefPtr<WebView> create(WebContext*, WebPageGroup*);
+
+ void initialize();
+
+ void setSize(const WebCore::IntSize&);
+ const WebCore::IntSize& size() const { return m_size; }
+
+ bool isFocused() const { return m_focused; }
+ void setFocused(bool);
+
+ bool isVisible() const { return m_visible; }
+ void setVisible(bool);
+
+ void setContentScaleFactor(float scaleFactor) { m_contentScaleFactor = scaleFactor; }
+ float contentScaleFactor() const { return m_contentScaleFactor; }
+
+ void setContentPosition(const WebCore::FloatPoint& position) { m_contentPosition = position; }
+ const WebCore::FloatPoint& contentPosition() const { return m_contentPosition; }
+
+ void setUserViewportTranslation(double tx, double ty);
+ WebCore::IntPoint userViewportToContents(const WebCore::IntPoint&) const;
+ WebCore::IntPoint userViewportToScene(const WebCore::IntPoint&) const;
+ WebCore::IntPoint contentsToUserViewport(const WebCore::IntPoint&) const;
+
+ void paintToCurrentGLContext();
+
+ WKPageRef pageRef() const { return toAPI(m_page.get()); }
+
+ void setDrawsBackground(bool);
+ bool drawsBackground() const;
+ void setDrawsTransparentBackground(bool);
+ bool drawsTransparentBackground() const;
+
+ void suspendActiveDOMObjectsAndAnimations();
+ void resumeActiveDOMObjectsAndAnimations();
+
+ void setShowsAsSource(bool);
+ bool showsAsSource() const;
+
+#if ENABLE(FULLSCREEN_API)
+ bool exitFullScreen();
+#endif
+
+ void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize&);
+
+ // View client.
+ void initializeClient(const WKViewClient*);
+
+ WebPageProxy* page() { return m_page.get(); }
+
+ void didChangeContentsSize(const WebCore::IntSize&);
+ const WebCore::IntSize& contentsSize() const { return m_contentsSize; }
+ WebCore::FloatSize visibleContentsSize() const;
+ void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
+
+ // FIXME: Should become private when Web Events creation is moved to WebView.
+ WebCore::AffineTransform transformFromScene() const;
+ WebCore::AffineTransform transformToScene() const;
+
+ void setOpacity(double opacity) { m_opacity = clampTo(opacity, 0.0, 1.0); }
+ double opacity() const { return m_opacity; }
+
+protected:
+ WebView(WebContext*, WebPageGroup*);
+ WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene();
+
+ void updateViewportSize();
+ WebCore::FloatSize dipSize() const;
+ // PageClient
+ virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy() OVERRIDE;
+
+ virtual void setViewNeedsDisplay(const WebCore::IntRect&) OVERRIDE;
+
+ virtual void displayView() OVERRIDE;
+
+ virtual bool canScrollView() OVERRIDE { return false; }
+ virtual void scrollView(const WebCore::IntRect&, const WebCore::IntSize&) OVERRIDE;
+
+ virtual WebCore::IntSize viewSize() OVERRIDE;
+
+ virtual bool isViewWindowActive() OVERRIDE;
+ virtual bool isViewFocused() OVERRIDE;
+ virtual bool isViewVisible() OVERRIDE;
+ virtual bool isViewInWindow() OVERRIDE;
+
+ virtual void processDidCrash() OVERRIDE;
+ virtual void didRelaunchProcess() OVERRIDE;
+ virtual void pageClosed() OVERRIDE;
+
+ virtual void preferencesDidChange() OVERRIDE;
+
+ virtual void toolTipChanged(const String&, const String&) OVERRIDE;
+
+ virtual void pageDidRequestScroll(const WebCore::IntPoint&) OVERRIDE;
+ virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) OVERRIDE;
+ virtual void pageTransitionViewportReady() OVERRIDE;
+
+ virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
+ virtual void setCursorHiddenUntilMouseMoves(bool) OVERRIDE;
+
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) OVERRIDE;
+
+ virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) OVERRIDE;
+ virtual void clearAllEditCommands() OVERRIDE;
+ virtual bool canUndoRedo(WebPageProxy::UndoOrRedo) OVERRIDE;
+ virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) OVERRIDE;
+
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) OVERRIDE;
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) OVERRIDE;
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) OVERRIDE;
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) OVERRIDE;
+
+ virtual void updateTextInputState() OVERRIDE;
+
+ virtual void handleDownloadRequest(DownloadProxy*) OVERRIDE;
+
+ virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool) OVERRIDE;
+#if ENABLE(TOUCH_EVENTS)
+ virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) OVERRIDE;
+#endif
+
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*) OVERRIDE;
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*) OVERRIDE;
+#if ENABLE(INPUT_TYPE_COLOR)
+ virtual PassRefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) OVERRIDE;
+#endif
+
+ virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool, bool) OVERRIDE;
+
+ virtual void enterAcceleratedCompositingMode(const LayerTreeContext&) OVERRIDE;
+ virtual void exitAcceleratedCompositingMode() OVERRIDE;
+ virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) OVERRIDE;
+
+ virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>&) OVERRIDE;
+
+protected:
+ WebViewClient m_client;
+ RefPtr<WebPageProxy> m_page;
+ DefaultUndoController m_undoController;
+ WebCore::TransformationMatrix m_userViewportTransform;
+ WebCore::IntSize m_size; // Size in device units.
+ bool m_focused;
+ bool m_visible;
+ float m_contentScaleFactor;
+ double m_opacity;
+ WebCore::FloatPoint m_contentPosition; // Position in UI units.
+ WebCore::IntSize m_contentsSize;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // WebView_h
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebViewClient.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebViewClient.cpp
new file mode 100644
index 000000000..f75de5023
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebViewClient.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "WebViewClient.h"
+
+#include "NotImplemented.h"
+#include "WKAPICast.h"
+#include "WKBase.h"
+#include "WKRetainPtr.h"
+#include "WebViewportAttributes.h"
+
+#if ENABLE(TOUCH_EVENTS)
+#include "NativeWebTouchEvent.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebViewClient::viewNeedsDisplay(WebView* view, const IntRect& area)
+{
+ if (!m_client.viewNeedsDisplay)
+ return;
+
+ m_client.viewNeedsDisplay(toAPI(view), toAPI(area), m_client.clientInfo);
+}
+
+void WebViewClient::didChangeContentsSize(WebView* view, const IntSize& size)
+{
+ if (!m_client.didChangeContentsSize)
+ return;
+
+ m_client.didChangeContentsSize(toAPI(view), toAPI(size), m_client.clientInfo);
+}
+
+void WebViewClient::webProcessCrashed(WebView* view, const String& url)
+{
+ if (!m_client.webProcessCrashed)
+ return;
+
+ m_client.webProcessCrashed(toAPI(view), adoptWK(toCopiedURLAPI(url)).get(), m_client.clientInfo);
+}
+
+void WebViewClient::webProcessDidRelaunch(WebView* view)
+{
+ if (!m_client.webProcessDidRelaunch)
+ return;
+
+ m_client.webProcessDidRelaunch(toAPI(view), m_client.clientInfo);
+}
+
+void WebViewClient::didChangeContentsPosition(WebView* view, const WebCore::IntPoint& point)
+{
+ if (!m_client.didChangeContentsPosition)
+ return;
+
+ m_client.didChangeContentsPosition(toAPI(view), toAPI(point), m_client.clientInfo);
+}
+
+void WebViewClient::didRenderFrame(WebView* view, const WebCore::IntSize& size, const WebCore::IntRect& coveredRect)
+{
+ if (!m_client.didRenderFrame)
+ return;
+
+ m_client.didRenderFrame(toAPI(view), toAPI(size), toAPI(coveredRect), m_client.clientInfo);
+}
+
+void WebViewClient::didCompletePageTransition(WebView* view)
+{
+ if (!m_client.didCompletePageTransition)
+ return;
+
+ m_client.didCompletePageTransition(toAPI(view), m_client.clientInfo);
+}
+
+void WebViewClient::didChangeViewportAttributes(WebView* view, const ViewportAttributes& attributes)
+{
+ if (!m_client.didChangeViewportAttributes)
+ return;
+
+ WKRetainPtr<WKViewportAttributesRef> wkAttributes = adoptWK(toAPI(WebViewportAttributes::create(attributes).leakRef()));
+ m_client.didChangeViewportAttributes(toAPI(view), wkAttributes.get(), m_client.clientInfo);
+}
+
+void WebViewClient::didChangeTooltip(WebView* view, const String& tooltip)
+{
+ if (!m_client.didChangeTooltip)
+ return;
+
+ m_client.didChangeTooltip(toAPI(view), adoptWK(toCopiedAPI(tooltip)).get(), m_client.clientInfo);
+}
+
+void WebViewClient::didFindZoomableArea(WebView* view, const IntPoint& target, const IntRect& area)
+{
+ if (!m_client.didFindZoomableArea)
+ return;
+
+ m_client.didFindZoomableArea(toAPI(view), toAPI(target), toAPI(area), m_client.clientInfo);
+}
+
+#if ENABLE(TOUCH_EVENTS)
+void WebViewClient::doneWithTouchEvent(WebView* view, const NativeWebTouchEvent& event, bool wasEventHandled)
+{
+#if PLATFORM(EFL)
+ if (!m_client.doneWithTouchEvent)
+ return;
+
+ m_client.doneWithTouchEvent(toAPI(view), toAPI(const_cast<EwkTouchEvent*>(event.nativeEvent())), wasEventHandled, m_client.clientInfo);
+#else
+ notImplemented();
+ UNUSED_PARAM(view);
+ UNUSED_PARAM(event);
+ UNUSED_PARAM(wasEventHandled);
+#endif
+}
+#endif
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/WebViewClient.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebViewClient.h
new file mode 100644
index 000000000..51979e9c7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/WebViewClient.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebViewClient_h
+#define WebViewClient_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "APIClient.h"
+#include "WKView.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+class IntPoint;
+class IntRect;
+class IntSize;
+class ViewportAttributes;
+}
+
+namespace WebKit {
+
+class WebView;
+
+#if ENABLE(TOUCH_EVENTS)
+class NativeWebTouchEvent;
+#endif
+
+class WebViewClient: public APIClient<WKViewClient, kWKViewClientCurrentVersion> {
+public:
+ void viewNeedsDisplay(WebView*, const WebCore::IntRect&);
+ void didChangeContentsSize(WebView*, const WebCore::IntSize&);
+ void webProcessCrashed(WebView*, const String& url);
+ void webProcessDidRelaunch(WebView*);
+ void didChangeContentsPosition(WebView*, const WebCore::IntPoint&);
+ void didRenderFrame(WebView*, const WebCore::IntSize&, const WebCore::IntRect&);
+ void didCompletePageTransition(WebView*);
+ void didChangeViewportAttributes(WebView*, const WebCore::ViewportAttributes&);
+ void didChangeTooltip(WebView*, const String& tooltip);
+ void didFindZoomableArea(WebView*, const WebCore::IntPoint&, const WebCore::IntRect&);
+#if ENABLE(TOUCH_EVENTS)
+ void doneWithTouchEvent(WebView*, const NativeWebTouchEvent&, bool);
+#endif
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // WebViewClient_h