summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-07-26 15:08:30 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-08-01 12:20:25 +0200
commit6bce05748e7ff25f2e487357e3fa40b5943ec664 (patch)
tree45ed8a7c030ffa0bda8a1a6d205919f4127fbeee /lib
parentdf4a06d291ce8a338c2bd83b9e7e27c67421b199 (diff)
Enable accelerated composition with QtWidgets view for testing.
Only enable it when the --force-compositing-mode switch is used. The purpose of this is only to allow testing pinch-zooming until we are able to use the delegated renderer in the QtQuick view. Change-Id: I2ca265c84c8fe6a74299f1b2757ad525f33fae17 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/quick/render_widget_host_view_qt_delegate_quick.cpp5
-rw-r--r--lib/render_widget_host_view_qt.cpp9
-rw-r--r--lib/render_widget_host_view_qt_delegate.cpp7
-rw-r--r--lib/render_widget_host_view_qt_delegate.h2
-rw-r--r--lib/widgets/render_widget_host_view_qt_delegate_widget.cpp16
5 files changed, 32 insertions, 7 deletions
diff --git a/lib/quick/render_widget_host_view_qt_delegate_quick.cpp b/lib/quick/render_widget_host_view_qt_delegate_quick.cpp
index d15bac21f..0c67f6e2f 100644
--- a/lib/quick/render_widget_host_view_qt_delegate_quick.cpp
+++ b/lib/quick/render_widget_host_view_qt_delegate_quick.cpp
@@ -83,7 +83,10 @@ bool RenderWidgetHostViewQtDelegateQuick::isVisible() const
QWindow* RenderWidgetHostViewQtDelegateQuick::window() const
{
- return QQuickPaintedItem::window();
+ // Only used to enable accelerated compositing by the compositor
+ // directly on our native window, which we want to eventually do
+ // through the delegated renderer instead.
+ return 0;
}
void RenderWidgetHostViewQtDelegateQuick::update(const QRect& rect)
diff --git a/lib/render_widget_host_view_qt.cpp b/lib/render_widget_host_view_qt.cpp
index ed648f8ec..82ec9ea83 100644
--- a/lib/render_widget_host_view_qt.cpp
+++ b/lib/render_widget_host_view_qt.cpp
@@ -181,10 +181,7 @@ gfx::NativeView RenderWidgetHostViewQt::GetNativeView() const
gfx::NativeViewId RenderWidgetHostViewQt::GetNativeViewId() const
{
- // This function is used in IPC in place of GetNativeView
- // and we can possibly avoid calls for now.
- QT_NOT_USED
- return m_delegate->window()->winId();
+ return m_delegate->window() ? m_delegate->window()->winId() : 0;
}
gfx::NativeViewAccessible RenderWidgetHostViewQt::GetNativeViewAccessible()
@@ -430,8 +427,8 @@ gfx::Rect RenderWidgetHostViewQt::GetBoundsInRootWindow()
gfx::GLSurfaceHandle RenderWidgetHostViewQt::GetCompositingSurface()
{
- QT_NOT_YET_IMPLEMENTED
- return gfx::GLSurfaceHandle();
+ gfx::NativeViewId nativeViewId = GetNativeViewId();
+ return nativeViewId ? gfx::GLSurfaceHandle(nativeViewId, gfx::NATIVE_TRANSPORT) : gfx::GLSurfaceHandle();
}
void RenderWidgetHostViewQt::SetHasHorizontalScrollbar(bool) { }
diff --git a/lib/render_widget_host_view_qt_delegate.cpp b/lib/render_widget_host_view_qt_delegate.cpp
index b6ae928bc..3c68ac968 100644
--- a/lib/render_widget_host_view_qt_delegate.cpp
+++ b/lib/render_widget_host_view_qt_delegate.cpp
@@ -44,9 +44,16 @@
#include "backing_store_qt.h"
#include "render_widget_host_view_qt.h"
+#include "base/command_line.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/public/common/content_switches.h"
#include <QPainter>
+bool RenderWidgetHostViewQtDelegate::isCompositingModeForced()
+{
+ return CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceCompositingMode);
+}
+
RenderWidgetHostViewQtDelegate::RenderWidgetHostViewQtDelegate()
: m_view(0), m_backingStore(0)
{
diff --git a/lib/render_widget_host_view_qt_delegate.h b/lib/render_widget_host_view_qt_delegate.h
index b58fefcce..f23bad376 100644
--- a/lib/render_widget_host_view_qt_delegate.h
+++ b/lib/render_widget_host_view_qt_delegate.h
@@ -68,6 +68,8 @@ public:
void resetView(RenderWidgetHostViewQt*);
protected:
+ static bool isCompositingModeForced();
+
RenderWidgetHostViewQtDelegate();
void paint(QPainter*, const QRectF& boundingRect);
void fetchBackingStore();
diff --git a/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp
index d90190edb..ee6d553c9 100644
--- a/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -41,6 +41,7 @@
#include "render_widget_host_view_qt_delegate_widget.h"
+#include <QtGlobal>
#include <QResizeEvent>
#include <QPainter>
#include <QPaintEvent>
@@ -51,6 +52,21 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(QWidg
setFocusPolicy(Qt::ClickFocus);
setAttribute(Qt::WA_AcceptTouchEvents);
setAttribute(Qt::WA_OpaquePaintEvent);
+
+#if defined(Q_OS_LINUX)
+ // FOR TESTING ONLY, use at your own risks.
+ // Supporting this properly on all platforms would require duplicating
+ // many tricks done by RenderWidgetHostView[Win|Mac].
+ if (isCompositingModeForced()) {
+ // This sets Qt::WA_NativeWindow and force a native window creation
+ // that we can give to the GPU process for it to render directly
+ // on through windowHandle().
+ winId();
+ // This makes sure that we won't try to paint the regular backing store
+ // on the window at the same time as the compositor.
+ setUpdatesEnabled(false);
+ }
+#endif
}
QRectF RenderWidgetHostViewQtDelegateWidget::screenRect() const