1 /* Copyright (C) 2007-2008 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 #ifndef _ANDROID_SKIN_SURFACE_H 13 #define _ANDROID_SKIN_SURFACE_H 14 15 #include "android/skin/region.h" 16 #include <stdint.h> 17 18 /* a SkinSurface models a 32-bit ARGB pixel image that can be blitted to or from 19 */ 20 typedef struct SkinSurface SkinSurface; 21 22 /* increment surface's reference count */ 23 extern SkinSurface* skin_surface_ref( SkinSurface* surface ); 24 25 /* decrement a surface's reference count. takes the surface's address as parameter. 26 it will be set to NULL on exit */ 27 extern void skin_surface_unrefp( SkinSurface* *psurface ); 28 29 /* sets a callback that will be called when the surface is destroyed. 30 * used NULL for done_func to disable it 31 */ 32 typedef void (*SkinSurfaceDoneFunc)( void* user ); 33 34 extern void skin_surface_set_done( SkinSurface* s, SkinSurfaceDoneFunc done_func, void* done_user ); 35 36 37 /* there are two kinds of surfaces: 38 39 - fast surfaces, whose content can be placed in video memory or 40 RLE-compressed for faster blitting and blending. the pixel format 41 used internally might be something very different from ARGB32. 42 43 - slow surfaces, whose content (pixel buffer) can be accessed and modified 44 with _lock()/_unlock() but may be blitted far slower since they reside in 45 system memory. 46 */ 47 48 /* create a 'fast' surface that contains a copy of an input ARGB32 pixmap */ 49 extern SkinSurface* skin_surface_create_fast( int w, int h ); 50 51 /* create an empty 'slow' surface containing an ARGB32 pixmap */ 52 extern SkinSurface* skin_surface_create_slow( int w, int h ); 53 54 /* create a 'slow' surface from a given pixel buffer. if 'do_copy' is TRUE, then 55 * the content of 'pixels' is copied into a heap-allocated buffer. otherwise 56 * the data will be used directly. 57 */ 58 extern SkinSurface* skin_surface_create_argb32_from( 59 int w, 60 int h, 61 int pitch, 62 uint32_t* pixels, 63 int do_copy ); 64 65 /* surface pixels information for slow surfaces */ 66 typedef struct { 67 int w; 68 int h; 69 int pitch; 70 uint32_t* pixels; 71 } SkinSurfacePixels; 72 73 /* lock a slow surface, and returns its pixel information. 74 returns 0 in case of success, -1 otherwise */ 75 extern int skin_surface_lock ( SkinSurface* s, SkinSurfacePixels *pix ); 76 77 /* unlock a slow surface that was previously locked */ 78 extern void skin_surface_unlock( SkinSurface* s ); 79 80 /* list of composition operators for the blit routine */ 81 typedef enum { 82 SKIN_BLIT_COPY = 0, 83 SKIN_BLIT_SRCOVER, 84 SKIN_BLIT_DSTOVER, 85 } SkinBlitOp; 86 87 88 /* blit a surface into another one */ 89 extern void skin_surface_blit( SkinSurface* dst, 90 SkinPos* dst_pos, 91 SkinSurface* src, 92 SkinRect* src_rect, 93 SkinBlitOp blitop ); 94 95 /* blit a colored rectangle into a destination surface */ 96 extern void skin_surface_fill( SkinSurface* dst, 97 SkinRect* rect, 98 uint32_t argb_premul, 99 SkinBlitOp blitop ); 100 101 #endif /* _ANDROID_SKIN_SURFACE_H */ 102