@@ -357,6 +357,15 @@ bool MCCustomMetaContext::candomark(MCMark *p_mark)
357357 MCUnreachableReturn (false );
358358}
359359
360+ MCRectangle MCCustomPrinterInsetRectangle (const MCRectangle &p_rect, uint32_t p_inset)
361+ {
362+ /* TODO - fix half pixels lost when insetting by odd integers */
363+ return MCRectangleMake (p_rect.x + p_inset / 2 ,
364+ p_rect.y + p_inset / 2 ,
365+ MCMax (0 , (int32_t )p_rect.width - p_inset),
366+ MCMax (0 , (int32_t )p_rect.height - p_inset));
367+ }
368+
360369void MCCustomMetaContext::domark (MCMark *p_mark)
361370{
362371 // If an error has occurred, we do nothing.
@@ -399,16 +408,7 @@ void MCCustomMetaContext::domark(MCMark *p_mark)
399408 break ;
400409 case MARK_TYPE_RECTANGLE:
401410 {
402- // MM-2014-04-23: [[ Bug 11884 ]] Inset the bounds. Since MCPath only accepts ints, if the inset value is uneven,
403- // round up to the nearest even value, keeping behaviour as close to that of the graphics context as possible.
404- // SN-2014-10-17: [[ Bug 13351 ]] Only round up existing inset
405- if (p_mark -> rectangle . inset && (p_mark -> rectangle . inset % 2 ))
406- p_mark -> rectangle . inset ++;
407- // SN-2014-10-17: [[ Bug 13351 ]] Be careful not to underflow the bounds
408- p_mark -> rectangle . bounds = MCRectangleMake (p_mark -> rectangle . bounds . x + p_mark -> rectangle . inset / 2 ,
409- p_mark -> rectangle . bounds . y + p_mark -> rectangle . inset / 2 ,
410- MCMin (p_mark -> rectangle . bounds . width, p_mark -> rectangle . bounds . width - p_mark -> rectangle . inset),
411- MCMin (p_mark -> rectangle . bounds . height, p_mark -> rectangle . bounds . height - p_mark -> rectangle . inset));
411+ p_mark -> rectangle . bounds = MCCustomPrinterInsetRectangle (p_mark -> rectangle . bounds, p_mark -> rectangle . inset);
412412
413413 MCPath *t_path;
414414 if (p_mark -> stroke != nil && p_mark -> rectangle . bounds . height == 1 )
@@ -428,16 +428,7 @@ void MCCustomMetaContext::domark(MCMark *p_mark)
428428 break ;
429429 case MARK_TYPE_ROUND_RECTANGLE:
430430 {
431- // MM-2014-04-23: [[ Bug 11884 ]] Inset the bounds. Since MCPath only accepts ints, if the inset value is uneven,
432- // round up to the nearest even value, keeping behaviour as close to that of the graphics context as possible.
433- // SN-2014-10-17: [[ Bug 13351 ]] Only round up existing inset
434- if (p_mark -> round_rectangle . inset % 2 )
435- p_mark -> round_rectangle . inset ++;
436- // SN-2014-10-17: [[ Bug 13351 ]] Be careful not to underflow the bounds
437- p_mark -> round_rectangle . bounds = MCRectangleMake (p_mark -> round_rectangle . bounds . x + p_mark -> round_rectangle . inset / 2 ,
438- p_mark -> round_rectangle . bounds . y + p_mark -> round_rectangle . inset / 2 ,
439- MCMin (p_mark -> round_rectangle . bounds . width, p_mark -> round_rectangle . bounds . width - p_mark -> round_rectangle . inset),
440- MCMin (p_mark -> round_rectangle . bounds . height, p_mark -> round_rectangle . bounds . height - p_mark -> round_rectangle . inset));
431+ p_mark -> round_rectangle . bounds = MCCustomPrinterInsetRectangle (p_mark -> round_rectangle . bounds, p_mark -> round_rectangle . inset);
441432
442433 MCPath *t_path;
443434 t_path = MCPath::create_rounded_rectangle (p_mark -> round_rectangle . bounds, p_mark -> round_rectangle . radius / 2 , p_mark -> stroke != nil);
@@ -452,16 +443,7 @@ void MCCustomMetaContext::domark(MCMark *p_mark)
452443 break ;
453444 case MARK_TYPE_ARC:
454445 {
455- // MM-2014-04-23: [[ Bug 11884 ]] Inset the bounds. Since MCPath only accepts ints, if the inset value is uneven,
456- // round up to the nearest even value, keeping behaviour as close to that of the graphics context as possible.
457- // SN-2014-10-17: [[ Bug 13351 ]] Only round up existing inset
458- if (p_mark -> arc . inset % 2 )
459- p_mark -> arc . inset ++;
460- // SN-2014-10-17: [[ Bug 13351 ]] Be careful not to underflow the bounds
461- p_mark -> arc . bounds = MCRectangleMake (p_mark -> arc . bounds . x + p_mark -> arc . inset / 2 ,
462- p_mark -> arc . bounds . y + p_mark -> arc . inset / 2 ,
463- MCMin (p_mark -> arc . bounds . width, p_mark -> arc . bounds . width - p_mark -> arc . inset),
464- MCMin (p_mark -> arc . bounds . height, p_mark -> arc . bounds . height - p_mark -> arc . inset));
446+ p_mark -> arc . bounds = MCCustomPrinterInsetRectangle (p_mark -> arc . bounds, p_mark -> arc . inset);
465447
466448 MCPath *t_path;
467449 if (p_mark -> arc . complete)
0 commit comments