Michael,

15bpp saturation shading:  mostly readability changes like adding shift
of 0.  (The compiler optimizes them out, I checked.)  An attempt to
change the spacing/indentation to be more like your style. And fix an
error that I made by leaving one too many bits set in green. (oops! :-)

16bpp saturation shading:  same as above w/o an error to correct.  Move
the int declarations back into the inner loop after verifying that the
compiler moves them out on its own.

32bpp unsaturated shading:  remove the unneeded type casting (unsigned
char).

24bpp unsaturated shading:  remove the unneeded temp variables r, g, and
b.  In reality all of the r, g, and b variables that are still needed
could be replaced with a single temp since I patched everything to
process the colors one at a time. (For efficiency in memory access two
should be used for 15/16bpp to avoid indexing into the array three
times; b is currently used for that as it is the last color processed.)

The second patch I actually recommend that you do not apply.  It does
greatly speed up the instruction but costs readability.  It is only
executed once per window to shade so the speedup may not be worth it but
I'll leave the decision up to you.  Basically checking that each color
modifier is less than 256 is the same as checking that no bits of 8
(starting from 0) or higher are set.  Or them all up, shift off the
irrelevant bits and see what's left.  You could also check to see if all
three color modifiers are equal to 256 and blow out early if you wanted
to.  if(!((rm^0x100)|(gm^0x100)|(bm^0x100)))

When I say that I checked how the compiler does something I mean that I
wrote small little programs and compiled them and then looked at the
assembly output.  It would be too tedious to look at the assembly output
of a large file like pixmap.c.

If you would like, I would be willing to maintain the shading routines.
I don't know cvs well enough to commit anything but you can bounce
anything that gets submitted off of me and I'll double check them; I
feel pretty comfortable in that code now.  I tried to adjust the
auto-magic stuff for sse2 but I don't know it well enough yet.  I
manually linked Eterm to use the sse routines on my machine and they
work here.  Please feel free to remove all my notes from the top of the
sse2_cmod.c file and any other crap you want to before merging it.  Let
me know if you want me to test the merged code.

Please double check the 15bpp C saturation shading routine just in case
I had another synapse misfire again. 

If you tell me where Eterm reads the background from e and sets its
initial geometry I'd also like to fix the problem of the pop-up
scrollbar taking up room when it is not active at startup.  (I sent you
pics of the problem awhile back.)

When it comes to the terminal side, I've always considered that a black
art so there isn't much I could do there even if I wanted to.  Actually
I think it works pretty damn great and doesn't need anything else.  If
there is any other graphics stuff or even assembly that you want help
with let me know -- other than that I'm going to start spending my free
time trying to code on E17 by adding SSE2 optimizations to evas.

Thanks for all your help and I hope I wasn't too much of a pain in the
ass.  I think I finished everything that I set out to do.

Regards,
-- 
Tres
Index: eterm/Eterm/src/pixmap.c
===================================================================
RCS file: /cvsroot/enlightenment/eterm/Eterm/src/pixmap.c,v
retrieving revision 1.112
diff -u -r1.112 pixmap.c
--- eterm/Eterm/src/pixmap.c	10 May 2005 18:59:50 -0000	1.112
+++ eterm/Eterm/src/pixmap.c	18 May 2005 06:03:40 -0000
@@ -1579,12 +1579,12 @@
                 int r, g, b;
 
                 b = ((DATA16 *) ptr)[x];
-                r = ( (b >> 10 )            * rm ) >> 8;
-                r = ( r > 0x001f ) ? 0xfc00 : ( r << 10 );
-                g = (((b >>  5 ) & 0x003f ) * gm ) >> 8;
-                g = ( g > 0x001f ) ? 0x03e0 : ( g << 5 );
-                b = (( b         & 0x001f ) * bm ) >> 8;
-                b = ( b > 0x001f ) ? 0x001f : b;
+                r = (((b >> 10) & 0x001f ) * rm) >> 8;
+                r = (r > 0x001f) ? 0x7c00 : (r << 10);
+                g = (((b >>  5) & 0x001f ) * gm) >> 8;
+                g = (g > 0x001f) ? 0x03e0 : (g << 5);
+                b = (((b >>  0) & 0x001f ) * bm) >> 8;
+                b = (b > 0x001f) ? 0x001f : (b << 0);
                 ((DATA16 *) ptr)[x] = (r|g|b);
             }
             ptr += bpl;
@@ -1618,15 +1618,16 @@
         }
     } else {
         for (y = h; --y >= 0;) {
-            int r, g, b;
             for (x = -w; x < 0; x++) {
+                int r, g, b;
+
                 b = ((DATA16 *) ptr)[x];
-                r = ( (b >> 11 )            * rm ) >> 8;
-		r = ( r > 0x001f ) ? 0xf800 : ( r << 11 );
-                g = (((b >>  5 ) & 0x003f ) * gm ) >> 8;
-		g = ( g > 0x003f ) ? 0x07e0 : ( g << 5 );
-                b = (( b         & 0x001f ) * bm ) >> 8;
-		b = ( b > 0x001f ) ? 0x001f : b;
+                r = (((b >> 11) & 0x001f) * rm) >> 8;
+		r = (r > 0x001f) ? 0xf800 : (r << 11);
+                g = (((b >>  5) & 0x003f) * gm) >> 8;
+		g = (g > 0x003f) ? 0x07e0 : (g << 5);
+                b = (((b >>  0) & 0x001f) * bm) >> 8;
+		b = (b > 0x001f) ? 0x001f : (b << 0);
                 ((DATA16 *) ptr)[x] = (r|g|b);
             }
             ptr += bpl;
@@ -1647,13 +1648,13 @@
         for (y = h; --y >= 0;) {
             for (x = -(w * 4); x < 0; x += 4) {
 # if WORDS_BIGENDIAN
-                ptr[x + 1] = (unsigned char) ((ptr[x + 1] * rm) >> 8);
-                ptr[x + 2] = (unsigned char) ((ptr[x + 2] * gm) >> 8);
-                ptr[x + 3] = (unsigned char) ((ptr[x + 3] * bm) >> 8);
+                ptr[x + 1] = ((ptr[x + 1] * rm) >> 8);
+                ptr[x + 2] = ((ptr[x + 2] * gm) >> 8);
+                ptr[x + 3] = ((ptr[x + 3] * bm) >> 8);
 # else
-                ptr[x + 2] = (unsigned char) ((ptr[x + 2] * rm) >> 8);
-                ptr[x + 1] = (unsigned char) ((ptr[x + 1] * gm) >> 8);
-                ptr[x + 0] = (unsigned char) ((ptr[x + 0] * bm) >> 8);
+                ptr[x + 2] = ((ptr[x + 2] * rm) >> 8);
+                ptr[x + 1] = ((ptr[x + 1] * gm) >> 8);
+                ptr[x + 0] = ((ptr[x + 0] * bm) >> 8);
 # endif
             }
             ptr += bpl;
@@ -1696,8 +1697,6 @@
         /* No saturation */
         for (y = h; --y >= 0;) {
             for (x = -(w * 3); x < 0; x += 3) {
-                int r, g, b;
-
 # if WORDS_BIGENDIAN
                 ptr[x + 0] = (ptr[x + 0] * rm) >> 8;
                 ptr[x + 1] = (ptr[x + 1] * gm) >> 8;
@@ -1714,6 +1713,7 @@
         for (y = h; --y >= 0;) {
             for (x = -(w * 3); x < 0; x += 3) {
                 int r, g, b;
+
 # if WORDS_BIGENDIAN
                 r = (ptr[x + 0] * rm) >> 8;
                 ptr[x + 0] = r|(!(r >> 8) - 1);
Index: eterm/Eterm/src/pixmap.c
===================================================================
RCS file: /cvsroot/enlightenment/eterm/Eterm/src/pixmap.c,v
retrieving revision 1.112
diff -u -r1.112 pixmap.c
--- eterm/Eterm/src/pixmap.c	10 May 2005 18:59:50 -0000	1.112
+++ eterm/Eterm/src/pixmap.c	18 May 2005 06:10:15 -0000
@@ -1557,7 +1557,7 @@
     int x, y;
 
     ptr = (unsigned char *) data + (w * sizeof(DATA16));
-    if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
+    if (!((rm|gm|bm) >> 8)) {
         /* No saturation */
         for (y = h; --y >= 0;) {
             for (x = -w; x < 0; x++) {
@@ -1600,7 +1600,7 @@
     int x, y;
 
     ptr = (unsigned char *) data + (w * sizeof(DATA16));
-    if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
+    if (!((rm|gm|bm) >> 8)) {
         /* No saturation */
         for (y = h; --y >= 0;) {
             for (x = -w; x < 0; x++) {
@@ -1642,18 +1643,18 @@
     int x, y;
 
     ptr = (unsigned char *) data + (w * 4);
-    if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
+    if (!((rm|gm|bm) >> 8)) {
         /* No saturation */
         for (y = h; --y >= 0;) {
             for (x = -(w * 4); x < 0; x += 4) {
@@ -1692,12 +1693,10 @@
     int x, y;
 
     ptr = (unsigned char *) data + (w * 3);
-    if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
+    if (!((rm|gm|bm) >> 8)) {
         /* No saturation */
         for (y = h; --y >= 0;) {
             for (x = -(w * 3); x < 0; x += 3) {

Reply via email to