From: <hez...@us...> - 2009-05-21 19:43:00
|
Revision: 9982 http://plplot.svn.sourceforge.net/plplot/?rev=9982&view=rev Author: hezekiahcarty Date: 2009-05-16 22:19:42 +0000 (Sat, 16 May 2009) Log Message: ----------- Change xcairo window title when the driver is waiting for user input. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-05-16 22:10:07 UTC (rev 9981) +++ trunk/drivers/cairo.c 2009-05-16 22:19:42 UTC (rev 9982) @@ -1125,6 +1125,7 @@ void plD_dispatch_init_xcairo (PLDispatchTable *pdt); void plD_init_xcairo (PLStream *); +void plD_bop_xcairo (PLStream *); void plD_eop_xcairo (PLStream *); void plD_tidy_xcairo (PLStream *); void plD_esc_xcairo (PLStream *, PLINT, void *); @@ -1148,7 +1149,7 @@ pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; pdt->pl_eop = (plD_eop_fp) plD_eop_xcairo; - pdt->pl_bop = (plD_bop_fp) plD_bop_cairo; + pdt->pl_bop = (plD_bop_fp) plD_bop_xcairo; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_xcairo; pdt->pl_state = (plD_state_fp) plD_state_cairo; pdt->pl_esc = (plD_esc_fp) plD_esc_xcairo; @@ -1237,6 +1238,29 @@ } +/*---------------------------------------------------------------------- + plD_bop_xcairo() + + X Windows specific start of page. + ----------------------------------------------------------------------*/ + +void plD_bop_xcairo(PLStream *pls) +{ + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + + plD_bop_cairo(pls); + + if (aStream->xdrawable_mode) + return; + + /* Be sure the window title is set appropriately. */ + XStoreName(aStream->XDisplay, aStream->XWindow, "PLplot"); + + XFlush(aStream->XDisplay); +} + /*--------------------------------------------------------------------- plD_eop_xcairo() @@ -1263,6 +1287,8 @@ /* Only pause if nopause is unset. */ if (pls->nopause) aStream->exit_event_loop = 1; + else + XStoreName(aStream->XDisplay, aStream->XWindow, "PLplot - Press Enter or right-click to continue"); /* Loop, handling selected events, till the user elects to close the plot. */ event_mask = ButtonPressMask | KeyPressMask | ExposureMask; |
From: <hez...@us...> - 2009-05-21 19:56:04
|
Revision: 9981 http://plplot.svn.sourceforge.net/plplot/?rev=9981&view=rev Author: hezekiahcarty Date: 2009-05-16 22:10:07 +0000 (Sat, 16 May 2009) Log Message: ----------- The xcairo drive now allows the user to right-click in the plot window to move to the next plot page. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-05-15 17:34:38 UTC (rev 9980) +++ trunk/drivers/cairo.c 2009-05-16 22:10:07 UTC (rev 9981) @@ -1277,6 +1277,10 @@ aStream->exit_event_loop = 1; } break; + case ButtonPress: + if (((XButtonEvent *)&event)->button == Button3) + aStream->exit_event_loop = 1; + break; case Expose: plD_bop_cairo(pls); plRemakePlot(pls); |
From: <hba...@us...> - 2009-06-17 03:58:55
|
Revision: 10054 http://plplot.svn.sourceforge.net/plplot/?rev=10054&view=rev Author: hbabcock Date: 2009-06-17 03:58:54 +0000 (Wed, 17 Jun 2009) Log Message: ----------- Accidently also checked in Hez's arc additions to the cairo driver. This commit hopefully removes these additions. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-06-17 03:54:28 UTC (rev 10053) +++ trunk/drivers/cairo.c 2009-06-17 03:58:54 UTC (rev 10054) @@ -215,7 +215,6 @@ static void set_current_context(PLStream *); static void poly_line(PLStream *, short *, short *, PLINT); static void filled_polygon(PLStream *pls, short *xa, short *ya, PLINT npts); -static void arc(PLStream *, arc_struct *); static void rotate_cairo_surface(PLStream *, float, float, float, float, float, float); /* Rasterization of plotted material */ static void start_raster(PLStream*); @@ -487,9 +486,6 @@ case PLESC_END_RASTERIZE: /* End offscreen/rasterized rendering */ end_raster(pls); break; - case PLESC_ARC: /* Draw an arc, either filled or outline */ - arc(pls, (arc_struct *) ptr); - break; } } @@ -996,7 +992,6 @@ pls->alt_unicode = 1; /* Wants to handle unicode character by character */ pls->page = 0; pls->dev_fill0 = 1; /* Supports hardware solid fills */ - pls->dev_arc = 1; /* Supports driver-level arcs */ pls->plbuf_write = 1; /* Activate plot buffer */ @@ -1154,60 +1149,6 @@ } /*--------------------------------------------------------------------- - arc() - - Draws an arc, possibly filled. - ---------------------------------------------------------------------*/ - -void arc(PLStream *pls, arc_struct *arc_info) -{ - /* - TODO: - - Decide on a direction for increasing angles and make sure this Cairo - implementation matches the software/fallback implementation. - - Add clipping to viewport boundaries - */ - PLCairo *aStream; - double x, y, a, b; - double angle1, angle2; - double rotation; - - set_current_context(pls); - - aStream = (PLCairo *)pls->dev; - - /* Scale to the proper Cairo coordinates */ - x = aStream->downscale * arc_info->x; - y = aStream->downscale * arc_info->y; - a = aStream->downscale * arc_info->a; - b = aStream->downscale * arc_info->b; - - /* Degrees to radians */ - angle1 = arc_info->angle1 * M_PI / 180.0; - angle2 = arc_info->angle2 * M_PI / 180.0; - rotation = - arc_info->rotation * M_PI / 180.0; - - /* Make sure the arc is properly shaped */ - cairo_save(aStream->cairoContext); - cairo_translate(aStream->cairoContext, x, y); - cairo_rotate(aStream->cairoContext, rotation); - cairo_scale(aStream->cairoContext, a, b); - cairo_arc(aStream->cairoContext, 0.0, 0.0, 1.0, angle1, angle2); - cairo_restore(aStream->cairoContext); - cairo_set_source_rgba(aStream->cairoContext, - (double)pls->curcolor.r/255.0, - (double)pls->curcolor.g/255.0, - (double)pls->curcolor.b/255.0, - (double)pls->curcolor.a); - if (arc_info->fill) { - cairo_fill(aStream->cairoContext); - } - else { - cairo_stroke(aStream->cairoContext); - } -} - -/*--------------------------------------------------------------------- rotate_cairo_surface() Rotates the cairo surface to the appropriate orientation. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2009-07-18 23:13:14
|
Revision: 10159 http://plplot.svn.sourceforge.net/plplot/?rev=10159&view=rev Author: hbabcock Date: 2009-07-18 23:13:11 +0000 (Sat, 18 Jul 2009) Log Message: ----------- Fix text clipping so that it handles plots w/ arbitrary rotations Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-07-18 18:03:49 UTC (rev 10158) +++ trunk/drivers/cairo.c 2009-07-18 23:13:11 UTC (rev 10159) @@ -589,7 +589,7 @@ { int textXExtent, textYExtent; char *textWithPangoMarkup; - PLFLT rotation, shear, stride, cos_rot, sin_rot, cos_shear, sin_shear; + PLFLT rotation, shear, stride, cos_rot, sin_rot, cos_shear, sin_shear, diorot_rad; cairo_matrix_t *cairoTransformMatrix; cairo_font_options_t *cairoFontOptions; PangoContext *context; @@ -617,15 +617,25 @@ pango_layout_context_changed(layout); cairo_font_options_destroy(cairoFontOptions); - /* Save current transform matrix & clipping region */ - cairo_save(aStream->cairoContext); - /* Set up the clipping region if we are doing text clipping */ if(aStream->text_clipping){ + cairo_save(aStream->cairoContext); + diorot_rad = pls->diorot * 2.0/3.14159; + rotate_cairo_surface(pls, + cos(diorot_rad), + sin(diorot_rad), + -sin(diorot_rad), + cos(diorot_rad), + 0.5 * pls->xlength, + 0.5 * pls->ylength); cairo_rectangle(aStream->cairoContext, aStream->downscale * pls->clpxmi, aStream->downscale * pls->clpymi, aStream->downscale * (pls->clpxma - pls->clpxmi), aStream->downscale * (pls->clpyma - pls->clpymi)); cairo_clip(aStream->cairoContext); + cairo_restore(aStream->cairoContext); } + /* Save current transform matrix & clipping region */ + cairo_save(aStream->cairoContext); + /* Move to the string reference point */ cairo_move_to(aStream->cairoContext, aStream->downscale * (double) args->x, aStream->downscale * (double) args->y); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2009-07-19 01:59:09
|
Revision: 10161 http://plplot.svn.sourceforge.net/plplot/?rev=10161&view=rev Author: hbabcock Date: 2009-07-19 01:59:08 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Units are PI/2 not 2/PI. Also change to using the PLplot constant PI instead of 3.14159 Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-07-19 01:54:46 UTC (rev 10160) +++ trunk/drivers/cairo.c 2009-07-19 01:59:08 UTC (rev 10161) @@ -332,7 +332,7 @@ (double)pls->cmap0[0].r/255.0, (double)pls->cmap0[0].g/255.0, (double)pls->cmap0[0].b/255.0); - cairo_fill(aStream->cairoContext); + cairo_fill(aStream->cairoContext); } /*--------------------------------------------------------------------- @@ -620,7 +620,7 @@ /* Set up the clipping region if we are doing text clipping */ if(aStream->text_clipping){ cairo_save(aStream->cairoContext); - diorot_rad = pls->diorot * 2.0/3.14159; + diorot_rad = pls->diorot * PI/2.0; rotate_cairo_surface(pls, cos(diorot_rad), sin(diorot_rad), @@ -647,7 +647,7 @@ /* Extract rotation angle and shear from the PLplot tranformation matrix. Compute sines and cosines of the angles as an optimization. */ plRotationShear(args->xform, &rotation, &shear, &stride); - rotation -= pls->diorot * 3.14159 / 2.0; + rotation -= pls->diorot * PI / 2.0; cos_rot = cos(rotation); sin_rot = sin(rotation); cos_shear = cos(shear); @@ -754,7 +754,7 @@ /* Extract rotation angle and shear from the PLplot tranformation matrix. Compute sines and cosines of the angles as an optimization. */ plRotationShear(args->xform, &rotation, &shear, &stride); - rotation -= pls->diorot * 3.14159 / 2.0; + rotation -= pls->diorot * PI / 2.0; cos_rot = cos(rotation); sin_rot = sin(rotation); cos_shear = cos(shear); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2009-08-02 05:44:56
|
Revision: 10198 http://plplot.svn.sourceforge.net/plplot/?rev=10198&view=rev Author: hezekiahcarty Date: 2009-08-02 05:44:48 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Factor out clipping code to share between text and arc functions Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-08-02 05:29:20 UTC (rev 10197) +++ trunk/drivers/cairo.c 2009-08-02 05:44:48 UTC (rev 10198) @@ -198,6 +198,7 @@ PLCairo *stream_and_font_setup(PLStream *, int); cairo_status_t write_to_stream(void *, unsigned char *, unsigned int); +void set_clip(PLStream *pls); /* String processing */ @@ -601,7 +602,6 @@ PangoLayout *layout; PangoFontDescription *fontDescription; PLCairo *aStream; - PLINT rcx[4], rcy[4]; aStream = (PLCairo *)pls->dev; @@ -628,30 +628,7 @@ /* Set up the clipping region if we are doing text clipping */ if(aStream->text_clipping){ - - /* Use PLplot core routine to get the corners of the clipping rectangle */ - difilt_clip(rcx, rcy); - - /* Layout the bounds of the clipping region */ - /* Should we convert PLINT to short and use the polyline routine? */ - cairo_move_to(aStream->cairoContext, - aStream->downscale * (double) rcx[0], - aStream->downscale * (double) rcy[0]); - cairo_line_to(aStream->cairoContext, - aStream->downscale * (double) rcx[1], - aStream->downscale * (double) rcy[1]); - cairo_line_to(aStream->cairoContext, - aStream->downscale * (double) rcx[2], - aStream->downscale * (double) rcy[2]); - cairo_line_to(aStream->cairoContext, - aStream->downscale * (double) rcx[3], - aStream->downscale * (double) rcy[3]); - cairo_line_to(aStream->cairoContext, - aStream->downscale * (double) rcx[0], - aStream->downscale * (double) rcy[0]); - - /* Set the clipping region */ - cairo_clip(aStream->cairoContext); + set_clip(pls); } /* Move to the string reference point */ @@ -757,8 +734,7 @@ /* Set up the clipping region if we are doing text clipping */ if(aStream->text_clipping){ - cairo_rectangle(aStream->cairoContext, aStream->downscale * pls->clpxmi, aStream->downscale * pls->clpymi, aStream->downscale * (pls->clpxma - pls->clpxmi), aStream->downscale * (pls->clpyma - pls->clpymi)); - cairo_clip(aStream->cairoContext); + set_clip(pls); } /* Move to the string reference point */ @@ -1178,6 +1154,49 @@ } /*--------------------------------------------------------------------- + set_clip() + + Set the clipping region to the plot window. + NOTE: cairo_save() and cairo_restore() should probably be called before + and after this, respectively. + ---------------------------------------------------------------------*/ + +void set_clip(PLStream *pls) +{ + PLINT rcx[4], rcy[4]; + PLCairo *aStream; + aStream = (PLCairo *)pls->dev; + + /* Use PLplot core routine to get the corners of the clipping rectangle */ + difilt_clip(rcx, rcy); + + /* Layout the bounds of the clipping region */ + /* Should we convert PLINT to short and use the polyline routine? */ + cairo_move_to(aStream->cairoContext, + aStream->downscale * (double) rcx[0], + aStream->downscale * (double) rcy[0]); + cairo_line_to(aStream->cairoContext, + aStream->downscale * (double) rcx[1], + aStream->downscale * (double) rcy[1]); + cairo_line_to(aStream->cairoContext, + aStream->downscale * (double) rcx[2], + aStream->downscale * (double) rcy[2]); + cairo_line_to(aStream->cairoContext, + aStream->downscale * (double) rcx[3], + aStream->downscale * (double) rcy[3]); + cairo_line_to(aStream->cairoContext, + aStream->downscale * (double) rcx[0], + aStream->downscale * (double) rcy[0]); + + /* Set the clipping region */ + cairo_clip(aStream->cairoContext); + + /* Apparently, in some older Cairo versions, cairo_clip does not consume + the current path. */ + cairo_new_path(aStream->cairoContext); +} + +/*--------------------------------------------------------------------- arc() Draws an arc, possibly filled. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2009-08-18 03:24:59
|
Revision: 10273 http://plplot.svn.sourceforge.net/plplot/?rev=10273&view=rev Author: hbabcock Date: 2009-08-18 03:24:51 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Changed the cairo drive to use 'span' and 'rise' instead of 'sub' and 'sup' so that it will correctly handle multiple level super and subscripts. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-08-17 19:07:32 UTC (rev 10272) +++ trunk/drivers/cairo.c 2009-08-18 03:24:51 UTC (rev 10273) @@ -211,6 +211,7 @@ static char *ucs4_to_pango_markup_format(PLUNICODE *, int, float); static void open_span_tag(char *, PLUNICODE, float, int); static void close_span_tag(char *, int); +static char *rise_span_tag(int, int); /* Graphics */ @@ -569,17 +570,17 @@ break; case PLTEXT_SUPERSCRIPT: if(aStream->upDown < 0){ - strncat(aStream->pangoMarkupString, "</sub>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + strncat(aStream->pangoMarkupString, "</span>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); } else { - strncat(aStream->pangoMarkupString, "<sup>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + strncat(aStream->pangoMarkupString, rise_span_tag(aStream->upDown, 1), MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); } aStream->upDown++; break; case PLTEXT_SUBSCRIPT: if(aStream->upDown > 0){ - strncat(aStream->pangoMarkupString, "</sup>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + strncat(aStream->pangoMarkupString, "</span>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); } else { - strncat(aStream->pangoMarkupString, "<sub>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + strncat(aStream->pangoMarkupString, rise_span_tag(aStream->upDown, -1), MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); } aStream->upDown--; break; @@ -851,17 +852,17 @@ else { if(ucs4[i] == (PLUNICODE)'u'){ /* Superscript */ if(upDown < 0){ - strncat(pangoMarkupString, "</sub>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); + strncat(pangoMarkupString, "</span>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); } else { - strncat(pangoMarkupString, "<sup>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); + strncat(pangoMarkupString, rise_span_tag(upDown, 1), MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); } upDown++; } if(ucs4[i] == (PLUNICODE)'d'){ /* Subscript */ if(upDown > 0){ - strncat(pangoMarkupString, "</sup>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); + strncat(pangoMarkupString, "</span>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); } else { - strncat(pangoMarkupString, "<sub>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); + strncat(pangoMarkupString, rise_span_tag(upDown, -1), MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); } upDown--; } @@ -915,13 +916,13 @@ /* Move to the right sub/super-script level */ if(upDown > 0){ while(upDown > 0){ - strncat(pangoMarkupString, "<sup>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); + strncat(pangoMarkupString, rise_span_tag(upDown, 1), MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); upDown--; } } if(upDown < 0){ while(upDown < 0){ - strncat(pangoMarkupString, "<sub>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); + strncat(pangoMarkupString, rise_span_tag(upDown, -1), MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); upDown++; } } @@ -937,13 +938,13 @@ { if(upDown > 0){ while(upDown > 0){ - strncat(pangoMarkupString, "</sup>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); + strncat(pangoMarkupString, "</span>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); upDown--; } } if(upDown < 0){ while(upDown < 0){ - strncat(pangoMarkupString, "</sub>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); + strncat(pangoMarkupString, "</span>", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); upDown++; } } @@ -952,6 +953,35 @@ } /*--------------------------------------------------------------------- + rise_span_tag + + Create a rise span tag w/ appropriate font size & baseline offset + ---------------------------------------------------------------------*/ + +#define STEPSIZE 7500.0 + +char *rise_span_tag(int level, int direction) +{ + int i; + float multiplier = 1.0; + float rise = STEPSIZE; + static char tag[100]; + + for(i=0;i<abs(level);i++){ + multiplier = multiplier * 0.9; + rise += STEPSIZE * multiplier; + } + if(direction>0){ + sprintf(tag, "<span rise=\"%d\" size=\"smaller\">", (int)rise); + } + else{ + sprintf(tag, "<span rise=\"%d\" size=\"smaller\">", (int)-rise); + } + + return(tag); +} + +/*--------------------------------------------------------------------- write_to_stream() Writes data to a open file stream. This function is passed to the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2009-08-24 00:27:34
|
Revision: 10317 http://plplot.svn.sourceforge.net/plplot/?rev=10317&view=rev Author: hbabcock Date: 2009-08-24 00:27:25 +0000 (Mon, 24 Aug 2009) Log Message: ----------- Fixed cairo driver so that it properly super/subscripts through a font change. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-08-23 00:22:26 UTC (rev 10316) +++ trunk/drivers/cairo.c 2009-08-24 00:27:25 UTC (rev 10317) @@ -916,14 +916,14 @@ /* Move to the right sub/super-script level */ if(upDown > 0){ while(upDown > 0){ + upDown--; strncat(pangoMarkupString, rise_span_tag(upDown, 1), MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); - upDown--; } } if(upDown < 0){ while(upDown < 0){ + upDown++; strncat(pangoMarkupString, rise_span_tag(upDown, -1), MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); - upDown++; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2009-08-25 17:05:28
|
Revision: 10329 http://plplot.svn.sourceforge.net/plplot/?rev=10329&view=rev Author: hezekiahcarty Date: 2009-08-25 17:05:16 +0000 (Tue, 25 Aug 2009) Log Message: ----------- Off-screen rendering for xcairo. This provides a large speed increase. A possibly negative side effect of this patch is that the plot is not displayed in the plot window until either plflush is called or we reach the end of the page. A positive side effect of this patch is that xcairo no longer flickers repeatedly due to replots on expose events (when the window has to be redrawn). Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-08-25 14:36:42 UTC (rev 10328) +++ trunk/drivers/cairo.c 2009-08-25 17:05:16 UTC (rev 10329) @@ -96,6 +96,8 @@ short upDown; float fontSize; #if defined(PLD_xcairo) + cairo_surface_t *cairoSurface_X; + cairo_t *cairoContext_X; short exit_event_loop; Display *XDisplay; Window XWindow; @@ -1405,7 +1407,11 @@ /* Create an cairo surface & context that are associated with the X window. */ defaultVisual = DefaultVisual(aStream->XDisplay, 0); /* Dimension units are pixels from cairo documentation. */ - aStream->cairoSurface = cairo_xlib_surface_create(aStream->XDisplay, aStream->XWindow, defaultVisual, pls->xlength, pls->ylength); + /* This is the X window Cairo surface. */ + aStream->cairoSurface_X = cairo_xlib_surface_create(aStream->XDisplay, aStream->XWindow, defaultVisual, pls->xlength, pls->ylength); + aStream->cairoContext_X = cairo_create(aStream->cairoSurface_X); + /* This is the Cairo surface PLplot will actually plot to. */ + aStream->cairoSurface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, pls->xlength, pls->ylength); aStream->cairoContext = cairo_create(aStream->cairoSurface); /* Invert the surface so that the graphs are drawn right side up. */ @@ -1466,6 +1472,18 @@ } +/*--------------------------------------------------------------------- + blit_to_x() + + Blit the offscreen image to the X window. + ---------------------------------------------------------------------*/ + +void blit_to_x(PLCairo *aStream) +{ + cairo_set_source_surface(aStream->cairoContext_X, aStream->cairoSurface, 0.0, 0.0); + cairo_paint(aStream->cairoContext_X); +} + /*---------------------------------------------------------------------- plD_bop_xcairo() @@ -1510,6 +1528,9 @@ if (aStream->xdrawable_mode) return; + /* Blit the offscreen image to the X window. */ + blit_to_x(aStream); + XFlush(aStream->XDisplay); /* Only pause if nopause is unset. */ @@ -1536,8 +1557,8 @@ aStream->exit_event_loop = 1; break; case Expose: - plD_bop_cairo(pls); - plRemakePlot(pls); + /* Blit the image again after an expose event. */ + blit_to_x(aStream); XFlush(aStream->XDisplay); break; } @@ -1560,6 +1581,10 @@ plD_tidy_cairo(pls); + /* Also free up the Cairo X surface and context */ + cairo_destroy(aStream->cairoContext_X); + cairo_surface_destroy(aStream->cairoSurface_X); + if (aStream->xdrawable_mode) return; @@ -1586,6 +1611,7 @@ switch(op) { case PLESC_FLUSH: /* forced update of the window */ + blit_to_x(aStream); XFlush(aStream->XDisplay); break; case PLESC_GETC: /* get cursor position */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2009-08-26 15:11:39
|
Revision: 10344 http://plplot.svn.sourceforge.net/plplot/?rev=10344&view=rev Author: hbabcock Date: 2009-08-26 15:11:20 +0000 (Wed, 26 Aug 2009) Log Message: ----------- Apply patch provided by Mark de Wever that fixes some issues with misplaced parentheses in the cairo driver. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-08-26 02:26:31 UTC (rev 10343) +++ trunk/drivers/cairo.c 2009-08-26 15:11:20 UTC (rev 10344) @@ -540,7 +540,7 @@ strncat(aStream->pangoMarkupString, "&", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); break; case 60: - strncat(aStream->pangoMarkupString, "<", MAX_MARKUP_LEN)-1-strlen(aStream->pangoMarkupString); + strncat(aStream->pangoMarkupString, "<", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); break; case 62: strncat(aStream->pangoMarkupString, ">", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); @@ -831,7 +831,7 @@ strncat(pangoMarkupString, "&", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); break; case 60: - strncat(pangoMarkupString, "<", MAX_MARKUP_LEN)-1-strlen(pangoMarkupString); + strncat(pangoMarkupString, "<", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); break; case 62: strncat(pangoMarkupString, ">", MAX_MARKUP_LEN-1-strlen(pangoMarkupString)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2009-10-05 21:06:27
|
Revision: 10513 http://plplot.svn.sourceforge.net/plplot/?rev=10513&view=rev Author: hezekiahcarty Date: 2009-10-05 21:06:17 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Only update xcairo window on the last expose event If several expose events occur quickly, it would previous trigger the same number of plot window redraws. This update speeds things up a bit in this case by ignoring all but the last expose event. The can help the window feel a bit more responsive. The downside is that quickly moving the plot window partly off then back on screen with a non-compositing window manager can highlight these less frequent updates. A better fix would be to only update the portion of the window which has been affected by the expose event. This should keep the window feeling responsive and avoid any artifacts from repeat expose events. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-10-04 17:03:08 UTC (rev 10512) +++ trunk/drivers/cairo.c 2009-10-05 21:06:17 UTC (rev 10513) @@ -1551,9 +1551,12 @@ aStream->exit_event_loop = 1; break; case Expose: - /* Blit the image again after an expose event. */ - blit_to_x(aStream); - XFlush(aStream->XDisplay); + /* Blit the image again after an expose event, but only for the last + available event. Otherwise multiple redraws occur needlessly. */ + if (((XExposeEvent *)&event)->count == 0) { + blit_to_x(aStream); + XFlush(aStream->XDisplay); + } break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-11-14 21:17:21
|
Revision: 10589 http://plplot.svn.sourceforge.net/plplot/?rev=10589&view=rev Author: airwin Date: 2009-11-14 21:17:15 +0000 (Sat, 14 Nov 2009) Log Message: ----------- Set plbuf_write = 1 only for xcairo device. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-11-14 20:40:45 UTC (rev 10588) +++ trunk/drivers/cairo.c 2009-11-14 21:17:15 UTC (rev 10589) @@ -1071,7 +1071,7 @@ pls->page = 0; pls->dev_fill0 = 1; /* Supports hardware solid fills */ pls->dev_arc = 1; /* Supports driver-level arcs */ - pls->plbuf_write = 1; /* Activate plot buffer */ + pls->plbuf_write = interactive; /* Activate plot buffer */ if ( pls->xlength <= 0 || pls->ylength <= 0 ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2010-01-26 01:09:42
|
Revision: 10769 http://plplot.svn.sourceforge.net/plplot/?rev=10769&view=rev Author: hbabcock Date: 2010-01-26 01:09:36 +0000 (Tue, 26 Jan 2010) Log Message: ----------- Update device numbers to reflect recent changes in the device numbering. Change device type for extcairo and wincairo from file to interactive. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-01-25 21:20:11 UTC (rev 10768) +++ trunk/drivers/cairo.c 2010-01-26 01:09:36 UTC (rev 10769) @@ -1494,7 +1494,7 @@ pdt->pl_DevName = "xcairo"; #endif pdt->pl_type = plDevType_Interactive; - pdt->pl_seq = 59; + pdt->pl_seq = 100; pdt->pl_init = (plD_init_fp) plD_init_xcairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; @@ -1878,7 +1878,7 @@ pdt->pl_DevName = "pdfcairo"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 60; + pdt->pl_seq = 101; pdt->pl_init = (plD_init_fp) plD_init_pdfcairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; @@ -1950,7 +1950,7 @@ pdt->pl_DevName = "pscairo"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 61; + pdt->pl_seq = 102; pdt->pl_init = (plD_init_fp) plD_init_pscairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; @@ -2025,7 +2025,7 @@ pdt->pl_DevName = "svgcairo"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 62; + pdt->pl_seq = 103; pdt->pl_init = (plD_init_fp) plD_init_svgcairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; @@ -2119,7 +2119,7 @@ pdt->pl_DevName = "pngcairo"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 63; + pdt->pl_seq = 104; pdt->pl_init = (plD_init_fp) plD_init_pngcairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; @@ -2228,7 +2228,7 @@ pdt->pl_DevName = "memcairo"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 64; + pdt->pl_seq = 105; pdt->pl_init = (plD_init_fp) plD_init_memcairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; @@ -2455,8 +2455,8 @@ pdt->pl_MenuStr = "Cairo external context driver"; pdt->pl_DevName = "extcairo"; #endif - pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 65; + pdt->pl_type = plDevType_Interactive; + pdt->pl_seq = 106; pdt->pl_init = (plD_init_fp) plD_init_extcairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; @@ -2685,8 +2685,8 @@ pdt->pl_MenuStr = "Cairo Microsoft Windows driver"; pdt->pl_DevName = "wincairo"; #endif - pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 65; + pdt->pl_type = plDevType_Interactive; + pdt->pl_seq = 107; pdt->pl_init = (plD_init_fp) plD_init_wincairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2010-02-01 03:51:31
|
Revision: 10791 http://plplot.svn.sourceforge.net/plplot/?rev=10791&view=rev Author: hbabcock Date: 2010-02-01 03:51:24 +0000 (Mon, 01 Feb 2010) Log Message: ----------- Improvements to the wincairo driver: (1) Handle redraw events. (2) Handle window resizing. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-01-31 23:59:04 UTC (rev 10790) +++ trunk/drivers/cairo.c 2010-02-01 03:51:24 UTC (rev 10791) @@ -116,11 +116,15 @@ char bigendian; #endif #if defined ( PLD_wincairo ) + cairo_surface_t *cairoSurface_win; + cairo_t *cairoContext_win; WNDCLASSEX wndclass; HWND hwnd; MSG msg; HDC hdc; HDC SCRN_hdc; + COLORREF oldcolour; + RECT rect; #endif } PLCairo; @@ -2586,9 +2590,21 @@ void plD_init_wincairo( PLStream * ); //void plD_bop_extcairo( PLStream * ); void plD_eop_wincairo( PLStream * ); -//void plD_esc_extcairo( PLStream *, PLINT, void * ); +void plD_esc_extcairo( PLStream *, PLINT, void * ); void plD_tidy_wincairo( PLStream * ); +/*--------------------------------------------------------------------- + * blit_to_win() + * + * Blit the offscreen image to the Windows window. + * ---------------------------------------------------------------------*/ + +void blit_to_win( PLCairo *aStream ) +{ + cairo_set_source_surface( aStream->cairoContext_win, aStream->cairoSurface, 0.0, 0.0 ); + cairo_paint( aStream->cairoContext_win ); +} + /*--------------------------------------------------------------------------*\ * This is the window function for the plot window. Whenever a message is * dispatched using DispatchMessage (or sent with SendMessage) this function @@ -2604,7 +2620,7 @@ * The window carries a 32bit user defined pointer which points to the * plplot stream (pls). This is used for tracking the window. * Unfortunately, this is "attached" to the window AFTER it is created - * so we can not initialise PLStream or wingcc_Dev "blindly" because + * so we can not initialise PLStream or wincairo "blindly" because * they may not yet have been initialised. * WM_CREATE is called before we get to initialise those variables, so * we wont try to set them. @@ -2643,10 +2659,12 @@ break; case WM_PAINT: + blit_to_win( dev ); return ( 1 ); break; case WM_SIZE: + GetClientRect( dev->hwnd, &dev->rect ); return ( 0 ); break; @@ -2659,7 +2677,13 @@ break; case WM_ERASEBKGND: - return ( 0 ); + if ( dev ) + { + dev->oldcolour = SetBkColor( dev->hdc, RGB( pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b ) ); + ExtTextOut( dev->hdc, 0, 0, ETO_OPAQUE, &dev->rect, "", 0, 0 ); + SetBkColor( dev->hdc, dev->oldcolour ); + } + return ( 1 ); break; case WM_COMMAND: @@ -2813,7 +2837,12 @@ * Initialize Cairo Surface using the windows hdc. */ - aStream->cairoSurface = (cairo_surface_t *) cairo_win32_surface_create( aStream->hdc ); + /* This is the Win32 Cairo surface. */ + aStream->cairoSurface_win = (cairo_surface_t *) cairo_win32_surface_create( aStream->hdc ); + aStream->cairoContext_win = cairo_create( aStream->cairoSurface_win ); + + /* This is the Cairo surface PLplot will actually plot to. */ + aStream->cairoSurface = cairo_image_surface_create( CAIRO_FORMAT_RGB24, pls->xlength, pls->ylength ); aStream->cairoContext = cairo_create( aStream->cairoSurface ); /* Invert the surface so that the graphs are drawn right side up. */ @@ -2868,6 +2897,12 @@ { PLCairo *aStream = (PLCairo *) pls->dev; + plD_tidy_cairo( pls ); + + /* Also free up the Cairo win32 surface and context */ + cairo_destroy( aStream->cairoContext_win ); + cairo_surface_destroy( aStream->cairoSurface_win ); + if ( aStream != NULL ) { if ( aStream->hdc != NULL ) ReleaseDC( aStream->hwnd, aStream->hdc ); @@ -2875,4 +2910,29 @@ } } +/*--------------------------------------------------------------------- + * plD_esc_wincairo() + * + * Escape function, specialized for the wincairo driver + * ---------------------------------------------------------------------*/ + +void plD_esc_wincairo( PLStream *pls, PLINT op, void *ptr ) +{ + PLCairo *aStream; + + aStream = (PLCairo *) pls->dev; + + switch ( op ) + { + case PLESC_FLUSH: + InvalidateRect( aStream->hwnd, NULL, TRUE); + break; + case PLESC_GETC: + break; + default: + plD_esc_cairo( pls, op, ptr ); + break; + } +} + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2010-02-01 15:59:52
|
Revision: 10792 http://plplot.svn.sourceforge.net/plplot/?rev=10792&view=rev Author: hbabcock Date: 2010-02-01 15:59:44 +0000 (Mon, 01 Feb 2010) Log Message: ----------- Apply patch from Mark de Wever. Style previous changes. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-02-01 03:51:24 UTC (rev 10791) +++ trunk/drivers/cairo.c 2010-02-01 15:59:44 UTC (rev 10792) @@ -957,7 +957,9 @@ plP_fci2hex( fci, &fontFamily, PL_FCI_FAMILY ); plP_fci2hex( fci, &fontStyle, PL_FCI_STYLE ); plP_fci2hex( fci, &fontWeight, PL_FCI_WEIGHT ); - snprintf( openTag, TAG_LEN, "<span font_desc=\"%s %.2f\" ", familyLookup[fontFamily], fontSize ); + /* From http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html + * size = font size in 1024ths of a point. */ + snprintf( openTag, TAG_LEN, "<span font_desc=\"%s\" size=\"%d\" ", familyLookup[fontFamily], (int)( fontSize * 1024. ) ); strncat( pangoMarkupString, openTag, MAX_MARKUP_LEN - 1 - strlen( pangoMarkupString ) ); snprintf( openTag, TAG_LEN, "style=\"%s\" ", styleLookup[fontStyle] ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2010-02-17 21:41:09
|
Revision: 10804 http://plplot.svn.sourceforge.net/plplot/?rev=10804&view=rev Author: airwin Date: 2010-02-17 21:41:03 +0000 (Wed, 17 Feb 2010) Log Message: ----------- Style recent cairo changes. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-02-17 07:49:20 UTC (rev 10803) +++ trunk/drivers/cairo.c 2010-02-17 21:41:03 UTC (rev 10804) @@ -959,7 +959,7 @@ plP_fci2hex( fci, &fontWeight, PL_FCI_WEIGHT ); /* From http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html * size = font size in 1024ths of a point. */ - snprintf( openTag, TAG_LEN, "<span font_desc=\"%s\" size=\"%d\" ", familyLookup[fontFamily], (int)( fontSize * 1024. ) ); + snprintf( openTag, TAG_LEN, "<span font_desc=\"%s\" size=\"%d\" ", familyLookup[fontFamily], (int) ( fontSize * 1024. ) ); strncat( pangoMarkupString, openTag, MAX_MARKUP_LEN - 1 - strlen( pangoMarkupString ) ); snprintf( openTag, TAG_LEN, "style=\"%s\" ", styleLookup[fontStyle] ); @@ -2681,9 +2681,9 @@ case WM_ERASEBKGND: if ( dev ) { - dev->oldcolour = SetBkColor( dev->hdc, RGB( pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b ) ); - ExtTextOut( dev->hdc, 0, 0, ETO_OPAQUE, &dev->rect, "", 0, 0 ); - SetBkColor( dev->hdc, dev->oldcolour ); + dev->oldcolour = SetBkColor( dev->hdc, RGB( pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b ) ); + ExtTextOut( dev->hdc, 0, 0, ETO_OPAQUE, &dev->rect, "", 0, 0 ); + SetBkColor( dev->hdc, dev->oldcolour ); } return ( 1 ); break; @@ -2927,7 +2927,7 @@ switch ( op ) { case PLESC_FLUSH: - InvalidateRect( aStream->hwnd, NULL, TRUE); + InvalidateRect( aStream->hwnd, NULL, TRUE ); break; case PLESC_GETC: break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2010-03-13 17:28:20
|
Revision: 10861 http://plplot.svn.sourceforge.net/plplot/?rev=10861&view=rev Author: hezekiahcarty Date: 2010-03-13 17:28:14 +0000 (Sat, 13 Mar 2010) Log Message: ----------- Re-use the poly_line function to avoid code duplication Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-13 17:27:27 UTC (rev 10860) +++ trunk/drivers/cairo.c 2010-03-13 17:28:14 UTC (rev 10861) @@ -426,6 +426,7 @@ set_line_properties( aStream, CAIRO_LINE_JOIN_BEVEL, CAIRO_LINE_CAP_BUTT ); poly_line( pls, xa, ya, npts ); + cairo_stroke( aStream->cairoContext ); set_line_properties( aStream, old_join, old_cap ); @@ -1242,9 +1243,8 @@ set_line_properties( aStream, CAIRO_LINE_JOIN_BEVEL, CAIRO_LINE_CAP_BUTT ); /* Draw the polygons */ - cairo_move_to( aStream->cairoContext, aStream->downscale * (double) xa[0], aStream->downscale * (double) ya[0] ); - for ( i = 1; i < npts; i++ ) - cairo_line_to( aStream->cairoContext, aStream->downscale * (double) xa[i], aStream->downscale * (double) ya[i] ); + poly_line( pls, xa, ya, npts ); + cairo_set_source_rgba( aStream->cairoContext, (double) pls->curcolor.r / 255.0, (double) pls->curcolor.g / 255.0, @@ -1301,10 +1301,8 @@ } /* Draw the polygon using the gradient. */ + poly_line( pls, xa, ya, npts ); - cairo_move_to( aStream->cairoContext, aStream->downscale * (double) xa[0], aStream->downscale * (double) ya[0] ); - for ( i = 1; i < npts; i++ ) - cairo_line_to( aStream->cairoContext, aStream->downscale * (double) xa[i], aStream->downscale * (double) ya[i] ); cairo_set_source( aStream->cairoContext, linear_gradient ); cairo_fill( aStream->cairoContext ); cairo_pattern_destroy( linear_gradient ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2010-03-13 17:30:31
|
Revision: 10862 http://plplot.svn.sourceforge.net/plplot/?rev=10862&view=rev Author: hezekiahcarty Date: 2010-03-13 17:30:24 +0000 (Sat, 13 Mar 2010) Log Message: ----------- Add dirty rectangle support to xcairo off-screen rendering This provides a large speedup for example 17 running with the xcairo driver. It also addresses a problem pointed out by AWI when using xcairo over a network. This also causes a small but noticable slowdown for example 20. I will look in to how to alleviate this. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-13 17:28:14 UTC (rev 10861) +++ trunk/drivers/cairo.c 2010-03-13 17:30:24 UTC (rev 10862) @@ -3,6 +3,7 @@ * Graphics drivers that are based on the Cairo / Pango Libraries. * * Copyright (C) 2008 Hazen Babcock + * Copyright (C) 2009, 2010 Hezekiah M. Carty * * This file is part of PLplot. * @@ -72,6 +73,10 @@ #define MAX_STRING_LEN 500 #define MAX_MARKUP_LEN MAX_STRING_LEN * 10 +/* Values to reset the dirty rectangle regions */ +#define DIRTY_MIN (1.0e50) +#define DIRTY_MAX (-1.0e50) + static int text_clipping; static int text_anti_aliasing; static int graphics_anti_aliasing; @@ -102,6 +107,11 @@ char *pangoMarkupString; short upDown; float fontSize; + /* Keep track of the bounding box of the modified portion of the surface */ + double dirty_x1; + double dirty_y1; + double dirty_x2; + double dirty_y2; #if defined ( PLD_xcairo ) cairo_surface_t *cairoSurface_X; cairo_t *cairoContext_X; @@ -280,7 +290,13 @@ /* Create an image surface and context for the offscreen rendering */ aStream->cairoSurface_raster = - cairo_image_surface_create( CAIRO_FORMAT_ARGB32, pls->xlength, pls->ylength ); + /* + cairo_surface_create_similar( aStream->cairoSurface, + CAIRO_CONTENT_COLOR, + pls->xlength, pls->ylength ); + */ + cairo_image_surface_create( CAIRO_FORMAT_ARGB32, + pls->xlength, pls->ylength ); aStream->cairoContext_raster = cairo_create( aStream->cairoSurface_raster ); /* Disable antialiasing for the raster surface. The output seems to look @@ -312,6 +328,9 @@ aStream = (PLCairo *) pls->dev; + /* TODO FIXME: This should really only copy the used portion of the + * offscreen pixmap. */ + /* Do not use the external surface if the user says not to */ if ( !aStream->rasterize_image ) return; @@ -388,6 +407,33 @@ cairo_set_line_cap( aStream->cairoContext, cap ); } +/* Call this after rendering paths have been defined and before they have + * been cleared. It will update the dirty rectangle information for the + * current stream for the new flush/end of page. */ + +void update_dirty_rectangle( PLCairo *aStream ) +{ + double x1, y1, x2, y2; + cairo_stroke_extents( aStream->cairoContext, &x1, &y1, &x2, &y2 ); + + /* Expand the rectangle slightly to account for thick lines and other + * effects which may extend beyond the defined Cairo path. */ + aStream->dirty_x1 = MAX( 0.0, MIN( x1 * 0.9, aStream->dirty_x1 ) ); + aStream->dirty_y1 = MAX( 0.0, MIN( y1 * 0.9, aStream->dirty_y1 ) ); + aStream->dirty_x2 = MAX( x2 * 1.1, aStream->dirty_x2 ); + aStream->dirty_y2 = MAX( y2 * 1.1, aStream->dirty_y2 ); +} + +/* Reset the dirty triangle extents */ + +void reset_dirty_rectangle( PLCairo *aStream ) +{ + aStream->dirty_x1 = DIRTY_MIN; + aStream->dirty_y1 = DIRTY_MIN; + aStream->dirty_x2 = DIRTY_MAX; + aStream->dirty_y2 = DIRTY_MAX; +} + void plD_line_cairo( PLStream *pls, short x1a, short y1a, short x2a, short y2a ) { PLCairo *aStream; @@ -403,6 +449,9 @@ cairo_move_to( aStream->cairoContext, aStream->downscale * (double) x1a, aStream->downscale * (double) y1a ); cairo_line_to( aStream->cairoContext, aStream->downscale * (double) x2a, aStream->downscale * (double) y2a ); + + update_dirty_rectangle( aStream ); + cairo_stroke( aStream->cairoContext ); set_line_properties( aStream, old_join, old_cap ); @@ -549,6 +598,13 @@ aStream->pangoMarkupString[i] = 0; } open_span_tag( aStream->pangoMarkupString, args->n_fci, aStream->fontSize, 0 ); + + /* TODO FIXME: Set the entire plot surface as dirty until the logic + * is added to properly calculate the actual text extents. */ + aStream->dirty_x1 = 0.0; + aStream->dirty_y1 = 0.0; + aStream->dirty_x2 = pls->xlength; + aStream->dirty_y2 = pls->ylength; } /*--------------------------------------------------------------------- @@ -1141,6 +1197,8 @@ aStream->cairoContext = NULL; aStream->downscale = downscale; + reset_dirty_rectangle( aStream ); + /* Set text clipping on by default since it makes little difference in * speed for a modern cairo stack.*/ aStream->text_clipping = 1; @@ -1218,6 +1276,8 @@ { cairo_line_to( aStream->cairoContext, aStream->downscale * (double) xa[i], aStream->downscale * (double) ya[i] ); } + + update_dirty_rectangle( aStream ); } /*--------------------------------------------------------------------- @@ -1391,6 +1451,8 @@ cairo_line_to( aStream->cairoContext, 0.0, 0.0 ); cairo_restore( aStream->cairoContext ); + update_dirty_rectangle( aStream ); + cairo_set_source_rgba( aStream->cairoContext, (double) pls->curcolor.r / 255.0, (double) pls->curcolor.g / 255.0, @@ -1422,7 +1484,11 @@ matrix = (cairo_matrix_t *) malloc( sizeof ( cairo_matrix_t ) ); cairo_matrix_init( matrix, x11, x12, x21, x22, x0, y0 ); +#if defined ( PLD_xcairo ) + cairo_transform( aStream->cairoContext_X, matrix ); +#else cairo_transform( aStream->cairoContext, matrix ); +#endif free( matrix ); } @@ -1535,7 +1601,14 @@ aStream->cairoSurface_X = cairo_xlib_surface_create( aStream->XDisplay, aStream->XWindow, defaultVisual, pls->xlength, pls->ylength ); aStream->cairoContext_X = cairo_create( aStream->cairoSurface_X ); /* This is the Cairo surface PLplot will actually plot to. */ - aStream->cairoSurface = cairo_image_surface_create( CAIRO_FORMAT_RGB24, pls->xlength, pls->ylength ); + aStream->cairoSurface = + /* + cairo_surface_create_similar( aStream->cairoSurface_X, + CAIRO_CONTENT_COLOR, + pls->xlength, pls->ylength ); + */ + cairo_image_surface_create( CAIRO_FORMAT_RGB24, + pls->xlength, pls->ylength ); aStream->cairoContext = cairo_create( aStream->cairoSurface ); /* Invert the surface so that the graphs are drawn right side up. */ @@ -1544,6 +1617,18 @@ /* Set graphics aliasing */ cairo_set_antialias( aStream->cairoContext, aStream->graphics_anti_aliasing ); + /* Fill in the X window with the background color to avoid starting out + * with a blank window of an unexpected color. */ + cairo_rectangle( aStream->cairoContext_X, 0.0, 0.0, pls->xlength, pls->ylength ); + cairo_set_source_rgba( aStream->cairoContext_X, + (double) pls->cmap0[0].r / 255.0, + (double) pls->cmap0[0].g / 255.0, + (double) pls->cmap0[0].b / 255.0, + (double) pls->cmap0[0].a ); + cairo_fill( aStream->cairoContext_X ); + + XFlush( aStream->XDisplay ); + return 0; } @@ -1600,10 +1685,22 @@ * Blit the offscreen image to the X window. * ---------------------------------------------------------------------*/ -void blit_to_x( PLCairo *aStream ) +void blit_to_x( PLCairo *aStream, double x, double y, double w, double h ) { - cairo_set_source_surface( aStream->cairoContext_X, aStream->cairoSurface, 0.0, 0.0 ); - cairo_paint( aStream->cairoContext_X ); + /* Copy a portion of the surface */ + cairo_save( aStream->cairoContext_X ); + cairo_rectangle( aStream->cairoContext_X, x, y, w, h ); + cairo_set_operator( aStream->cairoContext_X, CAIRO_OPERATOR_SOURCE ); + cairo_set_source_surface( aStream->cairoContext_X, aStream->cairoSurface, + 0.0, 0.0 ); + cairo_fill( aStream->cairoContext_X ); + cairo_restore( aStream->cairoContext_X ); + + /* Reset the drawn-on region */ + reset_dirty_rectangle( aStream ); + + /* Flush the X display */ + /* XFlush( aStream->XDisplay ); */ } /*---------------------------------------------------------------------- @@ -1640,6 +1737,7 @@ KeySym keysym; XComposeStatus cs; XEvent event; + XExposeEvent *expose; PLCairo *aStream; char helpmsg[] = " - Press Enter or right-click to continue"; char *plotTitle; @@ -1650,10 +1748,8 @@ return; /* Blit the offscreen image to the X window. */ - blit_to_x( aStream ); + blit_to_x( aStream, 0.0, 0.0, pls->xlength, pls->ylength ); - XFlush( aStream->XDisplay ); - /* Only pause if nopause is unset. */ if ( pls->nopause ) aStream->exit_event_loop = 1; @@ -1681,10 +1777,11 @@ case Expose: /* Blit the image again after an expose event, but only for the last * available event. Otherwise multiple redraws occur needlessly. */ - if ( ( (XExposeEvent *) &event )->count == 0 ) + expose = (XExposeEvent *) &event; + if ( expose->count == 0 ) { - blit_to_x( aStream ); - XFlush( aStream->XDisplay ); + blit_to_x( aStream, expose->x, expose->y, + expose->width, expose->height ); } break; } @@ -1736,7 +1833,9 @@ switch ( op ) { case PLESC_FLUSH: /* forced update of the window */ - blit_to_x( aStream ); + blit_to_x( aStream, aStream->dirty_x1, aStream->dirty_y1, + aStream->dirty_x2 - aStream->dirty_x1, + aStream->dirty_y2 - aStream->dirty_y1 ); XFlush( aStream->XDisplay ); break; case PLESC_GETC: /* get cursor position */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2010-03-13 19:39:16
|
Revision: 10863 http://plplot.svn.sourceforge.net/plplot/?rev=10863&view=rev Author: hbabcock Date: 2010-03-13 19:39:09 +0000 (Sat, 13 Mar 2010) Log Message: ----------- Set pls->dev_clear = 0, following the qt driver, so that you cannot see an older plot through a new plot with a transparent background. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-13 17:30:24 UTC (rev 10862) +++ trunk/drivers/cairo.c 2010-03-13 19:39:09 UTC (rev 10863) @@ -1149,6 +1149,7 @@ pls->color = 1; /* Supports color */ pls->dev_text = 1; /* Handles text */ pls->dev_unicode = 1; /* Wants unicode text */ + pls->dev_clear = 0; pls->alt_unicode = 1; /* Wants to handle unicode character by character */ pls->page = 0; pls->dev_fill0 = 1; /* Supports hardware solid fills */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2010-03-14 06:55:22
|
Revision: 10865 http://plplot.svn.sourceforge.net/plplot/?rev=10865&view=rev Author: hezekiahcarty Date: 2010-03-14 06:55:16 +0000 (Sun, 14 Mar 2010) Log Message: ----------- Fix a segfault-causing logic error in the xcairo dirty rectangle logic The Xlib Cairo surface should only be rotated when the xcairo device is in use, not just when it is enabled at compile time. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-13 23:37:28 UTC (rev 10864) +++ trunk/drivers/cairo.c 2010-03-14 06:55:16 UTC (rev 10865) @@ -254,7 +254,7 @@ static void filled_polygon( PLStream *pls, short *xa, short *ya, PLINT npts ); static void gradient( PLStream *pls, short *xa, short *ya, PLINT npts ); static void arc( PLStream *, arc_struct * ); -static void rotate_cairo_surface( PLStream *, float, float, float, float, float, float ); +static void rotate_cairo_surface( PLStream *, float, float, float, float, float, float, PLBOOL ); /* Rasterization of plotted material */ static void start_raster( PLStream* ); static void end_raster( PLStream* ); @@ -1476,7 +1476,7 @@ * Rotates the cairo surface to the appropriate orientation. * ---------------------------------------------------------------------*/ -void rotate_cairo_surface( PLStream *pls, float x11, float x12, float x21, float x22, float x0, float y0 ) +void rotate_cairo_surface( PLStream *pls, float x11, float x12, float x21, float x22, float x0, float y0, PLBOOL is_xcairo ) { cairo_matrix_t *matrix; PLCairo *aStream; @@ -1486,7 +1486,14 @@ matrix = (cairo_matrix_t *) malloc( sizeof ( cairo_matrix_t ) ); cairo_matrix_init( matrix, x11, x12, x21, x22, x0, y0 ); #if defined ( PLD_xcairo ) - cairo_transform( aStream->cairoContext_X, matrix ); + if ( is_xcairo ) + { + cairo_transform( aStream->cairoContext_X, matrix ); + } + else + { + cairo_transform( aStream->cairoContext, matrix ); + } #else cairo_transform( aStream->cairoContext, matrix ); #endif @@ -1613,7 +1620,7 @@ aStream->cairoContext = cairo_create( aStream->cairoSurface ); /* Invert the surface so that the graphs are drawn right side up. */ - rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength ); + rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength, TRUE ); /* Set graphics aliasing */ cairo_set_antialias( aStream->cairoContext, aStream->graphics_anti_aliasing ); @@ -2018,7 +2025,7 @@ pls->dev = aStream; /* Invert the surface so that the graphs are drawn right side up. */ - rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength ); + rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength, FALSE ); /* Set graphics aliasing */ cairo_set_antialias( aStream->cairoContext, aStream->graphics_anti_aliasing ); @@ -2095,7 +2102,7 @@ plsdiori( 1 ); pls->freeaspect = 1; } - rotate_cairo_surface( pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->xlength ); + rotate_cairo_surface( pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->xlength, FALSE ); } @@ -2186,7 +2193,7 @@ aStream->cairoContext = cairo_create( aStream->cairoSurface ); /* Invert the surface so that the graphs are drawn right side up. */ - rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength ); + rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength, FALSE ); /* Set graphics aliasing */ cairo_set_antialias( aStream->cairoContext, aStream->graphics_anti_aliasing ); @@ -2280,7 +2287,7 @@ aStream->cairoContext = cairo_create( aStream->cairoSurface ); /* Invert the surface so that the graphs are drawn right side up. */ - rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength ); + rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength, FALSE ); /* Set graphics aliasing */ cairo_set_antialias( aStream->cairoContext, aStream->graphics_anti_aliasing ); @@ -2448,7 +2455,7 @@ pls->dev = aStream; /* Invert the surface so that the graphs are drawn right side up. */ - rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength ); + rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength, FALSE ); /* Set graphics aliasing */ cairo_set_antialias( aStream->cairoContext, aStream->graphics_anti_aliasing ); @@ -2640,7 +2647,7 @@ cairo_set_antialias( aStream->cairoContext, aStream->graphics_anti_aliasing ); /* Invert the surface so that the graphs are drawn right side up. */ - rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength ); + rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength, FALSE ); /* Should adjust plot size to fit in the given cairo context? * Cairo does not provide a way to query the dimensions of a context? */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2010-03-14 15:44:55
|
Revision: 10866 http://plplot.svn.sourceforge.net/plplot/?rev=10866&view=rev Author: hezekiahcarty Date: 2010-03-14 15:44:48 +0000 (Sun, 14 Mar 2010) Log Message: ----------- If the background is transparent, use a white under-layer This fixes the "bleeding through" of previous plot pages when using the xcairo driver. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-14 06:55:16 UTC (rev 10865) +++ trunk/drivers/cairo.c 2010-03-14 15:44:48 UTC (rev 10866) @@ -376,6 +376,11 @@ /* Fill in the window with the background color. */ cairo_rectangle( aStream->cairoContext, 0.0, 0.0, pls->xlength, pls->ylength ); + if ( (double) pls->cmap0[0].a < 1.0 ) + { + cairo_set_source_rgba( aStream->cairoContext, 1.0, 1.0, 1.0, 1.0 ); + cairo_fill_preserve( aStream->cairoContext ); + } cairo_set_source_rgba( aStream->cairoContext, (double) pls->cmap0[0].r / 255.0, (double) pls->cmap0[0].g / 255.0, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2010-03-14 15:45:53
|
Revision: 10867 http://plplot.svn.sourceforge.net/plplot/?rev=10867&view=rev Author: hezekiahcarty Date: 2010-03-14 15:45:42 +0000 (Sun, 14 Mar 2010) Log Message: ----------- Small change to fix the extXdrawable_demo.c example The off-screen rendered plot was never flushed to the on-screen surface in the external drawable case. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-14 15:44:48 UTC (rev 10866) +++ trunk/drivers/cairo.c 2010-03-14 15:45:42 UTC (rev 10867) @@ -1757,12 +1757,12 @@ aStream = (PLCairo *) pls->dev; + /* Blit the offscreen image to the X window. */ + blit_to_x( aStream, 0.0, 0.0, pls->xlength, pls->ylength ); + if ( aStream->xdrawable_mode ) return; - /* Blit the offscreen image to the X window. */ - blit_to_x( aStream, 0.0, 0.0, pls->xlength, pls->ylength ); - /* Only pause if nopause is unset. */ if ( pls->nopause ) aStream->exit_event_loop = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2010-03-18 20:23:56
|
Revision: 10874 http://plplot.svn.sourceforge.net/plplot/?rev=10874&view=rev Author: hezekiahcarty Date: 2010-03-18 20:23:49 +0000 (Thu, 18 Mar 2010) Log Message: ----------- Fix transparent backgrounds for the pngcairo device Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-18 19:33:34 UTC (rev 10873) +++ trunk/drivers/cairo.c 2010-03-18 20:23:49 UTC (rev 10874) @@ -2288,7 +2288,7 @@ /* Create a new cairo surface & context for PNG file. */ /* Dimension units are pixels from cairo documentation. */ - aStream->cairoSurface = cairo_image_surface_create( CAIRO_FORMAT_RGB24, (double) pls->xlength, (double) pls->ylength ); + aStream->cairoSurface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, (double) pls->xlength, (double) pls->ylength ); aStream->cairoContext = cairo_create( aStream->cairoSurface ); /* Invert the surface so that the graphs are drawn right side up. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2010-03-21 19:10:26
|
Revision: 10876 http://plplot.svn.sourceforge.net/plplot/?rev=10876&view=rev Author: hbabcock Date: 2010-03-21 19:10:20 +0000 (Sun, 21 Mar 2010) Log Message: ----------- Fix win_cairo call to rotate_cairo_surface. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-21 00:43:45 UTC (rev 10875) +++ trunk/drivers/cairo.c 2010-03-21 19:10:20 UTC (rev 10876) @@ -2958,7 +2958,7 @@ aStream->cairoContext = cairo_create( aStream->cairoSurface ); /* Invert the surface so that the graphs are drawn right side up. */ - rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength ); + rotate_cairo_surface( pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength, FALSE ); /* Set graphics aliasing */ cairo_set_antialias( aStream->cairoContext, aStream->graphics_anti_aliasing ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2010-03-21 19:41:42
|
Revision: 10877 http://plplot.svn.sourceforge.net/plplot/?rev=10877&view=rev Author: hbabcock Date: 2010-03-21 19:41:36 +0000 (Sun, 21 Mar 2010) Log Message: ----------- Call blit_to_x in PLESC_GETC so that the plot is displayed for the user to click on. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-03-21 19:10:20 UTC (rev 10876) +++ trunk/drivers/cairo.c 2010-03-21 19:41:36 UTC (rev 10877) @@ -1852,6 +1852,9 @@ XFlush( aStream->XDisplay ); break; case PLESC_GETC: /* get cursor position */ + blit_to_x( aStream, aStream->dirty_x1, aStream->dirty_y1, + aStream->dirty_x2 - aStream->dirty_x1, + aStream->dirty_y2 - aStream->dirty_y1 ); XFlush( aStream->XDisplay ); xcairo_get_cursor( pls, (PLGraphicsIn*) ptr ); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |