Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

separate generate_font_key from add_raw_font/add_native_font to allow… #912

Merged
merged 3 commits into from Feb 22, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

separate generate_image_key from add_image for custom image key gener…

…ation
  • Loading branch information
lsalzman committed Feb 22, 2017
commit 7c80175e11e6374d3d6d30cb991734d3f0f92939
@@ -102,7 +102,9 @@ fn main() {
let epoch = Epoch(0);
let root_background_color = ColorF::new(0.3, 0.0, 0.0, 1.0);

let vector_img = api.add_image(
let vector_img = api.generate_image_key();
api.add_image(
vector_img,
ImageDescriptor {
format: ImageFormat::RGBA8,
width: 100,
@@ -143,17 +145,20 @@ fn main() {
);

let sub_clip = {
let mask_image = api.generate_image_key();
api.add_image(
mask_image,
ImageDescriptor {
width: 2,
height: 2,
stride: None,
format: ImageFormat::A8,
is_opaque: true,
},
ImageData::new(vec![0, 80, 180, 255])
);
let mask = webrender_traits::ImageMask {
image: api.add_image(
ImageDescriptor {
width: 2,
height: 2,
stride: None,
format: ImageFormat::A8,
is_opaque: true,
},
ImageData::new(vec![0, 80, 180, 255])
),
image: mask_image,
rect: LayoutRect::new(LayoutPoint::new(75.0, 75.0), LayoutSize::new(100.0, 100.0)),
repeat: false,
};
@@ -83,19 +83,18 @@ impl RenderApi {
}

/// Creates an `ImageKey`.
pub fn alloc_image(&self) -> ImageKey {
pub fn generate_image_key(&self) -> ImageKey {
let new_id = self.next_unique_id();
ImageKey::new(new_id.0, new_id.1)
}

/// Adds an image and returns the corresponding `ImageKey`.
/// Adds an image identified by the `ImageKey`.
pub fn add_image(&self,
key: ImageKey,
descriptor: ImageDescriptor,
data: ImageData) -> ImageKey {
let key = self.alloc_image();
data: ImageData) {
let msg = ApiMsg::AddImage(key, descriptor, data);
self.api_sender.send(msg).unwrap();
key
}

/// Updates a specific image.
@@ -302,7 +302,9 @@ impl Wrench {
_ => panic!("We don't support whatever your crazy image type is, come on"),
};
let bytes = image.raw_pixels();
let image_key = self.api.add_image(
let image_key = self.api.generate_image_key();
self.api.add_image(
image_key,
ImageDescriptor {
width: image_dims.0,
height: image_dims.1,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.