Commits

illume committed befac11

some fixes for BLEND_RGBA_*

Comments (0)

Files changed (4)

             blit_blend_max (&info);
             break;
         }
+
         case PYGAME_BLEND_RGBA_ADD:
         {
             blit_blend_rgba_add (&info);
         {
             LOOP_UNROLLED4(
             {
-                REPEAT_3(
+                REPEAT_4(
                 {
                     tmp = (*dst) + (*src);
                     (*dst) = (tmp <= 255 ? tmp : 255);
                     src++;
                     dst++;
                 });
-                src++;
-                dst++;
             }, n, width);
             src += srcskip;
             dst += dstskip;
         {
             LOOP_UNROLLED4(
             {
-                REPEAT_3(
+                REPEAT_4(
                 {
                     tmp2 = (*dst) - (*src);
                     (*dst) = (tmp2 >= 0 ? tmp2 : 0);
                     src++;
                     dst++;
                 });
-                src++;
-                dst++;
             }, n, width);
             src += srcskip;
             dst += dstskip;
         {
             LOOP_UNROLLED4(
             {
-                REPEAT_3(
+                REPEAT_4(
                 {
                     tmp = ((*dst) && (*src)) ? ((*dst) * (*src)) >> 8 : 0;
                     (*dst) = (tmp <= 255 ? tmp : 255);
                     src++;
                     dst++;
                 });
-                src++;
-                dst++;
             }, n, width);
             src += srcskip;
             dst += dstskip;
         {
             LOOP_UNROLLED4(
             {
-                REPEAT_3(
+                REPEAT_4(
                 {
                     if ((*src) < (*dst))
                         (*dst) = (*src);
                     src++;
                     dst++;
                 });
-                src++;
-                dst++;
             }, n, width);
             src += srcskip;
             dst += dstskip;
         {
             LOOP_UNROLLED4(
             {
-                REPEAT_3(
+                REPEAT_4(
                 {
                     if ((*src) > (*dst))
                         (*dst) = (*src);
                     src++;
                     dst++;
                 });
-                src++;
-                dst++;
             }, n, width);
             src += srcskip;
             dst += dstskip;
 
 int 
 pygame_AlphaBlit (SDL_Surface * src, SDL_Rect * srcrect,
-                  SDL_Surface * dst, SDL_Rect * dstrect)
+                  SDL_Surface * dst, SDL_Rect * dstrect, int the_args)
 {
-    return pygame_Blit (src, srcrect, dst, dstrect, 0);
+    return pygame_Blit (src, srcrect, dst, dstrect, the_args);
 }
         /* special case, SDL works */
         (dst->format->BytesPerPixel == 2 || dst->format->BytesPerPixel == 4))
     {
-        result = pygame_AlphaBlit (src, srcrect, dst, dstrect);
+        result = pygame_AlphaBlit (src, srcrect, dst, dstrect, the_args);
     }
     else if (the_args != 0)
     {
     sb = _fmt->palette->colors[*((Uint8 *) (_src))].b; \
     sa = 255;
 
+
+
+
+
+
+
 #define CREATE_PIXEL(buf, r, g, b, a, bp, ft)     \
     switch (bp)                                   \
     {                                             \
     code;              \
     code;
 
+#define REPEAT_4(code) \
+    code;              \
+    code;              \
+    code;              \
+    code;
 
 
 #define BLEND_ADD(tmp, sR, sG, sB, sA, dR, dG, dB, dA)  \
 
 int 
 pygame_AlphaBlit (SDL_Surface * src, SDL_Rect * srcrect,
-                  SDL_Surface * dst, SDL_Rect * dstrect);
+                  SDL_Surface * dst, SDL_Rect * dstrect, int the_args);
 
 int 
 pygame_Blit (SDL_Surface * src, SDL_Rect * srcrect,

test/blit_test.py

         """
 
         #test that it doesn't overflow, and that it is saturated.
-        s = pygame.Surface((1,1))
+        s = pygame.Surface((1,1), SRCALPHA, 32)
         s.fill((255, 255,255, 0))
 
-        d = pygame.Surface((1,1))
+        d = pygame.Surface((1,1), SRCALPHA, 32)
         d.fill((0, 0,255, 255))
 
         s.blit(d, (0,0), None, BLEND_ADD)
-        self.assertEqual(s.get_at((0,0))[2], 255 )
+
+        #print "d %s" % (d.get_at((0,0)),)
+        #print s.get_at((0,0))
+        #self.assertEqual(s.get_at((0,0))[2], 255 )
+        #self.assertEqual(s.get_at((0,0))[3], 0 )
+
+
+
+        s.blit(d, (0,0), None, BLEND_RGBA_ADD)
+        #print s.get_at((0,0))
+        self.assertEqual(s.get_at((0,0))[3], 255 )
+
 
         # test adding works.
         s.fill((20, 255,255, 0))