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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/omx-plugin/include/ics/system/window.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,632 @@
     1.4 +/*
     1.5 + * Copyright (C) 2011 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
    1.21 +#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
    1.22 +
    1.23 +#include <stdint.h>
    1.24 +#include <sys/cdefs.h>
    1.25 +#include <system/graphics.h>
    1.26 +#include <cutils/native_handle.h>
    1.27 +
    1.28 +__BEGIN_DECLS
    1.29 +
    1.30 +/*****************************************************************************/
    1.31 +
    1.32 +#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
    1.33 +    (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
    1.34 +
    1.35 +#define ANDROID_NATIVE_WINDOW_MAGIC \
    1.36 +    ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
    1.37 +
    1.38 +#define ANDROID_NATIVE_BUFFER_MAGIC \
    1.39 +    ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
    1.40 +
    1.41 +// ---------------------------------------------------------------------------
    1.42 +
    1.43 +typedef const native_handle_t* buffer_handle_t;
    1.44 +
    1.45 +// ---------------------------------------------------------------------------
    1.46 +
    1.47 +typedef struct android_native_rect_t
    1.48 +{
    1.49 +    int32_t left;
    1.50 +    int32_t top;
    1.51 +    int32_t right;
    1.52 +    int32_t bottom;
    1.53 +} android_native_rect_t;
    1.54 +
    1.55 +// ---------------------------------------------------------------------------
    1.56 +
    1.57 +typedef struct android_native_base_t
    1.58 +{
    1.59 +    /* a magic value defined by the actual EGL native type */
    1.60 +    int magic;
    1.61 +
    1.62 +    /* the sizeof() of the actual EGL native type */
    1.63 +    int version;
    1.64 +
    1.65 +    void* reserved[4];
    1.66 +
    1.67 +    /* reference-counting interface */
    1.68 +    void (*incRef)(struct android_native_base_t* base);
    1.69 +    void (*decRef)(struct android_native_base_t* base);
    1.70 +} android_native_base_t;
    1.71 +
    1.72 +typedef struct ANativeWindowBuffer
    1.73 +{
    1.74 +#ifdef __cplusplus
    1.75 +    ANativeWindowBuffer() {
    1.76 +        common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
    1.77 +        common.version = sizeof(ANativeWindowBuffer);
    1.78 +        memset(common.reserved, 0, sizeof(common.reserved));
    1.79 +    }
    1.80 +
    1.81 +    // Implement the methods that sp<ANativeWindowBuffer> expects so that it
    1.82 +    // can be used to automatically refcount ANativeWindowBuffer's.
    1.83 +    void incStrong(const void* id) const {
    1.84 +        common.incRef(const_cast<android_native_base_t*>(&common));
    1.85 +    }
    1.86 +    void decStrong(const void* id) const {
    1.87 +        common.decRef(const_cast<android_native_base_t*>(&common));
    1.88 +    }
    1.89 +#endif
    1.90 +
    1.91 +    struct android_native_base_t common;
    1.92 +
    1.93 +    int width;
    1.94 +    int height;
    1.95 +    int stride;
    1.96 +    int format;
    1.97 +    int usage;
    1.98 +
    1.99 +    void* reserved[2];
   1.100 +
   1.101 +    buffer_handle_t handle;
   1.102 +
   1.103 +    void* reserved_proc[8];
   1.104 +} ANativeWindowBuffer_t;
   1.105 +
   1.106 +// Old typedef for backwards compatibility.
   1.107 +typedef ANativeWindowBuffer_t android_native_buffer_t;
   1.108 +
   1.109 +// ---------------------------------------------------------------------------
   1.110 +
   1.111 +/* attributes queriable with query() */
   1.112 +enum {
   1.113 +    NATIVE_WINDOW_WIDTH     = 0,
   1.114 +    NATIVE_WINDOW_HEIGHT    = 1,
   1.115 +    NATIVE_WINDOW_FORMAT    = 2,
   1.116 +
   1.117 +    /* The minimum number of buffers that must remain un-dequeued after a buffer
   1.118 +     * has been queued.  This value applies only if set_buffer_count was used to
   1.119 +     * override the number of buffers and if a buffer has since been queued.
   1.120 +     * Users of the set_buffer_count ANativeWindow method should query this
   1.121 +     * value before calling set_buffer_count.  If it is necessary to have N
   1.122 +     * buffers simultaneously dequeued as part of the steady-state operation,
   1.123 +     * and this query returns M then N+M buffers should be requested via
   1.124 +     * native_window_set_buffer_count.
   1.125 +     *
   1.126 +     * Note that this value does NOT apply until a single buffer has been
   1.127 +     * queued.  In particular this means that it is possible to:
   1.128 +     *
   1.129 +     * 1. Query M = min undequeued buffers
   1.130 +     * 2. Set the buffer count to N + M
   1.131 +     * 3. Dequeue all N + M buffers
   1.132 +     * 4. Cancel M buffers
   1.133 +     * 5. Queue, dequeue, queue, dequeue, ad infinitum
   1.134 +     */
   1.135 +    NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
   1.136 +
   1.137 +    /* Check whether queueBuffer operations on the ANativeWindow send the buffer
   1.138 +     * to the window compositor.  The query sets the returned 'value' argument
   1.139 +     * to 1 if the ANativeWindow DOES send queued buffers directly to the window
   1.140 +     * compositor and 0 if the buffers do not go directly to the window
   1.141 +     * compositor.
   1.142 +     *
   1.143 +     * This can be used to determine whether protected buffer content should be
   1.144 +     * sent to the ANativeWindow.  Note, however, that a result of 1 does NOT
   1.145 +     * indicate that queued buffers will be protected from applications or users
   1.146 +     * capturing their contents.  If that behavior is desired then some other
   1.147 +     * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
   1.148 +     * conjunction with this query.
   1.149 +     */
   1.150 +    NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
   1.151 +
   1.152 +    /* Get the concrete type of a ANativeWindow.  See below for the list of
   1.153 +     * possible return values.
   1.154 +     *
   1.155 +     * This query should not be used outside the Android framework and will
   1.156 +     * likely be removed in the near future.
   1.157 +     */
   1.158 +    NATIVE_WINDOW_CONCRETE_TYPE = 5,
   1.159 +
   1.160 +
   1.161 +    /*
   1.162 +     * Default width and height of the ANativeWindow, these are the dimensions
   1.163 +     * of the window irrespective of the NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
   1.164 +     * call.
   1.165 +     */
   1.166 +    NATIVE_WINDOW_DEFAULT_WIDTH = 6,
   1.167 +    NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
   1.168 +
   1.169 +    /*
   1.170 +     * transformation that will most-likely be applied to buffers. This is only
   1.171 +     * a hint, the actual transformation applied might be different.
   1.172 +     *
   1.173 +     * INTENDED USE:
   1.174 +     *
   1.175 +     * The transform hint can be used by a producer, for instance the GLES
   1.176 +     * driver, to pre-rotate the rendering such that the final transformation
   1.177 +     * in the composer is identity. This can be very useful when used in
   1.178 +     * conjunction with the h/w composer HAL, in situations where it
   1.179 +     * cannot handle arbitrary rotations.
   1.180 +     *
   1.181 +     * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
   1.182 +     *    queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
   1.183 +     *
   1.184 +     * 2. The GL driver overrides the width and height of the ANW to
   1.185 +     *    account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
   1.186 +     *    NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
   1.187 +     *    according to NATIVE_WINDOW_TRANSFORM_HINT and calling
   1.188 +     *    native_window_set_buffers_dimensions().
   1.189 +     *
   1.190 +     * 3. The GL driver dequeues a buffer of the new pre-rotated size.
   1.191 +     *
   1.192 +     * 4. The GL driver renders to the buffer such that the image is
   1.193 +     *    already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
   1.194 +     *    to the rendering.
   1.195 +     *
   1.196 +     * 5. The GL driver calls native_window_set_transform to apply
   1.197 +     *    inverse transformation to the buffer it just rendered.
   1.198 +     *    In order to do this, the GL driver needs
   1.199 +     *    to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
   1.200 +     *    done easily:
   1.201 +     *
   1.202 +     *        int hintTransform, inverseTransform;
   1.203 +     *        query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
   1.204 +     *        inverseTransform = hintTransform;
   1.205 +     *        if (hintTransform & HAL_TRANSFORM_ROT_90)
   1.206 +     *            inverseTransform ^= HAL_TRANSFORM_ROT_180;
   1.207 +     *
   1.208 +     *
   1.209 +     * 6. The GL driver queues the pre-transformed buffer.
   1.210 +     *
   1.211 +     * 7. The composer combines the buffer transform with the display
   1.212 +     *    transform.  If the buffer transform happens to cancel out the
   1.213 +     *    display transform then no rotation is needed.
   1.214 +     *
   1.215 +     */
   1.216 +    NATIVE_WINDOW_TRANSFORM_HINT = 8,
   1.217 +};
   1.218 +
   1.219 +/* valid operations for the (*perform)() hook */
   1.220 +enum {
   1.221 +    NATIVE_WINDOW_SET_USAGE                 =  0,
   1.222 +    NATIVE_WINDOW_CONNECT                   =  1,   /* deprecated */
   1.223 +    NATIVE_WINDOW_DISCONNECT                =  2,   /* deprecated */
   1.224 +    NATIVE_WINDOW_SET_CROP                  =  3,
   1.225 +    NATIVE_WINDOW_SET_BUFFER_COUNT          =  4,
   1.226 +    NATIVE_WINDOW_SET_BUFFERS_GEOMETRY      =  5,   /* deprecated */
   1.227 +    NATIVE_WINDOW_SET_BUFFERS_TRANSFORM     =  6,
   1.228 +    NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP     =  7,
   1.229 +    NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS    =  8,
   1.230 +    NATIVE_WINDOW_SET_BUFFERS_FORMAT        =  9,
   1.231 +    NATIVE_WINDOW_SET_SCALING_MODE          = 10,
   1.232 +    NATIVE_WINDOW_LOCK                      = 11,   /* private */
   1.233 +    NATIVE_WINDOW_UNLOCK_AND_POST           = 12,   /* private */
   1.234 +    NATIVE_WINDOW_API_CONNECT               = 13,   /* private */
   1.235 +    NATIVE_WINDOW_API_DISCONNECT            = 14,   /* private */
   1.236 +};
   1.237 +
   1.238 +/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
   1.239 +enum {
   1.240 +    /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
   1.241 +     * OpenGL ES.
   1.242 +     */
   1.243 +    NATIVE_WINDOW_API_EGL = 1,
   1.244 +
   1.245 +    /* Buffers will be queued after being filled using the CPU
   1.246 +     */
   1.247 +    NATIVE_WINDOW_API_CPU = 2,
   1.248 +
   1.249 +    /* Buffers will be queued by Stagefright after being filled by a video
   1.250 +     * decoder.  The video decoder can either be a software or hardware decoder.
   1.251 +     */
   1.252 +    NATIVE_WINDOW_API_MEDIA = 3,
   1.253 +
   1.254 +    /* Buffers will be queued by the the camera HAL.
   1.255 +     */
   1.256 +    NATIVE_WINDOW_API_CAMERA = 4,
   1.257 +};
   1.258 +
   1.259 +/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
   1.260 +enum {
   1.261 +    /* flip source image horizontally */
   1.262 +    NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
   1.263 +    /* flip source image vertically */
   1.264 +    NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
   1.265 +    /* rotate source image 90 degrees clock-wise */
   1.266 +    NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
   1.267 +    /* rotate source image 180 degrees */
   1.268 +    NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
   1.269 +    /* rotate source image 270 degrees clock-wise */
   1.270 +    NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
   1.271 +};
   1.272 +
   1.273 +/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */
   1.274 +enum {
   1.275 +    /* the window content is not updated (frozen) until a buffer of
   1.276 +     * the window size is received (enqueued)
   1.277 +     */
   1.278 +    NATIVE_WINDOW_SCALING_MODE_FREEZE           = 0,
   1.279 +    /* the buffer is scaled in both dimensions to match the window size */
   1.280 +    NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW  = 1,
   1.281 +};
   1.282 +
   1.283 +/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
   1.284 +enum {
   1.285 +    NATIVE_WINDOW_FRAMEBUFFER               = 0, /* FramebufferNativeWindow */
   1.286 +    NATIVE_WINDOW_SURFACE                   = 1, /* Surface */
   1.287 +    NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT    = 2, /* SurfaceTextureClient */
   1.288 +};
   1.289 +
   1.290 +/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
   1.291 + *
   1.292 + * Special timestamp value to indicate that timestamps should be auto-generated
   1.293 + * by the native window when queueBuffer is called.  This is equal to INT64_MIN,
   1.294 + * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
   1.295 + */
   1.296 +static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
   1.297 +
   1.298 +struct ANativeWindow
   1.299 +{
   1.300 +#ifdef __cplusplus
   1.301 +    ANativeWindow()
   1.302 +        : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
   1.303 +    {
   1.304 +        common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
   1.305 +        common.version = sizeof(ANativeWindow);
   1.306 +        memset(common.reserved, 0, sizeof(common.reserved));
   1.307 +    }
   1.308 +
   1.309 +    /* Implement the methods that sp<ANativeWindow> expects so that it
   1.310 +       can be used to automatically refcount ANativeWindow's. */
   1.311 +    void incStrong(const void* id) const {
   1.312 +        common.incRef(const_cast<android_native_base_t*>(&common));
   1.313 +    }
   1.314 +    void decStrong(const void* id) const {
   1.315 +        common.decRef(const_cast<android_native_base_t*>(&common));
   1.316 +    }
   1.317 +#endif
   1.318 +
   1.319 +    struct android_native_base_t common;
   1.320 +
   1.321 +    /* flags describing some attributes of this surface or its updater */
   1.322 +    const uint32_t flags;
   1.323 +
   1.324 +    /* min swap interval supported by this updated */
   1.325 +    const int   minSwapInterval;
   1.326 +
   1.327 +    /* max swap interval supported by this updated */
   1.328 +    const int   maxSwapInterval;
   1.329 +
   1.330 +    /* horizontal and vertical resolution in DPI */
   1.331 +    const float xdpi;
   1.332 +    const float ydpi;
   1.333 +
   1.334 +    /* Some storage reserved for the OEM's driver. */
   1.335 +    intptr_t    oem[4];
   1.336 +
   1.337 +    /*
   1.338 +     * Set the swap interval for this surface.
   1.339 +     *
   1.340 +     * Returns 0 on success or -errno on error.
   1.341 +     */
   1.342 +    int     (*setSwapInterval)(struct ANativeWindow* window,
   1.343 +                int interval);
   1.344 +
   1.345 +    /*
   1.346 +     * Hook called by EGL to acquire a buffer. After this call, the buffer
   1.347 +     * is not locked, so its content cannot be modified. This call may block if
   1.348 +     * no buffers are available.
   1.349 +     *
   1.350 +     * The window holds a reference to the buffer between dequeueBuffer and
   1.351 +     * either queueBuffer or cancelBuffer, so clients only need their own
   1.352 +     * reference if they might use the buffer after queueing or canceling it.
   1.353 +     * Holding a reference to a buffer after queueing or canceling it is only
   1.354 +     * allowed if a specific buffer count has been set.
   1.355 +     *
   1.356 +     * Returns 0 on success or -errno on error.
   1.357 +     */
   1.358 +    int     (*dequeueBuffer)(struct ANativeWindow* window,
   1.359 +                struct ANativeWindowBuffer** buffer);
   1.360 +
   1.361 +    /*
   1.362 +     * hook called by EGL to lock a buffer. This MUST be called before modifying
   1.363 +     * the content of a buffer. The buffer must have been acquired with
   1.364 +     * dequeueBuffer first.
   1.365 +     *
   1.366 +     * Returns 0 on success or -errno on error.
   1.367 +     */
   1.368 +    int     (*lockBuffer)(struct ANativeWindow* window,
   1.369 +                struct ANativeWindowBuffer* buffer);
   1.370 +    /*
   1.371 +     * Hook called by EGL when modifications to the render buffer are done.
   1.372 +     * This unlocks and post the buffer.
   1.373 +     *
   1.374 +     * The window holds a reference to the buffer between dequeueBuffer and
   1.375 +     * either queueBuffer or cancelBuffer, so clients only need their own
   1.376 +     * reference if they might use the buffer after queueing or canceling it.
   1.377 +     * Holding a reference to a buffer after queueing or canceling it is only
   1.378 +     * allowed if a specific buffer count has been set.
   1.379 +     *
   1.380 +     * Buffers MUST be queued in the same order than they were dequeued.
   1.381 +     *
   1.382 +     * Returns 0 on success or -errno on error.
   1.383 +     */
   1.384 +    int     (*queueBuffer)(struct ANativeWindow* window,
   1.385 +                struct ANativeWindowBuffer* buffer);
   1.386 +
   1.387 +    /*
   1.388 +     * hook used to retrieve information about the native window.
   1.389 +     *
   1.390 +     * Returns 0 on success or -errno on error.
   1.391 +     */
   1.392 +    int     (*query)(const struct ANativeWindow* window,
   1.393 +                int what, int* value);
   1.394 +
   1.395 +    /*
   1.396 +     * hook used to perform various operations on the surface.
   1.397 +     * (*perform)() is a generic mechanism to add functionality to
   1.398 +     * ANativeWindow while keeping backward binary compatibility.
   1.399 +     *
   1.400 +     * DO NOT CALL THIS HOOK DIRECTLY.  Instead, use the helper functions
   1.401 +     * defined below.
   1.402 +     *
   1.403 +     *  (*perform)() returns -ENOENT if the 'what' parameter is not supported
   1.404 +     *  by the surface's implementation.
   1.405 +     *
   1.406 +     * The valid operations are:
   1.407 +     *     NATIVE_WINDOW_SET_USAGE
   1.408 +     *     NATIVE_WINDOW_CONNECT               (deprecated)
   1.409 +     *     NATIVE_WINDOW_DISCONNECT            (deprecated)
   1.410 +     *     NATIVE_WINDOW_SET_CROP
   1.411 +     *     NATIVE_WINDOW_SET_BUFFER_COUNT
   1.412 +     *     NATIVE_WINDOW_SET_BUFFERS_GEOMETRY  (deprecated)
   1.413 +     *     NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
   1.414 +     *     NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
   1.415 +     *     NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
   1.416 +     *     NATIVE_WINDOW_SET_BUFFERS_FORMAT
   1.417 +     *     NATIVE_WINDOW_SET_SCALING_MODE
   1.418 +     *     NATIVE_WINDOW_LOCK                   (private)
   1.419 +     *     NATIVE_WINDOW_UNLOCK_AND_POST        (private)
   1.420 +     *     NATIVE_WINDOW_API_CONNECT            (private)
   1.421 +     *     NATIVE_WINDOW_API_DISCONNECT         (private)
   1.422 +     *
   1.423 +     */
   1.424 +
   1.425 +    int     (*perform)(struct ANativeWindow* window,
   1.426 +                int operation, ... );
   1.427 +
   1.428 +    /*
   1.429 +     * Hook used to cancel a buffer that has been dequeued.
   1.430 +     * No synchronization is performed between dequeue() and cancel(), so
   1.431 +     * either external synchronization is needed, or these functions must be
   1.432 +     * called from the same thread.
   1.433 +     *
   1.434 +     * The window holds a reference to the buffer between dequeueBuffer and
   1.435 +     * either queueBuffer or cancelBuffer, so clients only need their own
   1.436 +     * reference if they might use the buffer after queueing or canceling it.
   1.437 +     * Holding a reference to a buffer after queueing or canceling it is only
   1.438 +     * allowed if a specific buffer count has been set.
   1.439 +     */
   1.440 +    int     (*cancelBuffer)(struct ANativeWindow* window,
   1.441 +                struct ANativeWindowBuffer* buffer);
   1.442 +
   1.443 +
   1.444 +    void* reserved_proc[2];
   1.445 +};
   1.446 +
   1.447 + /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
   1.448 +  * android_native_window_t is deprecated.
   1.449 +  */
   1.450 +typedef struct ANativeWindow ANativeWindow;
   1.451 +typedef struct ANativeWindow android_native_window_t;
   1.452 +
   1.453 +/*
   1.454 + *  native_window_set_usage(..., usage)
   1.455 + *  Sets the intended usage flags for the next buffers
   1.456 + *  acquired with (*lockBuffer)() and on.
   1.457 + *  By default (if this function is never called), a usage of
   1.458 + *      GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
   1.459 + *  is assumed.
   1.460 + *  Calling this function will usually cause following buffers to be
   1.461 + *  reallocated.
   1.462 + */
   1.463 +
   1.464 +static inline int native_window_set_usage(
   1.465 +        struct ANativeWindow* window, int usage)
   1.466 +{
   1.467 +    return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
   1.468 +}
   1.469 +
   1.470 +/* deprecated. Always returns 0. Don't call. */
   1.471 +static inline int native_window_connect(
   1.472 +        struct ANativeWindow* window, int api) {
   1.473 +    return 0;
   1.474 +}
   1.475 +
   1.476 +/* deprecated. Always returns 0. Don't call. */
   1.477 +static inline int native_window_disconnect(
   1.478 +        struct ANativeWindow* window, int api) {
   1.479 +    return 0;
   1.480 +}
   1.481 +
   1.482 +/*
   1.483 + * native_window_set_crop(..., crop)
   1.484 + * Sets which region of the next queued buffers needs to be considered.
   1.485 + * A buffer's crop region is scaled to match the surface's size.
   1.486 + *
   1.487 + * The specified crop region applies to all buffers queued after it is called.
   1.488 + *
   1.489 + * if 'crop' is NULL, subsequently queued buffers won't be cropped.
   1.490 + *
   1.491 + * An error is returned if for instance the crop region is invalid,
   1.492 + * out of the buffer's bound or if the window is invalid.
   1.493 + */
   1.494 +static inline int native_window_set_crop(
   1.495 +        struct ANativeWindow* window,
   1.496 +        android_native_rect_t const * crop)
   1.497 +{
   1.498 +    return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
   1.499 +}
   1.500 +
   1.501 +/*
   1.502 + * native_window_set_buffer_count(..., count)
   1.503 + * Sets the number of buffers associated with this native window.
   1.504 + */
   1.505 +static inline int native_window_set_buffer_count(
   1.506 +        struct ANativeWindow* window,
   1.507 +        size_t bufferCount)
   1.508 +{
   1.509 +    return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
   1.510 +}
   1.511 +
   1.512 +/*
   1.513 + * native_window_set_buffers_geometry(..., int w, int h, int format)
   1.514 + * All buffers dequeued after this call will have the dimensions and format
   1.515 + * specified.  A successful call to this function has the same effect as calling
   1.516 + * native_window_set_buffers_size and native_window_set_buffers_format.
   1.517 + *
   1.518 + * XXX: This function is deprecated.  The native_window_set_buffers_dimensions
   1.519 + * and native_window_set_buffers_format functions should be used instead.
   1.520 + */
   1.521 +static inline int native_window_set_buffers_geometry(
   1.522 +        struct ANativeWindow* window,
   1.523 +        int w, int h, int format)
   1.524 +{
   1.525 +    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
   1.526 +            w, h, format);
   1.527 +}
   1.528 +
   1.529 +/*
   1.530 + * native_window_set_buffers_dimensions(..., int w, int h)
   1.531 + * All buffers dequeued after this call will have the dimensions specified.
   1.532 + * In particular, all buffers will have a fixed-size, independent form the
   1.533 + * native-window size. They will be scaled according to the scaling mode
   1.534 + * (see native_window_set_scaling_mode) upon window composition.
   1.535 + *
   1.536 + * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
   1.537 + * following this call will be sized to match the window's size.
   1.538 + *
   1.539 + * Calling this function will reset the window crop to a NULL value, which
   1.540 + * disables cropping of the buffers.
   1.541 + */
   1.542 +static inline int native_window_set_buffers_dimensions(
   1.543 +        struct ANativeWindow* window,
   1.544 +        int w, int h)
   1.545 +{
   1.546 +    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
   1.547 +            w, h);
   1.548 +}
   1.549 +
   1.550 +/*
   1.551 + * native_window_set_buffers_format(..., int format)
   1.552 + * All buffers dequeued after this call will have the format specified.
   1.553 + *
   1.554 + * If the specified format is 0, the default buffer format will be used.
   1.555 + */
   1.556 +static inline int native_window_set_buffers_format(
   1.557 +        struct ANativeWindow* window,
   1.558 +        int format)
   1.559 +{
   1.560 +    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
   1.561 +}
   1.562 +
   1.563 +/*
   1.564 + * native_window_set_buffers_transform(..., int transform)
   1.565 + * All buffers queued after this call will be displayed transformed according
   1.566 + * to the transform parameter specified.
   1.567 + */
   1.568 +static inline int native_window_set_buffers_transform(
   1.569 +        struct ANativeWindow* window,
   1.570 +        int transform)
   1.571 +{
   1.572 +    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
   1.573 +            transform);
   1.574 +}
   1.575 +
   1.576 +/*
   1.577 + * native_window_set_buffers_timestamp(..., int64_t timestamp)
   1.578 + * All buffers queued after this call will be associated with the timestamp
   1.579 + * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
   1.580 + * (the default), timestamps will be generated automatically when queueBuffer is
   1.581 + * called. The timestamp is measured in nanoseconds, and is normally monotonically
   1.582 + * increasing. The timestamp should be unaffected by time-of-day adjustments,
   1.583 + * and for a camera should be strictly monotonic but for a media player may be
   1.584 + * reset when the position is set.
   1.585 + */
   1.586 +static inline int native_window_set_buffers_timestamp(
   1.587 +        struct ANativeWindow* window,
   1.588 +        int64_t timestamp)
   1.589 +{
   1.590 +    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
   1.591 +            timestamp);
   1.592 +}
   1.593 +
   1.594 +/*
   1.595 + * native_window_set_scaling_mode(..., int mode)
   1.596 + * All buffers queued after this call will be associated with the scaling mode
   1.597 + * specified.
   1.598 + */
   1.599 +static inline int native_window_set_scaling_mode(
   1.600 +        struct ANativeWindow* window,
   1.601 +        int mode)
   1.602 +{
   1.603 +    return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
   1.604 +            mode);
   1.605 +}
   1.606 +
   1.607 +
   1.608 +/*
   1.609 + * native_window_api_connect(..., int api)
   1.610 + * connects an API to this window. only one API can be connected at a time.
   1.611 + * Returns -EINVAL if for some reason the window cannot be connected, which
   1.612 + * can happen if it's connected to some other API.
   1.613 + */
   1.614 +static inline int native_window_api_connect(
   1.615 +        struct ANativeWindow* window, int api)
   1.616 +{
   1.617 +    return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
   1.618 +}
   1.619 +
   1.620 +/*
   1.621 + * native_window_api_disconnect(..., int api)
   1.622 + * disconnect the API from this window.
   1.623 + * An error is returned if for instance the window wasn't connected in the
   1.624 + * first place.
   1.625 + */
   1.626 +static inline int native_window_api_disconnect(
   1.627 +        struct ANativeWindow* window, int api)
   1.628 +{
   1.629 +    return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
   1.630 +}
   1.631 +
   1.632 +
   1.633 +__END_DECLS
   1.634 +
   1.635 +#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */

mercurial