@@ -213,6 +213,15 @@ bool MCGGradientToSkShader(MCGGradientRef self, MCGRectangle p_clip, sk_sp<SkSha
213213 // Because it implements repeats and mirroring differently, we need to synthesize extra stops for it
214214 uindex_t t_count = self->ramp_length ;
215215 uindex_t t_repeats = MCMax (1 , self->repeats );
216+
217+ MCGFloat t_gradient_scale = 1.0 ;
218+ if (self->wrap && self->mirror && self->function != kMCGGradientFunctionSweep )
219+ {
220+ // IM-2017-08-04: [[ Bug 20218 ]] For mirrored + wrapped gradients we generate the ramp
221+ // forward & reversed, then scale the length of the gradient.
222+ t_gradient_scale = 2.0 / t_repeats;
223+ t_repeats = 2 ;
224+ }
216225 uindex_t t_length = t_count * t_repeats;
217226 MCGFloat t_scale = MCGFloat (1 )/t_repeats;
218227 MCAutoArray<SkColor> t_colors;
@@ -250,16 +259,16 @@ bool MCGGradientToSkShader(MCGGradientRef self, MCGRectangle p_clip, sk_sp<SkSha
250259 {
251260 case kMCGGradientFunctionLinear :
252261 {
253- // The end points are always (0,0) and (1,0)
254- SkPoint t_points[2 ] = {{0 ,0 }, {1 ,0 }};
262+ // The end points are scaled from (0,0) and (1,0)
263+ SkPoint t_points[2 ] = {{0 ,0 }, {t_gradient_scale ,0 }};
255264 t_shader = SkGradientShader::MakeLinear (t_points, t_colors.Ptr (), t_stops.Ptr (), t_length, t_tile_mode, 0 , &self->transform );
256265 break ;
257266 }
258267
259268 case kMCGGradientFunctionRadial :
260269 {
261- // The gradient is always from (0,0) with a unit radius
262- t_shader = SkGradientShader::MakeRadial ({0 ,0 }, 1 , t_colors.Ptr (), t_stops.Ptr (), t_length, t_tile_mode, 0 , &self->transform );
270+ // The gradient is always from (0,0) with a scaled unit radius
271+ t_shader = SkGradientShader::MakeRadial ({0 ,0 }, t_gradient_scale , t_colors.Ptr (), t_stops.Ptr (), t_length, t_tile_mode, 0 , &self->transform );
263272 break ;
264273 }
265274
0 commit comments