summaryrefslogtreecommitdiffstats
path: root/glow/src/image.rs
diff options
context:
space:
mode:
Diffstat (limited to 'glow/src/image.rs')
-rw-r--r--glow/src/image.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/glow/src/image.rs b/glow/src/image.rs
index f906cd4c..521a01e7 100644
--- a/glow/src/image.rs
+++ b/glow/src/image.rs
@@ -14,6 +14,7 @@ use iced_graphics::image::raster;
use iced_graphics::image::vector;
use iced_graphics::layer;
+use iced_graphics::Rectangle;
use iced_graphics::Size;
use glow::HasContext;
@@ -141,14 +142,17 @@ impl Pipeline {
pub fn draw(
&mut self,
mut gl: &glow::Context,
+ target_height: u32,
transformation: Transformation,
_scale_factor: f32,
images: &[layer::Image],
+ layer_bounds: Rectangle<u32>,
) {
unsafe {
gl.use_program(Some(self.program));
gl.bind_vertex_array(Some(self.vertex_array));
gl.bind_buffer(glow::ARRAY_BUFFER, Some(self.vertex_buffer));
+ gl.enable(glow::SCISSOR_TEST);
}
#[cfg(feature = "image")]
@@ -168,11 +172,16 @@ impl Pipeline {
layer::Image::Raster { handle: _, bounds } => (None, bounds),
#[cfg(feature = "svg")]
- layer::Image::Vector { handle, bounds } => {
+ layer::Image::Vector {
+ handle,
+ color,
+ bounds,
+ } => {
let size = [bounds.width, bounds.height];
(
vector_cache.upload(
handle,
+ *color,
size,
_scale_factor,
&mut gl,
@@ -183,10 +192,18 @@ impl Pipeline {
}
#[cfg(not(feature = "svg"))]
- layer::Image::Vector { handle: _, bounds } => (None, bounds),
+ layer::Image::Vector { bounds, .. } => (None, bounds),
};
unsafe {
+ gl.scissor(
+ layer_bounds.x as i32,
+ (target_height - (layer_bounds.y + layer_bounds.height))
+ as i32,
+ layer_bounds.width as i32,
+ layer_bounds.height as i32,
+ );
+
if let Some(storage::Entry { texture, .. }) = entry {
gl.bind_texture(glow::TEXTURE_2D, Some(*texture))
} else {
@@ -213,6 +230,7 @@ impl Pipeline {
gl.bind_buffer(glow::ARRAY_BUFFER, None);
gl.bind_vertex_array(None);
gl.use_program(None);
+ gl.disable(glow::SCISSOR_TEST);
}
}