@@ -87,7 +87,7 @@ impl Cache {
8787 let _ = self . raster . pending . insert ( handle. id ( ) , vec ! [ callback] ) ;
8888
8989 #[ cfg( not( target_arch = "wasm32" ) ) ]
90- self . worker . load ( handle) ;
90+ self . worker . load ( handle, true ) ;
9191 }
9292
9393 #[ cfg( feature = "image" ) ]
@@ -307,7 +307,7 @@ impl Cache {
307307 }
308308
309309 #[ cfg( feature = "image" ) ]
310- fn receive ( & mut self ) {
310+ pub fn receive ( & mut self ) {
311311 #[ cfg( not( target_arch = "wasm32" ) ) ]
312312 while let Ok ( work) = self . worker . try_recv ( ) {
313313 use crate :: image:: raster:: Memory ;
@@ -401,7 +401,7 @@ fn load_image<'a>(
401401 let _ = pending. insert ( handle. id ( ) , Vec :: from_iter ( callback) ) ;
402402
403403 #[ cfg( not( target_arch = "wasm32" ) ) ]
404- worker. load ( handle) ;
404+ worker. load ( handle, false ) ;
405405 }
406406 }
407407
@@ -460,8 +460,11 @@ mod worker {
460460 }
461461 }
462462
463- pub fn load ( & self , handle : & image:: Handle ) {
464- let _ = self . jobs . send ( Job :: Load ( handle. clone ( ) ) ) ;
463+ pub fn load ( & self , handle : & image:: Handle , is_allocation : bool ) {
464+ let _ = self . jobs . send ( Job :: Load {
465+ handle : handle. clone ( ) ,
466+ is_allocation,
467+ } ) ;
465468 }
466469
467470 pub fn upload ( & self , handle : & image:: Handle , image : raster:: Image ) {
@@ -502,7 +505,10 @@ mod worker {
502505
503506 #[ derive( Debug ) ]
504507 enum Job {
505- Load ( image:: Handle ) ,
508+ Load {
509+ handle : image:: Handle ,
510+ is_allocation : bool ,
511+ } ,
506512 Upload {
507513 handle : image:: Handle ,
508514 rgba : image:: Bytes ,
@@ -537,22 +543,26 @@ mod worker {
537543 } ;
538544
539545 match job {
540- Job :: Load ( handle) => {
541- match crate :: graphics:: image:: load ( & handle) {
542- Ok ( image) => self . upload (
543- handle,
544- image. width ( ) ,
545- image. height ( ) ,
546- image. into_raw ( ) ,
547- Shell :: invalidate_layout,
548- ) ,
549- Err ( error) => {
550- let _ = self
551- . output
552- . send ( Work :: Error { handle, error } ) ;
553- }
546+ Job :: Load {
547+ handle,
548+ is_allocation,
549+ } => match crate :: graphics:: image:: load ( & handle) {
550+ Ok ( image) => self . upload (
551+ handle,
552+ image. width ( ) ,
553+ image. height ( ) ,
554+ image. into_raw ( ) ,
555+ if is_allocation {
556+ Shell :: tick
557+ } else {
558+ Shell :: invalidate_layout
559+ } ,
560+ ) ,
561+ Err ( error) => {
562+ let _ =
563+ self . output . send ( Work :: Error { handle, error } ) ;
554564 }
555- }
565+ } ,
556566 Job :: Upload {
557567 handle,
558568 rgba,
0 commit comments