1
0
Fork 0
forked from len0rd/rockbox

lcd-*: Merge common viewport operations into lcd-bitmap-common.c

Change-Id: Ibec2d039ac0ba1214c9bd1b667bc8a9538a0d3d7
This commit is contained in:
Thomas Martitz 2013-03-26 23:15:56 +01:00
parent 87c6df98a3
commit 47c8d3c14d
6 changed files with 48 additions and 224 deletions

View file

@ -141,6 +141,54 @@ void LCDFN(fill_viewport)(void)
LCDFN(fillrect)(0, 0, current_vp->width, current_vp->height);
}
/*** Viewports ***/
void LCDFN(set_viewport)(struct viewport* vp)
{
if (vp == NULL)
current_vp = &default_vp;
else
current_vp = vp;
#if LCDM(DEPTH) > 1
LCDFN(set_foreground)(current_vp->fg_pattern);
LCDFN(set_background)(current_vp->bg_pattern);
#endif
#if defined(SIMULATOR)
/* Force the viewport to be within bounds. If this happens it should
* be considered an error - the viewport will not draw as it might be
* expected.
*/
if((unsigned) current_vp->x > (unsigned) LCDM(WIDTH)
|| (unsigned) current_vp->y > (unsigned) LCDM(HEIGHT)
|| current_vp->x + current_vp->width > LCDM(WIDTH)
|| current_vp->y + current_vp->height > LCDM(HEIGHT))
{
#if !defined(HAVE_VIEWPORT_CLIP)
DEBUGF("ERROR: "
#else
DEBUGF("NOTE: "
#endif
"set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
current_vp->x, current_vp->y,
current_vp->width, current_vp->height);
}
#endif
}
void LCDFN(update_viewport)(void)
{
LCDFN(update_rect)(current_vp->x, current_vp->y,
current_vp->width, current_vp->height);
}
void LCDFN(update_viewport_rect)(int x, int y, int width, int height)
{
LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height);
}
/* put a string at a given pixel position, skipping first ofs pixel columns */
static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
{