annotate src/video/SDL_blit_auto.c @ 2262:bee005ace1bf

Work in progress: merging new texture features into SDL blit system
author Sam Lantinga <slouken@libsdl.org>
date Fri, 17 Aug 2007 06:21:58 +0000
parents
children 900c35d8e8fd
rev   line source
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /* DO NOT EDIT! This file is generated by sdlgenblit.pl */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 /*
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 SDL - Simple DirectMedia Layer
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 Copyright (C) 1997-2006 Sam Lantinga
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 This library is free software; you can redistribute it and/or
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 modify it under the terms of the GNU Lesser General Public
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 License as published by the Free Software Foundation; either
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 version 2.1 of the License, or (at your option) any later version.
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 This library is distributed in the hope that it will be useful,
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 Lesser General Public License for more details.
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 You should have received a copy of the GNU Lesser General Public
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 License along with this library; if not, write to the Free Software
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 Sam Lantinga
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 slouken@libsdl.org
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #include "SDL_config.h"
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 /* *INDENT-OFF* */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #include "SDL_video.h"
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include "SDL_blit.h"
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include "SDL_blit_auto.h"
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale },
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 { 0, 0, 0, 0, NULL }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 };
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 *dst = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
583 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
584 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597 void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
599 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
608 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
632 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
651 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
653 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
661 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
669 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
670 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
671
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
673 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
674 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
690 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
691 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
692 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
696 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
697 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
699 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
700 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
701 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
702 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
703 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
704 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
705 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
706 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
707 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
708 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
709 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
710 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
711 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
712 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
713 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
714 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
715 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
716 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
717 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
718 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
719 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
720 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
721 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
722 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
723 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
724 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
725 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
726 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
727 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
728 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
729 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
730 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
731 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
732 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
733 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
734 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
735
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
736 void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
737 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
738 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
739 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
740 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
741 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
742 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
743 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
744 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
745
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
746 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
747 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
748 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
749 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
750 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
751 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
752 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
753 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
754 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
755 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
756 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
757 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
758 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
759 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
760 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
761 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
762 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
763 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
764 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
765 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
766 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
767 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
768 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
769 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
770
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
771 void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
772 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
773 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
774 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
775 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
776 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
777 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
778 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
779 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
780 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
781 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
782 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
783
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
785 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
786 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
787 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
788
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
789 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
790 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
791 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
792 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
793 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
794 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
795 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
796 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
797 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
798 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
799 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
800 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
801 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
802 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
803 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
804 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
805 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
806 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
807 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
808 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
809 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
810 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
811 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
812 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
813 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
814 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
815 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
816 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
817 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
818 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
819 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
820 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
821 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
822 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
823 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
824 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
825 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
826
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
827 void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
828 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
829 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
830 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
831 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
832 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
833 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
834 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
835 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
836 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
837 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
838
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
839 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
840 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
841 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
842 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
844 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
845 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
846 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
847 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
848 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
849 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
850 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
851 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
852 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
853 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
854 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
855 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
856 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
857 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
858 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
859 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
860 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
861 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
862 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
863 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
864 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
865 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
866 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
867 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
868 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
869 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
870 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
871 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
872 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
873 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
874 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
875 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
876 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
877 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
878 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
879 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
880 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
881 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
882 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
883 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
884 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
885 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
886 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
887 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
888 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
889 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
890 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
891 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
892 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
893 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
894 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
895 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
896 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
897
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
898 void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
899 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
900 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
901 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
902 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
903 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
904 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
905 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
906 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
907 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
908 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
909 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
910 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
911 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
912
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
913 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
914 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
915 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
916 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
917
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
918 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
919 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
920 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
921 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
922 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
923 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
924 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
925 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
926 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
927 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
928 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
929 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
930 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
931 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
932 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
933 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
934 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
935 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
936 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
937 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
938 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
939 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
940 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
941 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
942 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
943 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
944 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
945 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
946 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
947 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
948 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
949 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
950 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
951 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
952 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
953 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
954 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
955 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
956 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
957 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
958 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
959 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
960 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
961 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
962 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
963 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
964 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
965 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
966 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
967 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
968 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
969 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
970 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
971 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
972 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
973 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
974 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
975 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
976 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
977 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
978 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
979 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
980 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
981 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
982 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
983 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
984 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
985 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
986 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
987 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
988 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
989
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
990 void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
991 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
992 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
993 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
994 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
995 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
996 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
997 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
998
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
999 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1000 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1001 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1002 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1003
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1004 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1005 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1006 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1007 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1008 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1009 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1010 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1011 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1012 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1013 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1014 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1015 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1016 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1017 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1018 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1019 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1020 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1021 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1022 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1023 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1024 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1025 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1026 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1027 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1028 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1029 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1030 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1031 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1032 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1033
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1034 void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1035 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1036 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1037 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1038 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1039 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1040 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1041
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1042 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1043 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1044 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1045 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1046 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1047 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1048 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1049 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1050 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1051 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1052 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1053 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1054 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1055 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1056 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1057 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1058 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1059 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1060 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1061 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1062 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1063 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1064 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1065 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1066 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1067 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1068 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1069 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1070 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1071 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1072 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1073 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1074 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1075 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1076 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1077 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1078 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1079 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1080 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1081 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1082 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1083 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1084 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1085 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1086 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1087 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1088 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1089 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1090 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1091 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1092
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1093 void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1094 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1095 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1096 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1097 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1098 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1099 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1100 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1101 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1102 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1103
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1104 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1105 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1106 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1107 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1108
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1109 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1110 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1111 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1112 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1113 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1114 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1115 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1116 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1117 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1118 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1119 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1120 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1121 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1122 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1123 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1124 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1125 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1126 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1127 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1128 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1129 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1130 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1131 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1132 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1133 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1134 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1135 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1136 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1137 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1138 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1139 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1140 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1141 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1142 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1143 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1144 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1145 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1146 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1147 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1148 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1149 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1150 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1151 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1152 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1153 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1154 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1155 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1156 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1157 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1158 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1159 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1160 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1161 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1162 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1163 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1164 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1165 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1166 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1167 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1168 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1169 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1170 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1171 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1172
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1173 void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1174 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1175 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1176 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1177 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1178 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1179 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1180 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1181 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1182
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1183 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1184 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1185 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1186 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1187 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1188 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1189 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1190 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1191 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1192 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1193 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1194 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1195 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1196 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1197 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1198 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1199 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1200 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1201 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1202 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1203 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1204 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1205 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1206 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1207
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1208 void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1209 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1210 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1211 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1212 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1213 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1214 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1215 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1216 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1217 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1218 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1219 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1220
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1221 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1222 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1223 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1224 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1225
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1226 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1227 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1228 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1229 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1230 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1231 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1232 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1233 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1234 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1235 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1236 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1237 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1238 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1239 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1240 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1241 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1242 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1243 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1244 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1245 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1246 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1247 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1248 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1249 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1250 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1251 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1252 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1253 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1254 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1255 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1256 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1257 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1258 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1259 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1260 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1261 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1262 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1263
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1264 void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1265 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1266 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1267 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1268 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1269 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1270 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1271 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1272 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1273 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1274 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1275
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1276 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1277 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1278 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1279 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1280 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1281 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1282 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1283 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1284 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1285 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1286 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1287 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1288 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1289 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1290 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1291 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1292 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1293 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1294 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1295 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1296 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1297 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1298 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1299 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1300 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1301 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1302 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1303 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1304 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1305 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1306 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1307 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1308 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1309 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1310 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1311 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1312 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1313 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1314 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1315 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1316 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1317 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1318 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1319 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1320 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1321 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1322 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1323 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1324 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1325 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1326 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1327 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1328 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1329 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1330 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1331 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1332 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1333 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1334
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1335 void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1336 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1337 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1338 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1339 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1340 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1341 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1342 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1343 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1344 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1345 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1346 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1347 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1348 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1349
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1350 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1351 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1352 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1353 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1354
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1355 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1356 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1357 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1358 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1359 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1360 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1361 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1362 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1363 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1364 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1365 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1366 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1367 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1368 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1369 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1370 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1371 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1372 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1373 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1374 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1375 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1376 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1377 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1378 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1379 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1380 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1381 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1382 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1383 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1384 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1385 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1386 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1387 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1388 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1389 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1390 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1391 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1392 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1393 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1394 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1395 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1396 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1397 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1398 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1399 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1400 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1401 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1402 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1403 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1404 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1405 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1406 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1407 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1408 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1409 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1410 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1411 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1412 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1413 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1414 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1415 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1416 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1417 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1418 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1419 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1420 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1421 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1422 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1423 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1424 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1425 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1426
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1427 void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1428 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1429 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1430 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1431 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1432 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1433
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1434 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1435 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1436 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1437 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1438
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1439 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1440 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1441 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1442 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1443 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1444 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1445 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1446 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1447 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1448 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1449 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1450 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1451 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1452 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1453 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1454 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1455 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1456 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1457 *dst = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1458 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1459 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1460 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1461 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1462 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1463 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1464 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1465
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1466 void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1467 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1468 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1469 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1470 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1471 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1472 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1473
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1474 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1475 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1476 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1477 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1478 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1479 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1480 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1481 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1482 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1483 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1484 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1485 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1486 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1487 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1488 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1489 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1490 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1491 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1492 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1493 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1494 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1495 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1496 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1497 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1498 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1499 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1500 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1501 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1502 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1503 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1504 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1505 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1506 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1507 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1508 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1509 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1510 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1511 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1512 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1513 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1514 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1515 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1516 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1517 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1518 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1519 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1520 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1521 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1522 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1523 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1524
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1525 void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1526 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1527 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1528 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1529 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1530 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1531 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1532 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1533 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1534 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1535
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1536 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1537 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1538 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1539 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1540
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1541 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1542 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1543 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1544 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1545 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1546 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1547 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1548 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1549 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1550 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1551 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1552 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1553 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1554 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1555 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1556 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1557 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1558 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1559 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1560 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1561 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1562 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1563 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1564 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1565 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1566 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1567 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1568 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1569 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1570 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1571 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1572 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1573 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1574 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1575 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1576 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1577 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1578 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1579 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1580 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1581 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1582 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1583 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1584 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1585 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1586 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1587 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1588 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1589 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1590 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1591 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1592 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1593 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1594 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1595 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1596 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1597 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1598 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1599 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1600 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1601 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1602 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1603 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1604
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1605 void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1606 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1607 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1608 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1609 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1610 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1611 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1612 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1613 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1614
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1615 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1616 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1617 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1618 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1619 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1620 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1621 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1622 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1623 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1624 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1625 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1626 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1627 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1628 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1629 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1630 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1631 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1632 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1633 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1634 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1635 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1636 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1637 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1638 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1639
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1640 void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1641 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1642 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1643 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1644 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1645 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1646 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1647 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1648 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1649 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1650 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1651 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1652
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1653 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1654 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1655 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1656 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1657
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1658 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1659 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1660 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1661 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1662 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1663 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1664 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1665 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1666 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1667 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1668 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1669 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1670 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1671 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1672 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1673 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1674 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1675 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1676 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1677 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1678 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1679 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1680 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1681 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1682 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1683 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1684 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1685 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1686 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1687 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1688 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1689 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1690 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1691 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1692 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1693 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1694 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1695
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1696 void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1697 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1698 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1699 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1700 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1701 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1702 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1703 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1704 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1705 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1706 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1707
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1708 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1709 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1710 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1711 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1712 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1713 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1714 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1715 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1716 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1717 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1718 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1719 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1720 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1721 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1722 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1723 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1724 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1725 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1726 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1727 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1728 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1729 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1730 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1731 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1732 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1733 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1734 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1735 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1736 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1737 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1738 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1739 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1740 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1741 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1742 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1743 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1744 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1745 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1746 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1747 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1748 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1749 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1750 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1751 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1752 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1753 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1754 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1755 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1756 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1757 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1758 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1759 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1760 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1761 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1762 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1763 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1764 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1765 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1766
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1767 void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1768 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1769 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1770 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1771 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1772 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1773 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1774 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1775 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1776 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1777 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1778 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1779 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1780 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1781
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1782 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1783 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1784 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1785 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1786
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1787 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1788 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1789 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1790 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1791 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1792 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1793 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1794 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1795 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1796 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1797 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1798 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1799 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1800 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1801 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1802 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1803 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1804 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1805 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1806 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1807 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1808 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1809 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1810 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1811 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1812 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1813 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1814 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1815 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1816 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1817 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1818 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1819 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1820 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1821 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1822 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1823 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1824 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1825 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1826 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1827 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1828 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1829 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1830 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1831 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1832 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1833 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1834 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1835 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1836 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1837 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1838 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1839 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1840 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1841 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1842 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1843 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1844 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1845 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1846 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1847 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1848 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1849 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1850 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1851 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1852 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1853 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1854 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1855 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1856 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1857 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1858
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1859 void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1860 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1861 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1862 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1863 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1864 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1865 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1866 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1867
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1868 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1869 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1870 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1871 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1872
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1873 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1874 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1875 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1876 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1877 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1878 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1879 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1880 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1881 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1882 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1883 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1884 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1885 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1886 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1887 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1888 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1889 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1890 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1891 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1892 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1893 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1894 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1895 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1896 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1897 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1898 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1899 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1900 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1901 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1902
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1903 void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1904 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1905 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1906 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1907 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1908 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1909 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1910
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1911 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1912 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1913 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1914 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1915 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1916 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1917 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1918 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1919 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1920 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1921 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1922 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1923 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1924 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1925 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1926 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1927 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1928 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1929 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1930 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1931 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1932 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1933 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1934 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1935 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1936 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1937 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1938 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1939 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1940 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1941 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1942 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1943 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1944 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1945 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1946 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1947 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1948 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1949 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1950 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1951 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1952 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1953 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1954 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1955 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1956 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1957 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1958 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1959 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1960 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1961
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1962 void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1963 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1964 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1965 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1966 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1967 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1968 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1969 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1970 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1971 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1972
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1973 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1974 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1975 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1976 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1977
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1978 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1979 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1980 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1981 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1982 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1983 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1984 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1985 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1986 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1987 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1988 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1989 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1990 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1991 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1992 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1993 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1994 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1995 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1996 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1997 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1998 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1999 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2000 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2001 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2002 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2003 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2004 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2005 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2006 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2007 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2008 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2009 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2010 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2011 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2012 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2013 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2014 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2015 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2016 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2017 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2018 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2019 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2020 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2021 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2022 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2023 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2024 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2025 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2026 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2027 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2028 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2029 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2030 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2031 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2032 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2033 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2034 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2035 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2036 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2037 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2038 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2039 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2040 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2041
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2042 void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2043 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2044 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2045 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2046 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2047 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2048 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2049 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2050 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2051
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2052 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2053 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2054 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2055 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2056 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2057 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2058 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2059 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2060 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2061 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2062 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2063 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2064 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2065 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2066 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2067 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2068 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2069 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2070 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2071 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2072 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2073 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2074 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2075 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2076
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2077 void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2078 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2079 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2080 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2081 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2082 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2083 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2084 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2085 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2086 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2087 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2088 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2089
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2090 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2091 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2092 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2093 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2094
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2095 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2096 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2097 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2098 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2099 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2100 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2101 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2102 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2103 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2104 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2105 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2106 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2107 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2108 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2109 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2110 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2111 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2112 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2113 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2114 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2115 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2116 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2117 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2118 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2119 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2120 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2121 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2122 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2123 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2124 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2125 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2126 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2127 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2128 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2129 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2130 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2131 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2132
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2133 void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2134 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2135 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2136 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2137 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2138 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2139 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2140 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2141 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2142 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2143 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2144
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2145 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2146 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2147 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2148 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2149 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2150 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2151 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2152 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2153 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2154 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2155 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2156 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2157 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2158 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2159 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2160 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2161 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2162 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2163 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2164 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2165 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2166 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2167 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2168 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2169 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2170 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2171 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2172 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2173 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2174 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2175 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2176 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2177 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2178 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2179 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2180 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2181 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2182 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2183 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2184 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2185 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2186 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2187 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2188 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2189 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2190 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2191 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2192 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2193 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2194 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2195 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2196 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2197 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2198 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2199 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2200 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2201 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2202 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2203
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2204 void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2205 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2206 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2207 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2208 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2209 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2210 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2211 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2212 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2213 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2214 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2215 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2216 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2217 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2218
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2219 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2220 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2221 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2222 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2223
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2224 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2225 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2226 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2227 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2228 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2229 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2230 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2231 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2232 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2233 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2234 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2235 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2236 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2237 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2238 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2239 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2240 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2241 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2242 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2243 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2244 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2245 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2246 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2247 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2248 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2249 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2250 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2251 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2252 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2253 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2254 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2255 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2256 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2257 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2258 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2259 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2260 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2261 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2262 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2263 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2264 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2265 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2266 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2267 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2268 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2269 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2270 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2271 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2272 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2273 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2274 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2275 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2276 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2277 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2278 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2279 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2280 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2281 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2282 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2283 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2284 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2285 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2286 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2287 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2288 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2289 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2290 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2291 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2292 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2293 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2294 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2295
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2296 void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2297 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2298 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2299 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2300 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2301 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2302 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2303 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2304
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2305 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2306 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2307 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2308 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2309
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2310 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2311 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2312 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2313 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2314 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2315 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2316 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2317 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2318 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2319 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2320 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2321 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2322 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2323 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2324 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2325 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2326 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2327 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2328 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2329 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2330 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2331 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2332 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2333 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2334 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2335 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2336 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2337 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2338 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2339
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2340 void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2341 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2342 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2343 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2344 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2345 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2346 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2347
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2348 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2349 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2350 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2351 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2352 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2353 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2354 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2355 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2356 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2357 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2358 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2359 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2360 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2361 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2362 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2363 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2364 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2365 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2366 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2367 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2368 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2369 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2370 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2371 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2372 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2373 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2374 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2375 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2376 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2377 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2378 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2379 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2380 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2381 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2382 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2383 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2384 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2385 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2386 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2387 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2388 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2389 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2390 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2391 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2392 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2393 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2394 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2395 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2396 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2397 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2398
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2399 void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2400 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2401 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2402 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2403 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2404 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2405 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2406 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2407 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2408 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2409
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2410 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2411 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2412 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2413 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2414
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2415 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2416 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2417 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2418 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2419 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2420 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2421 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2422 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2423 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2424 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2425 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2426 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2427 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2428 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2429 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2430 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2431 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2432 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2433 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2434 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2435 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2436 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2437 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2438 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2439 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2440 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2441 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2442 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2443 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2444 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2445 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2446 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2447 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2448 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2449 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2450 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2451 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2452 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2453 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2454 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2455 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2456 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2457 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2458 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2459 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2460 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2461 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2462 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2463 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2464 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2465 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2466 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2467 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2468 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2469 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2470 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2471 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2472 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2473 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2474 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2475 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2476 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2477 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2478
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2479 void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2480 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2481 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2482 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2483 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2484 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2485 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2486 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2487 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2488
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2489 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2490 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2491 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2492 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2493 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2494 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2495 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2496 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2497 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2498 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2499 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2500 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2501 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2502 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2503 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2504 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2505 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2506 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2507 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2508 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2509 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2510 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2511 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2512 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2513
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2514 void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2515 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2516 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2517 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2518 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2519 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2520 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2521 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2522 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2523 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2524 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2525 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2526
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2527 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2528 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2529 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2530 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2531
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2532 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2533 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2534 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2535 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2536 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2537 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2538 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2539 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2540 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2541 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2542 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2543 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2544 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2545 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2546 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2547 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2548 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2549 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2550 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2551 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2552 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2553 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2554 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2555 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2556 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2557 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2558 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2559 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2560 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2561 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2562 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2563 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2564 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2565 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2566 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2567 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2568 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2569
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2570 void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2571 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2572 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2573 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2574 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2575 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2576 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2577 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2578 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2579 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2580 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2581
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2582 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2583 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2584 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2585 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2586 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2587 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2588 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2589 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2590 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2591 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2592 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2593 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2594 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2595 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2596 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2597 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2598 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2599 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2600 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2601 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2602 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2603 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2604 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2605 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2606 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2607 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2608 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2609 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2610 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2611 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2612 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2613 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2614 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2615 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2616 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2617 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2618 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2619 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2620 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2621 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2622 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2623 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2624 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2625 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2626 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2627 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2628 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2629 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2630 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2631 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2632 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2633 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2634 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2635 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2636 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2637 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2638 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2639 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2640
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2641 void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2642 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2643 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2644 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2645 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2646 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2647 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2648 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2649 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2650 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2651 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2652 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2653 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2654 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2655
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2656 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2657 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2658 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2659 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2660
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2661 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2662 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2663 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2664 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2665 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2666 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2667 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2668 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2669 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2670 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2671 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2672 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2673 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2674 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2675 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2676 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2677 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2678 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2679 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2680 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2681 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2682 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2683 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2684 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2685 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2686 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2687 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2688 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2689 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2690 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2691 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2692 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2693 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2694 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2695 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2696 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2697 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2698 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2699 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2700 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2701 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2702 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2703 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2704 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2705 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2706 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2707 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2708 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2709 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2710 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2711 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2712 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2713 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2714 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2715 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2716 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2717 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2718 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2719 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2720 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2721 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2722 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2723 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2724 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2725 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2726 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2727 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2728 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2729 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2730 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2731 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2732
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2733 void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2734 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2735 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2736 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2737 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2738 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2739 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2740 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2741
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2742 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2743 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2744 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2745 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2746
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2747 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2748 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2749 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2750 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2751 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2752 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2753 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2754 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2755 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2756 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2757 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2758 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2759 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2760 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2761 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2762 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2763 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2764 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2765 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2766 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2767 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2768 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2769 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2770 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2771 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2772 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2773 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2774 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2775 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2776
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2777 void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2778 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2779 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2780 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2781 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2782 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2783 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2784
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2785 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2786 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2787 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2788 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2789 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2790 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2791 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2792 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2793 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2794 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2795 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2796 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2797 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2798 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2799 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2800 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2801 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2802 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2803 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2804 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2805 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2806 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2807 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2808 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2809 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2810 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2811 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2812 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2813 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2814 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2815 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2816 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2817 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2818 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2819 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2820 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2821 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2822 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2823 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2824 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2825 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2826 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2827 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2828 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2829 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2830 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2831 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2832 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2833 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2834 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2835
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2836 void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2837 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2838 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2839 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2840 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2841 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2842 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2843 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2844 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2845 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2846
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2847 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2848 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2849 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2850 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2851
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2852 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2853 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2854 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2855 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2856 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2857 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2858 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2859 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2860 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2861 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2862 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2863 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2864 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2865 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2866 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2867 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2868 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2869 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2870 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2871 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2872 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2873 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2874 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2875 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2876 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2877 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2878 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2879 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2880 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2881 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2882 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2883 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2884 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2885 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2886 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2887 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2888 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2889 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2890 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2891 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2892 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2893 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2894 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2895 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2896 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2897 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2898 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2899 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2900 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2901 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2902 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2903 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2904 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2905 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2906 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2907 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2908 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2909 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2910 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2911 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2912 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2913 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2914 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2915
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2916 void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2917 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2918 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2919 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2920 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2921 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2922 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2923 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2924 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2925
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2926 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2927 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2928 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2929 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2930 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2931 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2932 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2933 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2934 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2935 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2936 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2937 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2938 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2939 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2940 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2941 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2942 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2943 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2944 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2945 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2946 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2947 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2948 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2949 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2950
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2951 void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2952 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2953 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2954 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2955 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2956 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2957 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2958 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2959 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2960 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2961 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2962 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2963
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2964 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2965 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2966 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2967 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2968
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2969 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2970 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2971 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2972 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2973 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2974 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2975 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2976 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2977 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2978 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2979 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2980 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2981 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2982 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2983 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2984 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2985 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2986 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2987 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2988 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2989 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2990 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2991 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2992 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2993 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2994 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2995 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2996 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2997 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2998 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2999 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3000 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3001 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3002 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3003 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3004 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3005 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3006
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3007 void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3008 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3009 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3010 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3011 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3012 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3013 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3014 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3015 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3016 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3017 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3018
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3019 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3020 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3021 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3022 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3023 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3024 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3025 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3026 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3027 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3028 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3029 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3030 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3031 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3032 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3033 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3034 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3035 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3036 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3037 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3038 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3039 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3040 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3041 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3042 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3043 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3044 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3045 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3046 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3047 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3048 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3049 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3050 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3051 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3052 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3053 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3054 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3055 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3056 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3057 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3058 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3059 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3060 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3061 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3062 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3063 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3064 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3065 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3066 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3067 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3068 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3069 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3070 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3071 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3072 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3073 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3074 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3075 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3076 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3077
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3078 void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3079 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3080 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3081 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3082 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3083 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3084 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3085 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3086 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3087 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3088 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3089 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3090 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3091 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3092
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3093 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3094 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3095 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3096 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3097
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3098 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3099 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3100 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3101 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3102 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3103 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3104 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3105 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3106 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3107 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3108 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3109 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3110 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3111 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3112 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3113 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3114 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3115 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3116 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3117 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3118 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3119 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3120 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3121 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3122 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3123 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3124 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3125 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3126 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3127 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3128 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3129 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3130 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3131 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3132 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3133 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3134 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3135 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3136 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3137 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3138 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3139 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3140 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3141 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3142 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3143 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3144 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3145 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3146 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3147 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3148 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3149 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3150 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3151 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3152 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3153 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3154 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3155 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3156 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3157 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3158 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3159 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3160 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3161 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3162 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3163 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3164 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3165 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3166 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3167 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3168 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3169
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3170 void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3171 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3172 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3173 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3174 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3175 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3176 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3177 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3178
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3179 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3180 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3181 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3182 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3183
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3184 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3185 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3186 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3187 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3188 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3189 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3190 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3191 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3192 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3193 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3194 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3195 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3196 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3197 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3198 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3199 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3200 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3201 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3202 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3203 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3204 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3205 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3206 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3207 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3208 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3209 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3210 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3211 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3212 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3213
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3214 void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3215 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3216 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3217 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3218 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3219 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3220 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3221
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3222 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3223 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3224 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3225 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3226 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3227 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3228 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3229 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3230 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3231 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3232 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3233 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3234 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3235 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3236 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3237 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3238 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3239 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3240 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3241 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3242 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3243 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3244 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3245 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3246 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3247 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3248 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3249 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3250 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3251 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3252 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3253 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3254 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3255 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3256 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3257 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3258 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3259 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3260 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3261 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3262 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3263 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3264 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3265 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3266 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3267 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3268 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3269 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3270 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3271 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3272
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3273 void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3274 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3275 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3276 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3277 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3278 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3279 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3280 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3281 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3282 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3283
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3284 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3285 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3286 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3287 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3288
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3289 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3290 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3291 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3292 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3293 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3294 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3295 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3296 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3297 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3298 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3299 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3300 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3301 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3302 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3303 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3304 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3305 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3306 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3307 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3308 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3309 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3310 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3311 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3312 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3313 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3314 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3315 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3316 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3317 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3318 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3319 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3320 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3321 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3322 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3323 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3324 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3325 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3326 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3327 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3328 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3329 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3330 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3331 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3332 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3333 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3334 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3335 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3336 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3337 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3338 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3339 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3340 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3341 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3342 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3343 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3344 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3345 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3346 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3347 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3348 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3349 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3350 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3351 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3352
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3353 void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3354 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3355 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3356 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3357 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3358 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3359 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3360 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3361 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3362
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3363 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3364 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3365 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3366 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3367 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3368 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3369 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3370 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3371 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3372 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3373 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3374 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3375 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3376 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3377 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3378 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3379 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3380 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3381 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3382 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3383 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3384 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3385 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3386 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3387
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3388 void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3389 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3390 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3391 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3392 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3393 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3394 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3395 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3396 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3397 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3398 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3399 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3400
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3401 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3402 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3403 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3404 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3405
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3406 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3407 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3408 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3409 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3410 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3411 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3412 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3413 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3414 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3415 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3416 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3417 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3418 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3419 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3420 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3421 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3422 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3423 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3424 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3425 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3426 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3427 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3428 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3429 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3430 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3431 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3432 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3433 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3434 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3435 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3436 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3437 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3438 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3439 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3440 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3441 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3442 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3443
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3444 void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3445 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3446 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3447 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3448 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3449 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3450 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3451 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3452 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3453 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3454 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3455
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3456 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3457 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3458 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3459 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3460 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3461 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3462 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3463 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3464 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3465 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3466 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3467 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3468 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3469 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3470 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3471 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3472 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3473 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3474 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3475 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3476 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3477 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3478 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3479 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3480 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3481 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3482 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3483 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3484 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3485 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3486 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3487 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3488 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3489 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3490 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3491 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3492 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3493 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3494 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3495 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3496 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3497 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3498 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3499 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3500 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3501 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3502 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3503 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3504 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3505 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3506 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3507 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3508 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3509 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3510 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3511 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3512 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3513 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3514
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3515 void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3516 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3517 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3518 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3519 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3520 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3521 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3522 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3523 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3524 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3525 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3526 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3527 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3528 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3529
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3530 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3531 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3532 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3533 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3534
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3535 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3536 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3537 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3538 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3539 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3540 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3541 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3542 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3543 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3544 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3545 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3546 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3547 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3548 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3549 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3550 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3551 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3552 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3553 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3554 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3555 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3556 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3557 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3558 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3559 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3560 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3561 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3562 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3563 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3564 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3565 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3566 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3567 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3568 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3569 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3570 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3571 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3572 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3573 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3574 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3575 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3576 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3577 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3578 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3579 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3580 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3581 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3582 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3583 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3584 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3585 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3586 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3587 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3588 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3589 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3590 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3591 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3592 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3593 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3594 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3595 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3596 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3597 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3598 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3599 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3600 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3601 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3602 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3603 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3604 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3605 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3606
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3607 void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3608 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3609 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3610 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3611 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3612 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3613 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3614 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3615
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3616 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3617 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3618 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3619 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3620
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3621 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3622 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3623 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3624 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3625 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3626 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3627 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3628 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3629 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3630 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3631 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3632 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3633 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3634 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3635 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3636 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3637 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3638 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3639 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3640 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3641 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3642 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3643 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3644 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3645 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3646 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3647 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3648 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3649 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3650
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3651 void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3652 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3653 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3654 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3655 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3656 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3657 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3658
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3659 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3660 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3661 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3662 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3663 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3664 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3665 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3666 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3667 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3668 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3669 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3670 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3671 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3672 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3673 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3674 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3675 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3676 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3677 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3678 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3679 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3680 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3681 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3682 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3683 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3684 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3685 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3686 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3687 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3688 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3689 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3690 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3691 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3692 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3693 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3694 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3695 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3696 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3697 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3698 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3699 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3700 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3701 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3702 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3703 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3704 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3705 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3706 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3707 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3708 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3709
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3710 void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3711 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3712 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3713 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3714 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3715 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3716 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3717 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3718 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3719 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3720
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3721 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3722 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3723 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3724 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3725
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3726 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3727 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3728 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3729 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3730 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3731 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3732 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3733 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3734 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3735 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3736 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3737 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3738 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3739 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3740 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3741 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3742 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3743 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3744 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3745 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3746 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3747 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3748 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3749 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3750 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3751 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3752 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3753 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3754 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3755 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3756 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3757 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3758 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3759 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3760 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3761 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3762 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3763 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3764 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3765 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3766 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3767 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3768 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3769 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3770 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3771 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3772 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3773 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3774 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3775 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3776 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3777 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3778 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3779 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3780 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3781 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3782 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3783 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3784 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3785 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3786 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3787 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3788 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3789
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3790 void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3791 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3792 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3793 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3794 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3795 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3796 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3797 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3798 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3799
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3800 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3801 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3802 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3803 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3804 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3805 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3806 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3807 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3808 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3809 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3810 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3811 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3812 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3813 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3814 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3815 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3816 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3817 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3818 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3819 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3820 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3821 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3822 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3823 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3824
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3825 void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3826 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3827 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3828 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3829 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3830 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3831 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3832 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3833 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3834 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3835 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3836 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3837
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3838 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3839 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3840 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3841 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3842
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3843 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3844 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3845 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3846 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3847 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3848 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3849 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3850 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3851 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3852 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3853 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3854 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3855 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3856 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3857 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3858 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3859 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3860 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3861 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3862 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3863 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3864 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3865 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3866 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3867 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3868 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3869 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3870 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3871 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3872 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3873 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3874 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3875 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3876 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3877 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3878 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3879 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3880
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3881 void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3882 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3883 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3884 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3885 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3886 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3887 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3888 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3889 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3890 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3891 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3892
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3893 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3894 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3895 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3896 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3897 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3898 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3899 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3900 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3901 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3902 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3903 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3904 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3905 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3906 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3907 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3908 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3909 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3910 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3911 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3912 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3913 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3914 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3915 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3916 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3917 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3918 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3919 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3920 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3921 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3922 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3923 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3924 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3925 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3926 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3927 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3928 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3929 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3930 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3931 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3932 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3933 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3934 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3935 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3936 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3937 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3938 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3939 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3940 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3941 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3942 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3943 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3944 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3945 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3946 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3947 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3948 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3949 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3950 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3951
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3952 void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3953 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3954 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3955 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3956 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3957 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3958 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3959 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3960 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3961 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3962 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3963 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3964 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3965 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3966
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3967 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3968 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3969 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3970 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3971
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3972 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3973 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3974 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3975 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3976 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3977 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3978 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3979 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3980 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3981 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3982 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3983 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3984 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3985 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3986 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3987 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3988 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3989 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3990 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3991 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3992 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3993 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3994 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3995 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3996 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3997 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3998 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3999 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4000 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4001 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4002 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4003 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4004 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4005 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4006 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4007 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4008 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4009 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4010 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4011 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4012 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4013 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4014 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4015 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4016 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4017 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4018 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4019 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4020 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4021 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4022 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4023 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4024 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4025 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4026 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4027 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4028 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4029 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4030 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4031 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4032 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4033 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4034 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4035 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4036 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4037 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4038 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4039 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4040 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4041 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4042 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4043
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4044 void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4045 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4046 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4047 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4048 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4049 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4050 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4051 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4052
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4053 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4054 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4055 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4056 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4057
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4058 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4059 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4060 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4061 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4062 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4063 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4064 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4065 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4066 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4067 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4068 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4069 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4070 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4071 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4072 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4073 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4074 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4075 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4076 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4077 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4078 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4079 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4080 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4081 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4082 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4083 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4084 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4085 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4086 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4087
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4088 void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4089 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4090 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4091 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4092 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4093 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4094 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4095
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4096 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4097 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4098 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4099 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4100 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4101 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4102 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4103 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4104 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4105 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4106 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4107 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4108 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4109 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4110 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4111 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4112 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4113 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4114 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4115 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4116 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4117 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4118 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4119 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4120 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4121 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4122 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4123 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4124 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4125 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4126 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4127 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4128 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4129 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4130 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4131 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4132 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4133 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4134 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4135 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4136 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4137 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4138 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4139 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4140 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4141 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4142 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4143 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4144 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4145 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4146
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4147 void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4148 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4149 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4150 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4151 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4152 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4153 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4154 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4155 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4156 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4157
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4158 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4159 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4160 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4161 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4162
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4163 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4164 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4165 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4166 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4167 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4168 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4169 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4170 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4171 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4172 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4173 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4174 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4175 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4176 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4177 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4178 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4179 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4180 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4181 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4182 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4183 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4184 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4185 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4186 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4187 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4188 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4189 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4190 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4191 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4192 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4193 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4194 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4195 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4196 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4197 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4198 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4199 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4200 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4201 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4202 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4203 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4204 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4205 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4206 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4207 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4208 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4209 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4210 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4211 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4212 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4213 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4214 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4215 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4216 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4217 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4218 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4219 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4220 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4221 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4222 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4223 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4224 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4225 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4226
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4227 void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4228 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4229 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4230 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4231 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4232 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4233 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4234 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4235 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4236
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4237 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4238 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4239 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4240 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4241 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4242 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4243 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4244 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4245 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4246 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4247 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4248 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4249 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4250 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4251 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4252 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4253 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4254 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4255 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4256 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4257 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4258 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4259 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4260 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4261
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4262 void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4263 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4264 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4265 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4266 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4267 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4268 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4269 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4270 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4271 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4272 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4273 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4274
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4275 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4276 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4277 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4278 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4279
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4280 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4281 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4282 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4283 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4284 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4285 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4286 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4287 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4288 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4289 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4290 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4291 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4292 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4293 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4294 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4295 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4296 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4297 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4298 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4299 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4300 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4301 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4302 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4303 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4304 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4305 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4306 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4307 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4308 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4309 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4310 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4311 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4312 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4313 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4314 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4315 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4316 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4317
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4318 void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4319 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4320 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4321 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4322 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4323 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4324 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4325 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4326 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4327 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4328 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4329
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4330 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4331 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4332 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4333 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4334 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4335 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4336 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4337 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4338 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4339 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4340 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4341 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4342 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4343 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4344 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4345 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4346 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4347 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4348 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4349 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4350 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4351 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4352 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4353 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4354 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4355 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4356 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4357 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4358 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4359 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4360 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4361 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4362 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4363 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4364 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4365 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4366 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4367 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4368 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4369 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4370 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4371 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4372 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4373 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4374 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4375 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4376 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4377 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4378 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4379 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4380 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4381 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4382 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4383 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4384 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4385 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4386 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4387 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4388
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4389 void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4390 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4391 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4392 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4393 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4394 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4395 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4396 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4397 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4398 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4399 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4400 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4401 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4402 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4403
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4404 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4405 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4406 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4407 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4408
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4409 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4410 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4411 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4412 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4413 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4414 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4415 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4416 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4417 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4418 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4419 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4420 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4421 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4422 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4423 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4424 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4425 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4426 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4427 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4428 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4429 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4430 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4431 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4432 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4433 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4434 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4435 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4436 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4437 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4438 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4439 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4440 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4441 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4442 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4443 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4444 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4445 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4446 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4447 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4448 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4449 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4450 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4451 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4452 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4453 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4454 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4455 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4456 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4457 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4458 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4459 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4460 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4461 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4462 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4463 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4464 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4465 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4466 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4467 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4468 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4469 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4470 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4471 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4472 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4473 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4474 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4475 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4476 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4477 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4478 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4479 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4480
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4481 void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4482 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4483 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4484 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4485 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4486 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4487 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4488 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4489
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4490 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4491 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4492 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4493 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4494
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4495 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4496 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4497 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4498 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4499 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4500 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4501 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4502 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4503 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4504 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4505 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4506 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4507 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4508 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4509 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4510 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4511 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4512 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4513 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4514 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4515 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4516 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4517 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4518 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4519 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4520 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4521 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4522 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4523 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4524
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4525 void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4526 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4527 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4528 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4529 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4530 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4531 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4532
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4533 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4534 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4535 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4536 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4537 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4538 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4539 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4540 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4541 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4542 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4543 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4544 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4545 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4546 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4547 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4548 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4549 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4550 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4551 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4552 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4553 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4554 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4555 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4556 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4557 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4558 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4559 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4560 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4561 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4562 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4563 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4564 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4565 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4566 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4567 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4568 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4569 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4570 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4571 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4572 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4573 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4574 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4575 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4576 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4577 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4578 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4579 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4580 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4581 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4582 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4583
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4584 void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4585 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4586 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4587 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4588 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4589 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4590 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4591 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4592 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4593 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4594
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4595 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4596 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4597 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4598 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4599
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4600 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4601 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4602 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4603 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4604 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4605 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4606 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4607 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4608 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4609 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4610 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4611 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4612 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4613 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4614 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4615 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4616 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4617 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4618 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4619 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4620 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4621 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4622 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4623 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4624 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4625 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4626 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4627 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4628 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4629 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4630 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4631 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4632 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4633 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4634 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4635 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4636 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4637 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4638 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4639 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4640 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4641 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4642 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4643 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4644 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4645 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4646 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4647 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4648 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4649 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4650 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4651 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4652 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4653 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4654 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4655 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4656 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4657 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4658 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4659 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4660 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4661 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4662 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4663
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4664 void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4665 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4666 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4667 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4668 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4669 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4670 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4671 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4672 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4673
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4674 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4675 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4676 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4677 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4678 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4679 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4680 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4681 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4682 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4683 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4684 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4685 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4686 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4687 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4688 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4689 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4690 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4691 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4692 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4693 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4694 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4695 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4696 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4697 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4698
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4699 void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4700 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4701 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4702 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4703 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4704 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4705 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4706 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4707 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4708 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4709 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4710 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4711
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4712 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4713 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4714 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4715 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4716
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4717 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4718 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4719 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4720 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4721 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4722 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4723 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4724 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4725 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4726 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4727 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4728 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4729 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4730 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4731 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4732 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4733 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4734 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4735 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4736 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4737 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4738 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4739 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4740 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4741 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4742 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4743 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4744 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4745 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4746 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4747 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4748 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4749 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4750 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4751 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4752 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4753 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4754
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4755 void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4756 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4757 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4758 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4759 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4760 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4761 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4762 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4763 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4764 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4765 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4766
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4767 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4768 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4769 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4770 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4771 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4772 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4773 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4774 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4775 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4776 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4777 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4778 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4779 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4780 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4781 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4782 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4783 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4784 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4785 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4786 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4787 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4788 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4789 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4790 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4791 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4792 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4793 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4794 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4795 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4796 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4797 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4798 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4799 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4800 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4801 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4802 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4803 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4804 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4805 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4806 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4807 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4808 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4809 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4810 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4811 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4812 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4813 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4814 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4815 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4816 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4817 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4818 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4819 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4820 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4821 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4822 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4823 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4824 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4825
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4826 void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4827 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4828 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4829 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4830 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4831 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4832 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4833 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4834 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4835 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4836 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4837 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4838 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4839 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4840
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4841 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4842 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4843 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4844 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4845
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4846 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4847 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4848 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4849 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4850 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4851 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4852 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4853 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4854 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4855 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4856 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4857 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4858 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4859 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4860 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4861 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4862 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4863 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4864 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4865 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4866 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4867 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4868 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4869 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4870 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4871 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4872 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4873 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4874 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4875 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4876 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4877 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4878 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4879 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4880 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4881 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4882 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4883 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4884 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4885 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4886 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4887 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4888 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4889 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4890 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4891 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4892 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4893 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4894 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4895 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4896 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4897 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4898 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4899 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4900 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4901 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4902 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4903 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4904 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4905 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4906 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4907 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4908 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4909 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4910 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4911 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4912 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4913 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4914 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4915 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4916 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4917
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4918 void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4919 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4920 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4921 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4922 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4923 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4924 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4925 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4926
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4927 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4928 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4929 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4930 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4931
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4932 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4933 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4934 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4935 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4936 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4937 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4938 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4939 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4940 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4941 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4942 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4943 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4944 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4945 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4946 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4947 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4948 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4949 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4950 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4951 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4952 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4953 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4954 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4955 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4956 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4957 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4958 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4959 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4960 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4961
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4962 void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4963 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4964 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4965 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4966 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4967 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4968 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4969
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4970 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4971 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4972 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4973 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4974 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4975 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4976 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4977 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4978 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4979 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4980 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4981 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4982 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4983 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4984 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4985 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4986 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4987 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4988 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4989 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4990 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4991 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4992 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4993 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4994 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4995 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4996 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4997 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4998 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4999 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5000 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5001 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5002 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5003 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5004 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5005 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5006 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5007 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5008 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5009 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5010 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5011 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5012 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5013 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5014 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5015 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5016 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5017 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5018 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5019 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5020
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5021 void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5022 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5023 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5024 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5025 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5026 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5027 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5028 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5029 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5030 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5031
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5032 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5033 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5034 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5035 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5036
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5037 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5038 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5039 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5040 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5041 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5042 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5043 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5044 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5045 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5046 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5047 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5048 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5049 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5050 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5051 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5052 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5053 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5054 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5055 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5056 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5057 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5058 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5059 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5060 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5061 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5062 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5063 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5064 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5065 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5066 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5067 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5068 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5069 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5070 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5071 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5072 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5073 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5074 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5075 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5076 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5077 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5078 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5079 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5080 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5081 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5082 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5083 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5084 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5085 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5086 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5087 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5088 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5089 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5090 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5091 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5092 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5093 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5094 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5095 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5096 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5097 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5098 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5099 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5100
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5101 void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5102 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5103 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5104 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5105 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5106 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5107 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5108 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5109 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5110
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5111 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5112 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5113 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5114 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5115 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5116 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5117 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5118 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5119 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5120 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5121 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5122 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5123 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5124 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5125 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5126 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5127 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5128 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5129 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5130 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5131 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5132 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5133 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5134 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5135
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5136 void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5137 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5138 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5139 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5140 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5141 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5142 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5143 Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5144 Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5145 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5146 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5147 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5148
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5149 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5150 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5151 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5152 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5153
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5154 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5155 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5156 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5157 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5158 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5159 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5160 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5161 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5162 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5163 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5164 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5165 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5166 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5167 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5168 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5169 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5170 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5171 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5172 pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5173 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5174 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5175 R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5176 G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5177 B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5178 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5179 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5180 A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5181 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5182 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5183 *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5184 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5185 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5186 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5187 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5188 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5189 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5190 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5191
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5192 void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5193 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5194 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5195 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5196 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5197 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5198 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5199 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5200 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5201 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5202 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5203
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5204 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5205 Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5206 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5207 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5208 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5209 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5210 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5211 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5212 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5213 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5214 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5215 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5216 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5217 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5218 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5219 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5220 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5221 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5222 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5223 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5224 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5225 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5226 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5227 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5228 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5229 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5230 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5231 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5232 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5233 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5234 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5235 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5236 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5237 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5238 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5239 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5240 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5241 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5242 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5243 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5244 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5245 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5246 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5247 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5248 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5249 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5250 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5251 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5252 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5253 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5254 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5255 ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5256 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5257 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5258 info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5259 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5260 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5261 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5263 void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5264 {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5265 const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5266 const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5267 const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5268 const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5269 const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5270 Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5271 Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5272 Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5273 Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5274 int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5275 int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5276 int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5277
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5278 srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5279 posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5280 incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5281 incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5282
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5283 while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5284 Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5285 Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5286 int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5287 srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5288 posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5289 while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5290 ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5291 posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5292 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5293 while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5294 if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5295 while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5296 ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5297 posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5298 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5299 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5300 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5301 srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5302 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5303 dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5304 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5305 if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5306 srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5307 srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5308 srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5309 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5310 if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5311 srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5312 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5313 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5314 /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5315 if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5316 srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5317 srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5318 srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5319 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5320 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5321 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5322 case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5323 if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5324 dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5325 dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5326 dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5327 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5328 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5329 case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5330 dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5331 dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5332 dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5333 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5334 case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5335 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5336 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5337 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5338 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5339 case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5340 dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5341 dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5342 dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5343 break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5344 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5345 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5346 *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5347 posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5348 ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5349 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5350 posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5351 info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5352 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5353 }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5354
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5355 /* *INDENT-ON* */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5356
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5357 /* vi: set ts=4 sw=4 expandtab: */