2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_NATIVE_WINDOW_H
18 #define ANDROID_NATIVE_WINDOW_H
20 #include <android/rect.h>
27 * Pixel formats that a window can use.
30 WINDOW_FORMAT_RGBA_8888 = 1,
31 WINDOW_FORMAT_RGBX_8888 = 2,
32 WINDOW_FORMAT_RGB_565 = 4,
36 typedef struct ANativeWindow ANativeWindow;
38 typedef struct ANativeWindow_Buffer {
39 // The number of pixels that are show horizontally.
42 // The number of pixels that are shown vertically.
45 // The number of *pixels* that a line in the buffer takes in
46 // memory. This may be >= width.
49 // The format of the buffer. One of WINDOW_FORMAT_*
57 } ANativeWindow_Buffer;
60 * Acquire a reference on the given ANativeWindow object. This prevents the object
61 * from being deleted until the reference is removed.
63 void ANativeWindow_acquire(ANativeWindow* window);
66 * Remove a reference that was previously acquired with ANativeWindow_acquire().
68 void ANativeWindow_release(ANativeWindow* window);
71 * Return the current width in pixels of the window surface. Returns a
72 * negative value on error.
74 int32_t ANativeWindow_getWidth(ANativeWindow* window);
77 * Return the current height in pixels of the window surface. Returns a
78 * negative value on error.
80 int32_t ANativeWindow_getHeight(ANativeWindow* window);
83 * Return the current pixel format of the window surface. Returns a
84 * negative value on error.
86 int32_t ANativeWindow_getFormat(ANativeWindow* window);
89 * Change the format and size of the window buffers.
91 * The width and height control the number of pixels in the buffers, not the
92 * dimensions of the window on screen. If these are different than the
93 * window's physical size, then it buffer will be scaled to match that size
94 * when compositing it to the screen.
96 * For all of these parameters, if 0 is supplied then the window's base
97 * value will come back in force.
99 * width and height must be either both zero or both non-zero.
102 int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window,
103 int32_t width, int32_t height, int32_t format);
106 * Lock the window's next drawing surface for writing.
107 * inOutDirtyBounds is used as an in/out parameter, upon entering the
108 * function, it contains the dirty region, that is, the region the caller
109 * intends to redraw. When the function returns, inOutDirtyBounds is updated
110 * with the actual area the caller needs to redraw -- this region is often
111 * extended by ANativeWindow_lock.
113 int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer,
114 ARect* inOutDirtyBounds);
117 * Unlock the window's drawing surface after previously locking it,
118 * posting the new buffer to the display.
120 int32_t ANativeWindow_unlockAndPost(ANativeWindow* window);
126 #endif // ANDROID_NATIVE_WINDOW_H