@@ -516,6 +516,8 @@ pub struct ResourceCache {
516
516
/// Over time it would be better to handle each of these cases explicitly
517
517
/// and make it a hard error to fail to snapshot a stacking context.
518
518
fallback_handle : TextureCacheHandle ,
519
+ debug_fallback_panic : bool ,
520
+ debug_fallback_pink : bool ,
519
521
}
520
522
521
523
impl ResourceCache {
@@ -554,6 +556,8 @@ impl ResourceCache {
554
556
font_templates_memory : 0 ,
555
557
render_target_pool : Vec :: new ( ) ,
556
558
fallback_handle : TextureCacheHandle :: invalid ( ) ,
559
+ debug_fallback_panic : false ,
560
+ debug_fallback_pink : false ,
557
561
}
558
562
}
559
563
@@ -1367,6 +1371,9 @@ impl ResourceCache {
1367
1371
if self . resources . image_templates
1368
1372
. get ( request. key )
1369
1373
. map_or ( false , |img| img. data . is_snapshot ( ) ) {
1374
+ if self . debug_fallback_panic {
1375
+ panic ! ( "Missing snapshot image" ) ;
1376
+ }
1370
1377
return self . get_texture_cache_item ( & self . fallback_handle ) ;
1371
1378
}
1372
1379
@@ -1514,6 +1521,11 @@ impl ResourceCache {
1514
1521
profile_scope ! ( "update_texture_cache" ) ;
1515
1522
1516
1523
if self . fallback_handle == TextureCacheHandle :: invalid ( ) {
1524
+ let fallback_color = if self . debug_fallback_pink {
1525
+ vec ! [ 255 , 0 , 255 , 255 ]
1526
+ } else {
1527
+ vec ! [ 0 , 0 , 0 , 0 ]
1528
+ } ;
1517
1529
self . texture_cache . update (
1518
1530
& mut self . fallback_handle ,
1519
1531
ImageDescriptor {
@@ -1524,7 +1536,7 @@ impl ResourceCache {
1524
1536
offset : 0 ,
1525
1537
} ,
1526
1538
TextureFilter :: Linear ,
1527
- Some ( CachedImageData :: Raw ( Arc :: new ( vec ! [ 0 , 0 , 0 , 0 ] ) ) ) ,
1539
+ Some ( CachedImageData :: Raw ( Arc :: new ( fallback_color ) ) ) ,
1528
1540
[ 0.0 ; 4 ] ,
1529
1541
DirtyRect :: All ,
1530
1542
gpu_cache,
@@ -1808,6 +1820,13 @@ impl ResourceCache {
1808
1820
GLYPH_FLASHING . store ( flags. contains ( DebugFlags :: GLYPH_FLASHING ) , std:: sync:: atomic:: Ordering :: Relaxed ) ;
1809
1821
self . texture_cache . set_debug_flags ( flags) ;
1810
1822
self . picture_textures . set_debug_flags ( flags) ;
1823
+ self . debug_fallback_panic = flags. contains ( DebugFlags :: MISSING_SNAPSHOT_PANIC ) ;
1824
+ let fallback_pink = flags. contains ( DebugFlags :: MISSING_SNAPSHOT_PINK ) ;
1825
+
1826
+ if fallback_pink != self . debug_fallback_pink && self . fallback_handle != TextureCacheHandle :: invalid ( ) {
1827
+ self . texture_cache . evict_handle ( & self . fallback_handle ) ;
1828
+ }
1829
+ self . debug_fallback_pink = fallback_pink;
1811
1830
}
1812
1831
1813
1832
pub fn clear ( & mut self , what : ClearCache ) {
0 commit comments