1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00

window: impl Texture2d for SrgbTexture2d

This commit is contained in:
Wez Furlong 2019-10-07 08:20:22 -07:00
parent 2a19850350
commit 999e651b17

View File

@ -1,5 +1,7 @@
use crate::color::Color;
use crate::{Operator, Point, Rect, Size};
#[cfg(feature = "opengl")]
use glium::texture::SrgbTexture2d;
use palette::LinSrgba;
use std::cell::RefCell;
@ -41,6 +43,42 @@ pub trait Texture2d {
}
}
#[cfg(feature = "opengl")]
impl Texture2d for SrgbTexture2d {
fn write(&self, rect: Rect, im: &dyn BitmapImage) {
let (im_width, im_height) = im.image_dimensions();
let source = glium::texture::RawImage2d {
data: std::borrow::Cow::Borrowed(im.pixels()),
width: im_width as u32,
height: im_height as u32,
format: glium::texture::ClientFormat::U8U8U8U8,
};
SrgbTexture2d::write(
self,
glium::Rect {
left: rect.min_x() as u32,
bottom: rect.min_y() as u32,
width: rect.size.width as u32,
height: rect.size.height as u32,
},
source,
)
}
fn read(&self, _rect: Rect, _im: &mut dyn BitmapImage) {
unimplemented!();
}
fn width(&self) -> usize {
SrgbTexture2d::width(self) as usize
}
fn height(&self) -> usize {
SrgbTexture2d::height(self) as usize
}
}
#[cfg(target_arch = "x86_64")]
mod avx {
use super::*;