struct ImageCacheStore {
pending_loads: AllPendingLoads,
completed_loads: HashMap<(ServoUrl, ImmutableOrigin, Option<CorsSettings>), CompletedLoad>,
vector_images: FxHashMap<PendingImageId, VectorImageData>,
rasterized_vector_images: FxHashMap<(PendingImageId, DeviceIntSize), RasterizationTask>,
placeholder_image: Arc<RasterImage>,
placeholder_url: ServoUrl,
compositor_api: CrossProcessCompositorApi,
pipeline_id: Option<PipelineId>,
key_cache: KeyCache,
}
Expand description
§Image cache implementation.
Fields§
§pending_loads: AllPendingLoads
Images that are loading over network, or decoding.
completed_loads: HashMap<(ServoUrl, ImmutableOrigin, Option<CorsSettings>), CompletedLoad>
Images that have finished loading (successful or not)
vector_images: FxHashMap<PendingImageId, VectorImageData>
Vector (e.g. SVG) images that have been sucessfully loaded and parsed but are yet to be rasterized. Since the same SVG data can be used for rasterizing at different sizes, we use this hasmap to share the data.
rasterized_vector_images: FxHashMap<(PendingImageId, DeviceIntSize), RasterizationTask>
Vector images for which rasterization at a particular size has started
or completed. If completed, the result
member of RasterizationTask
contains the rasterized image.
placeholder_image: Arc<RasterImage>
The placeholder image used when an image fails to load
placeholder_url: ServoUrl
The URL used for the placeholder image
compositor_api: CrossProcessCompositorApi
Cross-process compositor API instance.
pipeline_id: Option<PipelineId>
§key_cache: KeyCache
Main struct to handle the cache of WebRenderImageKey
and
images that do not have a key yet.
Implementations§
Source§impl ImageCacheStore
impl ImageCacheStore
Sourcefn set_key_and_finish_load(
&mut self,
pending_image: PendingKey,
image_key: WebRenderImageKey,
)
fn set_key_and_finish_load( &mut self, pending_image: PendingKey, image_key: WebRenderImageKey, )
Finishes loading the image by setting the WebRenderImageKey and calling compete_load
or complete_load_svg
.
Sourcefn load_image_with_keycache(&mut self, pending_image: PendingKey)
fn load_image_with_keycache(&mut self, pending_image: PendingKey)
If a key is available the image will be immediately loaded, otherwise it will load then the next batch of
keys is received. Only call this if the image does not have a LoadKey
yet.
Sourcefn insert_keys_and_load_images(&mut self, image_keys: Vec<WebRenderImageKey>)
fn insert_keys_and_load_images(&mut self, image_keys: Vec<WebRenderImageKey>)
Insert received keys into the cache and complete the loading of images.
Sourcefn complete_load_svg(
&mut self,
rasterized_image: RasterImage,
pending_image_id: PendingImageId,
requested_size: DeviceIntSize,
)
fn complete_load_svg( &mut self, rasterized_image: RasterImage, pending_image_id: PendingImageId, requested_size: DeviceIntSize, )
Complete the loading the of the rasterized svg image. This needs the RasterImage
to
already have a WebRenderImageKey
.
Sourcefn complete_load(&mut self, key: PendingImageId, load_result: LoadResult)
fn complete_load(&mut self, key: PendingImageId, load_result: LoadResult)
The rest of complete load. This requires that images have a valid WebRenderImageKey
.
Sourcefn get_completed_image_if_available(
&self,
url: ServoUrl,
origin: ImmutableOrigin,
cors_setting: Option<CorsSettings>,
placeholder: UsePlaceholder,
) -> Option<Result<(Image, ServoUrl), ()>>
fn get_completed_image_if_available( &self, url: ServoUrl, origin: ImmutableOrigin, cors_setting: Option<CorsSettings>, placeholder: UsePlaceholder, ) -> Option<Result<(Image, ServoUrl), ()>>
Return a completed image if it exists, or None if there is no complete load or the complete load is not fully decoded or is unavailable.
Sourcefn handle_decoder(&mut self, msg: DecoderMsg)
fn handle_decoder(&mut self, msg: DecoderMsg)
Handle a message from one of the decoder worker threads or from a sync decoding operation.
Trait Implementations§
Source§impl Drop for ImageCacheStore
impl Drop for ImageCacheStore
Source§impl MallocSizeOf for ImageCacheStore
impl MallocSizeOf for ImageCacheStore
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl Freeze for ImageCacheStore
impl !RefUnwindSafe for ImageCacheStore
impl Send for ImageCacheStore
impl !Sync for ImageCacheStore
impl Unpin for ImageCacheStore
impl !UnwindSafe for ImageCacheStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more