window.h revision a6c0e20ac89b1be29901a7200590bf7cb8b99f78
1a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 2a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Copyright (C) 2011 The Android Open Source Project 3a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 4a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 5a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * you may not use this file except in compliance with the License. 6a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * You may obtain a copy of the License at 7a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 8a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 9a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 10a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Unless required by applicable law or agreed to in writing, software 11a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 12a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * See the License for the specific language governing permissions and 14a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * limitations under the License. 15a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 16a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 17a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/************************************************************************************************* 18a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 19a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * IMPORTANT: 20a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 21a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * There is an old copy of this file in system/core/include/system/window.h, which exists only 22a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * for backward source compatibility. 23a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * But there are binaries out there as well, so this version of window.h must stay binary 24a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * backward compatible with the one found in system/core. 25a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 26a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 27a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Source compatibility is also required for now, because this is how we're handling the 28a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * transition from system/core/include (global include path) to nativewindow/include. 29a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 30a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *************************************************************************************************/ 31a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 32a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#pragma once 33a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 34a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <cutils/native_handle.h> 35a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <errno.h> 36a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <limits.h> 37a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <stdint.h> 38a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <string.h> 39a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <sys/cdefs.h> 40a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <system/graphics.h> 41a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <unistd.h> 42a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <stdbool.h> 43a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 44a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// system/window.h is a superset of the vndk 45a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <vndk/window.h> 46a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 47a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 48a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifndef __UNUSED 49a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define __UNUSED __attribute__((__unused__)) 50a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif 51a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifndef __deprecated 52a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define __deprecated __attribute__((__deprecated__)) 53a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif 54a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 55a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian__BEGIN_DECLS 56a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 57a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*****************************************************************************/ 58a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 59a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifdef __cplusplus 60a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define ANDROID_NATIVE_UNSIGNED_CAST(x) static_cast<unsigned int>(x) 61a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#else 62a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define ANDROID_NATIVE_UNSIGNED_CAST(x) ((unsigned int)(x)) 63a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif 64a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 65a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ 66a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian ((ANDROID_NATIVE_UNSIGNED_CAST(a) << 24) | \ 67a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian (ANDROID_NATIVE_UNSIGNED_CAST(b) << 16) | \ 68a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian (ANDROID_NATIVE_UNSIGNED_CAST(c) << 8) | \ 69a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian (ANDROID_NATIVE_UNSIGNED_CAST(d))) 70a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 71a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define ANDROID_NATIVE_WINDOW_MAGIC \ 72a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') 73a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 74a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define ANDROID_NATIVE_BUFFER_MAGIC \ 75a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') 76a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 77a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// --------------------------------------------------------------------------- 78a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 79a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// This #define may be used to conditionally compile device-specific code to 80a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// support either the prior ANativeWindow interface, which did not pass libsync 81a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// fences around, or the new interface that does. This #define is only present 82a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// when the ANativeWindow interface does include libsync support. 83a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1 84a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 85a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// --------------------------------------------------------------------------- 86a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 87a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef const native_handle_t* buffer_handle_t; 88a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 89a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// --------------------------------------------------------------------------- 90a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 91a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct android_native_rect_t 92a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 93a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int32_t left; 94a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int32_t top; 95a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int32_t right; 96a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int32_t bottom; 97a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} android_native_rect_t; 98a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 99a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// --------------------------------------------------------------------------- 100a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 101a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct android_native_base_t 102a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 103a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* a magic value defined by the actual EGL native type */ 104a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int magic; 105a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 106a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* the sizeof() of the actual EGL native type */ 107a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int version; 108a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 109a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void* reserved[4]; 110a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 111a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* reference-counting interface */ 112a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void (*incRef)(struct android_native_base_t* base); 113a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void (*decRef)(struct android_native_base_t* base); 114a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} android_native_base_t; 115a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 116a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct ANativeWindowBuffer 117a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 118a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifdef __cplusplus 119a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian ANativeWindowBuffer() { 120a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian common.magic = ANDROID_NATIVE_BUFFER_MAGIC; 121a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian common.version = sizeof(ANativeWindowBuffer); 122a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian memset(common.reserved, 0, sizeof(common.reserved)); 123a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian } 124a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 125a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian // Implement the methods that sp<ANativeWindowBuffer> expects so that it 126a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian // can be used to automatically refcount ANativeWindowBuffer's. 127a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void incStrong(const void* /*id*/) const { 128a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian common.incRef(const_cast<android_native_base_t*>(&common)); 129a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian } 130a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void decStrong(const void* /*id*/) const { 131a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian common.decRef(const_cast<android_native_base_t*>(&common)); 132a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian } 133a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif 134a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 135a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct android_native_base_t common; 136a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 137a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int width; 138a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int height; 139a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int stride; 140a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int format; 141a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int usage; 142a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian uintptr_t layerCount; 143a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 144a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void* reserved[1]; 145a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 146a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian buffer_handle_t handle; 147a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 148a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void* reserved_proc[8]; 149a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} ANativeWindowBuffer_t; 150a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 151a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// Old typedef for backwards compatibility. 152a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef ANativeWindowBuffer_t android_native_buffer_t; 153a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 154a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// --------------------------------------------------------------------------- 155a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 156a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* attributes queriable with query() */ 157a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum { 158a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_WIDTH = 0, 159a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_HEIGHT = 1, 160a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_FORMAT = 2, 161a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 162a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* The minimum number of buffers that must remain un-dequeued after a buffer 163a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * has been queued. This value applies only if set_buffer_count was used to 164a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * override the number of buffers and if a buffer has since been queued. 165a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Users of the set_buffer_count ANativeWindow method should query this 166a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * value before calling set_buffer_count. If it is necessary to have N 167a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffers simultaneously dequeued as part of the steady-state operation, 168a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * and this query returns M then N+M buffers should be requested via 169a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffer_count. 170a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 171a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Note that this value does NOT apply until a single buffer has been 172a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * queued. In particular this means that it is possible to: 173a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 174a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 1. Query M = min undequeued buffers 175a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 2. Set the buffer count to N + M 176a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 3. Dequeue all N + M buffers 177a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 4. Cancel M buffers 178a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 5. Queue, dequeue, queue, dequeue, ad infinitum 179a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 180a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3, 181a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 182a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Check whether queueBuffer operations on the ANativeWindow send the buffer 183a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to the window compositor. The query sets the returned 'value' argument 184a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to 1 if the ANativeWindow DOES send queued buffers directly to the window 185a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * compositor and 0 if the buffers do not go directly to the window 186a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * compositor. 187a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 188a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * This can be used to determine whether protected buffer content should be 189a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * sent to the ANativeWindow. Note, however, that a result of 1 does NOT 190a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * indicate that queued buffers will be protected from applications or users 191a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * capturing their contents. If that behavior is desired then some other 192a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in 193a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * conjunction with this query. 194a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 195a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, 196a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 197a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Get the concrete type of a ANativeWindow. See below for the list of 198a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * possible return values. 199a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 200a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * This query should not be used outside the Android framework and will 201a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * likely be removed in the near future. 202a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 203a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_CONCRETE_TYPE = 5, 204a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 205a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 206a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 207a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Default width and height of ANativeWindow buffers, these are the 208a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * dimensions of the window buffers irrespective of the 209a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window 210a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. 211a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 212a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_DEFAULT_WIDTH = 6, 213a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_DEFAULT_HEIGHT = 7, 214a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 215a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 216a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * transformation that will most-likely be applied to buffers. This is only 217a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * a hint, the actual transformation applied might be different. 218a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 219a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * INTENDED USE: 220a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 221a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The transform hint can be used by a producer, for instance the GLES 222a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * driver, to pre-rotate the rendering such that the final transformation 223a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * in the composer is identity. This can be very useful when used in 224a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * conjunction with the h/w composer HAL, in situations where it 225a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * cannot handle arbitrary rotations. 226a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 227a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) 228a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. 229a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 230a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 2. The GL driver overrides the width and height of the ANW to 231a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying 232a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions 233a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * according to NATIVE_WINDOW_TRANSFORM_HINT and calling 234a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_dimensions(). 235a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 236a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 3. The GL driver dequeues a buffer of the new pre-rotated size. 237a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 238a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 4. The GL driver renders to the buffer such that the image is 239a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT 240a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to the rendering. 241a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 242a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 5. The GL driver calls native_window_set_transform to apply 243a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * inverse transformation to the buffer it just rendered. 244a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * In order to do this, the GL driver needs 245a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is 246a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * done easily: 247a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 248a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * int hintTransform, inverseTransform; 249a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); 250a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * inverseTransform = hintTransform; 251a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * if (hintTransform & HAL_TRANSFORM_ROT_90) 252a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * inverseTransform ^= HAL_TRANSFORM_ROT_180; 253a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 254a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 255a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 6. The GL driver queues the pre-transformed buffer. 256a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 257a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 7. The composer combines the buffer transform with the display 258a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * transform. If the buffer transform happens to cancel out the 259a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * display transform then no rotation is needed. 260a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 261a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 262a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_TRANSFORM_HINT = 8, 263a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 264a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 265a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Boolean that indicates whether the consumer is running more than 266a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * one buffer behind the producer. 267a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 268a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, 269a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 270a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 271a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The consumer gralloc usage bits currently set by the consumer. 272a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The values are defined in hardware/libhardware/include/gralloc.h. 273a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 274a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, 275a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 276a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /** 277a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Transformation that will by applied to buffers by the hwcomposer. 278a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * This must not be set or checked by producer endpoints, and will 279a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * disable the transform hint set in SurfaceFlinger (see 280a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * NATIVE_WINDOW_TRANSFORM_HINT). 281a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 282a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * INTENDED USE: 283a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Temporary - Please do not use this. This is intended only to be used 284a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * by the camera's LEGACY mode. 285a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 286a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * In situations where a SurfaceFlinger client wishes to set a transform 287a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * that is not visible to the producer, and will always be applied in the 288a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * hardware composer, the client can set this flag with 289a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_sticky_transform. This can be used to rotate 290a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * and flip buffers consumed by hardware composer without actually changing 291a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * the aspect ratio of the buffers produced. 292a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 293a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_STICKY_TRANSFORM = 11, 294a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 295a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /** 296a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The default data space for the buffers as set by the consumer. 297a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The values are defined in graphics.h. 298a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 299a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_DEFAULT_DATASPACE = 12, 300a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 301a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 302a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns the age of the contents of the most recently dequeued buffer as 303a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * the number of frames that have elapsed since it was last queued. For 304a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * example, if the window is double-buffered, the age of any given buffer in 305a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * steady state will be 2. If the dequeued buffer has never been queued, its 306a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * age will be 0. 307a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 308a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_BUFFER_AGE = 13, 309a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 310a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 311a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns the duration of the last dequeueBuffer call in microseconds 312a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 313a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_LAST_DEQUEUE_DURATION = 14, 314a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 315a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 316a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns the duration of the last queueBuffer call in microseconds 317a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 318a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_LAST_QUEUE_DURATION = 15, 319a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 320a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 321a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns the number of image layers that the ANativeWindow buffer 322a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * contains. By default this is 1, unless a buffer is explicitly allocated 323a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to contain multiple layers. 324a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 325a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_LAYER_COUNT = 16, 326a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 327a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 328a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 1 if the native window is valid, 0 otherwise. native window is valid 329a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * if it is safe (i.e. no crash will occur) to call any method on it. 330a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 331a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_IS_VALID = 17, 332a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}; 333a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 334a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* Valid operations for the (*perform)() hook. 335a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 336a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Values marked as 'deprecated' are supported, but have been superceded by 337a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * other functionality. 338a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 339a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Values marked as 'private' should be considered private to the framework. 340a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * HAL implementation code with access to an ANativeWindow should not use these, 341a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * as it may not interact properly with the framework's use of the 342a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * ANativeWindow. 343a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 344a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum { 345a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// clang-format off 346a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_USAGE = 0, 347a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_CONNECT = 1, /* deprecated */ 348a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ 349a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_CROP = 3, /* private */ 350a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFER_COUNT = 4, 351a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ 352a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, 353a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, 354a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, 355a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, 356a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ 357a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_LOCK = 11, /* private */ 358a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ 359a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_API_CONNECT = 13, /* private */ 360a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ 361a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ 362a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ 363a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */ 364a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, 365a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19, 366a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */ 367a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21, 368a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SET_AUTO_REFRESH = 22, 369a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION= 23, 370a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_GET_NEXT_FRAME_ID = 24, 371a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS = 25, 372a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_GET_COMPOSITOR_TIMING = 26, 373a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_GET_FRAME_TIMESTAMPS = 27, 374a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT = 28, 375a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_GET_HDR_SUPPORT = 29, 376a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// clang-format on 377a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}; 378a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 379a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ 380a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum { 381a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Buffers will be queued by EGL via eglSwapBuffers after being filled using 382a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * OpenGL ES. 383a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 384a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_API_EGL = 1, 385a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 386a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Buffers will be queued after being filled using the CPU 387a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 388a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_API_CPU = 2, 389a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 390a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Buffers will be queued by Stagefright after being filled by a video 391a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * decoder. The video decoder can either be a software or hardware decoder. 392a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 393a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_API_MEDIA = 3, 394a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 395a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Buffers will be queued by the the camera HAL. 396a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 397a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_API_CAMERA = 4, 398a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}; 399a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 400a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ 401a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum { 402a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* flip source image horizontally */ 403a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , 404a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* flip source image vertically */ 405a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, 406a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ 407a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, 408a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* rotate source image 180 degrees */ 409a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, 410a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* rotate source image 270 degrees clock-wise */ 411a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, 412a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* transforms source by the inverse transform of the screen it is displayed onto. This 413a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * transform is applied last */ 414a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 415a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}; 416a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 417a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_SCALING_MODE 418a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * keep in sync with Surface.java in frameworks/base */ 419a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum { 420a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* the window content is not updated (frozen) until a buffer of 421a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * the window size is received (enqueued) 422a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 423a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, 424a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* the buffer is scaled in both dimensions to match the window size */ 425a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, 426a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* the buffer is scaled uniformly such that the smaller dimension 427a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * of the buffer matches the window size (cropping in the process) 428a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 429a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, 430a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* the window is clipped to the size of the buffer's crop rectangle; pixels 431a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * outside the crop rectangle are treated as if they are completely 432a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * transparent. 433a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 434a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, 435a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}; 436a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 437a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ 438a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum { 439a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ 440a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian NATIVE_WINDOW_SURFACE = 1, /* Surface */ 441a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}; 442a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 443a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP 444a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 445a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Special timestamp value to indicate that timestamps should be auto-generated 446a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * by the native window when queueBuffer is called. This is equal to INT64_MIN, 447a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * defined directly to avoid problems with C99/C++ inclusion of stdint.h. 448a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 449a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); 450a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 451a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstruct ANativeWindow 452a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 453a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifdef __cplusplus 454a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian ANativeWindow() 455a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) 456a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian { 457a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian common.magic = ANDROID_NATIVE_WINDOW_MAGIC; 458a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian common.version = sizeof(ANativeWindow); 459a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian memset(common.reserved, 0, sizeof(common.reserved)); 460a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian } 461a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 462a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Implement the methods that sp<ANativeWindow> expects so that it 463a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian can be used to automatically refcount ANativeWindow's. */ 464a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void incStrong(const void* /*id*/) const { 465a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian common.incRef(const_cast<android_native_base_t*>(&common)); 466a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian } 467a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian void decStrong(const void* /*id*/) const { 468a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian common.decRef(const_cast<android_native_base_t*>(&common)); 469a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian } 470a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif 471a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 472a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct android_native_base_t common; 473a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 474a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* flags describing some attributes of this surface or its updater */ 475a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian const uint32_t flags; 476a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 477a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* min swap interval supported by this updated */ 478a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian const int minSwapInterval; 479a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 480a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* max swap interval supported by this updated */ 481a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian const int maxSwapInterval; 482a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 483a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* horizontal and vertical resolution in DPI */ 484a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian const float xdpi; 485a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian const float ydpi; 486a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 487a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Some storage reserved for the OEM's driver. */ 488a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian intptr_t oem[4]; 489a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 490a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 491a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Set the swap interval for this surface. 492a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 493a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 0 on success or -errno on error. 494a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 495a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*setSwapInterval)(struct ANativeWindow* window, 496a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int interval); 497a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 498a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 499a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Hook called by EGL to acquire a buffer. After this call, the buffer 500a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * is not locked, so its content cannot be modified. This call may block if 501a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * no buffers are available. 502a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 503a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The window holds a reference to the buffer between dequeueBuffer and 504a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * either queueBuffer or cancelBuffer, so clients only need their own 505a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reference if they might use the buffer after queueing or canceling it. 506a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Holding a reference to a buffer after queueing or canceling it is only 507a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * allowed if a specific buffer count has been set. 508a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 509a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 0 on success or -errno on error. 510a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 511a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * XXX: This function is deprecated. It will continue to work for some 512a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * time for binary compatibility, but the new dequeueBuffer function that 513a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * outputs a fence file descriptor should be used in its place. 514a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 515a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, 516a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindowBuffer** buffer); 517a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 518a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 519a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * hook called by EGL to lock a buffer. This MUST be called before modifying 520a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * the content of a buffer. The buffer must have been acquired with 521a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * dequeueBuffer first. 522a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 523a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 0 on success or -errno on error. 524a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 525a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * XXX: This function is deprecated. It will continue to work for some 526a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * time for binary compatibility, but it is essentially a no-op, and calls 527a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to it should be removed. 528a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 529a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, 530a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindowBuffer* buffer); 531a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 532a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 533a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Hook called by EGL when modifications to the render buffer are done. 534a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * This unlocks and post the buffer. 535a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 536a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The window holds a reference to the buffer between dequeueBuffer and 537a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * either queueBuffer or cancelBuffer, so clients only need their own 538a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reference if they might use the buffer after queueing or canceling it. 539a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Holding a reference to a buffer after queueing or canceling it is only 540a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * allowed if a specific buffer count has been set. 541a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 542a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Buffers MUST be queued in the same order than they were dequeued. 543a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 544a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 0 on success or -errno on error. 545a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 546a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * XXX: This function is deprecated. It will continue to work for some 547a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * time for binary compatibility, but the new queueBuffer function that 548a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * takes a fence file descriptor should be used in its place (pass a value 549a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * of -1 for the fence file descriptor if there is no valid one to pass). 550a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 551a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, 552a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindowBuffer* buffer); 553a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 554a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 555a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * hook used to retrieve information about the native window. 556a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 557a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 0 on success or -errno on error. 558a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 559a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*query)(const struct ANativeWindow* window, 560a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int what, int* value); 561a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 562a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 563a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * hook used to perform various operations on the surface. 564a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * (*perform)() is a generic mechanism to add functionality to 565a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * ANativeWindow while keeping backward binary compatibility. 566a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 567a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions 568a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * defined below. 569a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 570a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * (*perform)() returns -ENOENT if the 'what' parameter is not supported 571a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * by the surface's implementation. 572a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 573a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * See above for a list of valid operations, such as 574a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT 575a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 576a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*perform)(struct ANativeWindow* window, 577a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int operation, ... ); 578a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 579a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 580a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Hook used to cancel a buffer that has been dequeued. 581a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * No synchronization is performed between dequeue() and cancel(), so 582a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * either external synchronization is needed, or these functions must be 583a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * called from the same thread. 584a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 585a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The window holds a reference to the buffer between dequeueBuffer and 586a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * either queueBuffer or cancelBuffer, so clients only need their own 587a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reference if they might use the buffer after queueing or canceling it. 588a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Holding a reference to a buffer after queueing or canceling it is only 589a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * allowed if a specific buffer count has been set. 590a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 591a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * XXX: This function is deprecated. It will continue to work for some 592a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * time for binary compatibility, but the new cancelBuffer function that 593a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * takes a fence file descriptor should be used in its place (pass a value 594a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * of -1 for the fence file descriptor if there is no valid one to pass). 595a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 596a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, 597a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindowBuffer* buffer); 598a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 599a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 600a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Hook called by EGL to acquire a buffer. This call may block if no 601a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffers are available. 602a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 603a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The window holds a reference to the buffer between dequeueBuffer and 604a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * either queueBuffer or cancelBuffer, so clients only need their own 605a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reference if they might use the buffer after queueing or canceling it. 606a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Holding a reference to a buffer after queueing or canceling it is only 607a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * allowed if a specific buffer count has been set. 608a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 609a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The libsync fence file descriptor returned in the int pointed to by the 610a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * fenceFd argument will refer to the fence that must signal before the 611a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * dequeued buffer may be written to. A value of -1 indicates that the 612a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * caller may access the buffer immediately without waiting on a fence. If 613a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * a valid file descriptor is returned (i.e. any value except -1) then the 614a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * caller is responsible for closing the file descriptor. 615a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 616a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 0 on success or -errno on error. 617a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 618a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*dequeueBuffer)(struct ANativeWindow* window, 619a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindowBuffer** buffer, int* fenceFd); 620a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 621a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 622a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Hook called by EGL when modifications to the render buffer are done. 623a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * This unlocks and post the buffer. 624a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 625a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The window holds a reference to the buffer between dequeueBuffer and 626a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * either queueBuffer or cancelBuffer, so clients only need their own 627a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reference if they might use the buffer after queueing or canceling it. 628a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Holding a reference to a buffer after queueing or canceling it is only 629a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * allowed if a specific buffer count has been set. 630a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 631a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The fenceFd argument specifies a libsync fence file descriptor for a 632a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * fence that must signal before the buffer can be accessed. If the buffer 633a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * can be accessed immediately then a value of -1 should be used. The 634a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * caller must not use the file descriptor after it is passed to 635a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * queueBuffer, and the ANativeWindow implementation is responsible for 636a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * closing it. 637a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 638a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 0 on success or -errno on error. 639a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 640a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*queueBuffer)(struct ANativeWindow* window, 641a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindowBuffer* buffer, int fenceFd); 642a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 643a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* 644a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Hook used to cancel a buffer that has been dequeued. 645a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * No synchronization is performed between dequeue() and cancel(), so 646a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * either external synchronization is needed, or these functions must be 647a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * called from the same thread. 648a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 649a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The window holds a reference to the buffer between dequeueBuffer and 650a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * either queueBuffer or cancelBuffer, so clients only need their own 651a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reference if they might use the buffer after queueing or canceling it. 652a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Holding a reference to a buffer after queueing or canceling it is only 653a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * allowed if a specific buffer count has been set. 654a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 655a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The fenceFd argument specifies a libsync fence file decsriptor for a 656a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * fence that must signal before the buffer can be accessed. If the buffer 657a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * can be accessed immediately then a value of -1 should be used. 658a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 659a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Note that if the client has not waited on the fence that was returned 660a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * from dequeueBuffer, that same fence should be passed to cancelBuffer to 661a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * ensure that future uses of the buffer are preceded by a wait on that 662a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * fence. The caller must not use the file descriptor after it is passed 663a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to cancelBuffer, and the ANativeWindow implementation is responsible for 664a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * closing it. 665a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 666a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns 0 on success or -errno on error. 667a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 668a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int (*cancelBuffer)(struct ANativeWindow* window, 669a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindowBuffer* buffer, int fenceFd); 670a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}; 671a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 672a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). 673a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * android_native_window_t is deprecated. 674a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 675a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct ANativeWindow ANativeWindow; 676a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct ANativeWindow android_native_window_t __deprecated; 677a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 678a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 679a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_usage(..., usage) 680a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets the intended usage flags for the next buffers 681a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * acquired with (*lockBuffer)() and on. 682a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * By default (if this function is never called), a usage of 683a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE 684a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * is assumed. 685a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Calling this function will usually cause following buffers to be 686a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reallocated. 687a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 688a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 689a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_usage( 690a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, int usage) 691a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 692a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); 693a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 694a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 695a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* deprecated. Always returns 0. Don't call. */ 696a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_connect( 697a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; 698a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 699a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_connect( 700a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window __UNUSED, int api __UNUSED) { 701a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return 0; 702a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 703a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 704a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* deprecated. Always returns 0. Don't call. */ 705a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_disconnect( 706a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; 707a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 708a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_disconnect( 709a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window __UNUSED, int api __UNUSED) { 710a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return 0; 711a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 712a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 713a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 714a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_crop(..., crop) 715a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets which region of the next queued buffers needs to be considered. 716a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Depending on the scaling mode, a buffer's crop region is scaled and/or 717a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * cropped to match the surface's size. This function sets the crop in 718a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * pre-transformed buffer pixel coordinates. 719a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 720a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The specified crop region applies to all buffers queued after it is called. 721a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 722a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If 'crop' is NULL, subsequently queued buffers won't be cropped. 723a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 724a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * An error is returned if for instance the crop region is invalid, out of the 725a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffer's bound or if the window is invalid. 726a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 727a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_crop( 728a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 729a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian android_native_rect_t const * crop) 730a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 731a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); 732a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 733a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 734a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 735a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_post_transform_crop(..., crop) 736a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets which region of the next queued buffers needs to be considered. 737a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Depending on the scaling mode, a buffer's crop region is scaled and/or 738a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * cropped to match the surface's size. This function sets the crop in 739a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * post-transformed pixel coordinates. 740a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 741a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The specified crop region applies to all buffers queued after it is called. 742a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 743a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If 'crop' is NULL, subsequently queued buffers won't be cropped. 744a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 745a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * An error is returned if for instance the crop region is invalid, out of the 746a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffer's bound or if the window is invalid. 747a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 748a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_post_transform_crop( 749a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 750a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian android_native_rect_t const * crop) 751a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 752a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop); 753a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 754a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 755a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 756a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_active_rect(..., active_rect) 757a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 758a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * This function is deprecated and will be removed soon. For now it simply 759a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * sets the post-transform crop for compatibility while multi-project commits 760a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * get checked. 761a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 762a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_active_rect( 763a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 764a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian android_native_rect_t const * active_rect) __deprecated; 765a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 766a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_active_rect( 767a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 768a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian android_native_rect_t const * active_rect) 769a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 770a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return native_window_set_post_transform_crop(window, active_rect); 771a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 772a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 773a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 774a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffer_count(..., count) 775a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets the number of buffers associated with this native window. 776a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 777a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffer_count( 778a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 779a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian size_t bufferCount) 780a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 781a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); 782a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 783a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 784a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 785a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_geometry(..., int w, int h, int format) 786a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers dequeued after this call will have the dimensions and format 787a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * specified. A successful call to this function has the same effect as calling 788a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_size and native_window_set_buffers_format. 789a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 790a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * XXX: This function is deprecated. The native_window_set_buffers_dimensions 791a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * and native_window_set_buffers_format functions should be used instead. 792a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 793a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_geometry( 794a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 795a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int w, int h, int format) __deprecated; 796a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 797a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_geometry( 798a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 799a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int w, int h, int format) 800a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 801a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, 802a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian w, h, format); 803a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 804a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 805a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 806a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_dimensions(..., int w, int h) 807a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers dequeued after this call will have the dimensions specified. 808a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * In particular, all buffers will have a fixed-size, independent from the 809a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native-window size. They will be scaled according to the scaling mode 810a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * (see native_window_set_scaling_mode) upon window composition. 811a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 812a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If w and h are 0, the normal behavior is restored. That is, dequeued buffers 813a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * following this call will be sized to match the window's size. 814a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 815a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Calling this function will reset the window crop to a NULL value, which 816a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * disables cropping of the buffers. 817a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 818a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_dimensions( 819a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 820a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int w, int h) 821a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 822a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, 823a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian w, h); 824a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 825a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 826a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 827a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_user_dimensions(..., int w, int h) 828a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 829a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets the user buffer size for the window, which overrides the 830a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * window's size. All buffers dequeued after this call will have the 831a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * dimensions specified unless overridden by 832a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_dimensions. All buffers will have a 833a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * fixed-size, independent from the native-window size. They will be 834a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * scaled according to the scaling mode (see 835a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_scaling_mode) upon window composition. 836a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 837a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If w and h are 0, the normal behavior is restored. That is, the 838a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * default buffer size will match the windows's size. 839a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 840a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Calling this function will reset the window crop to a NULL value, which 841a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * disables cropping of the buffers. 842a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 843a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_user_dimensions( 844a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 845a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int w, int h) 846a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 847a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, 848a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian w, h); 849a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 850a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 851a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 852a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_format(..., int format) 853a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers dequeued after this call will have the format specified. 854a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 855a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If the specified format is 0, the default buffer format will be used. 856a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 857a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_format( 858a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 859a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int format) 860a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 861a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); 862a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 863a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 864a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 865a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_data_space(..., int dataSpace) 866a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be associated with the dataSpace 867a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * parameter specified. 868a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 869a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * dataSpace specifies additional information about the buffer that's dependent 870a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * on the buffer format and the endpoints. For example, it can be used to convey 871a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * the color space of the image data in the buffer, or it can be used to 872a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * indicate that the buffers contain depth measurement data instead of color 873a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been 874a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * overridden by the consumer. 875a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 876a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_data_space( 877a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 878a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian android_dataspace_t dataSpace) 879a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 880a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, 881a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian dataSpace); 882a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 883a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 884a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 885a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_transform(..., int transform) 886a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be displayed transformed according 887a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to the transform parameter specified. 888a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 889a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_transform( 890a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 891a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int transform) 892a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 893a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, 894a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian transform); 895a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 896a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 897a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 898a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_sticky_transform(..., int transform) 899a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be displayed transformed according 900a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to the transform parameter specified applied on top of the regular buffer 901a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * transform. Setting this transform will disable the transform hint. 902a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 903a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Temporary - This is only intended to be used by the LEGACY camera mode, do 904a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * not use this for anything else. 905a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 906a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_sticky_transform( 907a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 908a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int transform) 909a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 910a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, 911a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian transform); 912a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 913a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 914a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 915a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_timestamp(..., int64_t timestamp) 916a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be associated with the timestamp 917a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO 918a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * (the default), timestamps will be generated automatically when queueBuffer is 919a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * called. The timestamp is measured in nanoseconds, and is normally monotonically 920a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * increasing. The timestamp should be unaffected by time-of-day adjustments, 921a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * and for a camera should be strictly monotonic but for a media player may be 922a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reset when the position is set. 923a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 924a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_timestamp( 925a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 926a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t timestamp) 927a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 928a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, 929a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian timestamp); 930a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 931a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 932a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 933a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_scaling_mode(..., int mode) 934a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be associated with the scaling mode 935a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * specified. 936a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 937a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_scaling_mode( 938a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 939a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int mode) 940a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 941a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, 942a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian mode); 943a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 944a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 945a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 946a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_api_connect(..., int api) 947a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * connects an API to this window. only one API can be connected at a time. 948a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns -EINVAL if for some reason the window cannot be connected, which 949a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * can happen if it's connected to some other API. 950a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 951a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_api_connect( 952a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, int api) 953a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 954a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); 955a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 956a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 957a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 958a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_api_disconnect(..., int api) 959a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * disconnect the API from this window. 960a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * An error is returned if for instance the window wasn't connected in the 961a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * first place. 962a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 963a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_api_disconnect( 964a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, int api) 965a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 966a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); 967a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 968a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 969a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 970a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_dequeue_buffer_and_wait(...) 971a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Dequeue a buffer and wait on the fence associated with that buffer. The 972a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffer may safely be accessed immediately upon this function returning. An 973a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * error is returned if either of the dequeue or the wait operations fail. 974a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 975a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, 976a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindowBuffer** anb) { 977a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return anw->dequeueBuffer_DEPRECATED(anw, anb); 978a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 979a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 980a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 981a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_sideband_stream(..., native_handle_t*) 982a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Attach a sideband buffer stream to a native window. 983a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 984a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_sideband_stream( 985a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 986a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian native_handle_t* sidebandHandle) 987a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 988a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, 989a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian sidebandHandle); 990a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 991a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 992a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 993a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) 994a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Set the surface damage (i.e., the region of the surface that has changed 995a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * since the previous frame). The damage set by this call will be reset (to the 996a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * default of full-surface damage) after calling queue, so this must be called 997a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * prior to every frame with damage that does not cover the whole surface if the 998a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * caller desires downstream consumers to use this optimization. 999a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 1000a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The damage region is specified as an array of rectangles, with the important 1001a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * caveat that the origin of the surface is considered to be the bottom-left 1002a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * corner, as in OpenGL ES. 1003a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * 1004a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If numRects is set to 0, rects may be NULL, and the surface damage will be 1005a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * set to the full surface (the same as if this function had not been called for 1006a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * this frame). 1007a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 1008a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_surface_damage( 1009a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 1010a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian const android_native_rect_t* rects, size_t numRects) 1011a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 1012a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, 1013a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian rects, numRects); 1014a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1015a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1016a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 1017a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_shared_buffer_mode(..., bool sharedBufferMode) 1018a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Enable/disable shared buffer mode 1019a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 1020a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_shared_buffer_mode( 1021a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 1022a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian bool sharedBufferMode) 1023a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 1024a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE, 1025a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian sharedBufferMode); 1026a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1027a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1028a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* 1029a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_auto_refresh(..., autoRefresh) 1030a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Enable/disable auto refresh when in shared buffer mode 1031a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */ 1032a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_auto_refresh( 1033a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 1034a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian bool autoRefresh) 1035a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 1036a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh); 1037a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1038a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1039a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_refresh_cycle_duration( 1040a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 1041a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t* outRefreshDuration) 1042a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 1043a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION, 1044a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian outRefreshDuration); 1045a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1046a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1047a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_next_frame_id( 1048a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, uint64_t* frameId) 1049a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 1050a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_GET_NEXT_FRAME_ID, frameId); 1051a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1052a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1053a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_enable_frame_timestamps( 1054a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, bool enable) 1055a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 1056a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS, 1057a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian enable); 1058a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1059a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1060a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_compositor_timing( 1061a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, 1062a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t* compositeDeadline, int64_t* compositeInterval, 1063a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t* compositeToPresentLatency) 1064a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 1065a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_GET_COMPOSITOR_TIMING, 1066a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian compositeDeadline, compositeInterval, compositeToPresentLatency); 1067a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1068a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1069a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_frame_timestamps( 1070a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, uint64_t frameId, 1071a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t* outRequestedPresentTime, int64_t* outAcquireTime, 1072a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t* outLatchTime, int64_t* outFirstRefreshStartTime, 1073a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t* outLastRefreshStartTime, int64_t* outGpuCompositionDoneTime, 1074a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t* outDisplayPresentTime, int64_t* outDequeueReadyTime, 1075a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian int64_t* outReleaseTime) 1076a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{ 1077a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS, 1078a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian frameId, outRequestedPresentTime, outAcquireTime, outLatchTime, 1079a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian outFirstRefreshStartTime, outLastRefreshStartTime, 1080a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian outGpuCompositionDoneTime, outDisplayPresentTime, 1081a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian outDequeueReadyTime, outReleaseTime); 1082a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1083a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1084a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_wide_color_support( 1085a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian struct ANativeWindow* window, bool* outSupport) { 1086a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT, 1087a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian outSupport); 1088a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1089a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1090a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_hdr_support(struct ANativeWindow* window, 1091a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian bool* outSupport) { 1092a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian return window->perform(window, NATIVE_WINDOW_GET_HDR_SUPPORT, outSupport); 1093a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} 1094a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian 1095a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian__END_DECLS 1096