@@ -51,6 +51,8 @@
#include <private/qsystrace_p.h>
+#include <inttypes.h>
+
// #ifdef HWC_PLUGIN_HAVE_HWCOMPOSER1_API
// #define QPA_HWC_TIMING
@@ -117,6 +119,7 @@
HWC2Window(unsigned int width, unsigned int height, unsigned int format,
hwc2_compat_display_t *display, hwc2_compat_layer_t *layer);
+ ~HWC2Window();
void set();
};
@@ -136,6 +139,13 @@
m_syncBeforeSet = qEnvironmentVariableIsSet("QPA_HWC_SYNC_BEFORE_SET");
}
+HWC2Window::~HWC2Window()
+{
+ if (lastPresentFence != -1) {
+ close(lastPresentFence);
+ }
+}
+
void HWC2Window::present(HWComposerNativeWindowBuffer *buffer)
{
uint32_t numTypes = 0;
@@ -183,37 +193,20 @@
QSystrace::end("graphics", "QPA::set_client_target", "");
QSystrace::begin("graphics", "QPA::present", "");
- int presentFence;
+ int presentFence = -1;
hwc2_compat_display_present(hwcDisplay, &presentFence);
QSystrace::end("graphics", "QPA::present", "");
- if (error != HWC2_ERROR_NONE) {
- qDebug("presentAndGetReleaseFences: failed for display %d: %d",
- displayId, error);
- return;
- }
-
QPA_HWC_TIMING_SAMPLE(setTime);
- hwc2_compat_out_fences_t* fences;
- error = hwc2_compat_display_get_release_fences(
- hwcDisplay, &fences);
-
- if (error != HWC2_ERROR_NONE) {
- qDebug("presentAndGetReleaseFences: Failed to get release fences "
- "for display %d: %d", displayId, error);
- return;
+ if (lastPresentFence != -1) {
+ sync_wait(lastPresentFence, -1);
+ close(lastPresentFence);
}
- int fenceFd = hwc2_compat_out_fences_get_fence(fences, layer);
- if (fenceFd != -1)
- setFenceBufferFd(buffer, fenceFd);
- else if (presentFence != -1)
- setFenceBufferFd(buffer, presentFence);
-
- hwc2_compat_out_fences_destroy(fences);
+ lastPresentFence = presentFence != -1 ? dup(presentFence) : -1;
- lastPresentFence = presentFence;
+ setFenceBufferFd(buffer, presentFence);
}
int HwComposerBackend_v20::composerSequenceId = 0;
@@ -253,6 +246,8 @@
{
hwc2_compat_display_set_vsync_enabled(hwc2_primary_display, HWC2_VSYNC_DISABLE);
+ hwc2_compat_display_set_power_mode(hwc2_primary_display, HWC2_POWER_MODE_DOZE);
+
// Close the hwcomposer handle
if (!qgetenv("QPA_HWC_WORKAROUNDS").split(',').contains("no-close-hwc"))
free(hwc2_device);
@@ -277,7 +272,7 @@
// would leak stuff, and we want to avoid that for obvious reasons.
HWC_PLUGIN_EXPECT_NULL(hwc2_primary_layer);
- hwc2_compat_layer_t* layer = hwc2_primary_layer =
+ hwc2_compat_layer_t* layer = hwc2_primary_layer =
hwc2_compat_display_create_layer(hwc2_primary_display);
hwc2_compat_layer_set_composition_type(layer, HWC2_COMPOSITION_CLIENT);
|