blob: 7599d7e550f6cff7e9051c584c5bf899f3dc4170 [file] [log] [blame]
Dianne Hackborn8b49bd12010-06-30 13:56:17 -07001/*
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
Dianne Hackborn8b49bd12010-06-30 13:56:17 -070017#ifndef ANDROID_NATIVE_WINDOW_H
18#define ANDROID_NATIVE_WINDOW_H
19
Dianne Hackborn289b9b62010-07-09 11:44:11 -070020#include <android/rect.h>
21
Dianne Hackborn8b49bd12010-06-30 13:56:17 -070022#ifdef __cplusplus
23extern "C" {
24#endif
25
Dianne Hackborn8ae5a8e2010-07-01 18:44:46 -070026/*
27 * Pixel formats that a window can use.
28 */
29enum {
30 WINDOW_FORMAT_RGBA_8888 = 1,
31 WINDOW_FORMAT_RGBX_8888 = 2,
32 WINDOW_FORMAT_RGB_565 = 4,
33};
34
Dianne Hackborn8b49bd12010-06-30 13:56:17 -070035struct ANativeWindow;
36typedef struct ANativeWindow ANativeWindow;
37
Dianne Hackborn289b9b62010-07-09 11:44:11 -070038typedef struct ANativeWindow_Buffer {
39 int32_t width;
40 int32_t height;
41 int32_t stride;
42 int32_t format;
43 void* bits;
44
45 uint32_t reserved[6];
46} ANativeWindow_Buffer;
47
48/**
49 * Acquire a reference on the given ANativeWindow object. This prevents the object
50 * from being deleted until the reference is removed.
51 */
52void ANativeWindow_acquire(ANativeWindow* window);
53
54/**
55 * Remove a reference that was previously acquired with ANativeWindow_acquire().
56 */
57void ANativeWindow_release(ANativeWindow* window);
58
Dianne Hackborn54a181b2010-06-30 18:35:14 -070059/*
60 * Return the current width in pixels of the window surface. Returns a
61 * negative value on error.
62 */
63int32_t ANativeWindow_getWidth(ANativeWindow* window);
64
65/*
66 * Return the current height in pixels of the window surface. Returns a
67 * negative value on error.
68 */
69int32_t ANativeWindow_getHeight(ANativeWindow* window);
70
71/*
72 * Return the current pixel format of the window surface. Returns a
73 * negative value on error.
74 */
75int32_t ANativeWindow_getFormat(ANativeWindow* window);
Dianne Hackborn8b49bd12010-06-30 13:56:17 -070076
Dianne Hackborn8ae5a8e2010-07-01 18:44:46 -070077/*
78 * Change the format and size of the window buffers.
79 *
80 * The width and height control the number of pixels in the buffers, not the
81 * dimensions of the window on screen. If these are different than the
82 * window's physical size, then it buffer will be scaled to match that size
83 * when compositing it to the screen.
84 *
Dianne Hackborn289b9b62010-07-09 11:44:11 -070085 * For all of these parameters, if 0 is supplied then the window's base
Dianne Hackborn8ae5a8e2010-07-01 18:44:46 -070086 * value will come back in force.
87 */
Dianne Hackborn289b9b62010-07-09 11:44:11 -070088int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width, int32_t height);
89
90/**
91 * Lock the window's next drawing surface for writing.
92 */
93int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer,
94 ARect* inOutDirtyBounds);
95
96/**
97 * Unlock the window's drawing surface after previously locking it,
98 * posting the new buffer to the display.
99 */
100int32_t ANativeWindow_unlockAndPost(ANativeWindow* window);
Dianne Hackborn8ae5a8e2010-07-01 18:44:46 -0700101
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700102#ifdef __cplusplus
103};
104#endif
105
106#endif // ANDROID_NATIVE_WINDOW_H