diff options
author | rodri <rgl@antares-labs.eu> | 2024-07-14 21:49:43 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-07-14 21:49:43 +0000 |
commit | 5f10c82aad318fc9091c9bd612e89fda1a77009f (patch) | |
tree | 821cd9dfd0fcea21fdb720805666c77a63d2819c /viewport.c | |
parent | 78bf838d0c45fbe6e282450e127446de5888fa11 (diff) | |
download | libgraphics-5f10c82aad318fc9091c9bd612e89fda1a77009f.tar.gz libgraphics-5f10c82aad318fc9091c9bd612e89fda1a77009f.tar.bz2 libgraphics-5f10c82aad318fc9091c9bd612e89fda1a77009f.zip |
initial viewport upscaling support.
Diffstat (limited to 'viewport.c')
-rw-r--r-- | viewport.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -11,13 +11,35 @@ static void viewport_draw(Viewport *v, Image *dst) { - v->fbctl->draw(v->fbctl, dst); + Point scale; + + scale.x = Dx(dst->r)/Dx(v->r); + scale.y = Dy(dst->r)/Dy(v->r); + + /* no downsampling support yet */ + assert(scale.x > 0 && scale.y > 0); + + if(scale.x > 1 || scale.y > 1) + v->fbctl->upscaledraw(v->fbctl, dst, scale); + else + v->fbctl->draw(v->fbctl, dst); } static void viewport_memdraw(Viewport *v, Memimage *dst) { - v->fbctl->memdraw(v->fbctl, dst); + Point scale; + + scale.x = Dx(dst->r)/Dx(v->r); + scale.y = Dy(dst->r)/Dy(v->r); + + /* no downsampling support yet */ + assert(scale.x > 0 && scale.y > 0); + + if(scale.x > 1 || scale.y > 1) + v->fbctl->upscalememdraw(v->fbctl, dst, scale); + else + v->fbctl->memdraw(v->fbctl, dst); } static Framebuf * |