Skip to main content

ImageCache

Trait ImageCache 

Source
pub trait ImageCache: Sync + Send {
Show 13 methods // Required methods fn memory_reports( &self, prefix: &str, ops: &mut MallocSizeOfOps, ) -> Vec<Report>; fn get_image_key(&self) -> Option<ImageKey>; fn get_image( &self, url: ServoUrl, origin: ImmutableOrigin, cors_setting: Option<CorsSettings>, ) -> Option<Image>; fn get_cached_image_status( &self, url: ServoUrl, origin: ImmutableOrigin, cors_setting: Option<CorsSettings>, ) -> ImageCacheResult; fn rasterize_vector_image( &self, image_id: VectorImageId, size: DeviceIntSize, svg_id: Option<String>, ) -> Option<RasterImage>; fn add_rasterization_complete_listener( &self, pipeline_id: PipelineId, image_id: VectorImageId, size: DeviceIntSize, callback: ImageCacheResponseCallback, ); fn evict_rasterized_image(&self, svg_id: &str); fn evict_completed_image( &self, url: &ServoUrl, origin: &ImmutableOrigin, cors_setting: &Option<CorsSettings>, ); fn get_broken_image_icon(&self) -> Option<Arc<RasterImage>>; fn add_listener(&self, listener: ImageLoadListener); fn notify_pending_response( &self, id: PendingImageId, action: FetchResponseMsg, ); fn fill_key_cache_with_batch_of_keys(&self, image_keys: Vec<ImageKey>); fn clear(&self);
}
Expand description

An ImageCache manages fetching and decoding images for a single Pipeline for its Document and all of its associated Workers.

Required Methods§

Source

fn memory_reports(&self, prefix: &str, ops: &mut MallocSizeOfOps) -> Vec<Report>

Source

fn get_image_key(&self) -> Option<ImageKey>

Get an ImageKey to be used for external WebRender image management for things like canvas rendering. Returns None when an ImageKey cannot be generated properly.

Source

fn get_image( &self, url: ServoUrl, origin: ImmutableOrigin, cors_setting: Option<CorsSettings>, ) -> Option<Image>

Definitively check whether there is a cached, fully loaded image available.

Source

fn get_cached_image_status( &self, url: ServoUrl, origin: ImmutableOrigin, cors_setting: Option<CorsSettings>, ) -> ImageCacheResult

Source

fn rasterize_vector_image( &self, image_id: VectorImageId, size: DeviceIntSize, svg_id: Option<String>, ) -> Option<RasterImage>

Returns Some if the given image_id has already been rasterized at the given size. Otherwise, triggers a new job to perform the rasterization. If a notification is needed after rasterization is completed, the add_rasterization_complete_listener API below can be used to add a listener.

Source

fn add_rasterization_complete_listener( &self, pipeline_id: PipelineId, image_id: VectorImageId, size: DeviceIntSize, callback: ImageCacheResponseCallback, )

Adds a new listener to be notified once the given image_id has been rasterized at the given size. The listener will receive a VectorImageRasterizationComplete message on the given sender, even if the listener is called after rasterization at has already completed.

Source

fn evict_rasterized_image(&self, svg_id: &str)

Removes the rasterized image from the image_cache, identified by the id of the SVG

Source

fn evict_completed_image( &self, url: &ServoUrl, origin: &ImmutableOrigin, cors_setting: &Option<CorsSettings>, )

Removes the completed image from the image_cache, identified by url, origin, and cors

Source

fn get_broken_image_icon(&self) -> Option<Arc<RasterImage>>

Synchronously get the broken image icon for this ImageCache. This will allocate space for this icon and upload it to WebRender.

Source

fn add_listener(&self, listener: ImageLoadListener)

Add a new listener for the given pending image id. If the image is already present, the responder will still receive the expected response.

Source

fn notify_pending_response(&self, id: PendingImageId, action: FetchResponseMsg)

Inform the image cache about a response for a pending request.

Source

fn fill_key_cache_with_batch_of_keys(&self, image_keys: Vec<ImageKey>)

Fills the image cache with a batch of keys.

Source

fn clear(&self)

Clear the image cache.

Implementors§