HWC2OnFbAdapter: don't claim present fences work
We never produce real present fences, so indicate this to the
compositor. This will prevent GOOGLE_display_timing & friends from being
exposed in the client APIs.
Similar to previous change in HWC2On1Adapter.
Bug: b/111505197
Change-Id: I601a7f5628d4b218431fc0f1abb4807c9941ce64
diff --git a/graphics/composer/2.1/utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp b/graphics/composer/2.1/utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp
index 7c9e651..0f50577 100644
--- a/graphics/composer/2.1/utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp
+++ b/graphics/composer/2.1/utils/hwc2onfbadapter/HWC2OnFbAdapter.cpp
@@ -32,6 +32,8 @@
#include <log/log.h>
#include <sync/sync.h>
+using namespace HWC2;
+
namespace android {
namespace {
@@ -629,9 +631,10 @@
}
}
-void getCapabilitiesHook(hwc2_device_t* /*device*/, uint32_t* outCount,
- int32_t* /*outCapabilities*/) {
- *outCount = 0;
+void getCapabilitiesHook(hwc2_device_t* device, uint32_t* outCount,
+ int32_t* outCapabilities) {
+ auto& adapter = HWC2OnFbAdapter::cast(device);
+ adapter.getCapabilities(outCount, outCapabilities);
}
int closeHook(hw_device_t* device) {
@@ -656,6 +659,10 @@
mFbInfo.xdpi_scaled = int(mFbDevice->xdpi * 1000.0f);
mFbInfo.ydpi_scaled = int(mFbDevice->ydpi * 1000.0f);
+ // Present fences aren't supported, always indicate PresentFenceIsNotReliable
+ // for FB devices
+ mCapabilities.insert(Capability::PresentFenceIsNotReliable);
+
mVsyncThread.start(0, mFbInfo.vsync_period_ns);
}
@@ -791,6 +798,23 @@
mVsyncThread.enableCallback(enable);
}
+void HWC2OnFbAdapter::getCapabilities(uint32_t* outCount,
+ int32_t* outCapabilities) {
+ if (outCapabilities == nullptr) {
+ *outCount = mCapabilities.size();
+ return;
+ }
+
+ auto capabilityIter = mCapabilities.cbegin();
+ for (size_t written = 0; written < *outCount; ++written) {
+ if (capabilityIter == mCapabilities.cend()) {
+ return;
+ }
+ outCapabilities[written] = static_cast<int32_t>(*capabilityIter);
+ ++capabilityIter;
+ }
+}
+
int64_t HWC2OnFbAdapter::VsyncThread::now() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
diff --git a/graphics/composer/2.1/utils/hwc2onfbadapter/include/hwc2onfbadapter/HWC2OnFbAdapter.h b/graphics/composer/2.1/utils/hwc2onfbadapter/include/hwc2onfbadapter/HWC2OnFbAdapter.h
index d6272fd..f1f11ef 100644
--- a/graphics/composer/2.1/utils/hwc2onfbadapter/include/hwc2onfbadapter/HWC2OnFbAdapter.h
+++ b/graphics/composer/2.1/utils/hwc2onfbadapter/include/hwc2onfbadapter/HWC2OnFbAdapter.h
@@ -23,7 +23,11 @@
#include <thread>
#include <unordered_set>
+#define HWC2_INCLUDE_STRINGIFICATION
+#define HWC2_USE_CPP11
#include <hardware/hwcomposer2.h>
+#undef HWC2_INCLUDE_STRINGIFICATION
+#undef HWC2_USE_CPP11
struct framebuffer_device_t;
@@ -75,6 +79,7 @@
void setVsyncCallback(HWC2_PFN_VSYNC callback, hwc2_callback_data_t data);
void enableVsync(bool enable);
+ void getCapabilities(uint32_t* outCount, int32_t* outCapabilities);
private:
framebuffer_device_t* mFbDevice{nullptr};
@@ -90,6 +95,8 @@
buffer_handle_t mBuffer{nullptr};
+ std::unordered_set<HWC2::Capability> mCapabilities;
+
class VsyncThread {
public:
static int64_t now();