mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Use NonZeroU32 in canvas_traits
This commit is contained in:
parent
ecf3b05153
commit
5e72173e8c
6 changed files with 16 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -326,6 +326,7 @@ dependencies = [
|
||||||
"heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ipc-channel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"nonzero 0.0.1",
|
||||||
"offscreen_gl_context 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"offscreen_gl_context 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"servo_config 0.0.1",
|
"servo_config 0.0.1",
|
||||||
|
|
|
@ -9,6 +9,9 @@ publish = false
|
||||||
name = "canvas_traits"
|
name = "canvas_traits"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
unstable = ["nonzero/unstable"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cssparser = "0.22.0"
|
cssparser = "0.22.0"
|
||||||
euclid = "0.15"
|
euclid = "0.15"
|
||||||
|
@ -16,6 +19,7 @@ heapsize = "0.4"
|
||||||
heapsize_derive = "0.1"
|
heapsize_derive = "0.1"
|
||||||
ipc-channel = "0.8"
|
ipc-channel = "0.8"
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
|
nonzero = {path = "../nonzero"}
|
||||||
offscreen_gl_context = { version = "0.11", features = ["serde"] }
|
offscreen_gl_context = { version = "0.11", features = ["serde"] }
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
servo_config = {path = "../config"}
|
servo_config = {path = "../config"}
|
||||||
|
|
|
@ -4,17 +4,18 @@
|
||||||
|
|
||||||
#![crate_name = "canvas_traits"]
|
#![crate_name = "canvas_traits"]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![feature(nonzero)]
|
|
||||||
|
#![cfg_attr(feature = "unstable", feature(nonzero))]
|
||||||
|
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
|
|
||||||
extern crate core;
|
|
||||||
extern crate cssparser;
|
extern crate cssparser;
|
||||||
extern crate euclid;
|
extern crate euclid;
|
||||||
extern crate heapsize;
|
extern crate heapsize;
|
||||||
#[macro_use] extern crate heapsize_derive;
|
#[macro_use] extern crate heapsize_derive;
|
||||||
extern crate ipc_channel;
|
extern crate ipc_channel;
|
||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
|
extern crate nonzero;
|
||||||
extern crate offscreen_gl_context;
|
extern crate offscreen_gl_context;
|
||||||
#[macro_use] extern crate serde;
|
#[macro_use] extern crate serde;
|
||||||
extern crate servo_config;
|
extern crate servo_config;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use core::nonzero::NonZero;
|
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
|
use nonzero::NonZeroU32;
|
||||||
use offscreen_gl_context::{GLContextAttributes, GLLimits};
|
use offscreen_gl_context::{GLContextAttributes, GLLimits};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use webrender_api;
|
use webrender_api;
|
||||||
|
@ -242,13 +242,13 @@ pub enum WebGLCommand {
|
||||||
macro_rules! define_resource_id_struct {
|
macro_rules! define_resource_id_struct {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
||||||
pub struct $name(NonZero<u32>);
|
pub struct $name(NonZeroU32);
|
||||||
|
|
||||||
impl $name {
|
impl $name {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn new(id: u32) -> Self {
|
pub unsafe fn new(id: u32) -> Self {
|
||||||
$name(NonZero::new_unchecked(id))
|
$name(NonZeroU32::new_unchecked(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -39,6 +39,10 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub unsafe fn new_unchecked(x: u32) -> Self {
|
||||||
|
NonZeroU32(x)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get(self) -> u32 {
|
pub fn get(self) -> u32 {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ unstable = [
|
||||||
"euclid/unstable",
|
"euclid/unstable",
|
||||||
"layout_thread/unstable",
|
"layout_thread/unstable",
|
||||||
"msg/unstable",
|
"msg/unstable",
|
||||||
|
"canvas_traits/unstable",
|
||||||
"compositing/unstable",
|
"compositing/unstable",
|
||||||
"constellation/unstable",
|
"constellation/unstable",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue