| 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 |
{ @exclude Internal for the engine. } |
| 18 |
unit CastleAndroidInternalNativeWindow; |
| 19 |
|
| 20 |
{$I castleconf.inc} |
| 21 |
|
| 22 |
interface |
| 23 |
|
| 24 |
uses ctypes, CastleAndroidInternalRect; |
| 25 |
|
| 26 |
(* |
| 27 |
* Pixel formats that a window can use. |
| 28 |
*) |
| 29 |
const |
| 30 |
WINDOW_FORMAT_RGBA_8888 = 1; |
| 31 |
WINDOW_FORMAT_RGBX_8888 = 2; |
| 32 |
WINDOW_FORMAT_RGB_565 = 4; |
| 33 |
|
| 34 |
type |
| 35 |
PANativeWindow = ^ANativeWindow; |
| 36 |
ANativeWindow = record end; |
| 37 |
|
| 38 |
PANativeWindow_Buffer = ^ANativeWindow_Buffer; |
| 39 |
ANativeWindow_Buffer = packed record |
| 40 |
// The number of pixels that are show horizontally. |
| 41 |
width : cint32; |
| 42 |
// The number of pixels that are shown vertically. |
| 43 |
height : cint32; |
| 44 |
// The number of *pixels* that a line in the buffer takes in |
| 45 |
// memory. This may be >= width. |
| 46 |
stride : cint32; |
| 47 |
// The format of the buffer. One of WINDOW_FORMAT_* |
| 48 |
format : cint32; |
| 49 |
// The actual bits. |
| 50 |
bits : Pointer; |
| 51 |
// Do not touch. |
| 52 |
reserved : array [0..5] of cuint32; |
| 53 |
end; |
| 54 |
|
| 55 |
(** |
| 56 |
* Acquire a reference on the given ANativeWindow object. This prevents the object |
| 57 |
* from being deleted until the reference is removed. |
| 58 |
*) |
| 59 |
procedure ANativeWindow_acquire(window: PANativeWindow); cdecl; external; |
| 60 |
|
| 61 |
(** |
| 62 |
* Remove a reference that was previously acquired with ANativeWindow_acquire(). |
| 63 |
*) |
| 64 |
procedure ANativeWindow_release(window: PANativeWindow); cdecl; external; |
| 65 |
|
| 66 |
(* |
| 67 |
* Return the current width in pixels of the window surface. Returns a |
| 68 |
* negative value on error. |
| 69 |
*) |
| 70 |
function ANativeWindow_getWidth(window: PANativeWindow): cint32; cdecl; external; |
| 71 |
|
| 72 |
(* |
| 73 |
* Return the current height in pixels of the window surface. Returns a |
| 74 |
* negative value on error. |
| 75 |
*) |
| 76 |
function ANativeWindow_getHeight(window: PANativeWindow): cint32; cdecl; external; |
| 77 |
|
| 78 |
(* |
| 79 |
* Return the current pixel format of the window surface. Returns a |
| 80 |
* negative value on error. |
| 81 |
*) |
| 82 |
function ANativeWindow_getFormat(window: PANativeWindow): cint32; cdecl; external; |
| 83 |
|
| 84 |
(* |
| 85 |
* Change the format and size of the window buffers. |
| 86 |
* |
| 87 |
* The width and height control the number of pixels in the buffers, not the |
| 88 |
* dimensions of the window on screen. If these are different than the |
| 89 |
* window's physical size, then it buffer will be scaled to match that size |
| 90 |
* when compositing it to the screen. |
| 91 |
* |
| 92 |
* For all of these parameters, if 0 is supplied then the window's base |
| 93 |
* value will come back in force. |
| 94 |
*) |
| 95 |
function ANativeWindow_setBuffersGeometry(window: PANativeWindow; width, height, format: cint32): cint32; cdecl; external; |
| 96 |
|
| 97 |
(** |
| 98 |
* Lock the window's next drawing surface for writing. |
| 99 |
*) |
| 100 |
function ANativeWindow_lock(window: PANativeWindow; outBuffer: PANativeWindow_Buffer; inOutDirtyBounds: PARect): cint32; cdecl; external; |
| 101 |
|
| 102 |
(** |
| 103 |
* Unlock the window's drawing surface after previously locking it, |
| 104 |
* posting the new buffer to the display. |
| 105 |
*) |
| 106 |
function ANativeWindow_unlockAndPost(window: PANativeWindow): cint32; cdecl; external; |
| 107 |
|
| 108 |
implementation |
| 109 |
|
| 110 |
end. |
| 111 |
|