auto merge of #4625 : mrobinson/servo/surface-refactor, r=jdm

We no longer need to implement from_azure_surface in Servo, now that
rust-layers is handling more of the glue between rust-layers and Azure.
This commit is contained in:
bors-servo 2015-01-16 12:57:44 -07:00
commit efae66bccb
10 changed files with 20 additions and 122 deletions

View file

@ -16,7 +16,6 @@ use gfx::paint_task::Msg as PaintMsg;
use layers::color::Color;
use layers::geometry::LayerPixel;
use layers::layers::{Layer, LayerBufferSet};
use layers::platform::surface::NativeSurfaceMethods;
use script_traits::CompositorEvent::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
use script_traits::{ScriptControlChan, ConstellationControlMsg};
use servo_msg::compositor_msg::{Epoch, LayerId, ScrollPolicy};

View file

@ -11,13 +11,13 @@ use font_context::FontContext;
use paint_context::PaintContext;
use azure::azure_hl::{SurfaceFormat, Color, DrawTarget, BackendType, StolenGLResources};
use azure::AzFloat;
use azure::{AzFloat, AzGLNativeContextRef};
use geom::matrix2d::Matrix2D;
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use layers::platform::surface::{NativeGraphicsMetadata, NativePaintingGraphicsContext};
use layers::platform::surface::{NativeSurface, NativeSurfaceMethods};
use layers::platform::surface::NativeSurface;
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
use layers;
use servo_msg::compositor_msg::{Epoch, PaintState, LayerId};
@ -25,7 +25,6 @@ use servo_msg::compositor_msg::{LayerMetadata, PaintListener, ScrollPolicy};
use servo_msg::constellation_msg::Msg as ConstellationMsg;
use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
use servo_msg::constellation_msg::PipelineExitType;
use servo_msg::platform::surface::NativeSurfaceAzureMethods;
use servo_util::geometry::{Au, ZERO_POINT};
use servo_util::opts;
use servo_util::smallvec::SmallVec;
@ -315,10 +314,9 @@ impl<C> PaintTask<C> where C: PaintListener + Send {
// Create an empty native surface. We mark it as not leaking
// in case it dies in transit to the compositor task.
let mut native_surface: NativeSurface =
layers::platform::surface::NativeSurfaceMethods::new(native_graphics_context!(self),
Size2D(width as i32,
height as i32),
width as i32 * 4);
layers::platform::surface::NativeSurface::new(native_graphics_context!(self),
Size2D(width as i32, height as i32),
width as i32 * 4);
native_surface.mark_wont_leak();
Some(box LayerBuffer {
@ -520,10 +518,13 @@ impl WorkerThread {
} else {
// FIXME(pcwalton): Cache the components of draw targets (texture color buffer,
// paintbuffers) instead of recreating them.
let native_graphics_context =
native_graphics_context!(self) as *const _ as AzGLNativeContextRef;
let draw_target = DrawTarget::new_with_fbo(BackendType::Skia,
native_graphics_context!(self),
native_graphics_context,
size,
SurfaceFormat::B8G8R8A8);
draw_target.make_current();
draw_target
};
@ -592,13 +593,12 @@ impl WorkerThread {
// GPU painting path:
draw_target.make_current();
let StolenGLResources {
surface: native_surface
surface: azure_surface
} = draw_target.steal_gl_resources().unwrap();
// We mark the native surface as not leaking in case the surfaces
// die on their way to the compositor task.
let mut native_surface: NativeSurface =
NativeSurfaceAzureMethods::from_azure_surface(native_surface);
let mut native_surface: NativeSurface = NativeSurface::from_azure_surface(azure_surface);
native_surface.mark_wont_leak();
box LayerBuffer {

View file

@ -21,27 +21,3 @@ extern crate io_surface;
pub mod compositor_msg;
pub mod constellation_msg;
pub mod platform {
#[cfg(target_os="macos")]
pub mod macos {
#[cfg(target_os="macos")]
pub mod surface;
}
#[cfg(target_os="linux")]
pub mod linux {
#[cfg(target_os="linux")]
pub mod surface;
}
#[cfg(target_os="android")]
pub mod android {
#[cfg(target_os="android")]
pub mod surface;
}
pub mod surface;
}

View file

@ -1,20 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
//! EGL-specific implementation of cross-process surfaces. This uses EGL surfaces.
use platform::surface::NativeSurfaceAzureMethods;
use azure::AzSkiaGrGLSharedSurfaceRef;
use layers::platform::surface::NativeSurface;
use std::mem;
impl NativeSurfaceAzureMethods for NativeSurface {
fn from_azure_surface(surface: AzSkiaGrGLSharedSurfaceRef) -> NativeSurface {
unsafe {
NativeSurface::from_image_khr(mem::transmute(surface))
}
}
}

View file

@ -1,20 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
//! X11-specific implementation of cross-process surfaces. This uses X pixmaps.
use platform::surface::NativeSurfaceAzureMethods;
use azure::AzSkiaGrGLSharedSurfaceRef;
use layers::platform::surface::NativeSurface;
use std::mem;
impl NativeSurfaceAzureMethods for NativeSurface {
fn from_azure_surface(surface: AzSkiaGrGLSharedSurfaceRef) -> NativeSurface {
unsafe {
NativeSurface::from_pixmap(mem::transmute(surface))
}
}
}

View file

@ -1,25 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
//! Mac OS-specific implementation of cross-process surfaces. This uses `IOSurface`, introduced
//! in Mac OS X 10.6 Snow Leopard.
use platform::surface::NativeSurfaceAzureMethods;
use azure::AzSkiaGrGLSharedSurfaceRef;
use io_surface::IOSurface;
use layers::platform::surface::NativeSurface;
use std::mem;
impl NativeSurfaceAzureMethods for NativeSurface {
fn from_azure_surface(surface: AzSkiaGrGLSharedSurfaceRef) -> NativeSurface {
unsafe {
let io_surface = IOSurface {
obj: mem::transmute(surface),
};
NativeSurface::from_io_surface(io_surface)
}
}
}

View file

@ -1,12 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
//! Declarations of types for cross-process surfaces.
use azure::AzSkiaGrGLSharedSurfaceRef;
pub trait NativeSurfaceAzureMethods {
fn from_azure_surface(surface: AzSkiaGrGLSharedSurfaceRef) -> Self;
}

View file

@ -26,7 +26,7 @@ dependencies = [
[[package]]
name = "azure"
version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#f4a02f3f621b0a994a20d42e438371a87c62f898"
source = "git+https://github.com/servo/rust-azure#d0acabef6221e5fd6840254dc23f91c66b874629"
dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
@ -34,7 +34,6 @@ dependencies = [
"egl 0.1.0 (git+https://github.com/servo/rust-egl)",
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"skia-sys 0.0.20130412 (git+https://github.com/servo/skia?ref=upstream-2014-06-16)",
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
]
@ -432,8 +431,9 @@ source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa
[[package]]
name = "layers"
version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#574df7e1c1dd464af930d1cc735ca8d6af46bb90"
source = "git+https://github.com/servo/rust-layers#f20270839f8658a2b19eae6fade9325efe5f4578"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"egl 0.1.0 (git+https://github.com/servo/rust-egl)",

6
ports/cef/Cargo.lock generated
View file

@ -27,7 +27,7 @@ dependencies = [
[[package]]
name = "azure"
version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#f4a02f3f621b0a994a20d42e438371a87c62f898"
source = "git+https://github.com/servo/rust-azure#d0acabef6221e5fd6840254dc23f91c66b874629"
dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
@ -35,7 +35,6 @@ dependencies = [
"egl 0.1.0 (git+https://github.com/servo/rust-egl)",
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"skia-sys 0.0.20130412 (git+https://github.com/servo/skia?ref=upstream-2014-06-16)",
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
]
@ -400,8 +399,9 @@ source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa
[[package]]
name = "layers"
version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#574df7e1c1dd464af930d1cc735ca8d6af46bb90"
source = "git+https://github.com/servo/rust-layers#f20270839f8658a2b19eae6fade9325efe5f4578"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"egl 0.1.0 (git+https://github.com/servo/rust-egl)",

6
ports/gonk/Cargo.lock generated
View file

@ -15,7 +15,7 @@ dependencies = [
[[package]]
name = "azure"
version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#f4a02f3f621b0a994a20d42e438371a87c62f898"
source = "git+https://github.com/servo/rust-azure#d0acabef6221e5fd6840254dc23f91c66b874629"
dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
@ -23,7 +23,6 @@ dependencies = [
"egl 0.1.0 (git+https://github.com/servo/rust-egl)",
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"skia-sys 0.0.20130412 (git+https://github.com/servo/skia?ref=upstream-2014-06-16)",
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
]
@ -354,8 +353,9 @@ source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa
[[package]]
name = "layers"
version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#574df7e1c1dd464af930d1cc735ca8d6af46bb90"
source = "git+https://github.com/servo/rust-layers#f20270839f8658a2b19eae6fade9325efe5f4578"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"egl 0.1.0 (git+https://github.com/servo/rust-egl)",