blob: 1cc4a0a18b66e259343fc80500abca5f020dc174 [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>
21#include <sys/cdefs.h>
22#include <system/graphics.h>
23#include <cutils/native_handle.h>
24
25__BEGIN_DECLS
26
27/*****************************************************************************/
28
29#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
30 (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
31
32#define ANDROID_NATIVE_WINDOW_MAGIC \
33 ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
34
35#define ANDROID_NATIVE_BUFFER_MAGIC \
36 ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
37
38// ---------------------------------------------------------------------------
39
40typedef const native_handle_t* buffer_handle_t;
41
42// ---------------------------------------------------------------------------
43
44typedef struct android_native_rect_t
45{
46 int32_t left;
47 int32_t top;
48 int32_t right;
49 int32_t bottom;
50} android_native_rect_t;
51
52// ---------------------------------------------------------------------------
53
54typedef struct android_native_base_t
55{
56 /* a magic value defined by the actual EGL native type */
57 int magic;
58
59 /* the sizeof() of the actual EGL native type */
60 int version;
61
62 void* reserved[4];
63
64 /* reference-counting interface */
65 void (*incRef)(struct android_native_base_t* base);
66 void (*decRef)(struct android_native_base_t* base);
67} android_native_base_t;
68
69typedef struct ANativeWindowBuffer
70{
71#ifdef __cplusplus
72 ANativeWindowBuffer() {
73 common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
74 common.version = sizeof(ANativeWindowBuffer);
75 memset(common.reserved, 0, sizeof(common.reserved));
76 }
77
78 // Implement the methods that sp<ANativeWindowBuffer> expects so that it
79 // can be used to automatically refcount ANativeWindowBuffer's.
80 void incStrong(const void* id) const {
81 common.incRef(const_cast<android_native_base_t*>(&common));
82 }
83 void decStrong(const void* id) const {
84 common.decRef(const_cast<android_native_base_t*>(&common));
85 }
86#endif
87
88 struct android_native_base_t common;
89
90 int width;
91 int height;
92 int stride;
93 int format;
94 int usage;
95
96 void* reserved[2];
97
98 buffer_handle_t handle;
99
100 void* reserved_proc[8];
101} ANativeWindowBuffer_t;
102
103// Old typedef for backwards compatibility.
104typedef ANativeWindowBuffer_t android_native_buffer_t;
105
106// ---------------------------------------------------------------------------
107
108/* attributes queriable with query() */
109enum {
110 NATIVE_WINDOW_WIDTH = 0,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700111 NATIVE_WINDOW_HEIGHT = 1,
112 NATIVE_WINDOW_FORMAT = 2,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700113
114 /* The minimum number of buffers that must remain un-dequeued after a buffer
115 * has been queued. This value applies only if set_buffer_count was used to
116 * override the number of buffers and if a buffer has since been queued.
117 * Users of the set_buffer_count ANativeWindow method should query this
118 * value before calling set_buffer_count. If it is necessary to have N
119 * buffers simultaneously dequeued as part of the steady-state operation,
120 * and this query returns M then N+M buffers should be requested via
121 * native_window_set_buffer_count.
122 *
123 * Note that this value does NOT apply until a single buffer has been
124 * queued. In particular this means that it is possible to:
125 *
126 * 1. Query M = min undequeued buffers
127 * 2. Set the buffer count to N + M
128 * 3. Dequeue all N + M buffers
129 * 4. Cancel M buffers
130 * 5. Queue, dequeue, queue, dequeue, ad infinitum
131 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700132 NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700133
134 /* Check whether queueBuffer operations on the ANativeWindow send the buffer
135 * to the window compositor. The query sets the returned 'value' argument
136 * to 1 if the ANativeWindow DOES send queued buffers directly to the window
137 * compositor and 0 if the buffers do not go directly to the window
138 * compositor.
139 *
140 * This can be used to determine whether protected buffer content should be
141 * sent to the ANativeWindow. Note, however, that a result of 1 does NOT
142 * indicate that queued buffers will be protected from applications or users
143 * capturing their contents. If that behavior is desired then some other
144 * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
145 * conjunction with this query.
146 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700147 NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700148
149 /* Get the concrete type of a ANativeWindow. See below for the list of
150 * possible return values.
151 *
152 * This query should not be used outside the Android framework and will
153 * likely be removed in the near future.
154 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700155 NATIVE_WINDOW_CONCRETE_TYPE = 5,
Mathias Agopian51009162011-07-19 15:59:15 -0700156
157
158 /*
159 * Default width and height of the ANativeWindow, these are the dimensions
160 * of the window irrespective of the NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
161 * call.
162 */
163 NATIVE_WINDOW_DEFAULT_WIDTH = 6,
164 NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
165
166 /*
167 * transformation that will most-likely be applied to buffers. This is only
168 * a hint, the actual transformation applied might be different.
169 *
170 * INTENDED USE:
171 *
172 * The transform hint can be used by a producer, for instance the GLES
173 * driver, to pre-rotate the rendering such that the final transformation
174 * in the composer is identity. This can be very useful when used in
175 * conjunction with the h/w composer HAL, in situations where it
176 * cannot handle arbitrary rotations.
177 *
178 * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
179 * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
180 *
181 * 2. The GL driver overrides the width and height of the ANW to
182 * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
183 * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
184 * according to NATIVE_WINDOW_TRANSFORM_HINT and calling
185 * native_window_set_buffers_dimensions().
186 *
187 * 3. The GL driver dequeues a buffer of the new pre-rotated size.
188 *
189 * 4. The GL driver renders to the buffer such that the image is
190 * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
191 * to the rendering.
192 *
193 * 5. The GL driver calls native_window_set_transform to apply
194 * inverse transformation to the buffer it just rendered.
195 * In order to do this, the GL driver needs
196 * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
197 * done easily:
198 *
199 * int hintTransform, inverseTransform;
200 * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
201 * inverseTransform = hintTransform;
202 * if (hintTransform & HAL_TRANSFORM_ROT_90)
203 * inverseTransform ^= HAL_TRANSFORM_ROT_180;
204 *
205 *
206 * 6. The GL driver queues the pre-transformed buffer.
207 *
208 * 7. The composer combines the buffer transform with the display
209 * transform. If the buffer transform happens to cancel out the
210 * display transform then no rotation is needed.
211 *
212 */
213 NATIVE_WINDOW_TRANSFORM_HINT = 8,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700214};
215
216/* valid operations for the (*perform)() hook */
217enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700218 NATIVE_WINDOW_SET_USAGE = 0,
Mathias Agopian8ad54522011-07-29 17:52:36 -0700219 NATIVE_WINDOW_CONNECT = 1, /* deprecated */
220 NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700221 NATIVE_WINDOW_SET_CROP = 3,
222 NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
223 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
224 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
225 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
226 NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
227 NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
Mathias Agopianae3736a2011-07-13 18:40:38 -0700228 NATIVE_WINDOW_SET_SCALING_MODE = 10,
229 NATIVE_WINDOW_LOCK = 11, /* private */
230 NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
Mathias Agopian8ad54522011-07-29 17:52:36 -0700231 NATIVE_WINDOW_API_CONNECT = 13, /* private */
232 NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700233};
234
Mathias Agopian8ad54522011-07-29 17:52:36 -0700235/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700236enum {
Jamie Gennis5423e9e2011-07-12 13:53:42 -0700237 /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
238 * OpenGL ES.
239 */
240 NATIVE_WINDOW_API_EGL = 1,
241
242 /* Buffers will be queued after being filled using the CPU
243 */
244 NATIVE_WINDOW_API_CPU = 2,
245
246 /* Buffers will be queued by Stagefright after being filled by a video
247 * decoder. The video decoder can either be a software or hardware decoder.
248 */
249 NATIVE_WINDOW_API_MEDIA = 3,
250
251 /* Buffers will be queued by the the camera HAL.
252 */
253 NATIVE_WINDOW_API_CAMERA = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700254};
255
256/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
257enum {
258 /* flip source image horizontally */
259 NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
260 /* flip source image vertically */
261 NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
262 /* rotate source image 90 degrees clock-wise */
263 NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
264 /* rotate source image 180 degrees */
265 NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
266 /* rotate source image 270 degrees clock-wise */
267 NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
268};
269
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700270/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */
271enum {
272 /* the window content is not updated (frozen) until a buffer of
273 * the window size is received (enqueued)
274 */
275 NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
276 /* the buffer is scaled in both dimensions to match the window size */
277 NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
278};
279
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700280/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
281enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700282 NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
283 NATIVE_WINDOW_SURFACE = 1, /* Surface */
284 NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT = 2, /* SurfaceTextureClient */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700285};
286
287/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
288 *
289 * Special timestamp value to indicate that timestamps should be auto-generated
290 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
291 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
292 */
293static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
294
295struct ANativeWindow
296{
297#ifdef __cplusplus
298 ANativeWindow()
299 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
300 {
301 common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
302 common.version = sizeof(ANativeWindow);
303 memset(common.reserved, 0, sizeof(common.reserved));
304 }
305
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700306 /* Implement the methods that sp<ANativeWindow> expects so that it
307 can be used to automatically refcount ANativeWindow's. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700308 void incStrong(const void* id) const {
309 common.incRef(const_cast<android_native_base_t*>(&common));
310 }
311 void decStrong(const void* id) const {
312 common.decRef(const_cast<android_native_base_t*>(&common));
313 }
314#endif
315
316 struct android_native_base_t common;
317
318 /* flags describing some attributes of this surface or its updater */
319 const uint32_t flags;
320
321 /* min swap interval supported by this updated */
322 const int minSwapInterval;
323
324 /* max swap interval supported by this updated */
325 const int maxSwapInterval;
326
327 /* horizontal and vertical resolution in DPI */
328 const float xdpi;
329 const float ydpi;
330
331 /* Some storage reserved for the OEM's driver. */
332 intptr_t oem[4];
333
334 /*
335 * Set the swap interval for this surface.
336 *
337 * Returns 0 on success or -errno on error.
338 */
339 int (*setSwapInterval)(struct ANativeWindow* window,
340 int interval);
341
342 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800343 * Hook called by EGL to acquire a buffer. After this call, the buffer
344 * is not locked, so its content cannot be modified. This call may block if
345 * no buffers are available.
346 *
347 * The window holds a reference to the buffer between dequeueBuffer and
348 * either queueBuffer or cancelBuffer, so clients only need their own
349 * reference if they might use the buffer after queueing or canceling it.
350 * Holding a reference to a buffer after queueing or canceling it is only
351 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700352 *
353 * Returns 0 on success or -errno on error.
354 */
355 int (*dequeueBuffer)(struct ANativeWindow* window,
356 struct ANativeWindowBuffer** buffer);
357
358 /*
359 * hook called by EGL to lock a buffer. This MUST be called before modifying
360 * the content of a buffer. The buffer must have been acquired with
361 * dequeueBuffer first.
362 *
363 * Returns 0 on success or -errno on error.
364 */
365 int (*lockBuffer)(struct ANativeWindow* window,
366 struct ANativeWindowBuffer* buffer);
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800367 /*
368 * Hook called by EGL when modifications to the render buffer are done.
369 * This unlocks and post the buffer.
370 *
371 * The window holds a reference to the buffer between dequeueBuffer and
372 * either queueBuffer or cancelBuffer, so clients only need their own
373 * reference if they might use the buffer after queueing or canceling it.
374 * Holding a reference to a buffer after queueing or canceling it is only
375 * allowed if a specific buffer count has been set.
376 *
377 * Buffers MUST be queued in the same order than they were dequeued.
378 *
379 * Returns 0 on success or -errno on error.
380 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700381 int (*queueBuffer)(struct ANativeWindow* window,
382 struct ANativeWindowBuffer* buffer);
383
384 /*
385 * hook used to retrieve information about the native window.
386 *
387 * Returns 0 on success or -errno on error.
388 */
389 int (*query)(const struct ANativeWindow* window,
390 int what, int* value);
391
392 /*
393 * hook used to perform various operations on the surface.
394 * (*perform)() is a generic mechanism to add functionality to
395 * ANativeWindow while keeping backward binary compatibility.
396 *
397 * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
398 * defined below.
399 *
400 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
401 * by the surface's implementation.
402 *
403 * The valid operations are:
404 * NATIVE_WINDOW_SET_USAGE
Mathias Agopian8ad54522011-07-29 17:52:36 -0700405 * NATIVE_WINDOW_CONNECT (deprecated)
406 * NATIVE_WINDOW_DISCONNECT (deprecated)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700407 * NATIVE_WINDOW_SET_CROP
408 * NATIVE_WINDOW_SET_BUFFER_COUNT
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700409 * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700410 * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
411 * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700412 * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
413 * NATIVE_WINDOW_SET_BUFFERS_FORMAT
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700414 * NATIVE_WINDOW_SET_SCALING_MODE
Mathias Agopianae3736a2011-07-13 18:40:38 -0700415 * NATIVE_WINDOW_LOCK (private)
416 * NATIVE_WINDOW_UNLOCK_AND_POST (private)
Mathias Agopian8ad54522011-07-29 17:52:36 -0700417 * NATIVE_WINDOW_API_CONNECT (private)
418 * NATIVE_WINDOW_API_DISCONNECT (private)
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700419 *
420 */
421
422 int (*perform)(struct ANativeWindow* window,
423 int operation, ... );
424
425 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800426 * Hook used to cancel a buffer that has been dequeued.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700427 * No synchronization is performed between dequeue() and cancel(), so
428 * either external synchronization is needed, or these functions must be
429 * called from the same thread.
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800430 *
431 * The window holds a reference to the buffer between dequeueBuffer and
432 * either queueBuffer or cancelBuffer, so clients only need their own
433 * reference if they might use the buffer after queueing or canceling it.
434 * Holding a reference to a buffer after queueing or canceling it is only
435 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700436 */
437 int (*cancelBuffer)(struct ANativeWindow* window,
438 struct ANativeWindowBuffer* buffer);
439
440
441 void* reserved_proc[2];
442};
443
444 /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
445 * android_native_window_t is deprecated.
446 */
447typedef struct ANativeWindow ANativeWindow;
448typedef struct ANativeWindow android_native_window_t;
449
450/*
451 * native_window_set_usage(..., usage)
452 * Sets the intended usage flags for the next buffers
453 * acquired with (*lockBuffer)() and on.
454 * By default (if this function is never called), a usage of
455 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
456 * is assumed.
457 * Calling this function will usually cause following buffers to be
458 * reallocated.
459 */
460
461static inline int native_window_set_usage(
462 struct ANativeWindow* window, int usage)
463{
464 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
465}
466
Mathias Agopian8ad54522011-07-29 17:52:36 -0700467/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700468static inline int native_window_connect(
Mathias Agopian8ad54522011-07-29 17:52:36 -0700469 struct ANativeWindow* window, int api) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700470 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700471}
472
Mathias Agopian8ad54522011-07-29 17:52:36 -0700473/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700474static inline int native_window_disconnect(
Mathias Agopian8ad54522011-07-29 17:52:36 -0700475 struct ANativeWindow* window, int api) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700476 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700477}
478
479/*
480 * native_window_set_crop(..., crop)
481 * Sets which region of the next queued buffers needs to be considered.
482 * A buffer's crop region is scaled to match the surface's size.
483 *
484 * The specified crop region applies to all buffers queued after it is called.
485 *
486 * if 'crop' is NULL, subsequently queued buffers won't be cropped.
487 *
488 * An error is returned if for instance the crop region is invalid,
489 * out of the buffer's bound or if the window is invalid.
490 */
491static inline int native_window_set_crop(
492 struct ANativeWindow* window,
493 android_native_rect_t const * crop)
494{
495 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
496}
497
498/*
499 * native_window_set_buffer_count(..., count)
500 * Sets the number of buffers associated with this native window.
501 */
502static inline int native_window_set_buffer_count(
503 struct ANativeWindow* window,
504 size_t bufferCount)
505{
506 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
507}
508
509/*
510 * native_window_set_buffers_geometry(..., int w, int h, int format)
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700511 * All buffers dequeued after this call will have the dimensions and format
512 * specified. A successful call to this function has the same effect as calling
513 * native_window_set_buffers_size and native_window_set_buffers_format.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700514 *
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700515 * XXX: This function is deprecated. The native_window_set_buffers_dimensions
516 * and native_window_set_buffers_format functions should be used instead.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700517 */
518static inline int native_window_set_buffers_geometry(
519 struct ANativeWindow* window,
520 int w, int h, int format)
521{
522 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
523 w, h, format);
524}
525
526/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700527 * native_window_set_buffers_dimensions(..., int w, int h)
528 * All buffers dequeued after this call will have the dimensions specified.
529 * In particular, all buffers will have a fixed-size, independent form the
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700530 * native-window size. They will be scaled according to the scaling mode
531 * (see native_window_set_scaling_mode) upon window composition.
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700532 *
533 * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
534 * following this call will be sized to match the window's size.
535 *
536 * Calling this function will reset the window crop to a NULL value, which
537 * disables cropping of the buffers.
538 */
539static inline int native_window_set_buffers_dimensions(
540 struct ANativeWindow* window,
541 int w, int h)
542{
543 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
544 w, h);
545}
546
547/*
548 * native_window_set_buffers_format(..., int format)
549 * All buffers dequeued after this call will have the format specified.
550 *
551 * If the specified format is 0, the default buffer format will be used.
552 */
553static inline int native_window_set_buffers_format(
554 struct ANativeWindow* window,
555 int format)
556{
557 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
558}
559
560/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700561 * native_window_set_buffers_transform(..., int transform)
562 * All buffers queued after this call will be displayed transformed according
563 * to the transform parameter specified.
564 */
565static inline int native_window_set_buffers_transform(
566 struct ANativeWindow* window,
567 int transform)
568{
569 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
570 transform);
571}
572
573/*
574 * native_window_set_buffers_timestamp(..., int64_t timestamp)
575 * All buffers queued after this call will be associated with the timestamp
576 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
577 * (the default), timestamps will be generated automatically when queueBuffer is
Glenn Kastenc322f672011-06-27 10:42:39 -0700578 * called. The timestamp is measured in nanoseconds, and is normally monotonically
579 * increasing. The timestamp should be unaffected by time-of-day adjustments,
580 * and for a camera should be strictly monotonic but for a media player may be
581 * reset when the position is set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700582 */
583static inline int native_window_set_buffers_timestamp(
584 struct ANativeWindow* window,
585 int64_t timestamp)
586{
587 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
588 timestamp);
589}
590
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700591/*
592 * native_window_set_scaling_mode(..., int mode)
593 * All buffers queued after this call will be associated with the scaling mode
594 * specified.
595 */
596static inline int native_window_set_scaling_mode(
597 struct ANativeWindow* window,
598 int mode)
599{
600 return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
601 mode);
602}
603
Mathias Agopian8ad54522011-07-29 17:52:36 -0700604
605/*
606 * native_window_api_connect(..., int api)
607 * connects an API to this window. only one API can be connected at a time.
608 * Returns -EINVAL if for some reason the window cannot be connected, which
609 * can happen if it's connected to some other API.
610 */
611static inline int native_window_api_connect(
612 struct ANativeWindow* window, int api)
613{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700614 return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700615}
616
617/*
618 * native_window_api_disconnect(..., int api)
619 * disconnect the API from this window.
620 * An error is returned if for instance the window wasn't connected in the
621 * first place.
622 */
623static inline int native_window_api_disconnect(
624 struct ANativeWindow* window, int api)
625{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700626 return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700627}
628
629
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700630__END_DECLS
631
tedbo1ffdb382011-05-24 00:55:33 -0700632#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */