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

Replace GLUT with GLFW #563

Merged
merged 5 commits into from Jul 10, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Replace glut with glfw.

Also fixes initial window size to get based on the windowing code instead of
being hardcoded everywhere. This code works on HiDPI displays, but does not
appropriately scale the output up yet.
  • Loading branch information
metajack committed Jul 4, 2013
commit e0e5e1a2a7c33d265e1995a02211a8926980ce82
@@ -29,6 +29,7 @@ NATIVE_BUILDS += \
skia \
nss \
nspr \
glfw \
$(NULL)

# NOTE: the make magic can only compute transitive build dependencies,
@@ -40,18 +41,22 @@ NATIVE_BUILDS += \
DEPS_rust-azure += \
rust-opengles \
rust-layers \
rust-glut \
rust-geom \
glfw-rs \
glfw \
skia \
$(NULL)

DEPS_glfw-rs += \
glfw \
$(NULL)

DEPS_rust-glut += \
rust-opengles \
$(NULL)

DEPS_rust-layers += \
rust-geom \
rust-glut \
rust-opengles \
$(NULL)

@@ -23,6 +23,8 @@ use std::comm;
use std::comm::{Chan, SharedChan, Port};
use std::num::Orderable;
use std::task;
use extra::uv_global_loop;
use extra::timer;
use geom::matrix::identity;
use geom::point::Point2D;
use geom::size::Size2D;
@@ -80,15 +82,24 @@ impl CompositorChan {
chan: SharedChan::new(chan),
}
}

pub fn send(&self, msg: Msg) {
self.chan.send(msg);
}

pub fn get_size(&self) -> Size2D<int> {
let (port, chan) = comm::stream();
self.chan.send(GetSize(chan));
port.recv()
}
}

/// Messages to the compositor.
pub enum Msg {
/// Requests that the compositor shut down.
Exit,
/// Requests the window size
GetSize(Chan<Size2D<int>>),
/// Requests the compositors GL context.
GetGLContext(Chan<AzGLContext>),
/// Requests that the compositor paint the given layer buffer set for the given page size.
@@ -169,15 +180,18 @@ impl CompositorTask {
// list. This is only here because we don't have that logic in the renderer yet.
let context = rendergl::init_render_context();
let root_layer = @mut ContainerLayer();
let scene = @mut Scene(ContainerLayerKind(root_layer), Size2D(800.0f32, 600.0), identity());
let window_size = window.size();
let scene = @mut Scene(ContainerLayerKind(root_layer), window_size, identity());
let done = @mut false;
let recomposite = @mut false;

// FIXME: This should not be a separate offset applied after the fact but rather should be
// applied to the layers themselves on a per-layer basis. However, this won't work until scroll
// positions are sent to content.
let world_offset = @mut Point2D(0f32, 0f32);
let page_size = @mut Size2D(0f32, 0f32);
let window_size = @mut Size2D(800, 600);
let window_size = @mut Size2D(window_size.width as int,
window_size.height as int);

// Keeps track of the current zoom factor
let world_zoom = @mut 1f32;
@@ -271,6 +285,11 @@ impl CompositorTask {
response_chan.send(CompositorAck(new_pipeline_id));
}

GetSize(chan) => {
let size = window.size();
chan.send(Size2D(size.width as int, size.height as int));
}

GetGLContext(chan) => chan.send(current_gl_context()),

Paint(id, new_layer_buffer_set, new_size) => {
@@ -343,14 +362,14 @@ impl CompositorTask {
// TODO: Recycle the old buffers; send them back to the renderer to reuse if
// it wishes.

window.set_needs_display();
*recomposite = true;
}
}
}
};

let profiler_chan = self.profiler_chan.clone();
do window.set_composite_callback {
let composite = || {
do profile(time::CompositingCategory, profiler_chan.clone()) {
debug!("compositor: compositing");
// Adjust the layer dimensions as necessary to correspond to the size of the window.
@@ -361,7 +380,7 @@ impl CompositorTask {
}

window.present();
}
};

// When the user scrolls, move the layer around.
do window.set_scroll_callback |delta| {
@@ -390,7 +409,7 @@ impl CompositorTask {

root_layer.common.set_transform(scroll_transform);

window.set_needs_display()
*recomposite = true;
}


@@ -429,8 +448,7 @@ impl CompositorTask {
0.0);
root_layer.common.set_transform(zoom_transform);


window.set_needs_display()
*recomposite = true;
}

// Enter the main event loop.
@@ -440,6 +458,13 @@ impl CompositorTask {

// Check for messages coming from the windowing system.
window.check_loop();

if *recomposite {
*recomposite = false;
composite();
}

timer::sleep(&uv_global_loop::get(), 100);
}

self.shutdown_chan.send(())
@@ -57,13 +57,14 @@ impl Pipeline {
profiler_chan);

ScriptTask::create(id,
compositor_chan,
compositor_chan.clone(),
layout_chan.clone(),
script_port,
script_chan.clone(),
constellation_chan,
resource_task,
image_cache_task);
image_cache_task,
compositor_chan.get_size());

Pipeline::new(id,
script_chan,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.