render: compute image width/height in single function call
This commit is contained in:
parent
db9c382002
commit
4ba8550da8
7 changed files with 18 additions and 18 deletions
|
|
@ -396,17 +396,18 @@ impl MetalConnector {
|
|||
buffer.dev_fb.copy_texture(&self.state, tex, 0, 0, true);
|
||||
}
|
||||
}
|
||||
let (width, height) = buffer.dev_fb.size();
|
||||
changes.change_object(plane.id, |c| {
|
||||
c.change(plane.fb_id, buffer.drm.id().0 as _);
|
||||
c.change(plane.crtc_id.id, crtc.id.0 as _);
|
||||
c.change(plane.crtc_x.id, self.cursor_x.get() as _);
|
||||
c.change(plane.crtc_y.id, self.cursor_y.get() as _);
|
||||
c.change(plane.crtc_w.id, buffer.render_tex.width() as _);
|
||||
c.change(plane.crtc_h.id, buffer.render_tex.height() as _);
|
||||
c.change(plane.crtc_w.id, width as _);
|
||||
c.change(plane.crtc_h.id, height as _);
|
||||
c.change(plane.src_x.id, 0);
|
||||
c.change(plane.src_y.id, 0);
|
||||
c.change(plane.src_w.id, (buffer.render_tex.width() as u64) << 16);
|
||||
c.change(plane.src_h.id, (buffer.render_tex.height() as u64) << 16);
|
||||
c.change(plane.src_w.id, (width as u64) << 16);
|
||||
c.change(plane.src_h.id, (height as u64) << 16);
|
||||
});
|
||||
} else {
|
||||
changes.change_object(plane.id, |c| {
|
||||
|
|
|
|||
|
|
@ -270,8 +270,7 @@ pub trait GfxImage {
|
|||
}
|
||||
|
||||
pub trait GfxTexture: Debug {
|
||||
fn width(&self) -> i32;
|
||||
fn height(&self) -> i32;
|
||||
fn size(&self) -> (i32, i32);
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,8 @@ impl Texture {
|
|||
}
|
||||
|
||||
impl GfxTexture for Texture {
|
||||
fn width(&self) -> i32 {
|
||||
self.width()
|
||||
}
|
||||
|
||||
fn height(&self) -> i32 {
|
||||
self.height()
|
||||
fn size(&self) -> (i32, i32) {
|
||||
(self.width(), self.height())
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
|
|
|
|||
|
|
@ -304,7 +304,10 @@ impl GuiElement for Label {
|
|||
)
|
||||
.ok();
|
||||
let (tex, width, height) = match tex {
|
||||
Some((t, _)) => (Some(t.clone()), t.texture.width(), t.texture.height()),
|
||||
Some((t, _)) => {
|
||||
let (width, height) = t.texture.size();
|
||||
(Some(t.clone()), width, height)
|
||||
}
|
||||
_ => (None, 0, 0),
|
||||
};
|
||||
self.tex.set(tex);
|
||||
|
|
|
|||
|
|
@ -197,8 +197,9 @@ impl Renderer<'_> {
|
|||
&Color::from_rgba_straight(20, 20, 20, 255),
|
||||
);
|
||||
if let Some(tex) = placeholder.textures.get(&self.base.scale) {
|
||||
let x = x + (pos.width() - tex.texture.width()) / 2;
|
||||
let y = y + (pos.height() - tex.texture.height()) / 2;
|
||||
let (tex_width, tex_height) = tex.texture.size();
|
||||
let x = x + (pos.width() - tex_width) / 2;
|
||||
let y = y + (pos.height() - tex_height) / 2;
|
||||
self.base.render_texture(
|
||||
&tex.texture,
|
||||
x,
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ impl RendererBase<'_> {
|
|||
let (twidth, theight) = if let Some(size) = tsize {
|
||||
size
|
||||
} else {
|
||||
let (mut w, mut h) = (texture.width(), texture.height());
|
||||
let (mut w, mut h) = texture.size();
|
||||
if tscale != self.scale {
|
||||
let tscale = tscale.to_f64();
|
||||
w = (w as f64 * self.scalef / tscale).round() as _;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ impl OutputNode {
|
|||
};
|
||||
ws.title_texture.set(Some(title.clone()));
|
||||
let mut x = pos + 1;
|
||||
let mut width = title.texture.width();
|
||||
let (mut width, _) = title.texture.size();
|
||||
if let Some(scale) = scale {
|
||||
width = (width as f64 / scale).round() as _;
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ impl OutputNode {
|
|||
break 'set_status;
|
||||
}
|
||||
};
|
||||
let mut width = title.texture.width();
|
||||
let (mut width, _) = title.texture.size();
|
||||
if let Some(scale) = scale {
|
||||
width = (width as f64 / scale).round() as _;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue