mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
task -> thread
This commit is contained in:
parent
f00532bab0
commit
1f02c4ebbb
119 changed files with 1209 additions and 1207 deletions
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Data needed by the layout task.
|
||||
//! Data needed by the layout thread.
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
|
@ -10,13 +10,13 @@ use app_units::Au;
|
|||
use canvas_traits::CanvasMsg;
|
||||
use euclid::Rect;
|
||||
use fnv::FnvHasher;
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use gfx::font_context::FontContext;
|
||||
use gfx_traits::LayerId;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageResponse, ImageState};
|
||||
use net_traits::image_cache_task::{UsePlaceholder};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
|
||||
use net_traits::image_cache_thread::{UsePlaceholder};
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_state::DefaultState;
|
||||
|
@ -59,13 +59,13 @@ fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext)
|
|||
}
|
||||
context
|
||||
} else {
|
||||
let font_cache_task = shared_layout_context.font_cache_task.lock().unwrap().clone();
|
||||
let font_cache_thread = shared_layout_context.font_cache_thread.lock().unwrap().clone();
|
||||
let context = Rc::new(LocalLayoutContext {
|
||||
style_context: LocalStyleContext {
|
||||
applicable_declarations_cache: RefCell::new(ApplicableDeclarationsCache::new()),
|
||||
style_sharing_candidate_cache: RefCell::new(StyleSharingCandidateCache::new()),
|
||||
},
|
||||
font_context: RefCell::new(FontContext::new(font_cache_task)),
|
||||
font_context: RefCell::new(FontContext::new(font_cache_thread)),
|
||||
});
|
||||
*r = Some(context.clone());
|
||||
context
|
||||
|
@ -78,19 +78,19 @@ pub struct SharedLayoutContext {
|
|||
/// Bits shared by the layout and style system.
|
||||
pub style_context: SharedStyleContext,
|
||||
|
||||
/// The shared image cache task.
|
||||
pub image_cache_task: ImageCacheTask,
|
||||
/// The shared image cache thread.
|
||||
pub image_cache_thread: ImageCacheThread,
|
||||
|
||||
/// A channel for the image cache to send responses to.
|
||||
pub image_cache_sender: Mutex<ImageCacheChan>,
|
||||
|
||||
/// Interface to the font cache task.
|
||||
pub font_cache_task: Mutex<FontCacheTask>,
|
||||
/// Interface to the font cache thread.
|
||||
pub font_cache_thread: Mutex<FontCacheThread>,
|
||||
|
||||
/// The URL.
|
||||
pub url: Url,
|
||||
|
||||
/// A channel to send canvas renderers to paint task, in order to correctly paint the layers
|
||||
/// A channel to send canvas renderers to paint thread, in order to correctly paint the layers
|
||||
pub canvas_layers_sender: Mutex<Sender<(LayerId, IpcSender<CanvasMsg>)>>,
|
||||
|
||||
/// The visible rects for each layer, as reported to us by the compositor.
|
||||
|
@ -131,7 +131,7 @@ impl<'a> LayoutContext<'a> {
|
|||
pub fn get_or_request_image(&self, url: Url, use_placeholder: UsePlaceholder)
|
||||
-> Option<Arc<Image>> {
|
||||
// See if the image is already available
|
||||
let result = self.shared.image_cache_task.find_image(url.clone(),
|
||||
let result = self.shared.image_cache_thread.find_image(url.clone(),
|
||||
use_placeholder);
|
||||
|
||||
match result {
|
||||
|
@ -148,7 +148,7 @@ impl<'a> LayoutContext<'a> {
|
|||
// Not loaded, test mode - load the image synchronously
|
||||
(_, true) => {
|
||||
let (sync_tx, sync_rx) = ipc::channel().unwrap();
|
||||
self.shared.image_cache_task.request_image(url,
|
||||
self.shared.image_cache_thread.request_image(url,
|
||||
ImageCacheChan(sync_tx),
|
||||
None);
|
||||
match sync_rx.recv().unwrap().image_response {
|
||||
|
@ -160,7 +160,7 @@ impl<'a> LayoutContext<'a> {
|
|||
// Not yet requested, async mode - request image from the cache
|
||||
(ImageState::NotRequested, false) => {
|
||||
let sender = self.shared.image_cache_sender.lock().unwrap().clone();
|
||||
self.shared.image_cache_task.request_image(url, sender, None);
|
||||
self.shared.image_cache_thread.request_image(url, sender, None);
|
||||
None
|
||||
}
|
||||
// Image has been requested, is still pending. Return no image
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue