Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move windowing code out of compositor, take 2 #3563

Merged
merged 1 commit into from Oct 10, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Move windowing code out of the compositor

This is mainly just moving code around, in preparation for further changes to
the "windowing" API.
  • Loading branch information
mbrubeck committed Oct 10, 2014
commit 77d32ee4470981af2074e164cf47fc7a909b1ed1

Some generated files are not rendered by default. Learn more.

@@ -6,7 +6,7 @@ authors = ["The Servo Project Developers"]

[lib]
name = "servo"
crate-type = ["rlib", "dylib"]
crate-type = ["rlib"]

[[bin]]
name = "servo"
@@ -24,6 +24,8 @@ name = "contenttest"
path = "tests/contenttest.rs"
harness = false

[features]
default = ["glfw_app"]

[dependencies.compositing]
path = "components/compositing"
@@ -46,5 +48,9 @@ path = "components/layout"
[dependencies.gfx]
path = "components/gfx"

[dependencies.glfw_app]
path = "ports/glfw"
optional = true

[dependencies.url]
git = "https://github.com/servo/rust-url"
@@ -89,7 +89,6 @@ git clone https://github.com/servo/servo
cd servo
ANDROID_TOOLCHAIN=/path/to/toolchain ANDROID_NDK=/path/to/ndk PATH=$PATH:/path/to/toolchain/bin ./mach build --android
cd ports/android
ANDROID_NDK=/path/to/ndk ANDROID_SDK=/path/to/sdk make
ANDROID_SDK=/path/to/sdk make install
```

@@ -40,10 +40,6 @@ git = "https://github.com/servo/rust-azure"
[dependencies.geom]
git = "https://github.com/servo/rust-geom"

[dependencies.glfw]
git = "https://github.com/servo/glfw-rs"
branch = "servo"

[dependencies.layers]
git = "https://github.com/servo/rust-layers"

@@ -61,7 +57,3 @@ git = "https://github.com/servo/rust-core-graphics"

[dependencies.core_text]
git = "https://github.com/servo/rust-core-text"

[dependencies.glut]
git = "https://github.com/servo/rust-glut"

@@ -11,7 +11,6 @@ use constellation::SendableFrameTree;
use events;
use events::ScrollPositionChanged;
use pipeline::CompositionPipeline;
use platform::{Application, Window};
use windowing;
use windowing::{FinishedWindowEvent, IdleWindowEvent, LoadUrlWindowEvent, MouseWindowClickEvent};
use windowing::{MouseWindowEvent, MouseWindowEventClass, MouseWindowMouseDownEvent};
@@ -54,7 +53,7 @@ use time::precise_time_s;
use url::Url;


pub struct IOCompositor {
pub struct IOCompositor<Window: WindowMethods> {
/// The application window.
window: Rc<Window>,

@@ -136,22 +135,13 @@ enum ShutdownState {
FinishedShuttingDown,
}

impl IOCompositor {
fn new(app: &Application,
opts: Opts,
port: Receiver<Msg>,
constellation_chan: ConstellationChan,
time_profiler_chan: TimeProfilerChan,
memory_profiler_chan: MemoryProfilerChan) -> IOCompositor {

let scale_factor = match opts.device_pixels_per_px {
Some(device_pixels_per_px) => device_pixels_per_px,
None => ScaleFactor(1.0),
};
let framebuffer_size = opts.initial_window_size.as_f32() * scale_factor;

let window: Rc<Window> = WindowMethods::new(app, opts.output_file.is_none(),
framebuffer_size.as_uint());
impl<Window: WindowMethods> IOCompositor<Window> {
fn new(window: Rc<Window>,
opts: Opts,
port: Receiver<Msg>,
constellation_chan: ConstellationChan,
time_profiler_chan: TimeProfilerChan,
memory_profiler_chan: MemoryProfilerChan) -> IOCompositor<Window> {

// Create an initial layer tree.
//
@@ -192,13 +182,13 @@ impl IOCompositor {
}
}

pub fn create(app: &Application,
pub fn create(window: Rc<Window>,
opts: Opts,
port: Receiver<Msg>,
constellation_chan: ConstellationChan,
time_profiler_chan: TimeProfilerChan,
memory_profiler_chan: MemoryProfilerChan) {
let mut compositor = IOCompositor::new(app,
let mut compositor = IOCompositor::new(window,
opts,
port,
constellation_chan,
@@ -7,8 +7,7 @@ pub use windowing;
use compositor;
use headless;
pub use constellation::SendableFrameTree;
use windowing::{ApplicationMethods, WindowMethods};
use platform::Application;
use windowing::WindowMethods;

use azure::azure_hl::{SourceSurfaceMethods, Color};
use geom::point::Point2D;
@@ -23,6 +22,7 @@ use servo_util::memory::MemoryProfilerChan;
use servo_util::opts::Opts;
use servo_util::time::TimeProfilerChan;
use std::comm::{channel, Sender, Receiver};
use std::rc::Rc;

use url::Url;

@@ -183,28 +183,9 @@ pub enum Msg {
LoadComplete(PipelineId, Url),
}

pub enum CompositorMode {
Windowed(Application),
Headless
}

pub struct CompositorTask {
pub mode: CompositorMode,
}
pub struct CompositorTask;

impl CompositorTask {
fn new(is_headless: bool) -> CompositorTask {
let mode: CompositorMode = if is_headless {
Headless
} else {
Windowed(ApplicationMethods::new())
};

CompositorTask {
mode: mode
}
}

/// Creates a graphics context. Platform-specific.
///
/// FIXME(pcwalton): Probably could be less platform-specific, using the metadata abstraction.
@@ -217,24 +198,24 @@ impl CompositorTask {
NativeCompositingGraphicsContext::new()
}

pub fn create(opts: Opts,
pub fn create<Window: WindowMethods>(
window: Option<Rc<Window>>,
opts: Opts,
port: Receiver<Msg>,
constellation_chan: ConstellationChan,
time_profiler_chan: TimeProfilerChan,
memory_profiler_chan: MemoryProfilerChan) {

let compositor = CompositorTask::new(opts.headless);

match compositor.mode {
Windowed(ref app) => {
compositor::IOCompositor::create(app,
match window {
Some(window) => {
compositor::IOCompositor::create(window,
opts,
port,
constellation_chan.clone(),
time_profiler_chan,
memory_profiler_chan)
}
Headless => {
None => {
headless::NullCompositor::create(port,
constellation_chan.clone(),
time_profiler_chan,
@@ -19,10 +19,6 @@ extern crate azure;
extern crate devtools_traits;
extern crate geom;
extern crate gfx;
#[cfg(not(target_os="android"))]
extern crate glfw;
#[cfg(target_os="android")]
extern crate glut;
extern crate layers;
extern crate layout_traits;
extern crate opengles;
@@ -56,7 +52,4 @@ mod headless;
pub mod pipeline;
pub mod constellation;

mod windowing;

#[path="platform/mod.rs"]
pub mod platform;
pub mod windowing;
@@ -10,7 +10,6 @@ use geom::size::TypedSize2D;
use layers::geometry::DevicePixel;
use servo_msg::compositor_msg::{ReadyState, RenderState};
use servo_util::geometry::ScreenPx;
use std::rc::Rc;

pub enum MouseWindowEvent {
MouseWindowClickEvent(uint, TypedPoint2D<DevicePixel, f32>),
@@ -54,14 +53,7 @@ pub enum WindowEvent {
QuitWindowEvent,
}

/// Methods for an abstract Application.
pub trait ApplicationMethods {
fn new() -> Self;
}

pub trait WindowMethods<A> {
/// Creates a new window.
fn new(app: &A, is_foreground: bool, size: TypedSize2D<DevicePixel, uint>) -> Rc<Self>;
pub trait WindowMethods {
/// Returns the size of the window in hardware pixels.
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, uint>;
/// Returns the size of the window in density-independent "px" units.
@@ -1,9 +1,11 @@
CARGO_OPTS ?=

.PHONY: all
all:
all: glut_app
NDK_DEBUG=1 $(ANDROID_NDK)/ndk-build -B
find ../../target ! \( -type d -name dist -prune \) -name libmozjs.so | \
find glut_app/target ! \( -type d -name dist -prune \) -name libmozjs.so | \
xargs -I {} cp -f {} libs/armeabi
find ../../target ! \( -type d -name dist -prune \) -name 'libservo-*.so' | \
find glut_app/target ! \( -type d -name dist -prune \) -name 'libglut_app-*.so' | \
xargs -I {} cp -f {} libs/armeabi/libservo.so
find ../../rust/lib/rustlib/arm-linux-androideabi/lib \
-name '*.so' -type f -size +1c | \
@@ -14,6 +16,11 @@ all:
--path .
ant debug

.PHONY: glut_app
glut_app:
cd glut_app; \
../../../mach cargo build --target=arm-linux-androideabi $(CARGO_OPTS)

.PHONY: install
install:
$(ANDROID_SDK)/platform-tools/adb install -r bin/ServoAndroid-debug.apk
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.