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
19 #include <grallocusage/GrallocUsageConversion.h>
20 // from nativewindow/includes/system/window.h
21 // (not to be confused with the compatibility-only window.h from system/core/includes)
22 #include <system/window.h>
23 #include <android/native_window_aidl.h>
24
25 #include <private/android/AHardwareBufferHelpers.h>
26
27 #include <android/binder_libbinder.h>
28 #include <dlfcn.h>
29 #include <log/log.h>
30 #include <ui/GraphicBuffer.h>
31
32 using namespace android;
33
34 #if defined(__ANDROID_APEX__) || defined(__ANDROID_VNDK__)
35 #error libnativewindow can only be built for system
36 #endif
37
38 using android_view_Surface_writeToParcel = status_t (*)(ANativeWindow* _Nonnull window,
39 Parcel* _Nonnull parcel);
40
41 using android_view_Surface_readFromParcel =
42 status_t (*)(const Parcel* _Nonnull parcel, ANativeWindow* _Nullable* _Nonnull outWindow);
43
44 struct SurfaceParcelables {
45 android_view_Surface_writeToParcel write = nullptr;
46 android_view_Surface_readFromParcel read = nullptr;
47 };
48
getSurfaceParcelFunctions()49 const SurfaceParcelables* getSurfaceParcelFunctions() {
50 static SurfaceParcelables funcs = []() -> SurfaceParcelables {
51 SurfaceParcelables ret;
52 void* dl = dlopen("libgui.so", RTLD_NOW);
53 LOG_ALWAYS_FATAL_IF(!dl, "Failed to find libgui.so");
54 ret.write =
55 (android_view_Surface_writeToParcel)dlsym(dl, "android_view_Surface_writeToParcel");
56 LOG_ALWAYS_FATAL_IF(!ret.write,
57 "libgui.so missing android_view_Surface_writeToParcel; "
58 "loaded wrong libgui?");
59 ret.read =
60 (android_view_Surface_readFromParcel)dlsym(dl,
61 "android_view_Surface_readFromParcel");
62 LOG_ALWAYS_FATAL_IF(!ret.read,
63 "libgui.so missing android_view_Surface_readFromParcel; "
64 "loaded wrong libgui?");
65 return ret;
66 }();
67 return &funcs;
68 }
69
query(ANativeWindow * window,int what)70 static int32_t query(ANativeWindow* window, int what) {
71 int value;
72 int res = window->query(window, what, &value);
73 return res < 0 ? res : value;
74 }
75
query64(ANativeWindow * window,int what)76 static int64_t query64(ANativeWindow* window, int what) {
77 int64_t value;
78 int res = window->perform(window, what, &value);
79 return res < 0 ? res : value;
80 }
81
82 /**************************************************************************************************
83 * NDK
84 **************************************************************************************************/
85
ANativeWindow_acquire(ANativeWindow * window)86 void ANativeWindow_acquire(ANativeWindow* window) {
87 // incStrong/decStrong token must be the same, doesn't matter what it is
88 window->incStrong((void*)ANativeWindow_acquire);
89 }
90
ANativeWindow_release(ANativeWindow * window)91 void ANativeWindow_release(ANativeWindow* window) {
92 // incStrong/decStrong token must be the same, doesn't matter what it is
93 window->decStrong((void*)ANativeWindow_acquire);
94 }
95
ANativeWindow_getWidth(ANativeWindow * window)96 int32_t ANativeWindow_getWidth(ANativeWindow* window) {
97 return query(window, NATIVE_WINDOW_WIDTH);
98 }
99
ANativeWindow_getHeight(ANativeWindow * window)100 int32_t ANativeWindow_getHeight(ANativeWindow* window) {
101 return query(window, NATIVE_WINDOW_HEIGHT);
102 }
103
ANativeWindow_getFormat(ANativeWindow * window)104 int32_t ANativeWindow_getFormat(ANativeWindow* window) {
105 return query(window, NATIVE_WINDOW_FORMAT);
106 }
107
ANativeWindow_setBuffersGeometry(ANativeWindow * window,int32_t width,int32_t height,int32_t format)108 int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window,
109 int32_t width, int32_t height, int32_t format) {
110 int32_t err = native_window_set_buffers_format(window, format);
111 if (!err) {
112 err = native_window_set_buffers_user_dimensions(window, width, height);
113 if (!err) {
114 int mode = NATIVE_WINDOW_SCALING_MODE_FREEZE;
115 if (width && height) {
116 mode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW;
117 }
118 err = native_window_set_scaling_mode(window, mode);
119 }
120 }
121 return err;
122 }
123
ANativeWindow_lock(ANativeWindow * window,ANativeWindow_Buffer * outBuffer,ARect * inOutDirtyBounds)124 int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer,
125 ARect* inOutDirtyBounds) {
126 return window->perform(window, NATIVE_WINDOW_LOCK, outBuffer, inOutDirtyBounds);
127 }
128
ANativeWindow_unlockAndPost(ANativeWindow * window)129 int32_t ANativeWindow_unlockAndPost(ANativeWindow* window) {
130 return window->perform(window, NATIVE_WINDOW_UNLOCK_AND_POST);
131 }
132
ANativeWindow_setBuffersTransform(ANativeWindow * window,int32_t transform)133 int32_t ANativeWindow_setBuffersTransform(ANativeWindow* window, int32_t transform) {
134 static_assert(ANATIVEWINDOW_TRANSFORM_MIRROR_HORIZONTAL == NATIVE_WINDOW_TRANSFORM_FLIP_H);
135 static_assert(ANATIVEWINDOW_TRANSFORM_MIRROR_VERTICAL == NATIVE_WINDOW_TRANSFORM_FLIP_V);
136 static_assert(ANATIVEWINDOW_TRANSFORM_ROTATE_90 == NATIVE_WINDOW_TRANSFORM_ROT_90);
137
138 constexpr int32_t kAllTransformBits =
139 ANATIVEWINDOW_TRANSFORM_MIRROR_HORIZONTAL |
140 ANATIVEWINDOW_TRANSFORM_MIRROR_VERTICAL |
141 ANATIVEWINDOW_TRANSFORM_ROTATE_90 |
142 // We don't expose INVERSE_DISPLAY as an NDK constant, but someone could have read it
143 // from a buffer already set by Camera framework, so we allow it to be forwarded.
144 NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
145 if (!window || !query(window, NATIVE_WINDOW_IS_VALID))
146 return -EINVAL;
147 if ((transform & ~kAllTransformBits) != 0)
148 return -EINVAL;
149
150 return native_window_set_buffers_transform(window, transform);
151 }
152
ANativeWindow_setBuffersDataSpace(ANativeWindow * window,int32_t dataSpace)153 int32_t ANativeWindow_setBuffersDataSpace(ANativeWindow* window, int32_t dataSpace) {
154 static_assert(static_cast<int>(ADATASPACE_UNKNOWN) == static_cast<int>(HAL_DATASPACE_UNKNOWN));
155 static_assert(static_cast<int>(ADATASPACE_STANDARD_MASK) ==
156 static_cast<int>(HAL_DATASPACE_STANDARD_MASK));
157 static_assert(static_cast<int>(ADATASPACE_STANDARD_UNSPECIFIED) ==
158 static_cast<int>(HAL_DATASPACE_STANDARD_UNSPECIFIED));
159 static_assert(static_cast<int>(ADATASPACE_STANDARD_BT709) ==
160 static_cast<int>(HAL_DATASPACE_STANDARD_BT709));
161 static_assert(static_cast<int>(ADATASPACE_STANDARD_BT601_625) ==
162 static_cast<int>(HAL_DATASPACE_STANDARD_BT601_625));
163 static_assert(static_cast<int>(ADATASPACE_STANDARD_BT601_625_UNADJUSTED) ==
164 static_cast<int>(HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED));
165 static_assert(static_cast<int>(ADATASPACE_STANDARD_BT601_525) ==
166 static_cast<int>(HAL_DATASPACE_STANDARD_BT601_525));
167 static_assert(static_cast<int>(ADATASPACE_STANDARD_BT601_525_UNADJUSTED) ==
168 static_cast<int>(HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED));
169 static_assert(static_cast<int>(ADATASPACE_STANDARD_BT470M) ==
170 static_cast<int>(HAL_DATASPACE_STANDARD_BT470M));
171 static_assert(static_cast<int>(ADATASPACE_STANDARD_FILM) ==
172 static_cast<int>(HAL_DATASPACE_STANDARD_FILM));
173 static_assert(static_cast<int>(ADATASPACE_STANDARD_DCI_P3) ==
174 static_cast<int>(HAL_DATASPACE_STANDARD_DCI_P3));
175 static_assert(static_cast<int>(ADATASPACE_STANDARD_ADOBE_RGB) ==
176 static_cast<int>(HAL_DATASPACE_STANDARD_ADOBE_RGB));
177 static_assert(static_cast<int>(ADATASPACE_TRANSFER_MASK) ==
178 static_cast<int>(HAL_DATASPACE_TRANSFER_MASK));
179 static_assert(static_cast<int>(ADATASPACE_TRANSFER_UNSPECIFIED) ==
180 static_cast<int>(HAL_DATASPACE_TRANSFER_UNSPECIFIED));
181 static_assert(static_cast<int>(ADATASPACE_TRANSFER_LINEAR) ==
182 static_cast<int>(HAL_DATASPACE_TRANSFER_LINEAR));
183 static_assert(static_cast<int>(ADATASPACE_TRANSFER_SMPTE_170M) ==
184 static_cast<int>(HAL_DATASPACE_TRANSFER_SMPTE_170M));
185 static_assert(static_cast<int>(ADATASPACE_TRANSFER_GAMMA2_2) ==
186 static_cast<int>(HAL_DATASPACE_TRANSFER_GAMMA2_2));
187 static_assert(static_cast<int>(ADATASPACE_TRANSFER_GAMMA2_6) ==
188 static_cast<int>(HAL_DATASPACE_TRANSFER_GAMMA2_6));
189 static_assert(static_cast<int>(ADATASPACE_TRANSFER_GAMMA2_8) ==
190 static_cast<int>(HAL_DATASPACE_TRANSFER_GAMMA2_8));
191 static_assert(static_cast<int>(ADATASPACE_TRANSFER_ST2084) ==
192 static_cast<int>(HAL_DATASPACE_TRANSFER_ST2084));
193 static_assert(static_cast<int>(ADATASPACE_TRANSFER_HLG) ==
194 static_cast<int>(HAL_DATASPACE_TRANSFER_HLG));
195 static_assert(static_cast<int>(ADATASPACE_RANGE_MASK) ==
196 static_cast<int>(HAL_DATASPACE_RANGE_MASK));
197 static_assert(static_cast<int>(ADATASPACE_RANGE_UNSPECIFIED) ==
198 static_cast<int>(HAL_DATASPACE_RANGE_UNSPECIFIED));
199 static_assert(static_cast<int>(ADATASPACE_RANGE_FULL) ==
200 static_cast<int>(HAL_DATASPACE_RANGE_FULL));
201 static_assert(static_cast<int>(ADATASPACE_RANGE_LIMITED) ==
202 static_cast<int>(HAL_DATASPACE_RANGE_LIMITED));
203 static_assert(static_cast<int>(ADATASPACE_RANGE_EXTENDED) ==
204 static_cast<int>(HAL_DATASPACE_RANGE_EXTENDED));
205 static_assert(static_cast<int>(ADATASPACE_SRGB) == static_cast<int>(HAL_DATASPACE_V0_SRGB));
206 static_assert(static_cast<int>(ADATASPACE_SCRGB) == static_cast<int>(HAL_DATASPACE_V0_SCRGB));
207 static_assert(static_cast<int>(ADATASPACE_DISPLAY_P3) == static_cast<int>(HAL_DATASPACE_DISPLAY_P3));
208 static_assert(static_cast<int>(ADATASPACE_BT2020_PQ) == static_cast<int>(HAL_DATASPACE_BT2020_PQ));
209 static_assert(static_cast<int>(ADATASPACE_BT2020_ITU_PQ) ==
210 static_cast<int>(HAL_DATASPACE_BT2020_ITU_PQ));
211 static_assert(static_cast<int>(ADATASPACE_ADOBE_RGB) == static_cast<int>(HAL_DATASPACE_ADOBE_RGB));
212 static_assert(static_cast<int>(ADATASPACE_JFIF) == static_cast<int>(HAL_DATASPACE_V0_JFIF));
213 static_assert(static_cast<int>(ADATASPACE_BT601_625) == static_cast<int>(HAL_DATASPACE_V0_BT601_625));
214 static_assert(static_cast<int>(ADATASPACE_BT601_525) == static_cast<int>(HAL_DATASPACE_V0_BT601_525));
215 static_assert(static_cast<int>(ADATASPACE_BT2020) == static_cast<int>(HAL_DATASPACE_BT2020));
216 static_assert(static_cast<int>(ADATASPACE_BT709) == static_cast<int>(HAL_DATASPACE_V0_BT709));
217 static_assert(static_cast<int>(ADATASPACE_DCI_P3) == static_cast<int>(HAL_DATASPACE_DCI_P3));
218 static_assert(static_cast<int>(ADATASPACE_SRGB_LINEAR) == static_cast<int>(HAL_DATASPACE_V0_SRGB_LINEAR));
219 static_assert(static_cast<int>(ADATASPACE_BT2020_HLG) ==
220 static_cast<int>(HAL_DATASPACE_BT2020_HLG));
221 static_assert(static_cast<int>(ADATASPACE_BT2020_ITU_HLG) ==
222 static_cast<int>(HAL_DATASPACE_BT2020_ITU_HLG));
223 static_assert(static_cast<int>(ADATASPACE_DEPTH) == static_cast<int>(HAL_DATASPACE_DEPTH));
224 static_assert(static_cast<int>(ADATASPACE_DYNAMIC_DEPTH) == static_cast<int>(HAL_DATASPACE_DYNAMIC_DEPTH));
225
226 if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) {
227 return -EINVAL;
228 }
229 return native_window_set_buffers_data_space(window,
230 static_cast<android_dataspace_t>(dataSpace));
231 }
232
ANativeWindow_getBuffersDataSpace(ANativeWindow * window)233 int32_t ANativeWindow_getBuffersDataSpace(ANativeWindow* window) {
234 if (!window || !query(window, NATIVE_WINDOW_IS_VALID))
235 return -EINVAL;
236 return query(window, NATIVE_WINDOW_DATASPACE);
237 }
238
ANativeWindow_getBuffersDefaultDataSpace(ANativeWindow * window)239 int32_t ANativeWindow_getBuffersDefaultDataSpace(ANativeWindow* window) {
240 if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) {
241 return -EINVAL;
242 }
243 return query(window, NATIVE_WINDOW_DEFAULT_DATASPACE);
244 }
245
ANativeWindow_setFrameRate(ANativeWindow * window,float frameRate,int8_t compatibility)246 int32_t ANativeWindow_setFrameRate(ANativeWindow* window, float frameRate, int8_t compatibility) {
247 return ANativeWindow_setFrameRateWithChangeStrategy(window, frameRate, compatibility,
248 ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS);
249 }
250
ANativeWindow_tryAllocateBuffers(ANativeWindow * window)251 void ANativeWindow_tryAllocateBuffers(ANativeWindow* window) {
252 if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) {
253 return;
254 }
255 window->perform(window, NATIVE_WINDOW_ALLOCATE_BUFFERS);
256 }
257
ANativeWindow_setFrameRateWithChangeStrategy(ANativeWindow * window,float frameRate,int8_t compatibility,int8_t changeFrameRateStrategy)258 int32_t ANativeWindow_setFrameRateWithChangeStrategy(ANativeWindow* window, float frameRate,
259 int8_t compatibility, int8_t changeFrameRateStrategy) {
260 if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) {
261 return -EINVAL;
262 }
263 return native_window_set_frame_rate(window, frameRate, compatibility, changeFrameRateStrategy);
264 }
265
266 /**************************************************************************************************
267 * vndk-stable
268 **************************************************************************************************/
269
ANativeWindowBuffer_getHardwareBuffer(ANativeWindowBuffer * anwb)270 AHardwareBuffer* ANativeWindowBuffer_getHardwareBuffer(ANativeWindowBuffer* anwb) {
271 return AHardwareBuffer_from_GraphicBuffer(static_cast<GraphicBuffer*>(anwb));
272 }
273
ANativeWindow_OemStorageSet(ANativeWindow * window,uint32_t slot,intptr_t value)274 int ANativeWindow_OemStorageSet(ANativeWindow* window, uint32_t slot, intptr_t value) {
275 if (slot < 4) {
276 window->oem[slot] = value;
277 return 0;
278 }
279 return -EINVAL;
280 }
281
ANativeWindow_OemStorageGet(ANativeWindow * window,uint32_t slot,intptr_t * value)282 int ANativeWindow_OemStorageGet(ANativeWindow* window, uint32_t slot, intptr_t* value) {
283 if (slot >= 4) {
284 *value = window->oem[slot];
285 return 0;
286 }
287 return -EINVAL;
288 }
289
290
ANativeWindow_setSwapInterval(ANativeWindow * window,int interval)291 int ANativeWindow_setSwapInterval(ANativeWindow* window, int interval) {
292 return window->setSwapInterval(window, interval);
293 }
294
ANativeWindow_query(const ANativeWindow * window,ANativeWindowQuery what,int * value)295 int ANativeWindow_query(const ANativeWindow* window, ANativeWindowQuery what, int* value) {
296 switch (what) {
297 case ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS:
298 case ANATIVEWINDOW_QUERY_DEFAULT_WIDTH:
299 case ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT:
300 case ANATIVEWINDOW_QUERY_TRANSFORM_HINT:
301 case ANATIVEWINDOW_QUERY_BUFFER_AGE:
302 // these are part of the VNDK API
303 break;
304 case ANATIVEWINDOW_QUERY_MIN_SWAP_INTERVAL:
305 *value = window->minSwapInterval;
306 return 0;
307 case ANATIVEWINDOW_QUERY_MAX_SWAP_INTERVAL:
308 *value = window->maxSwapInterval;
309 return 0;
310 case ANATIVEWINDOW_QUERY_XDPI:
311 *value = (int)window->xdpi;
312 return 0;
313 case ANATIVEWINDOW_QUERY_YDPI:
314 *value = (int)window->ydpi;
315 return 0;
316 default:
317 // asked for an invalid query(), one that isn't part of the VNDK
318 return -EINVAL;
319 }
320 return window->query(window, int(what), value);
321 }
322
ANativeWindow_queryf(const ANativeWindow * window,ANativeWindowQuery what,float * value)323 int ANativeWindow_queryf(const ANativeWindow* window, ANativeWindowQuery what, float* value) {
324 switch (what) {
325 case ANATIVEWINDOW_QUERY_XDPI:
326 *value = window->xdpi;
327 return 0;
328 case ANATIVEWINDOW_QUERY_YDPI:
329 *value = window->ydpi;
330 return 0;
331 default:
332 break;
333 }
334
335 int i;
336 int e = ANativeWindow_query(window, what, &i);
337 if (e == 0) {
338 *value = (float)i;
339 }
340 return e;
341 }
342
ANativeWindow_dequeueBuffer(ANativeWindow * window,ANativeWindowBuffer ** buffer,int * fenceFd)343 int ANativeWindow_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd) {
344 return window->dequeueBuffer(window, buffer, fenceFd);
345 }
346
ANativeWindow_queueBuffer(ANativeWindow * window,ANativeWindowBuffer * buffer,int fenceFd)347 int ANativeWindow_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) {
348 return window->queueBuffer(window, buffer, fenceFd);
349 }
350
ANativeWindow_cancelBuffer(ANativeWindow * window,ANativeWindowBuffer * buffer,int fenceFd)351 int ANativeWindow_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd) {
352 return window->cancelBuffer(window, buffer, fenceFd);
353 }
354
ANativeWindow_setUsage(ANativeWindow * window,uint64_t usage)355 int ANativeWindow_setUsage(ANativeWindow* window, uint64_t usage) {
356 return native_window_set_usage(window, usage);
357 }
358
ANativeWindow_setBufferCount(ANativeWindow * window,size_t bufferCount)359 int ANativeWindow_setBufferCount(ANativeWindow* window, size_t bufferCount) {
360 return native_window_set_buffer_count(window, bufferCount);
361 }
362
ANativeWindow_setBuffersDimensions(ANativeWindow * window,uint32_t w,uint32_t h)363 int ANativeWindow_setBuffersDimensions(ANativeWindow* window, uint32_t w, uint32_t h) {
364 return native_window_set_buffers_dimensions(window, (int)w, (int)h);
365 }
366
ANativeWindow_setBuffersFormat(ANativeWindow * window,int format)367 int ANativeWindow_setBuffersFormat(ANativeWindow* window, int format) {
368 return native_window_set_buffers_format(window, format);
369 }
370
ANativeWindow_setBuffersTimestamp(ANativeWindow * window,int64_t timestamp)371 int ANativeWindow_setBuffersTimestamp(ANativeWindow* window, int64_t timestamp) {
372 return native_window_set_buffers_timestamp(window, timestamp);
373 }
374
ANativeWindow_setSharedBufferMode(ANativeWindow * window,bool sharedBufferMode)375 int ANativeWindow_setSharedBufferMode(ANativeWindow* window, bool sharedBufferMode) {
376 return native_window_set_shared_buffer_mode(window, sharedBufferMode);
377 }
378
ANativeWindow_setAutoRefresh(ANativeWindow * window,bool autoRefresh)379 int ANativeWindow_setAutoRefresh(ANativeWindow* window, bool autoRefresh) {
380 return native_window_set_auto_refresh(window, autoRefresh);
381 }
382
ANativeWindow_setAutoPrerotation(ANativeWindow * window,bool autoPrerotation)383 int ANativeWindow_setAutoPrerotation(ANativeWindow* window, bool autoPrerotation) {
384 return native_window_set_auto_prerotation(window, autoPrerotation);
385 }
386
ANativeWindow_readFromParcel(const AParcel * _Nonnull parcel,ANativeWindow * _Nullable * _Nonnull outWindow)387 binder_status_t ANativeWindow_readFromParcel(
388 const AParcel* _Nonnull parcel, ANativeWindow* _Nullable* _Nonnull outWindow) {
389 auto funcs = getSurfaceParcelFunctions();
390 if (funcs->read == nullptr) {
391 ALOGE("Failed to load Surface_readFromParcel implementation");
392 return STATUS_FAILED_TRANSACTION;
393 }
394 const Parcel* nativeParcel = AParcel_viewPlatformParcel(parcel);
395 return funcs->read(nativeParcel, outWindow);
396 }
397
ANativeWindow_writeToParcel(ANativeWindow * _Nonnull window,AParcel * _Nonnull parcel)398 binder_status_t ANativeWindow_writeToParcel(
399 ANativeWindow* _Nonnull window, AParcel* _Nonnull parcel) {
400 auto funcs = getSurfaceParcelFunctions();
401 if (funcs->write == nullptr) {
402 ALOGE("Failed to load Surface_writeToParcel implementation");
403 return STATUS_FAILED_TRANSACTION;
404 }
405 Parcel* nativeParcel = AParcel_viewPlatformParcel(parcel);
406 return funcs->write(window, nativeParcel);
407 }
408
409 /**************************************************************************************************
410 * apex-stable
411 **************************************************************************************************/
412
ANativeWindow_getLastDequeueDuration(ANativeWindow * window)413 int64_t ANativeWindow_getLastDequeueDuration(ANativeWindow* window) {
414 return query64(window, NATIVE_WINDOW_GET_LAST_DEQUEUE_DURATION);
415 }
416
ANativeWindow_getLastQueueDuration(ANativeWindow * window)417 int64_t ANativeWindow_getLastQueueDuration(ANativeWindow* window) {
418 return query64(window, NATIVE_WINDOW_GET_LAST_QUEUE_DURATION);
419 }
420
ANativeWindow_getLastDequeueStartTime(ANativeWindow * window)421 int64_t ANativeWindow_getLastDequeueStartTime(ANativeWindow* window) {
422 return query64(window, NATIVE_WINDOW_GET_LAST_DEQUEUE_START);
423 }
424
ANativeWindow_setDequeueTimeout(ANativeWindow * window,int64_t timeout)425 int ANativeWindow_setDequeueTimeout(ANativeWindow* window, int64_t timeout) {
426 return window->perform(window, NATIVE_WINDOW_SET_DEQUEUE_TIMEOUT, timeout);
427 }
428
ANativeWindow_setCancelBufferInterceptor(ANativeWindow * window,ANativeWindow_cancelBufferInterceptor interceptor,void * data)429 int ANativeWindow_setCancelBufferInterceptor(ANativeWindow* window,
430 ANativeWindow_cancelBufferInterceptor interceptor,
431 void* data) {
432 return window->perform(window, NATIVE_WINDOW_SET_CANCEL_INTERCEPTOR, interceptor, data);
433 }
434
ANativeWindow_setDequeueBufferInterceptor(ANativeWindow * window,ANativeWindow_dequeueBufferInterceptor interceptor,void * data)435 int ANativeWindow_setDequeueBufferInterceptor(ANativeWindow* window,
436 ANativeWindow_dequeueBufferInterceptor interceptor,
437 void* data) {
438 return window->perform(window, NATIVE_WINDOW_SET_DEQUEUE_INTERCEPTOR, interceptor, data);
439 }
440
ANativeWindow_setPerformInterceptor(ANativeWindow * window,ANativeWindow_performInterceptor interceptor,void * data)441 int ANativeWindow_setPerformInterceptor(ANativeWindow* window,
442 ANativeWindow_performInterceptor interceptor, void* data) {
443 return window->perform(window, NATIVE_WINDOW_SET_PERFORM_INTERCEPTOR, interceptor, data);
444 }
445
ANativeWindow_setQueueBufferInterceptor(ANativeWindow * window,ANativeWindow_queueBufferInterceptor interceptor,void * data)446 int ANativeWindow_setQueueBufferInterceptor(ANativeWindow* window,
447 ANativeWindow_queueBufferInterceptor interceptor,
448 void* data) {
449 return window->perform(window, NATIVE_WINDOW_SET_QUEUE_INTERCEPTOR, interceptor, data);
450 }
451