summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp')
-rw-r--r--Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp192
1 files changed, 71 insertions, 121 deletions
diff --git a/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp b/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
index c7ca7f116..ee05eaf41 100644
--- a/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
@@ -22,21 +22,22 @@
#if USE(ACCELERATED_COMPOSITING)
#include "LayerTreeHostProxy.h"
+#include "GraphicsLayerTextureMapper.h"
+#include "LayerBackingStore.h"
#include "LayerTreeHostMessages.h"
#include "MainThread.h"
#include "MessageID.h"
#include "ShareableBitmap.h"
#include "TextureMapper.h"
+#include "TextureMapperBackingStore.h"
+#include "TextureMapperLayer.h"
#include "UpdateInfo.h"
#include "WebCoreArgumentCoders.h"
#include "WebLayerTreeInfo.h"
#include "WebPageProxy.h"
#include "WebProcessProxy.h"
-#include "texmap/GraphicsLayerTextureMapper.h"
-#include "texmap/TextureMapper.h"
-#include "texmap/TextureMapperNode.h"
+#include <OpenGLShims.h>
#include <QDateTime>
-#include <cairo/OpenGLShims.h>
namespace WebKit {
@@ -148,16 +149,13 @@ class SetRootLayerMessage
PassOwnPtr<GraphicsLayer> LayerTreeHostProxy::createLayer(WebLayerID layerID)
{
GraphicsLayer* newLayer = new GraphicsLayerTextureMapper(this);
- TextureMapperNode* node = toTextureMapperNode(newLayer);
- node->setID(layerID);
- node->setTileOwnership(TextureMapperNode::ExternallyManagedTiles);
+ TextureMapperLayer* layer = toTextureMapperLayer(newLayer);
+ layer->setShouldUpdateBackingStoreFromLayer(false);
return adoptPtr(newLayer);
}
LayerTreeHostProxy::LayerTreeHostProxy(DrawingAreaProxy* drawingAreaProxy)
- : m_animationTimer(RunLoop::main(), this, &LayerTreeHostProxy::updateViewport)
- , m_drawingAreaProxy(drawingAreaProxy)
- , m_viewportUpdateTimer(this, &LayerTreeHostProxy::didFireViewportUpdateTimer)
+ : m_drawingAreaProxy(drawingAreaProxy)
, m_rootLayerID(0)
{
}
@@ -178,12 +176,12 @@ void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& mat
if (!currentRootLayer)
return;
- TextureMapperNode* node = toTextureMapperNode(currentRootLayer);
+ TextureMapperLayer* layer = toTextureMapperLayer(currentRootLayer);
- if (!node)
+ if (!layer)
return;
- node->setTextureMapper(m_textureMapper.get());
+ layer->setTextureMapper(m_textureMapper.get());
m_textureMapper->beginPainting();
m_textureMapper->bindSurface(0);
m_textureMapper->beginClip(TransformationMatrix(), clipRect);
@@ -194,14 +192,21 @@ void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& mat
currentRootLayer->syncCompositingStateForThisLayerOnly();
}
- node->paint();
+ layer->paint();
m_textureMapper->endClip();
m_textureMapper->endPainting();
- if (node->descendantsOrSelfHaveRunningAnimations()) {
- node->syncAnimationsRecursively();
- m_viewportUpdateTimer.startOneShot(0);
- }
+ syncAnimations();
+}
+
+void LayerTreeHostProxy::syncAnimations()
+{
+ TextureMapperLayer* layer = toTextureMapperLayer(rootLayer());
+ ASSERT(layer);
+
+ layer->syncAnimationsRecursively();
+ if (layer->descendantsOrSelfHaveRunningAnimations())
+ updateViewport();
}
void LayerTreeHostProxy::paintToGraphicsContext(QPainter* painter)
@@ -210,46 +215,32 @@ void LayerTreeHostProxy::paintToGraphicsContext(QPainter* painter)
m_textureMapper = TextureMapper::create();
ASSERT(m_textureMapper->accelerationMode() == TextureMapper::SoftwareMode);
syncRemoteContent();
- TextureMapperNode* node = toTextureMapperNode(rootLayer());
+ TextureMapperLayer* layer = toTextureMapperLayer(rootLayer());
- if (!node)
+ if (!layer)
return;
GraphicsContext graphicsContext(painter);
m_textureMapper->setGraphicsContext(&graphicsContext);
m_textureMapper->beginPainting();
m_textureMapper->bindSurface(0);
- node->paint();
+ layer->paint();
m_textureMapper->endPainting();
m_textureMapper->setGraphicsContext(0);
}
-
-void LayerTreeHostProxy::didFireViewportUpdateTimer(Timer<LayerTreeHostProxy>*)
-{
- updateViewport();
-}
-
void LayerTreeHostProxy::updateViewport()
{
m_drawingAreaProxy->updateViewport();
}
-int LayerTreeHostProxy::remoteTileIDToNodeTileID(int tileID) const
-{
- HashMap<int, int>::const_iterator it = m_tileToNodeTile.find(tileID);
- if (it == m_tileToNodeTile.end())
- return 0;
- return it->second;
-}
-
void LayerTreeHostProxy::syncLayerParameters(const WebLayerInfo& layerInfo)
{
WebLayerID id = layerInfo.id;
ensureLayer(id);
LayerMap::iterator it = m_layers.find(id);
GraphicsLayer* layer = it->second;
- bool needsToUpdateImageTiles = layerInfo.imageIsUpdated || layerInfo.contentsRect != layer->contentsRect();
+ bool needsToUpdateImageTiles = layerInfo.imageIsUpdated || (layerInfo.contentsRect != layer->contentsRect() && layerInfo.imageBackingStoreID);
layer->setName(layerInfo.name);
@@ -348,69 +339,41 @@ void LayerTreeHostProxy::setRootLayerID(WebLayerID layerID)
m_rootLayer->addChild(layer);
}
-void LayerTreeHostProxy::createTile(WebLayerID layerID, int tileID, float scale)
+PassRefPtr<LayerBackingStore> LayerTreeHostProxy::getBackingStore(WebLayerID id)
{
- ensureLayer(layerID);
- TextureMapperNode* node = toTextureMapperNode(layerByID(layerID));
+ ensureLayer(id);
+ TextureMapperLayer* layer = toTextureMapperLayer(layerByID(id));
+ RefPtr<LayerBackingStore> backingStore = static_cast<LayerBackingStore*>(layer->backingStore().get());
+ if (!backingStore) {
+ backingStore = LayerBackingStore::create();
+ layer->setBackingStore(backingStore.get());
+ }
+ ASSERT(backingStore);
+ return backingStore;
+}
- int nodeTileID = node->createContentsTile(scale);
- m_tileToNodeTile.add(tileID, nodeTileID);
+void LayerTreeHostProxy::createTile(WebLayerID layerID, int tileID, float scale)
+{
+ getBackingStore(layerID)->createTile(tileID, scale);
}
void LayerTreeHostProxy::removeTile(WebLayerID layerID, int tileID)
{
- TextureMapperNode* node = toTextureMapperNode(layerByID(layerID));
- if (!node)
- return;
-
- int nodeTileID = remoteTileIDToNodeTileID(tileID);
- if (!nodeTileID)
- return;
-
- node->removeContentsTile(nodeTileID);
- m_tileToNodeTile.remove(tileID);
+ getBackingStore(layerID)->removeTile(tileID);
}
void LayerTreeHostProxy::updateTile(WebLayerID layerID, int tileID, const IntRect& sourceRect, const IntRect& targetRect, ShareableBitmap* bitmap)
{
- ensureLayer(layerID);
- TextureMapperNode* node = toTextureMapperNode(layerByID(layerID));
- if (!node)
- return;
-
- int nodeTileID = remoteTileIDToNodeTileID(tileID);
- if (!nodeTileID)
- return;
-
- node->setTextureMapper(m_textureMapper.get());
- QImage image = bitmap->createQImage();
- node->setContentsTileBackBuffer(nodeTileID, sourceRect, targetRect, image.constBits());
+ RefPtr<LayerBackingStore> backingStore = getBackingStore(layerID);
+ backingStore->updateTile(tileID, sourceRect, targetRect, bitmap);
+ m_backingStoresWithPendingBuffers.add(backingStore);
}
void LayerTreeHostProxy::createImage(int64_t imageID, ShareableBitmap* bitmap)
{
- TiledImage tiledImage;
- static const int TileDimension = 1024;
- QImage image = bitmap->createQImage();
- bool imageHasAlpha = image.hasAlphaChannel();
- IntRect imageRect(0, 0, image.width(), image.height());
- for (int y = 0; y < image.height(); y += TileDimension) {
- for (int x = 0; x < image.width(); x += TileDimension) {
- QImage subImage;
- IntRect rect(x, y, TileDimension, TileDimension);
- rect.intersect(imageRect);
- if (QSize(rect.size()) == image.size())
- subImage = image;
- else
- subImage = image.copy(rect);
- RefPtr<BitmapTexture> texture = m_textureMapper->createTexture();
- texture->reset(rect.size(), !imageHasAlpha);
- texture->updateContents(subImage.constBits(), IntRect(IntPoint::zero(), rect.size()));
- tiledImage.add(rect.location(), texture);
- }
- }
-
- m_directlyCompositedImages.set(imageID, tiledImage);
+ RefPtr<TextureMapperTiledBackingStore> backingStore = TextureMapperTiledBackingStore::create();
+ backingStore->updateContents(m_textureMapper.get(), bitmap->createImage().get(), BitmapTexture::BGRAFormat);
+ m_directlyCompositedImages.set(imageID, backingStore);
}
void LayerTreeHostProxy::destroyImage(int64_t imageID)
@@ -420,38 +383,25 @@ void LayerTreeHostProxy::destroyImage(int64_t imageID)
void LayerTreeHostProxy::assignImageToLayer(GraphicsLayer* layer, int64_t imageID)
{
- TextureMapperNode* node = toTextureMapperNode(layer);
- if (!node)
- return;
-
- if (!imageID) {
- node->clearAllDirectlyCompositedImageTiles();
- return;
- }
+ HashMap<int64_t, RefPtr<TextureMapperBackingStore> >::iterator it = m_directlyCompositedImages.find(imageID);
+ ASSERT(it != m_directlyCompositedImages.end());
+ layer->setContentsToMedia(it->second.get());
+}
- FloatSize size(layer->size());
- FloatRect contentsRect(layer->contentsRect());
- float horizontalFactor = contentsRect.width() / size.width();
- float verticalFactor = contentsRect.height() / size.height();
- HashMap<int64_t, TiledImage>::iterator it = m_directlyCompositedImages.find(imageID);
- if (it == m_directlyCompositedImages.end())
- return;
+void LayerTreeHostProxy::swapBuffers()
+{
+ HashSet<RefPtr<LayerBackingStore> >::iterator end = m_backingStoresWithPendingBuffers.end();
+ for (HashSet<RefPtr<LayerBackingStore> >::iterator it = m_backingStoresWithPendingBuffers.begin(); it != end; ++it)
+ (*it)->swapBuffers(m_textureMapper.get());
- TiledImage::iterator endTileIterator = it->second.end();
- for (TiledImage::iterator tileIt = it->second.begin(); tileIt != endTileIterator; ++tileIt) {
- FloatRect sourceRect(FloatPoint(tileIt->first), FloatSize(tileIt->second->size()));
- FloatRect targetRect(sourceRect.x() * horizontalFactor + contentsRect.x(),
- sourceRect.y() * verticalFactor + contentsRect.y(),
- sourceRect.width() * horizontalFactor,
- sourceRect.height() * verticalFactor);
- int newTileID = node->createContentsTile(1.0);
- node->setTileBackBufferTextureForDirectlyCompositedImage(newTileID, IntRect(sourceRect), targetRect, tileIt->second.get());
- }
+ m_backingStoresWithPendingBuffers.clear();
}
void LayerTreeHostProxy::flushLayerChanges()
{
m_rootLayer->syncCompositingState(FloatRect());
+ swapBuffers();
+
// The pending tiles state is on its way for the screen, tell the web process to render the next one.
m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
}
@@ -469,7 +419,7 @@ void LayerTreeHostProxy::ensureRootLayer()
m_rootLayer->setSize(FloatSize(1.0, 1.0));
if (!m_textureMapper)
m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);
- toTextureMapperNode(m_rootLayer.get())->setTextureMapper(m_textureMapper.get());
+ toTextureMapperLayer(m_rootLayer.get())->setTextureMapper(m_textureMapper.get());
}
void LayerTreeHostProxy::syncRemoteContent()
@@ -556,7 +506,8 @@ void LayerTreeHostProxy::updateTileForLayer(int layerID, int tileID, const WebKi
data.layerID = layerID;
data.remoteTileID = tileID;
data.bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
- data.sourceRect = IntRect(IntPoint::zero(), updateInfo.updateRectBounds.size());
+ ASSERT(updateInfo.updateRects.size() == 1);
+ data.sourceRect = updateInfo.updateRects.first();
data.targetRect = updateInfo.updateRectBounds;
pushUpdateToQueue(UpdateTileMessage::create(data));
}
@@ -612,29 +563,28 @@ void LayerTreeHostProxy::destroyDirectlyCompositedImage(int64_t key)
pushUpdateToQueue(DestroyImageMessage::create(data));
}
-void LayerTreeHostProxy::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
+void LayerTreeHostProxy::setVisibleContentsRectForPanning(const IntRect& rect, const FloatPoint& trajectoryVector)
{
- m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectTrajectoryVector(trajectoryVector), m_drawingAreaProxy->page()->pageID());
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentsRectForPanning(rect, trajectoryVector), m_drawingAreaProxy->page()->pageID());
}
-void LayerTreeHostProxy::setVisibleContentsRectAndScale(const IntRect& rect, float scale)
+void LayerTreeHostProxy::setVisibleContentsRectForScaling(const IntRect& rect, float scale)
{
m_visibleContentsRect = rect;
m_contentsScale = scale;
- m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectAndScale(rect, scale), m_drawingAreaProxy->page()->pageID());
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentsRectForScaling(rect, scale), m_drawingAreaProxy->page()->pageID());
}
void LayerTreeHostProxy::purgeGLResources()
{
- TextureMapperNode* node = toTextureMapperNode(rootLayer());
+ TextureMapperLayer* layer = toTextureMapperLayer(rootLayer());
- if (node)
- node->purgeNodeTexturesRecursive();
+ if (layer)
+ layer->clearBackingStoresRecursive();
m_directlyCompositedImages.clear();
-
m_textureMapper.clear();
-
+ m_backingStoresWithPendingBuffers.clear();
m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
}