pub trait ImageCache: Sync + Send {
// Required methods
fn new(
compositor_api: CrossProcessCompositorApi,
rippy_data: Vec<u8>,
) -> Self
where Self: Sized;
fn memory_report(&self, prefix: &str, ops: &mut MallocSizeOfOps) -> Report;
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>,
use_placeholder: UsePlaceholder,
) -> ImageCacheResult;
fn rasterize_vector_image(
&self,
image_id: VectorImageId,
size: DeviceIntSize,
) -> Option<RasterImage>;
fn add_rasterization_complete_listener(
&self,
pipeline_id: PipelineId,
image_id: VectorImageId,
size: DeviceIntSize,
sender: IpcSender<ImageCacheResponseMessage>,
);
fn add_listener(&self, listener: ImageLoadListener);
fn notify_pending_response(
&self,
id: PendingImageId,
action: FetchResponseMsg,
);
fn create_new_image_cache(
&self,
compositor_api: CrossProcessCompositorApi,
) -> Arc<dyn ImageCache>;
}
Required Methods§
fn new(compositor_api: CrossProcessCompositorApi, rippy_data: Vec<u8>) -> Selfwhere
Self: Sized,
fn memory_report(&self, prefix: &str, ops: &mut MallocSizeOfOps) -> Report
Sourcefn get_image(
&self,
url: ServoUrl,
origin: ImmutableOrigin,
cors_setting: Option<CorsSettings>,
) -> Option<Image>
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.
fn get_cached_image_status( &self, url: ServoUrl, origin: ImmutableOrigin, cors_setting: Option<CorsSettings>, use_placeholder: UsePlaceholder, ) -> ImageCacheResult
Sourcefn rasterize_vector_image(
&self,
image_id: VectorImageId,
size: DeviceIntSize,
) -> Option<RasterImage>
fn rasterize_vector_image( &self, image_id: VectorImageId, size: DeviceIntSize, ) -> 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.
Sourcefn add_rasterization_complete_listener(
&self,
pipeline_id: PipelineId,
image_id: VectorImageId,
size: DeviceIntSize,
sender: IpcSender<ImageCacheResponseMessage>,
)
fn add_rasterization_complete_listener( &self, pipeline_id: PipelineId, image_id: VectorImageId, size: DeviceIntSize, sender: IpcSender<ImageCacheResponseMessage>, )
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.
Sourcefn add_listener(&self, listener: ImageLoadListener)
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.
Sourcefn notify_pending_response(&self, id: PendingImageId, action: FetchResponseMsg)
fn notify_pending_response(&self, id: PendingImageId, action: FetchResponseMsg)
Inform the image cache about a response for a pending request.
Sourcefn create_new_image_cache(
&self,
compositor_api: CrossProcessCompositorApi,
) -> Arc<dyn ImageCache>
fn create_new_image_cache( &self, compositor_api: CrossProcessCompositorApi, ) -> Arc<dyn ImageCache>
Create new image cache based on this one, while reusing the existing thread_pool.