media/omx-plugin/include/ics/system/window.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial