blob: 08ae11497db09210d7a41b6a03eceaf5b0e91ffe [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 /*
160 * Default width and height of the ANativeWindow, these are the dimensions
161 * of the window irrespective of the NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
162 * call.
163 */
164 NATIVE_WINDOW_DEFAULT_WIDTH = 6,
165 NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
166
167 /*
168 * transformation that will most-likely be applied to buffers. This is only
169 * a hint, the actual transformation applied might be different.
170 *
171 * INTENDED USE:
172 *
173 * The transform hint can be used by a producer, for instance the GLES
174 * driver, to pre-rotate the rendering such that the final transformation
175 * in the composer is identity. This can be very useful when used in
176 * conjunction with the h/w composer HAL, in situations where it
177 * cannot handle arbitrary rotations.
178 *
179 * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
180 * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
181 *
182 * 2. The GL driver overrides the width and height of the ANW to
183 * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
184 * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
185 * according to NATIVE_WINDOW_TRANSFORM_HINT and calling
186 * native_window_set_buffers_dimensions().
187 *
188 * 3. The GL driver dequeues a buffer of the new pre-rotated size.
189 *
190 * 4. The GL driver renders to the buffer such that the image is
191 * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
192 * to the rendering.
193 *
194 * 5. The GL driver calls native_window_set_transform to apply
195 * inverse transformation to the buffer it just rendered.
196 * In order to do this, the GL driver needs
197 * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
198 * done easily:
199 *
200 * int hintTransform, inverseTransform;
201 * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
202 * inverseTransform = hintTransform;
203 * if (hintTransform & HAL_TRANSFORM_ROT_90)
204 * inverseTransform ^= HAL_TRANSFORM_ROT_180;
205 *
206 *
207 * 6. The GL driver queues the pre-transformed buffer.
208 *
209 * 7. The composer combines the buffer transform with the display
210 * transform. If the buffer transform happens to cancel out the
211 * display transform then no rotation is needed.
212 *
213 */
214 NATIVE_WINDOW_TRANSFORM_HINT = 8,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700215};
216
217/* valid operations for the (*perform)() hook */
218enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700219 NATIVE_WINDOW_SET_USAGE = 0,
Mathias Agopian8ad54522011-07-29 17:52:36 -0700220 NATIVE_WINDOW_CONNECT = 1, /* deprecated */
221 NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700222 NATIVE_WINDOW_SET_CROP = 3,
223 NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
224 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
225 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
226 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
227 NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
228 NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
Mathias Agopianae3736a2011-07-13 18:40:38 -0700229 NATIVE_WINDOW_SET_SCALING_MODE = 10,
230 NATIVE_WINDOW_LOCK = 11, /* private */
231 NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
Mathias Agopian8ad54522011-07-29 17:52:36 -0700232 NATIVE_WINDOW_API_CONNECT = 13, /* private */
233 NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700234};
235
Mathias Agopian8ad54522011-07-29 17:52:36 -0700236/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700237enum {
Jamie Gennis5423e9e2011-07-12 13:53:42 -0700238 /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
239 * OpenGL ES.
240 */
241 NATIVE_WINDOW_API_EGL = 1,
242
243 /* Buffers will be queued after being filled using the CPU
244 */
245 NATIVE_WINDOW_API_CPU = 2,
246
247 /* Buffers will be queued by Stagefright after being filled by a video
248 * decoder. The video decoder can either be a software or hardware decoder.
249 */
250 NATIVE_WINDOW_API_MEDIA = 3,
251
252 /* Buffers will be queued by the the camera HAL.
253 */
254 NATIVE_WINDOW_API_CAMERA = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700255};
256
257/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
258enum {
259 /* flip source image horizontally */
260 NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
261 /* flip source image vertically */
262 NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
263 /* rotate source image 90 degrees clock-wise */
264 NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
265 /* rotate source image 180 degrees */
266 NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
267 /* rotate source image 270 degrees clock-wise */
268 NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
269};
270
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700271/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */
272enum {
273 /* the window content is not updated (frozen) until a buffer of
274 * the window size is received (enqueued)
275 */
276 NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
277 /* the buffer is scaled in both dimensions to match the window size */
278 NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
Daniel Lam29392a42012-04-11 18:19:46 -0700279 /* the buffer is scaled uniformly such that the smaller dimension
280 * of the buffer matches the window size (cropping in the process)
281 */
282 NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700283};
284
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700285/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
286enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700287 NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
288 NATIVE_WINDOW_SURFACE = 1, /* Surface */
289 NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT = 2, /* SurfaceTextureClient */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700290};
291
292/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
293 *
294 * Special timestamp value to indicate that timestamps should be auto-generated
295 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
296 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
297 */
298static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
299
300struct ANativeWindow
301{
302#ifdef __cplusplus
303 ANativeWindow()
304 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
305 {
306 common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
307 common.version = sizeof(ANativeWindow);
308 memset(common.reserved, 0, sizeof(common.reserved));
309 }
310
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700311 /* Implement the methods that sp<ANativeWindow> expects so that it
312 can be used to automatically refcount ANativeWindow's. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700313 void incStrong(const void* id) const {
314 common.incRef(const_cast<android_native_base_t*>(&common));
315 }
316 void decStrong(const void* id) const {
317 common.decRef(const_cast<android_native_base_t*>(&common));
318 }
319#endif
320
321 struct android_native_base_t common;
322
323 /* flags describing some attributes of this surface or its updater */
324 const uint32_t flags;
325
326 /* min swap interval supported by this updated */
327 const int minSwapInterval;
328
329 /* max swap interval supported by this updated */
330 const int maxSwapInterval;
331
332 /* horizontal and vertical resolution in DPI */
333 const float xdpi;
334 const float ydpi;
335
336 /* Some storage reserved for the OEM's driver. */
337 intptr_t oem[4];
338
339 /*
340 * Set the swap interval for this surface.
341 *
342 * Returns 0 on success or -errno on error.
343 */
344 int (*setSwapInterval)(struct ANativeWindow* window,
345 int interval);
346
347 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800348 * Hook called by EGL to acquire a buffer. After this call, the buffer
349 * is not locked, so its content cannot be modified. This call may block if
350 * no buffers are available.
351 *
352 * The window holds a reference to the buffer between dequeueBuffer and
353 * either queueBuffer or cancelBuffer, so clients only need their own
354 * reference if they might use the buffer after queueing or canceling it.
355 * Holding a reference to a buffer after queueing or canceling it is only
356 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700357 *
358 * Returns 0 on success or -errno on error.
359 */
360 int (*dequeueBuffer)(struct ANativeWindow* window,
361 struct ANativeWindowBuffer** buffer);
362
363 /*
364 * hook called by EGL to lock a buffer. This MUST be called before modifying
365 * the content of a buffer. The buffer must have been acquired with
366 * dequeueBuffer first.
367 *
368 * Returns 0 on success or -errno on error.
369 */
370 int (*lockBuffer)(struct ANativeWindow* window,
371 struct ANativeWindowBuffer* buffer);
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800372 /*
373 * Hook called by EGL when modifications to the render buffer are done.
374 * This unlocks and post the buffer.
375 *
376 * The window holds a reference to the buffer between dequeueBuffer and
377 * either queueBuffer or cancelBuffer, so clients only need their own
378 * reference if they might use the buffer after queueing or canceling it.
379 * Holding a reference to a buffer after queueing or canceling it is only
380 * allowed if a specific buffer count has been set.
381 *
382 * Buffers MUST be queued in the same order than they were dequeued.
383 *
384 * Returns 0 on success or -errno on error.
385 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700386 int (*queueBuffer)(struct ANativeWindow* window,
387 struct ANativeWindowBuffer* buffer);
388
389 /*
390 * hook used to retrieve information about the native window.
391 *
392 * Returns 0 on success or -errno on error.
393 */
394 int (*query)(const struct ANativeWindow* window,
395 int what, int* value);
396
397 /*
398 * hook used to perform various operations on the surface.
399 * (*perform)() is a generic mechanism to add functionality to
400 * ANativeWindow while keeping backward binary compatibility.
401 *
402 * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
403 * defined below.
404 *
405 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
406 * by the surface's implementation.
407 *
408 * The valid operations are:
409 * NATIVE_WINDOW_SET_USAGE
Mathias Agopian8ad54522011-07-29 17:52:36 -0700410 * NATIVE_WINDOW_CONNECT (deprecated)
411 * NATIVE_WINDOW_DISCONNECT (deprecated)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700412 * NATIVE_WINDOW_SET_CROP
413 * NATIVE_WINDOW_SET_BUFFER_COUNT
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700414 * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700415 * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
416 * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700417 * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
418 * NATIVE_WINDOW_SET_BUFFERS_FORMAT
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700419 * NATIVE_WINDOW_SET_SCALING_MODE
Mathias Agopianae3736a2011-07-13 18:40:38 -0700420 * NATIVE_WINDOW_LOCK (private)
421 * NATIVE_WINDOW_UNLOCK_AND_POST (private)
Mathias Agopian8ad54522011-07-29 17:52:36 -0700422 * NATIVE_WINDOW_API_CONNECT (private)
423 * NATIVE_WINDOW_API_DISCONNECT (private)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700424 *
425 */
426
427 int (*perform)(struct ANativeWindow* window,
428 int operation, ... );
429
430 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800431 * Hook used to cancel a buffer that has been dequeued.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700432 * No synchronization is performed between dequeue() and cancel(), so
433 * either external synchronization is needed, or these functions must be
434 * called from the same thread.
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800435 *
436 * The window holds a reference to the buffer between dequeueBuffer and
437 * either queueBuffer or cancelBuffer, so clients only need their own
438 * reference if they might use the buffer after queueing or canceling it.
439 * Holding a reference to a buffer after queueing or canceling it is only
440 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700441 */
442 int (*cancelBuffer)(struct ANativeWindow* window,
443 struct ANativeWindowBuffer* buffer);
444
445
446 void* reserved_proc[2];
447};
448
449 /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
450 * android_native_window_t is deprecated.
451 */
452typedef struct ANativeWindow ANativeWindow;
453typedef struct ANativeWindow android_native_window_t;
454
455/*
456 * native_window_set_usage(..., usage)
457 * Sets the intended usage flags for the next buffers
458 * acquired with (*lockBuffer)() and on.
459 * By default (if this function is never called), a usage of
460 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
461 * is assumed.
462 * Calling this function will usually cause following buffers to be
463 * reallocated.
464 */
465
466static inline int native_window_set_usage(
467 struct ANativeWindow* window, int usage)
468{
469 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
470}
471
Mathias Agopian8ad54522011-07-29 17:52:36 -0700472/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700473static inline int native_window_connect(
Mathias Agopian8ad54522011-07-29 17:52:36 -0700474 struct ANativeWindow* window, int api) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700475 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700476}
477
Mathias Agopian8ad54522011-07-29 17:52:36 -0700478/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700479static inline int native_window_disconnect(
Mathias Agopian8ad54522011-07-29 17:52:36 -0700480 struct ANativeWindow* window, int api) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700481 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700482}
483
484/*
485 * native_window_set_crop(..., crop)
486 * Sets which region of the next queued buffers needs to be considered.
487 * A buffer's crop region is scaled to match the surface's size.
488 *
489 * The specified crop region applies to all buffers queued after it is called.
490 *
491 * if 'crop' is NULL, subsequently queued buffers won't be cropped.
492 *
493 * An error is returned if for instance the crop region is invalid,
494 * out of the buffer's bound or if the window is invalid.
495 */
496static inline int native_window_set_crop(
497 struct ANativeWindow* window,
498 android_native_rect_t const * crop)
499{
500 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
501}
502
503/*
504 * native_window_set_buffer_count(..., count)
505 * Sets the number of buffers associated with this native window.
506 */
507static inline int native_window_set_buffer_count(
508 struct ANativeWindow* window,
509 size_t bufferCount)
510{
511 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
512}
513
514/*
515 * native_window_set_buffers_geometry(..., int w, int h, int format)
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700516 * All buffers dequeued after this call will have the dimensions and format
517 * specified. A successful call to this function has the same effect as calling
518 * native_window_set_buffers_size and native_window_set_buffers_format.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700519 *
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700520 * XXX: This function is deprecated. The native_window_set_buffers_dimensions
521 * and native_window_set_buffers_format functions should be used instead.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700522 */
523static inline int native_window_set_buffers_geometry(
524 struct ANativeWindow* window,
525 int w, int h, int format)
526{
527 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
528 w, h, format);
529}
530
531/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700532 * native_window_set_buffers_dimensions(..., int w, int h)
533 * All buffers dequeued after this call will have the dimensions specified.
534 * In particular, all buffers will have a fixed-size, independent form the
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700535 * native-window size. They will be scaled according to the scaling mode
536 * (see native_window_set_scaling_mode) upon window composition.
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700537 *
538 * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
539 * following this call will be sized to match the window's size.
540 *
541 * Calling this function will reset the window crop to a NULL value, which
542 * disables cropping of the buffers.
543 */
544static inline int native_window_set_buffers_dimensions(
545 struct ANativeWindow* window,
546 int w, int h)
547{
548 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
549 w, h);
550}
551
552/*
553 * native_window_set_buffers_format(..., int format)
554 * All buffers dequeued after this call will have the format specified.
555 *
556 * If the specified format is 0, the default buffer format will be used.
557 */
558static inline int native_window_set_buffers_format(
559 struct ANativeWindow* window,
560 int format)
561{
562 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
563}
564
565/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700566 * native_window_set_buffers_transform(..., int transform)
567 * All buffers queued after this call will be displayed transformed according
568 * to the transform parameter specified.
569 */
570static inline int native_window_set_buffers_transform(
571 struct ANativeWindow* window,
572 int transform)
573{
574 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
575 transform);
576}
577
578/*
579 * native_window_set_buffers_timestamp(..., int64_t timestamp)
580 * All buffers queued after this call will be associated with the timestamp
581 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
582 * (the default), timestamps will be generated automatically when queueBuffer is
Glenn Kastenc322f672011-06-27 10:42:39 -0700583 * called. The timestamp is measured in nanoseconds, and is normally monotonically
584 * increasing. The timestamp should be unaffected by time-of-day adjustments,
585 * and for a camera should be strictly monotonic but for a media player may be
586 * reset when the position is set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700587 */
588static inline int native_window_set_buffers_timestamp(
589 struct ANativeWindow* window,
590 int64_t timestamp)
591{
592 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
593 timestamp);
594}
595
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700596/*
597 * native_window_set_scaling_mode(..., int mode)
598 * All buffers queued after this call will be associated with the scaling mode
599 * specified.
600 */
601static inline int native_window_set_scaling_mode(
602 struct ANativeWindow* window,
603 int mode)
604{
605 return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
606 mode);
607}
608
Mathias Agopian8ad54522011-07-29 17:52:36 -0700609
610/*
611 * native_window_api_connect(..., int api)
612 * connects an API to this window. only one API can be connected at a time.
613 * Returns -EINVAL if for some reason the window cannot be connected, which
614 * can happen if it's connected to some other API.
615 */
616static inline int native_window_api_connect(
617 struct ANativeWindow* window, int api)
618{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700619 return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700620}
621
622/*
623 * native_window_api_disconnect(..., int api)
624 * disconnect the API from this window.
625 * An error is returned if for instance the window wasn't connected in the
626 * first place.
627 */
628static inline int native_window_api_disconnect(
629 struct ANativeWindow* window, int api)
630{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700631 return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700632}
633
634
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700635__END_DECLS
636
tedbo1ffdb382011-05-24 00:55:33 -0700637#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */