134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Copyright (C) 2011 The Android Open Source Project
334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * you may not use this file except in compliance with the License.
634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * You may obtain a copy of the License at
734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
1034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Unless required by applicable law or agreed to in writing, software
1134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
1234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * See the License for the specific language governing permissions and
1434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * limitations under the License.
1534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
1634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
1734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/**************************************************************************************************
1834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian **************************************************************************************************
1934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****                                                                                          ****
2034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****  DEPRECATED                                                                              ****
2134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****                                                                                          ****
2234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****  THIS FILE EXISTS ONLY FOR BACKWARD SOURCE COMPATIBILITY.                                ****
2334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****                                                                                          ****
2434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****  DO NOT ADD TO THIS FILE.                                                                ****
2534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****                                                                                          ****
2634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****  Driver implementors (vendors) should use vndk/window.h                                  ****
2734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****  (frameworks/native/libs/nativewindow/include/vndk/window.h)                             ****
2834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****                                                                                          ****
2934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****  Internal definition can be found here:                                                  ****
3034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****  frameworks/native/libs/nativewindow/include/system/window.h                             ****
3134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian ****                                                                                          ****
3234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian **************************************************************************************************
3334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian **************************************************************************************************/
3434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
35b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland#pragma once
36b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland
3734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <cutils/native_handle.h>
3834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <errno.h>
3934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <limits.h>
4034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <stdint.h>
4134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <string.h>
4234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <sys/cdefs.h>
4334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <system/graphics.h>
4434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <unistd.h>
4534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#include <stdbool.h>
4634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
4734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#ifndef __UNUSED
4834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#define __UNUSED __attribute__((__unused__))
4934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#endif
5034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#ifndef __deprecated
5134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#define __deprecated __attribute__((__deprecated__))
5234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#endif
5334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
5434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian__BEGIN_DECLS
5534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
5634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*****************************************************************************/
5734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
5834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#ifdef __cplusplus
5934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#define ANDROID_NATIVE_UNSIGNED_CAST(x) static_cast<unsigned int>(x)
6034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#else
6134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#define ANDROID_NATIVE_UNSIGNED_CAST(x) ((unsigned int)(x))
6234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#endif
6334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
6434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
6534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    ((ANDROID_NATIVE_UNSIGNED_CAST(a) << 24) | \
6634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     (ANDROID_NATIVE_UNSIGNED_CAST(b) << 16) | \
6734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     (ANDROID_NATIVE_UNSIGNED_CAST(c) << 8) | \
6834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     (ANDROID_NATIVE_UNSIGNED_CAST(d)))
6934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
7034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#define ANDROID_NATIVE_WINDOW_MAGIC \
7134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
7234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
7334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#define ANDROID_NATIVE_BUFFER_MAGIC \
7434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
7534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
7634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// ---------------------------------------------------------------------------
7734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
7834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// This #define may be used to conditionally compile device-specific code to
7934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// support either the prior ANativeWindow interface, which did not pass libsync
8034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// fences around, or the new interface that does.  This #define is only present
8134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// when the ANativeWindow interface does include libsync support.
8234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1
8334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
8434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// ---------------------------------------------------------------------------
8534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
8634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopiantypedef const native_handle_t* buffer_handle_t;
8734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
8834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// ---------------------------------------------------------------------------
8934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
9034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopiantypedef struct android_native_rect_t
9134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
9234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int32_t left;
9334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int32_t top;
9434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int32_t right;
9534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int32_t bottom;
9634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian} android_native_rect_t;
9734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
9834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// ---------------------------------------------------------------------------
9934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
10034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopiantypedef struct android_native_base_t
10134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
10234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* a magic value defined by the actual EGL native type */
10334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int magic;
10434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
10534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* the sizeof() of the actual EGL native type */
10634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int version;
10734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
10834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void* reserved[4];
10934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
11034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* reference-counting interface */
11134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void (*incRef)(struct android_native_base_t* base);
11234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void (*decRef)(struct android_native_base_t* base);
11334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian} android_native_base_t;
11434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
11534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopiantypedef struct ANativeWindowBuffer
11634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
11734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#ifdef __cplusplus
11834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    ANativeWindowBuffer() {
11934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
12034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        common.version = sizeof(ANativeWindowBuffer);
12134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        memset(common.reserved, 0, sizeof(common.reserved));
12234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    }
12334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
12434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    // Implement the methods that sp<ANativeWindowBuffer> expects so that it
12534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    // can be used to automatically refcount ANativeWindowBuffer's.
12634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void incStrong(const void* /*id*/) const {
12734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        common.incRef(const_cast<android_native_base_t*>(&common));
12834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    }
12934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void decStrong(const void* /*id*/) const {
13034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        common.decRef(const_cast<android_native_base_t*>(&common));
13134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    }
13234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#endif
13334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
13434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    struct android_native_base_t common;
13534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
13634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int width;
13734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int height;
13834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int stride;
13934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int format;
14034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int usage;
14134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    uintptr_t layerCount;
14234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
14334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void* reserved[1];
14434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
14534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    buffer_handle_t handle;
14634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
14734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void* reserved_proc[8];
14834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian} ANativeWindowBuffer_t;
14934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
15034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// Old typedef for backwards compatibility.
15134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopiantypedef ANativeWindowBuffer_t android_native_buffer_t;
15234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
15334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// ---------------------------------------------------------------------------
15434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
15534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* attributes queriable with query() */
15634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianenum {
15734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_WIDTH     = 0,
15834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_HEIGHT    = 1,
15934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_FORMAT    = 2,
16034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
16134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* The minimum number of buffers that must remain un-dequeued after a buffer
16234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * has been queued.  This value applies only if set_buffer_count was used to
16334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * override the number of buffers and if a buffer has since been queued.
16434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Users of the set_buffer_count ANativeWindow method should query this
16534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * value before calling set_buffer_count.  If it is necessary to have N
16634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * buffers simultaneously dequeued as part of the steady-state operation,
16734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * and this query returns M then N+M buffers should be requested via
16834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * native_window_set_buffer_count.
16934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
17034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Note that this value does NOT apply until a single buffer has been
17134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * queued.  In particular this means that it is possible to:
17234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
17334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 1. Query M = min undequeued buffers
17434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 2. Set the buffer count to N + M
17534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 3. Dequeue all N + M buffers
17634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 4. Cancel M buffers
17734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 5. Queue, dequeue, queue, dequeue, ad infinitum
17834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
17934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
18034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
18134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* Check whether queueBuffer operations on the ANativeWindow send the buffer
18234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * to the window compositor.  The query sets the returned 'value' argument
18334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * to 1 if the ANativeWindow DOES send queued buffers directly to the window
18434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * compositor and 0 if the buffers do not go directly to the window
18534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * compositor.
18634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
18734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * This can be used to determine whether protected buffer content should be
18834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * sent to the ANativeWindow.  Note, however, that a result of 1 does NOT
18934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * indicate that queued buffers will be protected from applications or users
19034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * capturing their contents.  If that behavior is desired then some other
19134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
19234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * conjunction with this query.
19334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
19434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
19534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
19634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* Get the concrete type of a ANativeWindow.  See below for the list of
19734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * possible return values.
19834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
19934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * This query should not be used outside the Android framework and will
20034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * likely be removed in the near future.
20134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
20234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_CONCRETE_TYPE = 5,
20334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
20434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
20534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
20634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Default width and height of ANativeWindow buffers, these are the
20734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * dimensions of the window buffers irrespective of the
20834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
20934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
21034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
21134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_DEFAULT_WIDTH = 6,
21234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
21334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
21434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
21534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * transformation that will most-likely be applied to buffers. This is only
21634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * a hint, the actual transformation applied might be different.
21734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
21834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * INTENDED USE:
21934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
22034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The transform hint can be used by a producer, for instance the GLES
22134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * driver, to pre-rotate the rendering such that the final transformation
22234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * in the composer is identity. This can be very useful when used in
22334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * conjunction with the h/w composer HAL, in situations where it
22434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * cannot handle arbitrary rotations.
22534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
22634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
22734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
22834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
22934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 2. The GL driver overrides the width and height of the ANW to
23034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
23134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
23234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    according to NATIVE_WINDOW_TRANSFORM_HINT and calling
23334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    native_window_set_buffers_dimensions().
23434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
23534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 3. The GL driver dequeues a buffer of the new pre-rotated size.
23634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
23734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 4. The GL driver renders to the buffer such that the image is
23834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
23934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    to the rendering.
24034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
24134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 5. The GL driver calls native_window_set_transform to apply
24234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    inverse transformation to the buffer it just rendered.
24334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    In order to do this, the GL driver needs
24434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
24534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    done easily:
24634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
24734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *        int hintTransform, inverseTransform;
24834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *        query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
24934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *        inverseTransform = hintTransform;
25034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *        if (hintTransform & HAL_TRANSFORM_ROT_90)
25134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *            inverseTransform ^= HAL_TRANSFORM_ROT_180;
25234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
25334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
25434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 6. The GL driver queues the pre-transformed buffer.
25534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
25634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * 7. The composer combines the buffer transform with the display
25734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    transform.  If the buffer transform happens to cancel out the
25834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *    display transform then no rotation is needed.
25934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
26034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
26134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_TRANSFORM_HINT = 8,
26234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
26334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
26434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Boolean that indicates whether the consumer is running more than
26534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * one buffer behind the producer.
26634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
26734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,
26834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
26934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
27034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The consumer gralloc usage bits currently set by the consumer.
27134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The values are defined in hardware/libhardware/include/gralloc.h.
27234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
27334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,
27434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
27534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /**
27634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Transformation that will by applied to buffers by the hwcomposer.
27734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * This must not be set or checked by producer endpoints, and will
27834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * disable the transform hint set in SurfaceFlinger (see
27934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * NATIVE_WINDOW_TRANSFORM_HINT).
28034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
28134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * INTENDED USE:
28234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Temporary - Please do not use this.  This is intended only to be used
28334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * by the camera's LEGACY mode.
28434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
28534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * In situations where a SurfaceFlinger client wishes to set a transform
28634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * that is not visible to the producer, and will always be applied in the
28734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * hardware composer, the client can set this flag with
28834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * native_window_set_buffers_sticky_transform.  This can be used to rotate
28934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * and flip buffers consumed by hardware composer without actually changing
29034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * the aspect ratio of the buffers produced.
29134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
29234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_STICKY_TRANSFORM = 11,
29334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
29434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /**
29534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The default data space for the buffers as set by the consumer.
29634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The values are defined in graphics.h.
29734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
29834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_DEFAULT_DATASPACE = 12,
29934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
30034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
30134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns the age of the contents of the most recently dequeued buffer as
30234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * the number of frames that have elapsed since it was last queued. For
30334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * example, if the window is double-buffered, the age of any given buffer in
30434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * steady state will be 2. If the dequeued buffer has never been queued, its
30534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * age will be 0.
30634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
30734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_BUFFER_AGE = 13,
30834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
30934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
31034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns the duration of the last dequeueBuffer call in microseconds
31134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
31234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_LAST_DEQUEUE_DURATION = 14,
31334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
31434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
31534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns the duration of the last queueBuffer call in microseconds
31634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
31734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_LAST_QUEUE_DURATION = 15,
31834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
31934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
32034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns the number of image layers that the ANativeWindow buffer
32134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * contains. By default this is 1, unless a buffer is explicitly allocated
32234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * to contain multiple layers.
32334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
32434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_LAYER_COUNT = 16,
32534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
32634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
32734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 1 if the native window is valid, 0 otherwise. native window is valid
32834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * if it is safe (i.e. no crash will occur) to call any method on it.
32934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
33034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_IS_VALID = 17,
331b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland
332b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland    /*
333b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland     * Returns 1 if NATIVE_WINDOW_GET_FRAME_TIMESTAMPS will return display
334b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland     * present info, 0 if it won't.
335b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland     */
336b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland    NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT = 18,
337faa4c188d0aed8f055a6983156ca9e91c3f4c6beJiwen 'Steve' Cai
338faa4c188d0aed8f055a6983156ca9e91c3f4c6beJiwen 'Steve' Cai    /*
339faa4c188d0aed8f055a6983156ca9e91c3f4c6beJiwen 'Steve' Cai     * The consumer end is capable of handling protected buffers, i.e. buffer
340faa4c188d0aed8f055a6983156ca9e91c3f4c6beJiwen 'Steve' Cai     * with GRALLOC_USAGE_PROTECTED usage bits on.
341faa4c188d0aed8f055a6983156ca9e91c3f4c6beJiwen 'Steve' Cai     */
342faa4c188d0aed8f055a6983156ca9e91c3f4c6beJiwen 'Steve' Cai    NATIVE_WINDOW_CONSUMER_IS_PROTECTED = 19,
34334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian};
34434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
34534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* Valid operations for the (*perform)() hook.
34634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
34734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Values marked as 'deprecated' are supported, but have been superceded by
34834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * other functionality.
34934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
35034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Values marked as 'private' should be considered private to the framework.
35134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * HAL implementation code with access to an ANativeWindow should not use these,
35234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * as it may not interact properly with the framework's use of the
35334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * ANativeWindow.
35434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
35534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianenum {
35634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// clang-format off
35734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_USAGE                 =  0,
35834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_CONNECT                   =  1,   /* deprecated */
35934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_DISCONNECT                =  2,   /* deprecated */
36034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_CROP                  =  3,   /* private */
36134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFER_COUNT          =  4,
36234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_GEOMETRY      =  5,   /* deprecated */
36334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_TRANSFORM     =  6,
36434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP     =  7,
36534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS    =  8,
36634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_FORMAT        =  9,
36734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_SCALING_MODE          = 10,   /* private */
36834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_LOCK                      = 11,   /* private */
36934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_UNLOCK_AND_POST           = 12,   /* private */
37034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_API_CONNECT               = 13,   /* private */
37134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_API_DISCONNECT            = 14,   /* private */
37234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
37334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_POST_TRANSFORM_CROP   = 16,   /* private */
37434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
37534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_SIDEBAND_STREAM       = 18,
37634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_DATASPACE     = 19,
37734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_SURFACE_DAMAGE        = 20,   /* private */
37834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_SHARED_BUFFER_MODE    = 21,
37934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SET_AUTO_REFRESH          = 22,
38034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION= 23,
38134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_GET_NEXT_FRAME_ID         = 24,
38234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS   = 25,
38334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_GET_COMPOSITOR_TIMING     = 26,
38434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_GET_FRAME_TIMESTAMPS      = 27,
38534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT    = 28,
38634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_GET_HDR_SUPPORT           = 29,
38734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian// clang-format on
38834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian};
38934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
39034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
39134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianenum {
39234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
39334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * OpenGL ES.
39434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
39534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_API_EGL = 1,
39634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
39734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* Buffers will be queued after being filled using the CPU
39834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
39934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_API_CPU = 2,
40034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
40134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* Buffers will be queued by Stagefright after being filled by a video
40234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * decoder.  The video decoder can either be a software or hardware decoder.
40334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
40434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_API_MEDIA = 3,
40534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
40634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* Buffers will be queued by the the camera HAL.
40734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
40834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_API_CAMERA = 4,
40934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian};
41034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
41134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
41234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianenum {
41334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* flip source image horizontally */
41434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
41534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* flip source image vertically */
41634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
41734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
41834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
41934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* rotate source image 180 degrees */
42034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
42134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* rotate source image 270 degrees clock-wise */
42234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
42334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* transforms source by the inverse transform of the screen it is displayed onto. This
42434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * transform is applied last */
42534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
42634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian};
42734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
42834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* parameter for NATIVE_WINDOW_SET_SCALING_MODE
42934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * keep in sync with Surface.java in frameworks/base */
43034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianenum {
43134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* the window content is not updated (frozen) until a buffer of
43234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * the window size is received (enqueued)
43334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
43434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_FREEZE           = 0,
43534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* the buffer is scaled in both dimensions to match the window size */
43634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW  = 1,
43734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* the buffer is scaled uniformly such that the smaller dimension
43834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * of the buffer matches the window size (cropping in the process)
43934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
44034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_SCALE_CROP       = 2,
44134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* the window is clipped to the size of the buffer's crop rectangle; pixels
44234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * outside the crop rectangle are treated as if they are completely
44334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * transparent.
44434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
44534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP    = 3,
44634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian};
44734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
44834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
44934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianenum {
45034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_FRAMEBUFFER               = 0, /* FramebufferNativeWindow */
45134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    NATIVE_WINDOW_SURFACE                   = 1, /* Surface */
45234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian};
45334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
45434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
45534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
45634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Special timestamp value to indicate that timestamps should be auto-generated
45734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * by the native window when queueBuffer is called.  This is equal to INT64_MIN,
45834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
45934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
46034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
46134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
462b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland/* parameter for NATIVE_WINDOW_GET_FRAME_TIMESTAMPS
463b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland *
464b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland * Special timestamp value to indicate the timestamps aren't yet known or
465b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland * that they are invalid.
466b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland */
467b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Morelandstatic const int64_t NATIVE_WINDOW_TIMESTAMP_PENDING = -2;
468b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Morelandstatic const int64_t NATIVE_WINDOW_TIMESTAMP_INVALID = -1;
469b084bc3545d7560e9a58bb0dc2fecb346c512298Steven Moreland
47034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstruct ANativeWindow
47134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
47234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#ifdef __cplusplus
47334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    ANativeWindow()
47434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
47534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    {
47634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
47734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        common.version = sizeof(ANativeWindow);
47834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        memset(common.reserved, 0, sizeof(common.reserved));
47934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    }
48034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
48134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* Implement the methods that sp<ANativeWindow> expects so that it
48234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian       can be used to automatically refcount ANativeWindow's. */
48334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void incStrong(const void* /*id*/) const {
48434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        common.incRef(const_cast<android_native_base_t*>(&common));
48534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    }
48634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    void decStrong(const void* /*id*/) const {
48734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        common.decRef(const_cast<android_native_base_t*>(&common));
48834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    }
48934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian#endif
49034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
49134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    struct android_native_base_t common;
49234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
49334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* flags describing some attributes of this surface or its updater */
49434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    const uint32_t flags;
49534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
49634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* min swap interval supported by this updated */
49734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    const int   minSwapInterval;
49834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
49934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* max swap interval supported by this updated */
50034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    const int   maxSwapInterval;
50134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
50234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* horizontal and vertical resolution in DPI */
50334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    const float xdpi;
50434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    const float ydpi;
50534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
50634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /* Some storage reserved for the OEM's driver. */
50734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    intptr_t    oem[4];
50834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
50934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
51034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Set the swap interval for this surface.
51134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
51234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 0 on success or -errno on error.
51334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
51434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*setSwapInterval)(struct ANativeWindow* window,
51534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                int interval);
51634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
51734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
51834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Hook called by EGL to acquire a buffer. After this call, the buffer
51934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * is not locked, so its content cannot be modified. This call may block if
52034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * no buffers are available.
52134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
52234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
52334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
52434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
52534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
52634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * allowed if a specific buffer count has been set.
52734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
52834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 0 on success or -errno on error.
52934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
53034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
53134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * time for binary compatibility, but the new dequeueBuffer function that
53234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * outputs a fence file descriptor should be used in its place.
53334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
53434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
53534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                struct ANativeWindowBuffer** buffer);
53634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
53734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
53834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * hook called by EGL to lock a buffer. This MUST be called before modifying
53934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * the content of a buffer. The buffer must have been acquired with
54034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * dequeueBuffer first.
54134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
54234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 0 on success or -errno on error.
54334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
54434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
54534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * time for binary compatibility, but it is essentially a no-op, and calls
54634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * to it should be removed.
54734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
54834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
54934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                struct ANativeWindowBuffer* buffer);
55034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
55134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
55234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Hook called by EGL when modifications to the render buffer are done.
55334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * This unlocks and post the buffer.
55434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
55534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
55634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
55734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
55834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
55934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * allowed if a specific buffer count has been set.
56034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
56134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Buffers MUST be queued in the same order than they were dequeued.
56234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
56334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 0 on success or -errno on error.
56434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
56534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
56634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * time for binary compatibility, but the new queueBuffer function that
56734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * takes a fence file descriptor should be used in its place (pass a value
56834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * of -1 for the fence file descriptor if there is no valid one to pass).
56934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
57034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
57134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                struct ANativeWindowBuffer* buffer);
57234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
57334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
57434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * hook used to retrieve information about the native window.
57534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
57634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 0 on success or -errno on error.
57734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
57834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*query)(const struct ANativeWindow* window,
57934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                int what, int* value);
58034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
58134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
58234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * hook used to perform various operations on the surface.
58334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * (*perform)() is a generic mechanism to add functionality to
58434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * ANativeWindow while keeping backward binary compatibility.
58534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
58634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * DO NOT CALL THIS HOOK DIRECTLY.  Instead, use the helper functions
58734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * defined below.
58834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
58934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * (*perform)() returns -ENOENT if the 'what' parameter is not supported
59034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * by the surface's implementation.
59134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
59234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * See above for a list of valid operations, such as
59334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
59434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
59534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*perform)(struct ANativeWindow* window,
59634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                int operation, ... );
59734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
59834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
59934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Hook used to cancel a buffer that has been dequeued.
60034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * No synchronization is performed between dequeue() and cancel(), so
60134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * either external synchronization is needed, or these functions must be
60234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * called from the same thread.
60334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
60434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
60534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
60634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
60734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
60834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * allowed if a specific buffer count has been set.
60934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
61034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
61134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * time for binary compatibility, but the new cancelBuffer function that
61234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * takes a fence file descriptor should be used in its place (pass a value
61334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * of -1 for the fence file descriptor if there is no valid one to pass).
61434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
61534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
61634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                struct ANativeWindowBuffer* buffer);
61734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
61834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
61934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Hook called by EGL to acquire a buffer. This call may block if no
62034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * buffers are available.
62134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
62234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
62334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
62434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
62534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
62634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * allowed if a specific buffer count has been set.
62734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
62834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The libsync fence file descriptor returned in the int pointed to by the
62934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * fenceFd argument will refer to the fence that must signal before the
63034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * dequeued buffer may be written to.  A value of -1 indicates that the
63134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * caller may access the buffer immediately without waiting on a fence.  If
63234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * a valid file descriptor is returned (i.e. any value except -1) then the
63334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * caller is responsible for closing the file descriptor.
63434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
63534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 0 on success or -errno on error.
63634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
63734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*dequeueBuffer)(struct ANativeWindow* window,
63834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                struct ANativeWindowBuffer** buffer, int* fenceFd);
63934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
64034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
64134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Hook called by EGL when modifications to the render buffer are done.
64234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * This unlocks and post the buffer.
64334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
64434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
64534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
64634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
64734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
64834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * allowed if a specific buffer count has been set.
64934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
65034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The fenceFd argument specifies a libsync fence file descriptor for a
65134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * fence that must signal before the buffer can be accessed.  If the buffer
65234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * can be accessed immediately then a value of -1 should be used.  The
65334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * caller must not use the file descriptor after it is passed to
65434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * queueBuffer, and the ANativeWindow implementation is responsible for
65534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * closing it.
65634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
65734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 0 on success or -errno on error.
65834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
65934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*queueBuffer)(struct ANativeWindow* window,
66034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                struct ANativeWindowBuffer* buffer, int fenceFd);
66134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
66234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    /*
66334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Hook used to cancel a buffer that has been dequeued.
66434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * No synchronization is performed between dequeue() and cancel(), so
66534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * either external synchronization is needed, or these functions must be
66634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * called from the same thread.
66734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
66834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
66934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
67034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
67134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
67234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * allowed if a specific buffer count has been set.
67334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
67434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * The fenceFd argument specifies a libsync fence file decsriptor for a
67534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * fence that must signal before the buffer can be accessed.  If the buffer
67634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * can be accessed immediately then a value of -1 should be used.
67734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
67834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Note that if the client has not waited on the fence that was returned
67934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * from dequeueBuffer, that same fence should be passed to cancelBuffer to
68034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * ensure that future uses of the buffer are preceded by a wait on that
68134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * fence.  The caller must not use the file descriptor after it is passed
68234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * to cancelBuffer, and the ANativeWindow implementation is responsible for
68334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * closing it.
68434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     *
68534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     * Returns 0 on success or -errno on error.
68634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian     */
68734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    int     (*cancelBuffer)(struct ANativeWindow* window,
68834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                struct ANativeWindowBuffer* buffer, int fenceFd);
68934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian};
69034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
69134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
69234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian  * android_native_window_t is deprecated.
69334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian  */
69434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopiantypedef struct ANativeWindow ANativeWindow;
69534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopiantypedef struct ANativeWindow android_native_window_t __deprecated;
69634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
69734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
69834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *  native_window_set_usage(..., usage)
69934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *  Sets the intended usage flags for the next buffers
70034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *  acquired with (*lockBuffer)() and on.
70134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *  By default (if this function is never called), a usage of
70234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *      GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
70334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *  is assumed.
70434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *  Calling this function will usually cause following buffers to be
70534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *  reallocated.
70634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
70734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
70834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_usage(
70934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window, int usage)
71034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
71134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
71234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
71334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
71434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* deprecated. Always returns 0. Don't call. */
71534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_connect(
71634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
71734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
71834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_connect(
71934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) {
72034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return 0;
72134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
72234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
72334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/* deprecated. Always returns 0. Don't call. */
72434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_disconnect(
72534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
72634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
72734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_disconnect(
72834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) {
72934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return 0;
73034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
73134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
73234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
73334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_crop(..., crop)
73434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Sets which region of the next queued buffers needs to be considered.
73534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Depending on the scaling mode, a buffer's crop region is scaled and/or
73634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * cropped to match the surface's size.  This function sets the crop in
73734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * pre-transformed buffer pixel coordinates.
73834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
73934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * The specified crop region applies to all buffers queued after it is called.
74034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
74134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * If 'crop' is NULL, subsequently queued buffers won't be cropped.
74234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
74334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * An error is returned if for instance the crop region is invalid, out of the
74434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * buffer's bound or if the window is invalid.
74534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
74634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_crop(
74734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
74834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        android_native_rect_t const * crop)
74934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
75034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
75134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
75234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
75334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
75434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_post_transform_crop(..., crop)
75534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Sets which region of the next queued buffers needs to be considered.
75634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Depending on the scaling mode, a buffer's crop region is scaled and/or
75734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * cropped to match the surface's size.  This function sets the crop in
75834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * post-transformed pixel coordinates.
75934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
76034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * The specified crop region applies to all buffers queued after it is called.
76134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
76234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * If 'crop' is NULL, subsequently queued buffers won't be cropped.
76334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
76434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * An error is returned if for instance the crop region is invalid, out of the
76534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * buffer's bound or if the window is invalid.
76634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
76734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_post_transform_crop(
76834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
76934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        android_native_rect_t const * crop)
77034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
77134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);
77234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
77334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
77434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
77534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_active_rect(..., active_rect)
77634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
77734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * This function is deprecated and will be removed soon.  For now it simply
77834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * sets the post-transform crop for compatibility while multi-project commits
77934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * get checked.
78034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
78134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_active_rect(
78234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
78334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        android_native_rect_t const * active_rect) __deprecated;
78434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
78534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_active_rect(
78634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
78734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        android_native_rect_t const * active_rect)
78834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
78934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return native_window_set_post_transform_crop(window, active_rect);
79034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
79134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
79234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
79334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffer_count(..., count)
79434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Sets the number of buffers associated with this native window.
79534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
79634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffer_count(
79734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
79834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        size_t bufferCount)
79934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
80034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
80134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
80234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
80334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
80434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_geometry(..., int w, int h, int format)
80534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * All buffers dequeued after this call will have the dimensions and format
80634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * specified.  A successful call to this function has the same effect as calling
80734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_size and native_window_set_buffers_format.
80834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
80934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * XXX: This function is deprecated.  The native_window_set_buffers_dimensions
81034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * and native_window_set_buffers_format functions should be used instead.
81134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
81234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_geometry(
81334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
81434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int w, int h, int format) __deprecated;
81534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
81634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_geometry(
81734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
81834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int w, int h, int format)
81934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
82034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
82134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            w, h, format);
82234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
82334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
82434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
82534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_dimensions(..., int w, int h)
82634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * All buffers dequeued after this call will have the dimensions specified.
82734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * In particular, all buffers will have a fixed-size, independent from the
82834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native-window size. They will be scaled according to the scaling mode
82934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * (see native_window_set_scaling_mode) upon window composition.
83034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
83134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
83234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * following this call will be sized to match the window's size.
83334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
83434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Calling this function will reset the window crop to a NULL value, which
83534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * disables cropping of the buffers.
83634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
83734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_dimensions(
83834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
83934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int w, int h)
84034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
84134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
84234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            w, h);
84334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
84434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
84534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
84634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_user_dimensions(..., int w, int h)
84734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
84834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Sets the user buffer size for the window, which overrides the
84934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * window's size.  All buffers dequeued after this call will have the
85034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * dimensions specified unless overridden by
85134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_dimensions.  All buffers will have a
85234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * fixed-size, independent from the native-window size. They will be
85334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * scaled according to the scaling mode (see
85434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_scaling_mode) upon window composition.
85534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
85634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * If w and h are 0, the normal behavior is restored. That is, the
85734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * default buffer size will match the windows's size.
85834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
85934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Calling this function will reset the window crop to a NULL value, which
86034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * disables cropping of the buffers.
86134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
86234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_user_dimensions(
86334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
86434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int w, int h)
86534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
86634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
86734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            w, h);
86834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
86934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
87034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
87134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_format(..., int format)
87234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * All buffers dequeued after this call will have the format specified.
87334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
87434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * If the specified format is 0, the default buffer format will be used.
87534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
87634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_format(
87734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
87834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int format)
87934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
88034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
88134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
88234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
88334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
88434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_data_space(..., int dataSpace)
88534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * All buffers queued after this call will be associated with the dataSpace
88634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * parameter specified.
88734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
88834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * dataSpace specifies additional information about the buffer that's dependent
88934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * on the buffer format and the endpoints. For example, it can be used to convey
89034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * the color space of the image data in the buffer, or it can be used to
89134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * indicate that the buffers contain depth measurement data instead of color
89234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * images.  The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
89334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * overridden by the consumer.
89434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
89534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_data_space(
89634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
89734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        android_dataspace_t dataSpace)
89834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
89934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
90034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            dataSpace);
90134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
90234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
90334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
90434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_transform(..., int transform)
90534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * All buffers queued after this call will be displayed transformed according
90634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * to the transform parameter specified.
90734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
90834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_transform(
90934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
91034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int transform)
91134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
91234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
91334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            transform);
91434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
91534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
91634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
91734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_sticky_transform(..., int transform)
91834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * All buffers queued after this call will be displayed transformed according
91934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * to the transform parameter specified applied on top of the regular buffer
92034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * transform.  Setting this transform will disable the transform hint.
92134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
92234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Temporary - This is only intended to be used by the LEGACY camera mode, do
92334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *   not use this for anything else.
92434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
92534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_sticky_transform(
92634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
92734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int transform)
92834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
92934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,
93034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            transform);
93134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
93234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
93334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
93434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_buffers_timestamp(..., int64_t timestamp)
93534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * All buffers queued after this call will be associated with the timestamp
93634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
93734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * (the default), timestamps will be generated automatically when queueBuffer is
93834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * called. The timestamp is measured in nanoseconds, and is normally monotonically
93934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * increasing. The timestamp should be unaffected by time-of-day adjustments,
94034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * and for a camera should be strictly monotonic but for a media player may be
94134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * reset when the position is set.
94234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
94334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_buffers_timestamp(
94434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
94534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t timestamp)
94634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
94734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
94834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            timestamp);
94934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
95034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
95134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
95234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_scaling_mode(..., int mode)
95334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * All buffers queued after this call will be associated with the scaling mode
95434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * specified.
95534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
95634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_scaling_mode(
95734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
95834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int mode)
95934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
96034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
96134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            mode);
96234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
96334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
96434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
96534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_api_connect(..., int api)
96634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * connects an API to this window. only one API can be connected at a time.
96734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Returns -EINVAL if for some reason the window cannot be connected, which
96834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * can happen if it's connected to some other API.
96934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
97034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_api_connect(
97134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window, int api)
97234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
97334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
97434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
97534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
97634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
97734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_api_disconnect(..., int api)
97834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * disconnect the API from this window.
97934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * An error is returned if for instance the window wasn't connected in the
98034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * first place.
98134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
98234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_api_disconnect(
98334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window, int api)
98434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
98534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
98634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
98734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
98834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
98934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_dequeue_buffer_and_wait(...)
99034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Dequeue a buffer and wait on the fence associated with that buffer.  The
99134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * buffer may safely be accessed immediately upon this function returning.  An
99234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * error is returned if either of the dequeue or the wait operations fail.
99334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
99434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,
99534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindowBuffer** anb) {
99634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return anw->dequeueBuffer_DEPRECATED(anw, anb);
99734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
99834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
99934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
100034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_sideband_stream(..., native_handle_t*)
100134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Attach a sideband buffer stream to a native window.
100234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
100334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_sideband_stream(
100434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
100534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        native_handle_t* sidebandHandle)
100634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
100734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,
100834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            sidebandHandle);
100934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
101034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
101134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
101234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
101334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Set the surface damage (i.e., the region of the surface that has changed
101434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * since the previous frame). The damage set by this call will be reset (to the
101534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * default of full-surface damage) after calling queue, so this must be called
101634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * prior to every frame with damage that does not cover the whole surface if the
101734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * caller desires downstream consumers to use this optimization.
101834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
101934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * The damage region is specified as an array of rectangles, with the important
102034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * caveat that the origin of the surface is considered to be the bottom-left
102134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * corner, as in OpenGL ES.
102234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian *
102334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * If numRects is set to 0, rects may be NULL, and the surface damage will be
102434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * set to the full surface (the same as if this function had not been called for
102534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * this frame).
102634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
102734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_surface_damage(
102834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
102934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        const android_native_rect_t* rects, size_t numRects)
103034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
103134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
103234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            rects, numRects);
103334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
103434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
103534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
103634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_shared_buffer_mode(..., bool sharedBufferMode)
103734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Enable/disable shared buffer mode
103834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
103934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_shared_buffer_mode(
104034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
104134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        bool sharedBufferMode)
104234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
104334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE,
104434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            sharedBufferMode);
104534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
104634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
104734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian/*
104834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * native_window_set_auto_refresh(..., autoRefresh)
104934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian * Enable/disable auto refresh when in shared buffer mode
105034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian */
105134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_set_auto_refresh(
105234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
105334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        bool autoRefresh)
105434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
105534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh);
105634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
105734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
105834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_get_refresh_cycle_duration(
105934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
106034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t* outRefreshDuration)
106134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
106234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION,
106334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            outRefreshDuration);
106434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
106534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
106634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_get_next_frame_id(
106734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window, uint64_t* frameId)
106834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
106934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_GET_NEXT_FRAME_ID, frameId);
107034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
107134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
107234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_enable_frame_timestamps(
107334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window, bool enable)
107434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
107534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS,
107634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            enable);
107734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
107834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
107934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_get_compositor_timing(
108034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window,
108134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t* compositeDeadline, int64_t* compositeInterval,
108234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t* compositeToPresentLatency)
108334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
108434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_GET_COMPOSITOR_TIMING,
108534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            compositeDeadline, compositeInterval, compositeToPresentLatency);
108634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
108734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
108834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_get_frame_timestamps(
108934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        struct ANativeWindow* window, uint64_t frameId,
109034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t* outRequestedPresentTime, int64_t* outAcquireTime,
109134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t* outLatchTime, int64_t* outFirstRefreshStartTime,
109234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t* outLastRefreshStartTime, int64_t* outGpuCompositionDoneTime,
109334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t* outDisplayPresentTime, int64_t* outDequeueReadyTime,
109434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian        int64_t* outReleaseTime)
109534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian{
109634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS,
109734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            frameId, outRequestedPresentTime, outAcquireTime, outLatchTime,
109834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            outFirstRefreshStartTime, outLastRefreshStartTime,
109934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            outGpuCompositionDoneTime, outDisplayPresentTime,
110034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian            outDequeueReadyTime, outReleaseTime);
110134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
110234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
110334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_get_wide_color_support(
110434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian    struct ANativeWindow* window, bool* outSupport) {
110534c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian  return window->perform(window, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT,
110634c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                         outSupport);
110734c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
110834c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
110934c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopianstatic inline int native_window_get_hdr_support(struct ANativeWindow* window,
111034c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian                                                bool* outSupport) {
111134c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian  return window->perform(window, NATIVE_WINDOW_GET_HDR_SUPPORT, outSupport);
111234c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian}
111334c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian
111434c9fbb6d1e42dafdb054a700dcb5e20d490a8d2Mathias Agopian__END_DECLS
1115