[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin.spec
^
|
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer.pro
^
|
@@ -27,7 +27,6 @@
SOURCES += hwcomposer_backend_v11.cpp
HEADERS += hwcomposer_backend_v11.h
-
QT += core-private compositor-private gui-private platformsupport-private dbus
DEFINES += QEGL_EXTRA_DEBUG
@@ -50,6 +49,13 @@
DEFINES += HWC_PLUGIN_HAVE_HWCOMPOSER1_API
}
+exists(/usr/lib/droid-devel/droid-headers/hardware/hwcomposer2.h) {
+ PKGCONFIG += libhwc2
+ DEFINES += HWC_PLUGIN_HAVE_HWCOMPOSER2_API
+ SOURCES += hwcomposer_backend_v20.cpp
+ HEADERS += hwcomposer_backend_v20.h
+}
+
# Avoid X11 header collision
DEFINES += MESA_EGL_NO_X11_HEADERS
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend.cpp
^
|
@@ -39,21 +39,34 @@
**
****************************************************************************/
+#include <dlfcn.h>
+
#include "hwcomposer_backend.h"
#ifdef HWC_DEVICE_API_VERSION_0_1
#include "hwcomposer_backend_v0.h"
#endif
#include "hwcomposer_backend_v10.h"
#include "hwcomposer_backend_v11.h"
+#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER2_API
+#include "hwcomposer_backend_v20.h"
+#endif
-HwComposerBackend::HwComposerBackend(hw_module_t *hwc_module)
- : hwc_module(hwc_module)
+extern "C" void *android_dlopen(const char *filename, int flags);
+extern "C" void *android_dlsym(void *handle, const char *symbol);
+extern "C" int android_dlclose(void *handle);
+
+HwComposerBackend::HwComposerBackend(hw_module_t *hwc_module, void *libmsf)
+ : hwc_module(hwc_module), libminisf(libmsf)
{
}
HwComposerBackend::~HwComposerBackend()
{
+ if (libminisf) {
+ android_dlclose(libminisf);
+ }
+
// XXX: Close/free hwc_module?
}
@@ -62,6 +75,8 @@
{
hw_module_t *hwc_module = NULL;
hw_device_t *hwc_device = NULL;
+ void *libminisf;
+ void (*startMiniSurfaceFlinger)(void) = NULL;
// Some implementations insist on having the framebuffer module opened before loading
// the hardware composer one. Therefor we rely on using the fbdev HYBRIS_EGLPLATFORM
@@ -70,6 +85,24 @@
eglGetDisplay(EGL_DEFAULT_DISPLAY);
}
+ // A reason for calling this method here is to initialize the binder
+ // thread pool such that services started from for example the
+ // hwcomposer plugin don't get stuck.
+ // Another is to have the SurfaceFlinger service in the same process
+ // as hwcomposer, on some devices this could improve performance.
+
+ libminisf = android_dlopen("libminisf.so", RTLD_LAZY);
+
+ if (libminisf) {
+ startMiniSurfaceFlinger = (void(*)(void))android_dlsym(libminisf, "startMiniSurfaceFlinger");
+ }
+
+ if (startMiniSurfaceFlinger) {
+ startMiniSurfaceFlinger();
+ } else {
+ fprintf(stderr, "libminisf is incompatible or missing. Can not possibly start the SurfaceFlinger service. If you're experiencing troubles with media try updating droidmedia (and/or this plugin).");
+ }
+
// Open hardware composer
HWC_PLUGIN_ASSERT_ZERO(hw_get_module(HWC_HARDWARE_MODULE_ID, (const hw_module_t **)(&hwc_module)));
@@ -99,7 +132,7 @@
if ((hwc_device->version == HWC_DEVICE_API_VERSION_0_1) ||
(hwc_device->version == HWC_DEVICE_API_VERSION_0_2) ||
(hwc_device->version == HWC_DEVICE_API_VERSION_0_3)) {
- return new HwComposerBackend_v0(hwc_module, hwc_device);
+ return new HwComposerBackend_v0(hwc_module, hwc_device, libminisf);
}
#endif
@@ -109,12 +142,12 @@
case HWC_DEVICE_API_VERSION_0_1:
case HWC_DEVICE_API_VERSION_0_2:
case HWC_DEVICE_API_VERSION_0_3:
- return new HwComposerBackend_v0(hwc_module, hwc_device);
+ return new HwComposerBackend_v0(hwc_module, hwc_device, libminisf);
break;
#endif
#ifdef HWC_DEVICE_API_VERSION_1_0
case HWC_DEVICE_API_VERSION_1_0:
- return new HwComposerBackend_v10(hwc_module, hwc_device);
+ return new HwComposerBackend_v10(hwc_module, hwc_device, libminisf);
break;
#endif /* HWC_DEVICE_API_VERSION_1_0 */
#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER1_API
@@ -133,9 +166,14 @@
#endif
// HWC_NUM_DISPLAY_TYPES is the actual size of the array, otherwise
// underrun/overruns happen
- return new HwComposerBackend_v11(hwc_module, hwc_device, HWC_NUM_DISPLAY_TYPES);
+ return new HwComposerBackend_v11(hwc_module, hwc_device, libminisf, HWC_NUM_DISPLAY_TYPES);
break;
#endif /* HWC_PLUGIN_HAVE_HWCOMPOSER1_API */
+#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER2_API
+ case HWC_DEVICE_API_VERSION_2_0:
+ return new HwComposerBackend_v20(hwc_module, libminisf);
+ break;
+#endif
default:
fprintf(stderr, "Unknown hwcomposer API: 0x%x/0x%x/0x%x\n",
hwc_module->module_api_version,
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend.h
^
|
@@ -109,13 +109,16 @@
virtual void sleepDisplay(bool sleep) = 0;
virtual float refreshRate() = 0;
+ virtual bool getScreenSizes(int *width, int *height, float *physical_width, float *physical_height) = 0;
+
virtual bool requestUpdate(QEglFSWindow *) { return false; }
protected:
- HwComposerBackend(hw_module_t *hwc_module);
+ HwComposerBackend(hw_module_t *hwc_module, void *libmsf);
virtual ~HwComposerBackend();
hw_module_t *hwc_module;
+ void *libminisf;
};
#endif /* HWCOMPOSER_BACKEND_H */
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend_v0.cpp
^
|
@@ -44,8 +44,8 @@
#ifdef HWC_DEVICE_API_VERSION_0_1
-HwComposerBackend_v0::HwComposerBackend_v0(hw_module_t *hwc_module, hw_device_t *hw_device)
- : HwComposerBackend(hwc_module)
+HwComposerBackend_v0::HwComposerBackend_v0(hw_module_t *hwc_module, hw_device_t *hw_device, void *libminisf)
+ : HwComposerBackend(hwc_module, libminisf)
, hwc_device((hwc_composer_device_t *)hw_device)
, hwc_layer_list(NULL)
{
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend_v0.h
^
|
@@ -47,7 +47,7 @@
class HwComposerBackend_v0 : public HwComposerBackend {
public:
- HwComposerBackend_v0(hw_module_t *hwc_module, hw_device_t *hw_device);
+ HwComposerBackend_v0(hw_module_t *hwc_module, hw_device_t *hw_device, void *libminisf);
virtual ~HwComposerBackend_v0();
virtual EGLNativeDisplayType display();
@@ -56,6 +56,15 @@
virtual void swap(EGLNativeDisplayType display, EGLSurface surface);
virtual void sleepDisplay(bool sleep);
virtual float refreshRate();
+ virtual bool getScreenSizes(int *width, int *height, float *physical_width, float *physical_height)
+ {
+ *width = 0;
+ *height = 0;
+ *physical_width = 0;
+ *physical_height = 0;
+ // N/A
+ return false;
+ }
private:
hwc_composer_device_t *hwc_device;
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend_v10.cpp
^
|
@@ -41,6 +41,8 @@
#include "hwcomposer_backend_v10.h"
+#include <unistd.h>
+
#ifdef HWC_DEVICE_API_VERSION_1_0
/* For vsync thread synchronization */
@@ -132,8 +134,8 @@
};
-HwComposerBackend_v10::HwComposerBackend_v10(hw_module_t *hwc_module, hw_device_t *hw_device)
- : HwComposerBackend(hwc_module)
+HwComposerBackend_v10::HwComposerBackend_v10(hw_module_t *hwc_module, hw_device_t *hw_device, void *libminisf)
+ : HwComposerBackend(hwc_module, libminisf)
, hwc_device((hwc_composer_device_1_t *)hw_device)
, hwc_list(NULL)
, hwc_mList(NULL)
@@ -146,6 +148,8 @@
HwComposerBackend_v10::~HwComposerBackend_v10()
{
+ hwc_device->eventControl(hwc_device, 0, HWC_EVENT_VSYNC, 0);
+
// Close the hwcomposer handle
HWC_PLUGIN_EXPECT_ZERO(hwc_close_1(hwc_device));
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend_v10.h
^
|
@@ -51,7 +51,7 @@
class HwComposerBackend_v10 : public HwComposerBackend {
public:
- HwComposerBackend_v10(hw_module_t *hwc_module, hw_device_t *hw_device);
+ HwComposerBackend_v10(hw_module_t *hwc_module, hw_device_t *hw_device, void *libminisf);
virtual ~HwComposerBackend_v10();
virtual EGLNativeDisplayType display();
@@ -60,6 +60,15 @@
virtual void swap(EGLNativeDisplayType display, EGLSurface surface);
virtual void sleepDisplay(bool sleep);
virtual float refreshRate();
+ virtual bool getScreenSizes(int *width, int *height, float *physical_width, float *physical_height)
+ {
+ *width = 0;
+ *height = 0;
+ *physical_width = 0;
+ *physical_height = 0;
+ // N/A
+ return false;
+ }
private:
hwc_composer_device_1_t *hwc_device;
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend_v11.cpp
^
|
@@ -48,10 +48,11 @@
#include <QtCore/QCoreApplication>
#include <private/qwindow_p.h>
+#include <private/qsystrace_p.h>
+
#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER1_API
// #define QPA_HWC_TIMING
-// #define QPA_HWC_SYNC_BEFORE_SET
#ifdef QPA_HWC_TIMING
#define QPA_HWC_TIMING_SAMPLE(variable) variable = timer.nsecsElapsed()
@@ -71,6 +72,13 @@
static void hwc11_callback_vsync(const struct hwc_procs *procs, int, int64_t)
{
+ static int counter = 0;
+ ++counter;
+ if (counter % 2)
+ QSystrace::begin("graphics", "QPA::vsync", "");
+ else
+ QSystrace::end("graphics", "QPA::vsync", "");
+
QCoreApplication::postEvent(static_cast<const HwcProcs_v11 *>(procs)->backend, new QEvent(QEvent::User));
}
@@ -90,6 +98,8 @@
hwc_composer_device_1_t *hwcdevice;
hwc_display_contents_1_t **mlist;
int num_displays;
+ bool m_syncBeforeSet;
+ bool m_waitOnRetireFence;
protected:
void present(HWComposerNativeWindowBuffer *buffer);
@@ -112,25 +122,36 @@
{
int bufferCount = qBound(2, qgetenv("QPA_HWC_BUFFER_COUNT").toInt(), 8);
setBufferCount(bufferCount);
+ m_syncBeforeSet = qEnvironmentVariableIsSet("QPA_HWC_SYNC_BEFORE_SET");
+ m_waitOnRetireFence = qEnvironmentVariableIsSet("QPA_HWC_WAIT_ON_RETIRE_FENCE");
}
void HWComposer::present(HWComposerNativeWindowBuffer *buffer)
{
+ QSystraceEvent trace("graphics", "QPA::present");
+
QPA_HWC_TIMING_SAMPLE(presentTime);
fblayer->handle = buffer->handle;
fblayer->releaseFenceFd = -1;
-#ifdef QPA_HWC_SYNC_BEFORE_SET
- int acqFd = getFenceBufferFd(buffer);
- if (acqFd >= 0) {
- sync_wait(acqFd, -1);
- close(acqFd);
- fblayer->acquireFenceFd = -1;
+ int retireFenceFd = -1;
+
+ if (m_waitOnRetireFence) {
+ retireFenceFd = mlist[0]->retireFenceFd;
+ mlist[0]->retireFenceFd = -1;
+ }
+
+ if (m_syncBeforeSet) {
+ int acqFd = getFenceBufferFd(buffer);
+ if (acqFd >= 0) {
+ sync_wait(acqFd, -1);
+ close(acqFd);
+ fblayer->acquireFenceFd = -1;
+ }
+ } else {
+ fblayer->acquireFenceFd = getFenceBufferFd(buffer);
}
-#else
- fblayer->acquireFenceFd = getFenceBufferFd(buffer);
-#endif
QPA_HWC_TIMING_SAMPLE(syncTime);
@@ -139,21 +160,26 @@
QPA_HWC_TIMING_SAMPLE(prepareTime);
+ QSystrace::begin("graphics", "QPA::set", "");
err = hwcdevice->set(hwcdevice, num_displays, mlist);
HWC_PLUGIN_EXPECT_ZERO(err);
+ QSystrace::end("graphics", "QPA::set", "");
QPA_HWC_TIMING_SAMPLE(setTime);
setFenceBufferFd(buffer, fblayer->releaseFenceFd);
- if (mlist[0]->retireFenceFd != -1) {
+ if (m_waitOnRetireFence && retireFenceFd != -1) {
+ sync_wait(retireFenceFd, -1);
+ close(retireFenceFd);
+ } else if (!m_waitOnRetireFence && mlist[0]->retireFenceFd != -1) {
close(mlist[0]->retireFenceFd);
mlist[0]->retireFenceFd = -1;
}
}
-HwComposerBackend_v11::HwComposerBackend_v11(hw_module_t *hwc_module, hw_device_t *hw_device, int num_displays)
- : HwComposerBackend(hwc_module)
+HwComposerBackend_v11::HwComposerBackend_v11(hw_module_t *hwc_module, hw_device_t *hw_device, void *libminisf, int num_displays)
+ : HwComposerBackend(hwc_module, libminisf)
, hwc_device((hwc_composer_device_1_t *)hw_device)
, hwc_list(NULL)
, hwc_mList(NULL)
@@ -174,6 +200,8 @@
HwComposerBackend_v11::~HwComposerBackend_v11()
{
+ hwc_device->eventControl(hwc_device, 0, HWC_EVENT_VSYNC, 0);
+
// Close the hwcomposer handle
if (!qgetenv("QPA_HWC_WORKAROUNDS").split(',').contains("no-close-hwc"))
HWC_PLUGIN_EXPECT_ZERO(hwc_close_1(hwc_device));
@@ -365,15 +393,80 @@
}
}
+int HwComposerBackend_v11::getSingleAttribute(uint32_t attribute)
+{
+ uint32_t config;
+
+ if (hwc_version == HWC_DEVICE_API_VERSION_1_1
+#ifdef HWC_DEVICE_API_VERSION_1_2
+ || hwc_version == HWC_DEVICE_API_VERSION_1_2
+#endif
+#ifdef HWC_DEVICE_API_VERSION_1_3
+ || hwc_version == HWC_DEVICE_API_VERSION_1_3
+#endif
+)
+ {
+ /* 1.3 or lower, currently active config is the first config */
+ size_t numConfigs = 1;
+ hwc_device->getDisplayConfigs(hwc_device, 0, &config, &numConfigs);
+ }
+#ifdef HWC_DEVICE_API_VERSION_1_4
+ else {
+ /* 1.4 or higher */
+ config = hwc_device->getActiveConfig(hwc_device, 0);
+ }
+#endif
+
+ const uint32_t attributes[] = {
+ attribute,
+ HWC_DISPLAY_NO_ATTRIBUTE,
+ };
+
+ int32_t values[] = {
+ 0,
+ 0,
+ };
+
+ hwc_device->getDisplayAttributes(hwc_device, 0, config, attributes, values);
+
+ for (unsigned int i = 0; i < sizeof(attributes) / sizeof(uint32_t); i++) {
+ if (attributes[i] == attribute) {
+ return values[i];
+ }
+ }
+
+ return 0;
+}
+
float
HwComposerBackend_v11::refreshRate()
{
- // TODO: Implement new hwc 1.1 querying of vsync period per-display
- //
- // from hwcomposer_defs.h:
- // "This query is not used for HWC_DEVICE_API_VERSION_1_1 and later.
- // Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used."
- return 60.0;
+ float value = (float)getSingleAttribute(HWC_DISPLAY_VSYNC_PERIOD);
+
+ value = (1000000000.0 / value);
+
+ // make sure the value is "reasonable", otherwise fallback to 60.0.
+ return (value > 0 && value <= 1000) ? value : 60.0;
+}
+
+bool
+HwComposerBackend_v11::getScreenSizes(int *width, int *height, float *physical_width, float *physical_height)
+{
+ int dpi_x = getSingleAttribute(HWC_DISPLAY_DPI_X) / 1000;
+ int dpi_y = getSingleAttribute(HWC_DISPLAY_DPI_Y) / 1000;
+
+ *width = getSingleAttribute(HWC_DISPLAY_WIDTH);
+ *height = getSingleAttribute(HWC_DISPLAY_HEIGHT);
+
+ if (dpi_x == 0 || dpi_y == 0 || *width == 0 || *height == 0) {
+ qWarning() << "failed to read screen size from hwc1.x backend";
+ return false;
+ }
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend_v11.h
^
|
@@ -56,7 +56,7 @@
class HwComposerBackend_v11 : public QObject, public HwComposerBackend {
public:
- HwComposerBackend_v11(hw_module_t *hwc_module, hw_device_t *hw_device, int num_displays);
+ HwComposerBackend_v11(hw_module_t *hwc_module, hw_device_t *hw_device, void *libminisf, int num_displays);
virtual ~HwComposerBackend_v11();
virtual EGLNativeDisplayType display();
@@ -65,6 +65,7 @@
virtual void swap(EGLNativeDisplayType display, EGLSurface surface);
virtual void sleepDisplay(bool sleep);
virtual float refreshRate();
+ virtual bool getScreenSizes(int *width, int *height, float *physical_width, float *physical_height);
virtual bool requestUpdate(QEglFSWindow *window) Q_DECL_OVERRIDE;
@@ -73,6 +74,7 @@
bool event(QEvent *e) Q_DECL_OVERRIDE;
private:
+ int getSingleAttribute(uint32_t attribute);
hwc_composer_device_1_t *hwc_device;
hwc_display_contents_1_t *hwc_list;
hwc_display_contents_1_t **hwc_mList;
|
[-]
[+]
|
Added |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend_v20.cpp
^
|
@@ -0,0 +1,436 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd.
+** Contact: Thomas Perl <thomas.perl@jolla.com>
+**
+** This file is part of the hwcomposer plugin.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <android-version.h>
+#include "hwcomposer_backend_v20.h"
+#include "qeglfswindow.h"
+
+#include <string>
+#include <QtCore/QElapsedTimer>
+#include <QtCore/QTimerEvent>
+#include <QtCore/QCoreApplication>
+#include <private/qwindow_p.h>
+
+#include <private/qsystrace_p.h>
+
+#include <inttypes.h>
+
+// #ifdef HWC_PLUGIN_HAVE_HWCOMPOSER1_API
+
+// #define QPA_HWC_TIMING
+
+#ifdef QPA_HWC_TIMING
+#define QPA_HWC_TIMING_SAMPLE(variable) variable = timer.nsecsElapsed()
+static QElapsedTimer timer;
+static qint64 presentTime;
+static qint64 syncTime;
+static qint64 prepareTime;
+static qint64 setTime;
+#else
+#define QPA_HWC_TIMING_SAMPLE(variable)
+#endif
+
+struct HwcProcs_v20 : public HWC2EventListener
+{
+ HwComposerBackend_v20 *backend;
+};
+
+void hwc2_callback_vsync(HWC2EventListener* listener, int32_t sequenceId,
+ hwc2_display_t display, int64_t timestamp)
+{
+ static int counter = 0;
+ ++counter;
+ if (counter % 2)
+ QSystrace::begin("graphics", "QPA::vsync", "");
+ else
+ QSystrace::end("graphics", "QPA::vsync", "");
+
+ QCoreApplication::postEvent(static_cast<const HwcProcs_v20 *>(listener)->backend,
+ new QEvent(QEvent::User));
+}
+
+void hwc2_callback_hotplug(HWC2EventListener* listener, int32_t sequenceId,
+ hwc2_display_t display, bool connected,
+ bool primaryDisplay)
+{
+ qDebug("onHotplugReceived(%d, %" PRIu64 ", %s, %s)",
+ sequenceId, display,
+ connected ? "connected" : "disconnected",
+ primaryDisplay ? "primary" : "external");
+
+ static_cast<const HwcProcs_v20 *>(listener)->backend->onHotplugReceived(
+ sequenceId, display, connected, primaryDisplay);
+}
+
+void hwc2_callback_refresh(HWC2EventListener* listener, int32_t sequenceId,
+ hwc2_display_t display)
+{
+}
+
+class HWC2Window : public HWComposerNativeWindow
+{
+ private:
+ hwc2_compat_layer_t *layer;
+ hwc2_compat_display_t *hwcDisplay;
+ int lastPresentFence = -1;
+ bool m_syncBeforeSet;
+ protected:
+ void present(HWComposerNativeWindowBuffer *buffer);
+
+ public:
+
+ HWC2Window(unsigned int width, unsigned int height, unsigned int format,
+ hwc2_compat_display_t *display, hwc2_compat_layer_t *layer);
+ ~HWC2Window();
+ void set();
+};
+
+HWC2Window::HWC2Window(unsigned int width, unsigned int height,
+ unsigned int format, hwc2_compat_display_t* display,
+ hwc2_compat_layer_t *layer) :
+ HWComposerNativeWindow(width, height, format),
+ layer(layer), hwcDisplay(display)
+{
+ int bufferCount = qgetenv("QPA_HWC_BUFFER_COUNT").toInt();
+ if (bufferCount)
+ bufferCount = qBound(2, bufferCount, 8);
+ else
+ // default to triple-buffering as on Android
+ bufferCount = 3;
+ setBufferCount(bufferCount);
+ m_syncBeforeSet = qEnvironmentVariableIsSet("QPA_HWC_SYNC_BEFORE_SET");
+}
+
+HWC2Window::~HWC2Window()
+{
+ if (lastPresentFence != -1) {
+ close(lastPresentFence);
+ }
+}
+
+void HWC2Window::present(HWComposerNativeWindowBuffer *buffer)
+{
+ uint32_t numTypes = 0;
+ uint32_t numRequests = 0;
+ int displayId = 0;
+ hwc2_error_t error = HWC2_ERROR_NONE;
+
+ QSystraceEvent trace("graphics", "QPA::present");
+
+ QPA_HWC_TIMING_SAMPLE(presentTime);
+
+ int acquireFenceFd = getFenceBufferFd(buffer);
+
+ if (m_syncBeforeSet && acquireFenceFd >= 0) {
+ sync_wait(acquireFenceFd, -1);
+ close(acquireFenceFd);
+ acquireFenceFd = -1;
+ }
+
+ error = hwc2_compat_display_validate(hwcDisplay, &numTypes,
+ &numRequests);
+ if (error != HWC2_ERROR_NONE && error != HWC2_ERROR_HAS_CHANGES) {
+ qDebug("prepare: validate failed for display %d: %d", displayId, error);
+ return;
+ }
+
+ if (numTypes || numRequests) {
+ qDebug("prepare: validate required changes for display %d: %d",
+ displayId, error);
+ return;
+ }
+
+ error = hwc2_compat_display_accept_changes(hwcDisplay);
+ if (error != HWC2_ERROR_NONE) {
+ qDebug("prepare: acceptChanges failed: %d", error);
+ return;
+ }
+
+ QPA_HWC_TIMING_SAMPLE(prepareTime);
+
+ QSystrace::begin("graphics", "QPA::set_client_target", "");
+ hwc2_compat_display_set_client_target(hwcDisplay, /* slot */0, buffer,
+ acquireFenceFd,
+ HAL_DATASPACE_UNKNOWN);
+ QSystrace::end("graphics", "QPA::set_client_target", "");
+
+ QSystrace::begin("graphics", "QPA::present", "");
+ int presentFence = -1;
+ hwc2_compat_display_present(hwcDisplay, &presentFence);
+ QSystrace::end("graphics", "QPA::present", "");
+
|
[-]
[+]
|
Added |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_backend_v20.h
^
|
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd.
+** Contact: Thomas Perl <thomas.perl@jolla.com>
+**
+** This file is part of the hwcomposer plugin.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HWCOMPOSER_BACKEND_V20_H
+#define HWCOMPOSER_BACKEND_V20_H
+
+#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER1_API
+
+#include "hwcomposer_backend.h"
+// libhybris access to the native hwcomposer window
+#include <hwcomposer_window.h>
+
+#include <hybris/hwc2/hwc2_compatibility_layer.h>
+
+#include <QBasicTimer>
+
+class HwcProcs_v20;
+class QWindow;
+
+class HwComposerBackend_v20 : public QObject, public HwComposerBackend {
+public:
+ HwComposerBackend_v20(hw_module_t *hwc_module, void *libminisf);
+ virtual ~HwComposerBackend_v20();
+
+ virtual EGLNativeDisplayType display();
+ virtual EGLNativeWindowType createWindow(int width, int height);
+ virtual void destroyWindow(EGLNativeWindowType window);
+ virtual void swap(EGLNativeDisplayType display, EGLSurface surface);
+ virtual void sleepDisplay(bool sleep);
+ virtual float refreshRate();
+ virtual bool getScreenSizes(int *width, int *height, float *physical_width, float *physical_height);
+
+ virtual bool requestUpdate(QEglFSWindow *window) Q_DECL_OVERRIDE;
+
+ void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
+ void handleVSyncEvent();
+ bool event(QEvent *e) Q_DECL_OVERRIDE;
+
+ void onHotplugReceived(int32_t sequenceId, hwc2_display_t display,
+ bool connected, bool primaryDisplay);
+
+ static int composerSequenceId;
+
+private:
+ hwc2_compat_device_t* hwc2_device;
+ hwc2_compat_display_t* hwc2_primary_display;
+ hwc2_compat_layer_t* hwc2_primary_layer;
+
+ bool m_displayOff;
+ QBasicTimer m_deliverUpdateTimeout;
+ QBasicTimer m_vsyncTimeout;
+ QSet<QWindow *> m_pendingUpdate;
+ HwcProcs_v20 *procs;
+};
+
+#endif /* HWC_PLUGIN_HAVE_HWCOMPOSER1_API */
+
+#endif /* HWCOMPOSER_BACKEND_V11_H */
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_context.cpp
^
|
@@ -71,7 +71,7 @@
}
HwComposerContext::HwComposerContext()
- : info(new HwComposerScreenInfo())
+ : info(NULL)
, backend(NULL)
, display_off(false)
, window_created(false)
@@ -92,6 +92,8 @@
HWC_PLUGIN_ASSERT_NOT_NULL(backend);
fps = backend->refreshRate();
+
+ info = new HwComposerScreenInfo(backend);
}
HwComposerContext::~HwComposerContext()
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_screeninfo.cpp
^
|
@@ -40,6 +40,7 @@
****************************************************************************/
#include "hwcomposer_screeninfo.h"
+#include "hwcomposer_backend.h"
#include <private/qmath_p.h>
#include <private/qcore_unix_p.h>
@@ -205,13 +206,48 @@
int m_depth;
};
+class HwComposerScreenInfoHWCSource {
+public:
+ HwComposerScreenInfoHWCSource(HwComposerBackend *backend) {
+ m_have_values = backend->getScreenSizes(&m_width, &m_height, &m_physicalWidth, &m_physicalHeight);
+ m_depth = 32;
+ }
+
+ QSizeF physicalScreenSize()
+ {
+ return QSizeF(m_physicalWidth, m_physicalHeight);
+ }
+
+ QSize screenSize()
+ {
+ return QSize(m_width, m_height);
+ }
+
+ int screenDepth()
+ {
+ return m_depth;
+ }
+
+ bool isValid()
+ {
+ return m_have_values;
+ }
+
+private:
+ float m_physicalWidth;
+ float m_physicalHeight;
+ int m_width;
+ int m_height;
+ int m_depth;
+ bool m_have_values;
+};
} /* empty namespace */
QT_BEGIN_NAMESPACE
-HwComposerScreenInfo::HwComposerScreenInfo()
+HwComposerScreenInfo::HwComposerScreenInfo(HwComposerBackend *backend)
{
/**
* Look up the values in the following order of preference:
@@ -220,12 +256,15 @@
* 2. fbdev via FBIOGET_VSCREENINFO is preferred otherwise
* 3. Fallback values (with warnings) if 1. and 2. fail
**/
+ HwComposerScreenInfoHWCSource hwcSource(backend);
HwComposerScreenInfoEnvironmentSource envSource;
HwComposerScreenInfoFbDevSource fbdevSource;
HwComposerScreenInfoFallbackSource fallbackSource;
if (envSource.hasScreenSize()) {
m_screenSize = envSource.screenSize();
+ } else if (hwcSource.isValid()) {
+ m_screenSize = hwcSource.screenSize();
} else if (fbdevSource.isValid()) {
m_screenSize = fbdevSource.screenSize();
} else {
@@ -234,6 +273,8 @@
if (envSource.hasPhysicalScreenSize()) {
m_physicalScreenSize = envSource.physicalScreenSize();
+ } else if (hwcSource.isValid()) {
+ m_physicalScreenSize = hwcSource.physicalScreenSize();
} else if (fbdevSource.isValid()) {
m_physicalScreenSize = fbdevSource.physicalScreenSize();
} else {
@@ -242,6 +283,8 @@
if (envSource.hasScreenDepth()) {
m_screenDepth = envSource.screenDepth();
+ } else if (hwcSource.isValid()) {
+ m_screenDepth = hwcSource.screenDepth();
} else if (fbdevSource.isValid()) {
m_screenDepth = fbdevSource.screenDepth();
} else {
|
[-]
[+]
|
Changed |
_service:tar_git:qt5-qpa-hwcomposer-plugin-5.6.2.12.tar.bz2/hwcomposer/hwcomposer_screeninfo.h
^
|
@@ -46,11 +46,13 @@
#include <QSizeF>
#include <QSize>
+class HwComposerBackend;
+
QT_BEGIN_NAMESPACE
class HwComposerScreenInfo {
public:
- HwComposerScreenInfo();
+ HwComposerScreenInfo(HwComposerBackend *backend);
QSizeF physicalScreenSize() const { return m_physicalScreenSize; }
QSize screenSize() const { return m_screenSize; }
|