mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Make image cache per-document rather than global
This commit is contained in:
parent
9eb6bb78b0
commit
72d7ee613b
25 changed files with 448 additions and 649 deletions
|
@ -9,8 +9,8 @@ use gfx::display_list::{WebRenderImageInfo, OpaqueNode};
|
|||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::font_context::FontContext;
|
||||
use heapsize::HeapSizeOf;
|
||||
use net_traits::image_cache_thread::{ImageCacheThread, ImageState, CanRequestImages};
|
||||
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||
use net_traits::image_cache::{CanRequestImages, ImageCache, ImageState};
|
||||
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||
use opaque_node::OpaqueNodeMethods;
|
||||
use parking_lot::RwLock;
|
||||
use script_layout_interface::{PendingImage, PendingImageState};
|
||||
|
@ -79,8 +79,8 @@ pub struct LayoutContext<'a> {
|
|||
/// Bits shared by the layout and style system.
|
||||
pub style_context: SharedStyleContext<'a>,
|
||||
|
||||
/// The shared image cache thread.
|
||||
pub image_cache_thread: Mutex<ImageCacheThread>,
|
||||
/// Reference to the script thread image cache.
|
||||
pub image_cache: Arc<ImageCache>,
|
||||
|
||||
/// Interface to the font cache thread.
|
||||
pub font_cache_thread: Mutex<FontCacheThread>,
|
||||
|
@ -126,10 +126,9 @@ impl<'a> LayoutContext<'a> {
|
|||
};
|
||||
|
||||
// See if the image is already available
|
||||
let result = self.image_cache_thread.lock().unwrap()
|
||||
.find_image_or_metadata(url.clone(),
|
||||
use_placeholder,
|
||||
can_request);
|
||||
let result = self.image_cache.find_image_or_metadata(url.clone(),
|
||||
use_placeholder,
|
||||
can_request);
|
||||
match result {
|
||||
Ok(image_or_metadata) => Some(image_or_metadata),
|
||||
// Image failed to load, so just return nothing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue