From 5acf36b89ecda31515de975be85197e0a4395db7 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sun, 6 Jan 2013 23:05:04 +0100 Subject: Clip only once, not on every drawing primitive... --- atari/plot/plot.c | 87 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 43 deletions(-) (limited to 'atari/plot') diff --git a/atari/plot/plot.c b/atari/plot/plot.c index 81c97c18b..9d1ba80fc 100755 --- a/atari/plot/plot.c +++ b/atari/plot/plot.c @@ -255,9 +255,9 @@ inline static void plot_get_visible_grect(GRECT * out) /* all values of the region are set to zero. */ inline static void update_visible_rect(void) { - GRECT screen; - GRECT common; - GRECT frame; + GRECT screen; // dimensions of the screen + GRECT frame; // dimensions of the drawing area + GRECT common; // dimensions of intersection of both screen.g_x = 0; screen.g_y = 0; @@ -269,14 +269,14 @@ inline static void update_visible_rect(void) common.g_w = frame.g_w = view.w; common.g_h = frame.g_h = view.h; - if( rc_intersect( &screen, &common ) ) { + if (rc_intersect(&screen, &common)) { view.vis_w = common.g_w; view.vis_h = common.g_h; - if( view.x < screen.g_x ) + if (view.x < screen.g_x) view.vis_x = frame.g_w - common.g_w; else view.vis_x = 0; - if( view.y stroke_colour); v_pline(atari_plot_vdi_handle, 2, (short *)&pxy ); - plot_vdi_clip(false); + //plot_vdi_clip(false); return (true); } @@ -1857,7 +1830,7 @@ static bool plot_polygon(const int *p, unsigned int n, short d[4]; if (vdi_sysinfo.maxpolycoords > 0) assert( (signed int)n < vdi_sysinfo.maxpolycoords); - plot_vdi_clip(true); + vsf_interior(atari_plot_vdi_handle, FIS_SOLID); vsf_style(atari_plot_vdi_handle, 1); for (i = 0; istroke_colour); v_pline(atari_plot_vdi_handle, n+1, (short *)&pxy); } - plot_vdi_clip(false); + return ( true ); } @@ -1912,12 +1885,41 @@ bool plot_get_dimensions(GRECT *dst) bool plot_clip(const struct rect *clip) { - // FIXME: consider the canvas size + GRECT canvas, screen, gclip, isection; + short pxy[4]; + + screen.g_x = 0; + screen.g_y = 0; + screen.g_w = vdi_sysinfo.scr_w; + screen.g_h = vdi_sysinfo.scr_h; + + plot_get_dimensions(&canvas); + view.clipping.x0 = clip->x0; view.clipping.y0 = clip->y0; view.clipping.x1 = clip->x1; view.clipping.y1 = clip->y1; + plot_get_clip_grect(&gclip); + + gclip.g_x += canvas.g_x; + gclip.g_y += canvas.g_y; + + rc_intersect(&canvas, &gclip); + + //dbg_grect("canvas clipped: ", &gclip); + + assert(rc_intersect(&screen, &gclip)); + + //dbg_grect("canvas clipped to screen", &gclip); + + pxy[0] = gclip.g_x; + pxy[1] = gclip.g_y; + pxy[2] = pxy[0] + gclip.g_w; + pxy[3] = pxy[1] + gclip.g_h; + + vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy); + return ( true ); } @@ -1949,7 +1951,6 @@ static bool plot_text(int x, int y, const char *text, size_t length, const plot_ static bool plot_disc(int x, int y, int radius, const plot_style_t *pstyle) { - plot_vdi_clip(true); if (pstyle->fill_type != PLOT_OP_TYPE_SOLID) { vsf_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); vsf_perimeter(atari_plot_vdi_handle, 1); @@ -1961,14 +1962,14 @@ static bool plot_disc(int x, int y, int radius, const plot_style_t *pstyle) vsf_interior(atari_plot_vdi_handle, FIS_SOLID); v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius); } - plot_vdi_clip(false); - return ( true ); + + return(true); } static bool plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *pstyle) { - //plot_vdi_clip(true); + vswr_mode(atari_plot_vdi_handle, MD_REPLACE ); if (pstyle->fill_type == PLOT_OP_TYPE_NONE) return(true); @@ -1983,7 +1984,7 @@ static bool plot_arc(int x, int y, int radius, int angle1, int angle2, vsf_perimeter(atari_plot_vdi_handle, 1); v_arc(atari_plot_vdi_handle, view.x + x, view.y + y, radius, angle1*10, angle2*10); } - //plot_vdi_clip(true); + return (true); } -- cgit v1.2.3