summaryrefslogtreecommitdiff
path: root/viewport.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-08-07 11:47:31 +0000
committerrodri <rgl@antares-labs.eu>2024-08-07 11:47:31 +0000
commit03149e5536a831e2ea7a20175f04938343529c99 (patch)
tree9494afdaa6be39a528640b2bf43bb773c1b55cf3 /viewport.c
parent05ae0d42a944f6c7d940a5e58eb90b619dadbfdb (diff)
downloadlibgraphics-03149e5536a831e2ea7a20175f04938343529c99.tar.gz
libgraphics-03149e5536a831e2ea7a20175f04938343529c99.tar.bz2
libgraphics-03149e5536a831e2ea7a20175f04938343529c99.zip
offset fb during drawing based on viewport config. move OBJ-related procedures to its own unit.
Diffstat (limited to 'viewport.c')
-rw-r--r--viewport.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/viewport.c b/viewport.c
index b3be122..9e41e53 100644
--- a/viewport.c
+++ b/viewport.c
@@ -11,31 +11,33 @@
static void
viewport_draw(Viewport *v, Image *dst)
{
- Point scale;
+ Point off, scale;
+ off = Pt(v->p.x, v->p.y);
/* no downsampling support yet */
scale.x = max(min(v->bx.x, Dx(dst->r)/Dx(v->r)), 1);
scale.y = max(min(v->by.y, Dy(dst->r)/Dy(v->r)), 1);
if(scale.x > 1 || scale.y > 1)
- v->fbctl->upscaledraw(v->fbctl, dst, scale);
+ v->fbctl->upscaledraw(v->fbctl, dst, off, scale);
else
- v->fbctl->draw(v->fbctl, dst);
+ v->fbctl->draw(v->fbctl, dst, off);
}
static void
viewport_memdraw(Viewport *v, Memimage *dst)
{
- Point scale;
+ Point off, scale;
+ off = Pt(v->p.x, v->p.y);
/* no downsampling support yet */
scale.x = max(min(v->bx.x, Dx(dst->r)/Dx(v->r)), 1);
scale.y = max(min(v->by.y, Dy(dst->r)/Dy(v->r)), 1);
if(scale.x > 1 || scale.y > 1)
- v->fbctl->upscalememdraw(v->fbctl, dst, scale);
+ v->fbctl->upscalememdraw(v->fbctl, dst, off, scale);
else
- v->fbctl->memdraw(v->fbctl, dst);
+ v->fbctl->memdraw(v->fbctl, dst, off);
}
static void
@@ -59,6 +61,18 @@ viewport_getfb(Viewport *v)
return v->fbctl->getfb(v->fbctl);
}
+static int
+viewport_getwidth(Viewport *v)
+{
+ return Dx(v->r)*v->bx.x;
+}
+
+static int
+viewport_getheight(Viewport *v)
+{
+ return Dy(v->r)*v->by.y;
+}
+
Viewport *
mkviewport(Rectangle r)
{
@@ -75,6 +89,8 @@ mkviewport(Rectangle r)
v->setscale = viewport_setscale;
v->setscalefilter = viewport_setscalefilter;
v->getfb = viewport_getfb;
+ v->getwidth = viewport_getwidth;
+ v->getheight = viewport_getheight;
return v;
}