Vulkan: only report refreshDuration, not {min|max}RefreshDuration

Test: Manually tested with a modified cube demo, that reports the refresh
duration returned from this extension.

As part of discussions within Khronos, it was decided that
VK_GOOGLE_display_timing should only report one refresh duration for a display,
and assume that it's refresh rate is fixed (which is the case for our current
devices).

Change-Id: I772348281c18a36b02dcfe0519d1943e25a41f7c
diff --git a/include/gui/Surface.h b/include/gui/Surface.h
index 4be11b4..750e653 100644
--- a/include/gui/Surface.h
+++ b/include/gui/Surface.h
@@ -150,9 +150,7 @@
             nsecs_t* outLastRefreshStartTime, nsecs_t* outGlCompositionDoneTime,
             nsecs_t* outDisplayPresentTime, nsecs_t* outDisplayRetireTime,
             nsecs_t* outDequeueReadyTime, nsecs_t* outReleaseTime);
-
-    status_t getDisplayRefreshCyclePeriod(nsecs_t* outMinRefreshDuration,
-            nsecs_t* outMaxRefreshDuration);
+    status_t getDisplayRefreshCycleDuration(nsecs_t* outRefreshDuration);
 
     status_t getUniqueId(uint64_t* outId) const;
 
@@ -210,7 +208,7 @@
     int dispatchSetAutoRefresh(va_list args);
     int dispatchEnableFrameTimestamps(va_list args);
     int dispatchGetFrameTimestamps(va_list args);
-    int dispatchGetDisplayRefreshCyclePeriod(va_list args);
+    int dispatchGetDisplayRefreshCycleDuration(va_list args);
 
 protected:
     virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 851a495..c2ed91a 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -262,15 +262,13 @@
 
     return NO_ERROR;
 }
-status_t Surface::getDisplayRefreshCyclePeriod(nsecs_t* outMinRefreshDuration,
-            nsecs_t* outMaxRefreshDuration) {
+status_t Surface::getDisplayRefreshCycleDuration(nsecs_t* outRefreshDuration) {
     ATRACE_CALL();
 
     DisplayStatInfo stats;
     status_t err = composerService()->getDisplayStats(NULL, &stats);
 
-    *outMinRefreshDuration = stats.vsyncPeriod;
-    *outMaxRefreshDuration = stats.vsyncPeriod;
+    *outRefreshDuration = stats.vsyncPeriod;
 
     return NO_ERROR;
 }
@@ -841,8 +839,8 @@
     case NATIVE_WINDOW_GET_FRAME_TIMESTAMPS:
         res = dispatchGetFrameTimestamps(args);
         break;
-    case NATIVE_WINDOW_GET_REFRESH_CYCLE_PERIOD:
-        res = dispatchGetDisplayRefreshCyclePeriod(args);
+    case NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION:
+        res = dispatchGetDisplayRefreshCycleDuration(args);
         break;
     default:
         res = NAME_NOT_FOUND;
@@ -989,11 +987,9 @@
             outDisplayRetireTime, outDequeueReadyTime, outReleaseTime);
 }
 
-int Surface::dispatchGetDisplayRefreshCyclePeriod(va_list args) {
-    nsecs_t* outMinRefreshDuration = va_arg(args, int64_t*);
-    nsecs_t* outMaxRefreshDuration = va_arg(args, int64_t*);
-    return getDisplayRefreshCyclePeriod(outMinRefreshDuration,
-            outMaxRefreshDuration);
+int Surface::dispatchGetDisplayRefreshCycleDuration(va_list args) {
+    nsecs_t* outRefreshDuration = va_arg(args, int64_t*);
+    return getDisplayRefreshCycleDuration(outRefreshDuration);
 }
 
 int Surface::connect(int api) {
diff --git a/vulkan/include/vulkan/vulkan.h b/vulkan/include/vulkan/vulkan.h
index 5d38ff9..47316f7 100644
--- a/vulkan/include/vulkan/vulkan.h
+++ b/vulkan/include/vulkan/vulkan.h
@@ -4146,8 +4146,7 @@
 #define VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME "VK_GOOGLE_display_timing"
 
 typedef struct VkRefreshCycleDurationGOOGLE {
-    uint64_t    minRefreshDuration;
-    uint64_t    maxRefreshDuration;
+    uint64_t    refreshDuration;
 } VkRefreshCycleDurationGOOGLE;
 
 typedef struct VkPastPresentationTimingGOOGLE {
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 08eee37..338462a 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -197,21 +197,17 @@
           frame_timestamps_enabled(false) {
         timing.clear();
         ANativeWindow* window = surface.window.get();
-        int64_t min_rdur;
-        int64_t max_rdur;
-        native_window_get_refresh_cycle_period(
+        int64_t rdur;
+        native_window_get_refresh_cycle_duration(
             window,
-            &min_rdur,
-            &max_rdur);
-        min_refresh_duration = static_cast<uint64_t>(min_rdur);
-        max_refresh_duration = static_cast<uint64_t>(max_rdur);
+            &rdur);
+        refresh_duration = static_cast<uint64_t>(rdur);
     }
 
     Surface& surface;
     uint32_t num_images;
     bool frame_timestamps_enabled;
-    uint64_t min_refresh_duration;
-    uint64_t max_refresh_duration;
+    uint64_t refresh_duration;
 
     struct Image {
         Image() : image(VK_NULL_HANDLE), dequeue_fence(-1), dequeued(false) {}
@@ -356,7 +352,7 @@
                                 // timestamps to calculate the info that should
                                 // be reported to the user:
                                 //
-                                ti->calculate(swapchain.min_refresh_duration);
+                                ti->calculate(swapchain.refresh_duration);
                                 num_ready++;
                             }
                             break;
@@ -1288,8 +1284,7 @@
     Swapchain& swapchain = *SwapchainFromHandle(swapchain_handle);
     VkResult result = VK_SUCCESS;
 
-    pDisplayTimingProperties->minRefreshDuration = swapchain.min_refresh_duration;
-    pDisplayTimingProperties->maxRefreshDuration = swapchain.max_refresh_duration;
+    pDisplayTimingProperties->refreshDuration = swapchain.refresh_duration;
 
     return result;
 }