@@ -394,12 +394,11 @@ impl PrimitiveStore {
394
394
local_clip_rect : clip. main . clone ( ) ,
395
395
} ) ;
396
396
397
- let ( clip_index, clip_source) = if clip. is_complex ( ) {
398
- ( Some ( self . gpu_data32 . alloc ( 6 ) ) ,
399
- Box :: new ( PrimitiveClipSource :: Region ( clip. clone ( ) ) ) )
397
+ let clip_source = Box :: new ( if clip. is_complex ( ) {
398
+ PrimitiveClipSource :: Region ( clip. clone ( ) )
400
399
} else {
401
- ( None , Box :: new ( PrimitiveClipSource :: NoClip ) )
402
- } ;
400
+ PrimitiveClipSource :: NoClip
401
+ } ) ;
403
402
404
403
let metadata = match container {
405
404
PrimitiveContainer :: Rectangle ( rect) => {
@@ -409,7 +408,7 @@ impl PrimitiveStore {
409
408
let metadata = PrimitiveMetadata {
410
409
is_opaque : is_opaque,
411
410
mask_texture_id : TextureId :: invalid ( ) ,
412
- clip_index : clip_index ,
411
+ clip_index : None ,
413
412
clip_source : clip_source,
414
413
prim_kind : PrimitiveKind :: Rectangle ,
415
414
cpu_prim_index : SpecificPrimitiveIndex :: invalid ( ) ,
@@ -428,7 +427,7 @@ impl PrimitiveStore {
428
427
let metadata = PrimitiveMetadata {
429
428
is_opaque : false ,
430
429
mask_texture_id : TextureId :: invalid ( ) ,
431
- clip_index : clip_index ,
430
+ clip_index : None ,
432
431
clip_source : clip_source,
433
432
prim_kind : PrimitiveKind :: TextRun ,
434
433
cpu_prim_index : SpecificPrimitiveIndex ( self . cpu_text_runs . len ( ) ) ,
@@ -447,7 +446,7 @@ impl PrimitiveStore {
447
446
let metadata = PrimitiveMetadata {
448
447
is_opaque : false ,
449
448
mask_texture_id : TextureId :: invalid ( ) ,
450
- clip_index : clip_index ,
449
+ clip_index : None ,
451
450
clip_source : clip_source,
452
451
prim_kind : PrimitiveKind :: Image ,
453
452
cpu_prim_index : SpecificPrimitiveIndex ( self . cpu_images . len ( ) ) ,
@@ -466,7 +465,7 @@ impl PrimitiveStore {
466
465
let metadata = PrimitiveMetadata {
467
466
is_opaque : false ,
468
467
mask_texture_id : TextureId :: invalid ( ) ,
469
- clip_index : clip_index ,
468
+ clip_index : None ,
470
469
clip_source : clip_source,
471
470
prim_kind : PrimitiveKind :: Border ,
472
471
cpu_prim_index : SpecificPrimitiveIndex ( self . cpu_borders . len ( ) ) ,
@@ -486,7 +485,7 @@ impl PrimitiveStore {
486
485
let metadata = PrimitiveMetadata {
487
486
is_opaque : false ,
488
487
mask_texture_id : TextureId :: invalid ( ) ,
489
- clip_index : clip_index ,
488
+ clip_index : None ,
490
489
clip_source : clip_source,
491
490
prim_kind : PrimitiveKind :: Gradient ,
492
491
cpu_prim_index : SpecificPrimitiveIndex ( self . cpu_gradients . len ( ) ) ,
@@ -524,7 +523,7 @@ impl PrimitiveStore {
524
523
let metadata = PrimitiveMetadata {
525
524
is_opaque : false ,
526
525
mask_texture_id : TextureId :: invalid ( ) ,
527
- clip_index : clip_index ,
526
+ clip_index : None ,
528
527
clip_source : clip_source,
529
528
prim_kind : PrimitiveKind :: BoxShadow ,
530
529
cpu_prim_index : SpecificPrimitiveIndex :: invalid ( ) ,
@@ -679,42 +678,45 @@ impl PrimitiveStore {
679
678
let metadata = & mut self . cpu_metadata [ prim_index. 0 ] ;
680
679
let mut prim_needs_resolve = false ;
681
680
let mut rebuild_bounding_rect = false ;
682
- if let & PrimitiveClipSource :: Region ( ClipRegion { image_mask : Some ( mask) , .. } ) = metadata. clip_source . as_ref ( ) {
683
- resource_cache. request_image ( mask. image , ImageRendering :: Auto ) ;
684
- prim_needs_resolve = true ;
685
- }
686
- if let Some ( gpu_address) = metadata. clip_index {
681
+
682
+ if metadata. clip_index . is_none ( ) {
683
+ // if the `clip_index` already exist, we consider the contents up to date
687
684
let clip_data = match metadata. clip_source . as_ref ( ) {
688
- & PrimitiveClipSource :: NoClip => {
689
- let local_rect = self . gpu_geometry . get ( GpuStoreAddress ( prim_index. 0 as i32 ) )
690
- . local_clip_rect ;
691
- ClipData :: uniform ( local_rect, 0.0 )
692
- }
685
+ & PrimitiveClipSource :: NoClip => None ,
693
686
& PrimitiveClipSource :: Complex ( rect, radius) => {
694
- ClipData :: uniform ( rect, radius)
687
+ Some ( ClipData :: uniform ( rect, radius) )
695
688
}
696
689
& PrimitiveClipSource :: Region ( ref clip_region) => {
690
+ if let Some ( mask) = clip_region. image_mask {
691
+ resource_cache. request_image ( mask. image , ImageRendering :: Auto ) ;
692
+ }
697
693
let clips = auxiliary_lists. complex_clip_regions ( & clip_region. complex ) ;
698
694
//TODO: proper solution to multiple complex clips
699
695
match clips. len ( ) {
700
- 0 => ClipData :: uniform ( clip_region. main , 0.0 ) ,
701
- 1 => ClipData :: from_clip_region ( & clips[ 0 ] ) ,
696
+ 0 if clip_region. image_mask . is_none ( ) => None ,
697
+ 0 => Some ( ClipData :: uniform ( clip_region. main , 0.0 ) ) ,
698
+ 1 => Some ( ClipData :: from_clip_region ( & clips[ 0 ] ) ) ,
702
699
_ => {
703
700
let internal_clip = clips. last ( ) . unwrap ( ) ;
704
701
let region = if clips. iter ( ) . all ( |current_clip| current_clip. might_contain ( internal_clip) ) {
705
702
internal_clip
706
703
} else {
707
704
& clips[ 0 ]
708
705
} ;
709
- ClipData :: from_clip_region ( region)
706
+ Some ( ClipData :: from_clip_region ( region) )
710
707
} ,
711
708
}
712
709
}
713
710
} ;
714
711
715
- metadata. mask_texture_id = dummy_mask_cache_item. texture_id ;
716
- let gpu_data = self . gpu_data32 . get_slice_mut ( gpu_address, 6 ) ;
717
- Self :: populate_clip_data ( gpu_data, clip_data) ;
712
+ if let Some ( data) = clip_data {
713
+ prim_needs_resolve = true ;
714
+ let gpu_address = self . gpu_data32 . alloc ( 6 ) ;
715
+ let gpu_data = self . gpu_data32 . get_slice_mut ( gpu_address, 6 ) ;
716
+ Self :: populate_clip_data ( gpu_data, data) ;
717
+ metadata. clip_index = Some ( gpu_address) ;
718
+ metadata. mask_texture_id = dummy_mask_cache_item. texture_id ;
719
+ }
718
720
}
719
721
720
722
match metadata. prim_kind {
0 commit comments