| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2010 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #define LOG_TAG "ANativeWindow" | 
|  | 18 |  | 
| Jesse Hall | 7992781 | 2017-03-23 11:03:23 -0700 | [diff] [blame] | 19 | #include <grallocusage/GrallocUsageConversion.h> | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 20 | // from nativewindow/includes/system/window.h | 
|  | 21 | // (not to be confused with the compatibility-only window.h from system/core/includes) | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 22 | #include <system/window.h> | 
|  | 23 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 24 | #include <private/android/AHardwareBufferHelpers.h> | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 25 |  | 
| Mathias Agopian | 453effd | 2017-04-03 15:34:13 -0700 | [diff] [blame] | 26 | #include <ui/GraphicBuffer.h> | 
|  | 27 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 28 | using namespace android; | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 29 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 30 | static int32_t query(ANativeWindow* window, int what) { | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 31 | int value; | 
|  | 32 | int res = window->query(window, what, &value); | 
|  | 33 | return res < 0 ? res : value; | 
|  | 34 | } | 
|  | 35 |  | 
| Alec Mouri | 72670c5 | 2019-08-31 01:54:33 -0700 | [diff] [blame] | 36 | static int64_t query64(ANativeWindow* window, int what) { | 
|  | 37 | int64_t value; | 
|  | 38 | int res = window->perform(window, what, &value); | 
|  | 39 | return res < 0 ? res : value; | 
|  | 40 | } | 
|  | 41 |  | 
| Peiyong Lin | 654f87b | 2018-01-30 14:21:33 -0800 | [diff] [blame] | 42 | static bool isDataSpaceValid(ANativeWindow* window, int32_t dataSpace) { | 
|  | 43 | bool supported = false; | 
|  | 44 | switch (dataSpace) { | 
|  | 45 | case HAL_DATASPACE_UNKNOWN: | 
|  | 46 | case HAL_DATASPACE_V0_SRGB: | 
|  | 47 | return true; | 
|  | 48 | // These data space need wide gamut support. | 
|  | 49 | case HAL_DATASPACE_V0_SCRGB_LINEAR: | 
|  | 50 | case HAL_DATASPACE_V0_SCRGB: | 
|  | 51 | case HAL_DATASPACE_DISPLAY_P3: | 
|  | 52 | native_window_get_wide_color_support(window, &supported); | 
|  | 53 | return supported; | 
|  | 54 | // These data space need HDR support. | 
|  | 55 | case HAL_DATASPACE_BT2020_PQ: | 
|  | 56 | native_window_get_hdr_support(window, &supported); | 
|  | 57 | return supported; | 
|  | 58 | default: | 
|  | 59 | return false; | 
|  | 60 | } | 
|  | 61 | } | 
|  | 62 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 63 | /************************************************************************************************** | 
|  | 64 | * NDK | 
|  | 65 | **************************************************************************************************/ | 
|  | 66 |  | 
|  | 67 | void ANativeWindow_acquire(ANativeWindow* window) { | 
|  | 68 | // incStrong/decStrong token must be the same, doesn't matter what it is | 
|  | 69 | window->incStrong((void*)ANativeWindow_acquire); | 
|  | 70 | } | 
|  | 71 |  | 
|  | 72 | void ANativeWindow_release(ANativeWindow* window) { | 
|  | 73 | // incStrong/decStrong token must be the same, doesn't matter what it is | 
|  | 74 | window->decStrong((void*)ANativeWindow_acquire); | 
|  | 75 | } | 
|  | 76 |  | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 77 | int32_t ANativeWindow_getWidth(ANativeWindow* window) { | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 78 | return query(window, NATIVE_WINDOW_WIDTH); | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 79 | } | 
|  | 80 |  | 
|  | 81 | int32_t ANativeWindow_getHeight(ANativeWindow* window) { | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 82 | return query(window, NATIVE_WINDOW_HEIGHT); | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 83 | } | 
|  | 84 |  | 
|  | 85 | int32_t ANativeWindow_getFormat(ANativeWindow* window) { | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 86 | return query(window, NATIVE_WINDOW_FORMAT); | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 87 | } | 
|  | 88 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 89 | int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, | 
|  | 90 | int32_t width, int32_t height, int32_t format) { | 
| Mathias Agopian | 89ed4c8 | 2017-02-09 18:48:34 -0800 | [diff] [blame] | 91 | int32_t err = native_window_set_buffers_format(window, format); | 
|  | 92 | if (!err) { | 
|  | 93 | err = native_window_set_buffers_user_dimensions(window, width, height); | 
|  | 94 | if (!err) { | 
|  | 95 | int mode = NATIVE_WINDOW_SCALING_MODE_FREEZE; | 
|  | 96 | if (width && height) { | 
|  | 97 | mode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW; | 
|  | 98 | } | 
|  | 99 | err = native_window_set_scaling_mode(window, mode); | 
|  | 100 | } | 
|  | 101 | } | 
|  | 102 | return err; | 
|  | 103 | } | 
|  | 104 |  | 
|  | 105 | int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, | 
|  | 106 | ARect* inOutDirtyBounds) { | 
|  | 107 | return window->perform(window, NATIVE_WINDOW_LOCK, outBuffer, inOutDirtyBounds); | 
|  | 108 | } | 
|  | 109 |  | 
|  | 110 | int32_t ANativeWindow_unlockAndPost(ANativeWindow* window) { | 
|  | 111 | return window->perform(window, NATIVE_WINDOW_UNLOCK_AND_POST); | 
|  | 112 | } | 
| Jesse Hall | 09932ec | 2017-03-13 11:36:05 -0700 | [diff] [blame] | 113 |  | 
|  | 114 | int32_t ANativeWindow_setBuffersTransform(ANativeWindow* window, int32_t transform) { | 
|  | 115 | static_assert(ANATIVEWINDOW_TRANSFORM_MIRROR_HORIZONTAL == NATIVE_WINDOW_TRANSFORM_FLIP_H); | 
|  | 116 | static_assert(ANATIVEWINDOW_TRANSFORM_MIRROR_VERTICAL == NATIVE_WINDOW_TRANSFORM_FLIP_V); | 
|  | 117 | static_assert(ANATIVEWINDOW_TRANSFORM_ROTATE_90 == NATIVE_WINDOW_TRANSFORM_ROT_90); | 
|  | 118 |  | 
|  | 119 | constexpr int32_t kAllTransformBits = | 
|  | 120 | ANATIVEWINDOW_TRANSFORM_MIRROR_HORIZONTAL | | 
|  | 121 | ANATIVEWINDOW_TRANSFORM_MIRROR_VERTICAL | | 
| Robert Carr | 175ed5b | 2018-04-06 13:59:00 -0700 | [diff] [blame] | 122 | ANATIVEWINDOW_TRANSFORM_ROTATE_90 | | 
|  | 123 | // We don't expose INVERSE_DISPLAY as an NDK constant, but someone could have read it | 
|  | 124 | // from a buffer already set by Camera framework, so we allow it to be forwarded. | 
|  | 125 | NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY; | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 126 | if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) | 
| Jesse Hall | 09932ec | 2017-03-13 11:36:05 -0700 | [diff] [blame] | 127 | return -EINVAL; | 
|  | 128 | if ((transform & ~kAllTransformBits) != 0) | 
|  | 129 | return -EINVAL; | 
|  | 130 |  | 
|  | 131 | return native_window_set_buffers_transform(window, transform); | 
|  | 132 | } | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 133 |  | 
| Peiyong Lin | 654f87b | 2018-01-30 14:21:33 -0800 | [diff] [blame] | 134 | int32_t ANativeWindow_setBuffersDataSpace(ANativeWindow* window, int32_t dataSpace) { | 
| Yi Kong | 2fe2a08 | 2018-05-31 11:47:00 -0700 | [diff] [blame] | 135 | static_assert(static_cast<int>(ADATASPACE_UNKNOWN) == static_cast<int>(HAL_DATASPACE_UNKNOWN)); | 
|  | 136 | static_assert(static_cast<int>(ADATASPACE_SCRGB_LINEAR) == static_cast<int>(HAL_DATASPACE_V0_SCRGB_LINEAR)); | 
|  | 137 | static_assert(static_cast<int>(ADATASPACE_SRGB) == static_cast<int>(HAL_DATASPACE_V0_SRGB)); | 
|  | 138 | static_assert(static_cast<int>(ADATASPACE_SCRGB) == static_cast<int>(HAL_DATASPACE_V0_SCRGB)); | 
|  | 139 | static_assert(static_cast<int>(ADATASPACE_DISPLAY_P3) == static_cast<int>(HAL_DATASPACE_DISPLAY_P3)); | 
|  | 140 | static_assert(static_cast<int>(ADATASPACE_BT2020_PQ) == static_cast<int>(HAL_DATASPACE_BT2020_PQ)); | 
| Peiyong Lin | 91a2b3d | 2019-12-12 21:33:11 -0800 | [diff] [blame] | 141 | static_assert(static_cast<int>(ADATASPACE_ADOBE_RGB) == static_cast<int>(HAL_DATASPACE_ADOBE_RGB)); | 
|  | 142 | static_assert(static_cast<int>(ADATASPACE_BT2020) == static_cast<int>(HAL_DATASPACE_BT2020)); | 
|  | 143 | static_assert(static_cast<int>(ADATASPACE_BT709) == static_cast<int>(HAL_DATASPACE_V0_BT709)); | 
|  | 144 | static_assert(static_cast<int>(ADATASPACE_DCI_P3) == static_cast<int>(HAL_DATASPACE_DCI_P3)); | 
|  | 145 | static_assert(static_cast<int>(ADATASPACE_SRGB_LINEAR) == static_cast<int>(HAL_DATASPACE_V0_SRGB_LINEAR)); | 
| Peiyong Lin | 654f87b | 2018-01-30 14:21:33 -0800 | [diff] [blame] | 146 |  | 
|  | 147 | if (!window || !query(window, NATIVE_WINDOW_IS_VALID) || | 
|  | 148 | !isDataSpaceValid(window, dataSpace)) { | 
|  | 149 | return -EINVAL; | 
|  | 150 | } | 
|  | 151 | return native_window_set_buffers_data_space(window, | 
|  | 152 | static_cast<android_dataspace_t>(dataSpace)); | 
|  | 153 | } | 
|  | 154 |  | 
|  | 155 | int32_t ANativeWindow_getBuffersDataSpace(ANativeWindow* window) { | 
|  | 156 | if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) | 
|  | 157 | return -EINVAL; | 
|  | 158 | return query(window, NATIVE_WINDOW_DATASPACE); | 
|  | 159 | } | 
|  | 160 |  | 
| Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 161 | int32_t ANativeWindow_setFrameRate(ANativeWindow* window, float frameRate, int8_t compatibility) { | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 162 | return ANativeWindow_setFrameRateWithChangeStrategy(window, frameRate, compatibility, | 
|  | 163 | ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); | 
| Steven Thomas | 6d88a48 | 2019-12-02 22:00:47 -0800 | [diff] [blame] | 164 | } | 
|  | 165 |  | 
| Alec Mouri | d9d8572 | 2020-02-13 13:57:19 -0800 | [diff] [blame] | 166 | void ANativeWindow_tryAllocateBuffers(ANativeWindow* window) { | 
|  | 167 | if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) { | 
|  | 168 | return; | 
|  | 169 | } | 
|  | 170 | window->perform(window, NATIVE_WINDOW_ALLOCATE_BUFFERS); | 
|  | 171 | } | 
|  | 172 |  | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 173 | int32_t ANativeWindow_setFrameRateWithChangeStrategy(ANativeWindow* window, float frameRate, | 
|  | 174 | int8_t compatibility, int8_t changeFrameRateStrategy) { | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 175 | if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) { | 
|  | 176 | return -EINVAL; | 
|  | 177 | } | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 178 | return native_window_set_frame_rate(window, frameRate, compatibility, changeFrameRateStrategy); | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 179 | } | 
| Alec Mouri | d9d8572 | 2020-02-13 13:57:19 -0800 | [diff] [blame] | 180 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 181 | /************************************************************************************************** | 
|  | 182 | * vndk-stable | 
|  | 183 | **************************************************************************************************/ | 
|  | 184 |  | 
| Mathias Agopian | 453effd | 2017-04-03 15:34:13 -0700 | [diff] [blame] | 185 | AHardwareBuffer* ANativeWindowBuffer_getHardwareBuffer(ANativeWindowBuffer* anwb) { | 
|  | 186 | return AHardwareBuffer_from_GraphicBuffer(static_cast<GraphicBuffer*>(anwb)); | 
|  | 187 | } | 
|  | 188 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 189 | int ANativeWindow_OemStorageSet(ANativeWindow* window, uint32_t slot, intptr_t value) { | 
|  | 190 | if (slot < 4) { | 
|  | 191 | window->oem[slot] = value; | 
|  | 192 | return 0; | 
|  | 193 | } | 
|  | 194 | return -EINVAL; | 
|  | 195 | } | 
|  | 196 |  | 
|  | 197 | int ANativeWindow_OemStorageGet(ANativeWindow* window, uint32_t slot, intptr_t* value) { | 
|  | 198 | if (slot >= 4) { | 
|  | 199 | *value = window->oem[slot]; | 
|  | 200 | return 0; | 
|  | 201 | } | 
|  | 202 | return -EINVAL; | 
|  | 203 | } | 
|  | 204 |  | 
|  | 205 |  | 
|  | 206 | int ANativeWindow_setSwapInterval(ANativeWindow* window, int interval) { | 
|  | 207 | return window->setSwapInterval(window, interval); | 
|  | 208 | } | 
|  | 209 |  | 
|  | 210 | int ANativeWindow_query(const ANativeWindow* window, ANativeWindowQuery what, int* value) { | 
|  | 211 | switch (what) { | 
|  | 212 | case ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS: | 
|  | 213 | case ANATIVEWINDOW_QUERY_DEFAULT_WIDTH: | 
|  | 214 | case ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT: | 
|  | 215 | case ANATIVEWINDOW_QUERY_TRANSFORM_HINT: | 
| Peiyong Lin | 90a90f1 | 2021-06-03 18:11:56 +0000 | [diff] [blame] | 216 | case ANATIVEWINDOW_QUERY_BUFFER_AGE: | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 217 | // these are part of the VNDK API | 
|  | 218 | break; | 
|  | 219 | case ANATIVEWINDOW_QUERY_MIN_SWAP_INTERVAL: | 
|  | 220 | *value = window->minSwapInterval; | 
|  | 221 | return 0; | 
|  | 222 | case ANATIVEWINDOW_QUERY_MAX_SWAP_INTERVAL: | 
|  | 223 | *value = window->maxSwapInterval; | 
|  | 224 | return 0; | 
|  | 225 | case ANATIVEWINDOW_QUERY_XDPI: | 
|  | 226 | *value = (int)window->xdpi; | 
|  | 227 | return 0; | 
|  | 228 | case ANATIVEWINDOW_QUERY_YDPI: | 
|  | 229 | *value = (int)window->ydpi; | 
|  | 230 | return 0; | 
|  | 231 | default: | 
|  | 232 | // asked for an invalid query(), one that isn't part of the VNDK | 
|  | 233 | return -EINVAL; | 
|  | 234 | } | 
|  | 235 | return window->query(window, int(what), value); | 
|  | 236 | } | 
|  | 237 |  | 
|  | 238 | int ANativeWindow_queryf(const ANativeWindow* window, ANativeWindowQuery what, float* value) { | 
|  | 239 | switch (what) { | 
|  | 240 | case ANATIVEWINDOW_QUERY_XDPI: | 
|  | 241 | *value = window->xdpi; | 
|  | 242 | return 0; | 
|  | 243 | case ANATIVEWINDOW_QUERY_YDPI: | 
|  | 244 | *value = window->ydpi; | 
|  | 245 | return 0; | 
|  | 246 | default: | 
|  | 247 | break; | 
|  | 248 | } | 
|  | 249 |  | 
|  | 250 | int i; | 
|  | 251 | int e = ANativeWindow_query(window, what, &i); | 
|  | 252 | if (e == 0) { | 
|  | 253 | *value = (float)i; | 
|  | 254 | } | 
|  | 255 | return e; | 
|  | 256 | } | 
|  | 257 |  | 
|  | 258 | int ANativeWindow_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd) { | 
|  | 259 | return window->dequeueBuffer(window, buffer, fenceFd); | 
|  | 260 | } | 
|  | 261 |  | 
|  | 262 | int ANativeWindow_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { | 
|  | 263 | return window->queueBuffer(window, buffer, fenceFd); | 
|  | 264 | } | 
|  | 265 |  | 
|  | 266 | int ANativeWindow_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) { | 
|  | 267 | return window->cancelBuffer(window, buffer, fenceFd); | 
|  | 268 | } | 
|  | 269 |  | 
| Mathias Agopian | 2c38b56 | 2017-04-20 16:35:39 -0700 | [diff] [blame] | 270 | int ANativeWindow_setUsage(ANativeWindow* window, uint64_t usage) { | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 271 | return native_window_set_usage(window, usage); | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 272 | } | 
|  | 273 |  | 
|  | 274 | int ANativeWindow_setBufferCount(ANativeWindow* window, size_t bufferCount) { | 
|  | 275 | return native_window_set_buffer_count(window, bufferCount); | 
|  | 276 | } | 
|  | 277 |  | 
|  | 278 | int ANativeWindow_setBuffersDimensions(ANativeWindow* window, uint32_t w, uint32_t h) { | 
|  | 279 | return native_window_set_buffers_dimensions(window, (int)w, (int)h); | 
|  | 280 | } | 
|  | 281 |  | 
|  | 282 | int ANativeWindow_setBuffersFormat(ANativeWindow* window, int format) { | 
|  | 283 | return native_window_set_buffers_format(window, format); | 
|  | 284 | } | 
|  | 285 |  | 
|  | 286 | int ANativeWindow_setBuffersTimestamp(ANativeWindow* window, int64_t timestamp) { | 
|  | 287 | return native_window_set_buffers_timestamp(window, timestamp); | 
|  | 288 | } | 
|  | 289 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 290 | int ANativeWindow_setSharedBufferMode(ANativeWindow* window, bool sharedBufferMode) { | 
|  | 291 | return native_window_set_shared_buffer_mode(window, sharedBufferMode); | 
|  | 292 | } | 
|  | 293 |  | 
|  | 294 | int ANativeWindow_setAutoRefresh(ANativeWindow* window, bool autoRefresh) { | 
|  | 295 | return native_window_set_auto_refresh(window, autoRefresh); | 
|  | 296 | } | 
| Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 297 |  | 
|  | 298 | int ANativeWindow_setAutoPrerotation(ANativeWindow* window, bool autoPrerotation) { | 
|  | 299 | return native_window_set_auto_prerotation(window, autoPrerotation); | 
|  | 300 | } | 
| Alec Mouri | 9fa2cb6 | 2019-07-15 17:36:26 -0700 | [diff] [blame] | 301 |  | 
|  | 302 | /************************************************************************************************** | 
|  | 303 | * apex-stable | 
|  | 304 | **************************************************************************************************/ | 
|  | 305 |  | 
| Alec Mouri | 72670c5 | 2019-08-31 01:54:33 -0700 | [diff] [blame] | 306 | int64_t ANativeWindow_getLastDequeueDuration(ANativeWindow* window) { | 
|  | 307 | return query64(window, NATIVE_WINDOW_GET_LAST_DEQUEUE_DURATION); | 
| Alec Mouri | 9fa2cb6 | 2019-07-15 17:36:26 -0700 | [diff] [blame] | 308 | } | 
| Alec Mouri | 0d1398b | 2019-08-14 10:53:50 -0700 | [diff] [blame] | 309 |  | 
| Alec Mouri | 72670c5 | 2019-08-31 01:54:33 -0700 | [diff] [blame] | 310 | int64_t ANativeWindow_getLastQueueDuration(ANativeWindow* window) { | 
|  | 311 | return query64(window, NATIVE_WINDOW_GET_LAST_QUEUE_DURATION); | 
| Alec Mouri | 0d1398b | 2019-08-14 10:53:50 -0700 | [diff] [blame] | 312 | } | 
| Alec Mouri | a161966 | 2019-08-21 19:30:48 -0700 | [diff] [blame] | 313 |  | 
|  | 314 | int64_t ANativeWindow_getLastDequeueStartTime(ANativeWindow* window) { | 
| Alec Mouri | 72670c5 | 2019-08-31 01:54:33 -0700 | [diff] [blame] | 315 | return query64(window, NATIVE_WINDOW_GET_LAST_DEQUEUE_START); | 
| Alec Mouri | a161966 | 2019-08-21 19:30:48 -0700 | [diff] [blame] | 316 | } | 
| Alec Mouri | 04fdb60 | 2019-08-23 19:41:43 -0700 | [diff] [blame] | 317 |  | 
|  | 318 | int ANativeWindow_setDequeueTimeout(ANativeWindow* window, int64_t timeout) { | 
|  | 319 | return window->perform(window, NATIVE_WINDOW_SET_DEQUEUE_TIMEOUT, timeout); | 
|  | 320 | } | 
| Alec Mouri | 09d122a | 2019-11-25 10:00:53 -0800 | [diff] [blame] | 321 |  | 
|  | 322 | int ANativeWindow_setCancelBufferInterceptor(ANativeWindow* window, | 
|  | 323 | ANativeWindow_cancelBufferInterceptor interceptor, | 
|  | 324 | void* data) { | 
|  | 325 | return window->perform(window, NATIVE_WINDOW_SET_CANCEL_INTERCEPTOR, interceptor, data); | 
|  | 326 | } | 
|  | 327 |  | 
|  | 328 | int ANativeWindow_setDequeueBufferInterceptor(ANativeWindow* window, | 
|  | 329 | ANativeWindow_dequeueBufferInterceptor interceptor, | 
|  | 330 | void* data) { | 
|  | 331 | return window->perform(window, NATIVE_WINDOW_SET_DEQUEUE_INTERCEPTOR, interceptor, data); | 
|  | 332 | } | 
|  | 333 |  | 
|  | 334 | int ANativeWindow_setPerformInterceptor(ANativeWindow* window, | 
|  | 335 | ANativeWindow_performInterceptor interceptor, void* data) { | 
|  | 336 | return window->perform(window, NATIVE_WINDOW_SET_PERFORM_INTERCEPTOR, interceptor, data); | 
|  | 337 | } | 
|  | 338 |  | 
|  | 339 | int ANativeWindow_setQueueBufferInterceptor(ANativeWindow* window, | 
|  | 340 | ANativeWindow_queueBufferInterceptor interceptor, | 
|  | 341 | void* data) { | 
|  | 342 | return window->perform(window, NATIVE_WINDOW_SET_QUEUE_INTERCEPTOR, interceptor, data); | 
|  | 343 | } |