@@ -46,12 +46,9 @@
#include <QtCore/QElapsedTimer>
#include <QtCore/QTimerEvent>
#include <QtCore/QCoreApplication>
-#include <QtCore/QTimer>
-#include <QtCore/QSocketNotifier>
#include <private/qwindow_p.h>
#include "qsystrace_selector.h"
-#include <fcntl.h>
#ifdef HWC_PLUGIN_HAVE_HWCOMPOSER1_API
@@ -68,17 +65,12 @@
#define QPA_HWC_TIMING_SAMPLE(variable)
#endif
-
-static int g_external_connected = 0;
-static int g_external_connected_next = 0;
-static int g_unblanked_displays[HWC_NUM_DISPLAY_TYPES] = { 0 };
-
struct HwcProcs_v11 : public hwc_procs
{
HwComposerBackend_v11 *backend;
};
-static void hwc11_callback_vsync(const struct hwc_procs *procs, int disp, int64_t)
+static void hwc11_callback_vsync(const struct hwc_procs *procs, int, int64_t)
{
static int counter = 0;
++counter;
@@ -87,426 +79,112 @@
else
QSystrace::end("graphics", "QPA::vsync", "");
- if (disp != 0)
- qDebug() << __func__ << " disp: " << disp;
-
QCoreApplication::postEvent(static_cast<const HwcProcs_v11 *>(procs)->backend, new QEvent(QEvent::User));
}
static void hwc11_callback_invalidate(const struct hwc_procs *)
{
- qDebug() << __func__;
}
-static void hwc11_callback_hotplug(const struct hwc_procs *procs, int disp, int connected)
+static void hwc11_callback_hotplug(const struct hwc_procs *, int, int)
{
- fprintf(stderr, "%s: procs=%p, disp=%d, connected=%d\n", __func__, (void*)procs, disp, connected);
- if (disp == HWC_DISPLAY_EXTERNAL) {
- g_external_connected_next = connected;
- }
}
-class HwComposerBackendWindow_v11 : public HWComposerNativeWindow
-{
-public:
- HwComposerBackendWindow_v11(unsigned int width, unsigned int height,
- unsigned int format, HwComposerBackend_v11 *backend)
- : HWComposerNativeWindow(width, height, format)
- , backend(backend)
- {
- 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");
- }
-
-protected:
- void present(HWComposerNativeWindowBuffer *buffer)
- {
- QSystraceEvent trace("graphics", "QPA::present");
-
- QPA_HWC_TIMING_SAMPLE(presentTime);
-
- RetireFencePool pool(m_waitOnRetireFence);
- // Obtain a new acquire fence to be used, then also
- // set the new release fence with the return value
- int fence = -1;
- if (m_syncBeforeSet) {
- int acqFd = getFenceBufferFd(buffer);
- if (acqFd >= 0) {
- sync_wait(acqFd, -1);
- close(acqFd);
- fence = -1;
- }
- } else {
- fence = getFenceBufferFd(buffer);
- }
- fence = backend->present(&pool, buffer->handle, fence);
- setFenceBufferFd(buffer, fence);
+class HWComposer : public HWComposerNativeWindow
+{
+ private:
+ hwc_layer_1_t *fblayer;
+ 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);
- backend->geometryChanged = false;
+ public:
- // Retire fence pool will wait on and close all FDs consumed here
- }
-
-private:
- HwComposerBackend_v11 *backend;
- bool m_syncBeforeSet;
- bool m_waitOnRetireFence;
+ HWComposer(unsigned int width, unsigned int height, unsigned int format,
+ hwc_composer_device_1_t *device, hwc_display_contents_1_t **mList,
+ hwc_layer_1_t *layer, int num_displays);
+ void set();
};
-static void
-get_screen_size(hwc_composer_device_1_t *hwc_device, int id, int *width, int *height)
+HWComposer::HWComposer(unsigned int width, unsigned int height, unsigned int format,
+ hwc_composer_device_1_t *device, hwc_display_contents_1_t **mList,
+ hwc_layer_1_t *layer, int num_displays)
+ : HWComposerNativeWindow(width, height, format)
+ , fblayer(layer)
+ , hwcdevice(device)
+ , mlist(mList)
+ , num_displays(num_displays)
{
- size_t count = 1;
- uint32_t config = 0;
- if (hwc_device->getDisplayConfigs(hwc_device, id, &config, &count) == 0) {
- uint32_t attrs[] = {
- HWC_DISPLAY_WIDTH,
- HWC_DISPLAY_HEIGHT,
- HWC_DISPLAY_NO_ATTRIBUTE,
- };
- int32_t values[] = {
- 0,
- 0,
- 0,
- };
-
- hwc_device->getDisplayAttributes(hwc_device, id, config, attrs, values);
- fprintf(stderr, "Display %d size: %dx%d\n", id, values[0], values[1]);
- *width = values[0];
- *height = values[1];
- } else {
- //fprintf(stderr, "No size for display %d (not connected)\n", id);
- }
+ 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");
}
-static void
-dump_attributes(hwc_composer_device_1_t *hwc_device, int num_displays)
+void HWComposer::present(HWComposerNativeWindowBuffer *buffer)
{
- // Get display configs
- for (int dpy=0; dpy<num_displays; dpy++) {
- size_t numConfigs = 32;
- uint32_t configs[numConfigs];
- if (hwc_device->getDisplayConfigs(hwc_device, dpy, configs, &numConfigs) != 0) {
- fprintf(stderr, "Display %d not connected, no configs\n", dpy);
- continue;
- }
-
- fprintf(stderr, "%d configs found for display %d\n", numConfigs, dpy);
+ QSystraceEvent trace("graphics", "QPA::present");
- for (uint i=0; i<numConfigs; i++) {
- uint32_t attributes[] = {
- HWC_DISPLAY_VSYNC_PERIOD,
- HWC_DISPLAY_WIDTH,
- HWC_DISPLAY_HEIGHT,
- HWC_DISPLAY_DPI_X,
- HWC_DISPLAY_DPI_Y,
- HWC_DISPLAY_NO_ATTRIBUTE, // sentinel
- };
- int32_t values[sizeof(attributes)/sizeof(attributes[0])];
+ QPA_HWC_TIMING_SAMPLE(presentTime);
- hwc_device->getDisplayAttributes(hwc_device, dpy, configs[i],
- attributes, values);
+ fblayer->handle = buffer->handle;
+ fblayer->releaseFenceFd = -1;
- fprintf(stderr, "Dpy %d Cfg %d (%d) VSYNC_PERIOD=%d, SIZE=(%d, %d), DPY=(%d, %d)\n",
- dpy, i, configs[i], values[0], values[1], values[2], values[3], values[4]);
- }
- }
-}
-
-// contents for a single screen
|
@@ -51,45 +51,10 @@
#include <QBasicTimer>
-// Helper class that takes care of waiting on and closing a set
-// of file descriptors
-class RetireFencePool {
-public:
- RetireFencePool(const bool wait) :
- m_fds(),
- m_wait(wait)
- {
- }
-
- ~RetireFencePool()
- {
- for (auto fd: m_fds) {
- //fprintf(stderr, "Waiting and closing retire fence fd: %d\n", fd);
- if (m_wait)
- sync_wait(fd, -1);
- close(fd);
- }
- }
-
- void consume(int &fd)
- {
- if (fd != -1) {
- m_fds.push_back(fd);
- fd = -1;
- }
- }
-
-private:
- std::vector<int> m_fds;
- bool m_wait;
-};
-
class HwcProcs_v11;
class QWindow;
-class HwComposerContent_v11;
class HwComposerBackend_v11 : public QObject, public HwComposerBackend {
- Q_OBJECT
public:
HwComposerBackend_v11(hw_module_t *hwc_module, hw_device_t *hw_device, void *libminisf, int num_displays);
virtual ~HwComposerBackend_v11();
@@ -98,7 +63,6 @@
virtual EGLNativeWindowType createWindow(int width, int height);
virtual void destroyWindow(EGLNativeWindowType window);
virtual void swap(EGLNativeDisplayType display, EGLSurface surface);
- virtual void blankDisplay(int display, bool blank);
virtual void sleepDisplay(bool sleep);
virtual float refreshRate();
virtual bool getScreenSizes(int *width, int *height, float *physical_width, float *physical_height);
@@ -109,13 +73,11 @@
void handleVSyncEvent();
bool event(QEvent *e) Q_DECL_OVERRIDE;
- // Present method that does the buffer swapping, returns the releaseFenceFd
- int present(RetireFencePool *pool, buffer_handle_t handle, int acquireFenceFd);
-
- bool geometryChanged;
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;
uint32_t hwc_version;
int num_displays;
@@ -124,13 +86,6 @@
QBasicTimer m_vsyncTimeout;
QSet<QWindow *> m_pendingUpdate;
HwcProcs_v11 *procs;
-
- int width;
- int height;
- HwComposerContent_v11 *content;
-
-private slots:
- void handleVSYNC();
};
#endif /* HWC_PLUGIN_HAVE_HWCOMPOSER1_API */
|