diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2008-04-05 08:56:43 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2008-04-05 08:56:43 +0000 |
| commit | 8f560bc2b5a612857f95f2c1352d69f3069030bf (patch) | |
| tree | a0b6dec3302fb8c6e1ad6b28a9cb955a2a015c9d /apps/plugins/lib | |
| parent | 36f8fba2090491913cb9c565bf3770873678eb8a (diff) | |
| download | rockbox-8f560bc2b5a612857f95f2c1352d69f3069030bf.zip rockbox-8f560bc2b5a612857f95f2c1352d69f3069030bf.tar.gz rockbox-8f560bc2b5a612857f95f2c1352d69f3069030bf.tar.bz2 rockbox-8f560bc2b5a612857f95f2c1352d69f3069030bf.tar.xz | |
Greyscale library: Always use reconstructing inversion, because it's legal to use unbuffered drawing functions in buffered mode, meaning that the chunky buffer might not be in sync with what's displayed. Mpegplayer does this.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16975 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
| -rw-r--r-- | apps/plugins/lib/grey_core.c | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index 1326599..143d09a 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c @@ -253,41 +253,33 @@ static void invert_gvalues(void) unsigned x = 0; unsigned last_x; - if (_grey_info.flags & GREY_BUFFERED) - { - fill_gvalues(); - grey_update(); - } - else /* Unbuffered - need crude reconstruction */ + /* Step 1: Calculate a transposed table for undoing the old mapping */ + for (i = 0; i < 256; i++) { - /* Step 1: Calculate a transposed table for undoing the old mapping */ - for (i = 0; i < 256; i++) + last_x = x; + x = _grey_info.gvalue[i]; + if (x > last_x) { - last_x = x; - x = _grey_info.gvalue[i]; - if (x > last_x) - { - rev_tab[last_x++] = (last_i + i) / 2; - while (x > last_x) - rev_tab[last_x++] = i; - last_i = i; - } + rev_tab[last_x++] = (last_i + i) / 2; + while (x > last_x) + rev_tab[last_x++] = i; + last_i = i; } - rev_tab[last_x++] = (last_i + 255) / 2; - while (256 > last_x) - rev_tab[last_x++] = 255; + } + rev_tab[last_x++] = (last_i + 255) / 2; + while (256 > last_x) + rev_tab[last_x++] = 255; - /* Step 2: Calculate new mapping */ - fill_gvalues(); + /* Step 2: Calculate new mapping */ + fill_gvalues(); - /* Step 3: Transpose all pixel values */ - val = _grey_info.values; - end = val + _GREY_MULUQ(_grey_info.width, _grey_info.height); + /* Step 3: Transpose all pixel values */ + val = _grey_info.values; + end = val + _GREY_MULUQ(_grey_info.width, _grey_info.height); - do - *val = _grey_info.gvalue[rev_tab[*val]]; - while (++val < end); - } + do + *val = _grey_info.gvalue[rev_tab[*val]]; + while (++val < end); } #endif |