summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/qt
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2012-12-13 20:15:30 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2012-12-13 22:07:16 +0100
commit69e9b8736f2410fc33db62b432cf5210b50331e9 (patch)
tree5d5a85c871cad42f8b95361ccb1c119371afc277 /Source/WebKit2/UIProcess/qt
parent5423dd08373bb58f0d469d52cde49f128b49ddf2 (diff)
downloadqtwebkit-69e9b8736f2410fc33db62b432cf5210b50331e9.tar.gz
[Qt][WK2] Fix painting on Mac with retina display
https://bugs.webkit.org/show_bug.cgi?id=104574 Reviewed by Kenneth Rohde Christiansen. Since HiDPI support has been added and enabled in Qt we ended up painting incorrectly scaled content on high-resolution screens. Because the intrinsic device pixel ratio is always taken into account by Qt when painting to high-resolution screens we should automatically obtain the scale ratio from the window in which the item is rendered instead of setting it in QML. Qt does not make it possible to override the device pixel ratio of the native window, therefore our experimental QML API for setting a custom value is of no use any more and should be removed. This patch fixes the scaling issue on Mac retina display by querying the underlying window for the device scale factor and applying it to the backing store and the scene-graph rendering of the content node. Additionally removes the experimental API and related API tests. Change-Id: I04f23059147773ca279a89ae8976ccd3d9bef292 git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137597 268f45cc-cd09-0410-ab3c-d52691b4dbfc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'Source/WebKit2/UIProcess/qt')
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp31
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h5
2 files changed, 33 insertions, 3 deletions
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp
index eb7023990..d72980c05 100644
--- a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp
@@ -23,7 +23,10 @@
#include "LayerTreeRenderer.h"
#include <QtGui/QPolygonF>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickWindow>
#include <QtQuick/QSGSimpleRectNode>
+#include <WebCore/TransformationMatrix.h>
#include <private/qsgrendernode_p.h>
using namespace WebCore;
@@ -45,7 +48,13 @@ public:
virtual void render(const RenderState& state)
{
- QMatrix4x4 renderMatrix = matrix() ? *matrix() : QMatrix4x4();
+ TransformationMatrix renderMatrix;
+ if (pageNode()->devicePixelRatio() != 1.0) {
+ renderMatrix.scale(pageNode()->devicePixelRatio());
+ if (matrix())
+ renderMatrix.multiply(*matrix());
+ } else if (matrix())
+ renderMatrix = *matrix();
// When rendering to an intermediate surface, Qt will
// mirror the projection matrix to fit on the destination coordinate system.
@@ -61,6 +70,13 @@ public:
layerTreeRenderer()->purgeGLResources();
}
+ const QtWebPageSGNode* pageNode() const
+ {
+ const QtWebPageSGNode* parent = static_cast<QtWebPageSGNode*>(this->parent());
+ ASSERT(parent);
+ return parent;
+ }
+
LayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); }
private:
@@ -73,6 +89,8 @@ private:
QMatrix4x4 clipMatrix;
if (clip->matrix())
clipMatrix = *clip->matrix();
+ clipMatrix.scale(pageNode()->devicePixelRatio());
+
QRectF currentClip;
if (clip->isRectangular())
@@ -108,9 +126,10 @@ private:
RefPtr<LayerTreeRenderer> m_renderer;
};
-QtWebPageSGNode::QtWebPageSGNode()
+QtWebPageSGNode::QtWebPageSGNode(const QQuickItem* item)
: m_contentsNode(0)
, m_backgroundNode(new QSGSimpleRectNode)
+ , m_item(item)
{
appendChildNode(m_backgroundNode);
}
@@ -128,6 +147,13 @@ void QtWebPageSGNode::setScale(float scale)
setMatrix(matrix);
}
+qreal QtWebPageSGNode::devicePixelRatio() const
+{
+ if (const QWindow* window = m_item->window())
+ return window->devicePixelRatio();
+ return 1;
+}
+
void QtWebPageSGNode::setRenderer(PassRefPtr<LayerTreeRenderer> renderer)
{
if (m_contentsNode && m_contentsNode->layerTreeRenderer() == renderer)
@@ -135,6 +161,7 @@ void QtWebPageSGNode::setRenderer(PassRefPtr<LayerTreeRenderer> renderer)
delete m_contentsNode;
m_contentsNode = new ContentsSGNode(renderer);
+ // This sets the parent node of the content to QtWebPageSGNode.
appendChildNode(m_contentsNode);
}
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h
index 11d18984e..368df704a 100644
--- a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h
@@ -25,6 +25,7 @@
#include <wtf/PassRefPtr.h>
QT_BEGIN_NAMESPACE
+class QQuickItem;
class QSGSimpleRectNode;
QT_END_NAMESPACE
@@ -35,14 +36,16 @@ class LayerTreeRenderer;
class QtWebPageSGNode : public QSGTransformNode {
public:
- QtWebPageSGNode();
+ QtWebPageSGNode(const QQuickItem*);
void setBackground(const QRectF&, const QColor&);
void setScale(float);
void setRenderer(PassRefPtr<LayerTreeRenderer>);
+ qreal devicePixelRatio() const;
private:
ContentsSGNode* m_contentsNode;
QSGSimpleRectNode* m_backgroundNode;
+ const QQuickItem* const m_item;
};
} // namespace WebKit