Home | History | Annotate | Download | only in skin
      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_REGION_H
     13 #define _ANDROID_SKIN_REGION_H
     14 
     15 #include "android/skin/rect.h"
     16 
     17 typedef struct SkinRegion  SkinRegion;
     18 
     19 extern void  skin_region_init_empty( SkinRegion*  r );
     20 extern void  skin_region_init( SkinRegion*  r, int  x1, int  y1, int  x2, int  y2 );
     21 extern void  skin_region_init_rect( SkinRegion*  r, SkinRect*  rect );
     22 extern void  skin_region_init_box( SkinRegion*  r, SkinBox*  box );
     23 extern void  skin_region_init_copy( SkinRegion*  r, SkinRegion*  r2 );
     24 extern void  skin_region_reset( SkinRegion*  r );
     25 
     26 /* finalize region, then copy src into it */
     27 extern void  skin_region_copy( SkinRegion*  r, SkinRegion*  src );
     28 
     29 /* compare two regions for equality */
     30 extern int   skin_region_equals( SkinRegion*  r1, SkinRegion*  r2 );
     31 
     32 /* swap two regions */
     33 extern void  skin_region_swap( SkinRegion*  r, SkinRegion*  r2 );
     34 
     35 extern int   skin_region_is_empty( SkinRegion*  r );
     36 extern int   skin_region_is_rect( SkinRegion*  r );
     37 extern int   skin_region_is_complex( SkinRegion*  r );
     38 extern void  skin_region_get_bounds( SkinRegion*  r, SkinRect*  bounds );
     39 
     40 extern void  skin_region_translate( SkinRegion*  r, int  dx, int  dy );
     41 
     42 extern SkinOverlap  skin_region_contains( SkinRegion*  r, int  x, int  y );
     43 
     44 extern SkinOverlap  skin_region_contains_rect( SkinRegion*  r,
     45                                                SkinRect*    rect );
     46 
     47 extern SkinOverlap  skin_region_contains_box( SkinRegion*  r, SkinBox*  b );
     48 
     49 /* returns overlap mode for "is r2 inside r1" */
     50 extern  SkinOverlap  skin_region_test_intersect( SkinRegion*  r1,
     51                                                  SkinRegion*  r2 );
     52 
     53 /* performs r = (intersect r r2), returns true if the resulting region
     54    is not empty */
     55 extern int  skin_region_intersect     ( SkinRegion*  r, SkinRegion*  r2 );
     56 extern int  skin_region_intersect_rect( SkinRegion*  r, SkinRect*    rect );
     57 
     58 /* performs r = (intersect r (region+_from_rect rect)), returns true iff
     59    the resulting region is not empty */
     60 
     61 /* performs r = (union r r2) */
     62 extern void skin_region_union     ( SkinRegion*  r, SkinRegion*  r2 );
     63 extern void skin_region_union_rect( SkinRegion*  r, SkinRect*  rect );
     64 
     65 /* performs r = (difference r r2) */
     66 extern void skin_region_substract     ( SkinRegion*  r, SkinRegion*  r2 );
     67 extern void skin_region_substract_rect( SkinRegion*  r, SkinRect*  rect );
     68 
     69 /* performs r = (xor r r2) */
     70 extern void skin_region_xor( SkinRegion*  r, SkinRegion*  r2 );
     71 
     72 typedef struct SkinRegionIterator  SkinRegionIterator;
     73 
     74 /* iterator */
     75 extern void  skin_region_iterator_init( SkinRegionIterator*  iter,
     76                                         SkinRegion*          r );
     77 
     78 extern int   skin_region_iterator_next( SkinRegionIterator*  iter,
     79                                         SkinRect            *rect );
     80 
     81 extern int   skin_rection_iterator_next_box( SkinRegionIterator*  iter,
     82                                              SkinBox             *box );
     83 
     84 /* the following should be considered private definitions. they're only here
     85    to allow clients to allocate SkinRegion objects themselves... */
     86 
     87 typedef signed short   SkinRegionRun;
     88 #define SKIN_REGION_SENTINEL  0x7fff
     89 
     90 struct SkinRegion
     91 {
     92     SkinRect        bounds;
     93     SkinRegionRun*  runs;
     94 };
     95 
     96 struct SkinRegionIterator
     97 {
     98     SkinRegion*     region;
     99     SkinRegionRun*  band;
    100     SkinRegionRun*  span;
    101 };
    102 
    103 #endif /* _ANDROID_SKIN_REGION_H */
    104