Cache initial pages directly with best resolution
This commit is contained in:
parent
78bc8b1e64
commit
1e6b9fc337
16
src/cache.rs
16
src/cache.rs
@ -182,6 +182,7 @@ pub enum CacheResponse {
|
|||||||
pub struct SyncCacheCommandChannel {
|
pub struct SyncCacheCommandChannel {
|
||||||
retrieve_commands: Vec<RetrievePagesCommand>,
|
retrieve_commands: Vec<RetrievePagesCommand>,
|
||||||
cache_commands: VecDeque<CachePageCommand>,
|
cache_commands: VecDeque<CachePageCommand>,
|
||||||
|
priority_cache_commands: Vec<CachePageCommand>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SyncCacheCommandSender {
|
pub struct SyncCacheCommandSender {
|
||||||
@ -197,6 +198,7 @@ impl SyncCacheCommandChannel {
|
|||||||
let channel = SyncCacheCommandChannel {
|
let channel = SyncCacheCommandChannel {
|
||||||
retrieve_commands: Vec::new(),
|
retrieve_commands: Vec::new(),
|
||||||
cache_commands: VecDeque::new(),
|
cache_commands: VecDeque::new(),
|
||||||
|
priority_cache_commands: Vec::new(),
|
||||||
};
|
};
|
||||||
let channel = Rc::new(RefCell::new(channel));
|
let channel = Rc::new(RefCell::new(channel));
|
||||||
|
|
||||||
@ -218,6 +220,16 @@ impl SyncCacheCommandSender {
|
|||||||
self.channel.borrow_mut().retrieve_commands.push(command);
|
self.channel.borrow_mut().retrieve_commands.push(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn send_priority_cache_commands(&self, pages: &[PageNumber], height: i32) {
|
||||||
|
for &page in pages {
|
||||||
|
// Make message in front the most important
|
||||||
|
self.channel
|
||||||
|
.borrow_mut()
|
||||||
|
.priority_cache_commands
|
||||||
|
.push(CachePageCommand { page, height });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn send_cache_commands(&self, pages: &[PageNumber], height: i32) {
|
pub fn send_cache_commands(&self, pages: &[PageNumber], height: i32) {
|
||||||
for &page in pages {
|
for &page in pages {
|
||||||
// Make message in front the most important
|
// Make message in front the most important
|
||||||
@ -240,7 +252,9 @@ impl SyncCacheCommandReceiver {
|
|||||||
|
|
||||||
pub fn receive_most_important_command(&self) -> Option<CacheCommand> {
|
pub fn receive_most_important_command(&self) -> Option<CacheCommand> {
|
||||||
let mut channel = self.channel.borrow_mut();
|
let mut channel = self.channel.borrow_mut();
|
||||||
if let Some(command) = channel.retrieve_commands.pop() {
|
if let Some(command) = channel.priority_cache_commands.pop() {
|
||||||
|
return Some(CacheCommand::Cache(command));
|
||||||
|
} else if let Some(command) = channel.retrieve_commands.pop() {
|
||||||
return Some(CacheCommand::Retrieve(command));
|
return Some(CacheCommand::Retrieve(command));
|
||||||
} else if let Some(command) = channel.cache_commands.pop_front() {
|
} else if let Some(command) = channel.cache_commands.pop_front() {
|
||||||
return Some(CacheCommand::Cache(command));
|
return Some(CacheCommand::Cache(command));
|
||||||
|
@ -54,7 +54,7 @@ impl DocumentCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn cache_initial_pages(&self, area_height: i32) {
|
pub fn cache_initial_pages(&self, area_height: i32) {
|
||||||
self.page_cache_sender.send_cache_commands(
|
self.page_cache_sender.send_priority_cache_commands(
|
||||||
&vec![self.current_page_number, self.current_page_number + 1],
|
&vec![self.current_page_number, self.current_page_number + 1],
|
||||||
area_height,
|
area_height,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user