annotate src/video/SDL_blendpoint.c @ 3156:4ead4cef6b7b gsoc2009_ps3

Rewritten Makefile (fixed bug) and cleanup for yuv2rgb.
author Martin Lowinski <martin@goldtopf.org>
date Fri, 14 Aug 2009 15:49:44 +0000
parents 133601e3b255
children 0267b8b1595c
rev   line source
2901
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_draw.h"
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 static int
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 DRAW_SETPIXELXY_BLEND_RGB555(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 DRAW_SETPIXELXY_ADD_RGB555(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 case SDL_BLENDMODE_MOD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 DRAW_SETPIXELXY_MOD_RGB555(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 DRAW_SETPIXELXY_RGB555(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 static int
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 DRAW_SETPIXELXY_BLEND_RGB565(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 DRAW_SETPIXELXY_ADD_RGB565(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 case SDL_BLENDMODE_MOD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 DRAW_SETPIXELXY_MOD_RGB565(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 DRAW_SETPIXELXY_RGB565(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 static int
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 DRAW_SETPIXELXY_BLEND_RGB888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 DRAW_SETPIXELXY_ADD_RGB888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 case SDL_BLENDMODE_MOD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 DRAW_SETPIXELXY_MOD_RGB888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 DRAW_SETPIXELXY_RGB888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 static int
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, int blendMode,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 DRAW_SETPIXELXY_BLEND_ARGB8888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 case SDL_BLENDMODE_MOD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 DRAW_SETPIXELXY_MOD_ARGB8888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 DRAW_SETPIXELXY_ARGB8888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 static int
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 SDL_PixelFormat *fmt = dst->format;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 switch (fmt->BytesPerPixel) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 case 2:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 DRAW_SETPIXELXY2_BLEND_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 DRAW_SETPIXELXY2_ADD_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 case SDL_BLENDMODE_MOD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 DRAW_SETPIXELXY2_MOD_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 DRAW_SETPIXELXY2_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 case 4:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 DRAW_SETPIXELXY4_BLEND_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 DRAW_SETPIXELXY4_ADD_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 case SDL_BLENDMODE_MOD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 DRAW_SETPIXELXY4_MOD_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 DRAW_SETPIXELXY4_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 SDL_Unsupported();
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 return -1;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 static int
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 SDL_PixelFormat *fmt = dst->format;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 switch (fmt->BytesPerPixel) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 case 4:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 DRAW_SETPIXELXY4_BLEND_RGBA(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 DRAW_SETPIXELXY4_ADD_RGBA(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 case SDL_BLENDMODE_MOD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 DRAW_SETPIXELXY4_MOD_RGBA(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 DRAW_SETPIXELXY4_RGBA(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 SDL_Unsupported();
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 return -1;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 int
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 SDL_BlendPoint(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 SDL_PixelFormat *fmt = dst->format;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 /* This function doesn't work on surfaces < 8 bpp */
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 if (dst->format->BitsPerPixel < 8) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 return (-1);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 /* Perform clipping */
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 x >= (dst->clip_rect.x + dst->clip_rect.w) ||
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 y >= (dst->clip_rect.y + dst->clip_rect.h)) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 if ((blendMode == SDL_BLENDMODE_BLEND)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 || (blendMode == SDL_BLENDMODE_ADD)) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 r = DRAW_MUL(r, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 g = DRAW_MUL(g, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 b = DRAW_MUL(b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 switch (fmt->BitsPerPixel) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 case 15:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 switch (fmt->Rmask) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 case 0x7C00:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 case 16:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 switch (fmt->Rmask) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 case 0xF800:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 case 32:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 switch (fmt->Rmask) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 case 0x00FF0000:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 if (!fmt->Amask) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 } else {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 if (!fmt->Amask) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 } else {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 /* vi: set ts=4 sw=4 expandtab: */