diff options
Diffstat (limited to 'atari/plot/plot.c')
-rwxr-xr-x | atari/plot/plot.c | 103 |
1 files changed, 96 insertions, 7 deletions
diff --git a/atari/plot/plot.c b/atari/plot/plot.c index 80551f968..2c75db335 100755 --- a/atari/plot/plot.c +++ b/atari/plot/plot.c @@ -48,7 +48,8 @@ struct s_view { short vis_y; /* coords are relative to plot location */ short vis_w; /* clipped to screen dimensions */ short vis_h; /* visible width */ - struct rect clipping; /* clipping rectangle */ + struct rect abs_clipping; /* The toplevel clipping rectangle */ + struct rect clipping; /* actual clipping rectangle */ float scale; }; @@ -865,6 +866,7 @@ static void snapshot_suspend(void) } } +#ifdef WITH_8BPP_SUPPORT if(size_buf_std > CONV_KEEP_LIMIT ) { buf_std.fd_addr = realloc( buf_std.fd_addr, CONV_KEEP_LIMIT @@ -875,6 +877,7 @@ static void snapshot_suspend(void) size_buf_std = 0; } } +#endif if(buf_scr_compat != NULL ) { size_t bs = bitmap_buffer_size(buf_scr_compat ); @@ -994,6 +997,17 @@ inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg, #ifdef WITH_8BPP_SUPPORT +/** + * Convert an bitmap to an 8 bit device dependant MFDB + * \param img the bitmap (only tested with 32bit bitmaps) + * \param x screen coord of the background + * \param y screen coord of the background + * \param clip the region of the image that get's converted + * \param bg the background used for cheap transparency + * \param flags + * \param out receives the converted bitmap (still owned by the plot API) + * + */ static bool bitmap_convert_8(struct bitmap * img, int x, int y, GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out ) @@ -1110,7 +1124,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x, stdform.fd_r1 = stdform.fd_r2 = stdform.fd_r3 = 0; int img_stride = bitmap_get_rowstride(img); - uint32_t prev_pixel = 0x12345678; + uint32_t prev_pixel = 0x12345678; //TODO: check for collision in first pixel unsigned long col = 0; unsigned char val = 0; uint32_t * row; @@ -1866,10 +1880,18 @@ static bool plot_polygon(const int *p, unsigned int n, return ( true ); } +/*** + * Set plot origin and canvas size + * \param x the x origin + * \param y the y origin + * \param w the width of the plot area + * \param h the height of the plot area + */ bool plot_set_dimensions(int x, int y, int w, int h) { bool doupdate = false; struct rect newclip = {0, 0, w, h}; + GRECT absclip = {x, y, w, h}; if (!(w == view.w && h == view.h)) { struct rect newclip = { 0, 0, w-1, h-1 }; @@ -1887,13 +1909,18 @@ bool plot_set_dimensions(int x, int y, int w, int h) //dbg_rect("plot_set_dimensions", &newclip); + plot_set_abs_clipping(&absclip); plot_clip(&newclip); return(true); } +/*** + * Get current canvas size + * \param dst the GRECT * which receives the canvas size + * + */ bool plot_get_dimensions(GRECT *dst) { - dst->g_x = view.x; dst->g_y = view.y; dst->g_w = view.w; @@ -1901,19 +1928,79 @@ bool plot_get_dimensions(GRECT *dst) return(true); } -bool plot_set_scale(float scale) +/** + * set scale of plotter. + * \param scale the new scale value + * \return the old scale value + */ + +float plot_set_scale(float scale) { + float ret = view.scale; + view.scale = scale; + + return(ret); } -float plot_get_scale() +float plot_get_scale(void) { return(view.scale); } + +/** + * + * Subsequent calls to plot_clip will be clipped by the absolute clip. + * \param area the maximum clipping rectangle (absolute screen coords) + * +*/ +void plot_set_abs_clipping(const GRECT *area) +{ + GRECT canvas; + + plot_get_dimensions(&canvas); + + if(!rc_intersect(area, &canvas)){ + view.abs_clipping.x0 = 0; + view.abs_clipping.x1 = 0; + view.abs_clipping.y0 = 0; + view.abs_clipping.y1 = 0; + } + else { + view.abs_clipping.x0 = area->g_x; + view.abs_clipping.x1 = area->g_x + area->g_w; + view.abs_clipping.y0 = area->g_y; + view.abs_clipping.y1 = area->g_y + area->g_h; + } +} + + +/*** + * Get the maximum clip extent, in absolute screen coords + * \param dst the structure that receives the absolute clipping + */ +void plot_get_abs_clipping(struct rect *dst) +{ + *dst = view.abs_clipping; +} + + +/*** + * Get the maximum clip extent, in absolute screen coords + * \param dst the structure that receives the absolute clipping + */ +void plot_get_abs_clipping_grect(GRECT *dst) +{ + dst->g_x = view.abs_clipping.x0; + dst->g_w = view.abs_clipping.x1 - view.abs_clipping.x0; + dst->g_y = view.abs_clipping.y0; + dst->g_h = view.abs_clipping.y1 - view.abs_clipping.y0; +} + bool plot_clip(const struct rect *clip) { - GRECT canvas, screen, gclip, isection; + GRECT canvas, screen, gclip, maxclip; short pxy[4]; screen.g_x = 0; @@ -1946,7 +2033,9 @@ bool plot_clip(const struct rect *clip) //assert(1 == 0); } - //assert(rc_intersect(&screen, &gclip)); + // When setting VDI clipping, obey to maximum cliping rectangle: + plot_get_abs_clipping_grect(&maxclip); + rc_intersect(&maxclip, &gclip); //dbg_grect("canvas clipped to screen", &gclip); |