harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r606881 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl: shared/SurfaceDataStructure.cpp shared/blitter.cpp windows/GDIBlitter.cpp
Date Wed, 26 Dec 2007 11:17:28 GMT
Author: apetrenko
Date: Wed Dec 26 03:17:27 2007
New Revision: 606881

URL: http://svn.apache.org/viewvc?rev=606881&view=rev
Log:
Patch for HARMONY-5278 "[classlib][awt] Unexpected behavior of XOR Mode 
image drawing while draw Image with transparency"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/blitter.cpp
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp?rev=606881&r1=606880&r2=606881&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp
Wed Dec 26 03:17:27 2007
@@ -99,17 +99,17 @@
 
         case INT_ARGB:
             {
-                unsigned char *src, *s, *dst, *d, sa;
+                if(alphaPre){
+                    unsigned char *src, *s, *dst, *d, sa;
 
-                src_stride = srcSurf->scanline_stride_byte;
-                dst_stride = srcSurf->width << 2;
+                    src_stride = srcSurf->scanline_stride_byte;
+                    dst_stride = srcSurf->width << 2;
 
-                src_offset = y * src_stride + ((x + w) << 2) - 1;
-                dst_offset = y * dst_stride + ((x + w) << 2) - 1;
-                src = (unsigned char *)srcDataPtr + src_offset;
-                dst = (unsigned char *)bmpDataPtr + dst_offset;
+                    src_offset = y * src_stride + ((x + w) << 2) - 1;
+                    dst_offset = y * dst_stride + ((x + w) << 2) - 1;
+                    src = (unsigned char *)srcDataPtr + src_offset;
+                    dst = (unsigned char *)bmpDataPtr + dst_offset;
 
-                if(alphaPre){
                     for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
@@ -129,28 +129,23 @@
                             }
                         }
                     }
+
                     srcSurf->isAlphaPre = true;
                 }else{
-                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
-                        s = src;
-                        d = dst;
+                    unsigned int *src, *dst;
 
-                        for(int _x = w; _x > 0; _x--){
-                            sa = *s--;
-                            if(sa == 0){
-                                *d-- = 0;
-                                *d-- = 0;
-                                *d-- = 0;
-                                *d-- = 0;
-                                s -= 3;
-                            }else{
-                                *d-- = sa;
-                                *d-- = MUL(sa, *s--);
-                                *d-- = MUL(sa, *s--);
-                                *d-- = MUL(sa, *s--);
-                            }
-                        }
+                    src_stride = srcSurf->scanline_stride;
+                    dst_stride = srcSurf->width;
+
+                    src_offset = y * src_stride + x;
+                    dst_offset = y * dst_stride + x;
+                    src = (unsigned int *)srcDataPtr + src_offset;
+                    dst = (unsigned int *)bmpDataPtr + dst_offset;
+
+                    for(int _y = 0; _y < h; _y++, src += src_stride, dst += dst_stride){
+                        memcpy(dst, src, w * sizeof(int));
                     }
+
                     srcSurf->isAlphaPre = false;
                 }
             }
@@ -303,17 +298,10 @@
                             g = *s--;
                             b = *s--;
                             a = *s--;
-                            if(a == 0){
-                                *d-- = 0;
-                                *d-- = 0;
-                                *d-- = 0;
-                                *d-- = 0;
-                            }else{
-                                *d-- = a;
-                                *d-- = r;
-                                *d-- = g;
-                                *d-- = b;
-                            }
+                            *d-- = a;
+                            *d-- = r;
+                            *d-- = g;
+                            *d-- = b;
                         }
                     }
                     srcSurf->isAlphaPre = false;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/blitter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/blitter.cpp?rev=606881&r1=606880&r2=606881&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/blitter.cpp (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/blitter.cpp Wed
Dec 26 03:17:27 2007
@@ -819,10 +819,10 @@
       r = (unsigned char)((xorcolor >> 16) & 0xff);
       g = (unsigned char)((xorcolor >> 8) & 0xff);
       b = (unsigned char)(xorcolor & 0xff);
-
       for(int _sy = srcY, _dy = dstY, maxY = srcY + height; _sy < maxY; _sy++, _dy++){
           for(int _sx = srcX, _dx = dstX, maxX = srcX + width; _sx < maxX; _sx++, _dx++){
               getRGB(_sx, _sy, srcStruct, srcData, sr, sg, sb, sa, false);
+              if(sa < 128) continue;
               getRGB(_dx, _dy, dstStruct, dstData, dr, dg, db, da, false);
               dr ^= (r ^ sr);
               dg ^= (g ^ sg);

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp?rev=606881&r1=606880&r2=606881&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp
Wed Dec 26 03:17:27 2007
@@ -417,7 +417,7 @@
           regions = (int *)malloc(regCount * sizeof(int));
           env->GetIntArrayRegion(dirtyRegions, 1, regCount, regions);
       }
-      if(!initBitmap(srcSurf, env, srcData, true, regions, regCount)) return;
+      if(!initBitmap(srcSurf, env, srcData, false, regions, regCount)) return;
 
       BYTE r = (BYTE)((xorcolor >> 16) & 0xff);
       BYTE g = (BYTE)((xorcolor >> 8) & 0xff);
@@ -450,8 +450,38 @@
 
       HGDIOBJ oldBrush = SelectObject(dstSurf->gi->hdc, brush);
 
-      BitBlt(dstSurf->gi->hdc, dstX, dstY, width, height, srcSurf->srcDC,
-              srcX, srcY, 0x960169);
+      if(srcSurf->has_alpha){
+
+          int scanline_word = srcSurf->width / 16;
+          if(srcSurf->width % 16 != 0) scanline_word++;
+
+          BYTE *pm = (BYTE *)calloc(scanline_word * srcSurf->height * 2, 1);
+
+          int byteIdx = 0;
+          unsigned int *p = (unsigned int *)srcSurf->bmpData;
+          for(int y = 0; y < srcSurf->height; y++){
+              for(int x = 0, shift = 7; x < srcSurf->width; x++, shift--, p++){
+                  if(shift < 0 ){
+                      shift = 7;
+                      byteIdx++;
+                  } 
+                  unsigned int pixel = (*p >> 24) & 0xff;
+                  if(pixel > 127) pm[byteIdx] |= 1 << shift;
+              }
+              if(byteIdx % 2 != 0) byteIdx++;
+              else byteIdx += 2;
+          }      
+
+          HBITMAP mask = CreateBitmap(srcSurf->width, srcSurf->height, 1, 1, pm);
+          free(pm);
+          MaskBlt(dstSurf->gi->hdc, dstX, dstY, width, height, srcSurf->srcDC,
+                  srcX, srcY, mask, srcX, srcY, MAKEROP4(0x960169, 0xAA0029));
+          DeleteObject(mask);
+      }else{
+
+          BitBlt(dstSurf->gi->hdc, dstX, dstY, width, height, srcSurf->srcDC,
+                  srcX, srcY, 0x960169);
+      }
 
       SelectObject(dstSurf->gi->hdc, oldBrush);
 



Mime
View raw message