@@ -516,6 +516,8 @@ pub struct ResourceCache {
516516 /// Over time it would be better to handle each of these cases explicitly
517517 /// and make it a hard error to fail to snapshot a stacking context.
518518 fallback_handle : TextureCacheHandle ,
519+ debug_fallback_panic : bool ,
520+ debug_fallback_pink : bool ,
519521}
520522
521523impl ResourceCache {
@@ -554,6 +556,8 @@ impl ResourceCache {
554556 font_templates_memory : 0 ,
555557 render_target_pool : Vec :: new ( ) ,
556558 fallback_handle : TextureCacheHandle :: invalid ( ) ,
559+ debug_fallback_panic : false ,
560+ debug_fallback_pink : false ,
557561 }
558562 }
559563
@@ -1367,6 +1371,9 @@ impl ResourceCache {
13671371 if self . resources . image_templates
13681372 . get ( request. key )
13691373 . map_or ( false , |img| img. data . is_snapshot ( ) ) {
1374+ if self . debug_fallback_panic {
1375+ panic ! ( "Missing snapshot image" ) ;
1376+ }
13701377 return self . get_texture_cache_item ( & self . fallback_handle ) ;
13711378 }
13721379
@@ -1514,6 +1521,11 @@ impl ResourceCache {
15141521 profile_scope ! ( "update_texture_cache" ) ;
15151522
15161523 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+ } ;
15171529 self . texture_cache . update (
15181530 & mut self . fallback_handle ,
15191531 ImageDescriptor {
@@ -1524,7 +1536,7 @@ impl ResourceCache {
15241536 offset : 0 ,
15251537 } ,
15261538 TextureFilter :: Linear ,
1527- Some ( CachedImageData :: Raw ( Arc :: new ( vec ! [ 0 , 0 , 0 , 0 ] ) ) ) ,
1539+ Some ( CachedImageData :: Raw ( Arc :: new ( fallback_color ) ) ) ,
15281540 [ 0.0 ; 4 ] ,
15291541 DirtyRect :: All ,
15301542 gpu_cache,
@@ -1808,6 +1820,13 @@ impl ResourceCache {
18081820 GLYPH_FLASHING . store ( flags. contains ( DebugFlags :: GLYPH_FLASHING ) , std:: sync:: atomic:: Ordering :: Relaxed ) ;
18091821 self . texture_cache . set_debug_flags ( flags) ;
18101822 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;
18111830 }
18121831
18131832 pub fn clear ( & mut self , what : ClearCache ) {
0 commit comments