@@ -33,7 +33,7 @@ impl Engine {
3333 background : & Background ,
3434 transformation : Transformation ,
3535 pixels : & mut tiny_skia:: PixmapMut < ' _ > ,
36- clip_mask : & mut tiny_skia:: Mask ,
36+ clip_mask : & tiny_skia:: Mask ,
3737 clip_bounds : Rectangle ,
3838 ) {
3939 debug_assert ! (
@@ -51,8 +51,8 @@ impl Engine {
5151 return ;
5252 }
5353
54- let clip_mask = ( !physical_bounds. is_within ( & clip_bounds) )
55- . then_some ( clip_mask as & _ ) ;
54+ let physical_mask = ( !physical_bounds. is_within ( & clip_bounds) )
55+ . then_some ( clip_mask) ;
5656
5757 let transform = into_transform ( transformation) ;
5858
@@ -143,7 +143,9 @@ impl Engine {
143143 pixmap. as_ref ( ) ,
144144 & tiny_skia:: PixmapPaint :: default ( ) ,
145145 tiny_skia:: Transform :: default ( ) ,
146- clip_mask,
146+ // Shadows physically could be larger than clip bounds.
147+ // To avoid out of bound draws, always pass original clip mask.
148+ Some ( clip_mask) ,
147149 ) ;
148150 }
149151 }
@@ -202,7 +204,7 @@ impl Engine {
202204 } ,
203205 tiny_skia:: FillRule :: EvenOdd ,
204206 transform,
205- clip_mask ,
207+ physical_mask ,
206208 ) ;
207209
208210 if border_width > 0.0 {
@@ -251,7 +253,7 @@ impl Engine {
251253 ..tiny_skia:: Stroke :: default ( )
252254 } ,
253255 transform,
254- clip_mask ,
256+ physical_mask ,
255257 ) ;
256258 } else {
257259 // Draw corners that have too small border radii as having no border radius,
@@ -315,7 +317,7 @@ impl Engine {
315317 temp_pixmap. as_ref ( ) ,
316318 & tiny_skia:: PixmapPaint :: default ( ) ,
317319 transform,
318- clip_mask ,
320+ physical_mask ,
319321 ) ;
320322 }
321323 }
@@ -326,7 +328,7 @@ impl Engine {
326328 text : & Text ,
327329 transformation : Transformation ,
328330 pixels : & mut tiny_skia:: PixmapMut < ' _ > ,
329- clip_mask : & mut tiny_skia:: Mask ,
331+ clip_mask : & tiny_skia:: Mask ,
330332 clip_bounds : Rectangle ,
331333 ) {
332334 match text {
@@ -347,15 +349,15 @@ impl Engine {
347349 return ;
348350 }
349351
350- let clip_mask = ( !physical_bounds. is_within ( & clip_bounds) )
351- . then_some ( clip_mask as & _ ) ;
352+ let physical_mask = ( !physical_bounds. is_within ( & clip_bounds) )
353+ . then_some ( clip_mask) ;
352354
353355 self . text_pipeline . draw_paragraph (
354356 paragraph,
355357 * position,
356358 * color,
357359 pixels,
358- clip_mask ,
360+ physical_mask ,
359361 transformation,
360362 ) ;
361363 }
@@ -375,15 +377,15 @@ impl Engine {
375377 return ;
376378 }
377379
378- let clip_mask = ( !physical_bounds. is_within ( & clip_bounds) )
379- . then_some ( clip_mask as & _ ) ;
380+ let physical_mask = ( !physical_bounds. is_within ( & clip_bounds) )
381+ . then_some ( clip_mask) ;
380382
381383 self . text_pipeline . draw_editor (
382384 editor,
383385 * position,
384386 * color,
385387 pixels,
386- clip_mask ,
388+ physical_mask ,
387389 transformation,
388390 ) ;
389391 }
@@ -405,8 +407,8 @@ impl Engine {
405407 return ;
406408 }
407409
408- let clip_mask = ( !physical_bounds. is_within ( & clip_bounds) )
409- . then_some ( clip_mask as & _ ) ;
410+ let physical_mask = ( !physical_bounds. is_within ( & clip_bounds) )
411+ . then_some ( clip_mask) ;
410412
411413 self . text_pipeline . draw_cached (
412414 content,
@@ -419,7 +421,7 @@ impl Engine {
419421 * vertical_alignment,
420422 * shaping,
421423 pixels,
422- clip_mask ,
424+ physical_mask ,
423425 transformation,
424426 ) ;
425427 }
@@ -446,15 +448,15 @@ impl Engine {
446448 return ;
447449 }
448450
449- let clip_mask = ( !physical_bounds. is_within ( & clip_bounds) )
450- . then_some ( clip_mask as & _ ) ;
451+ let physical_mask = ( !physical_bounds. is_within ( & clip_bounds) )
452+ . then_some ( clip_mask) ;
451453
452454 self . text_pipeline . draw_raw (
453455 & buffer,
454456 raw. position ,
455457 raw. color ,
456458 pixels,
457- clip_mask ,
459+ physical_mask ,
458460 transformation,
459461 ) ;
460462 }
@@ -466,7 +468,7 @@ impl Engine {
466468 primitive : & Primitive ,
467469 transformation : Transformation ,
468470 pixels : & mut tiny_skia:: PixmapMut < ' _ > ,
469- clip_mask : & mut tiny_skia:: Mask ,
471+ clip_mask : & tiny_skia:: Mask ,
470472 layer_bounds : Rectangle ,
471473 ) {
472474 match primitive {
@@ -488,15 +490,15 @@ impl Engine {
488490 return ;
489491 } ;
490492
491- let clip_mask =
492- ( physical_bounds != clip_bounds) . then_some ( clip_mask as & _ ) ;
493+ let physical_mask =
494+ ( physical_bounds != clip_bounds) . then_some ( clip_mask) ;
493495
494496 pixels. fill_path (
495497 path,
496498 paint,
497499 * rule,
498500 into_transform ( transformation) ,
499- clip_mask ,
501+ physical_mask ,
500502 ) ;
501503 }
502504 Primitive :: Stroke {
@@ -521,15 +523,15 @@ impl Engine {
521523 return ;
522524 } ;
523525
524- let clip_mask =
525- ( physical_bounds != clip_bounds) . then_some ( clip_mask as & _ ) ;
526+ let physical_mask =
527+ ( physical_bounds != clip_bounds) . then_some ( clip_mask) ;
526528
527529 pixels. stroke_path (
528530 path,
529531 paint,
530532 stroke,
531533 into_transform ( transformation) ,
532- clip_mask ,
534+ physical_mask ,
533535 ) ;
534536 }
535537 }
@@ -540,7 +542,7 @@ impl Engine {
540542 image : & Image ,
541543 _transformation : Transformation ,
542544 _pixels : & mut tiny_skia:: PixmapMut < ' _ > ,
543- _clip_mask : & mut tiny_skia:: Mask ,
545+ _clip_mask : & tiny_skia:: Mask ,
544546 _clip_bounds : Rectangle ,
545547 ) {
546548 match image {
@@ -552,8 +554,8 @@ impl Engine {
552554 return ;
553555 }
554556
555- let clip_mask = ( !physical_bounds. is_within ( & _clip_bounds) )
556- . then_some ( _clip_mask as & _ ) ;
557+ let physical_mask = ( !physical_bounds. is_within ( & _clip_bounds) )
558+ . then_some ( _clip_mask) ;
557559
558560 let center = physical_bounds. center ( ) ;
559561 let radians = f32:: from ( raster. rotation ) ;
@@ -571,7 +573,7 @@ impl Engine {
571573 raster. opacity ,
572574 _pixels,
573575 transform,
574- clip_mask ,
576+ physical_mask ,
575577 ) ;
576578 }
577579 #[ cfg( feature = "svg" ) ]
@@ -582,8 +584,8 @@ impl Engine {
582584 return ;
583585 }
584586
585- let clip_mask = ( !physical_bounds. is_within ( & _clip_bounds) )
586- . then_some ( _clip_mask as & _ ) ;
587+ let physical_mask = ( !physical_bounds. is_within ( & _clip_bounds) )
588+ . then_some ( _clip_mask) ;
587589
588590 let center = physical_bounds. center ( ) ;
589591 let radians = f32:: from ( svg. rotation ) ;
@@ -601,7 +603,7 @@ impl Engine {
601603 svg. opacity ,
602604 _pixels,
603605 transform,
604- clip_mask ,
606+ physical_mask ,
605607 ) ;
606608 }
607609 #[ cfg( not( feature = "image" ) ) ]
0 commit comments