Fix winding rule to paint negative winding numbers
This commit is contained in:
parent
bc6efc9b62
commit
7cd7210304
|
@ -31,7 +31,7 @@ __kernel void accum(__write_only image2d_t gImage,
|
||||||
int2 coord = (int2)((int)column, (int)row);
|
int2 coord = (int2)((int)column, (int)row);
|
||||||
coverage += read_imagef(gCoverage, SAMPLER, coord).r;
|
coverage += read_imagef(gCoverage, SAMPLER, coord).r;
|
||||||
|
|
||||||
uint gray = convert_uint(clamp(coverage, 0.0f, 1.0f) * 255.0f);
|
uint gray = convert_uint(clamp(fabs(coverage), 0.0f, 1.0f) * 255.0f);
|
||||||
write_imageui(gImage, coord + (int2)kAtlasRect.xy, (uint4)(gray, 255, 255, 255));
|
write_imageui(gImage, coord + (int2)kAtlasRect.xy, (uint4)(gray, 255, 255, 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
19
src/atlas.rs
19
src/atlas.rs
|
@ -68,11 +68,16 @@ impl AtlasBuilder {
|
||||||
glyph_index: glyph_index,
|
glyph_index: glyph_index,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.image_metadata.push(ImageMetadata {
|
while self.image_metadata.len() < glyph_index as usize + 1 {
|
||||||
atlas_size: pixel_size,
|
self.image_metadata.push(ImageMetadata::default())
|
||||||
|
}
|
||||||
|
|
||||||
|
self.image_metadata[glyph_index as usize] = ImageMetadata {
|
||||||
|
atlas_width: pixel_size.width,
|
||||||
|
atlas_height: pixel_size.height,
|
||||||
glyph_index: glyph_index,
|
glyph_index: glyph_index,
|
||||||
glyph_id: glyph_id,
|
glyph_id: glyph_id,
|
||||||
});
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -141,7 +146,8 @@ impl AtlasBuilder {
|
||||||
pub fn atlas_rect(&self, glyph_index: u32) -> Rect<u32> {
|
pub fn atlas_rect(&self, glyph_index: u32) -> Rect<u32> {
|
||||||
let descriptor = &self.image_descriptors[glyph_index as usize];
|
let descriptor = &self.image_descriptors[glyph_index as usize];
|
||||||
let metadata = &self.image_metadata[glyph_index as usize];
|
let metadata = &self.image_metadata[glyph_index as usize];
|
||||||
Rect::new(Point2D::new(descriptor.atlas_x, descriptor.atlas_y), metadata.atlas_size)
|
Rect::new(Point2D::new(descriptor.atlas_x, descriptor.atlas_y),
|
||||||
|
Size2D::new(metadata.atlas_width, metadata.atlas_height))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +195,10 @@ pub struct ImageDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about each image that we keep around ourselves.
|
/// Information about each image that we keep around ourselves.
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Default, Debug)]
|
||||||
pub struct ImageMetadata {
|
pub struct ImageMetadata {
|
||||||
atlas_size: Size2D<u32>,
|
atlas_width: u32,
|
||||||
|
atlas_height: u32,
|
||||||
glyph_index: u32,
|
glyph_index: u32,
|
||||||
glyph_id: u16,
|
glyph_id: u16,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue