Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2010 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 ANDROID_NATIVE_WINDOW_H
     18 #define ANDROID_NATIVE_WINDOW_H
     19 
     20 #include <sys/cdefs.h>
     21 #include <android/rect.h>
     22 
     23 __BEGIN_DECLS
     24 
     25 /*
     26  * Pixel formats that a window can use.
     27  */
     28 enum {
     29     WINDOW_FORMAT_RGBA_8888          = 1,
     30     WINDOW_FORMAT_RGBX_8888          = 2,
     31     WINDOW_FORMAT_RGB_565            = 4,
     32 };
     33 
     34 struct ANativeWindow;
     35 typedef struct ANativeWindow ANativeWindow;
     36 
     37 typedef struct ANativeWindow_Buffer {
     38     // The number of pixels that are show horizontally.
     39     int32_t width;
     40 
     41     // The number of pixels that are shown vertically.
     42     int32_t height;
     43 
     44     // The number of *pixels* that a line in the buffer takes in
     45     // memory.  This may be >= width.
     46     int32_t stride;
     47 
     48     // The format of the buffer.  One of WINDOW_FORMAT_*
     49     int32_t format;
     50 
     51     // The actual bits.
     52     void* bits;
     53 
     54     // Do not touch.
     55     uint32_t reserved[6];
     56 } ANativeWindow_Buffer;
     57 
     58 /**
     59  * Acquire a reference on the given ANativeWindow object.  This prevents the object
     60  * from being deleted until the reference is removed.
     61  */
     62 void ANativeWindow_acquire(ANativeWindow* window);
     63 
     64 /**
     65  * Remove a reference that was previously acquired with ANativeWindow_acquire().
     66  */
     67 void ANativeWindow_release(ANativeWindow* window);
     68 
     69 /*
     70  * Return the current width in pixels of the window surface.  Returns a
     71  * negative value on error.
     72  */
     73 int32_t ANativeWindow_getWidth(ANativeWindow* window);
     74 
     75 /*
     76  * Return the current height in pixels of the window surface.  Returns a
     77  * negative value on error.
     78  */
     79 int32_t ANativeWindow_getHeight(ANativeWindow* window);
     80 
     81 /*
     82  * Return the current pixel format of the window surface.  Returns a
     83  * negative value on error.
     84  */
     85 int32_t ANativeWindow_getFormat(ANativeWindow* window);
     86 
     87 /*
     88  * Change the format and size of the window buffers.
     89  *
     90  * The width and height control the number of pixels in the buffers, not the
     91  * dimensions of the window on screen.  If these are different than the
     92  * window's physical size, then it buffer will be scaled to match that size
     93  * when compositing it to the screen.
     94  *
     95  * For all of these parameters, if 0 is supplied then the window's base
     96  * value will come back in force.
     97  */
     98 int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width, int32_t height, int32_t format);
     99 
    100 /**
    101  * Lock the window's next drawing surface for writing.
    102  */
    103 int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer,
    104         ARect* inOutDirtyBounds);
    105 
    106 /**
    107  * Unlock the window's drawing surface after previously locking it,
    108  * posting the new buffer to the display.
    109  */
    110 int32_t ANativeWindow_unlockAndPost(ANativeWindow* window);
    111 
    112 __END_DECLS
    113 
    114 #endif /* ANDROID_NATIVE_WINDOW_H */
    115