michael@0: /* michael@0: * Copyright (C) 2010 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef ANDROID_NATIVE_WINDOW_H michael@0: #define ANDROID_NATIVE_WINDOW_H michael@0: michael@0: #include michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: /* michael@0: * Pixel formats that a window can use. michael@0: */ michael@0: enum { michael@0: WINDOW_FORMAT_RGBA_8888 = 1, michael@0: WINDOW_FORMAT_RGBX_8888 = 2, michael@0: WINDOW_FORMAT_RGB_565 = 4, michael@0: }; michael@0: michael@0: struct ANativeWindow; michael@0: typedef struct ANativeWindow ANativeWindow; michael@0: michael@0: typedef struct ANativeWindow_Buffer { michael@0: // The number of pixels that are show horizontally. michael@0: int32_t width; michael@0: michael@0: // The number of pixels that are shown vertically. michael@0: int32_t height; michael@0: michael@0: // The number of *pixels* that a line in the buffer takes in michael@0: // memory. This may be >= width. michael@0: int32_t stride; michael@0: michael@0: // The format of the buffer. One of WINDOW_FORMAT_* michael@0: int32_t format; michael@0: michael@0: // The actual bits. michael@0: void* bits; michael@0: michael@0: // Do not touch. michael@0: uint32_t reserved[6]; michael@0: } ANativeWindow_Buffer; michael@0: michael@0: /** michael@0: * Acquire a reference on the given ANativeWindow object. This prevents the object michael@0: * from being deleted until the reference is removed. michael@0: */ michael@0: void ANativeWindow_acquire(ANativeWindow* window); michael@0: michael@0: /** michael@0: * Remove a reference that was previously acquired with ANativeWindow_acquire(). michael@0: */ michael@0: void ANativeWindow_release(ANativeWindow* window); michael@0: michael@0: /* michael@0: * Return the current width in pixels of the window surface. Returns a michael@0: * negative value on error. michael@0: */ michael@0: int32_t ANativeWindow_getWidth(ANativeWindow* window); michael@0: michael@0: /* michael@0: * Return the current height in pixels of the window surface. Returns a michael@0: * negative value on error. michael@0: */ michael@0: int32_t ANativeWindow_getHeight(ANativeWindow* window); michael@0: michael@0: /* michael@0: * Return the current pixel format of the window surface. Returns a michael@0: * negative value on error. michael@0: */ michael@0: int32_t ANativeWindow_getFormat(ANativeWindow* window); michael@0: michael@0: /* michael@0: * Change the format and size of the window buffers. michael@0: * michael@0: * The width and height control the number of pixels in the buffers, not the michael@0: * dimensions of the window on screen. If these are different than the michael@0: * window's physical size, then it buffer will be scaled to match that size michael@0: * when compositing it to the screen. michael@0: * michael@0: * For all of these parameters, if 0 is supplied then the window's base michael@0: * value will come back in force. michael@0: */ michael@0: int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width, int32_t height, int32_t format); michael@0: michael@0: /** michael@0: * Lock the window's next drawing surface for writing. michael@0: */ michael@0: int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, michael@0: ARect* inOutDirtyBounds); michael@0: michael@0: /** michael@0: * Unlock the window's drawing surface after previously locking it, michael@0: * posting the new buffer to the display. michael@0: */ michael@0: int32_t ANativeWindow_unlockAndPost(ANativeWindow* window); michael@0: michael@0: #ifdef __cplusplus michael@0: }; michael@0: #endif michael@0: michael@0: #endif // ANDROID_NATIVE_WINDOW_H