mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Return None from get_graphics_metadata in headless compositor
This fixes servo -z.
This commit is contained in:
parent
c5db2ab516
commit
4a72abbbb2
6 changed files with 25 additions and 20 deletions
|
@ -8,7 +8,7 @@
|
||||||
url = "http://servo.org/")];
|
url = "http://servo.org/")];
|
||||||
#[crate_type = "lib"];
|
#[crate_type = "lib"];
|
||||||
|
|
||||||
#[feature(globs, managed_boxes)];
|
#[feature(globs, managed_boxes, macro_rules)];
|
||||||
|
|
||||||
extern mod azure;
|
extern mod azure;
|
||||||
extern mod extra;
|
extern mod extra;
|
||||||
|
|
|
@ -107,7 +107,7 @@ pub struct RenderTask<C,T> {
|
||||||
graphics_context: GraphicsContext,
|
graphics_context: GraphicsContext,
|
||||||
|
|
||||||
/// The native graphics context.
|
/// The native graphics context.
|
||||||
native_graphics_context: NativePaintingGraphicsContext,
|
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
||||||
|
|
||||||
/// The layer to be rendered
|
/// The layer to be rendered
|
||||||
render_layer: Option<RenderLayer<T>>,
|
render_layer: Option<RenderLayer<T>>,
|
||||||
|
@ -122,6 +122,14 @@ pub struct RenderTask<C,T> {
|
||||||
buffer_map: BufferMap<~LayerBuffer>,
|
buffer_map: BufferMap<~LayerBuffer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we implement this as a function, we get borrowck errors from borrowing
|
||||||
|
// the whole RenderTask struct.
|
||||||
|
macro_rules! native_graphics_context(
|
||||||
|
($task:expr) => (
|
||||||
|
$task.native_graphics_context.as_ref().expect("Need a graphics context to do rendering")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
||||||
pub fn create(id: PipelineId,
|
pub fn create(id: PipelineId,
|
||||||
port: Port<Msg<T>>,
|
port: Port<Msg<T>>,
|
||||||
|
@ -132,10 +140,9 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
||||||
do spawn_with((port, compositor, constellation_chan, opts, profiler_chan))
|
do spawn_with((port, compositor, constellation_chan, opts, profiler_chan))
|
||||||
|(port, compositor, constellation_chan, opts, profiler_chan)| {
|
|(port, compositor, constellation_chan, opts, profiler_chan)| {
|
||||||
|
|
||||||
let graphics_metadata = compositor.get_graphics_metadata();
|
let native_graphics_context = compositor.get_graphics_metadata().map(
|
||||||
|
|md| NativePaintingGraphicsContext::from_metadata(&md));
|
||||||
let cpu_painting = opts.cpu_painting;
|
let cpu_painting = opts.cpu_painting;
|
||||||
let native_graphics_context =
|
|
||||||
NativePaintingGraphicsContext::from_metadata(&graphics_metadata);
|
|
||||||
|
|
||||||
// FIXME: rust/#5967
|
// FIXME: rust/#5967
|
||||||
let mut render_task = RenderTask {
|
let mut render_task = RenderTask {
|
||||||
|
@ -167,7 +174,7 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
||||||
render_task.start();
|
render_task.start();
|
||||||
|
|
||||||
// Destroy all the buffers.
|
// Destroy all the buffers.
|
||||||
render_task.buffer_map.clear(&render_task.native_graphics_context)
|
render_task.buffer_map.clear(native_graphics_context!(render_task));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +202,7 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
||||||
UnusedBufferMsg(unused_buffers) => {
|
UnusedBufferMsg(unused_buffers) => {
|
||||||
// move_rev_iter is more efficient
|
// move_rev_iter is more efficient
|
||||||
for buffer in unused_buffers.move_rev_iter() {
|
for buffer in unused_buffers.move_rev_iter() {
|
||||||
self.buffer_map.insert(&self.native_graphics_context, buffer);
|
self.buffer_map.insert(native_graphics_context!(self), buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PaintPermissionGranted => {
|
PaintPermissionGranted => {
|
||||||
|
@ -249,7 +256,7 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
||||||
// (texture color buffer, renderbuffers) instead of recreating them.
|
// (texture color buffer, renderbuffers) instead of recreating them.
|
||||||
let draw_target =
|
let draw_target =
|
||||||
DrawTarget::new_with_fbo(self.opts.render_backend,
|
DrawTarget::new_with_fbo(self.opts.render_backend,
|
||||||
&self.native_graphics_context,
|
native_graphics_context!(self),
|
||||||
size,
|
size,
|
||||||
B8G8R8A8);
|
B8G8R8A8);
|
||||||
draw_target.make_current();
|
draw_target.make_current();
|
||||||
|
@ -306,7 +313,7 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
||||||
// in case it dies in transit to the compositor task.
|
// in case it dies in transit to the compositor task.
|
||||||
let mut native_surface: NativeSurface =
|
let mut native_surface: NativeSurface =
|
||||||
layers::platform::surface::NativeSurfaceMethods::new(
|
layers::platform::surface::NativeSurfaceMethods::new(
|
||||||
&self.native_graphics_context,
|
native_graphics_context!(self),
|
||||||
Size2D(width as i32, height as i32),
|
Size2D(width as i32, height as i32),
|
||||||
width as i32 * 4);
|
width as i32 * 4);
|
||||||
native_surface.mark_wont_leak();
|
native_surface.mark_wont_leak();
|
||||||
|
@ -322,7 +329,7 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
|
||||||
};
|
};
|
||||||
|
|
||||||
do draw_target.snapshot().get_data_surface().with_data |data| {
|
do draw_target.snapshot().get_data_surface().with_data |data| {
|
||||||
buffer.native_surface.upload(&self.native_graphics_context, data);
|
buffer.native_surface.upload(native_graphics_context!(self), data);
|
||||||
debug!("RENDERER uploading to native surface {:d}",
|
debug!("RENDERER uploading to native surface {:d}",
|
||||||
buffer.native_surface.get_id() as int);
|
buffer.native_surface.get_id() as int);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl ScriptListener for CompositorChan {
|
||||||
|
|
||||||
/// Implementation of the abstract `RenderListener` interface.
|
/// Implementation of the abstract `RenderListener` interface.
|
||||||
impl RenderListener for CompositorChan {
|
impl RenderListener for CompositorChan {
|
||||||
fn get_graphics_metadata(&self) -> NativeGraphicsMetadata {
|
fn get_graphics_metadata(&self) -> Option<NativeGraphicsMetadata> {
|
||||||
let (port, chan) = comm::stream();
|
let (port, chan) = comm::stream();
|
||||||
self.chan.send(GetGraphicsMetadata(chan));
|
self.chan.send(GetGraphicsMetadata(chan));
|
||||||
port.recv()
|
port.recv()
|
||||||
|
@ -117,7 +117,9 @@ pub enum Msg {
|
||||||
/// Requests the compositor's graphics metadata. Graphics metadata is what the renderer needs
|
/// Requests the compositor's graphics metadata. Graphics metadata is what the renderer needs
|
||||||
/// to create surfaces that the compositor can see. On Linux this is the X display; on Mac this
|
/// to create surfaces that the compositor can see. On Linux this is the X display; on Mac this
|
||||||
/// is the pixel format.
|
/// is the pixel format.
|
||||||
GetGraphicsMetadata(Chan<NativeGraphicsMetadata>),
|
///
|
||||||
|
/// The headless compositor returns `None`.
|
||||||
|
GetGraphicsMetadata(Chan<Option<NativeGraphicsMetadata>>),
|
||||||
|
|
||||||
/// Alerts the compositor that there is a new layer to be rendered.
|
/// Alerts the compositor that there is a new layer to be rendered.
|
||||||
NewLayer(PipelineId, Size2D<f32>),
|
NewLayer(PipelineId, Size2D<f32>),
|
||||||
|
|
|
@ -131,7 +131,7 @@ pub fn run_compositor(compositor: &CompositorTask) {
|
||||||
constellation_chan = Some(new_constellation_chan);
|
constellation_chan = Some(new_constellation_chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetGraphicsMetadata(chan) => chan.send(azure_hl::current_graphics_metadata()),
|
GetGraphicsMetadata(chan) => chan.send(Some(azure_hl::current_graphics_metadata())),
|
||||||
|
|
||||||
NewLayer(_id, new_size) => {
|
NewLayer(_id, new_size) => {
|
||||||
// FIXME: This should create an additional layer instead of replacing the current one.
|
// FIXME: This should create an additional layer instead of replacing the current one.
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
use compositing::*;
|
use compositing::*;
|
||||||
|
|
||||||
use std::unstable::intrinsics;
|
|
||||||
|
|
||||||
/// Starts the compositor, which listens for messages on the specified port.
|
/// Starts the compositor, which listens for messages on the specified port.
|
||||||
///
|
///
|
||||||
/// This is the null compositor which doesn't draw anything to the screen.
|
/// This is the null compositor which doesn't draw anything to the screen.
|
||||||
|
@ -15,10 +13,8 @@ pub fn run_compositor(compositor: &CompositorTask) {
|
||||||
match compositor.port.recv() {
|
match compositor.port.recv() {
|
||||||
Exit => break,
|
Exit => break,
|
||||||
|
|
||||||
GetGraphicsMetadata(chan) => {
|
GetGraphicsMetadata(chan) => {
|
||||||
unsafe {
|
chan.send(None);
|
||||||
chan.send(intrinsics::uninit());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetIds(_, response_chan, _) => {
|
SetIds(_, response_chan, _) => {
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl Epoch {
|
||||||
/// The interface used by the renderer to acquire draw targets for each render frame and
|
/// The interface used by the renderer to acquire draw targets for each render frame and
|
||||||
/// submit them to be drawn to the display.
|
/// submit them to be drawn to the display.
|
||||||
pub trait RenderListener {
|
pub trait RenderListener {
|
||||||
fn get_graphics_metadata(&self) -> NativeGraphicsMetadata;
|
fn get_graphics_metadata(&self) -> Option<NativeGraphicsMetadata>;
|
||||||
fn new_layer(&self, PipelineId, Size2D<uint>);
|
fn new_layer(&self, PipelineId, Size2D<uint>);
|
||||||
fn set_layer_page_size_and_color(&self, PipelineId, Size2D<uint>, Epoch, Color);
|
fn set_layer_page_size_and_color(&self, PipelineId, Size2D<uint>, Epoch, Color);
|
||||||
fn set_layer_clip_rect(&self, PipelineId, Rect<uint>);
|
fn set_layer_clip_rect(&self, PipelineId, Rect<uint>);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue