Mercurial > sdl-ios-xcode
annotate src/video/SDL_blendrect.c @ 2893:e67f3f3bf221
Turn on line antialiasing (requires blending to be enabled)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 20 Dec 2008 18:40:30 +0000 |
parents | 32e8bbba1e94 |
children | 1ef2f1e75ff7 |
rev | line source |
---|---|
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_video.h" |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "SDL_blit.h" |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 int |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 SDL_BlendRect(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode, Uint8 r, |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 Uint8 g, Uint8 b, Uint8 a) |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 { |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 /* This function doesn't work on surfaces < 8 bpp */ |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 if (dst->format->BitsPerPixel < 8) { |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 SDL_SetError("SDL_BlendRect(): Unsupported surface format"); |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 return (-1); |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 /* If 'dstrect' == NULL, then fill the whole surface */ |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 if (dstrect) { |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 /* Perform clipping */ |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) { |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 return (0); |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 } else { |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 dstrect = &dst->clip_rect; |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 SDL_Unsupported(); |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 return -1; |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 /* vi: set ts=4 sw=4 expandtab: */ |