diff options
author | 2017-04-04 10:51:39 -0700 | |
---|---|---|
committer | 2017-04-11 14:51:42 -0700 | |
commit | 6b376713907086c9642e7b7e66e51ddfa531b003 (patch) | |
tree | 85a14f06713e9d2fb5f977737136e0242f778cfa /libs/gui/Surface.cpp | |
parent | 99dfb8a6466b653afc63ed91f07f59daa3c66385 (diff) |
egl: Avoid use of retire as present
Retire fences from HWC1 are implemented inconsitently,
so present emulation doesn't always work well.
This patch disables present for all HWC1 based devices.
Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*
Bug: 36730849, 36887025
Change-Id: I1eba2f8490c2f6feced2a36d1efc4cd66be7da40
Diffstat (limited to 'libs/gui/Surface.cpp')
-rw-r--r-- | libs/gui/Surface.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 1149b8980b..41221aab8d 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -52,6 +52,8 @@ Surface::Surface( mAutoRefresh(false), mSharedBufferSlot(BufferItem::INVALID_BUFFER_SLOT), mSharedBufferHasBeenQueued(false), + mQueriedSupportedTimestamps(false), + mFrameTimestampsSupportsPresent(false), mEnableFrameTimestamps(false), mFrameEventHistory(std::make_unique<ProducerFrameEventHistory>()) { @@ -209,8 +211,8 @@ static bool checkConsumerForUpdates( bool checkForDisplayPresent = (outDisplayPresentTime != nullptr) && !e->hasDisplayPresentInfo(); - // LastRefreshStart, DequeueReady, and Release are never - // available for the last frame. + // LastRefreshStart, DequeueReady, and Release are never available for the + // last frame. bool checkForLastRefreshStart = (outLastRefreshStartTime != nullptr) && !e->hasLastRefreshStartInfo() && (e->frameNumber != lastFrameNumber); @@ -252,6 +254,12 @@ status_t Surface::getFrameTimestamps(uint64_t frameNumber, return INVALID_OPERATION; } + // Verify the requested timestamps are supported. + querySupportedTimestampsLocked(); + if (outDisplayPresentTime != nullptr && !mFrameTimestampsSupportsPresent) { + return BAD_VALUE; + } + FrameEvents* events = mFrameEventHistory->getFrame(frameNumber); if (events == nullptr) { // If the entry isn't available in the producer, it's definitely not @@ -739,6 +747,29 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { return err; } +void Surface::querySupportedTimestampsLocked() const { + // mMutex must be locked when calling this method. + + if (mQueriedSupportedTimestamps) { + return; + } + mQueriedSupportedTimestamps = true; + + std::vector<FrameEvent> supportedFrameTimestamps; + status_t err = composerService()->getSupportedFrameTimestamps( + &supportedFrameTimestamps); + + if (err != NO_ERROR) { + return; + } + + for (auto sft : supportedFrameTimestamps) { + if (sft == FrameEvent::DISPLAY_PRESENT) { + mFrameTimestampsSupportsPresent = true; + } + } +} + int Surface::query(int what, int* value) const { ATRACE_CALL(); ALOGV("Surface::query"); @@ -800,6 +831,11 @@ int Surface::query(int what, int* value) const { static_cast<int>(durationUs); return NO_ERROR; } + case NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT: { + querySupportedTimestampsLocked(); + *value = mFrameTimestampsSupportsPresent ? 1 : 0; + return NO_ERROR; + } case NATIVE_WINDOW_IS_VALID: { *value = mGraphicBufferProducer != nullptr ? 1 : 0; return NO_ERROR; |