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

Tiled image support #897

Merged
merged 6 commits into from Feb 24, 2017

Expose image tiling in the API.

  • Loading branch information
nical committed Feb 23, 2017
commit 9096349c2a29578b65b47619ad3ecb925f967796
@@ -107,6 +107,7 @@ fn main() {
vector_img,
ImageDescriptor::new(100, 100, ImageFormat::RGBA8).with_opaque_flag(true),
ImageData::new_blob_image(Vec::new()),
None,
);

let pipeline_id = PipelineId(0, 0);
@@ -143,7 +144,8 @@ fn main() {
api.add_image(
mask_image,
ImageDescriptor::new(2, 2, ImageFormat::A8).with_opaque_flag(true),
ImageData::new(vec![0, 80, 180, 255])
ImageData::new(vec![0, 80, 180, 255]),
None,
);
let mask = webrender_traits::ImageMask {
image: mask_image,
@@ -126,11 +126,11 @@ impl RenderBackend {
};
tx.send(glyph_dimensions).unwrap();
}
ApiMsg::AddImage(id, descriptor, data) => {
ApiMsg::AddImage(id, descriptor, data, tiling) => {
if let ImageData::Raw(ref bytes) = data {
profile_counters.image_templates.inc(bytes.len());
}
self.resource_cache.add_image_template(id, descriptor, data);
self.resource_cache.add_image_template(id, descriptor, data, tiling);
}
ApiMsg::UpdateImage(id, descriptor, bytes) => {
self.resource_cache.update_image_template(id, descriptor, bytes);
@@ -262,7 +262,8 @@ impl ResourceCache {
pub fn add_image_template(&mut self,
image_key: ImageKey,
descriptor: ImageDescriptor,
data: ImageData) {
data: ImageData,
tiling: Option<u16>) {
if descriptor.width > self.max_texture_size() || descriptor.height > self.max_texture_size() {
// TODO: we need to support handle this case gracefully, cf. issue #620.
println!("Warning: texture size ({} {}) larger than the maximum size",
@@ -273,7 +274,7 @@ impl ResourceCache {
descriptor: descriptor,
data: data,
epoch: Epoch(0),
tiling: None,
tiling: tiling,
};

self.image_templates.insert(image_key, resource);
@@ -92,8 +92,9 @@ impl RenderApi {
pub fn add_image(&self,
key: ImageKey,
descriptor: ImageDescriptor,
data: ImageData) {
let msg = ApiMsg::AddImage(key, descriptor, data);
data: ImageData,
tiling: Option<u16>) {
let msg = ApiMsg::AddImage(key, descriptor, data, tiling);
self.api_sender.send(msg).unwrap();
}

@@ -31,7 +31,7 @@ pub enum ApiMsg {
/// Gets the glyph dimensions
GetGlyphDimensions(Vec<GlyphKey>, MsgSender<Vec<Option<GlyphDimensions>>>),
/// Adds an image from the resource cache.
AddImage(ImageKey, ImageDescriptor, ImageData),
AddImage(ImageKey, ImageDescriptor, ImageData, Option<u16>),
/// Updates the the resource cache with the new image data.
UpdateImage(ImageKey, ImageDescriptor, Vec<u8>),
/// Drops an image from the resource cache.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.