annotate src/surface_fill.c @ 3172:d1b367fc08bc tests-returncode

Use a return code of 1 when the tests fail.
author Thomas Kluyver <takowl@gmail.com>
date Wed, 09 Jan 2013 10:13:57 +0000
parents 55d7ab7a344f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
1 /*
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
2 pygame - Python Game Library
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
3 Copyright (C) 2007 Marcus von Appen
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
4
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
9
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
13 Library General Public License for more details.
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
14
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
18 */
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
19
2071
87541598228a remove distracting "'PyGAME_C_API' defined but not used" gcc warnings from Pygame build
Lenard Lindstrom <len-l@telus.net>
parents: 1505
diff changeset
20 #define NO_PYGAME_C_API
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
21 #include "surface.h"
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
22
3122
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
23 /*
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
24 * Changes SDL_Rect to respect any clipping rect defined on the surface.
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
25 * Necessary when modifying surface->pixels directly instead of through an
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
26 * SDL interface.
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
27 */
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
28 void surface_respect_clip_rect (SDL_Surface *surface, SDL_Rect *rect)
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
29 {
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
30 SDL_Rect tmp;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
31 SDL_Rect *A, *B;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
32 int x, y, w, h;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
33
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
34 A = rect;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
35 B = &tmp;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
36 SDL_GetClipRect(surface, B);
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
37
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
38 /* Code here is nearly identical to rect_clip in rect.c */
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
39
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
40 /* Left */
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
41 if ((A->x >= B->x) && (A->x < (B->x + B->w)))
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
42 x = A->x;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
43 else if ((B->x >= A->x) && (B->x < (A->x + A->w)))
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
44 x = B->x;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
45 else
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
46 return;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
47
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
48 /* Right */
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
49 if (((A->x + A->w) > B->x) && ((A->x + A->w) <= (B->x + B->w)))
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
50 w = (A->x + A->w) - x;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
51 else if (((B->x + B->w) > A->x) && ((B->x + B->w) <= (A->x + A->w)))
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
52 w = (B->x + B->w) - x;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
53 else
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
54 return;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
55
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
56 /* Top */
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
57 if ((A->y >= B->y) && (A->y < (B->y + B->h)))
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
58 y = A->y;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
59 else if ((B->y >= A->y) && (B->y < (A->y + A->h)))
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
60 y = B->y;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
61 else
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
62 return;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
63
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
64 /* Bottom */
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
65 if (((A->y + A->h) > B->y) && ((A->y + A->h) <= (B->y + B->h)))
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
66 h = (A->y + A->h) - y;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
67 else if (((B->y + B->h) > A->y) && ((B->y + B->h) <= (A->y + A->h)))
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
68 h = (B->y + B->h) - y;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
69 else
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
70 return;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
71
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
72 rect->x = x;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
73 rect->y = y;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
74 rect->w = w;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
75 rect->h = h;
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
76 }
1141
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
77
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
78 static int
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
79 surface_fill_blend_add (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
80 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
81 Uint8 *pixels;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
82 int width = rect->w;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
83 int height = rect->h;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
84 int skip;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
85 int bpp = surface->format->BytesPerPixel;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
86 int n;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
87 SDL_PixelFormat *fmt = surface->format;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
88 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
89 Uint32 pixel;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
90 Uint32 tmp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
91 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
92 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
93
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
94 pixels = (Uint8 *) surface->pixels + surface->offset +
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
95 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
96 skip = surface->pitch - width * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
97
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
98 switch (bpp)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
99 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
100 case 1:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
101 {
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
102 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
103 while (height--)
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
104 {
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
105 LOOP_UNROLLED4(
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
106 {
985
9799aebf78f9 Improved blit and fill macros for surface operations.
marcus
parents: 825
diff changeset
107 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
108 BLEND_ADD (tmp, cR, cG, cB, cA, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
109 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
110 pixels += bpp;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
111 }, n, width);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
112 pixels += skip;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
113 }
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
114 result = 0;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
115 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
116 }
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
117 case 3:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
118 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
119 size_t offsetR, offsetG, offsetB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
120 SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
121 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
122 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
123 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
124 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
125 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
126 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
127 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
128 BLEND_ADD (tmp, cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
129 pixels[offsetR] = sR;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
130 pixels[offsetG] = sG;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
131 pixels[offsetB] = sB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
132 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
133 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
134 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
135 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
136 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
137 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
138 }
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
139 default:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
140 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
141 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
142 /*
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
143 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
144 */
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
145 while (height--)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
146 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
147 LOOP_UNROLLED4(
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
148 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
149 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
150 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
151 BLEND_ADD (tmp, cR, cG, cB, cA, sR, sG, sB, sA);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
152 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
153 pixels += bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
154 }, n, width);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
155 pixels += skip;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
156 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
157 result = 0;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
158 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
159 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
160 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
161 return result;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
162 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
163
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
164 static int
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
165 surface_fill_blend_sub (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
166 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
167 Uint8 *pixels;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
168 int width = rect->w;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
169 int height = rect->h;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
170 int skip;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
171 int bpp = surface->format->BytesPerPixel;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
172 int n;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
173 SDL_PixelFormat *fmt = surface->format;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
174 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
175 Uint32 pixel;
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
176 Sint32 tmp2;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
177 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
178 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
179
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
180 pixels = (Uint8 *) surface->pixels + surface->offset +
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
181 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
182 skip = surface->pitch - width * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
183
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
184 switch (bpp)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
185 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
186 case 1:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
187 {
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
188 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
189 while (height--)
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
190 {
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
191 LOOP_UNROLLED4(
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
192 {
985
9799aebf78f9 Improved blit and fill macros for surface operations.
marcus
parents: 825
diff changeset
193 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
194 BLEND_SUB (tmp2, cR, cG, cB, cA, sR, sG, sB, sA);
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
195 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
196 pixels += bpp;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
197 }, n, width);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
198 pixels += skip;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
199 }
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
200 result = 0;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
201 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
202 }
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
203 case 3:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
204 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
205 size_t offsetR, offsetG, offsetB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
206 SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
207 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
208 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
209 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
210 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
211 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
212 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
213 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
214 BLEND_SUB (tmp2, cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
215 pixels[offsetR] = sR;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
216 pixels[offsetG] = sG;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
217 pixels[offsetB] = sB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
218 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
219 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
220 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
221 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
222 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
223 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
224 }
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
225 default:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
226 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
227 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
228 /*
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
229 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
230 */
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
231 while (height--)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
232 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
233 LOOP_UNROLLED4(
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
234 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
235 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
236 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
237 BLEND_SUB (tmp2, cR, cG, cB, cA, sR, sG, sB, sA);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
238 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
239 pixels += bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
240 }, n, width);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
241 pixels += skip;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
242 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
243 result = 0;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
244 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
245 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
246 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
247 return result;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
248 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
249
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
250 static int
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
251 surface_fill_blend_mult (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
252 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
253 Uint8 *pixels;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
254 int width = rect->w;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
255 int height = rect->h;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
256 int skip;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
257 int bpp = surface->format->BytesPerPixel;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
258 int n;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
259 SDL_PixelFormat *fmt = surface->format;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
260 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
261 Uint32 pixel;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
262 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
263 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
264
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
265 pixels = (Uint8 *) surface->pixels + surface->offset +
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
266 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
267 skip = surface->pitch - width * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
268
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
269 switch (bpp)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
270 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
271 case 1:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
272 {
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
273 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
274 while (height--)
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
275 {
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
276 LOOP_UNROLLED4(
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
277 {
985
9799aebf78f9 Improved blit and fill macros for surface operations.
marcus
parents: 825
diff changeset
278 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
279 BLEND_MULT (cR, cG, cB, cA, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
280 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
281 pixels += bpp;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
282 }, n, width);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
283 pixels += skip;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
284 }
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
285 result = 0;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
286 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
287 }
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
288 case 3:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
289 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
290 size_t offsetR, offsetG, offsetB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
291 SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
292 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
293 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
294 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
295 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
296 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
297 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
298 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
299 BLEND_MULT (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
300 pixels[offsetR] = sR;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
301 pixels[offsetG] = sG;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
302 pixels[offsetB] = sB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
303 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
304 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
305 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
306 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
307 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
308 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
309 }
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
310 default:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
311 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
312 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
313 /*
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
314 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
315 */
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
316 while (height--)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
317 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
318 LOOP_UNROLLED4(
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
319 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
320 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
321 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
322 BLEND_MULT (cR, cG, cB, cA, sR, sG, sB, sA);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
323 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
324 pixels += bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
325 }, n, width);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
326 pixels += skip;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
327 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
328 result = 0;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
329 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
330 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
331 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
332 return result;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
333 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
334
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
335 static int
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
336 surface_fill_blend_min (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
337 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
338 Uint8 *pixels;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
339 int width = rect->w;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
340 int height = rect->h;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
341 int skip;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
342 int bpp = surface->format->BytesPerPixel;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
343 int n;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
344 SDL_PixelFormat *fmt = surface->format;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
345 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
346 Uint32 pixel;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
347 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
348 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
349
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
350 pixels = (Uint8 *) surface->pixels + surface->offset +
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
351 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
352 skip = surface->pitch - width * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
353
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
354 switch (bpp)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
355 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
356 case 1:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
357 {
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
358 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
359 while (height--)
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
360 {
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
361 LOOP_UNROLLED4(
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
362 {
985
9799aebf78f9 Improved blit and fill macros for surface operations.
marcus
parents: 825
diff changeset
363 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
364 BLEND_MIN (cR, cG, cB, cA, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
365 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
366 pixels += bpp;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
367 }, n, width);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
368 pixels += skip;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
369 }
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
370 result = 0;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
371 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
372 }
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
373 case 3:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
374 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
375 size_t offsetR, offsetG, offsetB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
376 SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
377 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
378 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
379 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
380 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
381 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
382 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
383 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
384 BLEND_MIN (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
385 pixels[offsetR] = sR;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
386 pixels[offsetG] = sG;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
387 pixels[offsetB] = sB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
388 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
389 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
390 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
391 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
392 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
393 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
394 }
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
395 default:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
396 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
397 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
398 /*
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
399 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
400 */
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
401 while (height--)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
402 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
403 LOOP_UNROLLED4(
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
404 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
405 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
406 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
407 BLEND_MIN (cR, cG, cB, cA, sR, sG, sB, sA);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
408 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
409 pixels += bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
410 }, n, width);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
411 pixels += skip;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
412 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
413 result = 0;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
414 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
415 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
416 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
417 return result;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
418 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
419
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
420 static int
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
421 surface_fill_blend_max (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
422 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
423 Uint8 *pixels;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
424 int width = rect->w;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
425 int height = rect->h;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
426 int skip;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
427 int bpp = surface->format->BytesPerPixel;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
428 int n;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
429 SDL_PixelFormat *fmt = surface->format;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
430 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
431 Uint32 pixel;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
432 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
433 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
434
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
435 pixels = (Uint8 *) surface->pixels + surface->offset +
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
436 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
437 skip = surface->pitch - width * bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
438
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
439 switch (bpp)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
440 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
441 case 1:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
442 {
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
443 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
444 while (height--)
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
445 {
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
446 LOOP_UNROLLED4(
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
447 {
985
9799aebf78f9 Improved blit and fill macros for surface operations.
marcus
parents: 825
diff changeset
448 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
823
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
449 BLEND_MAX (cR, cG, cB, cA, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
450 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
451 pixels += bpp;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
452 }, n, width);
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
453 pixels += skip;
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
454 }
ac614a9f164d 1bpp fixes for blend fill from marcus
Rene Dudfield <renesd@gmail.com>
parents: 819
diff changeset
455 result = 0;
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
456 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
457 }
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
458 case 3:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
459 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
460 size_t offsetR, offsetG, offsetB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
461 SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
462 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
463 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
464 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
465 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
466 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
467 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
468 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
469 BLEND_MAX (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
470 pixels[offsetR] = sR;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
471 pixels[offsetG] = sG;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
472 pixels[offsetB] = sB;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
473 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
474 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
475 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
476 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
477 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
478 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
479 }
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
480 default:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
481 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
482 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
483 /*
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
484 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
825
bae45548347d commented out some printf's.
Rene Dudfield <renesd@gmail.com>
parents: 823
diff changeset
485 */
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
486 while (height--)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
487 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
488 LOOP_UNROLLED4(
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
489 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
490 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
491 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
492 BLEND_MAX (cR, cG, cB, cA, sR, sG, sB, sA);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
493 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
494 pixels += bpp;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
495 }, n, width);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
496 pixels += skip;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
497 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
498 result = 0;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
499 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
500 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
501 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
502 return result;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
503 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
504
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
505
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
506 /* ------------------------- */
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
507
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
508 static int
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
509 surface_fill_blend_rgba_add (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
510 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
511 Uint8 *pixels;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
512 int width = rect->w;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
513 int height = rect->h;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
514 int skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
515 int bpp = surface->format->BytesPerPixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
516 int n;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
517 SDL_PixelFormat *fmt = surface->format;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
518 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
519 Uint32 pixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
520 Uint32 tmp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
521 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
522 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
523
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
524 if (!ppa)
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
525 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
526 return surface_fill_blend_add (surface, rect, color);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
527 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
528
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
529 pixels = (Uint8 *) surface->pixels + surface->offset +
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
530 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
531 skip = surface->pitch - width * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
532
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
533 switch (bpp)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
534 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
535 case 1:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
536 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
537 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
538 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
539 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
540 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
541 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
542 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
543 BLEND_RGBA_ADD (tmp, cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
544 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
545 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
546 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
547 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
548 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
549 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
550 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
551 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
552 default:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
553 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
554 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
555 /*
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
556 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
557 */
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
558 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
559 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
560 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
561 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
562 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
563 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
564 BLEND_RGBA_ADD (tmp, cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
565 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
566 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
567 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
568 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
569 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
570 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
571 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
572 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
573 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
574 return result;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
575 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
576
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
577 static int
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
578 surface_fill_blend_rgba_sub (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
579 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
580 Uint8 *pixels;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
581 int width = rect->w;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
582 int height = rect->h;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
583 int skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
584 int bpp = surface->format->BytesPerPixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
585 int n;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
586 SDL_PixelFormat *fmt = surface->format;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
587 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
588 Uint32 pixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
589 Sint32 tmp2;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
590 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
591 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
592
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
593 if (!ppa)
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
594 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
595 return surface_fill_blend_sub (surface, rect, color);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
596 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
597
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
598 pixels = (Uint8 *) surface->pixels + surface->offset +
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
599 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
600 skip = surface->pitch - width * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
601
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
602 switch (bpp)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
603 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
604 case 1:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
605 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
606 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
607 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
608 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
609 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
610 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
611 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
612 BLEND_RGBA_SUB (tmp2, cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
613 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
614 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
615 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
616 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
617 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
618 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
619 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
620 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
621 default:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
622 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
623 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
624 /*
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
625 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
626 */
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
627 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
628 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
629 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
630 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
631 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
632 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
633 BLEND_RGBA_SUB (tmp2, cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
634 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
635 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
636 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
637 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
638 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
639 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
640 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
641 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
642 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
643 return result;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
644 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
645
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
646 static int
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
647 surface_fill_blend_rgba_mult (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
648 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
649 Uint8 *pixels;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
650 int width = rect->w;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
651 int height = rect->h;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
652 int skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
653 int bpp = surface->format->BytesPerPixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
654 int n;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
655 SDL_PixelFormat *fmt = surface->format;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
656 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
657 Uint32 pixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
658 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
659 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
660
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
661 if (!ppa)
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
662 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
663 return surface_fill_blend_mult (surface, rect, color);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
664 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
665
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
666 pixels = (Uint8 *) surface->pixels + surface->offset +
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
667 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
668 skip = surface->pitch - width * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
669
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
670 switch (bpp)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
671 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
672 case 1:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
673 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
674 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
675 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
676 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
677 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
678 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
679 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
680 BLEND_RGBA_MULT (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
681 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
682 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
683 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
684 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
685 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
686 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
687 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
688 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
689 default:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
690 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
691 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
692 /*
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
693 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
694 */
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
695 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
696 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
697 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
698 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
699 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
700 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
701 BLEND_RGBA_MULT (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
702 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
703 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
704 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
705 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
706 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
707 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
708 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
709 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
710 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
711 return result;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
712 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
713
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
714 static int
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
715 surface_fill_blend_rgba_min (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
716 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
717 Uint8 *pixels;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
718 int width = rect->w;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
719 int height = rect->h;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
720 int skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
721 int bpp = surface->format->BytesPerPixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
722 int n;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
723 SDL_PixelFormat *fmt = surface->format;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
724 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
725 Uint32 pixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
726 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
727 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
728
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
729 if (!ppa)
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
730 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
731 return surface_fill_blend_min (surface, rect, color);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
732 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
733
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
734 pixels = (Uint8 *) surface->pixels + surface->offset +
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
735 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
736 skip = surface->pitch - width * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
737
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
738 switch (bpp)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
739 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
740 case 1:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
741 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
742 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
743 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
744 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
745 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
746 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
747 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
748 BLEND_RGBA_MIN (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
749 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
750 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
751 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
752 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
753 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
754 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
755 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
756 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
757 default:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
758 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
759 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
760 /*
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
761 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
762 */
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
763 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
764 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
765 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
766 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
767 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
768 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
769 BLEND_RGBA_MIN (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
770 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
771 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
772 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
773 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
774 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
775 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
776 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
777 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
778 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
779 return result;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
780 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
781
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
782 static int
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
783 surface_fill_blend_rgba_max (SDL_Surface *surface, SDL_Rect *rect, Uint32 color)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
784 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
785 Uint8 *pixels;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
786 int width = rect->w;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
787 int height = rect->h;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
788 int skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
789 int bpp = surface->format->BytesPerPixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
790 int n;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
791 SDL_PixelFormat *fmt = surface->format;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
792 Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
793 Uint32 pixel;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
794 int result = -1;
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
795 int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
796
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
797 if (!ppa)
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
798 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
799 return surface_fill_blend_max (surface, rect, color);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
800 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
801
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
802 pixels = (Uint8 *) surface->pixels + surface->offset +
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
803 (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
804 skip = surface->pitch - width * bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
805
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
806 switch (bpp)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
807 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
808 case 1:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
809 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
810 SDL_GetRGBA (color, fmt, &cR, &cG, &cB, &cA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
811 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
812 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
813 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
814 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
815 GET_PIXELVALS_1 (sR, sG, sB, sA, pixels, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
816 BLEND_RGBA_MAX (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
817 *pixels = SDL_MapRGBA (fmt, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
818 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
819 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
820 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
821 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
822 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
823 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
824 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
825 default:
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
826 {
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
827 GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
828 /*
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
829 printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
830 */
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
831 while (height--)
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
832 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
833 LOOP_UNROLLED4(
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
834 {
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
835 GET_PIXEL (pixel, bpp, pixels);
1505
902b98865c6c fix per-pixel alpha bug involving pixel unpacking
Lenard Lindstrom <len-l@telus.net>
parents: 1504
diff changeset
836 GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
1504
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
837 BLEND_RGBA_MAX (cR, cG, cB, cA, sR, sG, sB, sA);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
838 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
839 pixels += bpp;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
840 }, n, width);
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
841 pixels += skip;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
842 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
843 result = 0;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
844 break;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
845 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
846 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
847 return result;
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
848 }
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
849
1826c7247b4a BLEND_RGBA_xxx and more BLEND_xxx tests; related bug fixes
Lenard Lindstrom <len-l@telus.net>
parents: 1376
diff changeset
850
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
851 int
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
852 surface_fill_blend (SDL_Surface *surface, SDL_Rect *rect, Uint32 color,
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
853 int blendargs)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
854 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
855 int result = -1;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
856 int locked = 0;
3122
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
857
55d7ab7a344f Surface.fill() respects clipping rect or surface bounds with special flags.
Rene Dudfield <renesd@gmail.com>
parents: 2071
diff changeset
858 surface_respect_clip_rect(surface, rect);
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
859
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
860 /* Lock the surface, if needed */
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
861 if (SDL_MUSTLOCK (surface))
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
862 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
863 if (SDL_LockSurface (surface) < 0)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
864 return -1;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
865 locked = 1;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
866 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
867
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
868 switch (blendargs)
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
869 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
870 case PYGAME_BLEND_ADD:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
871 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
872 result = surface_fill_blend_add (surface, rect, color);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
873 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
874 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
875 case PYGAME_BLEND_SUB:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
876 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
877 result = surface_fill_blend_sub (surface, rect, color);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
878 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
879 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
880 case PYGAME_BLEND_MULT:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
881 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
882 result = surface_fill_blend_mult (surface, rect, color);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
883 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
884 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
885 case PYGAME_BLEND_MIN:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
886 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
887 result = surface_fill_blend_min (surface, rect, color);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
888 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
889 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
890 case PYGAME_BLEND_MAX:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
891 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
892 result = surface_fill_blend_max (surface, rect, color);
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
893 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
894 }
1141
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
895
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
896
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
897
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
898 case PYGAME_BLEND_RGBA_ADD:
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
899 {
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
900 result = surface_fill_blend_rgba_add (surface, rect, color);
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
901 break;
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
902 }
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
903 case PYGAME_BLEND_RGBA_SUB:
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
904 {
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
905 result = surface_fill_blend_rgba_sub (surface, rect, color);
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
906 break;
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
907 }
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
908 case PYGAME_BLEND_RGBA_MULT:
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
909 {
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
910 result = surface_fill_blend_rgba_mult (surface, rect, color);
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
911 break;
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
912 }
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
913 case PYGAME_BLEND_RGBA_MIN:
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
914 {
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
915 result = surface_fill_blend_rgba_min (surface, rect, color);
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
916 break;
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
917 }
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
918 case PYGAME_BLEND_RGBA_MAX:
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
919 {
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
920 result = surface_fill_blend_rgba_max (surface, rect, color);
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
921 break;
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
922 }
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
923
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
924
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
925
99a96e8e563d Added BLEND_RGBA_* special flags for blit, and fill.
Rene Dudfield <renesd@gmail.com>
parents: 985
diff changeset
926
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
927 default:
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
928 {
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
929 result = -1;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
930 break;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
931 }
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
932 }
1376
b9af57444694 Fixes an Surface.fill BLEND bug where a surface locked for filling is not unlocked
Lenard Lindstrom <len-l@telus.net>
parents: 1141
diff changeset
933
b9af57444694 Fixes an Surface.fill BLEND bug where a surface locked for filling is not unlocked
Lenard Lindstrom <len-l@telus.net>
parents: 1141
diff changeset
934 if (locked)
b9af57444694 Fixes an Surface.fill BLEND bug where a surface locked for filling is not unlocked
Lenard Lindstrom <len-l@telus.net>
parents: 1141
diff changeset
935 {
b9af57444694 Fixes an Surface.fill BLEND bug where a surface locked for filling is not unlocked
Lenard Lindstrom <len-l@telus.net>
parents: 1141
diff changeset
936 SDL_UnlockSurface (surface);
b9af57444694 Fixes an Surface.fill BLEND bug where a surface locked for filling is not unlocked
Lenard Lindstrom <len-l@telus.net>
parents: 1141
diff changeset
937 }
819
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
938 return result;
f10c63453e4e Marcus has added in blend modes for the surface.fill function.
Rene Dudfield <renesd@gmail.com>
parents:
diff changeset
939 }