blob: 1a036df1a18a9bc59c08e070d51dca5d13471126 [file] [log] [blame]
Iliyan Malchev0ab886b2011-05-01 14:07:43 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
18#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
19
20#include <stdint.h>
Mathias Agopianc958a7f2012-02-25 21:13:36 -080021#include <string.h>
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070022#include <sys/cdefs.h>
23#include <system/graphics.h>
24#include <cutils/native_handle.h>
25
26__BEGIN_DECLS
27
28/*****************************************************************************/
29
30#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
31 (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
32
33#define ANDROID_NATIVE_WINDOW_MAGIC \
34 ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
35
36#define ANDROID_NATIVE_BUFFER_MAGIC \
37 ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
38
39// ---------------------------------------------------------------------------
40
41typedef const native_handle_t* buffer_handle_t;
42
43// ---------------------------------------------------------------------------
44
45typedef struct android_native_rect_t
46{
47 int32_t left;
48 int32_t top;
49 int32_t right;
50 int32_t bottom;
51} android_native_rect_t;
52
53// ---------------------------------------------------------------------------
54
55typedef struct android_native_base_t
56{
57 /* a magic value defined by the actual EGL native type */
58 int magic;
59
60 /* the sizeof() of the actual EGL native type */
61 int version;
62
63 void* reserved[4];
64
65 /* reference-counting interface */
66 void (*incRef)(struct android_native_base_t* base);
67 void (*decRef)(struct android_native_base_t* base);
68} android_native_base_t;
69
70typedef struct ANativeWindowBuffer
71{
72#ifdef __cplusplus
73 ANativeWindowBuffer() {
74 common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
75 common.version = sizeof(ANativeWindowBuffer);
76 memset(common.reserved, 0, sizeof(common.reserved));
77 }
78
79 // Implement the methods that sp<ANativeWindowBuffer> expects so that it
80 // can be used to automatically refcount ANativeWindowBuffer's.
81 void incStrong(const void* id) const {
82 common.incRef(const_cast<android_native_base_t*>(&common));
83 }
84 void decStrong(const void* id) const {
85 common.decRef(const_cast<android_native_base_t*>(&common));
86 }
87#endif
88
89 struct android_native_base_t common;
90
91 int width;
92 int height;
93 int stride;
94 int format;
95 int usage;
96
97 void* reserved[2];
98
99 buffer_handle_t handle;
100
101 void* reserved_proc[8];
102} ANativeWindowBuffer_t;
103
104// Old typedef for backwards compatibility.
105typedef ANativeWindowBuffer_t android_native_buffer_t;
106
107// ---------------------------------------------------------------------------
108
109/* attributes queriable with query() */
110enum {
111 NATIVE_WINDOW_WIDTH = 0,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700112 NATIVE_WINDOW_HEIGHT = 1,
113 NATIVE_WINDOW_FORMAT = 2,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700114
115 /* The minimum number of buffers that must remain un-dequeued after a buffer
116 * has been queued. This value applies only if set_buffer_count was used to
117 * override the number of buffers and if a buffer has since been queued.
118 * Users of the set_buffer_count ANativeWindow method should query this
119 * value before calling set_buffer_count. If it is necessary to have N
120 * buffers simultaneously dequeued as part of the steady-state operation,
121 * and this query returns M then N+M buffers should be requested via
122 * native_window_set_buffer_count.
123 *
124 * Note that this value does NOT apply until a single buffer has been
125 * queued. In particular this means that it is possible to:
126 *
127 * 1. Query M = min undequeued buffers
128 * 2. Set the buffer count to N + M
129 * 3. Dequeue all N + M buffers
130 * 4. Cancel M buffers
131 * 5. Queue, dequeue, queue, dequeue, ad infinitum
132 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700133 NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700134
135 /* Check whether queueBuffer operations on the ANativeWindow send the buffer
136 * to the window compositor. The query sets the returned 'value' argument
137 * to 1 if the ANativeWindow DOES send queued buffers directly to the window
138 * compositor and 0 if the buffers do not go directly to the window
139 * compositor.
140 *
141 * This can be used to determine whether protected buffer content should be
142 * sent to the ANativeWindow. Note, however, that a result of 1 does NOT
143 * indicate that queued buffers will be protected from applications or users
144 * capturing their contents. If that behavior is desired then some other
145 * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
146 * conjunction with this query.
147 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700148 NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700149
150 /* Get the concrete type of a ANativeWindow. See below for the list of
151 * possible return values.
152 *
153 * This query should not be used outside the Android framework and will
154 * likely be removed in the near future.
155 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700156 NATIVE_WINDOW_CONCRETE_TYPE = 5,
Mathias Agopian51009162011-07-19 15:59:15 -0700157
158
159 /*
Michael I. Goldafcdef62012-04-09 18:21:13 -0700160 * Default width and height of ANativeWindow buffers, these are the
161 * dimensions of the window buffers irrespective of the
162 * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
Jamie Gennisaa3f4c32012-04-17 19:37:48 -0700163 * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
Mathias Agopian51009162011-07-19 15:59:15 -0700164 */
165 NATIVE_WINDOW_DEFAULT_WIDTH = 6,
166 NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
167
168 /*
169 * transformation that will most-likely be applied to buffers. This is only
170 * a hint, the actual transformation applied might be different.
171 *
172 * INTENDED USE:
173 *
174 * The transform hint can be used by a producer, for instance the GLES
175 * driver, to pre-rotate the rendering such that the final transformation
176 * in the composer is identity. This can be very useful when used in
177 * conjunction with the h/w composer HAL, in situations where it
178 * cannot handle arbitrary rotations.
179 *
180 * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
181 * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
182 *
183 * 2. The GL driver overrides the width and height of the ANW to
184 * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
185 * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
186 * according to NATIVE_WINDOW_TRANSFORM_HINT and calling
187 * native_window_set_buffers_dimensions().
188 *
189 * 3. The GL driver dequeues a buffer of the new pre-rotated size.
190 *
191 * 4. The GL driver renders to the buffer such that the image is
192 * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
193 * to the rendering.
194 *
195 * 5. The GL driver calls native_window_set_transform to apply
196 * inverse transformation to the buffer it just rendered.
197 * In order to do this, the GL driver needs
198 * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
199 * done easily:
200 *
201 * int hintTransform, inverseTransform;
202 * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
203 * inverseTransform = hintTransform;
204 * if (hintTransform & HAL_TRANSFORM_ROT_90)
205 * inverseTransform ^= HAL_TRANSFORM_ROT_180;
206 *
207 *
208 * 6. The GL driver queues the pre-transformed buffer.
209 *
210 * 7. The composer combines the buffer transform with the display
211 * transform. If the buffer transform happens to cancel out the
212 * display transform then no rotation is needed.
213 *
214 */
215 NATIVE_WINDOW_TRANSFORM_HINT = 8,
Jamie Gennisaa3f4c32012-04-17 19:37:48 -0700216
217 /*
218 * Boolean that indicates whether the consumer is running more than
219 * one buffer behind the producer.
220 */
221 NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700222};
223
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700224/* Valid operations for the (*perform)() hook.
225 *
226 * Values marked as 'deprecated' are supported, but have been superceded by
227 * other functionality.
228 *
229 * Values marked as 'private' should be considered private to the framework.
230 * HAL implementation code with access to an ANativeWindow should not use these,
231 * as it may not interact properly with the framework's use of the
232 * ANativeWindow.
233 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700234enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700235 NATIVE_WINDOW_SET_USAGE = 0,
Mathias Agopian8ad54522011-07-29 17:52:36 -0700236 NATIVE_WINDOW_CONNECT = 1, /* deprecated */
237 NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700238 NATIVE_WINDOW_SET_CROP = 3, /* private */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700239 NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
240 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
241 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
242 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
243 NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
244 NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700245 NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */
Mathias Agopianae3736a2011-07-13 18:40:38 -0700246 NATIVE_WINDOW_LOCK = 11, /* private */
247 NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
Mathias Agopian8ad54522011-07-29 17:52:36 -0700248 NATIVE_WINDOW_API_CONNECT = 13, /* private */
249 NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
Michael I. Goldafcdef62012-04-09 18:21:13 -0700250 NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700251 NATIVE_WINDOW_SET_ACTIVE_RECT = 16, /* private */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700252};
253
Mathias Agopian8ad54522011-07-29 17:52:36 -0700254/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700255enum {
Jamie Gennis5423e9e2011-07-12 13:53:42 -0700256 /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
257 * OpenGL ES.
258 */
259 NATIVE_WINDOW_API_EGL = 1,
260
261 /* Buffers will be queued after being filled using the CPU
262 */
263 NATIVE_WINDOW_API_CPU = 2,
264
265 /* Buffers will be queued by Stagefright after being filled by a video
266 * decoder. The video decoder can either be a software or hardware decoder.
267 */
268 NATIVE_WINDOW_API_MEDIA = 3,
269
270 /* Buffers will be queued by the the camera HAL.
271 */
272 NATIVE_WINDOW_API_CAMERA = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700273};
274
275/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
276enum {
277 /* flip source image horizontally */
278 NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
279 /* flip source image vertically */
280 NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
281 /* rotate source image 90 degrees clock-wise */
282 NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
283 /* rotate source image 180 degrees */
284 NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
285 /* rotate source image 270 degrees clock-wise */
286 NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
287};
288
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700289/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */
290enum {
291 /* the window content is not updated (frozen) until a buffer of
292 * the window size is received (enqueued)
293 */
294 NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
295 /* the buffer is scaled in both dimensions to match the window size */
296 NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
Daniel Lam29392a42012-04-11 18:19:46 -0700297 /* the buffer is scaled uniformly such that the smaller dimension
298 * of the buffer matches the window size (cropping in the process)
299 */
300 NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700301};
302
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700303/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
304enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700305 NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
306 NATIVE_WINDOW_SURFACE = 1, /* Surface */
307 NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT = 2, /* SurfaceTextureClient */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700308};
309
310/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
311 *
312 * Special timestamp value to indicate that timestamps should be auto-generated
313 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
314 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
315 */
316static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
317
318struct ANativeWindow
319{
320#ifdef __cplusplus
321 ANativeWindow()
322 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
323 {
324 common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
325 common.version = sizeof(ANativeWindow);
326 memset(common.reserved, 0, sizeof(common.reserved));
327 }
328
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700329 /* Implement the methods that sp<ANativeWindow> expects so that it
330 can be used to automatically refcount ANativeWindow's. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700331 void incStrong(const void* id) const {
332 common.incRef(const_cast<android_native_base_t*>(&common));
333 }
334 void decStrong(const void* id) const {
335 common.decRef(const_cast<android_native_base_t*>(&common));
336 }
337#endif
338
339 struct android_native_base_t common;
340
341 /* flags describing some attributes of this surface or its updater */
342 const uint32_t flags;
343
344 /* min swap interval supported by this updated */
345 const int minSwapInterval;
346
347 /* max swap interval supported by this updated */
348 const int maxSwapInterval;
349
350 /* horizontal and vertical resolution in DPI */
351 const float xdpi;
352 const float ydpi;
353
354 /* Some storage reserved for the OEM's driver. */
355 intptr_t oem[4];
356
357 /*
358 * Set the swap interval for this surface.
359 *
360 * Returns 0 on success or -errno on error.
361 */
362 int (*setSwapInterval)(struct ANativeWindow* window,
363 int interval);
364
365 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800366 * Hook called by EGL to acquire a buffer. After this call, the buffer
367 * is not locked, so its content cannot be modified. This call may block if
368 * no buffers are available.
369 *
370 * The window holds a reference to the buffer between dequeueBuffer and
371 * either queueBuffer or cancelBuffer, so clients only need their own
372 * reference if they might use the buffer after queueing or canceling it.
373 * Holding a reference to a buffer after queueing or canceling it is only
374 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700375 *
376 * Returns 0 on success or -errno on error.
377 */
378 int (*dequeueBuffer)(struct ANativeWindow* window,
379 struct ANativeWindowBuffer** buffer);
380
381 /*
382 * hook called by EGL to lock a buffer. This MUST be called before modifying
383 * the content of a buffer. The buffer must have been acquired with
384 * dequeueBuffer first.
385 *
386 * Returns 0 on success or -errno on error.
387 */
388 int (*lockBuffer)(struct ANativeWindow* window,
389 struct ANativeWindowBuffer* buffer);
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800390 /*
391 * Hook called by EGL when modifications to the render buffer are done.
392 * This unlocks and post the buffer.
393 *
394 * The window holds a reference to the buffer between dequeueBuffer and
395 * either queueBuffer or cancelBuffer, so clients only need their own
396 * reference if they might use the buffer after queueing or canceling it.
397 * Holding a reference to a buffer after queueing or canceling it is only
398 * allowed if a specific buffer count has been set.
399 *
400 * Buffers MUST be queued in the same order than they were dequeued.
401 *
402 * Returns 0 on success or -errno on error.
403 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700404 int (*queueBuffer)(struct ANativeWindow* window,
405 struct ANativeWindowBuffer* buffer);
406
407 /*
408 * hook used to retrieve information about the native window.
409 *
410 * Returns 0 on success or -errno on error.
411 */
412 int (*query)(const struct ANativeWindow* window,
413 int what, int* value);
414
415 /*
416 * hook used to perform various operations on the surface.
417 * (*perform)() is a generic mechanism to add functionality to
418 * ANativeWindow while keeping backward binary compatibility.
419 *
420 * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
421 * defined below.
422 *
423 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
424 * by the surface's implementation.
425 *
426 * The valid operations are:
427 * NATIVE_WINDOW_SET_USAGE
Mathias Agopian8ad54522011-07-29 17:52:36 -0700428 * NATIVE_WINDOW_CONNECT (deprecated)
429 * NATIVE_WINDOW_DISCONNECT (deprecated)
Jamie Gennis190b6e22012-04-30 16:32:06 -0700430 * NATIVE_WINDOW_SET_CROP (private)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700431 * NATIVE_WINDOW_SET_BUFFER_COUNT
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700432 * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700433 * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
434 * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700435 * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
436 * NATIVE_WINDOW_SET_BUFFERS_FORMAT
Jamie Gennis190b6e22012-04-30 16:32:06 -0700437 * NATIVE_WINDOW_SET_SCALING_MODE (private)
Mathias Agopianae3736a2011-07-13 18:40:38 -0700438 * NATIVE_WINDOW_LOCK (private)
439 * NATIVE_WINDOW_UNLOCK_AND_POST (private)
Mathias Agopian8ad54522011-07-29 17:52:36 -0700440 * NATIVE_WINDOW_API_CONNECT (private)
441 * NATIVE_WINDOW_API_DISCONNECT (private)
Michael I. Goldafcdef62012-04-09 18:21:13 -0700442 * NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS (private)
Jamie Gennis190b6e22012-04-30 16:32:06 -0700443 * NATIVE_WINDOW_SET_ACTIVE_RECT (private)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700444 *
445 */
446
447 int (*perform)(struct ANativeWindow* window,
448 int operation, ... );
449
450 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800451 * Hook used to cancel a buffer that has been dequeued.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700452 * No synchronization is performed between dequeue() and cancel(), so
453 * either external synchronization is needed, or these functions must be
454 * called from the same thread.
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800455 *
456 * The window holds a reference to the buffer between dequeueBuffer and
457 * either queueBuffer or cancelBuffer, so clients only need their own
458 * reference if they might use the buffer after queueing or canceling it.
459 * Holding a reference to a buffer after queueing or canceling it is only
460 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700461 */
462 int (*cancelBuffer)(struct ANativeWindow* window,
463 struct ANativeWindowBuffer* buffer);
464
465
466 void* reserved_proc[2];
467};
468
469 /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
470 * android_native_window_t is deprecated.
471 */
472typedef struct ANativeWindow ANativeWindow;
473typedef struct ANativeWindow android_native_window_t;
474
475/*
476 * native_window_set_usage(..., usage)
477 * Sets the intended usage flags for the next buffers
478 * acquired with (*lockBuffer)() and on.
479 * By default (if this function is never called), a usage of
480 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
481 * is assumed.
482 * Calling this function will usually cause following buffers to be
483 * reallocated.
484 */
485
486static inline int native_window_set_usage(
487 struct ANativeWindow* window, int usage)
488{
489 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
490}
491
Mathias Agopian8ad54522011-07-29 17:52:36 -0700492/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700493static inline int native_window_connect(
Mathias Agopian8ad54522011-07-29 17:52:36 -0700494 struct ANativeWindow* window, int api) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700495 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700496}
497
Mathias Agopian8ad54522011-07-29 17:52:36 -0700498/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700499static inline int native_window_disconnect(
Mathias Agopian8ad54522011-07-29 17:52:36 -0700500 struct ANativeWindow* window, int api) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700501 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700502}
503
504/*
505 * native_window_set_crop(..., crop)
506 * Sets which region of the next queued buffers needs to be considered.
507 * A buffer's crop region is scaled to match the surface's size.
508 *
509 * The specified crop region applies to all buffers queued after it is called.
510 *
511 * if 'crop' is NULL, subsequently queued buffers won't be cropped.
512 *
513 * An error is returned if for instance the crop region is invalid,
514 * out of the buffer's bound or if the window is invalid.
515 */
516static inline int native_window_set_crop(
517 struct ANativeWindow* window,
518 android_native_rect_t const * crop)
519{
520 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
521}
522
523/*
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700524 * native_window_set_active_rect(..., active_rect)
525 * Sets the region of future queued buffers that are 'active'. Pixels outside
526 * this 'active' region are considered to be completely transparent regardless
527 * of the pixel values in the buffer. The active_rect argument specifies the
528 * active rectangle in buffer pixel coordinates.
529 *
530 * The specified active rectangle applies to all buffers queued after it is
531 * called.
532 *
533 * An error is returned if for instance the crop region is invalid,
534 * out of the buffer's bound or if the window is invalid.
535 */
536static inline int native_window_set_active_rect(
537 struct ANativeWindow* window,
538 android_native_rect_t const * active_rect)
539{
540 return window->perform(window, NATIVE_WINDOW_SET_ACTIVE_RECT, active_rect);
541}
542
543/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700544 * native_window_set_buffer_count(..., count)
545 * Sets the number of buffers associated with this native window.
546 */
547static inline int native_window_set_buffer_count(
548 struct ANativeWindow* window,
549 size_t bufferCount)
550{
551 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
552}
553
554/*
555 * native_window_set_buffers_geometry(..., int w, int h, int format)
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700556 * All buffers dequeued after this call will have the dimensions and format
557 * specified. A successful call to this function has the same effect as calling
558 * native_window_set_buffers_size and native_window_set_buffers_format.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700559 *
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700560 * XXX: This function is deprecated. The native_window_set_buffers_dimensions
561 * and native_window_set_buffers_format functions should be used instead.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700562 */
563static inline int native_window_set_buffers_geometry(
564 struct ANativeWindow* window,
565 int w, int h, int format)
566{
567 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
568 w, h, format);
569}
570
571/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700572 * native_window_set_buffers_dimensions(..., int w, int h)
573 * All buffers dequeued after this call will have the dimensions specified.
Michael I. Goldafcdef62012-04-09 18:21:13 -0700574 * In particular, all buffers will have a fixed-size, independent from the
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700575 * native-window size. They will be scaled according to the scaling mode
576 * (see native_window_set_scaling_mode) upon window composition.
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700577 *
578 * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
579 * following this call will be sized to match the window's size.
580 *
581 * Calling this function will reset the window crop to a NULL value, which
582 * disables cropping of the buffers.
583 */
584static inline int native_window_set_buffers_dimensions(
585 struct ANativeWindow* window,
586 int w, int h)
587{
588 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
589 w, h);
590}
591
592/*
Michael I. Goldafcdef62012-04-09 18:21:13 -0700593 * native_window_set_buffers_user_dimensions(..., int w, int h)
594 *
595 * Sets the user buffer size for the window, which overrides the
596 * window's size. All buffers dequeued after this call will have the
597 * dimensions specified unless overridden by
598 * native_window_set_buffers_dimensions. All buffers will have a
599 * fixed-size, independent from the native-window size. They will be
600 * scaled according to the scaling mode (see
601 * native_window_set_scaling_mode) upon window composition.
602 *
603 * If w and h are 0, the normal behavior is restored. That is, the
604 * default buffer size will match the windows's size.
605 *
606 * Calling this function will reset the window crop to a NULL value, which
607 * disables cropping of the buffers.
608 */
609static inline int native_window_set_buffers_user_dimensions(
610 struct ANativeWindow* window,
611 int w, int h)
612{
613 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
614 w, h);
615}
616
617/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700618 * native_window_set_buffers_format(..., int format)
619 * All buffers dequeued after this call will have the format specified.
620 *
621 * If the specified format is 0, the default buffer format will be used.
622 */
623static inline int native_window_set_buffers_format(
624 struct ANativeWindow* window,
625 int format)
626{
627 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
628}
629
630/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700631 * native_window_set_buffers_transform(..., int transform)
632 * All buffers queued after this call will be displayed transformed according
633 * to the transform parameter specified.
634 */
635static inline int native_window_set_buffers_transform(
636 struct ANativeWindow* window,
637 int transform)
638{
639 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
640 transform);
641}
642
643/*
644 * native_window_set_buffers_timestamp(..., int64_t timestamp)
645 * All buffers queued after this call will be associated with the timestamp
646 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
647 * (the default), timestamps will be generated automatically when queueBuffer is
Glenn Kastenc322f672011-06-27 10:42:39 -0700648 * called. The timestamp is measured in nanoseconds, and is normally monotonically
649 * increasing. The timestamp should be unaffected by time-of-day adjustments,
650 * and for a camera should be strictly monotonic but for a media player may be
651 * reset when the position is set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700652 */
653static inline int native_window_set_buffers_timestamp(
654 struct ANativeWindow* window,
655 int64_t timestamp)
656{
657 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
658 timestamp);
659}
660
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700661/*
662 * native_window_set_scaling_mode(..., int mode)
663 * All buffers queued after this call will be associated with the scaling mode
664 * specified.
665 */
666static inline int native_window_set_scaling_mode(
667 struct ANativeWindow* window,
668 int mode)
669{
670 return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
671 mode);
672}
673
Mathias Agopian8ad54522011-07-29 17:52:36 -0700674/*
675 * native_window_api_connect(..., int api)
676 * connects an API to this window. only one API can be connected at a time.
677 * Returns -EINVAL if for some reason the window cannot be connected, which
678 * can happen if it's connected to some other API.
679 */
680static inline int native_window_api_connect(
681 struct ANativeWindow* window, int api)
682{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700683 return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700684}
685
686/*
687 * native_window_api_disconnect(..., int api)
688 * disconnect the API from this window.
689 * An error is returned if for instance the window wasn't connected in the
690 * first place.
691 */
692static inline int native_window_api_disconnect(
693 struct ANativeWindow* window, int api)
694{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700695 return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700696}
697
698
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700699__END_DECLS
700
tedbo1ffdb382011-05-24 00:55:33 -0700701#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */