summaryrefslogtreecommitdiff
path: root/viewport.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-07-14 21:49:43 +0000
committerrodri <rgl@antares-labs.eu>2024-07-14 21:49:43 +0000
commit5f10c82aad318fc9091c9bd612e89fda1a77009f (patch)
tree821cd9dfd0fcea21fdb720805666c77a63d2819c /viewport.c
parent78bf838d0c45fbe6e282450e127446de5888fa11 (diff)
downloadlibgraphics-5f10c82aad318fc9091c9bd612e89fda1a77009f.tar.gz
libgraphics-5f10c82aad318fc9091c9bd612e89fda1a77009f.tar.bz2
libgraphics-5f10c82aad318fc9091c9bd612e89fda1a77009f.zip
initial viewport upscaling support.
Diffstat (limited to 'viewport.c')
-rw-r--r--viewport.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/viewport.c b/viewport.c
index 0336353..d37a12c 100644
--- a/viewport.c
+++ b/viewport.c
@@ -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 *