Skip to content

Instantly share code, notes, and snippets.

@annulen
Created April 6, 2016 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save annulen/632bf3f69932f20b9978aa2a3a9df9da to your computer and use it in GitHub Desktop.
Save annulen/632bf3f69932f20b9978aa2a3a9df9da to your computer and use it in GitHub Desktop.
commit 763ebd68f7c51ce3162adf845e91b0d94fe8cd1b
Author: Allan Sandfeld Jensen <allan.jensen@digia.com>
Date: Fri May 23 15:09:51 2014 +0200
Coordinated WK1 graphics
Change-Id: Id171200839bd6d1664852c5025a27db353e919f6
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
index 74cd528..377287a 100644
--- a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
@@ -38,6 +38,7 @@
#include <wtf/CurrentTime.h>
#include <wtf/TemporaryChange.h>
+#include <QDebug>
namespace WebCore {
PassOwnPtr<CompositingCoordinator> CompositingCoordinator::create(Page* page, CompositingCoordinator::Client* client)
@@ -263,6 +264,7 @@ void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, G
PassOwnPtr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayerClient* client)
{
+ qDebug() << Q_FUNC_INFO;
CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client);
layer->setCoordinator(this);
m_registeredLayers.add(layer->id(), layer);
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
index 2737ec1..9657f55 100644
--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
@@ -109,6 +109,7 @@ void CoordinatedBackingStore::setSize(const FloatSize& size)
void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, const FloatRect& rect)
{
+ //qDebug() << Q_FUNC_INFO;
for (size_t i = 0; i < tiles.size(); ++i)
tiles[i]->paint(textureMapper, transform, opacity, calculateExposedTileEdges(rect, tiles[i]->rect()));
}
@@ -120,6 +121,7 @@ TransformationMatrix CoordinatedBackingStore::adjustedTransformForRect(const Flo
void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
{
+ //qDebug() << Q_FUNC_INFO << m_tiles.size () << m_size;
if (m_tiles.isEmpty())
return;
ASSERT(!m_size.isZero());
@@ -175,6 +177,7 @@ void CoordinatedBackingStore::drawRepaintCounter(TextureMapper* textureMapper, i
void CoordinatedBackingStore::commitTileOperations(TextureMapper* textureMapper)
{
+ qDebug() << Q_FUNC_INFO;
if (!m_pendingSize.isZero()) {
m_size = m_pendingSize;
m_pendingSize = FloatSize();
@@ -185,6 +188,9 @@ void CoordinatedBackingStore::commitTileOperations(TextureMapper* textureMapper)
m_tiles.remove(*it);
m_tilesToRemove.clear();
+ if (!textureMapper)
+ return;
+
CoordinatedBackingStoreTileMap::iterator tilesEnd = m_tiles.end();
for (CoordinatedBackingStoreTileMap::iterator it = m_tiles.begin(); it != tilesEnd; ++it)
it->value.swapBuffers(textureMapper);
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
index 32c7dac..3ee4808 100644
--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
@@ -126,6 +126,8 @@ void CoordinatedGraphicsScene::paintToGraphicsContext(PlatformGraphicsContext* p
if (!layer)
return;
+ layer->setTextureMapper(m_textureMapper.get());
+ layer->applyAnimationsRecursively();
GraphicsContext graphicsContext(platformContext);
m_textureMapper->setGraphicsContext(&graphicsContext);
m_textureMapper->beginPainting();
@@ -415,6 +417,8 @@ void CoordinatedGraphicsScene::setRootLayerID(CoordinatedLayerID layerID)
m_rootLayerID = layerID;
+ if (!m_rootLayer)
+ return;
TextureMapperLayer* layer = layerByID(layerID);
ASSERT(m_rootLayer->children().isEmpty());
m_rootLayer->addChild(layer);
@@ -487,6 +491,7 @@ void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, co
void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
{
+ qDebug() << Q_FUNC_INFO << state.tilesToUpdate.size();
if (state.tilesToUpdate.isEmpty())
return;
@@ -606,6 +611,7 @@ void CoordinatedGraphicsScene::removeReleasedImageBackingsIfNeeded()
void CoordinatedGraphicsScene::commitPendingBackingStoreOperations()
{
+ qDebug() << Q_FUNC_INFO;
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());
@@ -615,6 +621,7 @@ void CoordinatedGraphicsScene::commitPendingBackingStoreOperations()
void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState& state)
{
+ qDebug() << Q_FUNC_INFO;
m_renderedContentsScrollPosition = state.scrollPosition;
createLayers(state.layersToCreate);
@@ -645,6 +652,16 @@ void CoordinatedGraphicsScene::renderNextFrame()
m_client->renderNextFrame();
}
+void CoordinatedGraphicsScene::setTextureMapper(PassOwnPtr<TextureMapper> textureMapper)
+{
+ if (m_textureMapper)
+ return;
+
+ m_textureMapper = textureMapper;
+
+ ensureRootLayer();
+}
+
void CoordinatedGraphicsScene::ensureRootLayer()
{
if (m_rootLayer)
@@ -660,6 +677,12 @@ void CoordinatedGraphicsScene::ensureRootLayer()
ASSERT(m_textureMapper);
m_rootLayer->setTextureMapper(m_textureMapper.get());
+
+ if (m_rootLayerID != InvalidCoordinatedLayerID) {
+ TextureMapperLayer* layer = layerByID(m_rootLayerID);
+ m_rootLayer->addChild(layer);
+ }
+
}
void CoordinatedGraphicsScene::syncRemoteContent()
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
index 7fa92ad..8bbc647 100644
--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
@@ -84,6 +84,9 @@ public:
void setBackgroundColor(const Color&);
void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
+ void setTextureMapper(PassOwnPtr<TextureMapper>);
+ TextureMapper* textureMapper() { return m_textureMapper.get(); }
+
private:
void setRootLayerID(CoordinatedLayerID);
void createLayers(const Vector<CoordinatedLayerID>&);
diff --git a/Source/WebKit/WebKit1.pro b/Source/WebKit/WebKit1.pro
index 6dbb907..c27dba3 100644
--- a/Source/WebKit/WebKit1.pro
+++ b/Source/WebKit/WebKit1.pro
@@ -32,6 +32,8 @@ SOURCES += \
$$PWD/qt/Api/qwebscriptworld.cpp \
$$PWD/qt/WebCoreSupport/ChromeClientQt.cpp \
$$PWD/qt/WebCoreSupport/ContextMenuClientQt.cpp \
+ $$PWD/qt/WebCoreSupport/CoordinatedGraphicsClientQt.cpp \
+ $$PWD/qt/WebCoreSupport/CoordinatedSurfaceQt.cpp \
$$PWD/qt/WebCoreSupport/DragClientQt.cpp \
$$PWD/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp \
$$PWD/qt/WebCoreSupport/EditorClientQt.cpp \
@@ -71,6 +73,8 @@ HEADERS += \
$$PWD/qt/Api/qwebkitplatformplugin.h \
$$PWD/qt/WebCoreSupport/ChromeClientQt.h \
$$PWD/qt/WebCoreSupport/ContextMenuClientQt.h \
+ $$PWD/qt/WebCoreSupport/CoordinatedGraphicsClientQt.h \
+ $$PWD/qt/WebCoreSupport/CoordinatedSurfaceQt.h \
$$PWD/qt/WebCoreSupport/DragClientQt.h \
$$PWD/qt/WebCoreSupport/EditorClientQt.h \
$$PWD/qt/WebCoreSupport/FrameLoaderClientQt.h \
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index 6102537..ad0425a 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -60,7 +60,10 @@
#include "ScrollbarTheme.h"
#include "SearchPopupMenuQt.h"
#include "SecurityOrigin.h"
-#include "TextureMapperLayerClientQt.h"
+
+#include "CoordinatedGraphicsClientQt.h"
+//#include "TextureMapperLayerClientQt.h"
+
#include "TiledBackingStore.h"
#include "ViewportArguments.h"
#include "WindowFeatures.h"
@@ -627,36 +630,50 @@ void ChromeClientQt::scheduleAnimation()
void ChromeClientQt::serviceScriptedAnimations()
{
- m_webPage->mainFrameAdapter()->frame->view()->serviceScriptedAnimations(currentTime());
+ if (m_coordinatedGraphicsClient)
+ m_coordinatedGraphicsClient->scheduleAnimation();
+ else
+ m_webPage->mainFrameAdapter()->frame->view()->serviceScriptedAnimations(WTF::monotonicallyIncreasingTime());
}
#endif
-#if USE(ACCELERATED_COMPOSITING)
+#if 1 || USE(ACCELERATED_COMPOSITING)
+
+GraphicsLayerFactory* ChromeClientQt::graphicsLayerFactory() const
+{
+ if (!m_coordinatedGraphicsClient)
+ m_coordinatedGraphicsClient = adoptPtr(new CoordinatedGraphicsClientQt(m_webPage->mainFrameAdapter()));
+ return m_coordinatedGraphicsClient->graphicsLayerFactory();
+}
+
void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
{
- if (!m_textureMapperLayerClient)
- m_textureMapperLayerClient = adoptPtr(new TextureMapperLayerClientQt(m_webPage->mainFrameAdapter()));
- m_textureMapperLayerClient->setRootGraphicsLayer(graphicsLayer);
+// if (!m_textureMapperLayerClient)
+// m_textureMapperLayerClient = adoptPtr(new TextureMapperLayerClientQt(m_webPage->mainFrameAdapter()));
+// m_textureMapperLayerClient->setRootGraphicsLayer(graphicsLayer);
+ if (!m_coordinatedGraphicsClient)
+ m_coordinatedGraphicsClient = adoptPtr(new CoordinatedGraphicsClientQt(m_webPage->mainFrameAdapter()));
+ m_coordinatedGraphicsClient->setRootGraphicsLayer(graphicsLayer);
}
void ChromeClientQt::setNeedsOneShotDrawingSynchronization()
{
// we want the layers to synchronize next time we update the screen anyway
- if (m_textureMapperLayerClient)
- m_textureMapperLayerClient->markForSync(false);
+ if (m_coordinatedGraphicsClient)
+ m_coordinatedGraphicsClient->markForSync(false);
}
void ChromeClientQt::scheduleCompositingLayerFlush()
{
// we want the layers to synchronize ASAP
- if (m_textureMapperLayerClient)
- m_textureMapperLayerClient->markForSync(true);
+ if (m_coordinatedGraphicsClient)
+ m_coordinatedGraphicsClient->markForSync(true);
}
ChromeClient::CompositingTriggerFlags ChromeClientQt::allowedCompositingTriggers() const
{
if (allowsAcceleratedCompositing())
- return ThreeDTransformTrigger | CanvasTrigger | AnimationTrigger | AnimatedOpacityTrigger;
+ return ThreeDTransformTrigger | VideoTrigger | CanvasTrigger | AnimationTrigger | AnimatedOpacityTrigger;
return 0;
}
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index 8f2db26..0184029 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -58,7 +58,9 @@ struct ViewportArguments;
#if ENABLE(VIDEO)
class FullScreenVideoQt;
#endif
-class TextureMapperLayerClientQt;
+
+class CoordinatedGraphicsClientQt;
+//class TextureMapperLayerClientQt;
class ChromeClientQt : public ChromeClient {
public:
@@ -143,6 +145,7 @@ public:
virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded);
#if USE(ACCELERATED_COMPOSITING)
+ virtual GraphicsLayerFactory* graphicsLayerFactory() const;
// This is a hook for WebCore to tell us what we need to do with the GraphicsLayers.
virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*);
virtual void setNeedsOneShotDrawingSynchronization();
@@ -224,7 +227,8 @@ public:
mutable QtPlatformPlugin m_platformPlugin;
#if USE(ACCELERATED_COMPOSITING)
- OwnPtr<TextureMapperLayerClientQt> m_textureMapperLayerClient;
+// OwnPtr<TextureMapperLayerClientQt> m_textureMapperLayerClient;
+ mutable OwnPtr<CoordinatedGraphicsClientQt> m_coordinatedGraphicsClient;
#endif
};
}
diff --git a/Source/WebKit/qt/WebCoreSupport/CoordinatedGraphicsClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/CoordinatedGraphicsClientQt.cpp
new file mode 100644
index 0000000..bf8cf46
--- /dev/null
+++ b/Source/WebKit/qt/WebCoreSupport/CoordinatedGraphicsClientQt.cpp
@@ -0,0 +1,250 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2012 Digia Plc 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 "CoordinatedGraphicsClientQt.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "CoordinatedSurfaceQt.h"
+#include "GraphicsLayerTextureMapper.h"
+#include "FrameView.h"
+#include "QWebFrameAdapter.h"
+#include "QWebPageAdapter.h"
+#include "TextureMapperLayer.h"
+#include "coordinated/CoordinatedSurface.h"
+
+#include <QPaintEngine>
+
+using namespace WebCore;
+
+CoordinatedGraphicsClientQt::CoordinatedGraphicsClientQt(QWebFrameAdapter *frame)
+ : m_frame(frame)
+ , m_syncTimer(this, &CoordinatedGraphicsClientQt::syncLayers)
+ , m_isWaitingForRenderer(true)
+{
+ m_coordinator = CompositingCoordinator::create(frame->pageAdapter->page, this);
+ m_graphicsScene = new CoordinatedGraphicsScene(this);
+
+ QSize size = frame->frameRect().size();
+ m_coordinator->createRootLayer(size);
+ qDebug() << Q_FUNC_INFO << size;
+// m_coordinator->setVisibleContentsRect(IntRect(frame->frameRect()), FloatPoint());
+ m_coordinator->setVisibleContentsRect(IntRect(frame->pageAdapter->viewRectRelativeToWindow()), FloatPoint());
+
+ CoordinatedSurface::setFactory(createCoordinatedSurface);
+
+}
+
+CoordinatedGraphicsClientQt::~CoordinatedGraphicsClientQt()
+{
+ m_graphicsScene->detach();
+ m_coordinator = 0;
+ delete m_graphicsScene;
+}
+
+void CoordinatedGraphicsClientQt::markForSync(bool scheduleSync)
+{
+ qDebug() << Q_FUNC_INFO << scheduleSync;
+// m_coordinator->syncDisplayState();
+ if (m_syncTimer.isActive())
+ return;
+ m_syncTimer.startOneShot(0);
+}
+
+void CoordinatedGraphicsClientQt::setRootGraphicsLayer(GraphicsLayer* layer)
+{
+ qDebug() << Q_FUNC_INFO << layer;
+ if (layer) {
+ m_coordinator->setRootCompositingLayer(layer);
+// m_rootGraphicsLayer = GraphicsLayer::create(m_coordinator, 0);
+// m_rootTextureMapperLayer = toTextureMapperLayer(m_rootGraphicsLayer.get());
+// m_rootGraphicsLayer->addChild(layer);
+// m_rootGraphicsLayer->setDrawsContent(false);
+// m_rootGraphicsLayer->setMasksToBounds(false);
+// m_rootGraphicsLayer->setSize(IntSize(1, 1));
+ TextureMapper::AccelerationMode mode = TextureMapper::SoftwareMode;
+ if (m_frame->pageAdapter->client->makeOpenGLContextCurrentIfAvailable())
+ mode = TextureMapper::OpenGLMode;
+ OwnPtr<TextureMapper> textureMapper = TextureMapper::create(mode);
+ m_graphicsScene->setTextureMapper(textureMapper.release());
+// m_rootTextureMapperLayer->setTextureMapper(m_textureMapper.get());
+// syncRootLayer();
+// m_coordinator->rootLayer()->flushCompositingStateForThisLayerOnly();
+ } else {
+ m_graphicsScene->setActive(false);
+ m_coordinator->setRootCompositingLayer(0);
+// m_rootGraphicsLayer.clear();
+// m_rootTextureMapperLayer = 0;
+ }
+}
+
+void CoordinatedGraphicsClientQt::syncLayers(Timer<CoordinatedGraphicsClientQt>*)
+{
+ qDebug() << Q_FUNC_INFO << m_isWaitingForRenderer;
+ if (m_isWaitingForRenderer)
+ return;
+
+ m_coordinator->syncDisplayState();
+
+ m_coordinator->flushPendingLayerChanges();
+
+ m_frame->pageAdapter->client->repaintViewport();
+}
+
+
+void CoordinatedGraphicsClientQt::didFlushRootLayer()
+{
+// qDebug() << Q_FUNC_INFO;
+}
+
+void CoordinatedGraphicsClientQt::willSyncLayerState(CoordinatedGraphicsLayerState&)
+{
+// qDebug() << Q_FUNC_INFO;
+}
+
+void CoordinatedGraphicsClientQt::notifyFlushRequired()
+{
+ qDebug() << Q_FUNC_INFO;
+// m_coordinator->syncDisplayState();
+ if (!m_syncTimer.isActive())
+ m_syncTimer.startOneShot(0);
+// markForSync(true);
+}
+
+void CoordinatedGraphicsClientQt::commitSceneState(const CoordinatedGraphicsState& graphicsState)
+{
+ qDebug() << Q_FUNC_INFO;
+ m_isWaitingForRenderer = true;
+// m_graphicsScene->appendUpdate(bind(&CoordinatedGraphicsScene::commitSceneState, m_graphicsScene, graphicsState));
+ m_graphicsScene->commitSceneState(graphicsState);
+// updateViewport();
+}
+
+void CoordinatedGraphicsClientQt::paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect& clipRect)
+{
+ qDebug() << Q_FUNC_INFO << QRect(clipRect);
+}
+
+void CoordinatedGraphicsClientQt::purgeBackingStores()
+{
+ qDebug() << Q_FUNC_INFO;
+ m_coordinator->purgeBackingStores();
+}
+
+void CoordinatedGraphicsClientQt::renderNextFrame()
+{
+ qDebug() << Q_FUNC_INFO;
+ m_isWaitingForRenderer = false;
+ if (!m_syncTimer.isActive())
+ m_syncTimer.startOneShot(0);
+ m_coordinator->renderNextFrame();
+
+// m_coordinator->syncDisplayState();
+// m_frame->pageAdapter->client->repaintViewport();
+}
+
+void CoordinatedGraphicsClientQt::updateViewport()
+{
+ qDebug() << Q_FUNC_INFO;
+ m_frame->pageAdapter->client->repaintViewport();
+}
+
+void CoordinatedGraphicsClientQt::commitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+ qDebug() << Q_FUNC_INFO << layerID << QSize(offset);
+ updateViewport();
+ m_coordinator->commitScrollOffset(layerID, offset);
+}
+
+PassRefPtr<CoordinatedSurface> CoordinatedGraphicsClientQt::createCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags)
+{
+ return CoordinatedSurfaceQt::create(size, flags);
+}
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+void CoordinatedGraphicsClientQt::scheduleAnimation()
+{
+ qDebug() << Q_FUNC_INFO;
+ //m_coordinator->nextAnimationServiceTime();
+// m_coordinator->syncDisplayState();
+// m_graphicsScene->setActive(true);
+// markForSync(true);
+ if (!m_syncTimer.isActive())
+ m_syncTimer.startOneShot(0);
+
+// m_frame->pageAdapter->client->repaintViewport();
+}
+#endif
+
+
+void CoordinatedGraphicsClientQt::renderCompositedLayers(GraphicsContext* context, const IntRect& clip)
+{
+ qDebug() << Q_FUNC_INFO;
+ if (!m_graphicsScene->textureMapper())
+ return;
+
+ QPainter* painter = context->platformContext();
+
+ // GraphicsContext::imageInterpolationQuality is always InterpolationDefault here,
+ // but 'default' may be interpreted differently due to a different backend QPainter,
+ // so we need to set an explicit imageInterpolationQuality.
+ if (painter->renderHints() & QPainter::SmoothPixmapTransform)
+ m_graphicsScene->textureMapper()->setImageInterpolationQuality(WebCore::InterpolationMedium);
+ else
+ m_graphicsScene->textureMapper()->setImageInterpolationQuality(WebCore::InterpolationNone);
+ m_graphicsScene->textureMapper()->setTextDrawingMode(context->textDrawingMode());
+
+ m_graphicsScene->setActive(true);
+
+ if (m_graphicsScene->textureMapper()->accelerationMode() == TextureMapper::SoftwareMode) {
+
+ m_graphicsScene->paintToGraphicsContext(painter);
+// m_graphicsScene->setActive(true);
+// m_isWaitingForRenderer = false;
+// m_coordinator->renderNextFrame();
+// m_coordinator->syncDisplayState();
+ return;
+ }
+
+// m_textureMapper->setGraphicsContext(context);
+
+ QTransform transform;
+// if (m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode) {
+// // TextureMapperGL needs to duplicate the entire transform QPainter would do,
+// // including the transforms QPainter would normally do behind the scenes.
+ transform = painter->deviceTransform();
+// } else {
+// // TextureMapperImageBuffer needs a transform that can be used
+// // with QPainter::setWorldTransform.
+// transform = painter->worldTransform();
+// }
+ const TransformationMatrix matrix(
+ transform.m11(), transform.m12(), 0, transform.m13(),
+ transform.m21(), transform.m22(), 0, transform.m23(),
+ 0, 0, 1, 0,
+ transform.m31(), transform.m32(), 0, transform.m33()
+ );
+ m_graphicsScene->paintToCurrentGLContext(matrix, painter->opacity(), clip);
+// m_graphicsScene->setActive(true);
+}
+
+#endif
diff --git a/Source/WebKit/qt/WebCoreSupport/CoordinatedGraphicsClientQt.h b/Source/WebKit/qt/WebCoreSupport/CoordinatedGraphicsClientQt.h
new file mode 100644
index 0000000..39ba3b3
--- /dev/null
+++ b/Source/WebKit/qt/WebCoreSupport/CoordinatedGraphicsClientQt.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2012 Digia Plc 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 CoordinatedGraphicsClientClientQt_h
+#define CoordinatedGraphicsClientClientQt_h
+
+class QWebFrameAdapter;
+
+#include "GraphicsLayer.h"
+#include "TextureMapper.h"
+#include "coordinated/CompositingCoordinator.h"
+#include "coordinated/CoordinatedGraphicsScene.h"
+#include "coordinated/CoordinatedSurface.h"
+#include "Timer.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+#if USE(ACCELERATED_COMPOSITING) && USE(COORDINATED_GRAPHICS)
+class CoordinatedGraphicsClientQt
+ : CompositingCoordinator::Client
+ , CoordinatedGraphicsSceneClient
+{
+public:
+ CoordinatedGraphicsClientQt(QWebFrameAdapter*);
+ ~CoordinatedGraphicsClientQt();
+
+// void syncRootLayer();
+// TextureMapperLayer* rootLayer();
+
+ void markForSync(bool scheduleSync);
+
+ void setRootGraphicsLayer(GraphicsLayer*);
+
+ void syncLayers(Timer<CoordinatedGraphicsClientQt>*);
+
+ void renderCompositedLayers(GraphicsContext*, const IntRect& clip);
+
+ GraphicsLayerFactory* graphicsLayerFactory() const { return m_coordinator.get(); }
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ void scheduleAnimation();
+#endif
+
+ // CompositingCoordinator::Client:
+ virtual void didFlushRootLayer();
+ virtual void willSyncLayerState(CoordinatedGraphicsLayerState&) ;
+ virtual void notifyFlushRequired();
+ virtual void commitSceneState(const CoordinatedGraphicsState&);
+ virtual void paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect& clipRect);
+
+ // CoordinatedGraphicsSceneClient:
+ virtual void purgeBackingStores();
+ virtual void renderNextFrame();
+ virtual void updateViewport();
+ virtual void commitScrollOffset(uint32_t layerID, const IntSize& offset);
+
+ static PassRefPtr<CoordinatedSurface> createCoordinatedSurface(const IntSize&, CoordinatedSurface::Flags);
+
+private:
+// OwnPtr<GraphicsLayer> m_rootGraphicsLayer;
+ CoordinatedGraphicsScene* m_graphicsScene;
+ OwnPtr<CompositingCoordinator> m_coordinator;
+
+ QWebFrameAdapter* m_frame;
+// OwnPtr<GraphicsLayer> m_rootGraphicsLayer;
+ Timer<CoordinatedGraphicsClientQt> m_syncTimer;
+ bool m_isWaitingForRenderer;
+// WebCore::TextureMapperLayer* m_rootTextureMapperLayer;
+// OwnPtr<WebCore::TextureMapper> m_textureMapper;
+// WebCore::TextureMapperFPSCounter m_fpsCounter;
+};
+#endif
+
+}
+
+#endif
diff --git a/Source/WebKit/qt/WebCoreSupport/CoordinatedSurfaceQt.cpp b/Source/WebKit/qt/WebCoreSupport/CoordinatedSurfaceQt.cpp
new file mode 100644
index 0000000..4e45fe5
--- /dev/null
+++ b/Source/WebKit/qt/WebCoreSupport/CoordinatedSurfaceQt.cpp
@@ -0,0 +1,168 @@
+/*
+ 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"
+#include "CoordinatedSurfaceQt.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "GraphicsContext.h"
+#include "GraphicsSurfaceToken.h"
+
+#include "ImageBuffer.h"
+
+#if USE(TEXTURE_MAPPER)
+#include "TextureMapperGL.h"
+#endif
+
+using namespace WebCore;
+
+
+PassRefPtr<CoordinatedSurfaceQt> CoordinatedSurfaceQt::create(const IntSize& size, CoordinatedSurface::Flags flags)
+{
+ RefPtr<CoordinatedSurfaceQt> surface;
+#if USE(GRAPHICS_SURFACE)
+ surface = createWithSurface(size, flags);
+#endif
+
+ if (!surface) {
+ qDebug() << Q_FUNC_INFO << "no surface";
+ surface = create(size, flags, ImageBuffer::create(size));
+ }
+
+ return surface.release();
+}
+
+#if USE(GRAPHICS_SURFACE)
+PassRefPtr<CoordinatedSurfaceQt> CoordinatedSurfaceQt::createWithSurface(const IntSize& size, CoordinatedSurface::Flags flags)
+{
+ GraphicsSurface::Flags surfaceFlags =
+ GraphicsSurface::SupportsSoftwareWrite
+ | GraphicsSurface::SupportsCopyToTexture
+ | GraphicsSurface::SupportsSharing;
+
+ if (flags & SupportsAlpha)
+ surfaceFlags |= GraphicsSurface::SupportsAlpha;
+
+ // This might return null, if the system is unable to provide a new graphics surface.
+ // In that case, this function would return null and allow falling back to ShareableBitmap.
+ RefPtr<GraphicsSurface> surface = GraphicsSurface::create(size, surfaceFlags);
+ if (!surface)
+ return 0;
+
+ ASSERT(surface);
+ return adoptRef(new CoordinatedSurfaceQt(size, flags, surface.release()));
+}
+#endif
+
+PassOwnPtr<GraphicsContext> CoordinatedSurfaceQt::createGraphicsContext(const IntRect& rect)
+{
+#if USE(GRAPHICS_SURFACE)
+ if (isBackedByGraphicsSurface())
+ return m_graphicsSurface->beginPaint(rect, 0 /* Write without retaining pixels*/);
+#endif
+
+// ASSERT(m_bitmap);
+// OwnPtr<GraphicsContext> graphicsContext = m_bitmap->createGraphicsContext();
+// graphicsContext.clip(rect);
+// graphicsContext.translate(rect.x(), rect.y());
+// return graphicsContext.release();
+ qDebug() << Q_FUNC_INFO << "no surface";
+ return 0;
+}
+
+PassRefPtr<CoordinatedSurfaceQt> CoordinatedSurfaceQt::create(const IntSize& size, CoordinatedSurface::Flags flags, PassOwnPtr<ImageBuffer> imageBuffer)
+{
+ return adoptRef(new CoordinatedSurfaceQt(size, flags, imageBuffer));
+}
+
+CoordinatedSurfaceQt::CoordinatedSurfaceQt(const IntSize& size, CoordinatedSurface::Flags flags, PassOwnPtr<ImageBuffer> imageBuffer)
+ : CoordinatedSurface(size, flags)
+ , m_imageBuffer(imageBuffer)
+{
+}
+
+#if USE(GRAPHICS_SURFACE)
+CoordinatedSurfaceQt::CoordinatedSurfaceQt(const IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<GraphicsSurface> surface)
+ : CoordinatedSurface(size, flags)
+ , m_graphicsSurface(surface)
+{
+}
+
+PassRefPtr<CoordinatedSurfaceQt> CoordinatedSurfaceQt::create(const IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<GraphicsSurface> surface)
+{
+ return adoptRef(new CoordinatedSurfaceQt(size, flags, surface));
+}
+#endif
+
+CoordinatedSurfaceQt::~CoordinatedSurfaceQt()
+{
+}
+
+void CoordinatedSurfaceQt::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
+{
+ ASSERT(client);
+ qDebug() << Q_FUNC_INFO;
+
+ // FIXME: unwrap
+ if (isBackedByGraphicsSurface()) {
+ OwnPtr<GraphicsContext> context = createGraphicsContext(rect);
+ client->paintToSurfaceContext(context.get());
+ } else {
+ GraphicsContext* context = m_imageBuffer->context();
+ context->save();
+ context->clip(rect);
+ context->translate(rect.x(), rect.y());
+
+ client->paintToSurfaceContext(context);
+
+ context->restore();
+ }
+}
+
+#if USE(TEXTURE_MAPPER)
+void CoordinatedSurfaceQt::copyToTexture(PassRefPtr<BitmapTexture> passTexture, const IntRect& target, const IntPoint& sourceOffset)
+{
+ RefPtr<BitmapTexture> texture(passTexture);
+ qDebug() << Q_FUNC_INFO;
+
+#if USE(GRAPHICS_SURFACE)
+ if (isBackedByGraphicsSurface()) {
+ RefPtr<BitmapTextureGL> textureGL = toBitmapTextureGL(texture.get());
+ if (textureGL) {
+ uint32_t textureID = textureGL->id();
+ uint32_t textureTarget = textureGL->textureTarget();
+ m_graphicsSurface->copyToGLTexture(textureTarget, textureID, target, sourceOffset);
+ return;
+ }
+
+ RefPtr<Image> image = m_graphicsSurface->createReadOnlyImage(IntRect(sourceOffset, target.size()));
+ texture->updateContents(image.get(), target, IntPoint::zero(), BitmapTexture::UpdateCanModifyOriginalImageData);
+ return;
+ }
+#endif
+
+// ASSERT(m_bitmap);
+// RefPtr<Image> image = m_bitmap->createImage();
+ RefPtr<Image> image = m_imageBuffer->copyImage(DontCopyBackingStore);
+ texture->updateContents(image.get(), target, sourceOffset, BitmapTexture::UpdateCanModifyOriginalImageData);
+}
+#endif // USE(TEXTURE_MAPPER)
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebKit/qt/WebCoreSupport/CoordinatedSurfaceQt.h b/Source/WebKit/qt/WebCoreSupport/CoordinatedSurfaceQt.h
new file mode 100644
index 0000000..5ab88ef
--- /dev/null
+++ b/Source/WebKit/qt/WebCoreSupport/CoordinatedSurfaceQt.h
@@ -0,0 +1,72 @@
+/*
+ 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.
+ */
+
+#ifndef CoordinatedSurfaceQt_h
+#define CoordinatedSurfaceQt_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include "coordinated/CoordinatedSurface.h"
+
+#if USE(GRAPHICS_SURFACE)
+#include "GraphicsSurface.h"
+#endif
+
+namespace WebCore {
+class BitmapTexture;
+class GraphicsContext;
+class ImageBuffer;
+
+class CoordinatedSurfaceQt : public CoordinatedSurface {
+public:
+ static PassRefPtr<CoordinatedSurfaceQt> create(const IntSize&, Flags);
+
+ virtual ~CoordinatedSurfaceQt();
+
+ virtual void paintToSurface(const IntRect&, CoordinatedSurface::Client*) OVERRIDE;
+
+#if USE(TEXTURE_MAPPER)
+ virtual void copyToTexture(PassRefPtr<BitmapTexture>, const IntRect& target, const IntPoint& sourceOffset) OVERRIDE;
+#endif
+
+private:
+ PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext(const IntRect&);
+ static PassRefPtr<CoordinatedSurfaceQt> create(const WebCore::IntSize&, Flags, PassOwnPtr<ImageBuffer>);
+ CoordinatedSurfaceQt(const IntSize&, Flags, PassOwnPtr<ImageBuffer>);
+
+#if USE(GRAPHICS_SURFACE)
+ CoordinatedSurfaceQt(const IntSize&, Flags, PassRefPtr<GraphicsSurface>);
+ // Create a shareable bitmap backed by a graphics surface.
+ static PassRefPtr<CoordinatedSurfaceQt> createWithSurface(const IntSize&, Flags);
+ // Create a WebCoordinatedSurface referencing an existing GraphicsSurface.
+ static PassRefPtr<CoordinatedSurfaceQt> create(const IntSize&, Flags, PassRefPtr<GraphicsSurface>);
+
+ bool isBackedByGraphicsSurface() const { return !!m_graphicsSurface; }
+#endif
+ OwnPtr<ImageBuffer> m_imageBuffer;
+
+#if USE(GRAPHICS_SURFACE)
+ RefPtr<GraphicsSurface> m_graphicsSurface;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+#endif // CoordinatedSurfaceQt_h
diff --git a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
index 5385b05..bd8ca3d 100644
--- a/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
@@ -47,7 +47,10 @@
#include "ScriptSourceCode.h"
#include "ScriptValue.h"
#include "SubstituteData.h"
-#include "TextureMapperLayerClientQt.h"
+
+#include "CoordinatedGraphicsClientQt.h"
+//#include "TextureMapperLayerClientQt.h"
+
#include "TiledBackingStore.h"
#if ENABLE(GESTURE_EVENTS)
#include "PlatformGestureEvent.h"
@@ -443,7 +446,7 @@ void QWebFrameAdapter::renderCompositedLayers(WebCore::GraphicsContext* context,
WebCore::Page* page = frame->page();
if (!page)
return;
- if (TextureMapperLayerClientQt* client = static_cast<ChromeClientQt*>(page->chrome().client())->m_textureMapperLayerClient.get())
+ if (CoordinatedGraphicsClientQt* client = static_cast<ChromeClientQt*>(page->chrome().client())->m_coordinatedGraphicsClient.get())
client->renderCompositedLayers(context, clip);
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment