summaryrefslogtreecommitdiff
path: root/libs/gui/Surface.cpp
diff options
context:
space:
mode:
author Brian Anderson <brianderson@google.com> 2016-07-28 16:20:47 -0700
committer Brian Anderson <brianderson@google.com> 2017-01-12 10:40:55 -0800
commit3da8d2748580b2575e368e203ce2c7f8d34dea05 (patch)
tree4d5076f45374599ae346f0cb17da6197624776ae /libs/gui/Surface.cpp
parent50143b3780ad2aaa544c8d2d47619214b79c3c56 (diff)
Surface unit tests for getFrameTimestamps.
Verifies the following: 1) The timestamps and fences aren't transferred if the feature isn't explicitly enabled. 2) Attempts to get the timestamps will fail if not enabled. 3) Timestamps are transferred if enabled. 4) The support for Present/Retire timestamps are properly queried from the ISurfaceComposer. 5) Timestamps correspond to the correct frame. 6) The consumer doesn't send the acquire fence back to the producer and a sync call isn't made to try and get it from the producer. 7) A sync call isn't made when no timestamps are requested. 8) If the consumer sent the producer fences, the consumer can get the timestamps without a sync call. 9) If there was no GL composite performed, a sync call isn't made to get a non-existant fence/time. 10) When asking for the retire or release time of the most recent frame, a sync call isn't made. 11) Requests for unsupported timestamps return an error and do not result in a sync call. Test: Test: adb shell /data/nativetest/libgui_test/libgui_test --gtest_filter=*GetFrameTimestamps* Change-Id: I6f728af0d4a0f431c9e47131da64584a589559e7
Diffstat (limited to 'libs/gui/Surface.cpp')
-rw-r--r--libs/gui/Surface.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index a172c32522..ead8ecb3b4 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -52,7 +52,8 @@ Surface::Surface(
mQueriedSupportedTimestamps(false),
mFrameTimestampsSupportsPresent(false),
mFrameTimestampsSupportsRetire(false),
- mEnableFrameTimestamps(false)
+ mEnableFrameTimestamps(false),
+ mFrameEventHistory(std::make_unique<ProducerFrameEventHistory>())
{
// Initialize the ANativeWindow function pointers.
ANativeWindow::setSwapInterval = hook_setSwapInterval;
@@ -96,6 +97,10 @@ Surface::~Surface() {
}
}
+sp<ISurfaceComposer> Surface::composerService() const {
+ return ComposerService::getComposerService();
+}
+
sp<IGraphicBufferProducer> Surface::getIGraphicBufferProducer() const {
return mGraphicBufferProducer;
}
@@ -203,7 +208,7 @@ status_t Surface::getFrameTimestamps(uint64_t frameNumber,
return BAD_VALUE;
}
- FrameEvents* events = mFrameEventHistory.getFrame(frameNumber);
+ FrameEvents* events = mFrameEventHistory->getFrame(frameNumber);
if (events == nullptr) {
// If the entry isn't available in the producer, it's definitely not
// available in the consumer.
@@ -216,8 +221,8 @@ status_t Surface::getFrameTimestamps(uint64_t frameNumber,
outDisplayPresentTime, outDisplayRetireTime, outReleaseTime)) {
FrameEventHistoryDelta delta;
mGraphicBufferProducer->getFrameTimestamps(&delta);
- mFrameEventHistory.applyDelta(delta);
- events = mFrameEventHistory.getFrame(frameNumber);
+ mFrameEventHistory->applyDelta(delta);
+ events = mFrameEventHistory->getFrame(frameNumber);
}
if (events == nullptr) {
@@ -396,7 +401,7 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) {
}
if (enableFrameTimestamps) {
- mFrameEventHistory.applyDelta(frameTimestamps);
+ mFrameEventHistory->applyDelta(frameTimestamps);
}
if ((result & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) {
@@ -590,16 +595,16 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
}
if (mEnableFrameTimestamps) {
- mFrameEventHistory.applyDelta(output.frameTimestamps);
+ mFrameEventHistory->applyDelta(output.frameTimestamps);
// Update timestamps with the local acquire fence.
// The consumer doesn't send it back to prevent us from having two
// file descriptors of the same fence.
- mFrameEventHistory.updateAcquireFence(mNextFrameNumber,
+ mFrameEventHistory->updateAcquireFence(mNextFrameNumber,
std::make_shared<FenceTime>(std::move(fence)));
// Cache timestamps of signaled fences so we can close their file
// descriptors.
- mFrameEventHistory.updateSignalTimes();
+ mFrameEventHistory->updateSignalTimes();
}
mLastFrameNumber = mNextFrameNumber;
@@ -638,8 +643,7 @@ void Surface::querySupportedTimestampsLocked() const {
mQueriedSupportedTimestamps = true;
std::vector<FrameEvent> supportedFrameTimestamps;
- sp<ISurfaceComposer> composer(ComposerService::getComposerService());
- status_t err = composer->getSupportedFrameTimestamps(
+ status_t err = composerService()->getSupportedFrameTimestamps(
&supportedFrameTimestamps);
if (err != NO_ERROR) {
@@ -668,9 +672,8 @@ int Surface::query(int what, int* value) const {
}
break;
case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: {
- sp<ISurfaceComposer> composer(
- ComposerService::getComposerService());
- if (composer->authenticateSurfaceTexture(mGraphicBufferProducer)) {
+ if (composerService()->authenticateSurfaceTexture(
+ mGraphicBufferProducer)) {
*value = 1;
} else {
*value = 0;