/* @(#)canvas.h 9.3 88/01/19 */ /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ /*- Definitions dealing with canvases (drawing surfaces) canvas.h, Tue Oct 8 12:59:00 1985 James Gosling, Sun Microsystems */ #ifndef cv_is_canvas #ifndef pr_width #include #endif #ifndef canvas #include "cursor.h" #endif #define NoEvents 0 #define MatchedEvents 1 #define AllEvents 2 /* Per canvas cursor information */ struct canvas_cursor { struct psfont *psfont; /* Font used for reference counting */ struct cursor_shape cursor; /* Image description */ }; /* A surface upon which things can be drawn */ struct canvas { struct pixrect pixrect; /* A canvas is just an annotated pixrect */ int signature; /* The mark of a valid canvas. This is here as a stopgop to deal with a GC bug */ struct canvas *parent, /* The canvas that contains this canvas */ *topchild, /* Topmost visible child of this canvas */ *next, /* Double linked list of canvases, */ *prev, /* => overlapped layers; next is higher. * Such a set of canvases is called a * 'scene' */ *opaqparent; /* The opaque parent of this canvas, * points to self if not transparent */ struct spoint pos; /* The coordinates of this canvas in relation to the other canvases in this scene */ struct shape *outerclip, /* The outermost clipping region (the real * shape of the canvas) */ *globalclip, /* A clipping region within the shape of the canvas that is in effect for all graphics contexts that access the canvas -- is not a part of a graphics context */ *lastclip; /* The "current clipping region" for which parts[].clip are valid */ char *spare; /* An opaque handle for use by clients */ short refcnt; /* The number of references to this canvas */ unsigned char invgeneration,/* The generation in which this canvas's clipping was invalidated */ subgeneration; /* The generation in which this canvas invalidated the clipping of canvases under it */ unsigned int transparent:1; /* True iff this canvas is transparent; ie. its bits are really owned by its parent */ unsigned int events_consumed:2; /* whether canvas will prevent lower canvases from receiving events */ unsigned int mapped:1; /* True iff this canvas has been mapped onto a screen */ unsigned int map_req:1; /* True iff the client has explicitly requested this canvas to be mapped */ unsigned int complete:1; /* True iff the retained part of this canvas is complete */ unsigned int saveback:1; /* True iff the bits behind this canvas get saved in this canvas -- used in non-retained situations for pop-ups */ unsigned int retained:1; /* true iff this canvas is retained */ unsigned int overlay:1; /* true iff this canvas is an overlay */ unsigned int indamqueue:1; /* true iff this canvas is in the damage queue */ unsigned int validpix:1; /* true iff the associated pixrects are valid */ unsigned int hasopaque:1; /* true iff this canvas has any opaque subcanvases */ struct scene *scene; /* The scene that this canvas resides in */ struct canvas *damnext; /* The next entry in the damage queue */ struct shape *damage; /* The region that has been damaged */ struct canvas_part { /* The hidden & on-screen parts of the * canvas */ struct pixrect *pixrect;/* Where the bits are */ struct shape *clip; /* which are valid */ } parts[2]; /* part[0] is always the retained image, part[1] is the screen. */ struct canvas_cursor cdata; /* Cursor info */ fract matrix[3][2]; /* Default matrix */ struct spoint scr_pos; /* Position of canvas relative to screen, * (0,0) if unmapped (accelerator for * cursor tracker) */ }; #define CANVASSIGNATURE 0xA3F09E5C /* A scene is a collection of canvases. Generally there is one scene per display device */ struct scene { struct canvas *canvases; /* points to the root canvas for a display * This is the "framebuffer". It will * have no siblings, but its children will * be the usual opaque windows. */ struct pixrect *display; /* The pixrect for this device */ fract matrix[3][2]; /* The X and Y multipliers of the default * transformation matrix. This describes * the shape of a pixel. */ }; #define cv_is_canvas(pr) (((struct pixrect *)(pr))->pr_canvas) #define overlap_possible(c1,c2) \ !((c1)->pos.x>=(c2)->pos.x+(c2)->size.x \ || (c1)->pos.x+(c1)->size.x<=(c2)->pos.x \ || (c1)->pos.y>=(c2)->pos.y+(c2)->size.y \ || (c1)->pos.y+(c1)->size.y<=(c2)->pos.y) #define cv_overlap_possible(c1,c2) \ !((c1)->pos.x>=(c2)->pos.x+(c2)->pixrect.pr_size.x \ || (c1)->pos.x+(c1)->pixrect.pr_size.x<=(c2)->pos.x \ || (c1)->pos.y>=(c2)->pos.y+(c2)->pixrect.pr_size.y \ || (c1)->pos.y+(c1)->pixrect.pr_size.y<=(c2)->pos.y) /* #define REFTRACE /* Define this if you want incref/decref tracing */ #ifndef REFTRACE #define cv_incref(cv) ((cv)->refcnt++) #define cv_decref(cv) (--(cv)->refcnt==0 ? cv_destroy(cv) : 0) #else #ifdef LOGALLOC #ifndef FILE #include #endif #define cv_incref(cv) (qal_log(cv,(cv)->refcnt,__LINE__,__FILE__,'I'), \ (cv)->refcnt++) #define cv_decref(cv) (qal_log(cv,(cv)->refcnt-1,__LINE__,__FILE__,'D'), \ (--(cv)->refcnt==0 ? cv_destroy(cv) : 0)) #else #ifndef FILE #include #endif extern int cv_seq; #define cv_incref(cv) (fprintf(stderr,"%10d %6d %3d %s, line %d: cvincref %dx%d\n", \ cv, cv_seq++, (cv)->refcnt, \ __FILE__, __LINE__, \ (cv)->pixrect.pr_size.x, \ (cv)->pixrect.pr_size.y), \ (cv)->refcnt++) #define cv_decref(cv) (fprintf(stderr,"%10d %6d %3d %s, line %d: cvdecref %dx%d\n", \ cv, cv_seq++, (cv)->refcnt-1, \ __FILE__, __LINE__, \ (cv)->pixrect.pr_size.x, \ (cv)->pixrect.pr_size.y), \ (--(cv)->refcnt==0 ? cv_destroy(cv) : 0)) #endif #endif #define retained_part parts[0] #define screen_part parts[1] struct pixrect *tile_create(); struct canvas *ovl_create(); struct canvas *cv_make_canvas(); struct canvas *cv_make_screen_canvas(); extern struct canvas *cv_damage_list; /* The list of damaged canvases */ #endif