@@ -65,11 +65,6 @@
#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;
@@ -91,396 +86,85 @@
{
}
-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=%x, disp=%d, connected=%d\n", __func__, 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");
- }
-protected:
- void present(HWComposerNativeWindowBuffer *buffer)
- {
- QSystraceEvent trace("graphics", "QPA::present");
-
- QPA_HWC_TIMING_SAMPLE(presentTime);
-
- RetireFencePool pool;
-
- // 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;
+ protected:
+ void present(HWComposerNativeWindowBuffer *buffer);
- // Retire fence pool will wait on and close all FDs consumed here
- }
+ public:
-private:
- HwComposerBackend_v11 *backend;
- bool m_syncBeforeSet;
+ 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");
}
-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);
-
- 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])];
-
- hwc_device->getDisplayAttributes(hwc_device, dpy, configs[i],
- attributes, values);
+ QSystraceEvent trace("graphics", "QPA::present");
- 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
-class HwComposerScreen_v11 {
-public:
- enum Layer {
- // Layers we use for composition
- HWC_SCREEN_FRAMEBUFFER_LAYER = 0,
- HWC_SCREEN_FRAMEBUFFER_TARGET_LAYER = 1,
-
- // Number of layers we need to allocate space for
- HWC_SCREEN_REQUIRED_LAYERS = 2,
- };
-
- HwComposerScreen_v11(hwc_composer_device_1_t *hwc_device, int id)
- : hwc_device(hwc_device)
- , id(id)
- , hwc_list(nullptr)
- {
- size_t needed_size = sizeof(hwc_display_contents_1_t) +
- HWC_SCREEN_REQUIRED_LAYERS * sizeof(hwc_layer_1_t);
-
- hwc_list = (hwc_display_contents_1_t *) calloc(1, needed_size);
-
- // Need to set this here, and not every time in relayout
- hwc_list->numHwLayers = 2;
- hwc_list->retireFenceFd = -1;
-#ifdef HWC_DEVICE_API_VERSION_1_3
- hwc_list->outbuf = 0;
- hwc_list->outbufAcquireFenceFd = -1;
-#endif
- }
-
- bool relayout(int width, int height)
- {
- // Source rectangle of the desktop
- const hwc_rect_t source_rect = {
- 0, 0, width, height
- };
-
- int ww = width, hh = height;
- get_screen_size(hwc_device, id, &ww, &hh);
-
|