@@ -782,10 +782,10 @@ void MCGraphicsContext::setgradient(MCGradientFill *p_gradient)
782782 break ;
783783 }
784784
785- MCGFloat * t_stops;
786- /* UNCHECKED */ MCMemoryNewArray ( p_gradient -> ramp_length, t_stops );
787- MCGColor * t_colors;
788- /* UNCHECKED */ MCMemoryNewArray ( p_gradient -> ramp_length, t_colors );
785+ /* UNCHECKED */ MCAutoPointer<MCGFloat[]> t_stops =
786+ new MCGFloat[ p_gradient-> ramp_length ]( );
787+ /* UNCHECKED */ MCAutoPointer<MCGColor[]> t_colors =
788+ new MCGColor[ p_gradient-> ramp_length ]( );
789789 for (uint32_t i = 0 ; i < p_gradient -> ramp_length; i++)
790790 {
791791 t_stops[i] = (MCGFloat) p_gradient -> ramp[i] . offset / STOP_INT_MAX;
@@ -800,11 +800,8 @@ void MCGraphicsContext::setgradient(MCGradientFill *p_gradient)
800800 t_transform . tx = p_gradient -> origin . x;
801801 t_transform . ty = p_gradient -> origin . y;
802802
803- MCGContextSetFillGradient (m_gcontext, t_function, t_stops, t_colors, p_gradient -> ramp_length, p_gradient -> mirror, p_gradient -> wrap, p_gradient -> repeat, t_transform, t_filter);
804- MCGContextSetStrokeGradient (m_gcontext, t_function, t_stops, t_colors, p_gradient -> ramp_length, p_gradient -> mirror, p_gradient -> wrap, p_gradient -> repeat, t_transform, t_filter);
805-
806- MCMemoryDeleteArray (t_stops);
807- MCMemoryDeleteArray (t_colors);
803+ MCGContextSetFillGradient (m_gcontext, t_function, t_stops.Get (), t_colors.Get (), p_gradient -> ramp_length, p_gradient -> mirror, p_gradient -> wrap, p_gradient -> repeat, t_transform, t_filter);
804+ MCGContextSetStrokeGradient (m_gcontext, t_function, t_stops.Get (), t_colors.Get (), p_gradient -> ramp_length, p_gradient -> mirror, p_gradient -> wrap, p_gradient -> repeat, t_transform, t_filter);
808805 }
809806}
810807
@@ -1011,36 +1008,32 @@ void MCGraphicsContext::drawlines(MCPoint *points, uint2 npoints, bool p_closed)
10111008 else
10121009 {
10131010 // MM-2013-11-14: [[ Bug 11457 ]] Adjust lines and polygons to make sure antialiased lines don't draw across pixels.
1014- MCGPoint * t_points;
1015- /* UNCHECKED */ MCMemoryNewArray ( npoints, t_points );
1011+ /* UNCHECKED */ MCAutoPointer<MCGPoint[]> t_points =
1012+ new MCGPoint[ npoints]( );
10161013 for (uint32_t i = 0 ; i < npoints; i++)
10171014 t_points[i] = MCPointToMCGPoint (points[i], 0 .5f );
10181015
10191016 MCGContextBeginPath (m_gcontext);
10201017 if (p_closed)
1021- MCGContextAddPolygon (m_gcontext, t_points, npoints);
1018+ MCGContextAddPolygon (m_gcontext, t_points. Get () , npoints);
10221019 else
1023- MCGContextAddPolyline (m_gcontext, t_points, npoints);
1020+ MCGContextAddPolyline (m_gcontext, t_points. Get () , npoints);
10241021 MCGContextStroke (m_gcontext);
1025-
1026- MCMemoryDeleteArray (t_points);
10271022 }
10281023}
10291024
10301025void MCGraphicsContext::fillpolygon (MCPoint *points, uint2 npoints)
10311026{
10321027 // MM-2013-11-26: [[ Bug 11501 ]] Adjust lines and polygons to make sure antialiased lines don't draw across pixels.
10331028 // Here the adjust is 0.25 - not the same path as draw lines but appears to solve the issue where the fill interfers with the stroke.
1034- MCGPoint * t_points;
1035- /* UNCHECKED */ MCMemoryNewArray ( npoints, t_points );
1029+ /* UNCHECKED */ MCAutoPointer<MCGPoint[]> t_points =
1030+ new MCGPoint[ npoints]( );
10361031 for (uint32_t i = 0 ; i < npoints; i++)
10371032 t_points[i] = MCPointToMCGPoint (points[i], 0 .25f );
10381033
10391034 MCGContextBeginPath (m_gcontext);
1040- MCGContextAddPolygon (m_gcontext, t_points, npoints);
1035+ MCGContextAddPolygon (m_gcontext, t_points. Get () , npoints);
10411036 MCGContextFill (m_gcontext);
1042-
1043- MCMemoryDeleteArray (t_points);
10441037}
10451038
10461039static MCGRectangle MCGRectangleInset (const MCGRectangle &p_rect, MCGFloat p_inset)
0 commit comments