forked from len0rd/rockbox
Split grayscale library into several files to make up a real function library. Significantly decreases binary size for plugins using it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4802 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8877ad943e
commit
7c6bdd6493
30 changed files with 3109 additions and 2082 deletions
119
apps/plugins/lib/gray_drawline.c
Normal file
119
apps/plugins/lib/gray_drawline.c
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Grayscale framework
|
||||
* gray_drawline() function
|
||||
*
|
||||
* This is a generic framework to use grayscale display within Rockbox
|
||||
* plugins. It obviously does not work for the player.
|
||||
*
|
||||
* Copyright (C) 2004 Jens Arnold
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SIMULATOR /* not for simulator by now */
|
||||
#include "plugin.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
|
||||
#include "gray.h"
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Draw a line from (x1, y1) to (x2, y2) with the current drawinfo
|
||||
----------------------------------------------------------------------------
|
||||
See gray_drawpixel() for details
|
||||
*/
|
||||
void gray_drawline(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int numpixels;
|
||||
int i;
|
||||
int deltax, deltay;
|
||||
int d, dinc1, dinc2;
|
||||
int x, xinc1, xinc2;
|
||||
int y, yinc1, yinc2;
|
||||
unsigned long pattern;
|
||||
void (*pixelfunc)(int x, int y, unsigned long pattern);
|
||||
|
||||
if ((unsigned) x1 >= (unsigned) _graybuf->width
|
||||
|| (unsigned) y1 >= (unsigned) _graybuf->height
|
||||
|| (unsigned) x2 >= (unsigned) _graybuf->width
|
||||
|| (unsigned) y2 >= (unsigned) _graybuf->height)
|
||||
return;
|
||||
|
||||
deltax = abs(x2 - x1);
|
||||
deltay = abs(y2 - y1);
|
||||
xinc2 = 1;
|
||||
yinc2 = 1;
|
||||
|
||||
if (deltax >= deltay)
|
||||
{
|
||||
numpixels = deltax;
|
||||
d = 2 * deltay - deltax;
|
||||
dinc1 = deltay * 2;
|
||||
dinc2 = (deltay - deltax) * 2;
|
||||
xinc1 = 1;
|
||||
yinc1 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
numpixels = deltay;
|
||||
d = 2 * deltax - deltay;
|
||||
dinc1 = deltax * 2;
|
||||
dinc2 = (deltax - deltay) * 2;
|
||||
xinc1 = 0;
|
||||
yinc1 = 1;
|
||||
}
|
||||
numpixels++; /* include endpoints */
|
||||
|
||||
if (x1 > x2)
|
||||
{
|
||||
xinc1 = -xinc1;
|
||||
xinc2 = -xinc2;
|
||||
}
|
||||
|
||||
if (y1 > y2)
|
||||
{
|
||||
yinc1 = -yinc1;
|
||||
yinc2 = -yinc2;
|
||||
}
|
||||
|
||||
x = x1;
|
||||
y = y1;
|
||||
|
||||
pixelfunc = _gray_pixelfuncs[_graybuf->drawmode];
|
||||
pattern = (_graybuf->drawmode == GRAY_DRAW_BG) ?
|
||||
_graybuf->bg_pattern : _graybuf->fg_pattern;
|
||||
|
||||
for (i = 0; i < numpixels; i++)
|
||||
{
|
||||
pixelfunc(x, y, pattern);
|
||||
|
||||
if (d < 0)
|
||||
{
|
||||
d += dinc1;
|
||||
x += xinc1;
|
||||
y += yinc1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d += dinc2;
|
||||
x += xinc2;
|
||||
y += yinc2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #ifdef HAVE_LCD_BITMAP
|
||||
#endif // #ifndef SIMULATOR
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue