mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
servo: Merge #7875 - Move code to exit servo after writing a screenshot out of composite_specific_target (from jgraham:composite_no_exit); r=glennw
The structure of this function was confusing, so move some parts out into the caller where they seem like a more natural fit and add documentation of the functions Source-Repo: https://github.com/servo/servo Source-Revision: e7f73fdfd822fc2f0d3c239a428c739232bdfd12
This commit is contained in:
parent
8ff28f34dd
commit
6148e472ce
@ -488,7 +488,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
}
|
||||
|
||||
(Msg::CreatePng(reply), ShutdownState::NotShuttingDown) => {
|
||||
let img = self.composite_specific_target(CompositeTarget::WindowAndPng);
|
||||
let res = self.composite_specific_target(CompositeTarget::WindowAndPng);
|
||||
let img = res.unwrap_or(None);
|
||||
reply.send(img).unwrap();
|
||||
}
|
||||
|
||||
@ -1544,28 +1545,41 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
|
||||
fn composite(&mut self) {
|
||||
let target = self.composite_target;
|
||||
self.composite_specific_target(target);
|
||||
let composited = self.composite_specific_target(target);
|
||||
if composited.is_ok() &&
|
||||
(opts::get().output_file.is_some() || opts::get().exit_after_load) {
|
||||
debug!("shutting down the constellation (after generating an output file or exit flag specified)");
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
chan.send(ConstellationMsg::Exit).unwrap();
|
||||
self.shutdown_state = ShutdownState::ShuttingDown;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn composite_specific_target(&mut self, target: CompositeTarget) -> Option<png::Image> {
|
||||
/// Composite either to the screen or to a png image or both.
|
||||
/// Returns Ok if composition was performed or Err if it was not possible to composite
|
||||
/// for some reason. If CompositeTarget is Window or Png no image data is returned;
|
||||
/// in the latter case the image is written directly to a file. If CompositeTarget
|
||||
/// is WindowAndPng Ok(Some(png::Image)) is returned.
|
||||
pub fn composite_specific_target(&mut self, target: CompositeTarget) -> Result<Option<png::Image>, ()> {
|
||||
|
||||
if !self.context.is_some() {
|
||||
return None
|
||||
return Err(())
|
||||
}
|
||||
let (width, height) =
|
||||
(self.window_size.width.get() as usize, self.window_size.height.get() as usize);
|
||||
if !self.window.prepare_for_composite(width, height) {
|
||||
return None
|
||||
return Err(())
|
||||
}
|
||||
|
||||
match target {
|
||||
CompositeTarget::WindowAndPng | CompositeTarget::PngFile => {
|
||||
if !self.is_ready_to_paint_image_output() {
|
||||
return None
|
||||
return Err(())
|
||||
}
|
||||
}
|
||||
CompositeTarget::Window => {
|
||||
if opts::get().exit_after_load && !self.is_ready_to_paint_image_output() {
|
||||
return None
|
||||
return Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1609,13 +1623,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
}
|
||||
};
|
||||
|
||||
if opts::get().output_file.is_some() || opts::get().exit_after_load {
|
||||
debug!("shutting down the constellation (after generating an output file or exit flag specified)");
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
chan.send(ConstellationMsg::Exit).unwrap();
|
||||
self.shutdown_state = ShutdownState::ShuttingDown;
|
||||
}
|
||||
|
||||
// Perform the page flip. This will likely block for a while.
|
||||
self.window.present();
|
||||
|
||||
@ -1624,7 +1631,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
self.composition_request = CompositionRequest::NoCompositingNecessary;
|
||||
self.process_pending_scroll_events();
|
||||
self.process_animations();
|
||||
rv
|
||||
|
||||
Ok(rv)
|
||||
}
|
||||
|
||||
fn draw_png(&self,
|
||||
|
Loading…
Reference in New Issue
Block a user