[metapost] MPlib: some observations on the mp_gr_copy_object(MP mp, mp_graphic_object*p) function

luigi scarso luigi.scarso at gmail.com
Tue Nov 4 14:35:15 CET 2014


On Mon, Nov 3, 2014 at 11:33 PM, Graham Douglas <
graham.douglas at readytext.co.uk> wrote:

> Hi All
>
> I'm working with MPlib (version 1.801, compiled under Windows 7, 64 bit
> ) and using mp_gr_copy_object(MP mp,mp_graphic_object*p) to create a way
> to cache graphics produced by MPlib (which is now working well, after
> the "fixes" below.).  I noticed that the mp_gr_copy_object(MP
> mp,mp_graphic_object*p) function (in psout.c) was not copying a number
> of key values into the new object --- such as ljoin, lcap colour
> information etc. My apologies if this has been fixed or, of course,
> there are good reasons that these values are not copied (or it is some
> other error on my part). Anyway, I thought I'd make a note of this just
> in case. I have highlighted the changes I made within psout.c
>
> Warm wishes
> Graham
>
> mp_graphic_object* mp_gr_copy_object(MP mp,mp_graphic_object*p)
> {
>
> .....
>
> switch(gr_type(p)){
> case mp_fill_code:
> tf= (mp_fill_object*)mp_new_graphic_object(mp,mp_fill_code);
> gr_pre_script(tf)= mp_xstrdup(mp,gr_pre_script((mp_fill_object*)p));
> gr_post_script(tf)= mp_xstrdup(mp,gr_post_script((mp_fill_object*)p));
> gr_path_p(tf)= mp_gr_copy_path(mp,gr_path_p((mp_fill_object*)p));
> gr_htap_p(tf)= mp_gr_copy_path(mp,gr_htap_p(p));
> gr_pen_p(tf)= mp_gr_copy_path(mp,gr_pen_p((mp_fill_object*)p));
>
> //=============================================
> //GMD Graham fixes --------------------------------->
> tf->ljoin = ((mp_fill_object*)p)->ljoin;
> tf->miterlim = ((mp_fill_object*)p)->miterlim;
> tf->color_model = ((mp_fill_object*)p)->color_model;
> tf->color.a_val = ((mp_fill_object*)p)->color.a_val;
> tf->color.b_val = ((mp_fill_object*)p)->color.b_val;
> tf->color.c_val = ((mp_fill_object*)p)->color.c_val;
> tf->color.d_val = ((mp_fill_object*)p)->color.d_val;
> //<-----------------------------------------------------------------
> //=============================================
> q= (mp_graphic_object*)tf;
> break;
> case mp_stroked_code:
> ts= (mp_stroked_object*)mp_new_graphic_object(mp,mp_stroked_code);
> gr_pre_script(ts)= mp_xstrdup(mp,gr_pre_script((mp_stroked_object*)p));
> gr_post_script(ts)= mp_xstrdup(mp,gr_post_script((mp_stroked_object*)p));
> gr_path_p(ts)= mp_gr_copy_path(mp,gr_path_p((mp_stroked_object*)p));
> gr_pen_p(ts)= mp_gr_copy_path(mp,gr_pen_p((mp_stroked_object*)p));
> gr_dash_p(ts)= mp_gr_copy_dashes(mp,gr_dash_p(p));
>
> //=============================================
> //GMD Graham fixes --------------------------------->
> ts->ljoin = ((mp_stroked_object*)p)->ljoin;
> ts->color_model = ((mp_stroked_object*)p)->color_model;
> ts->miterlim = ((mp_stroked_object*)p)->miterlim;
> ts->lcap = ((mp_stroked_object*)p)->lcap;
> ts->color_model = ((mp_stroked_object*)p)->color_model;
> ts->color.a_val = ((mp_stroked_object*)p)->color.a_val;
> ts->color.b_val = ((mp_stroked_object*)p)->color.b_val;
> ts->color.c_val = ((mp_stroked_object*)p)->color.c_val;
> ts->color.d_val = ((mp_stroked_object*)p)->color.d_val;
> //<-----------------------------------------------------------------
> //=============================================
> q= (mp_graphic_object*)ts;
> --
> http://tug.org/metapost/
>


Can you post a diff -u ?
-- 
luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/metapost/attachments/20141104/36b26cbd/attachment.html>


More information about the metapost mailing list