зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1332465. Update webrender to 6c15d14bb6b786cad979407e6ed7b86949b4ae48 r=gfx?
This commit is contained in:
Родитель
00d069f137
Коммит
568cd6614e
|
@ -59,4 +59,4 @@ What if you have to make changes to webrender itself?
|
|||
|
||||
Yes, this is somewhat painful. It used to be worse. :)
|
||||
|
||||
Latest Commit: 0bbd08a41c2d54b72639f531628ba3800e7f5319
|
||||
Latest Commit: 6c15d14bb6b786cad979407e6ed7b86949b4ae48
|
||||
|
|
|
@ -31,11 +31,11 @@ webrender_traits = {path = "../webrender_traits", default-features = false}
|
|||
bitflags = "0.7"
|
||||
|
||||
[target.'cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))'.dependencies]
|
||||
freetype = {version = "0.1.2", default-features = false}
|
||||
freetype = { version = "0.2", default-features = false }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
dwrote = "0.1.4"
|
||||
dwrote = "0.1.5"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-graphics = "0.4.1"
|
||||
core-graphics = "0.5.0"
|
||||
core-text = "2.0"
|
||||
|
|
|
@ -43,7 +43,9 @@ fn main() {
|
|||
for entry in read_dir(res_dir).unwrap() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
|
||||
if entry.file_name().to_str().unwrap().ends_with(".glsl") {
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
glsl_files.push(path.to_owned());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#define UV_PIXEL uint(1)
|
||||
|
||||
#define MAX_STOPS_PER_ANGLE_GRADIENT 8
|
||||
#define MAX_STOPS_PER_RADIAL_GRADIENT 8
|
||||
|
||||
uniform sampler2DArray sCache;
|
||||
|
||||
|
@ -215,6 +216,22 @@ GradientStop fetch_gradient_stop(int index) {
|
|||
return stop;
|
||||
}
|
||||
|
||||
struct RadialGradient {
|
||||
vec4 start_end_center;
|
||||
vec4 start_end_radius;
|
||||
};
|
||||
|
||||
RadialGradient fetch_radial_gradient(int index) {
|
||||
RadialGradient gradient;
|
||||
|
||||
ivec2 uv = get_fetch_uv_2(index);
|
||||
|
||||
gradient.start_end_center = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
|
||||
gradient.start_end_radius = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
|
||||
|
||||
return gradient;
|
||||
}
|
||||
|
||||
struct Glyph {
|
||||
vec4 offset;
|
||||
};
|
||||
|
|
|
@ -366,8 +366,12 @@ void main(void) {
|
|||
|
||||
vec2 brightness_mod = vec2(0.7, 1.3);
|
||||
|
||||
// Note: we can't pass-through in the following cases,
|
||||
// because Angle doesn't support it and fails to compile the shaders.
|
||||
switch (vBorderStyle) {
|
||||
case BORDER_STYLE_DASHED:
|
||||
draw_dashed_or_dotted_border(local_pos, distance_from_mix_line);
|
||||
break;
|
||||
case BORDER_STYLE_DOTTED:
|
||||
draw_dashed_or_dotted_border(local_pos, distance_from_mix_line);
|
||||
break;
|
||||
|
@ -375,8 +379,14 @@ void main(void) {
|
|||
draw_double_border(distance_from_mix_line, local_pos);
|
||||
break;
|
||||
case BORDER_STYLE_OUTSET:
|
||||
draw_solid_border(distance_from_mix_line, local_pos);
|
||||
break;
|
||||
case BORDER_STYLE_INSET:
|
||||
draw_solid_border(distance_from_mix_line, local_pos);
|
||||
break;
|
||||
case BORDER_STYLE_SOLID:
|
||||
draw_solid_border(distance_from_mix_line, local_pos);
|
||||
break;
|
||||
case BORDER_STYLE_NONE:
|
||||
draw_solid_border(distance_from_mix_line, local_pos);
|
||||
break;
|
||||
|
@ -387,6 +397,7 @@ void main(void) {
|
|||
draw_mixed_border(distance_from_mix_line, distance_from_middle, local_pos, brightness_mod.xy);
|
||||
break;
|
||||
case BORDER_STYLE_HIDDEN:
|
||||
discard;
|
||||
default:
|
||||
discard;
|
||||
}
|
||||
|
|
|
@ -168,6 +168,9 @@ void main(void) {
|
|||
vec4 result = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
|
||||
switch (vOp) {
|
||||
case 1:
|
||||
result.rgb = Multiply(Cb.rgb, Cs.rgb);
|
||||
break;
|
||||
case 2:
|
||||
result.rgb = Screen(Cb.rgb, Cs.rgb);
|
||||
break;
|
||||
|
|
|
@ -12,7 +12,7 @@ void main(void) {
|
|||
|
||||
vec4 segment_rect;
|
||||
switch (int(gradient.kind.x)) {
|
||||
case GRADIENT_HORIZONTAL:
|
||||
case GRADIENT_HORIZONTAL: {
|
||||
float x0 = mix(gradient.start_end_point.x,
|
||||
gradient.start_end_point.z,
|
||||
g0.offset.x);
|
||||
|
@ -22,8 +22,8 @@ void main(void) {
|
|||
segment_rect.yw = prim.local_rect.yw;
|
||||
segment_rect.x = x0;
|
||||
segment_rect.z = x1 - x0;
|
||||
break;
|
||||
case GRADIENT_VERTICAL:
|
||||
} break;
|
||||
case GRADIENT_VERTICAL: {
|
||||
float y0 = mix(gradient.start_end_point.y,
|
||||
gradient.start_end_point.w,
|
||||
g0.offset.x);
|
||||
|
@ -33,7 +33,7 @@ void main(void) {
|
|||
segment_rect.xz = prim.local_rect.xz;
|
||||
segment_rect.y = y0;
|
||||
segment_rect.w = y1 - y0;
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/* 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/. */
|
||||
|
||||
float offset(int index) {
|
||||
return vOffsets[index / 4][index % 4];
|
||||
}
|
||||
|
||||
float linearStep(float lo, float hi, float x) {
|
||||
float d = hi - lo;
|
||||
float v = x - lo;
|
||||
if (d != 0.0) {
|
||||
v /= d;
|
||||
}
|
||||
return clamp(v, 0.0, 1.0);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
vec2 cd = vEndCenter - vStartCenter;
|
||||
vec2 pd = vPos - vStartCenter;
|
||||
float rd = vEndRadius - vStartRadius;
|
||||
|
||||
// Solve for t in length(t * cd - pd) = vStartRadius + t * rd
|
||||
// using a quadratic equation in form of At^2 - 2Bt + C = 0
|
||||
float A = dot(cd, cd) - rd * rd;
|
||||
float B = dot(pd, cd) + vStartRadius * rd;
|
||||
float C = dot(pd, pd) - vStartRadius * vStartRadius;
|
||||
|
||||
float x;
|
||||
if (A == 0.0) {
|
||||
// Since A is 0, just solve for -2Bt + C = 0
|
||||
if (B == 0.0) {
|
||||
discard;
|
||||
}
|
||||
float t = 0.5 * C / B;
|
||||
if (vStartRadius + rd * t >= 0.0) {
|
||||
x = t;
|
||||
} else {
|
||||
discard;
|
||||
}
|
||||
} else {
|
||||
float discr = B * B - A * C;
|
||||
if (discr < 0.0) {
|
||||
discard;
|
||||
}
|
||||
discr = sqrt(discr);
|
||||
float t0 = (B + discr) / A;
|
||||
float t1 = (B - discr) / A;
|
||||
if (vStartRadius + rd * t0 >= 0.0) {
|
||||
x = t0;
|
||||
} else if (vStartRadius + rd * t1 >= 0.0) {
|
||||
x = t1;
|
||||
} else {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
oFragColor = mix(vColors[0],
|
||||
vColors[1],
|
||||
linearStep(offset(0), offset(1), x));
|
||||
|
||||
for (int i=1 ; i < vStopCount-1 ; ++i) {
|
||||
oFragColor = mix(oFragColor,
|
||||
vColors[i+1],
|
||||
linearStep(offset(i), offset(i+1), x));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
/* 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/. */
|
||||
|
||||
flat varying int vStopCount;
|
||||
flat varying vec2 vStartCenter;
|
||||
flat varying vec2 vEndCenter;
|
||||
flat varying float vStartRadius;
|
||||
flat varying float vEndRadius;
|
||||
varying vec2 vPos;
|
||||
flat varying vec4 vColors[MAX_STOPS_PER_RADIAL_GRADIENT];
|
||||
flat varying vec4 vOffsets[MAX_STOPS_PER_RADIAL_GRADIENT/4];
|
|
@ -0,0 +1,35 @@
|
|||
#line 1
|
||||
/* 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/. */
|
||||
|
||||
void main(void) {
|
||||
Primitive prim = load_primitive();
|
||||
RadialGradient gradient = fetch_radial_gradient(prim.prim_index);
|
||||
|
||||
VertexInfo vi = write_vertex(prim.local_rect,
|
||||
prim.local_clip_rect,
|
||||
prim.z,
|
||||
prim.layer,
|
||||
prim.tile);
|
||||
|
||||
vStopCount = int(prim.user_data.x);
|
||||
vPos = vi.local_clamped_pos;
|
||||
|
||||
// Snap the start/end points to device pixel units.
|
||||
// I'm not sure this is entirely correct, but the
|
||||
// old render path does this, and it is needed to
|
||||
// make the angle gradient ref tests pass. It might
|
||||
// be better to fix this higher up in DL construction
|
||||
// and not snap here?
|
||||
vStartCenter = floor(0.5 + gradient.start_end_center.xy * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
vEndCenter = floor(0.5 + gradient.start_end_center.zw * uDevicePixelRatio) / uDevicePixelRatio;
|
||||
vStartRadius = gradient.start_end_radius.x;
|
||||
vEndRadius = gradient.start_end_radius.y;
|
||||
|
||||
for (int i=0 ; i < vStopCount ; ++i) {
|
||||
GradientStop stop = fetch_gradient_stop(prim.sub_index + i);
|
||||
vColors[i] = stop.color;
|
||||
vOffsets[i/4][i%4] = stop.offset.x;
|
||||
}
|
||||
}
|
|
@ -18,7 +18,8 @@ use std::mem;
|
|||
use std::path::PathBuf;
|
||||
//use std::sync::mpsc::{channel, Sender};
|
||||
//use std::thread;
|
||||
use webrender_traits::{ColorF, ImageFormat, DeviceIntRect};
|
||||
use webrender_traits::{ColorF, ImageFormat};
|
||||
use webrender_traits::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
|
||||
#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
|
||||
const GL_FORMAT_A: gl::GLuint = gl::RED;
|
||||
|
@ -1208,19 +1209,24 @@ impl Device {
|
|||
}
|
||||
|
||||
pub fn blit_render_target(&mut self,
|
||||
src_texture_id: TextureId,
|
||||
src_texture_layer: i32,
|
||||
src_texture: Option<(TextureId, i32)>,
|
||||
src_rect: Option<DeviceIntRect>,
|
||||
dest_rect: DeviceIntRect) {
|
||||
debug_assert!(self.inside_frame);
|
||||
|
||||
self.bind_read_target(Some((src_texture_id, src_texture_layer)));
|
||||
let src_rect = src_rect.unwrap_or_else(|| {
|
||||
let texture = self.textures.get(&src_texture.unwrap().0).expect("unknown texture id!");
|
||||
DeviceIntRect::new(DeviceIntPoint::zero(),
|
||||
DeviceIntSize::new(texture.width as gl::GLint,
|
||||
texture.height as gl::GLint))
|
||||
});
|
||||
|
||||
let texture = self.textures.get(&src_texture_id).expect("unknown texture id!");
|
||||
self.bind_read_target(src_texture);
|
||||
|
||||
gl::blit_framebuffer(0,
|
||||
0,
|
||||
texture.width as gl::GLint,
|
||||
texture.height as gl::GLint,
|
||||
gl::blit_framebuffer(src_rect.origin.x,
|
||||
src_rect.origin.y,
|
||||
src_rect.origin.x + src_rect.size.width,
|
||||
src_rect.origin.y + src_rect.size.height,
|
||||
dest_rect.origin.x,
|
||||
dest_rect.origin.y,
|
||||
dest_rect.origin.x + dest_rect.size.width,
|
||||
|
|
|
@ -352,9 +352,44 @@ impl Frame {
|
|||
(_, _, None) => return false,
|
||||
};
|
||||
|
||||
let scroll_root_id = match scroll_layer_id.info {
|
||||
ScrollLayerInfo::Scrollable(_, scroll_root_id) => scroll_root_id,
|
||||
ScrollLayerInfo::Fixed => unreachable!("Tried to scroll a fixed position layer."),
|
||||
let non_root_overscroll = if scroll_layer_id != root_scroll_layer_id {
|
||||
// true if the current layer is overscrolling,
|
||||
// and it is not the root scroll layer.
|
||||
let child_layer = self.layers.get(&scroll_layer_id).unwrap();
|
||||
let overscroll_amount = child_layer.overscroll_amount();
|
||||
overscroll_amount.width != 0.0 || overscroll_amount.height != 0.0
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
let switch_layer = match phase {
|
||||
ScrollEventPhase::Start => {
|
||||
// if this is a new gesture, we do not switch layer,
|
||||
// however we do save the state of non_root_overscroll,
|
||||
// for use in the subsequent Move phase.
|
||||
let mut current_layer = self.layers.get_mut(&scroll_layer_id).unwrap();
|
||||
current_layer.scrolling.should_handoff_scroll = non_root_overscroll;
|
||||
false
|
||||
},
|
||||
ScrollEventPhase::Move(_) => {
|
||||
// Switch layer if movement originated in a new gesture,
|
||||
// from a non root layer in overscroll.
|
||||
let current_layer = self.layers.get_mut(&scroll_layer_id).unwrap();
|
||||
current_layer.scrolling.should_handoff_scroll && non_root_overscroll
|
||||
},
|
||||
ScrollEventPhase::End => {
|
||||
// clean-up when gesture ends.
|
||||
let mut current_layer = self.layers.get_mut(&scroll_layer_id).unwrap();
|
||||
current_layer.scrolling.should_handoff_scroll = false;
|
||||
false
|
||||
},
|
||||
};
|
||||
|
||||
let scroll_root_id = match (switch_layer, scroll_layer_id.info, root_scroll_layer_id.info) {
|
||||
(true, _, ScrollLayerInfo::Scrollable(_, scroll_root_id)) |
|
||||
(true, ScrollLayerInfo::Scrollable(_, scroll_root_id), ScrollLayerInfo::Fixed) |
|
||||
(false, ScrollLayerInfo::Scrollable(_, scroll_root_id), _) => scroll_root_id,
|
||||
(_, ScrollLayerInfo::Fixed, _) => unreachable!("Tried to scroll a fixed position layer."),
|
||||
};
|
||||
|
||||
let mut scrolled_a_layer = false;
|
||||
|
@ -831,6 +866,15 @@ impl Frame {
|
|||
info.end_point,
|
||||
info.stops);
|
||||
}
|
||||
SpecificDisplayItem::RadialGradient(ref info) => {
|
||||
context.builder.add_radial_gradient(item.rect,
|
||||
&item.clip,
|
||||
info.start_center,
|
||||
info.start_radius,
|
||||
info.end_center,
|
||||
info.end_radius,
|
||||
info.stops);
|
||||
}
|
||||
SpecificDisplayItem::BoxShadow(ref box_shadow_info) => {
|
||||
context.builder.add_box_shadow(&box_shadow_info.box_bounds,
|
||||
&item.clip,
|
||||
|
|
|
@ -128,6 +128,7 @@ pub struct ScrollingState {
|
|||
pub spring: Spring,
|
||||
pub started_bouncing_back: bool,
|
||||
pub bouncing_back: bool,
|
||||
pub should_handoff_scroll: bool
|
||||
}
|
||||
|
||||
impl ScrollingState {
|
||||
|
@ -137,6 +138,7 @@ impl ScrollingState {
|
|||
spring: Spring::at(LayerPoint::zero(), STIFFNESS, DAMPING),
|
||||
started_bouncing_back: false,
|
||||
bouncing_back: false,
|
||||
should_handoff_scroll: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ use app_units::Au;
|
|||
use core_graphics::base::{kCGImageAlphaNoneSkipFirst, kCGImageAlphaPremultipliedLast};
|
||||
use core_graphics::base::kCGBitmapByteOrder32Little;
|
||||
use core_graphics::color_space::CGColorSpace;
|
||||
use core_graphics::context::CGContext;
|
||||
use core_graphics::context::{CGContext, CGTextDrawingMode};
|
||||
use core_graphics::data_provider::CGDataProvider;
|
||||
use core_graphics::font::{CGFont, CGGlyph};
|
||||
use core_graphics::geometry::CGPoint;
|
||||
use core_graphics::geometry::{CGPoint, CGSize, CGRect};
|
||||
use core_text::font::CTFont;
|
||||
use core_text::font_descriptor::kCTFontDefaultOrientation;
|
||||
use core_text;
|
||||
|
@ -158,6 +158,23 @@ impl FontContext {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn print_glyph_data(&mut self, data: &Vec<u8>, width: usize, height: usize) {
|
||||
// Rust doesn't have step_by support on stable :(
|
||||
for i in 0..height {
|
||||
let current_height = i * width * 4;
|
||||
|
||||
for pixel in data[current_height .. current_height + (width * 4)].chunks(4) {
|
||||
let b = pixel[0];
|
||||
let g = pixel[1];
|
||||
let r = pixel[2];
|
||||
let a = pixel[3];
|
||||
print!("({}, {}, {}, {}) ", r, g, b, a);
|
||||
}
|
||||
println!("");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rasterize_glyph(&mut self,
|
||||
font_key: FontKey,
|
||||
size: Au,
|
||||
|
@ -183,38 +200,91 @@ impl FontContext {
|
|||
&CGColorSpace::create_device_rgb(),
|
||||
context_flags);
|
||||
|
||||
|
||||
// Tested on mac OS Sierra, 10.12
|
||||
// For Mono + alpha, the only values that matter are the alpha values.
|
||||
// For subpixel, we need each individual rgb channel.
|
||||
// CG has two individual glyphs for subpixel AA (pre-10.11, this is not true):
|
||||
// 1) black text on white opaque background
|
||||
// 2) white text on black opaque background
|
||||
// Gecko does (1). Note, the BG must be opaque for subpixel AA to work.
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1230366#c35
|
||||
//
|
||||
// For grayscale / mono, CG still produces two glyphs, but it doesn't matter
|
||||
// 1) black text on transparent white - only alpha values filled
|
||||
// 2) white text on transparent black - channels == alpha
|
||||
//
|
||||
// If we draw grayscale/mono on an opaque background
|
||||
// the RGB channels are the alpha values from transparent backgrounds
|
||||
// with the alpha set as opaque.
|
||||
// At the end of all this, WR expects individual RGB channels and ignores alpha
|
||||
// for subpixel AA.
|
||||
// For alpha/mono, WR ignores all channels other than alpha.
|
||||
// Also note that WR expects text to be black bg with white text, so invert
|
||||
// when we draw the glyphs.
|
||||
let (antialias, smooth) = match render_mode {
|
||||
FontRenderMode::Subpixel => (true, true),
|
||||
FontRenderMode::Alpha => (true, false),
|
||||
FontRenderMode::Mono => (false, false),
|
||||
};
|
||||
|
||||
// These are always true in Gecko, even for non-AA fonts
|
||||
cg_context.set_allows_font_subpixel_positioning(true);
|
||||
cg_context.set_should_subpixel_position_fonts(true);
|
||||
|
||||
cg_context.set_allows_font_smoothing(smooth);
|
||||
cg_context.set_should_smooth_fonts(smooth);
|
||||
cg_context.set_allows_antialiasing(antialias);
|
||||
cg_context.set_should_antialias(antialias);
|
||||
cg_context.set_rgb_fill_color(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
let rasterization_origin = CGPoint {
|
||||
x: -metrics.rasterized_left as f64,
|
||||
y: metrics.rasterized_descent as f64,
|
||||
};
|
||||
|
||||
// Always draw black text on a white background
|
||||
// Fill the background
|
||||
cg_context.set_rgb_fill_color(1.0, 1.0, 1.0, 1.0);
|
||||
let rect = CGRect {
|
||||
origin: CGPoint {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
},
|
||||
size: CGSize {
|
||||
width: metrics.rasterized_width as f64,
|
||||
height: metrics.rasterized_height as f64,
|
||||
}
|
||||
};
|
||||
cg_context.fill_rect(rect);
|
||||
|
||||
// Set the text color
|
||||
cg_context.set_rgb_fill_color(0.0, 0.0, 0.0, 1.0);
|
||||
cg_context.set_text_drawing_mode(CGTextDrawingMode::CGTextFill);
|
||||
ct_font.draw_glyphs(&[glyph], &[rasterization_origin], cg_context.clone());
|
||||
|
||||
let rasterized_area = (metrics.rasterized_width * metrics.rasterized_height) as usize;
|
||||
let mut rasterized_pixels = cg_context.data().to_vec();
|
||||
|
||||
match render_mode {
|
||||
FontRenderMode::Alpha | FontRenderMode::Mono => {
|
||||
for i in 0..rasterized_area {
|
||||
let alpha = (rasterized_pixels[i * 4 + 3] as f32) / 255.0;
|
||||
for channel in &mut rasterized_pixels[(i*4)..(i*4 + 3)] {
|
||||
*channel = ((*channel as f32) / alpha) as u8;
|
||||
// We need to invert the pixels back since right now
|
||||
// transparent pixels are actually opaque white.
|
||||
for i in 0..metrics.rasterized_height {
|
||||
let current_height = (i * metrics.rasterized_width * 4) as usize;
|
||||
let end_row = current_height + (metrics.rasterized_width as usize * 4);
|
||||
|
||||
for mut pixel in rasterized_pixels[current_height .. end_row].chunks_mut(4) {
|
||||
pixel[0] = 255 - pixel[0];
|
||||
pixel[1] = 255 - pixel[1];
|
||||
pixel[2] = 255 - pixel[2];
|
||||
|
||||
pixel[3] = match render_mode {
|
||||
FontRenderMode::Subpixel => 255,
|
||||
_ => {
|
||||
assert_eq!(pixel[0], pixel[1]);
|
||||
assert_eq!(pixel[0], pixel[2]);
|
||||
pixel[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
FontRenderMode::Subpixel => {}
|
||||
}
|
||||
}; // end match
|
||||
} // end row
|
||||
} // end height
|
||||
|
||||
Some(RasterizedGlyph {
|
||||
width: metrics.rasterized_width,
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
use app_units::Au;
|
||||
use webrender_traits::{FontKey, FontRenderMode, GlyphDimensions, NativeFontHandle};
|
||||
|
||||
use freetype::freetype::{FTErrorMethods, FT_PIXEL_MODE_GRAY, FT_PIXEL_MODE_MONO, FT_PIXEL_MODE_LCD};
|
||||
use freetype::freetype::{FT_Done_FreeType, FT_RENDER_MODE_LCD, FT_Library_SetLcdFilter};
|
||||
use freetype::freetype::{FT_RENDER_MODE_NORMAL, FT_RENDER_MODE_MONO};
|
||||
use freetype::freetype::{FT_Render_Mode, FT_Pixel_Mode};
|
||||
use freetype::freetype::{FT_Done_FreeType, FT_Library_SetLcdFilter};
|
||||
use freetype::freetype::{FT_Library, FT_Set_Char_Size};
|
||||
use freetype::freetype::{FT_Face, FT_Long, FT_UInt, FT_F26Dot6};
|
||||
use freetype::freetype::{FT_Init_FreeType, FT_Load_Glyph, FT_Render_Glyph};
|
||||
|
@ -45,7 +44,9 @@ impl FontContext {
|
|||
let mut lib: FT_Library = ptr::null_mut();
|
||||
unsafe {
|
||||
let result = FT_Init_FreeType(&mut lib);
|
||||
if !result.succeeded() { panic!("Unable to initialize FreeType library {}", result); }
|
||||
if !result.succeeded() {
|
||||
panic!("Unable to initialize FreeType library {:?}", result);
|
||||
}
|
||||
|
||||
// TODO(gw): Check result of this to determine if freetype build supports subpixel.
|
||||
let result = FT_Library_SetLcdFilter(lib, FT_LcdFilter::FT_LCD_FILTER_DEFAULT);
|
||||
|
@ -140,9 +141,9 @@ impl FontContext {
|
|||
size,
|
||||
character) {
|
||||
let render_mode = match render_mode {
|
||||
FontRenderMode::Mono => FT_RENDER_MODE_MONO,
|
||||
FontRenderMode::Alpha => FT_RENDER_MODE_NORMAL,
|
||||
FontRenderMode::Subpixel => FT_RENDER_MODE_LCD,
|
||||
FontRenderMode::Mono => FT_Render_Mode::FT_RENDER_MODE_MONO,
|
||||
FontRenderMode::Alpha => FT_Render_Mode::FT_RENDER_MODE_NORMAL,
|
||||
FontRenderMode::Subpixel => FT_Render_Mode::FT_RENDER_MODE_LCD,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
|
@ -150,7 +151,6 @@ impl FontContext {
|
|||
|
||||
if result.succeeded() {
|
||||
let bitmap = &(*slot).bitmap;
|
||||
let bitmap_mode = bitmap.pixel_mode as u32;
|
||||
|
||||
let metrics = &(*slot).metrics;
|
||||
let mut glyph_width = (metrics.width >> 6) as i32;
|
||||
|
@ -159,74 +159,71 @@ impl FontContext {
|
|||
glyph_height as usize *
|
||||
4);
|
||||
|
||||
match bitmap_mode {
|
||||
FT_PIXEL_MODE_MONO => {
|
||||
// This is not exactly efficient... but it's only used by the
|
||||
// reftest pass when we have AA disabled on glyphs.
|
||||
let offset_x = (metrics.horiBearingX >> 6) as i32 - (*slot).bitmap_left;
|
||||
let offset_y = (metrics.horiBearingY >> 6) as i32 - (*slot).bitmap_top;
|
||||
if bitmap.pixel_mode == FT_Pixel_Mode::FT_PIXEL_MODE_MONO as u8 {
|
||||
// This is not exactly efficient... but it's only used by the
|
||||
// reftest pass when we have AA disabled on glyphs.
|
||||
let offset_x = (metrics.horiBearingX >> 6) as i32 - (*slot).bitmap_left;
|
||||
let offset_y = (metrics.horiBearingY >> 6) as i32 - (*slot).bitmap_top;
|
||||
|
||||
// Due to AA being disabled, the bitmap produced for mono
|
||||
// glyphs is often smaller than the reported glyph dimensions.
|
||||
// To account for this, place the rendered glyph within the
|
||||
// box of the glyph dimensions, filling in invalid pixels with
|
||||
// zero alpha.
|
||||
for iy in 0..glyph_height {
|
||||
let y = iy - offset_y;
|
||||
for ix in 0..glyph_width {
|
||||
let x = ix + offset_x;
|
||||
let valid_byte = x >= 0 &&
|
||||
y >= 0 &&
|
||||
x < bitmap.width &&
|
||||
y < bitmap.rows;
|
||||
let byte_value = if valid_byte {
|
||||
let byte_index = (y * bitmap.pitch) + (x >> 3);
|
||||
let bit_index = x & 7;
|
||||
let byte_ptr = bitmap.buffer.offset(byte_index as isize);
|
||||
let bit = (*byte_ptr & (0x80 >> bit_index)) != 0;
|
||||
if bit {
|
||||
0xff
|
||||
} else {
|
||||
0
|
||||
}
|
||||
// Due to AA being disabled, the bitmap produced for mono
|
||||
// glyphs is often smaller than the reported glyph dimensions.
|
||||
// To account for this, place the rendered glyph within the
|
||||
// box of the glyph dimensions, filling in invalid pixels with
|
||||
// zero alpha.
|
||||
for iy in 0..glyph_height {
|
||||
let y = iy - offset_y;
|
||||
for ix in 0..glyph_width {
|
||||
let x = ix + offset_x;
|
||||
let valid_byte = x >= 0 &&
|
||||
y >= 0 &&
|
||||
x < bitmap.width as i32 &&
|
||||
y < bitmap.rows as i32;
|
||||
let byte_value = if valid_byte {
|
||||
let byte_index = (y * bitmap.pitch as i32) + (x >> 3);
|
||||
let bit_index = x & 7;
|
||||
let byte_ptr = bitmap.buffer.offset(byte_index as isize);
|
||||
let bit = (*byte_ptr & (0x80 >> bit_index)) != 0;
|
||||
if bit {
|
||||
0xff
|
||||
} else {
|
||||
0
|
||||
};
|
||||
}
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
final_buffer.extend_from_slice(&[ 0xff, 0xff, 0xff, byte_value ]);
|
||||
}
|
||||
final_buffer.extend_from_slice(&[ 0xff, 0xff, 0xff, byte_value ]);
|
||||
}
|
||||
}
|
||||
FT_PIXEL_MODE_GRAY => {
|
||||
// We can assume that the reported glyph dimensions exactly
|
||||
// match the rasterized bitmap for normal alpha coverage glyphs.
|
||||
} else if bitmap.pixel_mode == FT_Pixel_Mode::FT_PIXEL_MODE_GRAY as u8 {
|
||||
// We can assume that the reported glyph dimensions exactly
|
||||
// match the rasterized bitmap for normal alpha coverage glyphs.
|
||||
|
||||
let buffer = slice::from_raw_parts(
|
||||
bitmap.buffer,
|
||||
(bitmap.width * bitmap.rows) as usize
|
||||
);
|
||||
let buffer = slice::from_raw_parts(
|
||||
bitmap.buffer,
|
||||
(bitmap.width * bitmap.rows) as usize
|
||||
);
|
||||
|
||||
// Convert to RGBA.
|
||||
for &byte in buffer.iter() {
|
||||
final_buffer.extend_from_slice(&[ 0xff, 0xff, 0xff, byte ]);
|
||||
// Convert to RGBA.
|
||||
for &byte in buffer.iter() {
|
||||
final_buffer.extend_from_slice(&[ 0xff, 0xff, 0xff, byte ]);
|
||||
}
|
||||
} else if bitmap.pixel_mode == FT_Pixel_Mode::FT_PIXEL_MODE_LCD as u8 {
|
||||
// Extra subpixel on each side of the glyph.
|
||||
glyph_width += 2;
|
||||
|
||||
for y in 0..bitmap.rows {
|
||||
for x in 0..(bitmap.width / 3) {
|
||||
let index = (y as i32 * bitmap.pitch) + (x as i32 * 3);
|
||||
let ptr = bitmap.buffer.offset(index as isize);
|
||||
let b = *ptr;
|
||||
let g = *(ptr.offset(1));
|
||||
let r = *(ptr.offset(2));
|
||||
final_buffer.extend_from_slice(&[ r, g, b, 0xff ]);
|
||||
}
|
||||
}
|
||||
FT_PIXEL_MODE_LCD => {
|
||||
// Extra subpixel on each side of the glyph.
|
||||
glyph_width += 2;
|
||||
|
||||
for y in 0..bitmap.rows {
|
||||
for x in 0..(bitmap.width / 3) {
|
||||
let index = (y * bitmap.pitch) + (x * 3);
|
||||
let ptr = bitmap.buffer.offset(index as isize);
|
||||
let b = *ptr;
|
||||
let g = *(ptr.offset(1));
|
||||
let r = *(ptr.offset(2));
|
||||
final_buffer.extend_from_slice(&[ r, g, b, 0xff ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => panic!("Unexpected render mode!"),
|
||||
} else {
|
||||
panic!("Unexpected render mode: {}!", bitmap.pixel_mode);
|
||||
}
|
||||
|
||||
glyph = Some(RasterizedGlyph {
|
||||
|
|
|
@ -18,7 +18,7 @@ lazy_static! {
|
|||
}
|
||||
|
||||
pub struct FontContext {
|
||||
fonts: HashMap<FontKey, dwrote::Font>,
|
||||
fonts: HashMap<FontKey, dwrote::FontFace>,
|
||||
}
|
||||
|
||||
pub struct RasterizedGlyph {
|
||||
|
@ -34,14 +34,19 @@ impl FontContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn add_raw_font(&mut self, font_key: &FontKey, _: &[u8]) {
|
||||
pub fn add_raw_font(&mut self, font_key: &FontKey, data: &[u8]) {
|
||||
if self.fonts.contains_key(font_key) {
|
||||
return
|
||||
}
|
||||
|
||||
debug!("DWrite WR backend can't do raw fonts yet, using Arial instead");
|
||||
|
||||
self.add_native_font(font_key, DEFAULT_FONT_DESCRIPTOR.clone());
|
||||
if let Some(font_file) = dwrote::FontFile::new_from_data(data) {
|
||||
let face = font_file.create_face(0, dwrote::DWRITE_FONT_SIMULATIONS_NONE);
|
||||
self.fonts.insert((*font_key).clone(), face);
|
||||
} else {
|
||||
// XXX add_raw_font needs to have a way to return an error
|
||||
debug!("DWrite WR failed to load font from data, using Arial instead");
|
||||
self.add_native_font(font_key, DEFAULT_FONT_DESCRIPTOR.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_native_font(&mut self, font_key: &FontKey, font_handle: dwrote::FontDescriptor) {
|
||||
|
@ -50,8 +55,9 @@ impl FontContext {
|
|||
}
|
||||
|
||||
let system_fc = dwrote::FontCollection::system();
|
||||
let realized_font = system_fc.get_font_from_descriptor(&font_handle).unwrap();
|
||||
self.fonts.insert((*font_key).clone(), realized_font);
|
||||
let font = system_fc.get_font_from_descriptor(&font_handle).unwrap();
|
||||
let face = font.create_font_face();
|
||||
self.fonts.insert((*font_key).clone(), face);
|
||||
}
|
||||
|
||||
fn get_glyph_dimensions_and_maybe_rasterize(&self,
|
||||
|
@ -61,8 +67,7 @@ impl FontContext {
|
|||
render_mode: Option<FontRenderMode>)
|
||||
-> (Option<GlyphDimensions>, Option<RasterizedGlyph>)
|
||||
{
|
||||
let font = self.fonts.get(&font_key).unwrap();
|
||||
let face = font.create_font_face();
|
||||
let face = self.fonts.get(&font_key).unwrap();
|
||||
let glyph = glyph as u16;
|
||||
|
||||
let glyph = glyph as u16;
|
||||
|
|
|
@ -76,6 +76,7 @@ pub enum PrimitiveKind {
|
|||
YuvImage,
|
||||
Border,
|
||||
Gradient,
|
||||
RadialGradient,
|
||||
BoxShadow,
|
||||
}
|
||||
|
||||
|
@ -248,6 +249,22 @@ pub struct GradientPrimitiveCpu {
|
|||
pub cache_dirty: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct RadialGradientPrimitiveGpu {
|
||||
pub start_center: LayerPoint,
|
||||
pub end_center: LayerPoint,
|
||||
pub start_radius: f32,
|
||||
pub end_radius: f32,
|
||||
pub padding: [f32; 2],
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RadialGradientPrimitiveCpu {
|
||||
pub stops_range: ItemRange,
|
||||
pub cache_dirty: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
struct InstanceRect {
|
||||
|
@ -412,6 +429,7 @@ pub enum PrimitiveContainer {
|
|||
YuvImage(YuvImagePrimitiveCpu, YuvImagePrimitiveGpu),
|
||||
Border(BorderPrimitiveCpu, BorderPrimitiveGpu),
|
||||
Gradient(GradientPrimitiveCpu, GradientPrimitiveGpu),
|
||||
RadialGradient(RadialGradientPrimitiveCpu, RadialGradientPrimitiveGpu),
|
||||
BoxShadow(BoxShadowPrimitiveGpu, Vec<LayerRect>),
|
||||
}
|
||||
|
||||
|
@ -422,6 +440,7 @@ pub struct PrimitiveStore {
|
|||
pub cpu_images: Vec<ImagePrimitiveCpu>,
|
||||
pub cpu_yuv_images: Vec<YuvImagePrimitiveCpu>,
|
||||
pub cpu_gradients: Vec<GradientPrimitiveCpu>,
|
||||
pub cpu_radial_gradients: Vec<RadialGradientPrimitiveCpu>,
|
||||
pub cpu_metadata: Vec<PrimitiveMetadata>,
|
||||
pub cpu_borders: Vec<BorderPrimitiveCpu>,
|
||||
|
||||
|
@ -448,6 +467,7 @@ impl PrimitiveStore {
|
|||
cpu_images: Vec::new(),
|
||||
cpu_yuv_images: Vec::new(),
|
||||
cpu_gradients: Vec::new(),
|
||||
cpu_radial_gradients: Vec::new(),
|
||||
cpu_borders: Vec::new(),
|
||||
gpu_geometry: GpuStore::new(),
|
||||
gpu_data16: GpuStore::new(),
|
||||
|
@ -596,6 +616,26 @@ impl PrimitiveStore {
|
|||
self.cpu_gradients.push(gradient_cpu);
|
||||
metadata
|
||||
}
|
||||
PrimitiveContainer::RadialGradient(radial_gradient_cpu, radial_gradient_gpu) => {
|
||||
let gpu_address = self.gpu_data32.push(radial_gradient_gpu);
|
||||
let gpu_stops_address = self.gpu_data32.alloc(radial_gradient_cpu.stops_range.length);
|
||||
|
||||
let metadata = PrimitiveMetadata {
|
||||
is_opaque: false,
|
||||
clip_source: clip_source,
|
||||
clip_cache_info: clip_info,
|
||||
prim_kind: PrimitiveKind::RadialGradient,
|
||||
cpu_prim_index: SpecificPrimitiveIndex(self.cpu_radial_gradients.len()),
|
||||
gpu_prim_index: gpu_address,
|
||||
gpu_data_address: gpu_stops_address,
|
||||
gpu_data_count: radial_gradient_cpu.stops_range.length as i32,
|
||||
render_task: None,
|
||||
clip_task: None,
|
||||
};
|
||||
|
||||
self.cpu_radial_gradients.push(radial_gradient_cpu);
|
||||
metadata
|
||||
}
|
||||
PrimitiveContainer::BoxShadow(box_shadow_gpu, instance_rects) => {
|
||||
let cache_key = PrimitiveCacheKey::BoxShadow(BoxShadowPrimitiveCacheKey {
|
||||
blur_radius: Au::from_f32_px(box_shadow_gpu.blur_radius),
|
||||
|
@ -689,7 +729,8 @@ impl PrimitiveStore {
|
|||
PrimitiveKind::Rectangle |
|
||||
PrimitiveKind::Border |
|
||||
PrimitiveKind::BoxShadow |
|
||||
PrimitiveKind::Gradient => {}
|
||||
PrimitiveKind::Gradient |
|
||||
PrimitiveKind::RadialGradient=> {}
|
||||
PrimitiveKind::TextRun => {
|
||||
let text = &mut self.cpu_text_runs[metadata.cpu_prim_index.0];
|
||||
let font_size_dp = text.logical_font_size.scale_by(device_pixel_ratio);
|
||||
|
@ -1018,6 +1059,26 @@ impl PrimitiveStore {
|
|||
}
|
||||
}
|
||||
|
||||
gradient.cache_dirty = false;
|
||||
}
|
||||
}
|
||||
PrimitiveKind::RadialGradient => {
|
||||
let gradient = &mut self.cpu_radial_gradients[metadata.cpu_prim_index.0];
|
||||
if gradient.cache_dirty {
|
||||
let src_stops = auxiliary_lists.gradient_stops(&gradient.stops_range);
|
||||
|
||||
debug_assert!(metadata.gpu_data_count == gradient.stops_range.length as i32);
|
||||
let dest_stops = self.gpu_data32.get_slice_mut(metadata.gpu_data_address,
|
||||
gradient.stops_range.length);
|
||||
|
||||
for (src, dest) in src_stops.iter().zip(dest_stops.iter_mut()) {
|
||||
*dest = GpuBlock32::from(GradientStop {
|
||||
offset: src.offset,
|
||||
color: src.color,
|
||||
padding: [0.0; 3],
|
||||
});
|
||||
}
|
||||
|
||||
gradient.cache_dirty = false;
|
||||
}
|
||||
}
|
||||
|
@ -1115,6 +1176,14 @@ impl From<GradientStop> for GpuBlock32 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RadialGradientPrimitiveGpu> for GpuBlock32 {
|
||||
fn from(data: RadialGradientPrimitiveGpu) -> GpuBlock32 {
|
||||
unsafe {
|
||||
mem::transmute::<RadialGradientPrimitiveGpu, GpuBlock32>(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<YuvImagePrimitiveGpu> for GpuBlock64 {
|
||||
fn from(data: YuvImagePrimitiveGpu) -> GpuBlock64 {
|
||||
unsafe {
|
||||
|
|
|
@ -196,22 +196,13 @@ impl RenderBackend {
|
|||
AuxiliaryLists::from_data(auxiliary_lists_data,
|
||||
auxiliary_lists_descriptor);
|
||||
|
||||
let frame = profile_counters.total_time.profile(|| {
|
||||
self.scene.set_root_display_list(pipeline_id,
|
||||
epoch,
|
||||
built_display_list,
|
||||
background_color,
|
||||
viewport_size,
|
||||
auxiliary_lists);
|
||||
|
||||
self.build_scene();
|
||||
self.render()
|
||||
});
|
||||
|
||||
if self.scene.root_pipeline_id.is_some() {
|
||||
self.publish_frame_and_notify_compositor(frame, &mut profile_counters);
|
||||
frame_counter += 1;
|
||||
}
|
||||
self.scene.set_root_display_list(pipeline_id,
|
||||
epoch,
|
||||
built_display_list,
|
||||
background_color,
|
||||
viewport_size,
|
||||
auxiliary_lists);
|
||||
self.build_scene();
|
||||
}
|
||||
ApiMsg::SetRootPipeline(pipeline_id) => {
|
||||
self.scene.set_root_pipeline_id(pipeline_id);
|
||||
|
@ -220,14 +211,7 @@ impl RenderBackend {
|
|||
continue;
|
||||
}
|
||||
|
||||
let frame = profile_counters.total_time.profile(|| {
|
||||
self.build_scene();
|
||||
self.render()
|
||||
});
|
||||
|
||||
// the root pipeline is guaranteed to be Some() at this point
|
||||
self.publish_frame_and_notify_compositor(frame, &mut profile_counters);
|
||||
frame_counter += 1;
|
||||
self.build_scene();
|
||||
}
|
||||
ApiMsg::Scroll(delta, cursor, move_phase) => {
|
||||
let frame = profile_counters.total_time.profile(|| {
|
||||
|
@ -515,4 +499,3 @@ impl GLContextDispatcher for WebRenderGLDispatcher {
|
|||
dispatcher.as_mut().unwrap().as_mut().unwrap().dispatch(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ use webrender_traits::{DeviceIntRect, DevicePoint, DeviceIntPoint, DeviceIntSize
|
|||
use webrender_traits::channel;
|
||||
use webrender_traits::VRCompositorHandler;
|
||||
|
||||
pub const VERTEX_TEXTURE_POOL: usize = 5;
|
||||
pub const MAX_VERTEX_TEXTURE_WIDTH: usize = 1024;
|
||||
|
||||
const GPU_TAG_CACHE_BOX_SHADOW: GpuProfileTag = GpuProfileTag { label: "C_BoxShadow", color: debug_colors::BLACK };
|
||||
|
@ -57,6 +58,7 @@ const GPU_TAG_PRIM_COMPOSITE: GpuProfileTag = GpuProfileTag { label: "Composite"
|
|||
const GPU_TAG_PRIM_TEXT_RUN: GpuProfileTag = GpuProfileTag { label: "TextRun", color: debug_colors::BLUE };
|
||||
const GPU_TAG_PRIM_GRADIENT: GpuProfileTag = GpuProfileTag { label: "Gradient", color: debug_colors::YELLOW };
|
||||
const GPU_TAG_PRIM_ANGLE_GRADIENT: GpuProfileTag = GpuProfileTag { label: "AngleGradient", color: debug_colors::POWDERBLUE };
|
||||
const GPU_TAG_PRIM_RADIAL_GRADIENT: GpuProfileTag = GpuProfileTag { label: "RadialGradient", color: debug_colors::LIGHTPINK };
|
||||
const GPU_TAG_PRIM_BOX_SHADOW: GpuProfileTag = GpuProfileTag { label: "BoxShadow", color: debug_colors::CYAN };
|
||||
const GPU_TAG_PRIM_BORDER: GpuProfileTag = GpuProfileTag { label: "Border", color: debug_colors::ORANGE };
|
||||
const GPU_TAG_PRIM_CACHE_IMAGE: GpuProfileTag = GpuProfileTag { label: "CacheImage", color: debug_colors::SILVER };
|
||||
|
@ -270,6 +272,52 @@ fn create_clip_shader(name: &'static str, device: &mut Device) -> ProgramId {
|
|||
program_id
|
||||
}
|
||||
|
||||
struct VertexTextures {
|
||||
layer_texture: VertexDataTexture,
|
||||
render_task_texture: VertexDataTexture,
|
||||
prim_geom_texture: VertexDataTexture,
|
||||
data16_texture: VertexDataTexture,
|
||||
data32_texture: VertexDataTexture,
|
||||
data64_texture: VertexDataTexture,
|
||||
data128_texture: VertexDataTexture,
|
||||
resource_rects_texture: VertexDataTexture,
|
||||
}
|
||||
|
||||
impl VertexTextures {
|
||||
fn new(device: &mut Device) -> VertexTextures {
|
||||
VertexTextures {
|
||||
layer_texture: VertexDataTexture::new(device),
|
||||
render_task_texture: VertexDataTexture::new(device),
|
||||
prim_geom_texture: VertexDataTexture::new(device),
|
||||
data16_texture: VertexDataTexture::new(device),
|
||||
data32_texture: VertexDataTexture::new(device),
|
||||
data64_texture: VertexDataTexture::new(device),
|
||||
data128_texture: VertexDataTexture::new(device),
|
||||
resource_rects_texture: VertexDataTexture::new(device),
|
||||
}
|
||||
}
|
||||
|
||||
fn init_frame(&mut self, device: &mut Device, frame: &mut Frame) {
|
||||
self.data16_texture.init(device, &mut frame.gpu_data16);
|
||||
self.data32_texture.init(device, &mut frame.gpu_data32);
|
||||
self.data64_texture.init(device, &mut frame.gpu_data64);
|
||||
self.data128_texture.init(device, &mut frame.gpu_data128);
|
||||
self.prim_geom_texture.init(device, &mut frame.gpu_geometry);
|
||||
self.resource_rects_texture.init(device, &mut frame.gpu_resource_rects);
|
||||
self.layer_texture.init(device, &mut frame.layer_texture_data);
|
||||
self.render_task_texture.init(device, &mut frame.render_task_data);
|
||||
|
||||
device.bind_texture(TextureSampler::Layers, self.layer_texture.id);
|
||||
device.bind_texture(TextureSampler::RenderTasks, self.render_task_texture.id);
|
||||
device.bind_texture(TextureSampler::Geometry, self.prim_geom_texture.id);
|
||||
device.bind_texture(TextureSampler::Data16, self.data16_texture.id);
|
||||
device.bind_texture(TextureSampler::Data32, self.data32_texture.id);
|
||||
device.bind_texture(TextureSampler::Data64, self.data64_texture.id);
|
||||
device.bind_texture(TextureSampler::Data128, self.data128_texture.id);
|
||||
device.bind_texture(TextureSampler::ResourceRects, self.resource_rects_texture.id);
|
||||
}
|
||||
}
|
||||
|
||||
/// The renderer is responsible for submitting to the GPU the work prepared by the
|
||||
/// RenderBackend.
|
||||
pub struct Renderer {
|
||||
|
@ -307,6 +355,7 @@ pub struct Renderer {
|
|||
ps_border: PrimitiveShader,
|
||||
ps_gradient: PrimitiveShader,
|
||||
ps_angle_gradient: PrimitiveShader,
|
||||
ps_radial_gradient: PrimitiveShader,
|
||||
ps_box_shadow: PrimitiveShader,
|
||||
ps_cache_image: PrimitiveShader,
|
||||
|
||||
|
@ -332,14 +381,8 @@ pub struct Renderer {
|
|||
blur_vao_id: VAOId,
|
||||
clip_vao_id: VAOId,
|
||||
|
||||
layer_texture: VertexDataTexture,
|
||||
render_task_texture: VertexDataTexture,
|
||||
prim_geom_texture: VertexDataTexture,
|
||||
data16_texture: VertexDataTexture,
|
||||
data32_texture: VertexDataTexture,
|
||||
data64_texture: VertexDataTexture,
|
||||
data128_texture: VertexDataTexture,
|
||||
resource_rects_texture: VertexDataTexture,
|
||||
vt_index: usize,
|
||||
vertex_textures: [VertexTextures; VERTEX_TEXTURE_POOL],
|
||||
|
||||
pipeline_epoch_map: HashMap<PipelineId, Epoch, BuildHasherDefault<FnvHasher>>,
|
||||
/// Used to dispatch functions to the main thread's event loop.
|
||||
|
@ -473,6 +516,10 @@ impl Renderer {
|
|||
&mut device,
|
||||
&[],
|
||||
options.precache_shaders);
|
||||
let ps_radial_gradient = PrimitiveShader::new("ps_radial_gradient",
|
||||
&mut device,
|
||||
&[],
|
||||
options.precache_shaders);
|
||||
let ps_cache_image = PrimitiveShader::new("ps_cache_image",
|
||||
&mut device,
|
||||
&[],
|
||||
|
@ -522,15 +569,13 @@ impl Renderer {
|
|||
|
||||
let debug_renderer = DebugRenderer::new(&mut device);
|
||||
|
||||
let layer_texture = VertexDataTexture::new(&mut device);
|
||||
let render_task_texture = VertexDataTexture::new(&mut device);
|
||||
let prim_geom_texture = VertexDataTexture::new(&mut device);
|
||||
|
||||
let data16_texture = VertexDataTexture::new(&mut device);
|
||||
let data32_texture = VertexDataTexture::new(&mut device);
|
||||
let data64_texture = VertexDataTexture::new(&mut device);
|
||||
let data128_texture = VertexDataTexture::new(&mut device);
|
||||
let resource_rects_texture = VertexDataTexture::new(&mut device);
|
||||
let vertex_textures = [
|
||||
VertexTextures::new(&mut device),
|
||||
VertexTextures::new(&mut device),
|
||||
VertexTextures::new(&mut device),
|
||||
VertexTextures::new(&mut device),
|
||||
VertexTextures::new(&mut device),
|
||||
];
|
||||
|
||||
let x0 = 0.0;
|
||||
let y0 = 0.0;
|
||||
|
@ -625,6 +670,7 @@ impl Renderer {
|
|||
ps_box_shadow: ps_box_shadow,
|
||||
ps_gradient: ps_gradient,
|
||||
ps_angle_gradient: ps_angle_gradient,
|
||||
ps_radial_gradient: ps_radial_gradient,
|
||||
ps_cache_image: ps_cache_image,
|
||||
ps_blend: ps_blend,
|
||||
ps_composite: ps_composite,
|
||||
|
@ -643,14 +689,8 @@ impl Renderer {
|
|||
prim_vao_id: prim_vao_id,
|
||||
blur_vao_id: blur_vao_id,
|
||||
clip_vao_id: clip_vao_id,
|
||||
layer_texture: layer_texture,
|
||||
render_task_texture: render_task_texture,
|
||||
prim_geom_texture: prim_geom_texture,
|
||||
data16_texture: data16_texture,
|
||||
data32_texture: data32_texture,
|
||||
data64_texture: data64_texture,
|
||||
data128_texture: data128_texture,
|
||||
resource_rects_texture: resource_rects_texture,
|
||||
vt_index: 0,
|
||||
vertex_textures: vertex_textures,
|
||||
pipeline_epoch_map: HashMap::with_hasher(Default::default()),
|
||||
main_thread_dispatcher: main_thread_dispatcher,
|
||||
cache_texture_id_map: Vec::new(),
|
||||
|
@ -1010,6 +1050,10 @@ impl Renderer {
|
|||
let shader = self.ps_angle_gradient.get(&mut self.device, transform_kind);
|
||||
(data, GPU_TAG_PRIM_ANGLE_GRADIENT, shader)
|
||||
}
|
||||
&PrimitiveBatchData::RadialGradient(ref data) => {
|
||||
let shader = self.ps_radial_gradient.get(&mut self.device, transform_kind);
|
||||
(data, GPU_TAG_PRIM_RADIAL_GRADIENT, shader)
|
||||
}
|
||||
};
|
||||
|
||||
let _gm = self.gpu_profile.add_marker(marker);
|
||||
|
@ -1312,8 +1356,7 @@ impl Renderer {
|
|||
self.render_targets.extend_from_slice(&new_targets);
|
||||
}
|
||||
|
||||
// Init textures and render targets to match this scene. This shouldn't
|
||||
// block in drivers, but it might be worth checking...
|
||||
// Init textures and render targets to match this scene.
|
||||
for (pass, texture_id) in frame.passes.iter().zip(self.render_targets.iter()) {
|
||||
self.device.init_texture(*texture_id,
|
||||
frame.cache_size.width as u32,
|
||||
|
@ -1324,23 +1367,12 @@ impl Renderer {
|
|||
None);
|
||||
}
|
||||
|
||||
self.layer_texture.init(&mut self.device, &mut frame.layer_texture_data);
|
||||
self.render_task_texture.init(&mut self.device, &mut frame.render_task_data);
|
||||
self.data16_texture.init(&mut self.device, &mut frame.gpu_data16);
|
||||
self.data32_texture.init(&mut self.device, &mut frame.gpu_data32);
|
||||
self.data64_texture.init(&mut self.device, &mut frame.gpu_data64);
|
||||
self.data128_texture.init(&mut self.device, &mut frame.gpu_data128);
|
||||
self.prim_geom_texture.init(&mut self.device, &mut frame.gpu_geometry);
|
||||
self.resource_rects_texture.init(&mut self.device, &mut frame.gpu_resource_rects);
|
||||
|
||||
self.device.bind_texture(TextureSampler::Layers, self.layer_texture.id);
|
||||
self.device.bind_texture(TextureSampler::RenderTasks, self.render_task_texture.id);
|
||||
self.device.bind_texture(TextureSampler::Geometry, self.prim_geom_texture.id);
|
||||
self.device.bind_texture(TextureSampler::Data16, self.data16_texture.id);
|
||||
self.device.bind_texture(TextureSampler::Data32, self.data32_texture.id);
|
||||
self.device.bind_texture(TextureSampler::Data64, self.data64_texture.id);
|
||||
self.device.bind_texture(TextureSampler::Data128, self.data128_texture.id);
|
||||
self.device.bind_texture(TextureSampler::ResourceRects, self.resource_rects_texture.id);
|
||||
// TODO(gw): This is a hack / workaround for #728.
|
||||
// We should find a better way to implement these updates rather
|
||||
// than wasting this extra memory, but for now it removes a large
|
||||
// number of driver stalls.
|
||||
self.vertex_textures[self.vt_index].init_frame(&mut self.device, frame);
|
||||
self.vt_index = (self.vt_index + 1) % VERTEX_TEXTURE_POOL;
|
||||
|
||||
let mut src_id = None;
|
||||
|
||||
|
@ -1412,8 +1444,8 @@ impl Renderer {
|
|||
|
||||
let dest_rect = DeviceIntRect::new(DeviceIntPoint::new(x0, y0),
|
||||
DeviceIntSize::new(rt_debug_size, rt_debug_size));
|
||||
self.device.blit_render_target(*texture_id,
|
||||
layer_index as i32,
|
||||
self.device.blit_render_target(Some((*texture_id, layer_index as i32)),
|
||||
None,
|
||||
dest_rect);
|
||||
|
||||
current_target += 1;
|
||||
|
|
|
@ -17,6 +17,7 @@ use prim_store::{ImagePrimitiveCpu, ImagePrimitiveGpu, YuvImagePrimitiveCpu, Yuv
|
|||
use prim_store::{PrimitiveKind, PrimitiveIndex, PrimitiveMetadata, TexelRect};
|
||||
use prim_store::{CLIP_DATA_GPU_SIZE, DeferredResolve};
|
||||
use prim_store::{GradientPrimitiveCpu, GradientPrimitiveGpu, GradientType};
|
||||
use prim_store::{RadialGradientPrimitiveCpu, RadialGradientPrimitiveGpu};
|
||||
use prim_store::{PrimitiveCacheKey, TextRunPrimitiveGpu, TextRunPrimitiveCpu};
|
||||
use prim_store::{PrimitiveStore, GpuBlock16, GpuBlock32, GpuBlock64, GpuBlock128};
|
||||
use profiler::FrameProfileCounters;
|
||||
|
@ -82,6 +83,7 @@ impl AlphaBatchHelpers for PrimitiveStore {
|
|||
PrimitiveKind::Image => AlphaBatchKind::Image,
|
||||
PrimitiveKind::YuvImage => AlphaBatchKind::YuvImage,
|
||||
PrimitiveKind::Rectangle => AlphaBatchKind::Rectangle,
|
||||
PrimitiveKind::RadialGradient => AlphaBatchKind::RadialGradient,
|
||||
PrimitiveKind::TextRun => {
|
||||
let text_run_cpu = &self.cpu_text_runs[metadata.cpu_prim_index.0];
|
||||
if text_run_cpu.blur_radius.0 == 0 {
|
||||
|
@ -115,7 +117,8 @@ impl AlphaBatchHelpers for PrimitiveStore {
|
|||
PrimitiveKind::Border |
|
||||
PrimitiveKind::BoxShadow |
|
||||
PrimitiveKind::Rectangle |
|
||||
PrimitiveKind::Gradient => [invalid; 3],
|
||||
PrimitiveKind::Gradient |
|
||||
PrimitiveKind::RadialGradient => [invalid; 3],
|
||||
PrimitiveKind::Image => {
|
||||
let image_cpu = &self.cpu_images[metadata.cpu_prim_index.0];
|
||||
[image_cpu.color_texture_id, invalid, invalid]
|
||||
|
@ -168,6 +171,7 @@ impl AlphaBatchHelpers for PrimitiveStore {
|
|||
PrimitiveKind::Image |
|
||||
PrimitiveKind::YuvImage |
|
||||
PrimitiveKind::Gradient |
|
||||
PrimitiveKind::RadialGradient |
|
||||
PrimitiveKind::BoxShadow => true,
|
||||
PrimitiveKind::Border => {
|
||||
let border = &self.cpu_borders[metadata.cpu_prim_index.0];
|
||||
|
@ -192,12 +196,13 @@ impl AlphaBatchHelpers for PrimitiveStore {
|
|||
let layer_index = layer_index.0 as i32;
|
||||
let global_prim_id = prim_index.0 as i32;
|
||||
let prim_address = metadata.gpu_prim_index;
|
||||
let clip_task_key = RenderTaskKey::CacheMask(MaskCacheKey::Primitive(prim_index));
|
||||
let clip_task_index = if metadata.clip_task.is_some() {
|
||||
let cache_task_id = RenderTaskId::Dynamic(clip_task_key);
|
||||
render_tasks.get_task_index(&cache_task_id, child_pass_index)
|
||||
} else {
|
||||
OPAQUE_TASK_INDEX
|
||||
let clip_task_index = match metadata.clip_task {
|
||||
Some(ref clip_task) => {
|
||||
render_tasks.get_task_index(&clip_task.id, child_pass_index)
|
||||
}
|
||||
None => {
|
||||
OPAQUE_TASK_INDEX
|
||||
}
|
||||
};
|
||||
let task_index = task_index.0 as i32;
|
||||
let clip_task_index = clip_task_index.0 as i32;
|
||||
|
@ -300,6 +305,18 @@ impl AlphaBatchHelpers for PrimitiveStore {
|
|||
z_sort_index: z_sort_index,
|
||||
});
|
||||
}
|
||||
&mut PrimitiveBatchData::RadialGradient(ref mut data) => {
|
||||
data.push(PrimitiveInstance {
|
||||
task_index: task_index,
|
||||
clip_task_index: clip_task_index,
|
||||
layer_index: layer_index,
|
||||
global_prim_id: global_prim_id,
|
||||
prim_address: prim_address,
|
||||
sub_index: metadata.gpu_data_address.0,
|
||||
user_data: [ metadata.gpu_data_count, 0 ],
|
||||
z_sort_index: z_sort_index,
|
||||
});
|
||||
}
|
||||
&mut PrimitiveBatchData::CacheImage(ref mut data) => {
|
||||
// Find the render task index for the render task
|
||||
// that this primitive depends on. Pass it to the
|
||||
|
@ -380,9 +397,9 @@ pub struct RenderTaskIndex(usize);
|
|||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub enum MaskCacheKey {
|
||||
Primitive(PrimitiveIndex),
|
||||
StackingContext(StackingContextIndex),
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub enum RenderTaskKey {
|
||||
/// Draw this primitive to a cache target.
|
||||
|
@ -1408,6 +1425,7 @@ enum AlphaBatchKind {
|
|||
Border,
|
||||
AlignedGradient,
|
||||
AngleGradient,
|
||||
RadialGradient,
|
||||
BoxShadow,
|
||||
CacheImage,
|
||||
}
|
||||
|
@ -1571,6 +1589,7 @@ pub enum PrimitiveBatchData {
|
|||
Borders(Vec<PrimitiveInstance>),
|
||||
AlignedGradient(Vec<PrimitiveInstance>),
|
||||
AngleGradient(Vec<PrimitiveInstance>),
|
||||
RadialGradient(Vec<PrimitiveInstance>),
|
||||
BoxShadow(Vec<PrimitiveInstance>),
|
||||
CacheImage(Vec<PrimitiveInstance>),
|
||||
Blend(Vec<PrimitiveInstance>),
|
||||
|
@ -1657,6 +1676,7 @@ impl PrimitiveBatch {
|
|||
AlphaBatchKind::Border => PrimitiveBatchData::Borders(Vec::new()),
|
||||
AlphaBatchKind::AlignedGradient => PrimitiveBatchData::AlignedGradient(Vec::new()),
|
||||
AlphaBatchKind::AngleGradient => PrimitiveBatchData::AngleGradient(Vec::new()),
|
||||
AlphaBatchKind::RadialGradient => PrimitiveBatchData::RadialGradient(Vec::new()),
|
||||
AlphaBatchKind::BoxShadow => PrimitiveBatchData::BoxShadow(Vec::new()),
|
||||
AlphaBatchKind::Blend | AlphaBatchKind::Composite => unreachable!(),
|
||||
AlphaBatchKind::CacheImage => PrimitiveBatchData::CacheImage(Vec::new()),
|
||||
|
@ -2274,6 +2294,32 @@ impl FrameBuilder {
|
|||
PrimitiveContainer::Gradient(gradient_cpu, gradient_gpu));
|
||||
}
|
||||
|
||||
pub fn add_radial_gradient(&mut self,
|
||||
rect: LayerRect,
|
||||
clip_region: &ClipRegion,
|
||||
start_center: LayerPoint,
|
||||
start_radius: f32,
|
||||
end_center: LayerPoint,
|
||||
end_radius: f32,
|
||||
stops: ItemRange) {
|
||||
let radial_gradient_cpu = RadialGradientPrimitiveCpu {
|
||||
stops_range: stops,
|
||||
cache_dirty: true,
|
||||
};
|
||||
|
||||
let radial_gradient_gpu = RadialGradientPrimitiveGpu {
|
||||
start_center: start_center,
|
||||
end_center: end_center,
|
||||
start_radius: start_radius,
|
||||
end_radius: end_radius,
|
||||
padding: [0.0, 0.0],
|
||||
};
|
||||
|
||||
self.add_primitive(&rect,
|
||||
clip_region,
|
||||
PrimitiveContainer::RadialGradient(radial_gradient_cpu, radial_gradient_gpu));
|
||||
}
|
||||
|
||||
pub fn add_text(&mut self,
|
||||
rect: LayerRect,
|
||||
clip_region: &ClipRegion,
|
||||
|
@ -2618,9 +2664,18 @@ impl FrameBuilder {
|
|||
}
|
||||
|
||||
// Try to create a mask if we may need to.
|
||||
if prim_clip_info.is_some() || !clip_info_stack.is_empty() {
|
||||
if !clip_info_stack.is_empty() {
|
||||
// If the primitive doesn't have a specific clip,
|
||||
// key the task ID off the stacking context. This means
|
||||
// that two primitives which are only clipped by the
|
||||
// stacking context stack can share clip masks during
|
||||
// render task assignment to targets.
|
||||
let mask_key = match prim_clip_info {
|
||||
Some(..) => MaskCacheKey::Primitive(prim_index),
|
||||
None => MaskCacheKey::StackingContext(*sc_index),
|
||||
};
|
||||
let mask_opt = RenderTask::new_mask(prim_bounding_rect,
|
||||
MaskCacheKey::Primitive(prim_index),
|
||||
mask_key,
|
||||
&clip_info_stack,
|
||||
&self.layer_store);
|
||||
match mask_opt {
|
||||
|
|
|
@ -117,6 +117,7 @@ pub unsafe extern fn wr_api_set_root_display_list(api: &mut RenderApi,
|
|||
epoch,
|
||||
LayoutSize::new(viewport_width, viewport_height),
|
||||
frame_builder.dl_builder);
|
||||
api.generate_frame();
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern fn wr_window_new(window_id: u64,
|
||||
|
@ -221,6 +222,7 @@ pub extern fn wr_dp_end(state: &mut WrState, api: &mut RenderApi, epoch: u32) {
|
|||
Epoch(epoch),
|
||||
LayoutSize::new(width as f32, height as f32),
|
||||
fb.dl_builder);
|
||||
api.generate_frame();
|
||||
}
|
||||
|
||||
|
||||
|
@ -451,6 +453,7 @@ pub extern fn wr_init_window(root_pipeline_id: u64,
|
|||
|
||||
let pipeline_id = u64_to_pipeline_id(root_pipeline_id);
|
||||
api.set_root_pipeline(pipeline_id);
|
||||
api.generate_frame();
|
||||
|
||||
let state = Box::new(WrWindowState {
|
||||
renderer: renderer,
|
||||
|
@ -588,6 +591,7 @@ pub extern fn wr_window_dp_end(window: &mut WrWindowState, state: &mut WrState)
|
|||
*epoch,
|
||||
LayoutSize::new(width as f32, height as f32),
|
||||
fb.dl_builder);
|
||||
window.api.generate_frame();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -622,6 +626,7 @@ pub extern fn wr_delete_image(window: &mut WrWindowState, key: ImageKey) {
|
|||
#[no_mangle]
|
||||
pub extern fn wr_api_set_root_pipeline(api: &mut RenderApi, pipeline_id: u64) {
|
||||
api.set_root_pipeline(u64_to_pipeline_id(pipeline_id));
|
||||
api.generate_frame();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
|
@ -25,7 +25,7 @@ serde_derive = {version = "0.8", optional = true}
|
|||
ipc-channel = { version = "0.5.0", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-graphics = "0.4"
|
||||
core-graphics = "0.5"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
dwrote = "0.1.1"
|
||||
|
|
|
@ -260,4 +260,3 @@ impl RenderApi {
|
|||
(namespace, id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use {AuxiliaryLists, AuxiliaryListsDescriptor, BorderDisplayItem, BorderRadius};
|
|||
use {BorderSide, BoxShadowClipMode, BoxShadowDisplayItem, BuiltDisplayList};
|
||||
use {BuiltDisplayListDescriptor, ClipRegion, ComplexClipRegion, ColorF};
|
||||
use {DisplayItem, DisplayListMode, FilterOp, YuvColorSpace};
|
||||
use {FontKey, GlyphInstance, GradientDisplayItem, GradientStop, IframeDisplayItem};
|
||||
use {FontKey, GlyphInstance, GradientDisplayItem, RadialGradientDisplayItem, GradientStop, IframeDisplayItem};
|
||||
use {ImageDisplayItem, ImageKey, ImageMask, ImageRendering, ItemRange, MixBlendMode, PipelineId};
|
||||
use {PushScrollLayerItem, PushStackingContextDisplayItem, RectangleDisplayItem, ScrollLayerId};
|
||||
use {ScrollPolicy, ServoScrollRootId, SpecificDisplayItem, StackingContext, TextDisplayItem};
|
||||
|
@ -255,6 +255,31 @@ impl DisplayListBuilder {
|
|||
self.list.push(display_item);
|
||||
}
|
||||
|
||||
pub fn push_radial_gradient(&mut self,
|
||||
rect: LayoutRect,
|
||||
clip: ClipRegion,
|
||||
start_center: LayoutPoint,
|
||||
start_radius: f32,
|
||||
end_center: LayoutPoint,
|
||||
end_radius: f32,
|
||||
stops: Vec<GradientStop>) {
|
||||
let item = RadialGradientDisplayItem {
|
||||
start_center: start_center,
|
||||
start_radius: start_radius,
|
||||
end_center: end_center,
|
||||
end_radius: end_radius,
|
||||
stops: self.auxiliary_lists_builder.add_gradient_stops(&stops),
|
||||
};
|
||||
|
||||
let display_item = DisplayItem {
|
||||
item: SpecificDisplayItem::RadialGradient(item),
|
||||
rect: rect,
|
||||
clip: clip,
|
||||
};
|
||||
|
||||
self.list.push(display_item);
|
||||
}
|
||||
|
||||
pub fn push_stacking_context(&mut self,
|
||||
scroll_policy: ScrollPolicy,
|
||||
bounds: LayoutRect,
|
||||
|
|
|
@ -305,6 +305,14 @@ pub struct GradientStop {
|
|||
}
|
||||
known_heap_size!(0, GradientStop);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub struct RadialGradientDisplayItem {
|
||||
pub start_center: LayoutPoint,
|
||||
pub start_radius: f32,
|
||||
pub end_center: LayoutPoint,
|
||||
pub end_radius: f32,
|
||||
pub stops: ItemRange,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub struct PushStackingContextDisplayItem {
|
||||
|
@ -531,6 +539,7 @@ pub enum SpecificDisplayItem {
|
|||
Border(BorderDisplayItem),
|
||||
BoxShadow(BoxShadowDisplayItem),
|
||||
Gradient(GradientDisplayItem),
|
||||
RadialGradient(RadialGradientDisplayItem),
|
||||
Iframe(IframeDisplayItem),
|
||||
PushStackingContext(PushStackingContextDisplayItem),
|
||||
PopStackingContext,
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"d0114f648b7f61e473b61c6d682fefaa4e3fadf2101aff056e2ffc52e9229d87",".travis.yml":"ed428615e11c6a76a8fb12dd8d4f87ba278cb2b9a1ebb0703afa931b3c5b9704","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"9391c5bc37299eb7969cbc13f265ffc83badd4461f330ede68131824a8ced3a3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"4a45abeb1e684e30bb361dfa7db59189423348e18d310cbae694b7c8c57cd86a","src/base.rs":"3f3d5d69bd79b146cc3c0402de6260f7531c04e6a44b080f4ec7c8cedebd1337","src/color_space.rs":"7d447e774e85cc33de574637a93c9a8550b681c8d4b94e99f95261ea9740e288","src/context.rs":"663577ad071ecd45b6b7ac34ac3f0b13289136291774161db8b768851958b945","src/data_provider.rs":"899a5762ea472b828e1726e1cefc8d2dbd237772ce171cf6b31a79f144ce8df1","src/display.rs":"906cbcb13f8214308a6afcfb3abdd04e409f48ce62673574d40087486f38b36d","src/font.rs":"635ee3d1039c807e00fe93b974c9e375c532f09c99322dd93b9496783a662c0a","src/geometry.rs":"9f59dcf55f393a3fa001afe8aea68a85a3c9a06239aeafe6da5d2823ed37b271","src/lib.rs":"ed510924bf8978d8864779d49180aeae8d07b31b7eec9392dc0421e6f0c922d3","src/private.rs":"87c96ed2002bd567bf02535b4c6e8e3f22827afb2dd92ee17d91cfb45bc6072c"},"package":"66e998abb8823fecd2a8a7205429b17a340d447d8c69b3bce86846dcdea3e33b"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"d0114f648b7f61e473b61c6d682fefaa4e3fadf2101aff056e2ffc52e9229d87",".travis.yml":"b71b9a6f84b9263b2b89be6ec90dff5920ee68cf9e5768d73ed71957de2d0670","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"369e564eec78780281f752fa17783b729951c2d703e1dce0f234f8c81ab79d24","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"4a45abeb1e684e30bb361dfa7db59189423348e18d310cbae694b7c8c57cd86a","src/base.rs":"3f3d5d69bd79b146cc3c0402de6260f7531c04e6a44b080f4ec7c8cedebd1337","src/color_space.rs":"7d447e774e85cc33de574637a93c9a8550b681c8d4b94e99f95261ea9740e288","src/context.rs":"7c764ffde2e0ebaecd30ced31ece29f82ddea2f3c8145f4ea59882df38fec0d2","src/data_provider.rs":"899a5762ea472b828e1726e1cefc8d2dbd237772ce171cf6b31a79f144ce8df1","src/display.rs":"906cbcb13f8214308a6afcfb3abdd04e409f48ce62673574d40087486f38b36d","src/event.rs":"7f25a98207f200f10717c2765179ece8ba02600767b7c194c49854e7bfaa470c","src/event_source.rs":"6d1c1378dab8988c46dd3bf20639913716418980b9b490a37a0d5120c60ad580","src/font.rs":"635ee3d1039c807e00fe93b974c9e375c532f09c99322dd93b9496783a662c0a","src/geometry.rs":"9f59dcf55f393a3fa001afe8aea68a85a3c9a06239aeafe6da5d2823ed37b271","src/lib.rs":"efed3638b05e6a806a6fa0c544893afeec931f6c6889bd4a69d8fd2f9838967f","src/private.rs":"87c96ed2002bd567bf02535b4c6e8e3f22827afb2dd92ee17d91cfb45bc6072c"},"package":"8bd94d0f0b2bbcbfeeb670fc48654afde7a13c2c551ca9d2b9a6cfafdafe1a64"}
|
|
@ -5,5 +5,9 @@ rust:
|
|||
- beta
|
||||
- stable
|
||||
|
||||
script:
|
||||
- cargo test
|
||||
- cargo test --features="elcapitan"
|
||||
|
||||
notifications:
|
||||
webhooks: http://build.servo.org:54856/travis
|
||||
|
|
|
@ -3,10 +3,14 @@ name = "core-graphics"
|
|||
description = "Bindings to Core Graphics for OS X"
|
||||
homepage = "https://github.com/servo/core-graphics-rs"
|
||||
repository = "https://github.com/servo/core-graphics-rs"
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MIT / Apache-2.0"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
elcapitan = []
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
core-foundation = "0.2"
|
||||
|
|
|
@ -14,6 +14,7 @@ use libc::{c_void, size_t};
|
|||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
use geometry::CGRect;
|
||||
|
||||
#[repr(C)]
|
||||
pub enum CGTextDrawingMode {
|
||||
|
@ -190,6 +191,12 @@ impl CGContext {
|
|||
CGContextSetTextDrawingMode(self.as_concrete_TypeRef(), mode)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fill_rect(&self, rect: CGRect) {
|
||||
unsafe {
|
||||
CGContextFillRect(self.as_concrete_TypeRef(), rect)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "ApplicationServices", kind = "framework")]
|
||||
|
@ -225,5 +232,7 @@ extern {
|
|||
green: CGFloat,
|
||||
blue: CGFloat,
|
||||
alpha: CGFloat);
|
||||
fn CGContextFillRect(context: CGContextRef,
|
||||
rect: CGRect);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,285 @@
|
|||
use core_foundation::base::{CFRelease, CFRetain, CFTypeID, CFTypeRef, TCFType};
|
||||
use geometry::CGPoint;
|
||||
use event_source::{CGEventSource,CGEventSourceRef};
|
||||
|
||||
use libc;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
pub type CGKeyCode = libc::uint16_t;
|
||||
|
||||
/// Flags for events
|
||||
///
|
||||
/// [Ref](http://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-700/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h)
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum CGEventFlags {
|
||||
// Device-independent modifier key bits.
|
||||
AlphaShift = 0x00010000,
|
||||
Shift = 0x00020000,
|
||||
Control = 0x00040000,
|
||||
Alternate = 0x00080000,
|
||||
Command = 0x00100000,
|
||||
|
||||
// Special key identifiers.
|
||||
Help = 0x00400000,
|
||||
SecondaryFn = 0x00800000,
|
||||
|
||||
// Identifies key events from numeric keypad area on extended keyboards.
|
||||
NumericPad = 0x00200000,
|
||||
|
||||
// Indicates if mouse/pen movement events are not being coalesced
|
||||
NonCoalesced = 0x00000100,
|
||||
}
|
||||
|
||||
/// Constants that specify the different types of input events.
|
||||
///
|
||||
/// [Ref](http://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-700/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h)
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum CGEventType {
|
||||
Null = 1 << 0,
|
||||
|
||||
// Mouse events.
|
||||
LeftMouseDown = 1 << 1,
|
||||
LeftMouseUp = 1 << 2,
|
||||
RightMouseDown = 1 << 3,
|
||||
RightMouseUp = 1 << 4,
|
||||
MouseMoved = 1 << 5,
|
||||
LeftMouseDragged = 1 << 6,
|
||||
RightMouseDragged = 1 << 7,
|
||||
|
||||
// Keyboard events.
|
||||
KeyDown = 1 << 10,
|
||||
KeyUp = 1 << 11,
|
||||
FlagsChanged = 1 << 12,
|
||||
|
||||
// Specialized control devices.
|
||||
ScrollWheel = 1 << 22,
|
||||
TabletPointer = 1 << 23,
|
||||
TabletProximity = 1 << 24,
|
||||
OtherMouseDown = 1 << 25,
|
||||
OtherMouseUp = 1 << 26,
|
||||
OtherMouseDragged = 1 << 27,
|
||||
|
||||
// Out of band event types. These are delivered to the event tap callback
|
||||
// to notify it of unusual conditions that disable the event tap.
|
||||
TapDisabledByTimeout = 0xFFFFFFFE,
|
||||
TapDisabledByUserInput = 0xFFFFFFFF,
|
||||
}
|
||||
|
||||
// Constants that specify buttons on a one, two, or three-button mouse.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum CGMouseButton {
|
||||
Left,
|
||||
Right,
|
||||
Center,
|
||||
}
|
||||
|
||||
/// Possible tapping points for events.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum CGEventTapLocation {
|
||||
HID,
|
||||
Session,
|
||||
AnnotatedSession,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct __CGEvent;
|
||||
|
||||
pub type CGEventRef = *const __CGEvent;
|
||||
|
||||
pub struct CGEvent {
|
||||
obj: CGEventRef,
|
||||
}
|
||||
|
||||
impl Clone for CGEvent {
|
||||
#[inline]
|
||||
fn clone(&self) -> CGEvent {
|
||||
unsafe {
|
||||
TCFType::wrap_under_get_rule(self.obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for CGEvent {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let ptr = self.as_CFTypeRef();
|
||||
assert!(ptr != ptr::null());
|
||||
CFRelease(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TCFType<CGEventRef> for CGEvent {
|
||||
#[inline]
|
||||
fn as_concrete_TypeRef(&self) -> CGEventRef {
|
||||
self.obj
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_get_rule(reference: CGEventRef) -> CGEvent {
|
||||
let reference: CGEventRef = mem::transmute(CFRetain(mem::transmute(reference)));
|
||||
TCFType::wrap_under_create_rule(reference)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_CFTypeRef(&self) -> CFTypeRef {
|
||||
unsafe {
|
||||
mem::transmute(self.as_concrete_TypeRef())
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_create_rule(obj: CGEventRef) -> CGEvent {
|
||||
CGEvent {
|
||||
obj: obj,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn type_id() -> CFTypeID {
|
||||
unsafe {
|
||||
CGEventGetTypeID()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CGEvent {
|
||||
pub fn new(source: CGEventSource) -> Result<CGEvent, ()> {
|
||||
unsafe {
|
||||
let event_ref = CGEventCreate(source.as_concrete_TypeRef());
|
||||
if event_ref != ptr::null() {
|
||||
Ok(TCFType::wrap_under_create_rule(event_ref))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_keyboard_event(
|
||||
source: CGEventSource,
|
||||
keycode: CGKeyCode,
|
||||
keydown: bool
|
||||
) -> Result<CGEvent, ()> {
|
||||
unsafe {
|
||||
let event_ref = CGEventCreateKeyboardEvent(source.as_concrete_TypeRef(), keycode, keydown);
|
||||
if event_ref != ptr::null() {
|
||||
Ok(TCFType::wrap_under_create_rule(event_ref))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_mouse_event(
|
||||
source: CGEventSource,
|
||||
mouse_type: CGEventType,
|
||||
mouse_cursor_position: CGPoint,
|
||||
mouse_button: CGMouseButton
|
||||
) -> Result<CGEvent, ()> {
|
||||
unsafe {
|
||||
let event_ref = CGEventCreateMouseEvent(source.as_concrete_TypeRef(), mouse_type,
|
||||
mouse_cursor_position, mouse_button);
|
||||
if event_ref != ptr::null() {
|
||||
Ok(TCFType::wrap_under_create_rule(event_ref))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn post(&self, tap_location: CGEventTapLocation) {
|
||||
unsafe {
|
||||
CGEventPost(tap_location, self.as_concrete_TypeRef());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn location(&self) -> CGPoint {
|
||||
unsafe {
|
||||
CGEventGetLocation(self.as_concrete_TypeRef())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "elcapitan")]
|
||||
pub fn post_to_pid(&self, pid: libc::pid_t) {
|
||||
unsafe {
|
||||
CGEventPostToPid(pid, self.as_concrete_TypeRef());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_flags(&self, flags: CGEventFlags) {
|
||||
unsafe {
|
||||
CGEventSetFlags(self.as_concrete_TypeRef(), flags);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_flags(&self) -> CGEventFlags {
|
||||
unsafe {
|
||||
CGEventGetFlags(self.as_concrete_TypeRef())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "ApplicationServices", kind = "framework")]
|
||||
extern {
|
||||
/// Return the type identifier for the opaque type `CGEventRef'.
|
||||
fn CGEventGetTypeID() -> CFTypeID;
|
||||
|
||||
/// Return a new event using the event source `source'. If `source' is NULL,
|
||||
/// the default source is used.
|
||||
fn CGEventCreate(source: CGEventSourceRef) -> CGEventRef;
|
||||
|
||||
/// Return a new keyboard event.
|
||||
///
|
||||
/// The event source may be taken from another event, or may be NULL. Based
|
||||
/// on the virtual key code values entered, the appropriate key down, key up,
|
||||
/// or flags changed events are generated.
|
||||
///
|
||||
/// All keystrokes needed to generate a character must be entered, including
|
||||
/// SHIFT, CONTROL, OPTION, and COMMAND keys. For example, to produce a 'Z',
|
||||
/// the SHIFT key must be down, the 'z' key must go down, and then the SHIFT
|
||||
/// and 'z' key must be released:
|
||||
fn CGEventCreateKeyboardEvent(source: CGEventSourceRef, keycode: CGKeyCode,
|
||||
keydown: bool) -> CGEventRef;
|
||||
|
||||
/// Return a new mouse event.
|
||||
///
|
||||
/// The event source may be taken from another event, or may be NULL.
|
||||
/// `mouseType' should be one of the mouse event types. `mouseCursorPosition'
|
||||
/// should be the position of the mouse cursor in global coordinates.
|
||||
/// `mouseButton' should be the button that's changing state; `mouseButton'
|
||||
/// is ignored unless `mouseType' is one of `kCGEventOtherMouseDown',
|
||||
/// `kCGEventOtherMouseDragged', or `kCGEventOtherMouseUp'.
|
||||
///
|
||||
/// The current implemementation of the event system supports a maximum of
|
||||
/// thirty-two buttons. Mouse button 0 is the primary button on the mouse.
|
||||
/// Mouse button 1 is the secondary mouse button (right). Mouse button 2 is
|
||||
/// the center button, and the remaining buttons are in USB device order.
|
||||
fn CGEventCreateMouseEvent(source: CGEventSourceRef, mouseType: CGEventType,
|
||||
mouseCursorPosition: CGPoint, mouseButton: CGMouseButton) -> CGEventRef;
|
||||
|
||||
/// Post an event into the event stream at a specified location.
|
||||
///
|
||||
/// This function posts the specified event immediately before any event taps
|
||||
/// instantiated for that location, and the event passes through any such
|
||||
/// taps.
|
||||
fn CGEventPost(tapLocation: CGEventTapLocation, event: CGEventRef);
|
||||
|
||||
#[cfg(feature = "elcapitan")]
|
||||
/// Post an event to a specified process ID
|
||||
fn CGEventPostToPid(pid: libc::pid_t, event: CGEventRef);
|
||||
|
||||
/// Set the event flags of an event.
|
||||
fn CGEventSetFlags(event: CGEventRef, flags: CGEventFlags);
|
||||
|
||||
/// Return the event flags of an event.
|
||||
fn CGEventGetFlags(event: CGEventRef) -> CGEventFlags;
|
||||
|
||||
/// Return the location of an event in global display coordinates.
|
||||
/// CGPointZero is returned if event is not a valid CGEventRef.
|
||||
fn CGEventGetLocation(event: CGEventRef) -> CGPoint;
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
use core_foundation::base::{CFRelease, CFRetain, CFTypeID, CFTypeRef, TCFType};
|
||||
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
/// Possible source states of an event source.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum CGEventSourceStateID {
|
||||
Private = -1,
|
||||
CombinedSessionState = 0,
|
||||
HIDSystemState = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct __CGEventSource;
|
||||
|
||||
pub type CGEventSourceRef = *const __CGEventSource;
|
||||
|
||||
pub struct CGEventSource {
|
||||
obj: CGEventSourceRef,
|
||||
}
|
||||
|
||||
impl Clone for CGEventSource {
|
||||
#[inline]
|
||||
fn clone(&self) -> CGEventSource {
|
||||
unsafe {
|
||||
TCFType::wrap_under_get_rule(self.obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for CGEventSource {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let ptr = self.as_CFTypeRef();
|
||||
assert!(ptr != ptr::null());
|
||||
CFRelease(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TCFType<CGEventSourceRef> for CGEventSource {
|
||||
#[inline]
|
||||
fn as_concrete_TypeRef(&self) -> CGEventSourceRef {
|
||||
self.obj
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_get_rule(reference: CGEventSourceRef) -> CGEventSource {
|
||||
let reference: CGEventSourceRef = mem::transmute(CFRetain(mem::transmute(reference)));
|
||||
TCFType::wrap_under_create_rule(reference)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_CFTypeRef(&self) -> CFTypeRef {
|
||||
unsafe {
|
||||
mem::transmute(self.as_concrete_TypeRef())
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn wrap_under_create_rule(obj: CGEventSourceRef) -> CGEventSource {
|
||||
CGEventSource {
|
||||
obj: obj,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn type_id() -> CFTypeID {
|
||||
unsafe {
|
||||
CGEventSourceGetTypeID()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CGEventSource {
|
||||
pub fn new(state_id: CGEventSourceStateID) -> Result<CGEventSource, ()> {
|
||||
unsafe {
|
||||
let event_source_ref = CGEventSourceCreate(state_id);
|
||||
if event_source_ref != ptr::null() {
|
||||
Ok(TCFType::wrap_under_create_rule(event_source_ref))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "ApplicationServices", kind = "framework")]
|
||||
extern {
|
||||
/// Return the type identifier for the opaque type `CGEventSourceRef'.
|
||||
fn CGEventSourceGetTypeID() -> CFTypeID;
|
||||
|
||||
/// Return a Quartz event source created with a specified source state.
|
||||
fn CGEventSourceCreate(stateID: CGEventSourceStateID) -> CGEventSourceRef;
|
||||
}
|
|
@ -16,7 +16,8 @@ pub mod color_space;
|
|||
pub mod context;
|
||||
pub mod data_provider;
|
||||
pub mod display;
|
||||
pub mod event;
|
||||
pub mod event_source;
|
||||
pub mod font;
|
||||
pub mod geometry;
|
||||
pub mod private;
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"d0114f648b7f61e473b61c6d682fefaa4e3fadf2101aff056e2ffc52e9229d87",".travis.yml":"10240f3098e41a47ff65e60a06d044fd6913aaa79a83f12d080b1efd63d55972","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"3e4acc0e26c3db22d2462590955f0ae52035dd34af96353d342808b8b288cd76","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"d9df5c37cb98436dbf8162af9c3449fea1eab41511d326840759d46d514bcada","src/font_collection.rs":"d4ca7f741fd54b4b22b823833dfa1f1ccd78a26cf112119ae992572835e48df6","src/font_descriptor.rs":"c38e79d9ba1249065707fdaa1e307ea6838f1156073675696e70133f2de7cd11","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"b1fc720a9ab7ae4f054f0767e05ba5640b2d9fc8c34d05ae04f25b9dd44f6b81"},"package":"2debbf22a8358e5e270e958b6d65694667be7a2ef9c3a2bf05a0872a3124dc98"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"d0114f648b7f61e473b61c6d682fefaa4e3fadf2101aff056e2ffc52e9229d87",".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"e185b9d848cdb6eda1bafc616b76c2452f80861f098610c5568ea68aa06f8877","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"d9df5c37cb98436dbf8162af9c3449fea1eab41511d326840759d46d514bcada","src/font_collection.rs":"d4ca7f741fd54b4b22b823833dfa1f1ccd78a26cf112119ae992572835e48df6","src/font_descriptor.rs":"cedc4bd303abd4519c7c95201672ce5652f7396cd34383c059f945eefb64623b","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"b1fc720a9ab7ae4f054f0767e05ba5640b2d9fc8c34d05ae04f25b9dd44f6b81"},"package":"642fa40165b6c53bbd3f636951ffc3e1a3fd3c47e7d00598523c3e8c9321ed0c"}
|
|
@ -1,5 +1,8 @@
|
|||
language: rust
|
||||
rust: nightly
|
||||
rust:
|
||||
- nightly
|
||||
- beta
|
||||
- stable
|
||||
os: osx
|
||||
notifications:
|
||||
webhooks: http://build.servo.org:54856/travis
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "core-text"
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Bindings to the Core Text framework."
|
||||
license = "MIT/Apache-2.0"
|
||||
|
@ -11,4 +11,4 @@ libc = "0.2"
|
|||
|
||||
[target.x86_64-apple-darwin.dependencies]
|
||||
core-foundation = "0.2"
|
||||
core-graphics = "0.4"
|
||||
core-graphics = "0.5"
|
||||
|
|
|
@ -42,6 +42,7 @@ pub const kCTFontCondensedTrait: CTFontSymbolicTraits = (1 << 6);
|
|||
pub const kCTFontMonoSpaceTrait: CTFontSymbolicTraits = (1 << 10);
|
||||
pub const kCTFontVerticalTrait: CTFontSymbolicTraits = (1 << 11);
|
||||
pub const kCTFontUIOptimizedTrait: CTFontSymbolicTraits = (1 << 12);
|
||||
pub const kCTFontColorGlyphsTrait: CTFontSymbolicTraits = (1 << 13);
|
||||
pub const kCTFontClassMaskTrait: CTFontSymbolicTraits = (15 << kCTFontClassMaskShift );
|
||||
|
||||
pub trait SymbolicTraitAccessors {
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"172610b244a5ee8a8e2f1f045058b8abf9291d84bb76bf8779d2fd420419c2d6","Cargo.toml":"681db6fd4be42bd99d2614ccb39e62f0910bd50bc84e56143c039205bae0596e","README.md":"d69d75705e2582721cbfb2d3b4b2af052c71679057a0b2ac53a22c03f1755bba","build.rs":"fea382a72243440bcfc334229684fecd2e0021f740dd95d2e2df267744cce402","src/bitmap_render_target.rs":"53a172ef42447f8433c5c315f40459c0260a0c44f2ba9ae49ec546d284dd0c73","src/comptr.rs":"4635880cac6639fcf90cfa87e9d10d90dbaf03b4ae0e9c7de834ed48c669892b","src/font.rs":"e792eed304dfcc6ab99d16076d48b5ec941bd18113e506970898a58db4df5d5b","src/font_collection.rs":"969fa3abf141dc3504774886f4783fda4a74cd5a198c643f8a77fc1af4e75258","src/font_face.rs":"f76c3cfef079df9211cf26d67b07140199762293938889a7f4b120eda0427cd5","src/font_family.rs":"403da9f8f9903cbe7f9f79636497b273f9885e200f53af99f9d4e483f11d6889","src/font_file.rs":"36313b4c6f1e29797f2da79e9ade2a5d15bcd8867707fc9746cdb98da973a550","src/gdi_interop.rs":"627a39c72d162308826ac1090972179d39f9962c8e7f29925983744a96862d84","src/glyph_run_analysis.rs":"f816225daa285624f1a1a74c7a5803a1e6b255b494c80cc77760cbc2b45ffbc5","src/helpers.rs":"5d6f164468234ca8806dc1cea117b42dbfae80cc4c9ae965cb0556efdb364682","src/lib.rs":"6b66c101c343816f606abff74ef7cc68896f1745cd800830f3ae73536452ea51","src/rendering_params.rs":"9b132aef922f1ff3df06a1b126eccb6a397e81a04625afdb7b72dc2f968c92cd","src/test.rs":"576dff73b5339d11bf821366797ae47801c4b6eceffbe3e9f40a871b700fe5b9","src/types.rs":"53e81cee77c3011b6a82088adf890bd508c779c2ed6d6b0c92502e08d3c21ff0"},"package":"22f91bd605c96566d22699af63ad29a7417bd8a9493570450634858e80c27ff3"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"172610b244a5ee8a8e2f1f045058b8abf9291d84bb76bf8779d2fd420419c2d6","Cargo.toml":"2abdbe33c0b8b7167287225ef902e43548a1b602959a1a9ace2525fe08550f59","README.md":"d69d75705e2582721cbfb2d3b4b2af052c71679057a0b2ac53a22c03f1755bba","build.rs":"fea382a72243440bcfc334229684fecd2e0021f740dd95d2e2df267744cce402","src/bitmap_render_target.rs":"53a172ef42447f8433c5c315f40459c0260a0c44f2ba9ae49ec546d284dd0c73","src/com_helpers.rs":"fccb4b36379ae3454a88aa32a8e5c09e46ef5f5626266dde1fe5f40a992de39c","src/comptr.rs":"218435689f505769686e07cfc5428852dda90b849a0d48e670f632307f5edc7c","src/font.rs":"e792eed304dfcc6ab99d16076d48b5ec941bd18113e506970898a58db4df5d5b","src/font_collection.rs":"969fa3abf141dc3504774886f4783fda4a74cd5a198c643f8a77fc1af4e75258","src/font_face.rs":"f76c3cfef079df9211cf26d67b07140199762293938889a7f4b120eda0427cd5","src/font_family.rs":"403da9f8f9903cbe7f9f79636497b273f9885e200f53af99f9d4e483f11d6889","src/font_file.rs":"60ad02fc25765a2c113175ea372e98a2be0d84aa65fef9246b6a0192e63ff708","src/font_file_loader_impl.rs":"0d304ad99ff1e6874510a1498223329d798ff75b417e3db7e823a695003dfe92","src/gdi_interop.rs":"627a39c72d162308826ac1090972179d39f9962c8e7f29925983744a96862d84","src/glyph_run_analysis.rs":"f816225daa285624f1a1a74c7a5803a1e6b255b494c80cc77760cbc2b45ffbc5","src/helpers.rs":"5d6f164468234ca8806dc1cea117b42dbfae80cc4c9ae965cb0556efdb364682","src/lib.rs":"ae3e07d640aff19442486dfe1501ee797a650598ea7519ee8525a9fa8bbdaa3f","src/rendering_params.rs":"9b132aef922f1ff3df06a1b126eccb6a397e81a04625afdb7b72dc2f968c92cd","src/test.rs":"d77e45f8866abeea070cbbafd4cbde62d875292e8d191310a04c70091978547c","src/types.rs":"53e81cee77c3011b6a82088adf890bd508c779c2ed6d6b0c92502e08d3c21ff0"},"package":"570707c940fc7b7fc627011fe2c8abedaea562b03bde715e3ee2dd3d6857a03c"}
|
|
@ -3,7 +3,7 @@ name = "dwrote"
|
|||
description = "Lightweight binding to DirectWrite."
|
||||
repository = "https://github.com/vvuk/dwrote-rs"
|
||||
license = "MPL-2.0"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
authors = ["Vladimir Vukicevic <vladimir@pobox.com>"]
|
||||
build = "build.rs"
|
||||
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
|
||||
// This is only handy for implementing a single-interface-implementing IUnknown.
|
||||
//
|
||||
// it assumes that there's a UuidOf$interface GUID globally defined
|
||||
|
||||
DEFINE_GUID!{UuidOfIUnknown, 0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
|
||||
|
||||
macro_rules! guid_equals {
|
||||
($left:expr, $right:expr) => {
|
||||
$left.Data1 == $right.Data1 &&
|
||||
$left.Data2 == $right.Data2 &&
|
||||
$left.Data3 == $right.Data3 &&
|
||||
$left.Data4 == $right.Data4
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! implement_iunknown {
|
||||
($interface:ident, $iuud:ident, $typ:ident) => {
|
||||
IUnknownVtbl {
|
||||
QueryInterface: {
|
||||
unsafe extern "system" fn QueryInterface(This: *mut IUnknown,
|
||||
riid: REFIID,
|
||||
ppvObject: *mut *mut c_void) -> HRESULT {
|
||||
let this = if guid_equals!(*riid, $iuud) {
|
||||
mem::transmute(This)
|
||||
} else if guid_equals!(*riid, UuidOfIUnknown) {
|
||||
mem::transmute(This)
|
||||
} else {
|
||||
return $crate::winapi::E_NOINTERFACE;
|
||||
};
|
||||
|
||||
(*This).AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
QueryInterface
|
||||
},
|
||||
AddRef: {
|
||||
unsafe extern "system" fn AddRef(This: *mut IUnknown) -> ULONG {
|
||||
let this = $typ::from_interface(This);
|
||||
let count = this.refcount.fetch_add(1, atomic::Ordering::Relaxed) + 1;
|
||||
count as ULONG
|
||||
}
|
||||
AddRef
|
||||
},
|
||||
Release: {
|
||||
unsafe extern "system" fn Release(This: *mut IUnknown) -> ULONG {
|
||||
let this = $typ::from_interface(This);
|
||||
let count = this.refcount.fetch_sub(1, atomic::Ordering::Release) - 1;
|
||||
if count == 0 {
|
||||
FontFileStream::destroy(This);
|
||||
}
|
||||
count as ULONG
|
||||
}
|
||||
Release
|
||||
},
|
||||
}
|
||||
};
|
||||
(static $interface:ident, $iuud:ident, $typ:ident) => {
|
||||
IUnknownVtbl {
|
||||
QueryInterface: {
|
||||
unsafe extern "system" fn QueryInterface(This: *mut IUnknown,
|
||||
riid: REFIID,
|
||||
ppvObject: *mut *mut c_void) -> HRESULT {
|
||||
let this = if guid_equals!(*riid, $iuud) {
|
||||
mem::transmute(This)
|
||||
} else if guid_equals!(*riid, UuidOfIUnknown) {
|
||||
mem::transmute(This)
|
||||
} else {
|
||||
return $crate::winapi::E_NOINTERFACE;
|
||||
};
|
||||
|
||||
(*This).AddRef();
|
||||
*ppvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
QueryInterface
|
||||
},
|
||||
AddRef: {
|
||||
unsafe extern "system" fn AddRef(_This: *mut IUnknown) -> ULONG {
|
||||
1
|
||||
}
|
||||
AddRef
|
||||
},
|
||||
Release: {
|
||||
unsafe extern "system" fn Release(_This: *mut IUnknown) -> ULONG {
|
||||
1
|
||||
}
|
||||
Release
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ComRepr<Type, Vtbl>(*const Vtbl, Type);
|
||||
|
||||
pub trait Com<Interface> where Self: Sized {
|
||||
type Vtbl: 'static;
|
||||
|
||||
fn vtbl() -> &'static Self::Vtbl;
|
||||
|
||||
fn into_interface(self) -> *mut Interface {
|
||||
let com = Box::new(ComRepr(Self::vtbl(), self));
|
||||
Box::into_raw(com) as *mut Interface
|
||||
}
|
||||
|
||||
unsafe fn from_interface<'a>(thing: *mut Interface) -> &'a mut Self {
|
||||
&mut (*(thing as *mut ComRepr<Self, Self::Vtbl>)).1
|
||||
}
|
||||
|
||||
unsafe fn destroy(thing: *mut Interface) {
|
||||
Box::from_raw(thing as *mut ComRepr<Self, Self::Vtbl>);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,15 @@ impl<T> ComPtr<T> {
|
|||
ComPtr { ptr: ptr::null_mut() }
|
||||
}
|
||||
|
||||
pub fn from_ptr(ptr: *mut T) -> Self {
|
||||
unsafe {
|
||||
if !ptr.is_null() {
|
||||
(*(ptr as *mut IUnknown)).AddRef();
|
||||
}
|
||||
}
|
||||
ComPtr { ptr: ptr }
|
||||
}
|
||||
|
||||
pub fn already_addrefed(ptr: *mut T) -> Self {
|
||||
ComPtr { ptr: ptr }
|
||||
}
|
||||
|
@ -102,3 +111,5 @@ impl<T> Drop for ComPtr<T> {
|
|||
self.release();
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T> Send for ComPtr<T> {}
|
||||
|
|
|
@ -10,15 +10,66 @@ use comptr::ComPtr;
|
|||
|
||||
use winapi;
|
||||
|
||||
use font_file_loader_impl::DataFontHelper;
|
||||
use font_face::FontFace;
|
||||
use super::DWriteFactory;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FontFile {
|
||||
native: UnsafeCell<ComPtr<winapi::IDWriteFontFile>>,
|
||||
data_key: usize,
|
||||
face_type: winapi::DWRITE_FONT_FACE_TYPE,
|
||||
}
|
||||
|
||||
impl FontFile {
|
||||
pub fn new_from_data(data: &[u8]) -> Option<FontFile> {
|
||||
let (font_file, key) = DataFontHelper::register_font_data(data);
|
||||
|
||||
let mut ff = FontFile {
|
||||
native: UnsafeCell::new(font_file),
|
||||
data_key: key,
|
||||
face_type: winapi::DWRITE_FONT_FACE_TYPE_UNKNOWN,
|
||||
};
|
||||
|
||||
if ff.analyze() == false {
|
||||
DataFontHelper::unregister_font_data(key);
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(ff)
|
||||
}
|
||||
|
||||
fn analyze(&mut self) -> bool {
|
||||
let mut face_type = winapi::DWRITE_FONT_FACE_TYPE_UNKNOWN;
|
||||
unsafe {
|
||||
let mut supported = 0;
|
||||
let mut _file_type = winapi::DWRITE_FONT_FILE_TYPE_UNKNOWN;
|
||||
let mut _num_faces = 0;
|
||||
|
||||
let hr = (*self.as_ptr()).Analyze(&mut supported, &mut _file_type, &mut face_type, &mut _num_faces);
|
||||
if hr != 0 || supported == 0 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
self.face_type = face_type;
|
||||
true
|
||||
}
|
||||
|
||||
pub fn take(native: ComPtr<winapi::IDWriteFontFile>) -> FontFile {
|
||||
FontFile {
|
||||
let mut ff = FontFile {
|
||||
native: UnsafeCell::new(native),
|
||||
data_key: 0,
|
||||
face_type: winapi::DWRITE_FONT_FACE_TYPE_UNKNOWN,
|
||||
};
|
||||
ff.analyze();
|
||||
ff
|
||||
}
|
||||
|
||||
pub fn data_key(&self) -> Option<usize> {
|
||||
if self.data_key != 0 {
|
||||
Some(self.data_key)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,4 +113,14 @@ impl FontFile {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn create_face(&self, face_index: u32, simulations: winapi::DWRITE_FONT_SIMULATIONS) -> FontFace {
|
||||
unsafe {
|
||||
let mut face: ComPtr<winapi::IDWriteFontFace> = ComPtr::new();
|
||||
let ptr = self.as_ptr();
|
||||
let hr = (*DWriteFactory()).CreateFontFace(self.face_type, 1, &ptr,
|
||||
face_index, simulations, face.getter_addrefs());
|
||||
assert!(hr == 0);
|
||||
FontFace::take(face)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
#![allow(non_snake_case, non_upper_case_globals)]
|
||||
|
||||
use std::{mem, ptr};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Mutex, atomic};
|
||||
use std::marker::Send;
|
||||
use winapi::{IUnknown, IUnknownVtbl};
|
||||
use winapi::{IDWriteFontFileStream, IDWriteFontFileStreamVtbl};
|
||||
use winapi::{IDWriteFontFileLoader, IDWriteFontFileLoaderVtbl};
|
||||
use winapi::IDWriteFontFile;
|
||||
use winapi::{E_FAIL, E_INVALIDARG, E_NOTIMPL, S_OK};
|
||||
use winapi::{c_void, UINT32, UINT64, ULONG, HRESULT, REFIID};
|
||||
|
||||
use super::DWriteFactory;
|
||||
use comptr::ComPtr;
|
||||
use com_helpers::*;
|
||||
|
||||
struct FontFileLoader;
|
||||
|
||||
DEFINE_GUID!{UuidOfIDWriteFontFileLoader, 0x727cad4e, 0xd6af, 0x4c9e, 0x8a, 0x08, 0xd6, 0x95, 0xb1, 0x1c, 0xaa, 0x49}
|
||||
DEFINE_GUID!{UuidOfIDWriteFontFileStream, 0x6d4865fe, 0x0ab8, 0x4d91, 0x8f, 0x62, 0x5d, 0xd6, 0xbe, 0x34, 0xa3, 0xe0}
|
||||
|
||||
const FontFileLoaderVtbl: &'static IDWriteFontFileLoaderVtbl = &IDWriteFontFileLoaderVtbl {
|
||||
parent: implement_iunknown!(static IDWriteFontFileLoader, UuidOfIDWriteFontFileLoader, FontFileLoader),
|
||||
CreateStreamFromKey: {
|
||||
unsafe extern "system" fn CreateStreamFromKey(
|
||||
_This: *mut IDWriteFontFileLoader,
|
||||
fontFileReferenceKey: *const c_void,
|
||||
fontFileReferenceKeySize: UINT32,
|
||||
fontFileStream: *mut *mut IDWriteFontFileStream) -> HRESULT
|
||||
{
|
||||
if fontFileReferenceKey.is_null() || fontFileStream.is_null() {
|
||||
return E_INVALIDARG
|
||||
}
|
||||
assert!(fontFileReferenceKeySize == mem::size_of::<usize>() as UINT32);
|
||||
let key = *(fontFileReferenceKey as *const usize);
|
||||
let stream = match FONT_FILE_STREAM_MAP.lock().unwrap().get_mut(&key) {
|
||||
None => {
|
||||
*fontFileStream = ptr::null_mut();
|
||||
return E_FAIL
|
||||
}
|
||||
Some(file_stream) => {
|
||||
file_stream.as_ptr()
|
||||
}
|
||||
};
|
||||
|
||||
*fontFileStream = stream;
|
||||
S_OK
|
||||
}
|
||||
CreateStreamFromKey
|
||||
}
|
||||
};
|
||||
|
||||
impl Com<IDWriteFontFileLoader> for FontFileLoader {
|
||||
type Vtbl = IDWriteFontFileLoaderVtbl;
|
||||
fn vtbl() -> &'static IDWriteFontFileLoaderVtbl { FontFileLoaderVtbl }
|
||||
}
|
||||
|
||||
impl Com<IUnknown> for FontFileLoader {
|
||||
type Vtbl = IUnknownVtbl;
|
||||
fn vtbl() -> &'static IUnknownVtbl { &FontFileLoaderVtbl.parent }
|
||||
}
|
||||
|
||||
impl FontFileLoader {
|
||||
pub fn new() -> FontFileLoader {
|
||||
FontFileLoader
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for FontFileLoader {}
|
||||
unsafe impl Sync for FontFileLoader {}
|
||||
|
||||
struct FontFileStream {
|
||||
refcount: atomic::AtomicUsize,
|
||||
data: Vec<u8>,
|
||||
}
|
||||
|
||||
const FontFileStreamVtbl: &'static IDWriteFontFileStreamVtbl = &IDWriteFontFileStreamVtbl {
|
||||
parent: implement_iunknown!(IDWriteFontFileStream, UuidOfIDWriteFontFileStream, FontFileStream),
|
||||
ReadFileFragment: {
|
||||
unsafe extern "system" fn ReadFileFragment(
|
||||
This: *mut IDWriteFontFileStream,
|
||||
fragmentStart: *mut *const c_void,
|
||||
fileOffset: UINT64,
|
||||
fragmentSize: UINT64,
|
||||
fragmentContext: *mut *mut c_void) -> HRESULT
|
||||
{
|
||||
let this = FontFileStream::from_interface(This);
|
||||
*fragmentContext = ptr::null_mut();
|
||||
if (fileOffset + fragmentSize) as usize > this.data.len() {
|
||||
return E_INVALIDARG
|
||||
}
|
||||
let index = fileOffset as usize;
|
||||
*fragmentStart = this.data[index..].as_mut_ptr() as *const c_void;
|
||||
S_OK
|
||||
}
|
||||
ReadFileFragment
|
||||
},
|
||||
ReleaseFileFragment: {
|
||||
unsafe extern "system" fn ReleaseFileFragment(
|
||||
_This: *mut IDWriteFontFileStream,
|
||||
_fragmentContext: *mut c_void)
|
||||
{
|
||||
}
|
||||
ReleaseFileFragment
|
||||
},
|
||||
GetFileSize: {
|
||||
unsafe extern "system" fn GetFileSize(
|
||||
This: *mut IDWriteFontFileStream,
|
||||
fileSize: *mut UINT64) -> HRESULT
|
||||
{
|
||||
let this = FontFileStream::from_interface(This);
|
||||
*fileSize = this.data.len() as UINT64;
|
||||
S_OK
|
||||
}
|
||||
GetFileSize
|
||||
},
|
||||
GetLastWriteTime: {
|
||||
unsafe extern "system" fn GetLastWriteTime(
|
||||
_This: *mut IDWriteFontFileStream,
|
||||
_lastWriteTime: *mut UINT64) -> HRESULT
|
||||
{
|
||||
E_NOTIMPL
|
||||
}
|
||||
GetLastWriteTime
|
||||
},
|
||||
};
|
||||
|
||||
impl FontFileStream {
|
||||
pub fn new(data: &[u8]) -> FontFileStream {
|
||||
FontFileStream {
|
||||
refcount: atomic::ATOMIC_USIZE_INIT,
|
||||
data: data.to_vec(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Com<IDWriteFontFileStream> for FontFileStream {
|
||||
type Vtbl = IDWriteFontFileStreamVtbl;
|
||||
fn vtbl() -> &'static IDWriteFontFileStreamVtbl { FontFileStreamVtbl }
|
||||
}
|
||||
|
||||
impl Com<IUnknown> for FontFileStream {
|
||||
type Vtbl = IUnknownVtbl;
|
||||
fn vtbl() -> &'static IUnknownVtbl { &FontFileStreamVtbl.parent }
|
||||
}
|
||||
|
||||
static mut FONT_FILE_KEY: atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT;
|
||||
|
||||
lazy_static! {
|
||||
static ref FONT_FILE_STREAM_MAP: Mutex<HashMap<usize, ComPtr<IDWriteFontFileStream>>> = {
|
||||
Mutex::new(HashMap::new())
|
||||
};
|
||||
|
||||
static ref FONT_FILE_LOADER: Mutex<ComPtr<IDWriteFontFileLoader>> = {
|
||||
let ffl_native = FontFileLoader::new();
|
||||
let ffl = ComPtr::<IDWriteFontFileLoader>::from_ptr(ffl_native.into_interface());
|
||||
unsafe {
|
||||
let hr = (*DWriteFactory()).RegisterFontFileLoader(ffl.as_ptr());
|
||||
assert!(hr == 0);
|
||||
}
|
||||
Mutex::new(ffl)
|
||||
};
|
||||
}
|
||||
|
||||
pub struct DataFontHelper;
|
||||
|
||||
impl DataFontHelper {
|
||||
pub fn register_font_data(font_data: &[u8]) -> (ComPtr<IDWriteFontFile>, usize) {
|
||||
unsafe {
|
||||
let key = FONT_FILE_KEY.fetch_add(1, atomic::Ordering::Relaxed);
|
||||
let font_file_stream_native = FontFileStream::new(font_data);
|
||||
let font_file_stream = ComPtr::from_ptr(font_file_stream_native.into_interface());
|
||||
{
|
||||
let mut map = FONT_FILE_STREAM_MAP.lock().unwrap();
|
||||
map.insert(key, font_file_stream);
|
||||
}
|
||||
|
||||
let mut font_file: ComPtr<IDWriteFontFile> = ComPtr::new();
|
||||
{
|
||||
let loader = FONT_FILE_LOADER.lock().unwrap();
|
||||
let hr = (*DWriteFactory()).CreateCustomFontFileReference(
|
||||
mem::transmute(&key),
|
||||
mem::size_of::<usize>() as UINT32,
|
||||
loader.as_ptr(),
|
||||
font_file.getter_addrefs());
|
||||
assert!(hr == S_OK);
|
||||
}
|
||||
|
||||
(font_file, key)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unregister_font_data(key: usize) {
|
||||
let mut map = FONT_FILE_STREAM_MAP.lock().unwrap();
|
||||
if map.remove(&key).is_none() {
|
||||
panic!("unregister_font_data: trying to unregister key that is no longer registered");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,8 +58,13 @@ pub use winapi::{DWRITE_RENDERING_MODE_DEFAULT,
|
|||
pub use winapi::{DWRITE_MEASURING_MODE_NATURAL,
|
||||
DWRITE_MEASURING_MODE_GDI_CLASSIC,
|
||||
DWRITE_MEASURING_MODE_GDI_NATURAL};
|
||||
pub use winapi::{DWRITE_FONT_SIMULATIONS_NONE,
|
||||
DWRITE_FONT_SIMULATIONS_BOLD,
|
||||
DWRITE_FONT_SIMULATIONS_OBLIQUE};
|
||||
pub use winapi::{DWRITE_TEXTURE_ALIASED_1x1, DWRITE_TEXTURE_CLEARTYPE_3x1};
|
||||
|
||||
#[macro_use] mod com_helpers;
|
||||
|
||||
mod bitmap_render_target; pub use bitmap_render_target::BitmapRenderTarget;
|
||||
mod font; pub use font::Font;
|
||||
mod font_collection; pub use font_collection::FontCollection;
|
||||
|
@ -70,6 +75,11 @@ mod gdi_interop; pub use gdi_interop::GdiInterop;
|
|||
mod rendering_params; pub use rendering_params::RenderingParams;
|
||||
mod glyph_run_analysis; pub use glyph_run_analysis::GlyphRunAnalysis;
|
||||
|
||||
// This is an internal implementation of FontFileLoader, for our utility
|
||||
// functions. We don't wrap the DWriteFontFileLoader interface and
|
||||
// related things.
|
||||
mod font_file_loader_impl;
|
||||
|
||||
DEFINE_GUID!{UuidOfIDWriteFactory, 0xb859ee5a, 0xd838, 0x4b5b, 0xa2, 0xe8, 0x1a, 0xdc, 0x7d, 0x93, 0xdb, 0x48}
|
||||
|
||||
unsafe impl Sync for ComPtr<IDWriteFactory> { }
|
||||
|
|
|
@ -38,15 +38,35 @@ fn test_get_font_file_bytes() {
|
|||
FontStretch::Normal,
|
||||
FontStyle::Normal);
|
||||
let face = arial_font.create_font_face();
|
||||
println!("face1: {:?}", unsafe { face.as_ptr1() });
|
||||
let files = face.get_files();
|
||||
assert!(files.len() > 0);
|
||||
|
||||
let bytes = files[0].get_font_file_bytes();
|
||||
println!("Bytes length: {}", bytes.len());
|
||||
assert!(bytes.len() > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_font_file_from_bytes() {
|
||||
let system_fc = FontCollection::system();
|
||||
|
||||
let arial_family = system_fc.get_font_family_by_name("Arial").unwrap();
|
||||
let arial_font = arial_family.get_first_matching_font(FontWeight::Regular,
|
||||
FontStretch::Normal,
|
||||
FontStyle::Normal);
|
||||
let face = arial_font.create_font_face();
|
||||
let files = face.get_files();
|
||||
assert!(files.len() > 0);
|
||||
|
||||
let bytes = files[0].get_font_file_bytes();
|
||||
assert!(bytes.len() > 0);
|
||||
|
||||
// now go back
|
||||
let new_font = FontFile::new_from_data(&bytes);
|
||||
assert!(new_font.is_some());
|
||||
|
||||
let new_font = new_font.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_glyph_image() {
|
||||
let system_fc = FontCollection::system();
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"13342ffa9256624fdc9d3a0323c8d454e42648391683e844a58f752f48925c8c",".travis.yml":"b66e958a27e280a79ae1742be91e02cbaf7392851d430f19b13f3619861860e2","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"5fe96337714216da86037a4402cf35ecefe4ed738fe92852f739a588ddeb3f05","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","Makefile.in":"7348b5f8a577048279b3f98e2c2b5705f506cf5b4b1e6bb542cc0b1e62468411","README.md":"755e885eb12f7b0b459c8b579f20cd941e55f0197b947591131daf048c5d7bc6","configure":"e0e6ba778e5f5784fa87abf235aa4f3da750d922bfb26a34803d9674577d56ec","src/freetype.rs":"9c76e90f04798dc4a05ad54ddccad5b1d64590a588f97dab5e2bd8f251affbd9","src/lib.rs":"aee922a00b7d102f72f96114340f3fb9ba950249f8fdc1c0a43e68ba370cc11a","src/tt_os2.rs":"9517c53fc4e575ceb615d554dc72812dcbb532bf94883d51202b24caae1a1418"},"package":"812b23abc34a2cd1e1a0635a8d65e9bc83f2dd6e7879b92683ed0b9faaa629e5"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"13342ffa9256624fdc9d3a0323c8d454e42648391683e844a58f752f48925c8c",".travis.yml":"b66e958a27e280a79ae1742be91e02cbaf7392851d430f19b13f3619861860e2","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"7d09decba6c94743746eb13ebd51735356ec6a1125d33da708d3e141148c81c3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","Makefile.in":"7348b5f8a577048279b3f98e2c2b5705f506cf5b4b1e6bb542cc0b1e62468411","README.md":"755e885eb12f7b0b459c8b579f20cd941e55f0197b947591131daf048c5d7bc6","configure":"e0e6ba778e5f5784fa87abf235aa4f3da750d922bfb26a34803d9674577d56ec","etc/bindgen.sh":"116938e8c7a4500e056f719c66bdc896739c8b0a34a16e6a29a9e335f7458648","etc/bindings.h":"f6110c7a692e24f9c6d1c4a78ba8a7750952b397b86a5ac466353c7c57cfb7bb","src/freetype.rs":"0e27e13cca4f79569718fa4c247b8f7020388d8a84ad5f971c376a0658073cfa","src/lib.rs":"812e79af46e33a93420c8301ad95392f5e8a57266b3e43c47085c6dd0c63653f","src/tt_os2.rs":"9517c53fc4e575ceb615d554dc72812dcbb532bf94883d51202b24caae1a1418"},"package":"fde23272c687e4570aefec06cb71174ec0f5284b725deac4e77ba2665d635faf"}
|
|
@ -2,7 +2,7 @@
|
|||
description = "Bindings for Freetype used by Servo"
|
||||
license = "Apache-2.0 / MIT"
|
||||
name = "freetype"
|
||||
version = "0.1.3"
|
||||
version = "0.2.0"
|
||||
authors = ["The Servo Project Developers"]
|
||||
documentation = "http://doc.servo.org/freetype/"
|
||||
repository = "https://github.com/servo/rust-freetype"
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname $0)"
|
||||
|
||||
# We replace the FT_ integer types of known widths, since we can do better.
|
||||
#
|
||||
# We blacklist FT_Error and import our own in order to have convenience methods
|
||||
# on it instead of being a plain integer.
|
||||
"${BINDGEN}" bindings.h -o ../src/freetype.rs \
|
||||
--no-unstable-rust \
|
||||
--blacklist-type "FT_(Int16|UInt16|Int32|UInt32|Int16|Int64|UInt64)" \
|
||||
--raw-line "pub type FT_Int16 = i16;" \
|
||||
--raw-line "pub type FT_UInt16 = u16;" \
|
||||
--raw-line "pub type FT_Int32 = i32;" \
|
||||
--raw-line "pub type FT_UInt32 = u32;" \
|
||||
--raw-line "pub type FT_Int64= i64;" \
|
||||
--raw-line "pub type FT_UInt64= u64;" \
|
||||
--blacklist-type "FT_Error" \
|
||||
--raw-line "pub use FT_Error;" \
|
||||
--generate=functions,types,vars \
|
||||
--whitelist-function="FT_.*" \
|
||||
--whitelist-type="FT_.*" \
|
||||
--whitelist-var="FT_.*" \
|
||||
-- -I/usr/include/freetype2
|
|
@ -0,0 +1,5 @@
|
|||
#include <freetype2/ft2build.h>
|
||||
#include <freetype2/freetype/freetype.h>
|
||||
#include <freetype2/freetype/ftlcdfil.h>
|
||||
#include <freetype2/freetype/tttables.h>
|
||||
#include <freetype2/freetype/ftmodapi.h>
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -20,5 +20,18 @@
|
|||
extern crate freetype_sys;
|
||||
extern crate libc;
|
||||
|
||||
/// A wrapper over FT_Error so we can add convenience methods on it.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct FT_Error(pub ::std::os::raw::c_int);
|
||||
|
||||
impl FT_Error {
|
||||
#[inline]
|
||||
pub fn succeeded(&self) -> bool {
|
||||
self.0 == freetype::FT_Err_Ok as ::std::os::raw::c_int
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(improper_ctypes)] // https://github.com/rust-lang/rust/issues/34798
|
||||
pub mod freetype;
|
||||
pub mod tt_os2;
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
|
||||
name = "libc"
|
||||
version = "0.2.19"
|
||||
version = "0.2.20"
|
||||
authors = ["The Rust Project Developers"]
|
||||
license = "MIT/Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
|
|
@ -51,3 +51,7 @@ s! {
|
|||
extern {
|
||||
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
|
||||
}
|
||||
|
||||
#[link(name = "c")]
|
||||
#[link(name = "m")]
|
||||
extern {}
|
||||
|
|
|
@ -21,6 +21,7 @@ pub type tcflag_t = ::c_ulong;
|
|||
pub type nl_item = ::c_int;
|
||||
pub type id_t = ::c_uint;
|
||||
pub type sem_t = ::c_int;
|
||||
pub type idtype_t = ::c_uint;
|
||||
|
||||
pub enum timezone {}
|
||||
|
||||
|
@ -860,6 +861,8 @@ pub const SO_RCVTIMEO: ::c_int = 0x1006;
|
|||
pub const SO_ERROR: ::c_int = 0x1007;
|
||||
pub const SO_TYPE: ::c_int = 0x1008;
|
||||
|
||||
pub const MSG_PEEK: ::c_int = 0x2;
|
||||
|
||||
pub const IFF_LOOPBACK: ::c_int = 0x8;
|
||||
|
||||
pub const SHUT_RD: ::c_int = 0;
|
||||
|
@ -1363,6 +1366,15 @@ pub const LIO_READ: ::c_int = 1;
|
|||
pub const LIO_WAIT: ::c_int = 2;
|
||||
pub const LIO_NOWAIT: ::c_int = 1;
|
||||
|
||||
pub const WEXITED: ::c_int = 0x00000004;
|
||||
pub const WSTOPPED: ::c_int = 0x00000008;
|
||||
pub const WCONTINUED: ::c_int = 0x00000010;
|
||||
pub const WNOWAIT: ::c_int = 0x00000020;
|
||||
|
||||
pub const P_ALL: idtype_t = 0;
|
||||
pub const P_PID: idtype_t = 1;
|
||||
pub const P_PGID: idtype_t = 2;
|
||||
|
||||
f! {
|
||||
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
|
||||
status >> 8
|
||||
|
@ -1532,6 +1544,12 @@ extern {
|
|||
flags: ::c_int) -> ::c_int;
|
||||
|
||||
pub fn initgroups(user: *const ::c_char, basegroup: ::c_int) -> ::c_int;
|
||||
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "waitid$UNIX2003")]
|
||||
pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
|
||||
options: ::c_int) -> ::c_int;
|
||||
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -344,6 +344,7 @@ pub const NOTE_TRACK: ::uint32_t = 0x00000001;
|
|||
pub const NOTE_TRACKERR: ::uint32_t = 0x00000002;
|
||||
pub const NOTE_CHILD: ::uint32_t = 0x00000004;
|
||||
|
||||
pub const MSG_PEEK: ::c_int = 0x2;
|
||||
pub const MSG_NOSIGNAL: ::c_int = 0x400;
|
||||
|
||||
pub const EMPTY: ::c_short = 0;
|
||||
|
@ -369,6 +370,14 @@ pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
|
|||
| LC_NUMERIC_MASK
|
||||
| LC_TIME_MASK;
|
||||
|
||||
pub const TIOCSIG: ::c_uint = 0x2000745f;
|
||||
pub const BTUARTDISC: ::c_int = 0x7;
|
||||
pub const TIOCDCDTIMESTAMP: ::c_uint = 0x40107458;
|
||||
pub const TIOCISPTMASTER: ::c_uint = 0x20007455;
|
||||
pub const TIOCMODG: ::c_uint = 0x40047403;
|
||||
pub const TIOCMODS: ::c_ulong = 0x80047404;
|
||||
pub const TIOCREMOTE: ::c_ulong = 0x80047469;
|
||||
|
||||
extern {
|
||||
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
|
||||
-> ::c_int;
|
||||
|
|
|
@ -9,6 +9,7 @@ pub type sem_t = _sem;
|
|||
|
||||
pub type fsblkcnt_t = ::uint64_t;
|
||||
pub type fsfilcnt_t = ::uint64_t;
|
||||
pub type idtype_t = ::c_uint;
|
||||
|
||||
s! {
|
||||
pub struct utmpx {
|
||||
|
@ -315,6 +316,11 @@ pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22;
|
|||
pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23;
|
||||
pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24;
|
||||
pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25;
|
||||
pub const TIOCGPTN: ::c_uint = 0x4004740f;
|
||||
pub const TIOCPTMASTER: ::c_uint = 0x2000741c;
|
||||
pub const TIOCSIG: ::c_uint = 0x2004745f;
|
||||
pub const TIOCM_DCD: ::c_int = 0x40;
|
||||
pub const H4DISC: ::c_int = 0x7;
|
||||
|
||||
// The *_MAXID constants never should've been used outside of the
|
||||
// FreeBSD base system. And with the exception of CTL_P1003_1B_MAXID,
|
||||
|
@ -331,6 +337,7 @@ pub const USER_MAXID: ::c_int = 21;
|
|||
#[doc(hidden)]
|
||||
pub const CTL_P1003_1B_MAXID: ::c_int = 26;
|
||||
|
||||
pub const MSG_PEEK: ::c_int = 0x2;
|
||||
pub const MSG_NOSIGNAL: ::c_int = 0x20000;
|
||||
|
||||
pub const EMPTY: ::c_short = 0;
|
||||
|
@ -356,6 +363,18 @@ pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
|
|||
| LC_NUMERIC_MASK
|
||||
| LC_TIME_MASK;
|
||||
|
||||
pub const WSTOPPED: ::c_int = 2; // same as WUNTRACED
|
||||
pub const WCONTINUED: ::c_int = 4;
|
||||
pub const WNOWAIT: ::c_int = 8;
|
||||
pub const WEXITED: ::c_int = 16;
|
||||
pub const WTRAPPED: ::c_int = 32;
|
||||
|
||||
// FreeBSD defines a great many more of these, we only expose the
|
||||
// standardized ones.
|
||||
pub const P_PID: idtype_t = 0;
|
||||
pub const P_PGID: idtype_t = 2;
|
||||
pub const P_ALL: idtype_t = 7;
|
||||
|
||||
extern {
|
||||
pub fn __error() -> *mut ::c_int;
|
||||
|
||||
|
@ -382,6 +401,8 @@ extern {
|
|||
timeout: *mut ::timespec) -> ::ssize_t;
|
||||
|
||||
pub fn freelocale(loc: ::locale_t) -> ::c_int;
|
||||
pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t,
|
||||
options: ::c_int) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -688,8 +688,68 @@ pub const LOG_SECURITY: ::c_int = 13 << 3;
|
|||
pub const LOG_CONSOLE: ::c_int = 14 << 3;
|
||||
pub const LOG_NFACILITIES: ::c_int = 24;
|
||||
|
||||
pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
|
||||
pub const TIOCEXCL: ::c_uint = 0x2000740d;
|
||||
pub const TIOCNXCL: ::c_uint = 0x2000740e;
|
||||
pub const TIOCFLUSH: ::c_ulong = 0x80047410;
|
||||
pub const TIOCGETA: ::c_uint = 0x402c7413;
|
||||
pub const TIOCSETA: ::c_ulong = 0x802c7414;
|
||||
pub const TIOCSETAW: ::c_ulong = 0x802c7415;
|
||||
pub const TIOCSETAF: ::c_ulong = 0x802c7416;
|
||||
pub const TIOCGETD: ::c_uint = 0x4004741a;
|
||||
pub const TIOCSETD: ::c_ulong = 0x8004741b;
|
||||
pub const TIOCGDRAINWAIT: ::c_uint = 0x40047456;
|
||||
pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457;
|
||||
pub const TIOCTIMESTAMP: ::c_uint = 0x40107459;
|
||||
pub const TIOCMGDTRWAIT: ::c_uint = 0x4004745a;
|
||||
pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b;
|
||||
pub const TIOCDRAIN: ::c_uint = 0x2000745e;
|
||||
pub const TIOCEXT: ::c_ulong = 0x80047460;
|
||||
pub const TIOCSCTTY: ::c_uint = 0x20007461;
|
||||
pub const TIOCCONS: ::c_ulong = 0x80047462;
|
||||
pub const TIOCGSID: ::c_uint = 0x40047463;
|
||||
pub const TIOCSTAT: ::c_uint = 0x20007465;
|
||||
pub const TIOCUCNTL: ::c_ulong = 0x80047466;
|
||||
pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
|
||||
pub const TIOCGWINSZ: ::c_uint = 0x40087468;
|
||||
pub const TIOCMGET: ::c_uint = 0x4004746a;
|
||||
pub const TIOCM_LE: ::c_int = 0x1;
|
||||
pub const TIOCM_DTR: ::c_int = 0x2;
|
||||
pub const TIOCM_RTS: ::c_int = 0x4;
|
||||
pub const TIOCM_ST: ::c_int = 0x8;
|
||||
pub const TIOCM_SR: ::c_int = 0x10;
|
||||
pub const TIOCM_CTS: ::c_int = 0x20;
|
||||
pub const TIOCM_RI: ::c_int = 0x80;
|
||||
pub const TIOCM_DSR: ::c_int = 0x100;
|
||||
pub const TIOCM_CD: ::c_int = 0x40;
|
||||
pub const TIOCM_CAR: ::c_int = 0x40;
|
||||
pub const TIOCM_RNG: ::c_int = 0x80;
|
||||
pub const TIOCMBIC: ::c_ulong = 0x8004746b;
|
||||
pub const TIOCMBIS: ::c_ulong = 0x8004746c;
|
||||
pub const TIOCMSET: ::c_ulong = 0x8004746d;
|
||||
pub const TIOCSTART: ::c_uint = 0x2000746e;
|
||||
pub const TIOCSTOP: ::c_uint = 0x2000746f;
|
||||
pub const TIOCPKT: ::c_ulong = 0x80047470;
|
||||
pub const TIOCPKT_DATA: ::c_int = 0x0;
|
||||
pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1;
|
||||
pub const TIOCPKT_FLUSHWRITE: ::c_int = 0x2;
|
||||
pub const TIOCPKT_STOP: ::c_int = 0x4;
|
||||
pub const TIOCPKT_START: ::c_int = 0x8;
|
||||
pub const TIOCPKT_NOSTOP: ::c_int = 0x10;
|
||||
pub const TIOCPKT_DOSTOP: ::c_int = 0x20;
|
||||
pub const TIOCPKT_IOCTL: ::c_int = 0x40;
|
||||
pub const TIOCNOTTY: ::c_uint = 0x20007471;
|
||||
pub const TIOCSTI: ::c_ulong = 0x80017472;
|
||||
pub const TIOCOUTQ: ::c_uint = 0x40047473;
|
||||
pub const TIOCSPGRP: ::c_ulong = 0x80047476;
|
||||
pub const TIOCGPGRP: ::c_uint = 0x40047477;
|
||||
pub const TIOCCDTR: ::c_uint = 0x20007478;
|
||||
pub const TIOCSDTR: ::c_uint = 0x20007479;
|
||||
pub const TIOCCBRK: ::c_uint = 0x2000747a;
|
||||
pub const TIOCSBRK: ::c_uint = 0x2000747b;
|
||||
pub const TTYDISC: ::c_int = 0x0;
|
||||
pub const SLIPDISC: ::c_int = 0x4;
|
||||
pub const PPPDISC: ::c_int = 0x5;
|
||||
pub const NETGRAPHDISC: ::c_int = 0x6;
|
||||
|
||||
pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t;
|
||||
|
||||
|
|
|
@ -355,6 +355,10 @@ extern {
|
|||
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
|
||||
pub fn if_nameindex() -> *mut if_nameindex;
|
||||
pub fn if_freenameindex(ptr: *mut if_nameindex);
|
||||
|
||||
pub fn getpeereid(socket: ::c_int,
|
||||
euid: *mut ::uid_t,
|
||||
egid: *mut ::gid_t) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -392,6 +392,7 @@ pub const SO_RCVLOWAT: ::c_int = 0x1004;
|
|||
pub const SO_ERROR: ::c_int = 0x1007;
|
||||
pub const SO_TYPE: ::c_int = 0x1008;
|
||||
|
||||
pub const MSG_PEEK: ::c_int = 0x2;
|
||||
pub const MSG_NOSIGNAL: ::c_int = 0x400;
|
||||
|
||||
pub const IFF_LOOPBACK: ::c_int = 0x8;
|
||||
|
|
|
@ -4,6 +4,7 @@ pub type dev_t = u64;
|
|||
pub type blksize_t = ::int32_t;
|
||||
pub type fsblkcnt_t = ::uint64_t;
|
||||
pub type fsfilcnt_t = ::uint64_t;
|
||||
pub type idtype_t = ::c_int;
|
||||
|
||||
s! {
|
||||
pub struct aiocb {
|
||||
|
@ -583,6 +584,15 @@ pub const SIGEV_NONE: ::c_int = 0;
|
|||
pub const SIGEV_SIGNAL: ::c_int = 1;
|
||||
pub const SIGEV_THREAD: ::c_int = 2;
|
||||
|
||||
pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED
|
||||
pub const WCONTINUED: ::c_int = 0x00000010;
|
||||
pub const WEXITED: ::c_int = 0x000000020;
|
||||
pub const WNOWAIT: ::c_int = 0x00010000;
|
||||
|
||||
pub const P_ALL: idtype_t = 0;
|
||||
pub const P_PID: idtype_t = 1;
|
||||
pub const P_PGID: idtype_t = 4;
|
||||
|
||||
extern {
|
||||
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
|
||||
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
|
||||
|
|
|
@ -28,6 +28,8 @@ pub type fsblkcnt_t = i64;
|
|||
pub type fsfilcnt_t = i64;
|
||||
pub type pthread_attr_t = *mut ::c_void;
|
||||
pub type nl_item = ::c_int;
|
||||
pub type id_t = i32;
|
||||
pub type idtype_t = ::c_uint;
|
||||
|
||||
pub enum timezone {}
|
||||
|
||||
|
@ -556,6 +558,7 @@ pub const IPV6_V6ONLY: ::c_int = 30;
|
|||
|
||||
pub const SO_DEBUG: ::c_int = 0x00000004;
|
||||
|
||||
pub const MSG_PEEK: ::c_int = 0x2;
|
||||
pub const MSG_NOSIGNAL: ::c_int = 0x0800;
|
||||
|
||||
pub const SHUT_RD: ::c_int = 0;
|
||||
|
@ -670,6 +673,17 @@ pub const SO_PEERCRED: ::c_int = 0x4000000b;
|
|||
|
||||
pub const NI_MAXHOST: ::size_t = 1025;
|
||||
|
||||
pub const WNOHANG: ::c_int = 0x01;
|
||||
pub const WUNTRACED: ::c_int = 0x02;
|
||||
pub const WCONTINUED: ::c_int = 0x04;
|
||||
pub const WEXITED: ::c_int = 0x08;
|
||||
pub const WSTOPPED: ::c_int = 0x10;
|
||||
pub const WNOWAIT: ::c_int = 0x20;
|
||||
|
||||
pub const P_ALL: idtype_t = 0;
|
||||
pub const P_PID: idtype_t = 1;
|
||||
pub const P_PGID: idtype_t = 2;
|
||||
|
||||
f! {
|
||||
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
|
||||
let fd = fd as usize;
|
||||
|
@ -742,6 +756,8 @@ extern {
|
|||
flags: ::c_int) -> ::c_int;
|
||||
pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
|
||||
abstime: *const ::timespec) -> ::c_int;
|
||||
pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
|
||||
options: ::c_int) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -366,6 +366,7 @@ extern {
|
|||
pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
|
||||
pub fn alarm(seconds: ::c_uint) -> ::c_uint;
|
||||
pub fn chdir(dir: *const c_char) -> ::c_int;
|
||||
pub fn fchdir(dirfd: ::c_int) -> ::c_int;
|
||||
pub fn chown(path: *const c_char, uid: uid_t,
|
||||
gid: gid_t) -> ::c_int;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
|
|
|
@ -25,6 +25,7 @@ pub type rlim_t = ::c_ulong;
|
|||
pub type dev_t = ::c_ulong;
|
||||
pub type ino_t = ::c_ulong;
|
||||
pub type __CPU_BITTYPE = ::c_ulong;
|
||||
pub type idtype_t = ::c_int;
|
||||
|
||||
s! {
|
||||
pub struct dirent {
|
||||
|
|
|
@ -17,6 +17,7 @@ pub type msgqnum_t = ::c_ulong;
|
|||
pub type msglen_t = ::c_ulong;
|
||||
pub type nfds_t = ::c_ulong;
|
||||
pub type nl_item = ::c_int;
|
||||
pub type idtype_t = ::c_uint;
|
||||
|
||||
pub enum fpos64_t {} // TODO: fill this out with a struct
|
||||
|
||||
|
|
|
@ -468,6 +468,7 @@ pub const IPV6_V6ONLY: ::c_int = 26;
|
|||
|
||||
pub const SO_DEBUG: ::c_int = 1;
|
||||
|
||||
pub const MSG_PEEK: ::c_int = 0x2;
|
||||
pub const MSG_NOSIGNAL: ::c_int = 0x4000;
|
||||
|
||||
pub const SHUT_RD: ::c_int = 0;
|
||||
|
@ -624,6 +625,10 @@ pub const SIGEV_SIGNAL: ::c_int = 0;
|
|||
pub const SIGEV_NONE: ::c_int = 1;
|
||||
pub const SIGEV_THREAD: ::c_int = 2;
|
||||
|
||||
pub const P_ALL: idtype_t = 0;
|
||||
pub const P_PID: idtype_t = 1;
|
||||
pub const P_PGID: idtype_t = 2;
|
||||
|
||||
f! {
|
||||
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
|
||||
let fd = fd as usize;
|
||||
|
@ -851,6 +856,8 @@ extern {
|
|||
buf: *mut ::c_char,
|
||||
buflen: ::size_t) -> ::c_int;
|
||||
pub fn clearenv() -> ::c_int;
|
||||
pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
|
||||
options: ::c_int) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -32,6 +32,8 @@ pub type pthread_key_t = ::c_uint;
|
|||
pub type blksize_t = u32;
|
||||
pub type fflags_t = u32;
|
||||
pub type nl_item = ::c_int;
|
||||
pub type id_t = ::c_int;
|
||||
pub type idtype_t = ::c_uint;
|
||||
|
||||
pub enum timezone {}
|
||||
|
||||
|
@ -550,6 +552,18 @@ pub const SIGXFSZ: ::c_int = 31;
|
|||
pub const WNOHANG: ::c_int = 0x40;
|
||||
pub const WUNTRACED: ::c_int = 0x04;
|
||||
|
||||
pub const WEXITED: ::c_int = 0x01;
|
||||
pub const WTRAPPED: ::c_int = 0x02;
|
||||
pub const WSTOPPED: ::c_int = WUNTRACED;
|
||||
pub const WCONTINUED: ::c_int = 0x08;
|
||||
pub const WNOWAIT: ::c_int = 0x80;
|
||||
|
||||
// Solaris defines a great many more of these; we only expose the
|
||||
// standardized ones.
|
||||
pub const P_PID: idtype_t = 0;
|
||||
pub const P_PGID: idtype_t = 2;
|
||||
pub const P_ALL: idtype_t = 7;
|
||||
|
||||
pub const PROT_NONE: ::c_int = 0;
|
||||
pub const PROT_READ: ::c_int = 1;
|
||||
pub const PROT_WRITE: ::c_int = 2;
|
||||
|
@ -1056,4 +1070,6 @@ extern {
|
|||
abstime: *const ::timespec) -> ::c_int;
|
||||
pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
|
||||
abstime: *const ::timespec) -> ::c_int;
|
||||
pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
|
||||
options: ::c_int) -> ::c_int;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"0f1318d8af8fb2f5ae189496e8d7f9c460446d600a49d164c4d6ef969af9115a","src/ident.rs":"830077b64dce8c8ede1fb6ab664cae72f5496f4ab6be21a5b4e3b5e4e57ec425","src/lib.rs":"f799c898057a4e8e1620b32c70e13d3fee7af3a0352a5a4a1da6393942d21cc7","src/to_tokens.rs":"4367d7cd2c2c80c49ed716d954365bcf3a7d33f361573305e48d4cfadceafebf","src/tokens.rs":"a559a56905debae32a0e7852114812cca7173341a62b277894517264a759dfa6"},"package":"6732e32663c9c271bfc7c1823486b471f18c47a2dbf87c066897b7b51afc83be"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"ea9f9bb37492e62dbd04d7a38da935c4ca54b7cc74fb46ed7f99e07116a6966b","src/ident.rs":"830077b64dce8c8ede1fb6ab664cae72f5496f4ab6be21a5b4e3b5e4e57ec425","src/lib.rs":"f799c898057a4e8e1620b32c70e13d3fee7af3a0352a5a4a1da6393942d21cc7","src/to_tokens.rs":"9443c192caa28f1e7d9de80a2d37c87fedd1d8664915513db9ca02a1ee8abfdc","src/tokens.rs":"a559a56905debae32a0e7852114812cca7173341a62b277894517264a759dfa6"},"package":"48f961356de2df29263e751df9e2e2493bd765e57fce250cc8b8dcef53ed33c0"}
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "quote"
|
||||
version = "0.3.10" # don't forget to update version in readme for breaking changes
|
||||
version = "0.3.11" # don't forget to update version in readme for breaking changes
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Quasi-quoting macro quote!(...)"
|
||||
|
|
|
@ -49,7 +49,17 @@ impl<T: ToTokens> ToTokens for Option<T> {
|
|||
|
||||
impl ToTokens for str {
|
||||
fn to_tokens(&self, tokens: &mut Tokens) {
|
||||
tokens.append(&escape_str(self));
|
||||
let mut escaped = "\"".to_string();
|
||||
for ch in self.chars() {
|
||||
match ch {
|
||||
'\0' => escaped.push_str(r"\0"),
|
||||
'\'' => escaped.push_str("'"),
|
||||
_ => escaped.extend(ch.escape_default().map(|c| c as char)),
|
||||
}
|
||||
}
|
||||
escaped.push('"');
|
||||
|
||||
tokens.append(&escaped);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,21 +85,23 @@ pub struct ByteStr<'a>(pub &'a str);
|
|||
|
||||
impl<'a> ToTokens for ByteStr<'a> {
|
||||
fn to_tokens(&self, tokens: &mut Tokens) {
|
||||
tokens.append(&format!("b{}", escape_str(self.0)));
|
||||
}
|
||||
}
|
||||
|
||||
fn escape_str(s: &str) -> String {
|
||||
let mut escaped = "\"".to_string();
|
||||
for ch in s.chars() {
|
||||
match ch {
|
||||
'\0' => escaped.push_str(r"\0"),
|
||||
'\'' => escaped.push_str("'"),
|
||||
_ => escaped.extend(ch.escape_default().map(|c| c as char)),
|
||||
let mut escaped = "b\"".to_string();
|
||||
for b in self.0.bytes() {
|
||||
match b {
|
||||
b'\0' => escaped.push_str(r"\0"),
|
||||
b'\t' => escaped.push_str(r"\t"),
|
||||
b'\n' => escaped.push_str(r"\n"),
|
||||
b'\r' => escaped.push_str(r"\r"),
|
||||
b'"' => escaped.push_str("\\\""),
|
||||
b'\\' => escaped.push_str("\\\\"),
|
||||
b'\x20' ... b'\x7E' => escaped.push(b as char),
|
||||
_ => escaped.push_str(&format!("\\x{:02X}", b)),
|
||||
}
|
||||
}
|
||||
escaped.push('"');
|
||||
|
||||
tokens.append(&escaped);
|
||||
}
|
||||
escaped.push('"');
|
||||
escaped
|
||||
}
|
||||
|
||||
macro_rules! impl_to_tokens_display {
|
||||
|
@ -209,26 +221,20 @@ array_impls! {
|
|||
30 31 32
|
||||
}
|
||||
|
||||
// To support Rust 1.11.0.
|
||||
// https://github.com/rust-lang/rust/issues/19630
|
||||
macro_rules! e {
|
||||
($e:expr) => { $e };
|
||||
}
|
||||
|
||||
macro_rules! tuple_impls {
|
||||
($(
|
||||
$Tuple:ident {
|
||||
$(($idx:tt) -> $T:ident)+
|
||||
$(($idx:tt) -> $T:ident)*
|
||||
}
|
||||
)+) => {
|
||||
$(
|
||||
impl<$($T: ToTokens),+> ToTokens for ($($T,)+) {
|
||||
impl<$($T: ToTokens),*> ToTokens for ($($T,)*) {
|
||||
fn to_tokens(&self, tokens: &mut Tokens) {
|
||||
tokens.append("(");
|
||||
$(
|
||||
e!(self.$idx).to_tokens(tokens);
|
||||
self.$idx.to_tokens(tokens);
|
||||
tokens.append(",");
|
||||
)+
|
||||
)*
|
||||
tokens.append(")");
|
||||
}
|
||||
}
|
||||
|
@ -237,6 +243,7 @@ macro_rules! tuple_impls {
|
|||
}
|
||||
|
||||
tuple_impls! {
|
||||
Tuple0 {}
|
||||
Tuple1 {
|
||||
(0) -> A
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"944bf600c6230664922a011cbca026699969f2f89f6c7ff689835836ccd7b1de","Cargo.toml":"e1423d4f80dd1b358812a9993312cf6338df844c2b15e423ab779bf914cead14","src/arch/arm.rs":"0cd845b3790f7358b5290b58163ae2663b46b7ecf64eb8c6b0a29b33da6f143c","src/arch/x86.rs":"3fc9757cbb775bd08da9999ab39d95b62b3cb509e0ab309dd26c11c3fbdbc778","src/arch/x86_64.rs":"37bc2c6e74c009ff5f2896b249fac7ddf9f5e30e223a5122a28a93cef5ba33b1","src/call.rs":"7913da5b7d8b11e290d863d6cbca17be20c98bef420ddb964519a9c9cfeff366","src/data.rs":"c3406d581387828b6fb246bea2b57582cef890cedeb2c0e632e472cd3776d884","src/error.rs":"b23c12db8cafb64f3b909a95bdd47cf03f62f6fa1201b40892febf46ec56bcb4","src/flag.rs":"400c91c57b1ab1afd6ab06c0582b1b0817590688900882de31fc3a4aab27da49","src/io/dma.rs":"4ab65016b3bc9121f0844dc4b8de77608eba327c0e0d930900254242b2c204b0","src/io/io.rs":"1bcb36d1867e9bab6a8186cd6928efe70ae2655e9f9d0dd3def20bc0fb6a82f6","src/io/mmio.rs":"bd475c815d483cc2b187348c32e10f94df0ca756ee8d14260b6ca3c660b2a73a","src/io/mod.rs":"4df12af3e82e6b5fe22112c9f51552112ee4811b7d1131d2a43d608d8d1cac09","src/io/pio.rs":"219fcd317d6c490a14794ec4db9de3e305c722dda720043c67076bda60632bb8","src/lib.rs":"988fb0b0bd3b396345f11ef46617072aeaf9307d3fa05a4d2a2ee9d590598bba","src/number.rs":"9043372ef517ecbbca776536efa3d7a822ba6f49d29c20d4c3648f0e3c85fe35","src/scheme.rs":"3281173d9a5d7d420f5dbdaed7562ba5adc1ce5753843a3bf3eecf4060eb09c2"},"package":"8dd35cc9a8bdec562c757e3d43c1526b5c6d2653e23e2315065bc25556550753"}
|
|
@ -0,0 +1,2 @@
|
|||
Cargo.lock
|
||||
target
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.16"
|
||||
description = "A Rust library to access raw Redox system calls"
|
||||
license = "MIT"
|
||||
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
|
||||
|
||||
[lib]
|
||||
name = "syscall"
|
|
@ -0,0 +1,72 @@
|
|||
use error::{Error, Result};
|
||||
|
||||
pub unsafe fn syscall0(mut a: usize) -> Result<usize> {
|
||||
asm!("swi $$0"
|
||||
: "={r0}"(a)
|
||||
: "{r7}"(a)
|
||||
: "memory"
|
||||
: "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall1(mut a: usize, b: usize) -> Result<usize> {
|
||||
asm!("swi $$0"
|
||||
: "={r0}"(a)
|
||||
: "{r7}"(a), "{r0}"(b)
|
||||
: "memory"
|
||||
: "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
// Clobbers all registers - special for clone
|
||||
pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result<usize> {
|
||||
asm!("swi $$0"
|
||||
: "={r0}"(a)
|
||||
: "{r7}"(a), "{r0}"(b)
|
||||
: "memory", "r0", "r1", "r2", "r3", "r4"
|
||||
: "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result<usize> {
|
||||
asm!("swi $$0"
|
||||
: "={r0}"(a)
|
||||
: "{r7}"(a), "{r0}"(b), "{r1}"(c)
|
||||
: "memory"
|
||||
: "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result<usize> {
|
||||
asm!("swi $$0"
|
||||
: "={r0}"(a)
|
||||
: "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d)
|
||||
: "memory"
|
||||
: "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result<usize> {
|
||||
asm!("swi $$0"
|
||||
: "={r0}"(a)
|
||||
: "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d), "{r3}"(e)
|
||||
: "memory"
|
||||
: "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> Result<usize> {
|
||||
asm!("swi $$0"
|
||||
: "={r0}"(a)
|
||||
: "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d), "{r3}"(e), "{r4}"(f)
|
||||
: "memory"
|
||||
: "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
use error::{Error, Result};
|
||||
|
||||
pub unsafe fn syscall0(mut a: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall1(mut a: usize, b: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a), "{ebx}"(b)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
// Clobbers all registers - special for clone
|
||||
pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a), "{ebx}"(b)
|
||||
: "memory", "ebx", "ecx", "edx", "esi", "edi"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a), "{ebx}"(b), "{ecx}"(c)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d), "{esi}"(e)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d), "{esi}"(e), "{edi}"(f)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
use error::{Error, Result};
|
||||
|
||||
pub unsafe fn syscall0(mut a: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall1(mut a: usize, b: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
// Clobbers all registers - special for clone
|
||||
pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b)
|
||||
: "memory", "rbx", "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b), "{rcx}"(c)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b), "{rcx}"(c), "{rdx}"(d)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b), "{rcx}"(c), "{rdx}"(d), "{rsi}"(e)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b), "{rcx}"(c), "{rdx}"(d), "{rsi}"(e), "{rdi}"(f)
|
||||
: "memory"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
|
@ -0,0 +1,292 @@
|
|||
use super::arch::*;
|
||||
use super::data::{Stat, StatVfs, TimeSpec};
|
||||
use super::error::Result;
|
||||
use super::number::*;
|
||||
|
||||
use core::mem;
|
||||
|
||||
/// Set the end of the process's heap
|
||||
///
|
||||
/// When `addr` is `0`, this function will return the current break.
|
||||
///
|
||||
/// When `addr` is nonzero, this function will attempt to set the end of the process's
|
||||
/// heap to `addr` and return the new program break. The new program break should be
|
||||
/// checked by the allocator, it may not be exactly `addr`, as it may be aligned to a page
|
||||
/// boundary.
|
||||
///
|
||||
/// On error, `Err(ENOMEM)` will be returned indicating that no memory is available
|
||||
pub unsafe fn brk(addr: usize) -> Result<usize> {
|
||||
syscall1(SYS_BRK, addr)
|
||||
}
|
||||
|
||||
/// Change the process's working directory
|
||||
///
|
||||
/// This function will attempt to set the process's working directory to `path`, which can be
|
||||
/// either a relative, scheme relative, or absolute path.
|
||||
///
|
||||
/// On success, `Ok(0)` will be returned. On error, one of the following errors will be returned.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// * `EACCES` - permission is denied for one of the components of `path`, or `path`
|
||||
/// * `EFAULT` - `path` does not point to the process's addressible memory
|
||||
/// * `EIO` - an I/O error occured
|
||||
/// * `ENOENT` - `path` does not exit
|
||||
/// * `ENOTDIR` - `path` is not a directory
|
||||
pub fn chdir(path: &str) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_CHDIR, path.as_ptr() as usize, path.len()) }
|
||||
}
|
||||
|
||||
pub fn chmod(path: &str, mode: usize) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_CHMOD, path.as_ptr() as usize, path.len(), mode) }
|
||||
}
|
||||
|
||||
/// Produce a fork of the current process, or a new process thread
|
||||
pub unsafe fn clone(flags: usize) -> Result<usize> {
|
||||
syscall1_clobber(SYS_CLONE, flags)
|
||||
}
|
||||
|
||||
/// Close a file
|
||||
pub fn close(fd: usize) -> Result<usize> {
|
||||
unsafe { syscall1(SYS_CLOSE, fd) }
|
||||
}
|
||||
|
||||
/// Get the current system time
|
||||
pub fn clock_gettime(clock: usize, tp: &mut TimeSpec) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_CLOCK_GETTIME, clock, tp as *mut TimeSpec as usize) }
|
||||
}
|
||||
|
||||
/// Copy and transform a file descriptor
|
||||
pub fn dup(fd: usize, buf: &[u8]) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_DUP, fd, buf.as_ptr() as usize, buf.len()) }
|
||||
}
|
||||
|
||||
/// Copy and transform a file descriptor
|
||||
pub fn dup2(fd: usize, newfd: usize, buf: &[u8]) -> Result<usize> {
|
||||
unsafe { syscall4(SYS_DUP2, fd, newfd, buf.as_ptr() as usize, buf.len()) }
|
||||
}
|
||||
|
||||
/// Replace the current process with a new executable
|
||||
pub fn execve(path: &str, args: &[[usize; 2]]) -> Result<usize> {
|
||||
unsafe { syscall4(SYS_EXECVE, path.as_ptr() as usize, path.len(), args.as_ptr() as usize, args.len()) }
|
||||
}
|
||||
|
||||
/// Exit the current process
|
||||
pub fn exit(status: usize) -> Result<usize> {
|
||||
unsafe { syscall1(SYS_EXIT, status) }
|
||||
}
|
||||
|
||||
/// Register a file for event-based I/O
|
||||
pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_FCNTL, fd, cmd, arg) }
|
||||
}
|
||||
|
||||
/// Register a file for event-based I/O
|
||||
pub fn fevent(fd: usize, flags: usize) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_FEVENT, fd, flags) }
|
||||
}
|
||||
|
||||
/// Map a file into memory
|
||||
pub unsafe fn fmap(fd: usize, offset: usize, size: usize) -> Result<usize> {
|
||||
syscall3(SYS_FMAP, fd, offset, size)
|
||||
}
|
||||
|
||||
/// Unmap a memory-mapped file
|
||||
pub unsafe fn funmap(addr: usize) -> Result<usize> {
|
||||
syscall1(SYS_FUNMAP, addr)
|
||||
}
|
||||
|
||||
/// Retrieve the canonical path of a file
|
||||
pub fn fpath(fd: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_FPATH, fd, buf.as_mut_ptr() as usize, buf.len()) }
|
||||
}
|
||||
|
||||
/// Get metadata about a file
|
||||
pub fn fstat(fd: usize, stat: &mut Stat) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_FSTAT, fd, stat as *mut Stat as usize, mem::size_of::<Stat>()) }
|
||||
}
|
||||
|
||||
/// Get metadata about a filesystem
|
||||
pub fn fstatvfs(fd: usize, stat: &mut StatVfs) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_FSTATVFS, fd, stat as *mut StatVfs as usize, mem::size_of::<StatVfs>()) }
|
||||
}
|
||||
|
||||
/// Sync a file descriptor to its underlying medium
|
||||
pub fn fsync(fd: usize) -> Result<usize> {
|
||||
unsafe { syscall1(SYS_FSYNC, fd) }
|
||||
}
|
||||
|
||||
/// Truncate or extend a file to a specified length
|
||||
pub fn ftruncate(fd: usize, len: usize) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_FTRUNCATE, fd, len) }
|
||||
}
|
||||
|
||||
/// Fast userspace mutex - TODO: Document
|
||||
pub unsafe fn futex(addr: *mut i32, op: usize, val: i32, val2: usize, addr2: *mut i32) -> Result<usize> {
|
||||
syscall5(SYS_FUTEX, addr as usize, op, (val as isize) as usize, val2, addr2 as usize)
|
||||
}
|
||||
|
||||
/// Get the current working directory
|
||||
pub fn getcwd(buf: &mut [u8]) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_GETCWD, buf.as_mut_ptr() as usize, buf.len()) }
|
||||
}
|
||||
|
||||
/// Get the effective group ID
|
||||
pub fn getegid() -> Result<usize> {
|
||||
unsafe { syscall0(SYS_GETEGID) }
|
||||
}
|
||||
|
||||
/// Get the effective namespace
|
||||
pub fn getens() -> Result<usize> {
|
||||
unsafe { syscall0(SYS_GETENS) }
|
||||
}
|
||||
|
||||
/// Get the effective user ID
|
||||
pub fn geteuid() -> Result<usize> {
|
||||
unsafe { syscall0(SYS_GETEUID) }
|
||||
}
|
||||
|
||||
/// Get the current group ID
|
||||
pub fn getgid() -> Result<usize> {
|
||||
unsafe { syscall0(SYS_GETGID) }
|
||||
}
|
||||
|
||||
/// Get the current namespace
|
||||
pub fn getns() -> Result<usize> {
|
||||
unsafe { syscall0(SYS_GETNS) }
|
||||
}
|
||||
|
||||
/// Get the current process ID
|
||||
pub fn getpid() -> Result<usize> {
|
||||
unsafe { syscall0(SYS_GETPID) }
|
||||
}
|
||||
|
||||
/// Get the current user ID
|
||||
pub fn getuid() -> Result<usize> {
|
||||
unsafe { syscall0(SYS_GETUID) }
|
||||
}
|
||||
|
||||
/// Set the I/O privilege level
|
||||
pub unsafe fn iopl(level: usize) -> Result<usize> {
|
||||
syscall1(SYS_IOPL, level)
|
||||
}
|
||||
|
||||
/// Send a signal `sig` to the process identified by `pid`
|
||||
pub fn kill(pid: usize, sig: usize) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_KILL, pid, sig) }
|
||||
}
|
||||
|
||||
/// Create a link to a file
|
||||
pub unsafe fn link(old: *const u8, new: *const u8) -> Result<usize> {
|
||||
syscall2(SYS_LINK, old as usize, new as usize)
|
||||
}
|
||||
|
||||
/// Seek to `offset` bytes in a file descriptor
|
||||
pub fn lseek(fd: usize, offset: isize, whence: usize) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_LSEEK, fd, offset as usize, whence) }
|
||||
}
|
||||
|
||||
/// Make a new scheme namespace
|
||||
pub fn mkns(schemes: &[[usize; 2]]) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_MKNS, schemes.as_ptr() as usize, schemes.len()) }
|
||||
}
|
||||
|
||||
/// Sleep for the time specified in `req`
|
||||
pub fn nanosleep(req: &TimeSpec, rem: &mut TimeSpec) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_NANOSLEEP, req as *const TimeSpec as usize, rem as *mut TimeSpec as usize) }
|
||||
}
|
||||
|
||||
/// Open a file
|
||||
pub fn open(path: &str, flags: usize) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_OPEN, path.as_ptr() as usize, path.len(), flags) }
|
||||
}
|
||||
|
||||
/// Allocate pages, linearly in physical memory
|
||||
pub unsafe fn physalloc(size: usize) -> Result<usize> {
|
||||
syscall1(SYS_PHYSALLOC, size)
|
||||
}
|
||||
|
||||
/// Free physically allocated pages
|
||||
pub unsafe fn physfree(physical_address: usize, size: usize) -> Result<usize> {
|
||||
syscall2(SYS_PHYSFREE, physical_address, size)
|
||||
}
|
||||
|
||||
/// Map physical memory to virtual memory
|
||||
pub unsafe fn physmap(physical_address: usize, size: usize, flags: usize) -> Result<usize> {
|
||||
syscall3(SYS_PHYSMAP, physical_address, size, flags)
|
||||
}
|
||||
|
||||
/// Unmap previously mapped physical memory
|
||||
pub unsafe fn physunmap(virtual_address: usize) -> Result<usize> {
|
||||
syscall1(SYS_PHYSUNMAP, virtual_address)
|
||||
}
|
||||
|
||||
/// Create a pair of file descriptors referencing the read and write ends of a pipe
|
||||
pub fn pipe2(fds: &mut [usize; 2], flags: usize) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_PIPE2, fds.as_ptr() as usize, flags) }
|
||||
}
|
||||
|
||||
/// Read from a file descriptor into a buffer
|
||||
pub fn read(fd: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_READ, fd, buf.as_mut_ptr() as usize, buf.len()) }
|
||||
}
|
||||
|
||||
/// Remove a directory
|
||||
pub fn rmdir(path: &str) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_RMDIR, path.as_ptr() as usize, path.len()) }
|
||||
}
|
||||
|
||||
/// Set the current process group IDs
|
||||
pub fn setregid(rgid: usize, egid: usize) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_SETREGID, rgid, egid) }
|
||||
}
|
||||
|
||||
/// Make a new scheme namespace
|
||||
pub fn setrens(rns: usize, ens: usize) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_SETRENS, rns, ens) }
|
||||
}
|
||||
|
||||
/// Set the current process user IDs
|
||||
pub fn setreuid(ruid: usize, euid: usize) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_SETREUID, ruid, euid) }
|
||||
}
|
||||
|
||||
/// Remove a file
|
||||
pub fn unlink(path: &str) -> Result<usize> {
|
||||
unsafe { syscall2(SYS_UNLINK, path.as_ptr() as usize, path.len()) }
|
||||
}
|
||||
|
||||
/// Convert a virtual address to a physical one
|
||||
pub unsafe fn virttophys(virtual_address: usize) -> Result<usize> {
|
||||
syscall1(SYS_VIRTTOPHYS, virtual_address)
|
||||
}
|
||||
|
||||
/// Check if a child process has exited or received a signal
|
||||
pub fn waitpid(pid: usize, status: &mut usize, options: usize) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_WAITPID, pid, status as *mut usize as usize, options) }
|
||||
}
|
||||
|
||||
/// Write a buffer to a file descriptor
|
||||
///
|
||||
/// The kernel will attempt to write the bytes in `buf` to the file descriptor `fd`, returning
|
||||
/// either an `Err`, explained below, or `Ok(count)` where `count` is the number of bytes which
|
||||
/// were written.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// * `EAGAIN` - the file descriptor was opened with `O_NONBLOCK` and writing would block
|
||||
/// * `EBADF` - the file descriptor is not valid or is not open for writing
|
||||
/// * `EFAULT` - `buf` does not point to the process's addressible memory
|
||||
/// * `EIO` - an I/O error occured
|
||||
/// * `ENOSPC` - the device containing the file descriptor has no room for data
|
||||
/// * `EPIPE` - the file descriptor refers to a pipe or socket whose reading end is closed
|
||||
pub fn write(fd: usize, buf: &[u8]) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_WRITE, fd, buf.as_ptr() as usize, buf.len()) }
|
||||
}
|
||||
|
||||
/// Yield the process's time slice to the kernel
|
||||
///
|
||||
/// This function will return Ok(0) on success
|
||||
pub fn sched_yield() -> Result<usize> {
|
||||
unsafe { syscall0(SYS_YIELD) }
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
use core::ops::{Deref, DerefMut};
|
||||
use core::{mem, slice};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
pub struct Event {
|
||||
pub id: usize,
|
||||
pub flags: usize,
|
||||
pub data: usize
|
||||
}
|
||||
|
||||
impl Deref for Event {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const Event as *const u8, mem::size_of::<Event>()) as &[u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Event {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut Event as *mut u8, mem::size_of::<Event>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
#[repr(packed)]
|
||||
pub struct Packet {
|
||||
pub id: u64,
|
||||
pub pid: usize,
|
||||
pub uid: u32,
|
||||
pub gid: u32,
|
||||
pub a: usize,
|
||||
pub b: usize,
|
||||
pub c: usize,
|
||||
pub d: usize
|
||||
}
|
||||
|
||||
impl Deref for Packet {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const Packet as *const u8, mem::size_of::<Packet>()) as &[u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Packet {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut Packet as *mut u8, mem::size_of::<Packet>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
#[repr(packed)]
|
||||
pub struct Stat {
|
||||
pub st_dev: u64,
|
||||
pub st_ino: u64,
|
||||
pub st_mode: u16,
|
||||
pub st_nlink: u32,
|
||||
pub st_uid: u32,
|
||||
pub st_gid: u32,
|
||||
pub st_size: u64,
|
||||
pub st_blksize: u32,
|
||||
pub st_blocks: u64,
|
||||
pub st_mtime: u64,
|
||||
pub st_mtime_nsec: u32,
|
||||
pub st_atime: u64,
|
||||
pub st_atime_nsec: u32,
|
||||
pub st_ctime: u64,
|
||||
pub st_ctime_nsec: u32,
|
||||
}
|
||||
|
||||
impl Deref for Stat {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const Stat as *const u8, mem::size_of::<Stat>()) as &[u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Stat {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut Stat as *mut u8, mem::size_of::<Stat>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
#[repr(packed)]
|
||||
pub struct StatVfs {
|
||||
pub f_bsize: u32,
|
||||
pub f_blocks: u64,
|
||||
pub f_bfree: u64,
|
||||
pub f_bavail: u64,
|
||||
//TODO: More fields https://linux.die.net/man/2/statvfs
|
||||
}
|
||||
|
||||
impl Deref for StatVfs {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const StatVfs as *const u8, mem::size_of::<StatVfs>()) as &[u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for StatVfs {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut StatVfs as *mut u8, mem::size_of::<StatVfs>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
#[repr(packed)]
|
||||
pub struct TimeSpec {
|
||||
pub tv_sec: i64,
|
||||
pub tv_nsec: i32,
|
||||
}
|
||||
|
||||
impl Deref for TimeSpec {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const TimeSpec as *const u8,
|
||||
mem::size_of::<TimeSpec>()) as &[u8]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for TimeSpec {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut TimeSpec as *mut u8,
|
||||
mem::size_of::<TimeSpec>()) as &mut [u8]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,315 @@
|
|||
use core::{fmt, result};
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
pub struct Error {
|
||||
pub errno: i32,
|
||||
}
|
||||
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
impl Error {
|
||||
pub fn new(errno: i32) -> Error {
|
||||
Error { errno: errno }
|
||||
}
|
||||
|
||||
pub fn mux(result: Result<usize>) -> usize {
|
||||
match result {
|
||||
Ok(value) => value,
|
||||
Err(error) => -error.errno as usize,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn demux(value: usize) -> Result<usize> {
|
||||
let errno = -(value as i32);
|
||||
if errno >= 1 && errno < STR_ERROR.len() as i32 {
|
||||
Err(Error::new(errno))
|
||||
} else {
|
||||
Ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text(&self) -> &str {
|
||||
if let Some(description) = STR_ERROR.get(self.errno as usize) {
|
||||
description
|
||||
} else {
|
||||
"Unknown Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
|
||||
f.write_str(self.text())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
|
||||
f.write_str(self.text())
|
||||
}
|
||||
}
|
||||
|
||||
pub const EPERM: i32 = 1; /* Operation not permitted */
|
||||
pub const ENOENT: i32 = 2; /* No such file or directory */
|
||||
pub const ESRCH: i32 = 3; /* No such process */
|
||||
pub const EINTR: i32 = 4; /* Interrupted system call */
|
||||
pub const EIO: i32 = 5; /* I/O error */
|
||||
pub const ENXIO: i32 = 6; /* No such device or address */
|
||||
pub const E2BIG: i32 = 7; /* Argument list too long */
|
||||
pub const ENOEXEC: i32 = 8; /* Exec format error */
|
||||
pub const EBADF: i32 = 9; /* Bad file number */
|
||||
pub const ECHILD: i32 = 10; /* No child processes */
|
||||
pub const EAGAIN: i32 = 11; /* Try again */
|
||||
pub const ENOMEM: i32 = 12; /* Out of memory */
|
||||
pub const EACCES: i32 = 13; /* Permission denied */
|
||||
pub const EFAULT: i32 = 14; /* Bad address */
|
||||
pub const ENOTBLK: i32 = 15; /* Block device required */
|
||||
pub const EBUSY: i32 = 16; /* Device or resource busy */
|
||||
pub const EEXIST: i32 = 17; /* File exists */
|
||||
pub const EXDEV: i32 = 18; /* Cross-device link */
|
||||
pub const ENODEV: i32 = 19; /* No such device */
|
||||
pub const ENOTDIR: i32 = 20; /* Not a directory */
|
||||
pub const EISDIR: i32 = 21; /* Is a directory */
|
||||
pub const EINVAL: i32 = 22; /* Invalid argument */
|
||||
pub const ENFILE: i32 = 23; /* File table overflow */
|
||||
pub const EMFILE: i32 = 24; /* Too many open files */
|
||||
pub const ENOTTY: i32 = 25; /* Not a typewriter */
|
||||
pub const ETXTBSY: i32 = 26; /* Text file busy */
|
||||
pub const EFBIG: i32 = 27; /* File too large */
|
||||
pub const ENOSPC: i32 = 28; /* No space left on device */
|
||||
pub const ESPIPE: i32 = 29; /* Illegal seek */
|
||||
pub const EROFS: i32 = 30; /* Read-only file system */
|
||||
pub const EMLINK: i32 = 31; /* Too many links */
|
||||
pub const EPIPE: i32 = 32; /* Broken pipe */
|
||||
pub const EDOM: i32 = 33; /* Math argument out of domain of func */
|
||||
pub const ERANGE: i32 = 34; /* Math result not representable */
|
||||
pub const EDEADLK: i32 = 35; /* Resource deadlock would occur */
|
||||
pub const ENAMETOOLONG: i32 = 36; /* File name too long */
|
||||
pub const ENOLCK: i32 = 37; /* No record locks available */
|
||||
pub const ENOSYS: i32 = 38; /* Function not implemented */
|
||||
pub const ENOTEMPTY: i32 = 39; /* Directory not empty */
|
||||
pub const ELOOP: i32 = 40; /* Too many symbolic links encountered */
|
||||
pub const EWOULDBLOCK: i32 = 41; /* Operation would block */
|
||||
pub const ENOMSG: i32 = 42; /* No message of desired type */
|
||||
pub const EIDRM: i32 = 43; /* Identifier removed */
|
||||
pub const ECHRNG: i32 = 44; /* Channel number out of range */
|
||||
pub const EL2NSYNC: i32 = 45; /* Level 2 not synchronized */
|
||||
pub const EL3HLT: i32 = 46; /* Level 3 halted */
|
||||
pub const EL3RST: i32 = 47; /* Level 3 reset */
|
||||
pub const ELNRNG: i32 = 48; /* Link number out of range */
|
||||
pub const EUNATCH: i32 = 49; /* Protocol driver not attached */
|
||||
pub const ENOCSI: i32 = 50; /* No CSI structure available */
|
||||
pub const EL2HLT: i32 = 51; /* Level 2 halted */
|
||||
pub const EBADE: i32 = 52; /* Invalid exchange */
|
||||
pub const EBADR: i32 = 53; /* Invalid request descriptor */
|
||||
pub const EXFULL: i32 = 54; /* Exchange full */
|
||||
pub const ENOANO: i32 = 55; /* No anode */
|
||||
pub const EBADRQC: i32 = 56; /* Invalid request code */
|
||||
pub const EBADSLT: i32 = 57; /* Invalid slot */
|
||||
pub const EDEADLOCK: i32 = 58; /* Resource deadlock would occur */
|
||||
pub const EBFONT: i32 = 59; /* Bad font file format */
|
||||
pub const ENOSTR: i32 = 60; /* Device not a stream */
|
||||
pub const ENODATA: i32 = 61; /* No data available */
|
||||
pub const ETIME: i32 = 62; /* Timer expired */
|
||||
pub const ENOSR: i32 = 63; /* Out of streams resources */
|
||||
pub const ENONET: i32 = 64; /* Machine is not on the network */
|
||||
pub const ENOPKG: i32 = 65; /* Package not installed */
|
||||
pub const EREMOTE: i32 = 66; /* Object is remote */
|
||||
pub const ENOLINK: i32 = 67; /* Link has been severed */
|
||||
pub const EADV: i32 = 68; /* Advertise error */
|
||||
pub const ESRMNT: i32 = 69; /* Srmount error */
|
||||
pub const ECOMM: i32 = 70; /* Communication error on send */
|
||||
pub const EPROTO: i32 = 71; /* Protocol error */
|
||||
pub const EMULTIHOP: i32 = 72; /* Multihop attempted */
|
||||
pub const EDOTDOT: i32 = 73; /* RFS specific error */
|
||||
pub const EBADMSG: i32 = 74; /* Not a data message */
|
||||
pub const EOVERFLOW: i32 = 75; /* Value too large for defined data type */
|
||||
pub const ENOTUNIQ: i32 = 76; /* Name not unique on network */
|
||||
pub const EBADFD: i32 = 77; /* File descriptor in bad state */
|
||||
pub const EREMCHG: i32 = 78; /* Remote address changed */
|
||||
pub const ELIBACC: i32 = 79; /* Can not access a needed shared library */
|
||||
pub const ELIBBAD: i32 = 80; /* Accessing a corrupted shared library */
|
||||
pub const ELIBSCN: i32 = 81; /* .lib section in a.out corrupted */
|
||||
pub const ELIBMAX: i32 = 82; /* Attempting to link in too many shared libraries */
|
||||
pub const ELIBEXEC: i32 = 83; /* Cannot exec a shared library directly */
|
||||
pub const EILSEQ: i32 = 84; /* Illegal byte sequence */
|
||||
pub const ERESTART: i32 = 85; /* Interrupted system call should be restarted */
|
||||
pub const ESTRPIPE: i32 = 86; /* Streams pipe error */
|
||||
pub const EUSERS: i32 = 87; /* Too many users */
|
||||
pub const ENOTSOCK: i32 = 88; /* Socket operation on non-socket */
|
||||
pub const EDESTADDRREQ: i32 = 89; /* Destination address required */
|
||||
pub const EMSGSIZE: i32 = 90; /* Message too long */
|
||||
pub const EPROTOTYPE: i32 = 91; /* Protocol wrong type for socket */
|
||||
pub const ENOPROTOOPT: i32 = 92; /* Protocol not available */
|
||||
pub const EPROTONOSUPPORT: i32 = 93; /* Protocol not supported */
|
||||
pub const ESOCKTNOSUPPORT: i32 = 94; /* Socket type not supported */
|
||||
pub const EOPNOTSUPP: i32 = 95; /* Operation not supported on transport endpoint */
|
||||
pub const EPFNOSUPPORT: i32 = 96; /* Protocol family not supported */
|
||||
pub const EAFNOSUPPORT: i32 = 97; /* Address family not supported by protocol */
|
||||
pub const EADDRINUSE: i32 = 98; /* Address already in use */
|
||||
pub const EADDRNOTAVAIL: i32 = 99; /* Cannot assign requested address */
|
||||
pub const ENETDOWN: i32 = 100; /* Network is down */
|
||||
pub const ENETUNREACH: i32 = 101; /* Network is unreachable */
|
||||
pub const ENETRESET: i32 = 102; /* Network dropped connection because of reset */
|
||||
pub const ECONNABORTED: i32 = 103; /* Software caused connection abort */
|
||||
pub const ECONNRESET: i32 = 104; /* Connection reset by peer */
|
||||
pub const ENOBUFS: i32 = 105; /* No buffer space available */
|
||||
pub const EISCONN: i32 = 106; /* Transport endpoint is already connected */
|
||||
pub const ENOTCONN: i32 = 107; /* Transport endpoint is not connected */
|
||||
pub const ESHUTDOWN: i32 = 108; /* Cannot send after transport endpoint shutdown */
|
||||
pub const ETOOMANYREFS: i32 = 109; /* Too many references: cannot splice */
|
||||
pub const ETIMEDOUT: i32 = 110; /* Connection timed out */
|
||||
pub const ECONNREFUSED: i32 = 111; /* Connection refused */
|
||||
pub const EHOSTDOWN: i32 = 112; /* Host is down */
|
||||
pub const EHOSTUNREACH: i32 = 113; /* No route to host */
|
||||
pub const EALREADY: i32 = 114; /* Operation already in progress */
|
||||
pub const EINPROGRESS: i32 = 115; /* Operation now in progress */
|
||||
pub const ESTALE: i32 = 116; /* Stale NFS file handle */
|
||||
pub const EUCLEAN: i32 = 117; /* Structure needs cleaning */
|
||||
pub const ENOTNAM: i32 = 118; /* Not a XENIX named type file */
|
||||
pub const ENAVAIL: i32 = 119; /* No XENIX semaphores available */
|
||||
pub const EISNAM: i32 = 120; /* Is a named type file */
|
||||
pub const EREMOTEIO: i32 = 121; /* Remote I/O error */
|
||||
pub const EDQUOT: i32 = 122; /* Quota exceeded */
|
||||
pub const ENOMEDIUM: i32 = 123; /* No medium found */
|
||||
pub const EMEDIUMTYPE: i32 = 124; /* Wrong medium type */
|
||||
pub const ECANCELED: i32 = 125; /* Operation Canceled */
|
||||
pub const ENOKEY: i32 = 126; /* Required key not available */
|
||||
pub const EKEYEXPIRED: i32 = 127; /* Key has expired */
|
||||
pub const EKEYREVOKED: i32 = 128; /* Key has been revoked */
|
||||
pub const EKEYREJECTED: i32 = 129; /* Key was rejected by service */
|
||||
pub const EOWNERDEAD: i32 = 130; /* Owner died */
|
||||
pub const ENOTRECOVERABLE: i32 = 131; /* State not recoverable */
|
||||
|
||||
pub static STR_ERROR: [&'static str; 132] = ["Success",
|
||||
"Operation not permitted",
|
||||
"No such file or directory",
|
||||
"No such process",
|
||||
"Interrupted system call",
|
||||
"I/O error",
|
||||
"No such device or address",
|
||||
"Argument list too long",
|
||||
"Exec format error",
|
||||
"Bad file number",
|
||||
"No child processes",
|
||||
"Try again",
|
||||
"Out of memory",
|
||||
"Permission denied",
|
||||
"Bad address",
|
||||
"Block device required",
|
||||
"Device or resource busy",
|
||||
"File exists",
|
||||
"Cross-device link",
|
||||
"No such device",
|
||||
"Not a directory",
|
||||
"Is a directory",
|
||||
"Invalid argument",
|
||||
"File table overflow",
|
||||
"Too many open files",
|
||||
"Not a typewriter",
|
||||
"Text file busy",
|
||||
"File too large",
|
||||
"No space left on device",
|
||||
"Illegal seek",
|
||||
"Read-only file system",
|
||||
"Too many links",
|
||||
"Broken pipe",
|
||||
"Math argument out of domain of func",
|
||||
"Math result not representable",
|
||||
"Resource deadlock would occur",
|
||||
"File name too long",
|
||||
"No record locks available",
|
||||
"Function not implemented",
|
||||
"Directory not empty",
|
||||
"Too many symbolic links encountered",
|
||||
"Operation would block",
|
||||
"No message of desired type",
|
||||
"Identifier removed",
|
||||
"Channel number out of range",
|
||||
"Level 2 not synchronized",
|
||||
"Level 3 halted",
|
||||
"Level 3 reset",
|
||||
"Link number out of range",
|
||||
"Protocol driver not attached",
|
||||
"No CSI structure available",
|
||||
"Level 2 halted",
|
||||
"Invalid exchange",
|
||||
"Invalid request descriptor",
|
||||
"Exchange full",
|
||||
"No anode",
|
||||
"Invalid request code",
|
||||
"Invalid slot",
|
||||
"Resource deadlock would occur",
|
||||
"Bad font file format",
|
||||
"Device not a stream",
|
||||
"No data available",
|
||||
"Timer expired",
|
||||
"Out of streams resources",
|
||||
"Machine is not on the network",
|
||||
"Package not installed",
|
||||
"Object is remote",
|
||||
"Link has been severed",
|
||||
"Advertise error",
|
||||
"Srmount error",
|
||||
"Communication error on send",
|
||||
"Protocol error",
|
||||
"Multihop attempted",
|
||||
"RFS specific error",
|
||||
"Not a data message",
|
||||
"Value too large for defined data type",
|
||||
"Name not unique on network",
|
||||
"File descriptor in bad state",
|
||||
"Remote address changed",
|
||||
"Can not access a needed shared library",
|
||||
"Accessing a corrupted shared library",
|
||||
".lib section in a.out corrupted",
|
||||
"Attempting to link in too many shared libraries",
|
||||
"Cannot exec a shared library directly",
|
||||
"Illegal byte sequence",
|
||||
"Interrupted system call should be restarted",
|
||||
"Streams pipe error",
|
||||
"Too many users",
|
||||
"Socket operation on non-socket",
|
||||
"Destination address required",
|
||||
"Message too long",
|
||||
"Protocol wrong type for socket",
|
||||
"Protocol not available",
|
||||
"Protocol not supported",
|
||||
"Socket type not supported",
|
||||
"Operation not supported on transport endpoint",
|
||||
"Protocol family not supported",
|
||||
"Address family not supported by protocol",
|
||||
"Address already in use",
|
||||
"Cannot assign requested address",
|
||||
"Network is down",
|
||||
"Network is unreachable",
|
||||
"Network dropped connection because of reset",
|
||||
"Software caused connection abort",
|
||||
"Connection reset by peer",
|
||||
"No buffer space available",
|
||||
"Transport endpoint is already connected",
|
||||
"Transport endpoint is not connected",
|
||||
"Cannot send after transport endpoint shutdown",
|
||||
"Too many references: cannot splice",
|
||||
"Connection timed out",
|
||||
"Connection refused",
|
||||
"Host is down",
|
||||
"No route to host",
|
||||
"Operation already in progress",
|
||||
"Operation now in progress",
|
||||
"Stale NFS file handle",
|
||||
"Structure needs cleaning",
|
||||
"Not a XENIX named type file",
|
||||
"No XENIX semaphores available",
|
||||
"Is a named type file",
|
||||
"Remote I/O error",
|
||||
"Quota exceeded",
|
||||
"No medium found",
|
||||
"Wrong medium type",
|
||||
"Operation Canceled",
|
||||
"Required key not available",
|
||||
"Key has expired",
|
||||
"Key has been revoked",
|
||||
"Key was rejected by service",
|
||||
"Owner died",
|
||||
"State not recoverable"];
|
|
@ -0,0 +1,84 @@
|
|||
pub const CLONE_VM: usize = 0x100;
|
||||
pub const CLONE_FS: usize = 0x200;
|
||||
pub const CLONE_FILES: usize = 0x400;
|
||||
pub const CLONE_VFORK: usize = 0x4000;
|
||||
|
||||
pub const CLOCK_REALTIME: usize = 1;
|
||||
pub const CLOCK_MONOTONIC: usize = 4;
|
||||
|
||||
pub const EVENT_NONE: usize = 0;
|
||||
pub const EVENT_READ: usize = 1;
|
||||
pub const EVENT_WRITE: usize = 2;
|
||||
|
||||
pub const F_GETFL: usize = 1;
|
||||
pub const F_SETFL: usize = 2;
|
||||
|
||||
pub const FUTEX_WAIT: usize = 0;
|
||||
pub const FUTEX_WAKE: usize = 1;
|
||||
pub const FUTEX_REQUEUE: usize = 2;
|
||||
|
||||
pub const MAP_WRITE: usize = 1;
|
||||
pub const MAP_WRITE_COMBINE: usize = 2;
|
||||
|
||||
pub const MODE_TYPE: u16 = 0xF000;
|
||||
pub const MODE_DIR: u16 = 0x4000;
|
||||
pub const MODE_FILE: u16 = 0x8000;
|
||||
|
||||
pub const MODE_PERM: u16 = 0x0FFF;
|
||||
pub const MODE_SETUID: u16 = 0o4000;
|
||||
pub const MODE_SETGID: u16 = 0o2000;
|
||||
|
||||
pub const O_RDONLY: usize = 0x0001_0000;
|
||||
pub const O_WRONLY: usize = 0x0002_0000;
|
||||
pub const O_RDWR: usize = 0x0003_0000;
|
||||
pub const O_NONBLOCK: usize = 0x0004_0000;
|
||||
pub const O_APPEND: usize = 0x0008_0000;
|
||||
pub const O_SHLOCK: usize = 0x0010_0000;
|
||||
pub const O_EXLOCK: usize = 0x0020_0000;
|
||||
pub const O_ASYNC: usize = 0x0040_0000;
|
||||
pub const O_FSYNC: usize = 0x0080_0000;
|
||||
pub const O_CLOEXEC: usize = 0x0100_0000;
|
||||
pub const O_CREAT: usize = 0x0200_0000;
|
||||
pub const O_TRUNC: usize = 0x0400_0000;
|
||||
pub const O_EXCL: usize = 0x0800_0000;
|
||||
pub const O_DIRECTORY: usize = 0x1000_0000;
|
||||
pub const O_STAT: usize = 0x2000_0000;
|
||||
pub const O_ACCMODE: usize = O_RDONLY | O_WRONLY | O_RDWR;
|
||||
|
||||
pub const SEEK_SET: usize = 0;
|
||||
pub const SEEK_CUR: usize = 1;
|
||||
pub const SEEK_END: usize = 2;
|
||||
|
||||
pub const SIGHUP: usize = 1;
|
||||
pub const SIGINT: usize = 2;
|
||||
pub const SIGQUIT: usize = 3;
|
||||
pub const SIGILL: usize = 4;
|
||||
pub const SIGTRAP: usize = 5;
|
||||
pub const SIGABRT: usize = 6;
|
||||
pub const SIGBUS: usize = 7;
|
||||
pub const SIGFPE: usize = 8;
|
||||
pub const SIGKILL: usize = 9;
|
||||
pub const SIGUSR1: usize = 10;
|
||||
pub const SIGSEGV: usize = 11;
|
||||
pub const SIGUSR2: usize = 12;
|
||||
pub const SIGPIPE: usize = 13;
|
||||
pub const SIGALRM: usize = 14;
|
||||
pub const SIGTERM: usize = 15;
|
||||
pub const SIGSTKFLT: usize= 16;
|
||||
pub const SIGCHLD: usize = 17;
|
||||
pub const SIGCONT: usize = 18;
|
||||
pub const SIGSTOP: usize = 19;
|
||||
pub const SIGTSTP: usize = 20;
|
||||
pub const SIGTTIN: usize = 21;
|
||||
pub const SIGTTOU: usize = 22;
|
||||
pub const SIGURG: usize = 23;
|
||||
pub const SIGXCPU: usize = 24;
|
||||
pub const SIGXFSZ: usize = 25;
|
||||
pub const SIGVTALRM: usize= 26;
|
||||
pub const SIGPROF: usize = 27;
|
||||
pub const SIGWINCH: usize = 28;
|
||||
pub const SIGIO: usize = 29;
|
||||
pub const SIGPWR: usize = 30;
|
||||
pub const SIGSYS: usize = 31;
|
||||
|
||||
pub const WNOHANG: usize = 1;
|
|
@ -0,0 +1,76 @@
|
|||
use core::{mem, ptr};
|
||||
use core::ops::{Deref, DerefMut};
|
||||
|
||||
use Result;
|
||||
|
||||
struct PhysBox {
|
||||
address: usize,
|
||||
size: usize
|
||||
}
|
||||
|
||||
impl PhysBox {
|
||||
fn new(size: usize) -> Result<PhysBox> {
|
||||
let address = unsafe { ::physalloc(size)? };
|
||||
Ok(PhysBox {
|
||||
address: address,
|
||||
size: size
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for PhysBox {
|
||||
fn drop(&mut self) {
|
||||
let _ = unsafe { ::physfree(self.address, self.size) };
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Dma<T> {
|
||||
phys: PhysBox,
|
||||
virt: *mut T
|
||||
}
|
||||
|
||||
impl<T> Dma<T> {
|
||||
pub fn new(value: T) -> Result<Dma<T>> {
|
||||
let phys = PhysBox::new(mem::size_of::<T>())?;
|
||||
let virt = unsafe { ::physmap(phys.address, phys.size, ::MAP_WRITE)? } as *mut T;
|
||||
unsafe { ptr::write(virt, value); }
|
||||
Ok(Dma {
|
||||
phys: phys,
|
||||
virt: virt
|
||||
})
|
||||
}
|
||||
|
||||
pub fn zeroed() -> Result<Dma<T>> {
|
||||
let phys = PhysBox::new(mem::size_of::<T>())?;
|
||||
let virt = unsafe { ::physmap(phys.address, phys.size, ::MAP_WRITE)? } as *mut T;
|
||||
unsafe { ptr::write_bytes(virt as *mut u8, 0, phys.size); }
|
||||
Ok(Dma {
|
||||
phys: phys,
|
||||
virt: virt
|
||||
})
|
||||
}
|
||||
|
||||
pub fn physical(&self) -> usize {
|
||||
self.phys.address
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for Dma<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
unsafe { &*self.virt }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> DerefMut for Dma<T> {
|
||||
fn deref_mut(&mut self) -> &mut T {
|
||||
unsafe { &mut *self.virt }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for Dma<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { drop(ptr::read(self.virt)); }
|
||||
let _ = unsafe { ::physunmap(self.virt as usize) };
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
use core::cmp::PartialEq;
|
||||
use core::ops::{BitAnd, BitOr, Not};
|
||||
|
||||
pub trait Io {
|
||||
type Value: Copy + PartialEq + BitAnd<Output = Self::Value> + BitOr<Output = Self::Value> + Not<Output = Self::Value>;
|
||||
|
||||
fn read(&self) -> Self::Value;
|
||||
fn write(&mut self, value: Self::Value);
|
||||
|
||||
#[inline(always)]
|
||||
fn readf(&self, flags: Self::Value) -> bool {
|
||||
(self.read() & flags) as Self::Value == flags
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn writef(&mut self, flags: Self::Value, value: bool) {
|
||||
let tmp: Self::Value = match value {
|
||||
true => self.read() | flags,
|
||||
false => self.read() & !flags,
|
||||
};
|
||||
self.write(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ReadOnly<I: Io> {
|
||||
inner: I
|
||||
}
|
||||
|
||||
impl<I: Io> ReadOnly<I> {
|
||||
pub const fn new(inner: I) -> ReadOnly<I> {
|
||||
ReadOnly {
|
||||
inner: inner
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn read(&self) -> I::Value {
|
||||
self.inner.read()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn readf(&self, flags: I::Value) -> bool {
|
||||
self.inner.readf(flags)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WriteOnly<I: Io> {
|
||||
inner: I
|
||||
}
|
||||
|
||||
impl<I: Io> WriteOnly<I> {
|
||||
pub const fn new(inner: I) -> WriteOnly<I> {
|
||||
WriteOnly {
|
||||
inner: inner
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn write(&mut self, value: I::Value) {
|
||||
self.inner.write(value)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn writef(&mut self, flags: I::Value, value: bool) {
|
||||
self.inner.writef(flags, value)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
use core::intrinsics::{volatile_load, volatile_store};
|
||||
use core::mem::uninitialized;
|
||||
use core::ops::{BitAnd, BitOr, Not};
|
||||
|
||||
use super::io::Io;
|
||||
|
||||
#[repr(packed)]
|
||||
pub struct Mmio<T> {
|
||||
value: T,
|
||||
}
|
||||
|
||||
impl<T> Mmio<T> {
|
||||
/// Create a new Mmio without initializing
|
||||
pub fn new() -> Self {
|
||||
Mmio {
|
||||
value: unsafe { uninitialized() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Io for Mmio<T> where T: Copy + PartialEq + BitAnd<Output = T> + BitOr<Output = T> + Not<Output = T> {
|
||||
type Value = T;
|
||||
|
||||
fn read(&self) -> T {
|
||||
unsafe { volatile_load(&self.value) }
|
||||
}
|
||||
|
||||
fn write(&mut self, value: T) {
|
||||
unsafe { volatile_store(&mut self.value, value) };
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
//! I/O functions
|
||||
|
||||
pub use self::dma::*;
|
||||
pub use self::io::*;
|
||||
pub use self::mmio::*;
|
||||
pub use self::pio::*;
|
||||
|
||||
mod dma;
|
||||
mod io;
|
||||
mod mmio;
|
||||
mod pio;
|
|
@ -0,0 +1,89 @@
|
|||
use core::marker::PhantomData;
|
||||
|
||||
use super::io::Io;
|
||||
|
||||
/// Generic PIO
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Pio<T> {
|
||||
port: u16,
|
||||
value: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T> Pio<T> {
|
||||
/// Create a PIO from a given port
|
||||
pub const fn new(port: u16) -> Self {
|
||||
Pio::<T> {
|
||||
port: port,
|
||||
value: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Read/Write for byte PIO
|
||||
impl Io for Pio<u8> {
|
||||
type Value = u8;
|
||||
|
||||
/// Read
|
||||
#[inline(always)]
|
||||
fn read(&self) -> u8 {
|
||||
let value: u8;
|
||||
unsafe {
|
||||
asm!("in $0, $1" : "={al}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile");
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
/// Write
|
||||
#[inline(always)]
|
||||
fn write(&mut self, value: u8) {
|
||||
unsafe {
|
||||
asm!("out $1, $0" : : "{al}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Read/Write for word PIO
|
||||
impl Io for Pio<u16> {
|
||||
type Value = u16;
|
||||
|
||||
/// Read
|
||||
#[inline(always)]
|
||||
fn read(&self) -> u16 {
|
||||
let value: u16;
|
||||
unsafe {
|
||||
asm!("in $0, $1" : "={ax}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile");
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
/// Write
|
||||
#[inline(always)]
|
||||
fn write(&mut self, value: u16) {
|
||||
unsafe {
|
||||
asm!("out $1, $0" : : "{ax}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Read/Write for doubleword PIO
|
||||
impl Io for Pio<u32> {
|
||||
type Value = u32;
|
||||
|
||||
/// Read
|
||||
#[inline(always)]
|
||||
fn read(&self) -> u32 {
|
||||
let value: u32;
|
||||
unsafe {
|
||||
asm!("in $0, $1" : "={eax}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile");
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
/// Write
|
||||
#[inline(always)]
|
||||
fn write(&mut self, value: u32) {
|
||||
unsafe {
|
||||
asm!("out $1, $0" : : "{eax}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
#![deny(warnings)]
|
||||
#![feature(asm)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![no_std]
|
||||
|
||||
pub use self::arch::*;
|
||||
pub use self::call::*;
|
||||
pub use self::data::*;
|
||||
pub use self::error::*;
|
||||
pub use self::flag::*;
|
||||
pub use self::io::*;
|
||||
pub use self::number::*;
|
||||
pub use self::scheme::*;
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[path="arch/arm.rs"]
|
||||
mod arch;
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
#[path="arch/x86.rs"]
|
||||
mod arch;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[path="arch/x86_64.rs"]
|
||||
mod arch;
|
||||
|
||||
/// Function definitions
|
||||
pub mod call;
|
||||
|
||||
/// Complex structures that are used for some system calls
|
||||
pub mod data;
|
||||
|
||||
/// All errors that can be generated by a system call
|
||||
pub mod error;
|
||||
|
||||
/// Flags used as an argument to many system calls
|
||||
pub mod flag;
|
||||
|
||||
/// Functions for low level hardware control
|
||||
pub mod io;
|
||||
|
||||
/// Call numbers used by each system call
|
||||
pub mod number;
|
||||
|
||||
/// A trait useful for scheme handlers
|
||||
pub mod scheme;
|
|
@ -0,0 +1,64 @@
|
|||
pub const SYS_CLASS: usize = 0xF000_0000;
|
||||
pub const SYS_CLASS_PATH: usize=0x1000_0000;
|
||||
pub const SYS_CLASS_FILE: usize=0x2000_0000;
|
||||
|
||||
pub const SYS_ARG: usize = 0x0F00_0000;
|
||||
pub const SYS_ARG_SLICE: usize =0x0100_0000;
|
||||
pub const SYS_ARG_MSLICE: usize=0x0200_0000;
|
||||
pub const SYS_ARG_PATH: usize = 0x0300_0000;
|
||||
|
||||
pub const SYS_RET: usize = 0x00F0_0000;
|
||||
pub const SYS_RET_FILE: usize = 0x0010_0000;
|
||||
|
||||
pub const SYS_LINK: usize = SYS_CLASS_PATH | SYS_ARG_PATH | 9;
|
||||
pub const SYS_OPEN: usize = SYS_CLASS_PATH | SYS_RET_FILE | 5;
|
||||
pub const SYS_CHMOD: usize = SYS_CLASS_PATH | 15;
|
||||
pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84;
|
||||
pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10;
|
||||
|
||||
pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6;
|
||||
pub const SYS_DUP: usize = SYS_CLASS_FILE | SYS_RET_FILE | 41;
|
||||
pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63;
|
||||
pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3;
|
||||
pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4;
|
||||
pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19;
|
||||
pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55;
|
||||
pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927;
|
||||
pub const SYS_FMAP: usize = SYS_CLASS_FILE | 90;
|
||||
pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 91;
|
||||
pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928;
|
||||
pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28;
|
||||
pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100;
|
||||
pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118;
|
||||
pub const SYS_FTRUNCATE: usize =SYS_CLASS_FILE | 93;
|
||||
|
||||
pub const SYS_BRK: usize = 45;
|
||||
pub const SYS_CHDIR: usize = 12;
|
||||
pub const SYS_CLOCK_GETTIME: usize = 265;
|
||||
pub const SYS_CLONE: usize = 120;
|
||||
pub const SYS_EXECVE: usize = 11;
|
||||
pub const SYS_EXIT: usize = 1;
|
||||
pub const SYS_FUTEX: usize = 240;
|
||||
pub const SYS_GETCWD: usize = 183;
|
||||
pub const SYS_GETEGID: usize = 202;
|
||||
pub const SYS_GETENS: usize = 951;
|
||||
pub const SYS_GETEUID: usize = 201;
|
||||
pub const SYS_GETGID: usize = 200;
|
||||
pub const SYS_GETNS: usize = 950;
|
||||
pub const SYS_GETPID: usize = 20;
|
||||
pub const SYS_GETUID: usize = 199;
|
||||
pub const SYS_IOPL: usize = 110;
|
||||
pub const SYS_KILL: usize = 37;
|
||||
pub const SYS_MKNS: usize = 984;
|
||||
pub const SYS_NANOSLEEP: usize =162;
|
||||
pub const SYS_PHYSALLOC: usize =945;
|
||||
pub const SYS_PHYSFREE: usize = 946;
|
||||
pub const SYS_PHYSMAP: usize = 947;
|
||||
pub const SYS_PHYSUNMAP: usize =948;
|
||||
pub const SYS_VIRTTOPHYS: usize=949;
|
||||
pub const SYS_PIPE2: usize = 331;
|
||||
pub const SYS_SETREGID: usize = 204;
|
||||
pub const SYS_SETRENS: usize = 952;
|
||||
pub const SYS_SETREUID: usize = 203;
|
||||
pub const SYS_WAITPID: usize = 7;
|
||||
pub const SYS_YIELD: usize = 158;
|
|
@ -0,0 +1,232 @@
|
|||
use core::{mem, slice};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub trait Scheme {
|
||||
fn handle(&self, packet: &mut Packet) {
|
||||
packet.a = Error::mux(match packet.a {
|
||||
SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid),
|
||||
SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid),
|
||||
SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid),
|
||||
SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid),
|
||||
|
||||
SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
|
||||
SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
|
||||
SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
|
||||
SYS_LSEEK => self.seek(packet.b, packet.c, packet.d),
|
||||
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
|
||||
SYS_FEVENT => self.fevent(packet.b, packet.c),
|
||||
SYS_FMAP => self.fmap(packet.b, packet.c, packet.d),
|
||||
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
|
||||
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() { self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) } else { Err(Error::new(EFAULT)) },
|
||||
SYS_FSTATVFS => if packet.d >= mem::size_of::<StatVfs>() { self.fstatvfs(packet.b, unsafe { &mut *(packet.c as *mut StatVfs) }) } else { Err(Error::new(EFAULT)) },
|
||||
SYS_FSYNC => self.fsync(packet.b),
|
||||
SYS_FTRUNCATE => self.ftruncate(packet.b, packet.c),
|
||||
SYS_CLOSE => self.close(packet.b),
|
||||
|
||||
_ => Err(Error::new(ENOSYS))
|
||||
});
|
||||
}
|
||||
|
||||
/* Scheme operations */
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn open(&self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn rmdir(&self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn unlink(&self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
/* Resource operations */
|
||||
#[allow(unused_variables)]
|
||||
fn dup(&self, old_id: usize, buf: &[u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn read(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn write(&self, id: usize, buf: &[u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn seek(&self, id: usize, pos: usize, whence: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fcntl(&self, id: usize, cmd: usize, arg: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fevent(&self, id: usize, flags: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fmap(&self, id: usize, offset: usize, size: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fstat(&self, id: usize, stat: &mut Stat) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fstatvfs(&self, id: usize, stat: &mut StatVfs) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fsync(&self, id: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn ftruncate(&self, id: usize, len: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn close(&self, id: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SchemeMut {
|
||||
fn handle(&mut self, packet: &mut Packet) {
|
||||
packet.a = Error::mux(match packet.a {
|
||||
SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid),
|
||||
SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid),
|
||||
SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid),
|
||||
SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid),
|
||||
|
||||
SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
|
||||
SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
|
||||
SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }),
|
||||
SYS_LSEEK => self.seek(packet.b, packet.c, packet.d),
|
||||
SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d),
|
||||
SYS_FEVENT => self.fevent(packet.b, packet.c),
|
||||
SYS_FMAP => self.fmap(packet.b, packet.c, packet.d),
|
||||
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
|
||||
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() { self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) } else { Err(Error::new(EFAULT)) },
|
||||
SYS_FSTATVFS => if packet.d >= mem::size_of::<StatVfs>() { self.fstatvfs(packet.b, unsafe { &mut *(packet.c as *mut StatVfs) }) } else { Err(Error::new(EFAULT)) },
|
||||
SYS_FSYNC => self.fsync(packet.b),
|
||||
SYS_FTRUNCATE => self.ftruncate(packet.b, packet.c),
|
||||
SYS_CLOSE => self.close(packet.b),
|
||||
|
||||
_ => Err(Error::new(ENOSYS))
|
||||
});
|
||||
}
|
||||
|
||||
/* Scheme operations */
|
||||
#[allow(unused_variables)]
|
||||
fn open(&mut self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn rmdir(&mut self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn unlink(&mut self, path: &[u8], uid: u32, gid: u32) -> Result<usize> {
|
||||
Err(Error::new(ENOENT))
|
||||
}
|
||||
|
||||
/* Resource operations */
|
||||
#[allow(unused_variables)]
|
||||
fn dup(&mut self, old_id: usize, buf: &[u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn read(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn write(&mut self, id: usize, buf: &[u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn seek(&mut self, id: usize, pos: usize, whence: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fcntl(&mut self, id: usize, cmd: usize, arg: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fevent(&mut self, id: usize, flags: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fmap(&mut self, id: usize, offset: usize, size: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fstat(&mut self, id: usize, stat: &mut Stat) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fstatvfs(&self, id: usize, stat: &mut StatVfs) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn fsync(&mut self, id: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn ftruncate(&mut self, id: usize, len: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn close(&mut self, id: usize) -> Result<usize> {
|
||||
Err(Error::new(EBADF))
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"c1e953ee360e77de57f7b02f1b7880bd6a3dc22d1a69e953c2ac2c52cc52d247",".travis.yml":"0b3aedafe95a176323862579626f44f1e6e133a8be8d6dcc763194870de05a4f","Cargo.toml":"228d3261e17dac22f5d9309cd26cf8da841ff82c3250886efedf7b332979fe8f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"fdd42ee4d95c0f9e4a6da0f621e859f5f15009a14ed4c454d3db69a6020a5a9f","appveyor.yml":"da991211b72fa6f231af7adb84c9fb72f5a9131d1c0a3d47b8ceffe5a82c8542","benches/precise_time_ns.rs":"f331c85489a05ea3bb83df9d57131a6e651ce852ca881417f328c4e8f53503c6","src/display.rs":"ea481cc44d7b630d962cdb465986a2c4b18c532d1661b45945644d482bb670a1","src/duration.rs":"032f2ced8ea4dddaf6ed111f345e99217bad17edb7ed9fc4c511e405c8e02b87","src/lib.rs":"9cfed653793f67f3846dcb8e65595b49f786fc52022259fd3a59e0792e559016","src/parse.rs":"717ae5735dfdaaba513f2a54a179e73bb2a48f8d4fb8787740d4662d6ff3389c","src/sys.rs":"8147b7fe7cbc37c6586c6fca87dd45fb541f3eef74e4b22c06589e9ad104982e"},"package":"3c7ec6d62a20df54e07ab3b78b9a3932972f4b7981de295563686849eb3989af"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"c1e953ee360e77de57f7b02f1b7880bd6a3dc22d1a69e953c2ac2c52cc52d247",".travis.yml":"9555a092ed1f87de52b07a90c614a30c6fa8f307eb4b05229253d06df363ce7a","Cargo.toml":"9369a5798a85c467578e9be04ffdb220d1d7457950373bd3b0662a62ca58520b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"2c17f942c4a797f6f491c6d40570f904f35047531884ded3244438832b3d6f0a","appveyor.yml":"da991211b72fa6f231af7adb84c9fb72f5a9131d1c0a3d47b8ceffe5a82c8542","benches/precise_time_ns.rs":"f331c85489a05ea3bb83df9d57131a6e651ce852ca881417f328c4e8f53503c6","src/display.rs":"b79a81b4f068e44934ad3398ba0259120cc30cf0855ac5108c4569e320fd7f1d","src/duration.rs":"032f2ced8ea4dddaf6ed111f345e99217bad17edb7ed9fc4c511e405c8e02b87","src/lib.rs":"d01631b2340e30673e4c809678a5bdd3f8c18debb25ada21805a990254cb7caf","src/parse.rs":"717ae5735dfdaaba513f2a54a179e73bb2a48f8d4fb8787740d4662d6ff3389c","src/sys.rs":"a6bf379947da5ed16063a9bfcdf877c84e38e006a9cbc45ee0558cba4cf5c295"},"package":"211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade"}
|
|
@ -4,24 +4,21 @@ rust:
|
|||
- beta
|
||||
- nightly
|
||||
sudo: false
|
||||
before_script:
|
||||
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
|
||||
script:
|
||||
- cargo build --verbose
|
||||
- cargo test --verbose
|
||||
- cargo test --verbose --features rustc-serialize
|
||||
- |
|
||||
[ $TRAVIS_RUST_VERSION != nightly ] || cargo bench
|
||||
- cargo doc
|
||||
after_success: |
|
||||
[ $TRAVIS_BRANCH = master ] &&
|
||||
[ $TRAVIS_PULL_REQUEST = false ] &&
|
||||
[ $TRAVIS_RUST_VERSION = nightly ] &&
|
||||
echo '<meta http-equiv=refresh content=0;url=time/index.html>' > target/doc/index.html &&
|
||||
pip install ghp-import --user $USER &&
|
||||
$HOME/.local/bin/ghp-import -n target/doc &&
|
||||
git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
|
||||
- cargo doc --no-deps
|
||||
after_success:
|
||||
- travis-cargo --only nightly doc-upload
|
||||
env:
|
||||
global:
|
||||
secure: qxCB/4AUtX5cQPDfmAccpxRkxkdoZtkjiYW5tbaThzFEJJ1SpkIJzS+IdhCPxDGhwF+aiLLky9KDZi1bXbtjkDS8n/bFaGc/k2vRNgLKuaLdztZ1dGHlBNN2J7j0bLGUm0MAy62OHLNXbPmvS0uGvv0q4pQ6sQB2+YItwqHPuyQ=
|
||||
secure: "NlXnNaUBf2MgV2gPJyIQU+JM814e29itvvb8o5BvN4YB60rseu16yLbzKpO4FzuOFBc/Uc+1veDcKyzZYsdV6FIwQk4jfdUkNZ3i56InVCzXcaaHCe78cpg/IxK+/48fGy/EIJkWYdtQsoVCGunaf5NdF360Lzb6G/B1vheC34E="
|
||||
|
||||
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
|
||||
name = "time"
|
||||
version = "0.1.35"
|
||||
version = "0.1.36"
|
||||
authors = ["The Rust Project Developers"]
|
||||
license = "MIT/Apache-2.0"
|
||||
homepage = "https://github.com/rust-lang/time"
|
||||
|
@ -13,9 +13,14 @@ Utilities for working with time-related functions in Rust.
|
|||
|
||||
[dependencies]
|
||||
libc = "0.2.1"
|
||||
rustc-serialize = { version = "0.3", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "redox")'.dependencies]
|
||||
redox_syscall = "0.1"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = "0.2.0"
|
||||
kernel32-sys = "0.2.0"
|
||||
rustc-serialize = { version = "0.3", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
log = "0.3"
|
||||
|
|
|
@ -8,6 +8,12 @@ Utilities for working with time-related functions in Rust
|
|||
|
||||
[Documentation](https://doc.rust-lang.org/time)
|
||||
|
||||
## Notes
|
||||
|
||||
This library is no longer actively maintained, but bugfixes will be added ([details](https://github.com/rust-lang-deprecated/time/issues/136)).
|
||||
|
||||
In case you're looking for something a little fresher and more actively maintained have a look at the [`chrono`](https://github.com/lifthrasiir/rust-chrono) crate.
|
||||
|
||||
## Usage
|
||||
|
||||
Put this in your `Cargo.toml`:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::fmt::{self, Display};
|
||||
use std::fmt::{self, Write};
|
||||
|
||||
use super::{TmFmt, Tm, Fmt};
|
||||
|
||||
|
@ -13,7 +13,7 @@ impl<'a> fmt::Display for TmFmt<'a> {
|
|||
// another char
|
||||
try!(parse_type(fmt, chars.next().unwrap(), self.tm));
|
||||
} else {
|
||||
try!(write!(fmt, "{}", ch));
|
||||
try!(fmt.write_char(ch));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ fn iso_week(fmt: &mut fmt::Formatter, ch:char, tm: &Tm) -> fmt::Result {
|
|||
|
||||
fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
||||
match ch {
|
||||
'A' => write!(fmt, "{}", match tm.tm_wday {
|
||||
'A' => fmt.write_str(match tm.tm_wday {
|
||||
0 => "Sunday",
|
||||
1 => "Monday",
|
||||
2 => "Tuesday",
|
||||
|
@ -106,7 +106,7 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
6 => "Saturday",
|
||||
_ => unreachable!(),
|
||||
}),
|
||||
'a' => write!(fmt, "{}", match tm.tm_wday {
|
||||
'a' => fmt.write_str(match tm.tm_wday {
|
||||
0 => "Sun",
|
||||
1 => "Mon",
|
||||
2 => "Tue",
|
||||
|
@ -116,7 +116,7 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
6 => "Sat",
|
||||
_ => unreachable!(),
|
||||
}),
|
||||
'B' => write!(fmt, "{}", match tm.tm_mon {
|
||||
'B' => fmt.write_str(match tm.tm_mon {
|
||||
0 => "January",
|
||||
1 => "February",
|
||||
2 => "March",
|
||||
|
@ -131,7 +131,7 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
11 => "December",
|
||||
_ => unreachable!(),
|
||||
}),
|
||||
'b' | 'h' => write!(fmt, "{}", match tm.tm_mon {
|
||||
'b' | 'h' => fmt.write_str(match tm.tm_mon {
|
||||
0 => "Jan",
|
||||
1 => "Feb",
|
||||
2 => "Mar",
|
||||
|
@ -149,20 +149,20 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
'C' => write!(fmt, "{:02}", (tm.tm_year + 1900) / 100),
|
||||
'c' => {
|
||||
try!(parse_type(fmt, 'a', tm));
|
||||
try!(write!(fmt, " "));
|
||||
try!(fmt.write_str(" "));
|
||||
try!(parse_type(fmt, 'b', tm));
|
||||
try!(write!(fmt, " "));
|
||||
try!(fmt.write_str(" "));
|
||||
try!(parse_type(fmt, 'e', tm));
|
||||
try!(write!(fmt, " "));
|
||||
try!(fmt.write_str(" "));
|
||||
try!(parse_type(fmt, 'T', tm));
|
||||
try!(write!(fmt, " "));
|
||||
try!(fmt.write_str(" "));
|
||||
parse_type(fmt, 'Y', tm)
|
||||
}
|
||||
'D' | 'x' => {
|
||||
try!(parse_type(fmt, 'm', tm));
|
||||
try!(write!(fmt, "/"));
|
||||
try!(fmt.write_str("/"));
|
||||
try!(parse_type(fmt, 'd', tm));
|
||||
try!(write!(fmt, "/"));
|
||||
try!(fmt.write_str("/"));
|
||||
parse_type(fmt, 'y', tm)
|
||||
}
|
||||
'd' => write!(fmt, "{:02}", tm.tm_mday),
|
||||
|
@ -170,9 +170,9 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
'f' => write!(fmt, "{:09}", tm.tm_nsec),
|
||||
'F' => {
|
||||
try!(parse_type(fmt, 'Y', tm));
|
||||
try!(write!(fmt, "-"));
|
||||
try!(fmt.write_str("-"));
|
||||
try!(parse_type(fmt, 'm', tm));
|
||||
try!(write!(fmt, "-"));
|
||||
try!(fmt.write_str("-"));
|
||||
parse_type(fmt, 'd', tm)
|
||||
}
|
||||
'G' => iso_week(fmt, 'G', tm),
|
||||
|
@ -194,33 +194,33 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
}
|
||||
'M' => write!(fmt, "{:02}", tm.tm_min),
|
||||
'm' => write!(fmt, "{:02}", tm.tm_mon + 1),
|
||||
'n' => write!(fmt, "\n"),
|
||||
'P' => write!(fmt, "{}", if tm.tm_hour < 12 { "am" } else { "pm" }),
|
||||
'p' => write!(fmt, "{}", if (tm.tm_hour) < 12 { "AM" } else { "PM" }),
|
||||
'n' => fmt.write_str("\n"),
|
||||
'P' => fmt.write_str(if tm.tm_hour < 12 { "am" } else { "pm" }),
|
||||
'p' => fmt.write_str(if (tm.tm_hour) < 12 { "AM" } else { "PM" }),
|
||||
'R' => {
|
||||
try!(parse_type(fmt, 'H', tm));
|
||||
try!(write!(fmt, ":"));
|
||||
try!(fmt.write_str(":"));
|
||||
parse_type(fmt, 'M', tm)
|
||||
}
|
||||
'r' => {
|
||||
try!(parse_type(fmt, 'I', tm));
|
||||
try!(write!(fmt, ":"));
|
||||
try!(fmt.write_str(":"));
|
||||
try!(parse_type(fmt, 'M', tm));
|
||||
try!(write!(fmt, ":"));
|
||||
try!(fmt.write_str(":"));
|
||||
try!(parse_type(fmt, 'S', tm));
|
||||
try!(write!(fmt, " "));
|
||||
try!(fmt.write_str(" "));
|
||||
parse_type(fmt, 'p', tm)
|
||||
}
|
||||
'S' => write!(fmt, "{:02}", tm.tm_sec),
|
||||
's' => write!(fmt, "{}", tm.to_timespec().sec),
|
||||
'T' | 'X' => {
|
||||
try!(parse_type(fmt, 'H', tm));
|
||||
try!(write!(fmt, ":"));
|
||||
try!(fmt.write_str(":"));
|
||||
try!(parse_type(fmt, 'M', tm));
|
||||
try!(write!(fmt, ":"));
|
||||
try!(fmt.write_str(":"));
|
||||
parse_type(fmt, 'S', tm)
|
||||
}
|
||||
't' => write!(fmt, "\t"),
|
||||
't' => fmt.write_str("\t"),
|
||||
'U' => write!(fmt, "{:02}", (tm.tm_yday - tm.tm_wday + 7) / 7),
|
||||
'u' => {
|
||||
let i = tm.tm_wday;
|
||||
|
@ -229,9 +229,9 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
'V' => iso_week(fmt, 'V', tm),
|
||||
'v' => {
|
||||
try!(parse_type(fmt, 'e', tm));
|
||||
try!(write!(fmt, "-"));
|
||||
try!(fmt.write_str("-"));
|
||||
try!(parse_type(fmt, 'b', tm));
|
||||
try!(write!(fmt, "-"));
|
||||
try!(fmt.write_str("-"));
|
||||
parse_type(fmt, 'Y', tm)
|
||||
}
|
||||
'W' => {
|
||||
|
@ -241,7 +241,7 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
'Y' => write!(fmt, "{}", tm.tm_year + 1900),
|
||||
'y' => write!(fmt, "{:02}", (tm.tm_year + 1900) % 100),
|
||||
// FIXME (#2350): support locale
|
||||
'Z' => write!(fmt, "{}", if tm.tm_utcoff == 0 { "UTC"} else { "" }),
|
||||
'Z' => fmt.write_str(if tm.tm_utcoff == 0 { "UTC"} else { "" }),
|
||||
'z' => {
|
||||
let sign = if tm.tm_utcoff > 0 { '+' } else { '-' };
|
||||
let mut m = abs(tm.tm_utcoff) / 60;
|
||||
|
@ -250,7 +250,7 @@ fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result {
|
|||
write!(fmt, "{}{:02}{:02}", sign, h, m)
|
||||
}
|
||||
'+' => write!(fmt, "{}", tm.rfc3339()),
|
||||
'%' => write!(fmt, "{}", "%"),
|
||||
'%' => fmt.write_str("%"),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#![allow(trivial_numeric_casts)]
|
||||
#![cfg_attr(test, deny(warnings))]
|
||||
|
||||
#[cfg(target_os = "redox")] extern crate syscall;
|
||||
#[cfg(unix)] extern crate libc;
|
||||
#[cfg(windows)] extern crate kernel32;
|
||||
#[cfg(windows)] extern crate winapi;
|
||||
|
@ -1147,6 +1148,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[allow(deprecated)]
|
||||
fn test_timespec_hash() {
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
|
|
|
@ -2,6 +2,201 @@
|
|||
|
||||
pub use self::inner::*;
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
mod inner {
|
||||
use std::fmt;
|
||||
use std::cmp::Ordering;
|
||||
use std::ops::{Add, Sub};
|
||||
use syscall;
|
||||
|
||||
use Duration;
|
||||
use Tm;
|
||||
|
||||
fn time_to_tm(ts: i64, tm: &mut Tm) {
|
||||
let leapyear = |year| -> bool {
|
||||
year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
|
||||
};
|
||||
|
||||
static _ytab: [[i64; 12]; 2] = [
|
||||
[ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ],
|
||||
[ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
|
||||
];
|
||||
|
||||
let mut year = 1970;
|
||||
|
||||
let dayclock = ts % 86400;
|
||||
let mut dayno = ts / 86400;
|
||||
|
||||
tm.tm_sec = (dayclock % 60) as i32;
|
||||
tm.tm_min = ((dayclock % 3600) / 60) as i32;
|
||||
tm.tm_hour = (dayclock / 3600) as i32;
|
||||
tm.tm_wday = ((dayno + 4) % 7) as i32;
|
||||
loop {
|
||||
let yearsize = if leapyear(year) {
|
||||
366
|
||||
} else {
|
||||
365
|
||||
};
|
||||
if dayno >= yearsize {
|
||||
dayno -= yearsize;
|
||||
year += 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tm.tm_year = (year - 1900) as i32;
|
||||
tm.tm_yday = dayno as i32;
|
||||
let mut mon = 0;
|
||||
while dayno >= _ytab[if leapyear(year) { 1 } else { 0 }][mon] {
|
||||
dayno -= _ytab[if leapyear(year) { 1 } else { 0 }][mon];
|
||||
mon += 1;
|
||||
}
|
||||
tm.tm_mon = mon as i32;
|
||||
tm.tm_mday = dayno as i32 + 1;
|
||||
tm.tm_isdst = 0;
|
||||
}
|
||||
|
||||
fn tm_to_time(tm: &Tm) -> i64 {
|
||||
let mut y = tm.tm_year as i64 + 1900;
|
||||
let mut m = tm.tm_mon as i64 + 1;
|
||||
if m <= 2 {
|
||||
y -= 1;
|
||||
m += 12;
|
||||
}
|
||||
let d = tm.tm_mday as i64;
|
||||
let h = tm.tm_hour as i64;
|
||||
let mi = tm.tm_min as i64;
|
||||
let s = tm.tm_sec as i64;
|
||||
(365*y + y/4 - y/100 + y/400 + 3*(m+1)/5 + 30*m + d - 719561)
|
||||
* 86400 + 3600 * h + 60 * mi + s
|
||||
}
|
||||
|
||||
pub fn time_to_utc_tm(sec: i64, tm: &mut Tm) {
|
||||
time_to_tm(sec, tm);
|
||||
}
|
||||
|
||||
pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
|
||||
// FIXME: Add timezone logic
|
||||
time_to_tm(sec, tm);
|
||||
}
|
||||
|
||||
pub fn utc_tm_to_time(tm: &Tm) -> i64 {
|
||||
tm_to_time(tm)
|
||||
}
|
||||
|
||||
pub fn local_tm_to_time(tm: &Tm) -> i64 {
|
||||
// FIXME: Add timezone logic
|
||||
tm_to_time(tm)
|
||||
}
|
||||
|
||||
pub fn get_time() -> (i64, i32) {
|
||||
let mut tv = syscall::TimeSpec { tv_sec: 0, tv_nsec: 0 };
|
||||
syscall::clock_gettime(syscall::CLOCK_REALTIME, &mut tv).unwrap();
|
||||
(tv.tv_sec as i64, tv.tv_nsec as i32)
|
||||
}
|
||||
|
||||
pub fn get_precise_ns() -> u64 {
|
||||
let mut ts = syscall::TimeSpec { tv_sec: 0, tv_nsec: 0 };
|
||||
syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut ts).unwrap();
|
||||
(ts.tv_sec as u64) * 1000000000 + (ts.tv_nsec as u64)
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
pub struct SteadyTime {
|
||||
t: syscall::TimeSpec,
|
||||
}
|
||||
|
||||
impl fmt::Debug for SteadyTime {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "SteadyTime {{ tv_sec: {:?}, tv_nsec: {:?} }}",
|
||||
self.t.tv_sec, self.t.tv_nsec)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for SteadyTime {
|
||||
fn clone(&self) -> SteadyTime {
|
||||
SteadyTime { t: self.t }
|
||||
}
|
||||
}
|
||||
|
||||
impl SteadyTime {
|
||||
pub fn now() -> SteadyTime {
|
||||
let mut t = SteadyTime {
|
||||
t: syscall::TimeSpec {
|
||||
tv_sec: 0,
|
||||
tv_nsec: 0,
|
||||
}
|
||||
};
|
||||
syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut t.t).unwrap();
|
||||
t
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub for SteadyTime {
|
||||
type Output = Duration;
|
||||
fn sub(self, other: SteadyTime) -> Duration {
|
||||
if self.t.tv_nsec >= other.t.tv_nsec {
|
||||
Duration::seconds(self.t.tv_sec as i64 - other.t.tv_sec as i64) +
|
||||
Duration::nanoseconds(self.t.tv_nsec as i64 - other.t.tv_nsec as i64)
|
||||
} else {
|
||||
Duration::seconds(self.t.tv_sec as i64 - 1 - other.t.tv_sec as i64) +
|
||||
Duration::nanoseconds(self.t.tv_nsec as i64 + ::NSEC_PER_SEC as i64 -
|
||||
other.t.tv_nsec as i64)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<Duration> for SteadyTime {
|
||||
type Output = SteadyTime;
|
||||
fn sub(self, other: Duration) -> SteadyTime {
|
||||
self + -other
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Duration> for SteadyTime {
|
||||
type Output = SteadyTime;
|
||||
fn add(mut self, other: Duration) -> SteadyTime {
|
||||
let seconds = other.num_seconds();
|
||||
let nanoseconds = other - Duration::seconds(seconds);
|
||||
let nanoseconds = nanoseconds.num_nanoseconds().unwrap();
|
||||
self.t.tv_sec += seconds;
|
||||
self.t.tv_nsec += nanoseconds as i32;
|
||||
if self.t.tv_nsec >= ::NSEC_PER_SEC {
|
||||
self.t.tv_nsec -= ::NSEC_PER_SEC;
|
||||
self.t.tv_sec += 1;
|
||||
} else if self.t.tv_nsec < 0 {
|
||||
self.t.tv_sec -= 1;
|
||||
self.t.tv_nsec += ::NSEC_PER_SEC;
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for SteadyTime {
|
||||
fn partial_cmp(&self, other: &SteadyTime) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for SteadyTime {
|
||||
fn cmp(&self, other: &SteadyTime) -> Ordering {
|
||||
match self.t.tv_sec.cmp(&other.t.tv_sec) {
|
||||
Ordering::Equal => self.t.tv_nsec.cmp(&other.t.tv_nsec),
|
||||
ord => ord
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for SteadyTime {
|
||||
fn eq(&self, other: &SteadyTime) -> bool {
|
||||
self.t.tv_sec == other.t.tv_sec &&
|
||||
self.t.tv_nsec == other.t.tv_nsec
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for SteadyTime {}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
mod inner {
|
||||
use libc::{self, time_t};
|
||||
|
@ -39,8 +234,6 @@ mod inner {
|
|||
rust_tm.tm_utcoff = utcoff;
|
||||
}
|
||||
|
||||
type time64_t = i64;
|
||||
|
||||
#[cfg(target_os = "nacl")]
|
||||
unsafe fn timegm(tm: *const libc::tm) -> time_t {
|
||||
use std::env::{set_var, var_os, remove_var};
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"b3df3312a2ceca2f539abc280027c109738c07583eb076f83e057b536a2036d6","build.rs":"c4ec61284fcbf2d836d9b42e86b013baf168c14058632b7c3d676139157e484b","examples/hello-world.rs":"0fc60afb6ba41930e0e74fc31b835faa771b06eb70314cdd9a07e05204b1b389","examples/input.rs":"18a254cbd92871c1c27edf420ff29eb02e0dd6eb744ecbb8dbebcd590780b96a","examples/xrecord.rs":"d2458011f4ee170db613d5effa483f51ac56bceab7f25c44eee4cb22c1863207","src/dpms.rs":"77cb9237a0262350bf6553e40d6cc9e97a599bca089a457ef87c57c9b9cf6194","src/glx.rs":"f41af4853dadc3fbf5154c8a8108505123118ddd8e8d9c6122ed1cd2ffda4262","src/internal.rs":"9e1f269e36e6a92325be4f5e67185d60c12e4a74b98c454759c0161325d0d1e4","src/keysym.rs":"4d65901072224729fe18fb5c815242e51e75a34c1dfc88e5ac1cea19e8a423a8","src/lib.rs":"49ad75828478d09a2f0aceb7effe61fecea9785285cd17d8622b924e88740c5a","src/link.rs":"5a6f63372091daf218d27d55e8ab5775ccf591e50c532c4c442acdf2b64136a9","src/xcursor.rs":"3dafa1d232321eb35e1c1a3e5cf0677ab9fd273a2b97799a4a6fc20dc546522e","src/xf86vmode.rs":"98f074fade0d0c6e063644f6a9f8720c12f9533c01722ff83ca77ed11b61b9ce","src/xfixes.rs":"cc2a1681415c3d2d32331dd610567376b6eaa5f42d58b8940a1ff1d765d9cc85","src/xft.rs":"1d5ff70c95b3c5d339903ea347e4436e226bfd2c2990fd5b476472c1a6aedba0","src/xinerama.rs":"13f9007d027e081169a22a3ad3fd9fd2a78bdcd831489a654e22e7a6a7e4bde5","src/xinput.rs":"84f79c8eb57a8feff5897d282479d4535e3ea17876871caee93879818157d674","src/xinput2.rs":"413ee38d11c340ab9dd12a9cb95f6746df8bb158f1201cb7e9b9ec6f0aeabd42","src/xlib.rs":"d332108571a727027205a0e300a9d87543c95be8e1ce1c6cb21b81f70a67bab6","src/xlib_xcb.rs":"71ee6274e261bb8f0b82ea260afffa9273531f0f87df9541152412b88aff468f","src/xmd.rs":"149c818c19e90a14c8f60016cd18a04d0de4fd702fc5df89e5283f6ee1ce4852","src/xmu.rs":"262df634c584dac47d0d898dd75b6b2de7c4256b9b494cf89123d8279dad3020","src/xrandr.rs":"78315519ceb035358f0f331770371528b540016f49a26c41ae22fb3c05a52e89","src/xrecord.rs":"8339eea0b42c2206444d98ac35e2ca9df82fb666dca9e942970155e324213e93","src/xrender.rs":"7883ea45cf2bde0f8dc7593b1011737f2b8ecb0745e1364c72adf7462751dabe","src/xss.rs":"313df0898df612afc8bdf7a5c475679a5dfa011a377b48f1bf7a5572dc414bc5","src/xt.rs":"fa2324391a91387f44eeee6742c50676329f08d941d002ff70d4eb99f36af7bc","src/xtest.rs":"dcd0eb130ffb3cf96165d1699d6b625649c28ed819036a85b5f175c2a3479918"},"package":"a4f82ca6895c7dcac581106c706586e4776eeab731c65dae39499d88a9c7432b"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"51a03803afe9ea2446fcd62bbf9ba678628b1dfdf1a56464dfd2ed8a8d017327","build.rs":"c4ec61284fcbf2d836d9b42e86b013baf168c14058632b7c3d676139157e484b","examples/hello-world.rs":"0fc60afb6ba41930e0e74fc31b835faa771b06eb70314cdd9a07e05204b1b389","examples/input.rs":"18a254cbd92871c1c27edf420ff29eb02e0dd6eb744ecbb8dbebcd590780b96a","examples/xrecord.rs":"d2458011f4ee170db613d5effa483f51ac56bceab7f25c44eee4cb22c1863207","src/dpms.rs":"77cb9237a0262350bf6553e40d6cc9e97a599bca089a457ef87c57c9b9cf6194","src/glx.rs":"f41af4853dadc3fbf5154c8a8108505123118ddd8e8d9c6122ed1cd2ffda4262","src/internal.rs":"9e1f269e36e6a92325be4f5e67185d60c12e4a74b98c454759c0161325d0d1e4","src/keysym.rs":"4d65901072224729fe18fb5c815242e51e75a34c1dfc88e5ac1cea19e8a423a8","src/lib.rs":"49ad75828478d09a2f0aceb7effe61fecea9785285cd17d8622b924e88740c5a","src/link.rs":"5a6f63372091daf218d27d55e8ab5775ccf591e50c532c4c442acdf2b64136a9","src/xcursor.rs":"3dafa1d232321eb35e1c1a3e5cf0677ab9fd273a2b97799a4a6fc20dc546522e","src/xf86vmode.rs":"98f074fade0d0c6e063644f6a9f8720c12f9533c01722ff83ca77ed11b61b9ce","src/xfixes.rs":"cc2a1681415c3d2d32331dd610567376b6eaa5f42d58b8940a1ff1d765d9cc85","src/xft.rs":"1d5ff70c95b3c5d339903ea347e4436e226bfd2c2990fd5b476472c1a6aedba0","src/xinerama.rs":"13f9007d027e081169a22a3ad3fd9fd2a78bdcd831489a654e22e7a6a7e4bde5","src/xinput.rs":"84f79c8eb57a8feff5897d282479d4535e3ea17876871caee93879818157d674","src/xinput2.rs":"413ee38d11c340ab9dd12a9cb95f6746df8bb158f1201cb7e9b9ec6f0aeabd42","src/xlib.rs":"d332108571a727027205a0e300a9d87543c95be8e1ce1c6cb21b81f70a67bab6","src/xlib_xcb.rs":"71ee6274e261bb8f0b82ea260afffa9273531f0f87df9541152412b88aff468f","src/xmd.rs":"149c818c19e90a14c8f60016cd18a04d0de4fd702fc5df89e5283f6ee1ce4852","src/xmu.rs":"262df634c584dac47d0d898dd75b6b2de7c4256b9b494cf89123d8279dad3020","src/xrandr.rs":"78315519ceb035358f0f331770371528b540016f49a26c41ae22fb3c05a52e89","src/xrecord.rs":"8339eea0b42c2206444d98ac35e2ca9df82fb666dca9e942970155e324213e93","src/xrender.rs":"7883ea45cf2bde0f8dc7593b1011737f2b8ecb0745e1364c72adf7462751dabe","src/xss.rs":"313df0898df612afc8bdf7a5c475679a5dfa011a377b48f1bf7a5572dc414bc5","src/xt.rs":"fa2324391a91387f44eeee6742c50676329f08d941d002ff70d4eb99f36af7bc","src/xtest.rs":"dcd0eb130ffb3cf96165d1699d6b625649c28ed819036a85b5f175c2a3479918"},"package":"124eb405bf0262a54e1a982d4ffe4cd1c24261bdb306e49996e2ce7d492284a8"}
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "x11"
|
||||
version = "2.12.0"
|
||||
version = "2.12.1"
|
||||
authors = ["Daggerbot <daggerbot@gmail.com>"]
|
||||
description = "X11 library bindings for Rust"
|
||||
license = "CC0-1.0"
|
||||
|
@ -36,7 +36,7 @@ metadeps = "1.1"
|
|||
|
||||
[package.metadata.pkg-config]
|
||||
gl = { version = "1", feature = "glx" }
|
||||
x11 = { version = "1.6", feature = "xlib" }
|
||||
x11 = { version = "1.4.99.1", feature = "xlib" }
|
||||
x11-xcb = { version = "1.6", feature = "xlib_xcb" }
|
||||
xcursor = { version = "1.1", feature = "xcursor" }
|
||||
xext = { version = "1.3", feature = "dpms" }
|
||||
|
|
|
@ -68,7 +68,7 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gleam 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -77,7 +77,7 @@ version = "0.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -85,38 +85,38 @@ name = "core-foundation-sys"
|
|||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dwrote"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_codegen 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -146,10 +146,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "freetype"
|
||||
version = "0.1.3"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -229,7 +229,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.19"
|
||||
version = "0.2.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -306,7 +306,7 @@ dependencies = [
|
|||
"serde 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11 2.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11 2.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -324,14 +324,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.3.10"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rust_url_capi"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nsstring 0.1.0",
|
||||
"url 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -351,7 +356,7 @@ name = "serde_codegen"
|
|||
version = "0.8.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_codegen_internals 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -372,7 +377,7 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -380,7 +385,7 @@ name = "syn"
|
|||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -398,7 +403,7 @@ name = "syntex_errors"
|
|||
version = "0.54.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex_pos 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -420,7 +425,7 @@ version = "0.54.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex_errors 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -445,11 +450,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.35"
|
||||
version = "0.1.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -508,19 +514,19 @@ dependencies = [
|
|||
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"offscreen_gl_context 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_traits 0.11.0",
|
||||
]
|
||||
|
||||
|
@ -545,8 +551,8 @@ version = "0.11.0"
|
|||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -567,10 +573,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "x11"
|
||||
version = "2.12.0"
|
||||
version = "2.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"metadeps 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -594,13 +600,13 @@ dependencies = [
|
|||
"checksum cgl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8bdd78cca65a739cb5475dbf6b6bbb49373e327f4a6f2b499c0f98632df38c10"
|
||||
"checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67"
|
||||
"checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d"
|
||||
"checksum core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "66e998abb8823fecd2a8a7205429b17a340d447d8c69b3bce86846dcdea3e33b"
|
||||
"checksum core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2debbf22a8358e5e270e958b6d65694667be7a2ef9c3a2bf05a0872a3124dc98"
|
||||
"checksum dwrote 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "22f91bd605c96566d22699af63ad29a7417bd8a9493570450634858e80c27ff3"
|
||||
"checksum core-graphics 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd94d0f0b2bbcbfeeb670fc48654afde7a13c2c551ca9d2b9a6cfafdafe1a64"
|
||||
"checksum core-text 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "642fa40165b6c53bbd3f636951ffc3e1a3fd3c47e7d00598523c3e8c9321ed0c"
|
||||
"checksum dwrote 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "570707c940fc7b7fc627011fe2c8abedaea562b03bde715e3ee2dd3d6857a03c"
|
||||
"checksum error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "318cb3c71ee4cdea69fdc9e15c173b245ed6063e1709029e8fd32525a881120f"
|
||||
"checksum euclid 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0c274f13773ec277a48408d0c7a8dc935ad4bfe190f4cfccd0126d203afc3c83"
|
||||
"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344"
|
||||
"checksum freetype 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "812b23abc34a2cd1e1a0635a8d65e9bc83f2dd6e7879b92683ed0b9faaa629e5"
|
||||
"checksum freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fde23272c687e4570aefec06cb71174ec0f5284b725deac4e77ba2665d635faf"
|
||||
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
|
||||
"checksum gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1d8edc81c5ae84605a62f5dac661a2313003b26d59839f81d47d46cf0f16a55"
|
||||
"checksum gleam 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)" = "6af023107aa969ccf8868a0304fead4b2f813c19aa9a6a243fddc041f3e51da5"
|
||||
|
@ -609,7 +615,7 @@ dependencies = [
|
|||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09c9d3760673c427d46f91a0350f0a84a52e6bc5a84adf26dc610b6c52436630"
|
||||
"checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b"
|
||||
"checksum libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "9e030dc72013ed68994d1b2cbf36a94dd0e58418ba949c4b0db7eeb70a7a6352"
|
||||
"checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5"
|
||||
"checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054"
|
||||
"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1"
|
||||
"checksum metadeps 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829fffe7ea1d747e23f64be972991bc516b2f1ac2ae4a3b33d8bea150c410151"
|
||||
|
@ -617,7 +623,8 @@ dependencies = [
|
|||
"checksum offscreen_gl_context 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2fe2fe54ba2b6ea8f43a17b16c13168c5bbf008e0fc91b34122a11f637e2728a"
|
||||
"checksum osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b"
|
||||
"checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa"
|
||||
"checksum quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6732e32663c9c271bfc7c1823486b471f18c47a2dbf87c066897b7b51afc83be"
|
||||
"checksum quote 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "48f961356de2df29263e751df9e2e2493bd765e57fce250cc8b8dcef53ed33c0"
|
||||
"checksum redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd35cc9a8bdec562c757e3d43c1526b5c6d2653e23e2315065bc25556550753"
|
||||
"checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b"
|
||||
"checksum serde 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)" = "f1e4aab5b62fb90ac9c99d5a55caa7c37e06a15d1b189ccc2b117782655fd11f"
|
||||
"checksum serde_codegen 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)" = "200c97dd86298518356c694869a7a51af1de398bd6c6dcce89fa21a512fdea44"
|
||||
|
@ -630,7 +637,7 @@ dependencies = [
|
|||
"checksum syntex_syntax 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc960085bae44591e22d01f6c0e82a8aec832f8659aca556cdf8ecbdac2bb47b"
|
||||
"checksum term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3deff8a2b3b6607d6d7cc32ac25c0b33709453ca9cceac006caac51e963cf94a"
|
||||
"checksum threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "59f6d3eff89920113dac9db44dde461d71d01e88a5b57b258a0466c32b5d7fe1"
|
||||
"checksum time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7ec6d62a20df54e07ab3b78b9a3932972f4b7981de295563686849eb3989af"
|
||||
"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade"
|
||||
"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4"
|
||||
"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f"
|
||||
"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172"
|
||||
|
@ -640,5 +647,5 @@ dependencies = [
|
|||
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
"checksum x11 2.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4f82ca6895c7dcac581106c706586e4776eeab731c65dae39499d88a9c7432b"
|
||||
"checksum x11 2.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "124eb405bf0262a54e1a982d4ffe4cd1c24261bdb306e49996e2ce7d492284a8"
|
||||
"checksum xml-rs 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b15eed12692bd59d15e98ee7f8dc8408465b992d8ddb4d1672c24865132ec7"
|
||||
|
|
|
@ -66,7 +66,7 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gleam 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -75,7 +75,7 @@ version = "0.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -83,38 +83,38 @@ name = "core-foundation-sys"
|
|||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dwrote"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_codegen 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -144,10 +144,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "freetype"
|
||||
version = "0.1.3"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -227,7 +227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.19"
|
||||
version = "0.2.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -293,7 +293,7 @@ dependencies = [
|
|||
"serde 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11 2.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"x11 2.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -311,14 +311,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.3.10"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rust_url_capi"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nsstring 0.1.0",
|
||||
"url 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -338,7 +343,7 @@ name = "serde_codegen"
|
|||
version = "0.8.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_codegen_internals 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -359,7 +364,7 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -367,7 +372,7 @@ name = "syn"
|
|||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -385,7 +390,7 @@ name = "syntex_errors"
|
|||
version = "0.54.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex_pos 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -407,7 +412,7 @@ version = "0.54.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syntex_errors 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -432,11 +437,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.35"
|
||||
version = "0.1.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -495,19 +501,19 @@ dependencies = [
|
|||
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"offscreen_gl_context 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webrender_traits 0.11.0",
|
||||
]
|
||||
|
||||
|
@ -532,8 +538,8 @@ version = "0.11.0"
|
|||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gleam 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -554,10 +560,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "x11"
|
||||
version = "2.12.0"
|
||||
version = "2.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"metadeps 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -581,13 +587,13 @@ dependencies = [
|
|||
"checksum cgl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8bdd78cca65a739cb5475dbf6b6bbb49373e327f4a6f2b499c0f98632df38c10"
|
||||
"checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67"
|
||||
"checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d"
|
||||
"checksum core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "66e998abb8823fecd2a8a7205429b17a340d447d8c69b3bce86846dcdea3e33b"
|
||||
"checksum core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2debbf22a8358e5e270e958b6d65694667be7a2ef9c3a2bf05a0872a3124dc98"
|
||||
"checksum dwrote 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "22f91bd605c96566d22699af63ad29a7417bd8a9493570450634858e80c27ff3"
|
||||
"checksum core-graphics 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd94d0f0b2bbcbfeeb670fc48654afde7a13c2c551ca9d2b9a6cfafdafe1a64"
|
||||
"checksum core-text 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "642fa40165b6c53bbd3f636951ffc3e1a3fd3c47e7d00598523c3e8c9321ed0c"
|
||||
"checksum dwrote 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "570707c940fc7b7fc627011fe2c8abedaea562b03bde715e3ee2dd3d6857a03c"
|
||||
"checksum error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "318cb3c71ee4cdea69fdc9e15c173b245ed6063e1709029e8fd32525a881120f"
|
||||
"checksum euclid 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0c274f13773ec277a48408d0c7a8dc935ad4bfe190f4cfccd0126d203afc3c83"
|
||||
"checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344"
|
||||
"checksum freetype 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "812b23abc34a2cd1e1a0635a8d65e9bc83f2dd6e7879b92683ed0b9faaa629e5"
|
||||
"checksum freetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fde23272c687e4570aefec06cb71174ec0f5284b725deac4e77ba2665d635faf"
|
||||
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
|
||||
"checksum gl_generator 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1d8edc81c5ae84605a62f5dac661a2313003b26d59839f81d47d46cf0f16a55"
|
||||
"checksum gleam 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)" = "6af023107aa969ccf8868a0304fead4b2f813c19aa9a6a243fddc041f3e51da5"
|
||||
|
@ -596,7 +602,7 @@ dependencies = [
|
|||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09c9d3760673c427d46f91a0350f0a84a52e6bc5a84adf26dc610b6c52436630"
|
||||
"checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b"
|
||||
"checksum libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "9e030dc72013ed68994d1b2cbf36a94dd0e58418ba949c4b0db7eeb70a7a6352"
|
||||
"checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5"
|
||||
"checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054"
|
||||
"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1"
|
||||
"checksum metadeps 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829fffe7ea1d747e23f64be972991bc516b2f1ac2ae4a3b33d8bea150c410151"
|
||||
|
@ -604,7 +610,8 @@ dependencies = [
|
|||
"checksum offscreen_gl_context 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2fe2fe54ba2b6ea8f43a17b16c13168c5bbf008e0fc91b34122a11f637e2728a"
|
||||
"checksum osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b"
|
||||
"checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa"
|
||||
"checksum quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6732e32663c9c271bfc7c1823486b471f18c47a2dbf87c066897b7b51afc83be"
|
||||
"checksum quote 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "48f961356de2df29263e751df9e2e2493bd765e57fce250cc8b8dcef53ed33c0"
|
||||
"checksum redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd35cc9a8bdec562c757e3d43c1526b5c6d2653e23e2315065bc25556550753"
|
||||
"checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b"
|
||||
"checksum serde 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)" = "f1e4aab5b62fb90ac9c99d5a55caa7c37e06a15d1b189ccc2b117782655fd11f"
|
||||
"checksum serde_codegen 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)" = "200c97dd86298518356c694869a7a51af1de398bd6c6dcce89fa21a512fdea44"
|
||||
|
@ -617,7 +624,7 @@ dependencies = [
|
|||
"checksum syntex_syntax 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc960085bae44591e22d01f6c0e82a8aec832f8659aca556cdf8ecbdac2bb47b"
|
||||
"checksum term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3deff8a2b3b6607d6d7cc32ac25c0b33709453ca9cceac006caac51e963cf94a"
|
||||
"checksum threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "59f6d3eff89920113dac9db44dde461d71d01e88a5b57b258a0466c32b5d7fe1"
|
||||
"checksum time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7ec6d62a20df54e07ab3b78b9a3932972f4b7981de295563686849eb3989af"
|
||||
"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade"
|
||||
"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4"
|
||||
"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f"
|
||||
"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172"
|
||||
|
@ -627,5 +634,5 @@ dependencies = [
|
|||
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
"checksum x11 2.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4f82ca6895c7dcac581106c706586e4776eeab731c65dae39499d88a9c7432b"
|
||||
"checksum x11 2.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "124eb405bf0262a54e1a982d4ffe4cd1c24261bdb306e49996e2ce7d492284a8"
|
||||
"checksum xml-rs 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b15eed12692bd59d15e98ee7f8dc8408465b992d8ddb4d1672c24865132ec7"
|
||||
|
|
Загрузка…
Ссылка в новой задаче