Skip to content

Instantly share code, notes, and snippets.

@kenchris
Created March 16, 2012 12:27
Show Gist options
  • Save kenchris/2049868 to your computer and use it in GitHub Desktop.
Save kenchris/2049868 to your computer and use it in GitHub Desktop.
diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.cpp b/Source/WebCore/platform/graphics/TiledBackingStore.cpp
index 9bd424c..940b45e 100644
--- a/Source/WebCore/platform/graphics/TiledBackingStore.cpp
+++ b/Source/WebCore/platform/graphics/TiledBackingStore.cpp
@@ -69,10 +69,14 @@ void TiledBackingStore::setTileCreationDelay(double delay)
void TiledBackingStore::coverWithTilesIfNeeded(const FloatPoint& trajectoryVector)
{
IntRect visibleRect = this->visibleRect();
- if (m_trajectoryVector == trajectoryVector && m_visibleRect == visibleRect)
+
+ FloatPoint normalizedVector = trajectoryVector;
+ normalizedVector.normalize();
+
+ if (m_trajectoryVector == normalizedVector && m_visibleRect == visibleRect)
return;
- m_trajectoryVector = trajectoryVector;
+ m_trajectoryVector = normalizedVector;
m_visibleRect = visibleRect;
startBackingStoreUpdateTimer();
@@ -340,8 +344,7 @@ void TiledBackingStore::computeCoverAndKeepRect(const IntRect& visibleRect, IntR
coverRect.inflateY(visibleRect.height() * (m_coverAreaMultiplier - 1) / 2);
keepRect = coverRect;
- float trajectoryVectorNorm = sqrt(pow(m_trajectoryVector.x(), 2) + pow(m_trajectoryVector.y(), 2));
- if (trajectoryVectorNorm) {
+ if (m_trajectoryVector == FloatPoint::zero()) {
// A null trajectory vector (no motion) means that tiles for the coverArea will be created.
// A non-null trajectory vector will shrink the covered rect to visibleRect plus its expansion from its
// center toward the cover area edges in the direction of the given vector.
@@ -356,8 +359,8 @@ void TiledBackingStore::computeCoverAndKeepRect(const IntRect& visibleRect, IntR
// Unite the visible rect with a "ghost" of the visible rect moved in the direction of the trajectory vector.
coverRect = visibleRect;
- coverRect.move(coverRect.width() * m_trajectoryVector.x() / trajectoryVectorNorm * trajectoryVectorMultiplier,
- coverRect.height() * m_trajectoryVector.y() / trajectoryVectorNorm * trajectoryVectorMultiplier);
+ coverRect.move(coverRect.width() * m_trajectoryVector.x() * trajectoryVectorMultiplier,
+ coverRect.height() * m_trajectoryVector.y() * trajectoryVectorMultiplier);
coverRect.unite(visibleRect);
}
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
index ee1abf4..6391e49 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -506,7 +506,7 @@ void QQuickWebViewLegacyPrivate::updateViewportSize()
// The fixed layout is handled by the FrameView and the drawing area doesn't behave differently
// whether its fixed or not. We still need to tell the drawing area which part of it
// has to be rendered on tiles, and in desktop mode it's all of it.
- webPageProxy->drawingArea()->setVisibleContentsRectForScaling(IntRect(IntPoint(), viewportSize), 1);
+ webPageProxy->drawingArea()->setVisibleContentsRect(IntRect(IntPoint(), viewportSize), 1, FloatPoint());
}
QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* viewport)
@@ -657,7 +657,7 @@ void QQuickWebViewFlickablePrivate::_q_commitScaleChange()
const QRect visibleRect(visibleContentsRect());
float scale = pageView->contentsScale();
- drawingArea->setVisibleContentsRectForScaling(visibleRect, scale);
+ drawingArea->setVisibleContentsRect(visibleRect, scale, FloatPoint());
webPageProxy->setFixedVisibleContentRect(visibleRect);
}
@@ -668,11 +668,9 @@ void QQuickWebViewPrivate::_q_commitPositionChange(const QPointF& trajectoryVect
return;
const QRect visibleRect(visibleContentsRect());
- drawingArea->setVisibleContentsRectForPanning(visibleRect, trajectoryVector);
-
- if (!trajectoryVector.isNull())
- return;
+ float scale = pageView->contentsScale();
+ drawingArea->setVisibleContentsRect(visibleRect, scale, trajectoryVector);
webPageProxy->setFixedVisibleContentRect(visibleRect);
}
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.h b/Source/WebKit2/UIProcess/DrawingAreaProxy.h
index 8b8dc2b..8f7930c 100644
--- a/Source/WebKit2/UIProcess/DrawingAreaProxy.h
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.h
@@ -93,8 +93,7 @@ public:
virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&) { }
virtual void paintLayerTree(BackingStore::PlatformGraphicsContext) { }
LayerTreeHostProxy* layerTreeHostProxy() const { return m_layerTreeHostProxy.get(); }
- virtual void setVisibleContentsRectForScaling(const WebCore::IntRect& visibleContentsRect, float scale) { }
- virtual void setVisibleContentsRectForPanning(const WebCore::IntRect& visibleContentsRect, const WebCore::FloatPoint& trajectoryVector) { }
+ virtual void setVisibleContentsRect(const WebCore::IntRect& visibleContentsRect, float scale, const WebCore::FloatPoint& trajectoryVector) { }
virtual void createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&) { }
virtual void updateTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&) { }
virtual void removeTileForLayer(int layerID, int tileID) { }
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
index c0d044b..6edf4ab 100644
--- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
@@ -348,16 +348,10 @@ void DrawingAreaProxyImpl::didReceiveLayerTreeHostProxyMessage(CoreIPC::Connecti
m_layerTreeHostProxy->didReceiveLayerTreeHostProxyMessage(connection, messageID, arguments);
}
-void DrawingAreaProxyImpl::setVisibleContentsRectForScaling(const WebCore::IntRect& visibleContentsRect, float scale)
+void DrawingAreaProxyImpl::setVisibleContentsRect(const WebCore::IntRect& visibleContentsRect, float scale, const WebCore::FloatPoint& trajectoryVector)
{
if (m_layerTreeHostProxy)
- m_layerTreeHostProxy->setVisibleContentsRectForScaling(visibleContentsRect, scale);
-}
-
-void DrawingAreaProxyImpl::setVisibleContentsRectForPanning(const WebCore::IntRect& visibleContentsRect, const WebCore::FloatPoint& trajectoryVector)
-{
- if (m_layerTreeHostProxy)
- m_layerTreeHostProxy->setVisibleContentsRectForPanning(visibleContentsRect, trajectoryVector);
+ m_layerTreeHostProxy->setVisibleContentsRect(visibleContentsRect, scale, trajectoryVector);
}
void DrawingAreaProxyImpl::paintLayerTree(BackingStore::PlatformGraphicsContext context)
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
index 613073b..2d57417 100644
--- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
@@ -78,8 +78,7 @@ private:
bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
#if USE(UI_SIDE_COMPOSITING)
- virtual void setVisibleContentsRectForScaling(const WebCore::IntRect& visibleContentsRect, float scale);
- virtual void setVisibleContentsRectForPanning(const WebCore::IntRect& visibleContentsRect, const WebCore::FloatPoint&);
+ virtual void setVisibleContentsRect(const WebCore::IntRect& visibleContentsRect, float scale, const WebCore::FloatPoint& trajectory);
virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity, const WebCore::FloatRect&);
virtual void paintLayerTree(BackingStore::PlatformGraphicsContext);
void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
diff --git a/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp b/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp
index e760a7d..004c951 100644
--- a/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp
+++ b/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp
@@ -118,15 +118,10 @@ void LayerTreeHostProxy::destroyDirectlyCompositedImage(int64_t key)
dispatchUpdate(bind(&WebLayerTreeRenderer::destroyImage, m_renderer.get(), key));
}
-void LayerTreeHostProxy::setVisibleContentsRectForPanning(const IntRect& rect, const FloatPoint& trajectoryVector)
+void LayerTreeHostProxy::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector)
{
- m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentsRectForPanning(rect, trajectoryVector), m_drawingAreaProxy->page()->pageID());
-}
-
-void LayerTreeHostProxy::setVisibleContentsRectForScaling(const IntRect& rect, float scale)
-{
- m_renderer->setVisibleContentsRectForScaling(rect, scale);
- m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentsRectForScaling(rect, scale), m_drawingAreaProxy->page()->pageID());
+ m_renderer->setVisibleContentsRect(rect, scale);
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentsRect(rect, scale, trajectoryVector), m_drawingAreaProxy->page()->pageID());
}
void LayerTreeHostProxy::renderNextFrame()
diff --git a/Source/WebKit2/UIProcess/LayerTreeHostProxy.h b/Source/WebKit2/UIProcess/LayerTreeHostProxy.h
index f6c31d1..2587c1f 100644
--- a/Source/WebKit2/UIProcess/LayerTreeHostProxy.h
+++ b/Source/WebKit2/UIProcess/LayerTreeHostProxy.h
@@ -54,8 +54,7 @@ public:
void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity, const WebCore::FloatRect& clip);
void paintToGraphicsContext(BackingStore::PlatformGraphicsContext);
void purgeGLResources();
- void setVisibleContentsRectForScaling(const WebCore::IntRect&, float);
- void setVisibleContentsRectForPanning(const WebCore::IntRect&, const WebCore::FloatPoint&);
+ void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint& trajectory);
void didRenderFrame();
void createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&);
void updateTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&);
diff --git a/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp b/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp
index f2c0495..20229f3 100644
--- a/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp
+++ b/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp
@@ -155,7 +155,7 @@ void WebLayerTreeRenderer::paintToGraphicsContext(QPainter* painter)
m_textureMapper->setGraphicsContext(0);
}
-void WebLayerTreeRenderer::setVisibleContentsRectForScaling(const IntRect& rect, float scale)
+void WebLayerTreeRenderer::setVisibleContentsRect(const IntRect& rect, float scale)
{
m_visibleContentsRect = rect;
m_contentsScale = scale;
diff --git a/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h b/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h
index 6c78865..f258489 100644
--- a/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h
+++ b/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h
@@ -51,7 +51,7 @@ public:
void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&);
void paintToGraphicsContext(BackingStore::PlatformGraphicsContext);
void syncRemoteContent();
- void setVisibleContentsRectForScaling(const WebCore::IntRect&, float);
+ void setVisibleContentsRect(const WebCore::IntRect&, float scale);
void detach();
void appendUpdate(const Function<void()>&);
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
index 6f336a5..0349e24 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
@@ -80,8 +80,7 @@ public:
virtual void resumeRendering() { }
#if USE(TILED_BACKING_STORE)
- virtual void setVisibleContentsRectForScaling(const WebCore::IntRect&, float scale) { }
- virtual void setVisibleContentsRectForPanning(const WebCore::IntRect&, const WebCore::FloatPoint&) { }
+ virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&) { }
virtual void setVisibleContentsRectForLayer(int layerID, const WebCore::IntRect&) { }
virtual void renderNextFrame() { }
virtual void purgeBackingStores() { }
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in
index 70fa858..8920de2 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in
@@ -20,8 +20,7 @@
#if USE(TILED_BACKING_STORE)
messages -> LayerTreeHost {
- SetVisibleContentsRectForPanning(WebCore::IntRect visibleContentsRect, WebCore::FloatPoint trajectoryVectory)
- SetVisibleContentsRectForScaling(WebCore::IntRect visibleContentsRect, float scale)
+ SetVisibleContentsRect(WebCore::IntRect visibleContentsRect, float scale, WebCore::FloatPoint trajectoryVectory)
RenderNextFrame()
PurgeBackingStores()
}
diff --git a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
index 2137430..468a5e5 100644
--- a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
@@ -415,24 +415,26 @@ WebCore::IntRect LayerTreeHostQt::visibleContentsRect() const
return m_visibleContentsRect;
}
-void LayerTreeHostQt::setVisibleContentsRectForScaling(const IntRect& rect, float scale)
+void LayerTreeHostQt::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector)
{
- m_visibleContentsRect = rect;
- m_contentsScale = scale;
+ bool contentsRectDidChange = rect != m_visibleContentsRect;
+ bool contentsScaleDidChange = scale != m_contentsScale;
- HashSet<WebCore::WebGraphicsLayer*>::iterator end = m_registeredLayers.end();
- for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) {
- (*it)->setContentsScale(scale);
- (*it)->adjustVisibleRect();
- }
- scheduleLayerFlush();
-}
+ if (trajectoryVector != FloatPoint::zero())
+ toWebGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
-void LayerTreeHostQt::setVisibleContentsRectForPanning(const IntRect& rect, const FloatPoint& trajectoryVector)
-{
- m_visibleContentsRect = rect;
+ if (contentsRectDidChange || contentsScaleDidChange) {
+ m_visibleContentsRect = rect;
+ m_contentsScale = scale;
- toWebGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
+ HashSet<WebCore::WebGraphicsLayer*>::iterator end = m_registeredLayers.end();
+ for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) {
+ if (contentsScaleDidChange)
+ (*it)->setContentsScale(scale);
+ if (contentsRectDidChange)
+ (*it)->adjustVisibleRect();
+ }
+ }
scheduleLayerFlush();
}
diff --git a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
index 9db85b7..08f0e64 100644
--- a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
+++ b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
@@ -70,8 +70,7 @@ public:
virtual void renderNextFrame();
virtual void purgeBackingStores();
virtual bool layerTreeTileUpdatesAllowed() const;
- virtual void setVisibleContentsRectForScaling(const WebCore::IntRect&, float scale);
- virtual void setVisibleContentsRectForPanning(const WebCore::IntRect&, const WebCore::FloatPoint&);
+ virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&);
virtual void didSyncCompositingStateForLayer(const WebLayerInfo&);
virtual void attachLayer(WebCore::WebGraphicsLayer*);
virtual void detachLayer(WebCore::WebGraphicsLayer*);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment