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

More Rust version updates #11

Merged
merged 1 commit into from Aug 12, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -9,15 +9,15 @@

//! A platform-independent interface to 3D graphics contexts.

use extra::arc::ARC;
use extra::arc::Arc;

/// Platform-independent interface to 3D graphics contexts.
pub trait GraphicsContextMethods<NativeContextType> {
/// Wraps the given instance of the native 3D context, incrementing its reference count.
fn wrap(instance: ARC<NativeContextType>) -> Self;
fn wrap(instance: Arc<NativeContextType>) -> Self;

/// Returns the underlying native 3D context.
fn native(&self) -> ARC<NativeContextType>;
fn native(&self) -> Arc<NativeContextType>;

/// Creates a new offscreen 3D graphics context.
fn new() -> Self;
@@ -9,12 +9,10 @@

use context::GraphicsContextMethods;

use core::cast::transmute;
use core::libc::{c_char, c_int, c_long, c_uint, c_ulong, c_void};
use core::ptr::null;
use core::ptr;
use std::arc::ARC;
use std::arc;
use std::libc::{c_char, c_int, c_long, c_uint, c_ulong, c_void};
use std::ptr::null;
use std::ptr;
use extra::arc::Arc;

// Constants.

@@ -156,24 +154,17 @@ extern {

fn DefaultScreen(dpy: *Display) -> c_int {
unsafe {
let orig = dpy as uint;
let off: uint = transmute(&(*dpy).default_screen);
let default_screen = (*dpy).default_screen;
default_screen
(*dpy).default_screen
}
}
fn RootWindow(dpy: *Display, scr: c_int) -> Window {
unsafe {
let screen = ScreenOfDisplay(dpy, scr);
let root_window = (*ScreenOfDisplay(dpy, scr)).root;
root_window
(*ScreenOfDisplay(dpy, scr)).root
}
}
fn ScreenOfDisplay(dpy: *Display, scr: c_int) -> *Screen {
unsafe {
let orig = dpy as uint;
let off: uint = transmute(&(*dpy).screens);
*ptr::offset(&(*dpy).screens, scr as uint)
*ptr::offset(&(*dpy).screens, scr as int)
}
}

@@ -183,7 +174,7 @@ fn ScreenOfDisplay(dpy: *Display, scr: c_int) -> *Screen {
pub struct GraphicsContext {
priv display: *Display,
priv pixmap: GLXPixmap,
priv context: ARC<GLXContext>,
priv context: Arc<GLXContext>,
}

impl GraphicsContext {
@@ -196,7 +187,7 @@ impl GraphicsContext {
None => glXCreateContext(display, visual, null(), 1),
Some(share_context) => {
let native_share_context = share_context.native();
glXCreateContext(display, visual, *arc::get(&native_share_context), 1)
glXCreateContext(display, visual, *native_share_context.get(), 1)
}
};

@@ -205,7 +196,7 @@ impl GraphicsContext {
GraphicsContext {
display: display,
pixmap: pixmap,
context: ARC(context),
context: Arc::new(context),
}
}
}
@@ -235,7 +226,7 @@ impl GraphicsContext {
impl GraphicsContextMethods<GLXContext> for GraphicsContext {
/// Wraps the given instance of the native GLX graphics context, bumping the reference count in
/// the process.
fn wrap(instance: ARC<GLXContext>) -> GraphicsContext {
fn wrap(instance: Arc<GLXContext>) -> GraphicsContext {
let (display, _, pixmap) = GraphicsContext::create_display_visual_and_pixmap();
GraphicsContext {
display: display,
@@ -245,7 +236,7 @@ impl GraphicsContextMethods<GLXContext> for GraphicsContext {
}

/// Returns the underlying native 3D context.
fn native(&self) -> ARC<GLXContext> {
fn native(&self) -> Arc<GLXContext> {
self.context.clone()
}

@@ -265,7 +256,7 @@ impl GraphicsContextMethods<GLXContext> for GraphicsContext {
let result = glXMakeContextCurrent(self.display,
self.pixmap,
self.pixmap,
*arc::get(&self.context));
*self.context.get());
assert!(result != 0);
}
}
@@ -10,8 +10,7 @@
use base::ShareContext;
use context::GraphicsContextMethods;

use extra::arc::ARC;
use extra::arc;
use extra::arc::Arc;
use geom::size::Size2D;
use io_surface::{IOSurface, kIOSurfaceBytesPerElement, kIOSurfaceBytesPerRow};
use io_surface::{kIOSurfaceHeight, kIOSurfaceIsGlobal, kIOSurfaceWidth};
@@ -35,7 +34,7 @@ extern {}

/// Mac-specific interface to 3D graphics contexts.
pub struct GraphicsContext {
cgl_context: ARC<CGLContextObj>,
cgl_context: Arc<CGLContextObj>,
}

impl GraphicsContext {
@@ -62,14 +61,14 @@ impl GraphicsContext {
};
assert!(gl_error == kCGLNoError);

GraphicsContextMethods::wrap(ARC(cgl_context))
GraphicsContextMethods::wrap(Arc::new(cgl_context))
}
}
}

impl GraphicsContextMethods<CGLContextObj> for GraphicsContext {
/// Wraps the given instance of the native Core OpenGL graphics context.
fn wrap(instance: ARC<CGLContextObj>) -> GraphicsContext {
fn wrap(instance: Arc<CGLContextObj>) -> GraphicsContext {
unsafe {
GraphicsContext {
cgl_context: instance
@@ -78,7 +77,7 @@ impl GraphicsContextMethods<CGLContextObj> for GraphicsContext {
}

/// Returns the underlying native 3D context without modifying its reference count.
fn native(&self) -> ARC<CGLContextObj> {
fn native(&self) -> Arc<CGLContextObj> {
self.cgl_context.clone()
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.