@@ -443,6 +443,12 @@ def draw(self, renderer):
443
443
# iterate over all paths and draw them one by one.
444
444
hatchcolors_arg_supported = False
445
445
446
+ # If the hatchcolors argument is not needed or not passed
447
+ # then we can skip the iteration over paths in case the
448
+ # argument is not supported by the renderer.
449
+ hatchcolors_not_needed = (self .get_hatch () is None or
450
+ self ._original_hatchcolor is None )
451
+
446
452
if self ._gapcolor is not None :
447
453
# First draw paths within the gaps.
448
454
ipaths , ilinestyles = self ._get_inverse_paths_linestyles ()
@@ -455,16 +461,21 @@ def draw(self, renderer):
455
461
self .get_transforms (), * args ,
456
462
hatchcolors = self .get_hatchcolor ())
457
463
else :
458
- path_ids = renderer ._iter_collection_raw_paths (
459
- transform .frozen (), ipaths , self .get_transforms ())
460
- for xo , yo , path_id , gc0 , rgbFace in renderer ._iter_collection (
461
- gc , list (path_ids ), * args , hatchcolors = self .get_hatchcolor (),
462
- ):
463
- path , transform = path_id
464
- if xo != 0 or yo != 0 :
465
- transform = transform .frozen ()
466
- transform .translate (xo , yo )
467
- renderer .draw_path (gc0 , path , transform , rgbFace )
464
+ if hatchcolors_not_needed :
465
+ renderer .draw_path_collection (gc , transform .frozen (), ipaths ,
466
+ self .get_transforms (), * args )
467
+ else :
468
+ path_ids = renderer ._iter_collection_raw_paths (
469
+ transform .frozen (), ipaths , self .get_transforms ())
470
+ for xo , yo , path_id , gc0 , rgbFace in renderer ._iter_collection (
471
+ gc , list (path_ids ), * args ,
472
+ hatchcolors = self .get_hatchcolor (),
473
+ ):
474
+ path , transform = path_id
475
+ if xo != 0 or yo != 0 :
476
+ transform = transform .frozen ()
477
+ transform .translate (xo , yo )
478
+ renderer .draw_path (gc0 , path , transform , rgbFace )
468
479
469
480
args = [offsets , offset_trf , self .get_facecolor (), self .get_edgecolor (),
470
481
self ._linewidths , self ._linestyles , self ._antialiaseds , self ._urls ,
@@ -475,16 +486,20 @@ def draw(self, renderer):
475
486
self .get_transforms (), * args ,
476
487
hatchcolors = self .get_hatchcolor ())
477
488
else :
478
- path_ids = renderer ._iter_collection_raw_paths (
479
- transform .frozen (), paths , self .get_transforms ())
480
- for xo , yo , path_id , gc0 , rgbFace in renderer ._iter_collection (
481
- gc , list (path_ids ), * args , hatchcolors = self .get_hatchcolor (),
482
- ):
483
- path , transform = path_id
484
- if xo != 0 or yo != 0 :
485
- transform = transform .frozen ()
486
- transform .translate (xo , yo )
487
- renderer .draw_path (gc0 , path , transform , rgbFace )
489
+ if hatchcolors_not_needed :
490
+ renderer .draw_path_collection (gc , transform .frozen (), paths ,
491
+ self .get_transforms (), * args )
492
+ else :
493
+ path_ids = renderer ._iter_collection_raw_paths (
494
+ transform .frozen (), paths , self .get_transforms ())
495
+ for xo , yo , path_id , gc0 , rgbFace in renderer ._iter_collection (
496
+ gc , list (path_ids ), * args , hatchcolors = self .get_hatchcolor (),
497
+ ):
498
+ path , transform = path_id
499
+ if xo != 0 or yo != 0 :
500
+ transform = transform .frozen ()
501
+ transform .translate (xo , yo )
502
+ renderer .draw_path (gc0 , path , transform , rgbFace )
488
503
489
504
gc .restore ()
490
505
renderer .close_group (self .__class__ .__name__ )
0 commit comments