annotate src/video/SDL_blit_slow.c @ 5067:61d53410eb41

Fixed bug #859 CREATE_SUBDIRS helps a lot if browsing HTML documentation in a file browser. ALWAYS_DETAILED_SEC makes sure everything has at least the automatic documentation like function prototype and source references. STRIP_FROM_PATH allows you to include only the relevant portions of the files' paths, cleaning up both the file list and directory tree, though you need to change the path listed here to match wherever you put SDL. ALIASES avoids some warnings generated by C:\source\svn.libsdl.org\trunk\SDL\src\joystick\darwin\10.3.9-FIX\IOHIDLib.h. It seems Apple uses a few commands which are not normally supported by Doxygen. BUILTIN_STL_SUPPORT adds support for parsing code which makes use of the standard template library. There isn't a lot of C++ in SDL (some in bwindow at least), but this still seems like a good idea. TYPEDEF_HIDES_STRUCT means that for code like this: typedef struct A {int B;} C; C is documented as a structure containing B instead of a typedef mapped to A. EXTRACT_ALL, EXTRACT_PRIVATE, EXTRACT_STATIC, EXTRACT_LOCAL_METHODS, EXTRACT_ANON_NSPACES and INTERNAL_DOCS make sure that _everything_ is documented. CASE_SENSE_NAMES = NO avoids potential conflicts when building documentation on case insensitive file systems like NTFS and FAT32. WARN_NO_PARAMDOC lets you know when you have documented some, but not all, of the parameters of a function. This is useful when you're working on adding such documentation since it makes partially documented functions easier to spot. WARN_LOGFILE writes warnings to a seperate file instead of mixing them in with stdout. When not running in quiet mode, these warnings can be hard to spot without this flag. I added *.h.in and *.h.default to FILE_PATTERNS to generate documentation for config.h.in and config.h.default. RECURSIVE tells doxygen to look not only in the input directory, but also in subfolders. EXCLUDE avoids documenting things like test programs, examples and templates which need to be documented separately. I've used EXCLUDE_PATTERNS to exclude non-source subdirectories that often find their way into source folders (such as obj or .svn). EXAMPLE_PATH lists directories doxygen will search to find included example code. So far, SDL doesn't really use this feature, but I've listed some likely locations. SOURCE_BROWSER adds syntax highlighted source code to the HTML output. USE_HTAGS is nice, but not available on Windows. INLINE_SOURCES adds the body of a function to it's documentation so you can quickly see exactly what it does. ALPHABETICAL_INDEX generates an alphabetical list of all structures, functions, etc., which makes it much easier to find what you're looking for. IGNORE_PREFIX skips the SDL_ prefix when deciding which index page to place an item on so you don't have everything show up under "S". HTML_DYNAMIC_SECTIONS hides the includes/included by diagrams by default and adds JavaScript to allow the user to show and hide them by clicking a link. ENUM_VALUES_PER_LINE = 1 makes enums easier to read by placing each value on it's own line. GENERATE_TREEVIEW produces a two frame index page with a navigation tree on the left. I have LaTeX and man pages turned off to speed up doxygen, you may want to turn them back on yourself. I added _WIN32=1 to PREDEFINED to cause SDL to output documentation related to Win32 builds of SDL. Normally, doxygen gets confused since there are multiple definitions for various structures and formats that vary by platform. Without this doxygen can produce broken documentation or, if you're lucky, output documentation only for the dummy drivers, which isn't very useful. You need to pick a platform. GENERATE_TAGFILE produces a file which can be used to link other doxygen documentation to the SDL documentation. CLASS_DIAGRAMS turns on class diagrams even when dot is not available. HAVE_DOT tells doxygen to try to use dot to generate diagrams. TEMPLATE_RELATIONS and INCLUDE_GRAPH add additional diagrams to the documentation. DOT_MULTI_TARGETS speeds up dot. OUTPUT_DIRECTORY, INPUT and other paths reflect the fact that this Doxyfile is intended to process src as well as include and is being run from a separate subdirectory. Doxygen produces several temporary files while it's running and if interrupted, can leave those files behind. It's easier to clean up if there aren't a hundred or so files in the same folder. I typically run doxygen in SDL/doxy and set the output directory to '.'. Since doxygen puts it's output in subfolders by type, this keeps things pretty well organised. You could use '../doc' instead and get the same results.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 21 Jan 2011 12:57:01 -0800
parents 791b3256fb22
children e743b9c3f6d6
rev   line source
2256
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3588
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
2256
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_video.h"
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include "SDL_blit.h"
4472
791b3256fb22 Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
26 #include "SDL_blit_slow.h"
2256
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 /* The ONE TRUE BLITTER
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 * This puppy has to handle all the unoptimized cases - yes, it's slow.
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 */
2824
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
31 void
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
32 SDL_Blit_Slow(SDL_BlitInfo * info)
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
33 {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
34 const int flags = info->flags;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
35 const Uint32 modulateR = info->r;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
36 const Uint32 modulateG = info->g;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
37 const Uint32 modulateB = info->b;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
38 const Uint32 modulateA = info->a;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
39 Uint32 srcpixel;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
40 Uint32 srcR, srcG, srcB, srcA;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
41 Uint32 dstpixel;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
42 Uint32 dstR, dstG, dstB, dstA;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
43 int srcy, srcx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
44 int posy, posx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
45 int incy, incx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
46 SDL_PixelFormat *src_fmt = info->src_fmt;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
47 SDL_PixelFormat *dst_fmt = info->dst_fmt;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
48 int srcbpp = src_fmt->BytesPerPixel;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
49 int dstbpp = dst_fmt->BytesPerPixel;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
50
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
51 srcy = 0;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
52 posy = 0;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
53 incy = (info->src_h << 16) / info->dst_h;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
54 incx = (info->src_w << 16) / info->dst_w;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
55
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
56 while (info->dst_h--) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
57 Uint8 *src;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
58 Uint8 *dst = (Uint8 *) info->dst;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
59 int n = info->dst_w;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
60 srcx = -1;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
61 posx = 0x10000L;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
62 while (posy >= 0x10000L) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
63 ++srcy;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
64 posy -= 0x10000L;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
65 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
66 while (n--) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
67 if (posx >= 0x10000L) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
68 while (posx >= 0x10000L) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
69 ++srcx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
70 posx -= 0x10000L;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
71 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
72 src =
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
73 (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
74 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
75 if (src_fmt->Amask) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
76 DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
77 srcB, srcA);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
78 } else {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
79 DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
80 srcB);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
81 srcA = 0xFF;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
82 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
83 if (flags & SDL_COPY_COLORKEY) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
84 /* srcpixel isn't set for 24 bpp */
3588
c5fe76962106 Fixed bug #843
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
85 if (srcbpp == 3) {
2824
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
86 srcpixel = (srcR << src_fmt->Rshift) |
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
87 (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
88 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
89 if (srcpixel == info->colorkey) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
90 posx += incx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
91 dst += dstbpp;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
92 continue;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
93 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
94 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
95 if (dst_fmt->Amask) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
96 DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
97 dstB, dstA);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
98 } else {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
99 DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
100 dstB);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
101 dstA = 0xFF;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
102 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
103
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
104 if (flags & SDL_COPY_MODULATE_COLOR) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
105 srcR = (srcR * modulateR) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
106 srcG = (srcG * modulateG) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
107 srcB = (srcB * modulateB) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
108 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
109 if (flags & SDL_COPY_MODULATE_ALPHA) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
110 srcA = (srcA * modulateA) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
111 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
112 if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
113 /* This goes away if we ever use premultiplied alpha */
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
114 if (srcA < 255) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
115 srcR = (srcR * srcA) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
116 srcG = (srcG * srcA) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
117 srcB = (srcB * srcA) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
118 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
119 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
120 switch (flags &
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
121 (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
122 SDL_COPY_MOD)) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
123 case 0:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
124 dstR = srcR;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
125 dstG = srcG;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
126 dstB = srcB;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
127 dstA = srcA;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
128 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
129 case SDL_COPY_MASK:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
130 if (srcA) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
131 dstR = srcR;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
132 dstG = srcG;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
133 dstB = srcB;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
134 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
135 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
136 case SDL_COPY_BLEND:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
137 dstR = srcR + ((255 - srcA) * dstR) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
138 dstG = srcG + ((255 - srcA) * dstG) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
139 dstB = srcB + ((255 - srcA) * dstB) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
140 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
141 case SDL_COPY_ADD:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
142 dstR = srcR + dstR;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
143 if (dstR > 255)
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
144 dstR = 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
145 dstG = srcG + dstG;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
146 if (dstG > 255)
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
147 dstG = 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
148 dstB = srcB + dstB;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
149 if (dstB > 255)
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
150 dstB = 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
151 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
152 case SDL_COPY_MOD:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
153 dstR = (srcR * dstR) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
154 dstG = (srcG * dstG) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
155 dstB = (srcB * dstB) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
156 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
157 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
158 if (dst_fmt->Amask) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
159 ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
160 } else {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
161 ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
162 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
163 posx += incx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
164 dst += dstbpp;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
165 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
166 posy += incy;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
167 info->dst += info->dst_pitch;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
168 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
169 }
2256
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 /* vi: set ts=4 sw=4 expandtab: */