Make image cache per-document rather than global

This commit is contained in:
Fernando Jiménez Moreno 2017-03-16 11:08:09 +01:00
parent 9eb6bb78b0
commit 72d7ee613b
25 changed files with 448 additions and 649 deletions

View file

@ -17,7 +17,7 @@ use ipc_channel::router::ROUTER;
use layout_traits::LayoutThreadFactory;
use msg::constellation_msg::{FrameId, FrameType, PipelineId, PipelineNamespaceId};
use net_traits::{IpcSend, ResourceThreads};
use net_traits::image_cache_thread::ImageCacheThread;
use net_traits::image_cache::ImageCache;
use profile_traits::mem as profile_mem;
use profile_traits::time;
use script_traits::{ConstellationControlMsg, DevicePixel, DiscardBrowsingContext};
@ -133,9 +133,6 @@ pub struct InitialPipelineState {
/// A channel to the service worker manager thread
pub swmanager_thread: IpcSender<SWManagerMsg>,
/// A channel to the image cache thread.
pub image_cache_thread: ImageCacheThread,
/// A channel to the font cache thread.
pub font_cache_thread: FontCacheThread,
@ -250,7 +247,6 @@ impl Pipeline {
devtools_chan: script_to_devtools_chan,
bluetooth_thread: state.bluetooth_thread,
swmanager_thread: state.swmanager_thread,
image_cache_thread: state.image_cache_thread,
font_cache_thread: state.font_cache_thread,
resource_threads: state.resource_threads,
time_profiler_chan: state.time_profiler_chan,
@ -451,7 +447,6 @@ pub struct UnprivilegedPipelineContent {
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
bluetooth_thread: IpcSender<BluetoothRequest>,
swmanager_thread: IpcSender<SWManagerMsg>,
image_cache_thread: ImageCacheThread,
font_cache_thread: FontCacheThread,
resource_threads: ResourceThreads,
time_profiler_chan: time::ProfilerChan,
@ -477,6 +472,7 @@ impl UnprivilegedPipelineContent {
where LTF: LayoutThreadFactory<Message=Message>,
STF: ScriptThreadFactory<Message=Message>
{
let image_cache = ImageCache::new(self.webrender_api_sender.create_api());
let layout_pair = STF::create(InitialScriptState {
id: self.id,
frame_id: self.frame_id,
@ -489,7 +485,7 @@ impl UnprivilegedPipelineContent {
scheduler_chan: self.scheduler_chan,
bluetooth_thread: self.bluetooth_thread,
resource_threads: self.resource_threads,
image_cache_thread: self.image_cache_thread.clone(),
image_cache: image_cache.clone(),
time_profiler_chan: self.time_profiler_chan.clone(),
mem_profiler_chan: self.mem_profiler_chan.clone(),
devtools_chan: self.devtools_chan,
@ -507,7 +503,7 @@ impl UnprivilegedPipelineContent {
self.pipeline_port,
self.layout_to_constellation_chan,
self.script_chan,
self.image_cache_thread,
image_cache.clone(),
self.font_cache_thread,
self.time_profiler_chan,
self.mem_profiler_chan,