DXR3 better color management

Message ID 4267DA24.1050808@ventoso.org
State New

Commit Message

Luca Olivetti April 21, 2005, 4:51 p.m. UTC
  Husterer, Thomas RD-CP1 wrote:
> Hi,
> like Luca Olivetti a week ago, I fixed the bug in the colormanager which caused
> the color bleeding effekt.
> Unfortunately I could not compare my changes to them of Luca Olivetti because the diff-files are not stored in the mailing-archive and i was not subscribed to this mailinglist at that time.

Use the archive at gmane, that stores the attachments too.
Unfortunately (for the duplication of effort), that has been only a 
first step. I've done more radical modifications that have been commited 
to cvs last sunday (or saturday).

> My changes should not change too much the original performance.
> I fixed the behaviour of the color-index optimization by introduction of
> A maximal x-koordinate to which this color-index is valid.

Already done in cvs

> This ensures that no section regions are crossed.
> To improve performance I removed the final memcopy which copied a help-buffer into the destination buffer.

Already done in cvs
> After this fix I recognized that the last region was not closed and therefore the last color-index table was not sent to the spu. This resulted in a small
> bad colored rectangle in the lower right corner of the channels-menu.
> This is fixed by a closeRegion() at the end.

Already done in cvs

> A small change in osd.c ensures that the default color of an empty bitmap
> results in a well defined transparent color. Before that change i recognized to different colorindices for the transparent color.

Is that really needed?

> At least I changed the color-to-section-map-algorithm.
> The algorithm before had a problem with diagonal edged shapes like the charactar ´A´.
> This edges could lead to a consumption of many regions with very flat sections because the sectionlimits move to the left from each line to another.
> My changement uses in the first line of a Region only 3 colors for one section instead of 4. This leads to more sections in horizontal direction but it gives a chance to other colors in sequential lines.
> This leads to more quadratic sections because the width decreases and the height increases.

This is an interesting optimization, since I usually have many regions 
with 1 or 2 sections each. With your method it's a big improvement (if 
there are no more than 15 sections for region, in that case it fails, 
check, e.g. the solitaire plugin, not a big loss since it isn't playable 

> Does anybody know how these changes can be merged into the cvs-archive of the dxr3-plugin?
> (my original version is a nearly HEAD version of the cvs-archive)

You can check out the current version (the vdr-dxr3-0-2 branch) and send 
the diff against it to Ville (only the last optimization is needed, the 
rest is already there).
I've attached it here so you'll avoid to do the work ;-)
Anyway, if you didn't already do that, checkout the current version in 
cvs: I've changed color management so that you can have different colors 
at each Flush (useful if you want to use skinks with icons: with enigma 
I had to limit the colors for each icon to 3, but those can be different 
for each icon).

Now, if only you could find why Dirty gives bad results, only if used 
with the dxr3 plugin...... ;-)



Index: dxr3colormanager.c
RCS file: /cvsroot/dxr3plugin/dxr3/dxr3colormanager.c,v
retrieving revision
diff --unified -r1.1.2.9 dxr3colormanager.c
--- dxr3colormanager.c	19 Apr 2005 18:19:36 -0000
+++ dxr3colormanager.c	21 Apr 2005 16:49:31 -0000
@@ -68,13 +68,17 @@ 
 // ==================================
+    //printf("NrOfRegions %d ",NrOfRegions);
     for (int i = 0; i < NrOfRegions; i++)
 	if (hlr[i])
+	    //printf("%d ",hlr[i]->N);
+    //printf("\n");	
 // ==================================
@@ -231,7 +235,7 @@ 
     if (!curSection->HasColor(color, ColorIndex))
 	// this color is new for this section
-	if (curSection->AllColorsUsed())
+	if (curSection->AllColorsUsed(curRegion->Y1==y))
 	    // no more free colors
 	    if (y != curRegion->Y1)
Index: dxr3colormanager.h
RCS file: /cvsroot/dxr3plugin/dxr3/dxr3colormanager.h,v
retrieving revision
diff --unified -r1.1.2.8 dxr3colormanager.h
--- dxr3colormanager.h	19 Apr 2005 18:19:34 -0000
+++ dxr3colormanager.h	21 Apr 2005 16:49:31 -0000
@@ -54,12 +54,9 @@ 
     xSection(int x);
     bool HasColor(unsigned int color, unsigned char &ColorIndex);
     unsigned char AddColor(unsigned int color);
-    bool AllColorsUsed() {
+    bool AllColorsUsed(bool FirstLine) {
 	//DIAG("AllColorsUsed: %d\n",NrOfColors);
-	if(NrOfColors >= 4)
-	    return (true);
-	else
-	    return (false);
+	return(NrOfColors >= (FirstLine ? 3 : 4));
     int X1;
     int X2;