Re: [AD] New clipping API

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2003-11-22, Eric <ebotcazou@xxxxxxxxxx> wrote:
> This patch implements a new clipping API.  This topic was discussed at length 
> about one year ago and has been on the TODO list since then.
> 
> It deprecates set_clip() and replaces it with 5 new functions:
> 
> void set_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2);
> void add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2);
> inline void get_clip_rect(BITMAP *bitmap, int *x1, int *y1, int *x2, int*y2);
> inline void set_clip_state, (BITMAP *bitmap, int state);
> inline int get_clip_state(BITMAP *bitmap);
> 
> The semantics of the coordinates is the same as the current one for set_clip.  

I think you incorporated all the right parts of the various proposals.
I'm very happy with this.

> -@domain.hid @set_clip(BITMAP *bitmap, int x1, int y1, int x2, int y2);
> +@@void @set_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2);
> +@xref get_clip_rect, add_clip_rect, set_clip_state, get_clip_state
>  @eref ex12bit, excamera
[...]
> +   Drawing operations will be performed (at least partially) on the bitmap as
> +   long as the intersection of its clipping rectangle and its actual surface
> +   is non-empty and the first coordinates are not greater than the second
> +   coordinates. If either condition is not fulfilled, drawing will be turned
> +   off for the bitmap.

    e.g. set_clip_rect(bmp, 1, 1, 0, 0); /* disable drawing on bmp */

The first thing I would have tried was set_clip_rect(bmp,0,0,-1,-1) but
that wouldn't work.

Luckily, set_clip_rect(bmp,1,1,0,0) would extend itself to zero-area
bitmaps (if one day allowed), since you can't draw to such bitmaps
anyway.

-- 
王浩禎




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/