PageRenderTime 97ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/project/jni/sdl-1.3/src/video/SDL_blit_auto.c

https://github.com/aichunyu/FFPlayer
C | 7491 lines | 7066 code | 329 blank | 96 comment | 1044 complexity | 3ae07b461596b922a17cf29366324a9e MD5 | raw file
Possible License(s): LGPL-3.0, 0BSD, Apache-2.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, LGPL-2.0, BSD-3-Clause
  1. /* DO NOT EDIT! This file is generated by sdlgenblit.pl */
  2. /*
  3. Simple DirectMedia Layer
  4. Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any damages
  7. arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose,
  9. including commercial applications, and to alter it and redistribute it
  10. freely, subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software
  13. in a product, an acknowledgment in the product documentation would be
  14. appreciated but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. */
  19. #include "SDL_config.h"
  20. /* *INDENT-OFF* */
  21. #include "SDL_video.h"
  22. #include "SDL_blit.h"
  23. #include "SDL_blit_auto.h"
  24. static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
  25. {
  26. int srcy, srcx;
  27. int posy, posx;
  28. int incy, incx;
  29. srcy = 0;
  30. posy = 0;
  31. incy = (info->src_h << 16) / info->dst_h;
  32. incx = (info->src_w << 16) / info->dst_w;
  33. while (info->dst_h--) {
  34. Uint32 *src = 0;
  35. Uint32 *dst = (Uint32 *)info->dst;
  36. int n = info->dst_w;
  37. srcx = -1;
  38. posx = 0x10000L;
  39. while (posy >= 0x10000L) {
  40. ++srcy;
  41. posy -= 0x10000L;
  42. }
  43. while (n--) {
  44. if (posx >= 0x10000L) {
  45. while (posx >= 0x10000L) {
  46. ++srcx;
  47. posx -= 0x10000L;
  48. }
  49. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  50. }
  51. *dst = *src;
  52. posx += incx;
  53. ++dst;
  54. }
  55. posy += incy;
  56. info->dst += info->dst_pitch;
  57. }
  58. }
  59. static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
  60. {
  61. const int flags = info->flags;
  62. Uint32 srcpixel;
  63. Uint32 srcR, srcG, srcB, srcA;
  64. Uint32 dstpixel;
  65. Uint32 dstR, dstG, dstB, dstA;
  66. while (info->dst_h--) {
  67. Uint32 *src = (Uint32 *)info->src;
  68. Uint32 *dst = (Uint32 *)info->dst;
  69. int n = info->dst_w;
  70. while (n--) {
  71. srcpixel = *src;
  72. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  73. dstpixel = *dst;
  74. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  75. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  76. /* This goes away if we ever use premultiplied alpha */
  77. if (srcA < 255) {
  78. srcR = (srcR * srcA) / 255;
  79. srcG = (srcG * srcA) / 255;
  80. srcB = (srcB * srcA) / 255;
  81. }
  82. }
  83. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  84. case SDL_COPY_BLEND:
  85. dstR = srcR + ((255 - srcA) * dstR) / 255;
  86. dstG = srcG + ((255 - srcA) * dstG) / 255;
  87. dstB = srcB + ((255 - srcA) * dstB) / 255;
  88. break;
  89. case SDL_COPY_ADD:
  90. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  91. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  92. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  93. break;
  94. case SDL_COPY_MOD:
  95. dstR = (srcR * dstR) / 255;
  96. dstG = (srcG * dstG) / 255;
  97. dstB = (srcB * dstB) / 255;
  98. break;
  99. }
  100. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  101. *dst = dstpixel;
  102. ++src;
  103. ++dst;
  104. }
  105. info->src += info->src_pitch;
  106. info->dst += info->dst_pitch;
  107. }
  108. }
  109. static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  110. {
  111. const int flags = info->flags;
  112. Uint32 srcpixel;
  113. Uint32 srcR, srcG, srcB, srcA;
  114. Uint32 dstpixel;
  115. Uint32 dstR, dstG, dstB, dstA;
  116. int srcy, srcx;
  117. int posy, posx;
  118. int incy, incx;
  119. srcy = 0;
  120. posy = 0;
  121. incy = (info->src_h << 16) / info->dst_h;
  122. incx = (info->src_w << 16) / info->dst_w;
  123. while (info->dst_h--) {
  124. Uint32 *src = 0;
  125. Uint32 *dst = (Uint32 *)info->dst;
  126. int n = info->dst_w;
  127. srcx = -1;
  128. posx = 0x10000L;
  129. while (posy >= 0x10000L) {
  130. ++srcy;
  131. posy -= 0x10000L;
  132. }
  133. while (n--) {
  134. if (posx >= 0x10000L) {
  135. while (posx >= 0x10000L) {
  136. ++srcx;
  137. posx -= 0x10000L;
  138. }
  139. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  140. }
  141. srcpixel = *src;
  142. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  143. dstpixel = *dst;
  144. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  145. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  146. /* This goes away if we ever use premultiplied alpha */
  147. if (srcA < 255) {
  148. srcR = (srcR * srcA) / 255;
  149. srcG = (srcG * srcA) / 255;
  150. srcB = (srcB * srcA) / 255;
  151. }
  152. }
  153. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  154. case SDL_COPY_BLEND:
  155. dstR = srcR + ((255 - srcA) * dstR) / 255;
  156. dstG = srcG + ((255 - srcA) * dstG) / 255;
  157. dstB = srcB + ((255 - srcA) * dstB) / 255;
  158. break;
  159. case SDL_COPY_ADD:
  160. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  161. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  162. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  163. break;
  164. case SDL_COPY_MOD:
  165. dstR = (srcR * dstR) / 255;
  166. dstG = (srcG * dstG) / 255;
  167. dstB = (srcB * dstB) / 255;
  168. break;
  169. }
  170. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  171. *dst = dstpixel;
  172. posx += incx;
  173. ++dst;
  174. }
  175. posy += incy;
  176. info->dst += info->dst_pitch;
  177. }
  178. }
  179. static void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
  180. {
  181. const int flags = info->flags;
  182. const Uint32 modulateR = info->r;
  183. const Uint32 modulateG = info->g;
  184. const Uint32 modulateB = info->b;
  185. const Uint32 modulateA = info->a;
  186. Uint32 pixel;
  187. Uint32 R, G, B, A;
  188. while (info->dst_h--) {
  189. Uint32 *src = (Uint32 *)info->src;
  190. Uint32 *dst = (Uint32 *)info->dst;
  191. int n = info->dst_w;
  192. while (n--) {
  193. pixel = *src;
  194. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  195. if (flags & SDL_COPY_MODULATE_COLOR) {
  196. R = (R * modulateR) / 255;
  197. G = (G * modulateG) / 255;
  198. B = (B * modulateB) / 255;
  199. }
  200. if (flags & SDL_COPY_MODULATE_ALPHA) {
  201. A = (A * modulateA) / 255;
  202. }
  203. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  204. *dst = pixel;
  205. ++src;
  206. ++dst;
  207. }
  208. info->src += info->src_pitch;
  209. info->dst += info->dst_pitch;
  210. }
  211. }
  212. static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  213. {
  214. const int flags = info->flags;
  215. const Uint32 modulateR = info->r;
  216. const Uint32 modulateG = info->g;
  217. const Uint32 modulateB = info->b;
  218. const Uint32 modulateA = info->a;
  219. Uint32 pixel;
  220. Uint32 R, G, B, A;
  221. int srcy, srcx;
  222. int posy, posx;
  223. int incy, incx;
  224. srcy = 0;
  225. posy = 0;
  226. incy = (info->src_h << 16) / info->dst_h;
  227. incx = (info->src_w << 16) / info->dst_w;
  228. while (info->dst_h--) {
  229. Uint32 *src = 0;
  230. Uint32 *dst = (Uint32 *)info->dst;
  231. int n = info->dst_w;
  232. srcx = -1;
  233. posx = 0x10000L;
  234. while (posy >= 0x10000L) {
  235. ++srcy;
  236. posy -= 0x10000L;
  237. }
  238. while (n--) {
  239. if (posx >= 0x10000L) {
  240. while (posx >= 0x10000L) {
  241. ++srcx;
  242. posx -= 0x10000L;
  243. }
  244. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  245. }
  246. pixel = *src;
  247. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  248. if (flags & SDL_COPY_MODULATE_COLOR) {
  249. R = (R * modulateR) / 255;
  250. G = (G * modulateG) / 255;
  251. B = (B * modulateB) / 255;
  252. }
  253. if (flags & SDL_COPY_MODULATE_ALPHA) {
  254. A = (A * modulateA) / 255;
  255. }
  256. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  257. *dst = pixel;
  258. posx += incx;
  259. ++dst;
  260. }
  261. posy += incy;
  262. info->dst += info->dst_pitch;
  263. }
  264. }
  265. static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  266. {
  267. const int flags = info->flags;
  268. const Uint32 modulateR = info->r;
  269. const Uint32 modulateG = info->g;
  270. const Uint32 modulateB = info->b;
  271. const Uint32 modulateA = info->a;
  272. Uint32 srcpixel;
  273. Uint32 srcR, srcG, srcB, srcA;
  274. Uint32 dstpixel;
  275. Uint32 dstR, dstG, dstB, dstA;
  276. while (info->dst_h--) {
  277. Uint32 *src = (Uint32 *)info->src;
  278. Uint32 *dst = (Uint32 *)info->dst;
  279. int n = info->dst_w;
  280. while (n--) {
  281. srcpixel = *src;
  282. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  283. dstpixel = *dst;
  284. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  285. if (flags & SDL_COPY_MODULATE_COLOR) {
  286. srcR = (srcR * modulateR) / 255;
  287. srcG = (srcG * modulateG) / 255;
  288. srcB = (srcB * modulateB) / 255;
  289. }
  290. if (flags & SDL_COPY_MODULATE_ALPHA) {
  291. srcA = (srcA * modulateA) / 255;
  292. }
  293. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  294. /* This goes away if we ever use premultiplied alpha */
  295. if (srcA < 255) {
  296. srcR = (srcR * srcA) / 255;
  297. srcG = (srcG * srcA) / 255;
  298. srcB = (srcB * srcA) / 255;
  299. }
  300. }
  301. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  302. case SDL_COPY_BLEND:
  303. dstR = srcR + ((255 - srcA) * dstR) / 255;
  304. dstG = srcG + ((255 - srcA) * dstG) / 255;
  305. dstB = srcB + ((255 - srcA) * dstB) / 255;
  306. break;
  307. case SDL_COPY_ADD:
  308. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  309. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  310. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  311. break;
  312. case SDL_COPY_MOD:
  313. dstR = (srcR * dstR) / 255;
  314. dstG = (srcG * dstG) / 255;
  315. dstB = (srcB * dstB) / 255;
  316. break;
  317. }
  318. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  319. *dst = dstpixel;
  320. ++src;
  321. ++dst;
  322. }
  323. info->src += info->src_pitch;
  324. info->dst += info->dst_pitch;
  325. }
  326. }
  327. static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  328. {
  329. const int flags = info->flags;
  330. const Uint32 modulateR = info->r;
  331. const Uint32 modulateG = info->g;
  332. const Uint32 modulateB = info->b;
  333. const Uint32 modulateA = info->a;
  334. Uint32 srcpixel;
  335. Uint32 srcR, srcG, srcB, srcA;
  336. Uint32 dstpixel;
  337. Uint32 dstR, dstG, dstB, dstA;
  338. int srcy, srcx;
  339. int posy, posx;
  340. int incy, incx;
  341. srcy = 0;
  342. posy = 0;
  343. incy = (info->src_h << 16) / info->dst_h;
  344. incx = (info->src_w << 16) / info->dst_w;
  345. while (info->dst_h--) {
  346. Uint32 *src = 0;
  347. Uint32 *dst = (Uint32 *)info->dst;
  348. int n = info->dst_w;
  349. srcx = -1;
  350. posx = 0x10000L;
  351. while (posy >= 0x10000L) {
  352. ++srcy;
  353. posy -= 0x10000L;
  354. }
  355. while (n--) {
  356. if (posx >= 0x10000L) {
  357. while (posx >= 0x10000L) {
  358. ++srcx;
  359. posx -= 0x10000L;
  360. }
  361. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  362. }
  363. srcpixel = *src;
  364. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  365. dstpixel = *dst;
  366. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  367. if (flags & SDL_COPY_MODULATE_COLOR) {
  368. srcR = (srcR * modulateR) / 255;
  369. srcG = (srcG * modulateG) / 255;
  370. srcB = (srcB * modulateB) / 255;
  371. }
  372. if (flags & SDL_COPY_MODULATE_ALPHA) {
  373. srcA = (srcA * modulateA) / 255;
  374. }
  375. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  376. /* This goes away if we ever use premultiplied alpha */
  377. if (srcA < 255) {
  378. srcR = (srcR * srcA) / 255;
  379. srcG = (srcG * srcA) / 255;
  380. srcB = (srcB * srcA) / 255;
  381. }
  382. }
  383. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  384. case SDL_COPY_BLEND:
  385. dstR = srcR + ((255 - srcA) * dstR) / 255;
  386. dstG = srcG + ((255 - srcA) * dstG) / 255;
  387. dstB = srcB + ((255 - srcA) * dstB) / 255;
  388. break;
  389. case SDL_COPY_ADD:
  390. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  391. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  392. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  393. break;
  394. case SDL_COPY_MOD:
  395. dstR = (srcR * dstR) / 255;
  396. dstG = (srcG * dstG) / 255;
  397. dstB = (srcB * dstB) / 255;
  398. break;
  399. }
  400. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  401. *dst = dstpixel;
  402. posx += incx;
  403. ++dst;
  404. }
  405. posy += incy;
  406. info->dst += info->dst_pitch;
  407. }
  408. }
  409. static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
  410. {
  411. Uint32 pixel;
  412. Uint32 R, G, B, A;
  413. int srcy, srcx;
  414. int posy, posx;
  415. int incy, incx;
  416. srcy = 0;
  417. posy = 0;
  418. incy = (info->src_h << 16) / info->dst_h;
  419. incx = (info->src_w << 16) / info->dst_w;
  420. while (info->dst_h--) {
  421. Uint32 *src = 0;
  422. Uint32 *dst = (Uint32 *)info->dst;
  423. int n = info->dst_w;
  424. srcx = -1;
  425. posx = 0x10000L;
  426. while (posy >= 0x10000L) {
  427. ++srcy;
  428. posy -= 0x10000L;
  429. }
  430. while (n--) {
  431. if (posx >= 0x10000L) {
  432. while (posx >= 0x10000L) {
  433. ++srcx;
  434. posx -= 0x10000L;
  435. }
  436. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  437. }
  438. pixel = *src;
  439. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  440. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  441. *dst = pixel;
  442. posx += incx;
  443. ++dst;
  444. }
  445. posy += incy;
  446. info->dst += info->dst_pitch;
  447. }
  448. }
  449. static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
  450. {
  451. const int flags = info->flags;
  452. Uint32 srcpixel;
  453. Uint32 srcR, srcG, srcB, srcA;
  454. Uint32 dstpixel;
  455. Uint32 dstR, dstG, dstB, dstA;
  456. while (info->dst_h--) {
  457. Uint32 *src = (Uint32 *)info->src;
  458. Uint32 *dst = (Uint32 *)info->dst;
  459. int n = info->dst_w;
  460. while (n--) {
  461. srcpixel = *src;
  462. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  463. dstpixel = *dst;
  464. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  465. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  466. /* This goes away if we ever use premultiplied alpha */
  467. if (srcA < 255) {
  468. srcR = (srcR * srcA) / 255;
  469. srcG = (srcG * srcA) / 255;
  470. srcB = (srcB * srcA) / 255;
  471. }
  472. }
  473. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  474. case SDL_COPY_BLEND:
  475. dstR = srcR + ((255 - srcA) * dstR) / 255;
  476. dstG = srcG + ((255 - srcA) * dstG) / 255;
  477. dstB = srcB + ((255 - srcA) * dstB) / 255;
  478. break;
  479. case SDL_COPY_ADD:
  480. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  481. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  482. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  483. break;
  484. case SDL_COPY_MOD:
  485. dstR = (srcR * dstR) / 255;
  486. dstG = (srcG * dstG) / 255;
  487. dstB = (srcB * dstB) / 255;
  488. break;
  489. }
  490. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  491. *dst = dstpixel;
  492. ++src;
  493. ++dst;
  494. }
  495. info->src += info->src_pitch;
  496. info->dst += info->dst_pitch;
  497. }
  498. }
  499. static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  500. {
  501. const int flags = info->flags;
  502. Uint32 srcpixel;
  503. Uint32 srcR, srcG, srcB, srcA;
  504. Uint32 dstpixel;
  505. Uint32 dstR, dstG, dstB, dstA;
  506. int srcy, srcx;
  507. int posy, posx;
  508. int incy, incx;
  509. srcy = 0;
  510. posy = 0;
  511. incy = (info->src_h << 16) / info->dst_h;
  512. incx = (info->src_w << 16) / info->dst_w;
  513. while (info->dst_h--) {
  514. Uint32 *src = 0;
  515. Uint32 *dst = (Uint32 *)info->dst;
  516. int n = info->dst_w;
  517. srcx = -1;
  518. posx = 0x10000L;
  519. while (posy >= 0x10000L) {
  520. ++srcy;
  521. posy -= 0x10000L;
  522. }
  523. while (n--) {
  524. if (posx >= 0x10000L) {
  525. while (posx >= 0x10000L) {
  526. ++srcx;
  527. posx -= 0x10000L;
  528. }
  529. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  530. }
  531. srcpixel = *src;
  532. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  533. dstpixel = *dst;
  534. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  535. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  536. /* This goes away if we ever use premultiplied alpha */
  537. if (srcA < 255) {
  538. srcR = (srcR * srcA) / 255;
  539. srcG = (srcG * srcA) / 255;
  540. srcB = (srcB * srcA) / 255;
  541. }
  542. }
  543. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  544. case SDL_COPY_BLEND:
  545. dstR = srcR + ((255 - srcA) * dstR) / 255;
  546. dstG = srcG + ((255 - srcA) * dstG) / 255;
  547. dstB = srcB + ((255 - srcA) * dstB) / 255;
  548. break;
  549. case SDL_COPY_ADD:
  550. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  551. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  552. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  553. break;
  554. case SDL_COPY_MOD:
  555. dstR = (srcR * dstR) / 255;
  556. dstG = (srcG * dstG) / 255;
  557. dstB = (srcB * dstB) / 255;
  558. break;
  559. }
  560. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  561. *dst = dstpixel;
  562. posx += incx;
  563. ++dst;
  564. }
  565. posy += incy;
  566. info->dst += info->dst_pitch;
  567. }
  568. }
  569. static void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
  570. {
  571. const int flags = info->flags;
  572. const Uint32 modulateR = info->r;
  573. const Uint32 modulateG = info->g;
  574. const Uint32 modulateB = info->b;
  575. const Uint32 modulateA = info->a;
  576. Uint32 pixel;
  577. Uint32 R, G, B, A;
  578. while (info->dst_h--) {
  579. Uint32 *src = (Uint32 *)info->src;
  580. Uint32 *dst = (Uint32 *)info->dst;
  581. int n = info->dst_w;
  582. while (n--) {
  583. pixel = *src;
  584. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  585. if (flags & SDL_COPY_MODULATE_COLOR) {
  586. R = (R * modulateR) / 255;
  587. G = (G * modulateG) / 255;
  588. B = (B * modulateB) / 255;
  589. }
  590. if (flags & SDL_COPY_MODULATE_ALPHA) {
  591. A = (A * modulateA) / 255;
  592. }
  593. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  594. *dst = pixel;
  595. ++src;
  596. ++dst;
  597. }
  598. info->src += info->src_pitch;
  599. info->dst += info->dst_pitch;
  600. }
  601. }
  602. static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  603. {
  604. const int flags = info->flags;
  605. const Uint32 modulateR = info->r;
  606. const Uint32 modulateG = info->g;
  607. const Uint32 modulateB = info->b;
  608. const Uint32 modulateA = info->a;
  609. Uint32 pixel;
  610. Uint32 R, G, B, A;
  611. int srcy, srcx;
  612. int posy, posx;
  613. int incy, incx;
  614. srcy = 0;
  615. posy = 0;
  616. incy = (info->src_h << 16) / info->dst_h;
  617. incx = (info->src_w << 16) / info->dst_w;
  618. while (info->dst_h--) {
  619. Uint32 *src = 0;
  620. Uint32 *dst = (Uint32 *)info->dst;
  621. int n = info->dst_w;
  622. srcx = -1;
  623. posx = 0x10000L;
  624. while (posy >= 0x10000L) {
  625. ++srcy;
  626. posy -= 0x10000L;
  627. }
  628. while (n--) {
  629. if (posx >= 0x10000L) {
  630. while (posx >= 0x10000L) {
  631. ++srcx;
  632. posx -= 0x10000L;
  633. }
  634. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  635. }
  636. pixel = *src;
  637. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  638. if (flags & SDL_COPY_MODULATE_COLOR) {
  639. R = (R * modulateR) / 255;
  640. G = (G * modulateG) / 255;
  641. B = (B * modulateB) / 255;
  642. }
  643. if (flags & SDL_COPY_MODULATE_ALPHA) {
  644. A = (A * modulateA) / 255;
  645. }
  646. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  647. *dst = pixel;
  648. posx += incx;
  649. ++dst;
  650. }
  651. posy += incy;
  652. info->dst += info->dst_pitch;
  653. }
  654. }
  655. static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  656. {
  657. const int flags = info->flags;
  658. const Uint32 modulateR = info->r;
  659. const Uint32 modulateG = info->g;
  660. const Uint32 modulateB = info->b;
  661. const Uint32 modulateA = info->a;
  662. Uint32 srcpixel;
  663. Uint32 srcR, srcG, srcB, srcA;
  664. Uint32 dstpixel;
  665. Uint32 dstR, dstG, dstB, dstA;
  666. while (info->dst_h--) {
  667. Uint32 *src = (Uint32 *)info->src;
  668. Uint32 *dst = (Uint32 *)info->dst;
  669. int n = info->dst_w;
  670. while (n--) {
  671. srcpixel = *src;
  672. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  673. dstpixel = *dst;
  674. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  675. if (flags & SDL_COPY_MODULATE_COLOR) {
  676. srcR = (srcR * modulateR) / 255;
  677. srcG = (srcG * modulateG) / 255;
  678. srcB = (srcB * modulateB) / 255;
  679. }
  680. if (flags & SDL_COPY_MODULATE_ALPHA) {
  681. srcA = (srcA * modulateA) / 255;
  682. }
  683. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  684. /* This goes away if we ever use premultiplied alpha */
  685. if (srcA < 255) {
  686. srcR = (srcR * srcA) / 255;
  687. srcG = (srcG * srcA) / 255;
  688. srcB = (srcB * srcA) / 255;
  689. }
  690. }
  691. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  692. case SDL_COPY_BLEND:
  693. dstR = srcR + ((255 - srcA) * dstR) / 255;
  694. dstG = srcG + ((255 - srcA) * dstG) / 255;
  695. dstB = srcB + ((255 - srcA) * dstB) / 255;
  696. break;
  697. case SDL_COPY_ADD:
  698. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  699. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  700. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  701. break;
  702. case SDL_COPY_MOD:
  703. dstR = (srcR * dstR) / 255;
  704. dstG = (srcG * dstG) / 255;
  705. dstB = (srcB * dstB) / 255;
  706. break;
  707. }
  708. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  709. *dst = dstpixel;
  710. ++src;
  711. ++dst;
  712. }
  713. info->src += info->src_pitch;
  714. info->dst += info->dst_pitch;
  715. }
  716. }
  717. static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  718. {
  719. const int flags = info->flags;
  720. const Uint32 modulateR = info->r;
  721. const Uint32 modulateG = info->g;
  722. const Uint32 modulateB = info->b;
  723. const Uint32 modulateA = info->a;
  724. Uint32 srcpixel;
  725. Uint32 srcR, srcG, srcB, srcA;
  726. Uint32 dstpixel;
  727. Uint32 dstR, dstG, dstB, dstA;
  728. int srcy, srcx;
  729. int posy, posx;
  730. int incy, incx;
  731. srcy = 0;
  732. posy = 0;
  733. incy = (info->src_h << 16) / info->dst_h;
  734. incx = (info->src_w << 16) / info->dst_w;
  735. while (info->dst_h--) {
  736. Uint32 *src = 0;
  737. Uint32 *dst = (Uint32 *)info->dst;
  738. int n = info->dst_w;
  739. srcx = -1;
  740. posx = 0x10000L;
  741. while (posy >= 0x10000L) {
  742. ++srcy;
  743. posy -= 0x10000L;
  744. }
  745. while (n--) {
  746. if (posx >= 0x10000L) {
  747. while (posx >= 0x10000L) {
  748. ++srcx;
  749. posx -= 0x10000L;
  750. }
  751. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  752. }
  753. srcpixel = *src;
  754. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  755. dstpixel = *dst;
  756. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  757. if (flags & SDL_COPY_MODULATE_COLOR) {
  758. srcR = (srcR * modulateR) / 255;
  759. srcG = (srcG * modulateG) / 255;
  760. srcB = (srcB * modulateB) / 255;
  761. }
  762. if (flags & SDL_COPY_MODULATE_ALPHA) {
  763. srcA = (srcA * modulateA) / 255;
  764. }
  765. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  766. /* This goes away if we ever use premultiplied alpha */
  767. if (srcA < 255) {
  768. srcR = (srcR * srcA) / 255;
  769. srcG = (srcG * srcA) / 255;
  770. srcB = (srcB * srcA) / 255;
  771. }
  772. }
  773. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  774. case SDL_COPY_BLEND:
  775. dstR = srcR + ((255 - srcA) * dstR) / 255;
  776. dstG = srcG + ((255 - srcA) * dstG) / 255;
  777. dstB = srcB + ((255 - srcA) * dstB) / 255;
  778. break;
  779. case SDL_COPY_ADD:
  780. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  781. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  782. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  783. break;
  784. case SDL_COPY_MOD:
  785. dstR = (srcR * dstR) / 255;
  786. dstG = (srcG * dstG) / 255;
  787. dstB = (srcB * dstB) / 255;
  788. break;
  789. }
  790. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  791. *dst = dstpixel;
  792. posx += incx;
  793. ++dst;
  794. }
  795. posy += incy;
  796. info->dst += info->dst_pitch;
  797. }
  798. }
  799. static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info)
  800. {
  801. Uint32 pixel;
  802. Uint32 R, G, B, A;
  803. int srcy, srcx;
  804. int posy, posx;
  805. int incy, incx;
  806. srcy = 0;
  807. posy = 0;
  808. incy = (info->src_h << 16) / info->dst_h;
  809. incx = (info->src_w << 16) / info->dst_w;
  810. while (info->dst_h--) {
  811. Uint32 *src = 0;
  812. Uint32 *dst = (Uint32 *)info->dst;
  813. int n = info->dst_w;
  814. srcx = -1;
  815. posx = 0x10000L;
  816. while (posy >= 0x10000L) {
  817. ++srcy;
  818. posy -= 0x10000L;
  819. }
  820. while (n--) {
  821. if (posx >= 0x10000L) {
  822. while (posx >= 0x10000L) {
  823. ++srcx;
  824. posx -= 0x10000L;
  825. }
  826. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  827. }
  828. pixel = *src;
  829. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  830. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  831. *dst = pixel;
  832. posx += incx;
  833. ++dst;
  834. }
  835. posy += incy;
  836. info->dst += info->dst_pitch;
  837. }
  838. }
  839. static void SDL_Blit_RGB888_ARGB8888_Blend(SDL_BlitInfo *info)
  840. {
  841. const int flags = info->flags;
  842. Uint32 srcpixel;
  843. Uint32 srcR, srcG, srcB, srcA;
  844. Uint32 dstpixel;
  845. Uint32 dstR, dstG, dstB, dstA;
  846. while (info->dst_h--) {
  847. Uint32 *src = (Uint32 *)info->src;
  848. Uint32 *dst = (Uint32 *)info->dst;
  849. int n = info->dst_w;
  850. while (n--) {
  851. srcpixel = *src;
  852. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  853. dstpixel = *dst;
  854. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  855. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  856. /* This goes away if we ever use premultiplied alpha */
  857. if (srcA < 255) {
  858. srcR = (srcR * srcA) / 255;
  859. srcG = (srcG * srcA) / 255;
  860. srcB = (srcB * srcA) / 255;
  861. }
  862. }
  863. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  864. case SDL_COPY_BLEND:
  865. dstR = srcR + ((255 - srcA) * dstR) / 255;
  866. dstG = srcG + ((255 - srcA) * dstG) / 255;
  867. dstB = srcB + ((255 - srcA) * dstB) / 255;
  868. break;
  869. case SDL_COPY_ADD:
  870. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  871. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  872. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  873. break;
  874. case SDL_COPY_MOD:
  875. dstR = (srcR * dstR) / 255;
  876. dstG = (srcG * dstG) / 255;
  877. dstB = (srcB * dstB) / 255;
  878. break;
  879. }
  880. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  881. *dst = dstpixel;
  882. ++src;
  883. ++dst;
  884. }
  885. info->src += info->src_pitch;
  886. info->dst += info->dst_pitch;
  887. }
  888. }
  889. static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  890. {
  891. const int flags = info->flags;
  892. Uint32 srcpixel;
  893. Uint32 srcR, srcG, srcB, srcA;
  894. Uint32 dstpixel;
  895. Uint32 dstR, dstG, dstB, dstA;
  896. int srcy, srcx;
  897. int posy, posx;
  898. int incy, incx;
  899. srcy = 0;
  900. posy = 0;
  901. incy = (info->src_h << 16) / info->dst_h;
  902. incx = (info->src_w << 16) / info->dst_w;
  903. while (info->dst_h--) {
  904. Uint32 *src = 0;
  905. Uint32 *dst = (Uint32 *)info->dst;
  906. int n = info->dst_w;
  907. srcx = -1;
  908. posx = 0x10000L;
  909. while (posy >= 0x10000L) {
  910. ++srcy;
  911. posy -= 0x10000L;
  912. }
  913. while (n--) {
  914. if (posx >= 0x10000L) {
  915. while (posx >= 0x10000L) {
  916. ++srcx;
  917. posx -= 0x10000L;
  918. }
  919. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  920. }
  921. srcpixel = *src;
  922. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  923. dstpixel = *dst;
  924. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  925. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  926. /* This goes away if we ever use premultiplied alpha */
  927. if (srcA < 255) {
  928. srcR = (srcR * srcA) / 255;
  929. srcG = (srcG * srcA) / 255;
  930. srcB = (srcB * srcA) / 255;
  931. }
  932. }
  933. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  934. case SDL_COPY_BLEND:
  935. dstR = srcR + ((255 - srcA) * dstR) / 255;
  936. dstG = srcG + ((255 - srcA) * dstG) / 255;
  937. dstB = srcB + ((255 - srcA) * dstB) / 255;
  938. break;
  939. case SDL_COPY_ADD:
  940. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  941. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  942. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  943. break;
  944. case SDL_COPY_MOD:
  945. dstR = (srcR * dstR) / 255;
  946. dstG = (srcG * dstG) / 255;
  947. dstB = (srcB * dstB) / 255;
  948. break;
  949. }
  950. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  951. *dst = dstpixel;
  952. posx += incx;
  953. ++dst;
  954. }
  955. posy += incy;
  956. info->dst += info->dst_pitch;
  957. }
  958. }
  959. static void SDL_Blit_RGB888_ARGB8888_Modulate(SDL_BlitInfo *info)
  960. {
  961. const int flags = info->flags;
  962. const Uint32 modulateR = info->r;
  963. const Uint32 modulateG = info->g;
  964. const Uint32 modulateB = info->b;
  965. const Uint32 modulateA = info->a;
  966. Uint32 pixel;
  967. Uint32 R, G, B, A;
  968. while (info->dst_h--) {
  969. Uint32 *src = (Uint32 *)info->src;
  970. Uint32 *dst = (Uint32 *)info->dst;
  971. int n = info->dst_w;
  972. while (n--) {
  973. pixel = *src;
  974. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  975. if (flags & SDL_COPY_MODULATE_COLOR) {
  976. R = (R * modulateR) / 255;
  977. G = (G * modulateG) / 255;
  978. B = (B * modulateB) / 255;
  979. }
  980. if (flags & SDL_COPY_MODULATE_ALPHA) {
  981. A = (A * modulateA) / 255;
  982. }
  983. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  984. *dst = pixel;
  985. ++src;
  986. ++dst;
  987. }
  988. info->src += info->src_pitch;
  989. info->dst += info->dst_pitch;
  990. }
  991. }
  992. static void SDL_Blit_RGB888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  993. {
  994. const int flags = info->flags;
  995. const Uint32 modulateR = info->r;
  996. const Uint32 modulateG = info->g;
  997. const Uint32 modulateB = info->b;
  998. const Uint32 modulateA = info->a;
  999. Uint32 pixel;
  1000. Uint32 R, G, B, A;
  1001. int srcy, srcx;
  1002. int posy, posx;
  1003. int incy, incx;
  1004. srcy = 0;
  1005. posy = 0;
  1006. incy = (info->src_h << 16) / info->dst_h;
  1007. incx = (info->src_w << 16) / info->dst_w;
  1008. while (info->dst_h--) {
  1009. Uint32 *src = 0;
  1010. Uint32 *dst = (Uint32 *)info->dst;
  1011. int n = info->dst_w;
  1012. srcx = -1;
  1013. posx = 0x10000L;
  1014. while (posy >= 0x10000L) {
  1015. ++srcy;
  1016. posy -= 0x10000L;
  1017. }
  1018. while (n--) {
  1019. if (posx >= 0x10000L) {
  1020. while (posx >= 0x10000L) {
  1021. ++srcx;
  1022. posx -= 0x10000L;
  1023. }
  1024. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1025. }
  1026. pixel = *src;
  1027. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  1028. if (flags & SDL_COPY_MODULATE_COLOR) {
  1029. R = (R * modulateR) / 255;
  1030. G = (G * modulateG) / 255;
  1031. B = (B * modulateB) / 255;
  1032. }
  1033. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1034. A = (A * modulateA) / 255;
  1035. }
  1036. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1037. *dst = pixel;
  1038. posx += incx;
  1039. ++dst;
  1040. }
  1041. posy += incy;
  1042. info->dst += info->dst_pitch;
  1043. }
  1044. }
  1045. static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1046. {
  1047. const int flags = info->flags;
  1048. const Uint32 modulateR = info->r;
  1049. const Uint32 modulateG = info->g;
  1050. const Uint32 modulateB = info->b;
  1051. const Uint32 modulateA = info->a;
  1052. Uint32 srcpixel;
  1053. Uint32 srcR, srcG, srcB, srcA;
  1054. Uint32 dstpixel;
  1055. Uint32 dstR, dstG, dstB, dstA;
  1056. while (info->dst_h--) {
  1057. Uint32 *src = (Uint32 *)info->src;
  1058. Uint32 *dst = (Uint32 *)info->dst;
  1059. int n = info->dst_w;
  1060. while (n--) {
  1061. srcpixel = *src;
  1062. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  1063. dstpixel = *dst;
  1064. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1065. if (flags & SDL_COPY_MODULATE_COLOR) {
  1066. srcR = (srcR * modulateR) / 255;
  1067. srcG = (srcG * modulateG) / 255;
  1068. srcB = (srcB * modulateB) / 255;
  1069. }
  1070. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1071. srcA = (srcA * modulateA) / 255;
  1072. }
  1073. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1074. /* This goes away if we ever use premultiplied alpha */
  1075. if (srcA < 255) {
  1076. srcR = (srcR * srcA) / 255;
  1077. srcG = (srcG * srcA) / 255;
  1078. srcB = (srcB * srcA) / 255;
  1079. }
  1080. }
  1081. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1082. case SDL_COPY_BLEND:
  1083. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1084. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1085. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1086. break;
  1087. case SDL_COPY_ADD:
  1088. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1089. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1090. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1091. break;
  1092. case SDL_COPY_MOD:
  1093. dstR = (srcR * dstR) / 255;
  1094. dstG = (srcG * dstG) / 255;
  1095. dstB = (srcB * dstB) / 255;
  1096. break;
  1097. }
  1098. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1099. *dst = dstpixel;
  1100. ++src;
  1101. ++dst;
  1102. }
  1103. info->src += info->src_pitch;
  1104. info->dst += info->dst_pitch;
  1105. }
  1106. }
  1107. static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1108. {
  1109. const int flags = info->flags;
  1110. const Uint32 modulateR = info->r;
  1111. const Uint32 modulateG = info->g;
  1112. const Uint32 modulateB = info->b;
  1113. const Uint32 modulateA = info->a;
  1114. Uint32 srcpixel;
  1115. Uint32 srcR, srcG, srcB, srcA;
  1116. Uint32 dstpixel;
  1117. Uint32 dstR, dstG, dstB, dstA;
  1118. int srcy, srcx;
  1119. int posy, posx;
  1120. int incy, incx;
  1121. srcy = 0;
  1122. posy = 0;
  1123. incy = (info->src_h << 16) / info->dst_h;
  1124. incx = (info->src_w << 16) / info->dst_w;
  1125. while (info->dst_h--) {
  1126. Uint32 *src = 0;
  1127. Uint32 *dst = (Uint32 *)info->dst;
  1128. int n = info->dst_w;
  1129. srcx = -1;
  1130. posx = 0x10000L;
  1131. while (posy >= 0x10000L) {
  1132. ++srcy;
  1133. posy -= 0x10000L;
  1134. }
  1135. while (n--) {
  1136. if (posx >= 0x10000L) {
  1137. while (posx >= 0x10000L) {
  1138. ++srcx;
  1139. posx -= 0x10000L;
  1140. }
  1141. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1142. }
  1143. srcpixel = *src;
  1144. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  1145. dstpixel = *dst;
  1146. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1147. if (flags & SDL_COPY_MODULATE_COLOR) {
  1148. srcR = (srcR * modulateR) / 255;
  1149. srcG = (srcG * modulateG) / 255;
  1150. srcB = (srcB * modulateB) / 255;
  1151. }
  1152. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1153. srcA = (srcA * modulateA) / 255;
  1154. }
  1155. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1156. /* This goes away if we ever use premultiplied alpha */
  1157. if (srcA < 255) {
  1158. srcR = (srcR * srcA) / 255;
  1159. srcG = (srcG * srcA) / 255;
  1160. srcB = (srcB * srcA) / 255;
  1161. }
  1162. }
  1163. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1164. case SDL_COPY_BLEND:
  1165. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1166. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1167. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1168. break;
  1169. case SDL_COPY_ADD:
  1170. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1171. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1172. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1173. break;
  1174. case SDL_COPY_MOD:
  1175. dstR = (srcR * dstR) / 255;
  1176. dstG = (srcG * dstG) / 255;
  1177. dstB = (srcB * dstB) / 255;
  1178. break;
  1179. }
  1180. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1181. *dst = dstpixel;
  1182. posx += incx;
  1183. ++dst;
  1184. }
  1185. posy += incy;
  1186. info->dst += info->dst_pitch;
  1187. }
  1188. }
  1189. static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
  1190. {
  1191. Uint32 pixel;
  1192. Uint32 R, G, B, A;
  1193. int srcy, srcx;
  1194. int posy, posx;
  1195. int incy, incx;
  1196. srcy = 0;
  1197. posy = 0;
  1198. incy = (info->src_h << 16) / info->dst_h;
  1199. incx = (info->src_w << 16) / info->dst_w;
  1200. while (info->dst_h--) {
  1201. Uint32 *src = 0;
  1202. Uint32 *dst = (Uint32 *)info->dst;
  1203. int n = info->dst_w;
  1204. srcx = -1;
  1205. posx = 0x10000L;
  1206. while (posy >= 0x10000L) {
  1207. ++srcy;
  1208. posy -= 0x10000L;
  1209. }
  1210. while (n--) {
  1211. if (posx >= 0x10000L) {
  1212. while (posx >= 0x10000L) {
  1213. ++srcx;
  1214. posx -= 0x10000L;
  1215. }
  1216. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1217. }
  1218. pixel = *src;
  1219. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  1220. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1221. *dst = pixel;
  1222. posx += incx;
  1223. ++dst;
  1224. }
  1225. posy += incy;
  1226. info->dst += info->dst_pitch;
  1227. }
  1228. }
  1229. static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
  1230. {
  1231. const int flags = info->flags;
  1232. Uint32 srcpixel;
  1233. Uint32 srcR, srcG, srcB, srcA;
  1234. Uint32 dstpixel;
  1235. Uint32 dstR, dstG, dstB, dstA;
  1236. while (info->dst_h--) {
  1237. Uint32 *src = (Uint32 *)info->src;
  1238. Uint32 *dst = (Uint32 *)info->dst;
  1239. int n = info->dst_w;
  1240. while (n--) {
  1241. srcpixel = *src;
  1242. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  1243. dstpixel = *dst;
  1244. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1245. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1246. /* This goes away if we ever use premultiplied alpha */
  1247. if (srcA < 255) {
  1248. srcR = (srcR * srcA) / 255;
  1249. srcG = (srcG * srcA) / 255;
  1250. srcB = (srcB * srcA) / 255;
  1251. }
  1252. }
  1253. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1254. case SDL_COPY_BLEND:
  1255. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1256. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1257. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1258. break;
  1259. case SDL_COPY_ADD:
  1260. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1261. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1262. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1263. break;
  1264. case SDL_COPY_MOD:
  1265. dstR = (srcR * dstR) / 255;
  1266. dstG = (srcG * dstG) / 255;
  1267. dstB = (srcB * dstB) / 255;
  1268. break;
  1269. }
  1270. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1271. *dst = dstpixel;
  1272. ++src;
  1273. ++dst;
  1274. }
  1275. info->src += info->src_pitch;
  1276. info->dst += info->dst_pitch;
  1277. }
  1278. }
  1279. static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  1280. {
  1281. const int flags = info->flags;
  1282. Uint32 srcpixel;
  1283. Uint32 srcR, srcG, srcB, srcA;
  1284. Uint32 dstpixel;
  1285. Uint32 dstR, dstG, dstB, dstA;
  1286. int srcy, srcx;
  1287. int posy, posx;
  1288. int incy, incx;
  1289. srcy = 0;
  1290. posy = 0;
  1291. incy = (info->src_h << 16) / info->dst_h;
  1292. incx = (info->src_w << 16) / info->dst_w;
  1293. while (info->dst_h--) {
  1294. Uint32 *src = 0;
  1295. Uint32 *dst = (Uint32 *)info->dst;
  1296. int n = info->dst_w;
  1297. srcx = -1;
  1298. posx = 0x10000L;
  1299. while (posy >= 0x10000L) {
  1300. ++srcy;
  1301. posy -= 0x10000L;
  1302. }
  1303. while (n--) {
  1304. if (posx >= 0x10000L) {
  1305. while (posx >= 0x10000L) {
  1306. ++srcx;
  1307. posx -= 0x10000L;
  1308. }
  1309. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1310. }
  1311. srcpixel = *src;
  1312. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  1313. dstpixel = *dst;
  1314. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1315. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1316. /* This goes away if we ever use premultiplied alpha */
  1317. if (srcA < 255) {
  1318. srcR = (srcR * srcA) / 255;
  1319. srcG = (srcG * srcA) / 255;
  1320. srcB = (srcB * srcA) / 255;
  1321. }
  1322. }
  1323. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1324. case SDL_COPY_BLEND:
  1325. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1326. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1327. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1328. break;
  1329. case SDL_COPY_ADD:
  1330. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1331. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1332. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1333. break;
  1334. case SDL_COPY_MOD:
  1335. dstR = (srcR * dstR) / 255;
  1336. dstG = (srcG * dstG) / 255;
  1337. dstB = (srcB * dstB) / 255;
  1338. break;
  1339. }
  1340. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1341. *dst = dstpixel;
  1342. posx += incx;
  1343. ++dst;
  1344. }
  1345. posy += incy;
  1346. info->dst += info->dst_pitch;
  1347. }
  1348. }
  1349. static void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
  1350. {
  1351. const int flags = info->flags;
  1352. const Uint32 modulateR = info->r;
  1353. const Uint32 modulateG = info->g;
  1354. const Uint32 modulateB = info->b;
  1355. const Uint32 modulateA = info->a;
  1356. Uint32 pixel;
  1357. Uint32 R, G, B, A;
  1358. while (info->dst_h--) {
  1359. Uint32 *src = (Uint32 *)info->src;
  1360. Uint32 *dst = (Uint32 *)info->dst;
  1361. int n = info->dst_w;
  1362. while (n--) {
  1363. pixel = *src;
  1364. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  1365. if (flags & SDL_COPY_MODULATE_COLOR) {
  1366. R = (R * modulateR) / 255;
  1367. G = (G * modulateG) / 255;
  1368. B = (B * modulateB) / 255;
  1369. }
  1370. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1371. A = (A * modulateA) / 255;
  1372. }
  1373. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1374. *dst = pixel;
  1375. ++src;
  1376. ++dst;
  1377. }
  1378. info->src += info->src_pitch;
  1379. info->dst += info->dst_pitch;
  1380. }
  1381. }
  1382. static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  1383. {
  1384. const int flags = info->flags;
  1385. const Uint32 modulateR = info->r;
  1386. const Uint32 modulateG = info->g;
  1387. const Uint32 modulateB = info->b;
  1388. const Uint32 modulateA = info->a;
  1389. Uint32 pixel;
  1390. Uint32 R, G, B, A;
  1391. int srcy, srcx;
  1392. int posy, posx;
  1393. int incy, incx;
  1394. srcy = 0;
  1395. posy = 0;
  1396. incy = (info->src_h << 16) / info->dst_h;
  1397. incx = (info->src_w << 16) / info->dst_w;
  1398. while (info->dst_h--) {
  1399. Uint32 *src = 0;
  1400. Uint32 *dst = (Uint32 *)info->dst;
  1401. int n = info->dst_w;
  1402. srcx = -1;
  1403. posx = 0x10000L;
  1404. while (posy >= 0x10000L) {
  1405. ++srcy;
  1406. posy -= 0x10000L;
  1407. }
  1408. while (n--) {
  1409. if (posx >= 0x10000L) {
  1410. while (posx >= 0x10000L) {
  1411. ++srcx;
  1412. posx -= 0x10000L;
  1413. }
  1414. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1415. }
  1416. pixel = *src;
  1417. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  1418. if (flags & SDL_COPY_MODULATE_COLOR) {
  1419. R = (R * modulateR) / 255;
  1420. G = (G * modulateG) / 255;
  1421. B = (B * modulateB) / 255;
  1422. }
  1423. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1424. A = (A * modulateA) / 255;
  1425. }
  1426. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1427. *dst = pixel;
  1428. posx += incx;
  1429. ++dst;
  1430. }
  1431. posy += incy;
  1432. info->dst += info->dst_pitch;
  1433. }
  1434. }
  1435. static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  1436. {
  1437. const int flags = info->flags;
  1438. const Uint32 modulateR = info->r;
  1439. const Uint32 modulateG = info->g;
  1440. const Uint32 modulateB = info->b;
  1441. const Uint32 modulateA = info->a;
  1442. Uint32 srcpixel;
  1443. Uint32 srcR, srcG, srcB, srcA;
  1444. Uint32 dstpixel;
  1445. Uint32 dstR, dstG, dstB, dstA;
  1446. while (info->dst_h--) {
  1447. Uint32 *src = (Uint32 *)info->src;
  1448. Uint32 *dst = (Uint32 *)info->dst;
  1449. int n = info->dst_w;
  1450. while (n--) {
  1451. srcpixel = *src;
  1452. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  1453. dstpixel = *dst;
  1454. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1455. if (flags & SDL_COPY_MODULATE_COLOR) {
  1456. srcR = (srcR * modulateR) / 255;
  1457. srcG = (srcG * modulateG) / 255;
  1458. srcB = (srcB * modulateB) / 255;
  1459. }
  1460. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1461. srcA = (srcA * modulateA) / 255;
  1462. }
  1463. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1464. /* This goes away if we ever use premultiplied alpha */
  1465. if (srcA < 255) {
  1466. srcR = (srcR * srcA) / 255;
  1467. srcG = (srcG * srcA) / 255;
  1468. srcB = (srcB * srcA) / 255;
  1469. }
  1470. }
  1471. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1472. case SDL_COPY_BLEND:
  1473. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1474. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1475. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1476. break;
  1477. case SDL_COPY_ADD:
  1478. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1479. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1480. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1481. break;
  1482. case SDL_COPY_MOD:
  1483. dstR = (srcR * dstR) / 255;
  1484. dstG = (srcG * dstG) / 255;
  1485. dstB = (srcB * dstB) / 255;
  1486. break;
  1487. }
  1488. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1489. *dst = dstpixel;
  1490. ++src;
  1491. ++dst;
  1492. }
  1493. info->src += info->src_pitch;
  1494. info->dst += info->dst_pitch;
  1495. }
  1496. }
  1497. static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1498. {
  1499. const int flags = info->flags;
  1500. const Uint32 modulateR = info->r;
  1501. const Uint32 modulateG = info->g;
  1502. const Uint32 modulateB = info->b;
  1503. const Uint32 modulateA = info->a;
  1504. Uint32 srcpixel;
  1505. Uint32 srcR, srcG, srcB, srcA;
  1506. Uint32 dstpixel;
  1507. Uint32 dstR, dstG, dstB, dstA;
  1508. int srcy, srcx;
  1509. int posy, posx;
  1510. int incy, incx;
  1511. srcy = 0;
  1512. posy = 0;
  1513. incy = (info->src_h << 16) / info->dst_h;
  1514. incx = (info->src_w << 16) / info->dst_w;
  1515. while (info->dst_h--) {
  1516. Uint32 *src = 0;
  1517. Uint32 *dst = (Uint32 *)info->dst;
  1518. int n = info->dst_w;
  1519. srcx = -1;
  1520. posx = 0x10000L;
  1521. while (posy >= 0x10000L) {
  1522. ++srcy;
  1523. posy -= 0x10000L;
  1524. }
  1525. while (n--) {
  1526. if (posx >= 0x10000L) {
  1527. while (posx >= 0x10000L) {
  1528. ++srcx;
  1529. posx -= 0x10000L;
  1530. }
  1531. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1532. }
  1533. srcpixel = *src;
  1534. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  1535. dstpixel = *dst;
  1536. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1537. if (flags & SDL_COPY_MODULATE_COLOR) {
  1538. srcR = (srcR * modulateR) / 255;
  1539. srcG = (srcG * modulateG) / 255;
  1540. srcB = (srcB * modulateB) / 255;
  1541. }
  1542. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1543. srcA = (srcA * modulateA) / 255;
  1544. }
  1545. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1546. /* This goes away if we ever use premultiplied alpha */
  1547. if (srcA < 255) {
  1548. srcR = (srcR * srcA) / 255;
  1549. srcG = (srcG * srcA) / 255;
  1550. srcB = (srcB * srcA) / 255;
  1551. }
  1552. }
  1553. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1554. case SDL_COPY_BLEND:
  1555. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1556. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1557. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1558. break;
  1559. case SDL_COPY_ADD:
  1560. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1561. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1562. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1563. break;
  1564. case SDL_COPY_MOD:
  1565. dstR = (srcR * dstR) / 255;
  1566. dstG = (srcG * dstG) / 255;
  1567. dstB = (srcB * dstB) / 255;
  1568. break;
  1569. }
  1570. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1571. *dst = dstpixel;
  1572. posx += incx;
  1573. ++dst;
  1574. }
  1575. posy += incy;
  1576. info->dst += info->dst_pitch;
  1577. }
  1578. }
  1579. static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
  1580. {
  1581. int srcy, srcx;
  1582. int posy, posx;
  1583. int incy, incx;
  1584. srcy = 0;
  1585. posy = 0;
  1586. incy = (info->src_h << 16) / info->dst_h;
  1587. incx = (info->src_w << 16) / info->dst_w;
  1588. while (info->dst_h--) {
  1589. Uint32 *src = 0;
  1590. Uint32 *dst = (Uint32 *)info->dst;
  1591. int n = info->dst_w;
  1592. srcx = -1;
  1593. posx = 0x10000L;
  1594. while (posy >= 0x10000L) {
  1595. ++srcy;
  1596. posy -= 0x10000L;
  1597. }
  1598. while (n--) {
  1599. if (posx >= 0x10000L) {
  1600. while (posx >= 0x10000L) {
  1601. ++srcx;
  1602. posx -= 0x10000L;
  1603. }
  1604. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1605. }
  1606. *dst = *src;
  1607. posx += incx;
  1608. ++dst;
  1609. }
  1610. posy += incy;
  1611. info->dst += info->dst_pitch;
  1612. }
  1613. }
  1614. static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
  1615. {
  1616. const int flags = info->flags;
  1617. Uint32 srcpixel;
  1618. Uint32 srcR, srcG, srcB, srcA;
  1619. Uint32 dstpixel;
  1620. Uint32 dstR, dstG, dstB, dstA;
  1621. while (info->dst_h--) {
  1622. Uint32 *src = (Uint32 *)info->src;
  1623. Uint32 *dst = (Uint32 *)info->dst;
  1624. int n = info->dst_w;
  1625. while (n--) {
  1626. srcpixel = *src;
  1627. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  1628. dstpixel = *dst;
  1629. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1630. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1631. /* This goes away if we ever use premultiplied alpha */
  1632. if (srcA < 255) {
  1633. srcR = (srcR * srcA) / 255;
  1634. srcG = (srcG * srcA) / 255;
  1635. srcB = (srcB * srcA) / 255;
  1636. }
  1637. }
  1638. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1639. case SDL_COPY_BLEND:
  1640. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1641. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1642. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1643. break;
  1644. case SDL_COPY_ADD:
  1645. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1646. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1647. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1648. break;
  1649. case SDL_COPY_MOD:
  1650. dstR = (srcR * dstR) / 255;
  1651. dstG = (srcG * dstG) / 255;
  1652. dstB = (srcB * dstB) / 255;
  1653. break;
  1654. }
  1655. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1656. *dst = dstpixel;
  1657. ++src;
  1658. ++dst;
  1659. }
  1660. info->src += info->src_pitch;
  1661. info->dst += info->dst_pitch;
  1662. }
  1663. }
  1664. static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  1665. {
  1666. const int flags = info->flags;
  1667. Uint32 srcpixel;
  1668. Uint32 srcR, srcG, srcB, srcA;
  1669. Uint32 dstpixel;
  1670. Uint32 dstR, dstG, dstB, dstA;
  1671. int srcy, srcx;
  1672. int posy, posx;
  1673. int incy, incx;
  1674. srcy = 0;
  1675. posy = 0;
  1676. incy = (info->src_h << 16) / info->dst_h;
  1677. incx = (info->src_w << 16) / info->dst_w;
  1678. while (info->dst_h--) {
  1679. Uint32 *src = 0;
  1680. Uint32 *dst = (Uint32 *)info->dst;
  1681. int n = info->dst_w;
  1682. srcx = -1;
  1683. posx = 0x10000L;
  1684. while (posy >= 0x10000L) {
  1685. ++srcy;
  1686. posy -= 0x10000L;
  1687. }
  1688. while (n--) {
  1689. if (posx >= 0x10000L) {
  1690. while (posx >= 0x10000L) {
  1691. ++srcx;
  1692. posx -= 0x10000L;
  1693. }
  1694. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1695. }
  1696. srcpixel = *src;
  1697. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  1698. dstpixel = *dst;
  1699. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1700. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1701. /* This goes away if we ever use premultiplied alpha */
  1702. if (srcA < 255) {
  1703. srcR = (srcR * srcA) / 255;
  1704. srcG = (srcG * srcA) / 255;
  1705. srcB = (srcB * srcA) / 255;
  1706. }
  1707. }
  1708. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1709. case SDL_COPY_BLEND:
  1710. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1711. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1712. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1713. break;
  1714. case SDL_COPY_ADD:
  1715. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1716. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1717. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1718. break;
  1719. case SDL_COPY_MOD:
  1720. dstR = (srcR * dstR) / 255;
  1721. dstG = (srcG * dstG) / 255;
  1722. dstB = (srcB * dstB) / 255;
  1723. break;
  1724. }
  1725. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1726. *dst = dstpixel;
  1727. posx += incx;
  1728. ++dst;
  1729. }
  1730. posy += incy;
  1731. info->dst += info->dst_pitch;
  1732. }
  1733. }
  1734. static void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
  1735. {
  1736. const int flags = info->flags;
  1737. const Uint32 modulateR = info->r;
  1738. const Uint32 modulateG = info->g;
  1739. const Uint32 modulateB = info->b;
  1740. const Uint32 modulateA = info->a;
  1741. Uint32 pixel;
  1742. Uint32 R, G, B, A;
  1743. while (info->dst_h--) {
  1744. Uint32 *src = (Uint32 *)info->src;
  1745. Uint32 *dst = (Uint32 *)info->dst;
  1746. int n = info->dst_w;
  1747. while (n--) {
  1748. pixel = *src;
  1749. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  1750. if (flags & SDL_COPY_MODULATE_COLOR) {
  1751. R = (R * modulateR) / 255;
  1752. G = (G * modulateG) / 255;
  1753. B = (B * modulateB) / 255;
  1754. }
  1755. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1756. A = (A * modulateA) / 255;
  1757. }
  1758. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1759. *dst = pixel;
  1760. ++src;
  1761. ++dst;
  1762. }
  1763. info->src += info->src_pitch;
  1764. info->dst += info->dst_pitch;
  1765. }
  1766. }
  1767. static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  1768. {
  1769. const int flags = info->flags;
  1770. const Uint32 modulateR = info->r;
  1771. const Uint32 modulateG = info->g;
  1772. const Uint32 modulateB = info->b;
  1773. const Uint32 modulateA = info->a;
  1774. Uint32 pixel;
  1775. Uint32 R, G, B, A;
  1776. int srcy, srcx;
  1777. int posy, posx;
  1778. int incy, incx;
  1779. srcy = 0;
  1780. posy = 0;
  1781. incy = (info->src_h << 16) / info->dst_h;
  1782. incx = (info->src_w << 16) / info->dst_w;
  1783. while (info->dst_h--) {
  1784. Uint32 *src = 0;
  1785. Uint32 *dst = (Uint32 *)info->dst;
  1786. int n = info->dst_w;
  1787. srcx = -1;
  1788. posx = 0x10000L;
  1789. while (posy >= 0x10000L) {
  1790. ++srcy;
  1791. posy -= 0x10000L;
  1792. }
  1793. while (n--) {
  1794. if (posx >= 0x10000L) {
  1795. while (posx >= 0x10000L) {
  1796. ++srcx;
  1797. posx -= 0x10000L;
  1798. }
  1799. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1800. }
  1801. pixel = *src;
  1802. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  1803. if (flags & SDL_COPY_MODULATE_COLOR) {
  1804. R = (R * modulateR) / 255;
  1805. G = (G * modulateG) / 255;
  1806. B = (B * modulateB) / 255;
  1807. }
  1808. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1809. A = (A * modulateA) / 255;
  1810. }
  1811. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1812. *dst = pixel;
  1813. posx += incx;
  1814. ++dst;
  1815. }
  1816. posy += incy;
  1817. info->dst += info->dst_pitch;
  1818. }
  1819. }
  1820. static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  1821. {
  1822. const int flags = info->flags;
  1823. const Uint32 modulateR = info->r;
  1824. const Uint32 modulateG = info->g;
  1825. const Uint32 modulateB = info->b;
  1826. const Uint32 modulateA = info->a;
  1827. Uint32 srcpixel;
  1828. Uint32 srcR, srcG, srcB, srcA;
  1829. Uint32 dstpixel;
  1830. Uint32 dstR, dstG, dstB, dstA;
  1831. while (info->dst_h--) {
  1832. Uint32 *src = (Uint32 *)info->src;
  1833. Uint32 *dst = (Uint32 *)info->dst;
  1834. int n = info->dst_w;
  1835. while (n--) {
  1836. srcpixel = *src;
  1837. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  1838. dstpixel = *dst;
  1839. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1840. if (flags & SDL_COPY_MODULATE_COLOR) {
  1841. srcR = (srcR * modulateR) / 255;
  1842. srcG = (srcG * modulateG) / 255;
  1843. srcB = (srcB * modulateB) / 255;
  1844. }
  1845. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1846. srcA = (srcA * modulateA) / 255;
  1847. }
  1848. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1849. /* This goes away if we ever use premultiplied alpha */
  1850. if (srcA < 255) {
  1851. srcR = (srcR * srcA) / 255;
  1852. srcG = (srcG * srcA) / 255;
  1853. srcB = (srcB * srcA) / 255;
  1854. }
  1855. }
  1856. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1857. case SDL_COPY_BLEND:
  1858. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1859. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1860. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1861. break;
  1862. case SDL_COPY_ADD:
  1863. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1864. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1865. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1866. break;
  1867. case SDL_COPY_MOD:
  1868. dstR = (srcR * dstR) / 255;
  1869. dstG = (srcG * dstG) / 255;
  1870. dstB = (srcB * dstB) / 255;
  1871. break;
  1872. }
  1873. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1874. *dst = dstpixel;
  1875. ++src;
  1876. ++dst;
  1877. }
  1878. info->src += info->src_pitch;
  1879. info->dst += info->dst_pitch;
  1880. }
  1881. }
  1882. static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1883. {
  1884. const int flags = info->flags;
  1885. const Uint32 modulateR = info->r;
  1886. const Uint32 modulateG = info->g;
  1887. const Uint32 modulateB = info->b;
  1888. const Uint32 modulateA = info->a;
  1889. Uint32 srcpixel;
  1890. Uint32 srcR, srcG, srcB, srcA;
  1891. Uint32 dstpixel;
  1892. Uint32 dstR, dstG, dstB, dstA;
  1893. int srcy, srcx;
  1894. int posy, posx;
  1895. int incy, incx;
  1896. srcy = 0;
  1897. posy = 0;
  1898. incy = (info->src_h << 16) / info->dst_h;
  1899. incx = (info->src_w << 16) / info->dst_w;
  1900. while (info->dst_h--) {
  1901. Uint32 *src = 0;
  1902. Uint32 *dst = (Uint32 *)info->dst;
  1903. int n = info->dst_w;
  1904. srcx = -1;
  1905. posx = 0x10000L;
  1906. while (posy >= 0x10000L) {
  1907. ++srcy;
  1908. posy -= 0x10000L;
  1909. }
  1910. while (n--) {
  1911. if (posx >= 0x10000L) {
  1912. while (posx >= 0x10000L) {
  1913. ++srcx;
  1914. posx -= 0x10000L;
  1915. }
  1916. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1917. }
  1918. srcpixel = *src;
  1919. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  1920. dstpixel = *dst;
  1921. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1922. if (flags & SDL_COPY_MODULATE_COLOR) {
  1923. srcR = (srcR * modulateR) / 255;
  1924. srcG = (srcG * modulateG) / 255;
  1925. srcB = (srcB * modulateB) / 255;
  1926. }
  1927. if (flags & SDL_COPY_MODULATE_ALPHA) {
  1928. srcA = (srcA * modulateA) / 255;
  1929. }
  1930. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1931. /* This goes away if we ever use premultiplied alpha */
  1932. if (srcA < 255) {
  1933. srcR = (srcR * srcA) / 255;
  1934. srcG = (srcG * srcA) / 255;
  1935. srcB = (srcB * srcA) / 255;
  1936. }
  1937. }
  1938. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1939. case SDL_COPY_BLEND:
  1940. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1941. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1942. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1943. break;
  1944. case SDL_COPY_ADD:
  1945. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1946. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1947. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1948. break;
  1949. case SDL_COPY_MOD:
  1950. dstR = (srcR * dstR) / 255;
  1951. dstG = (srcG * dstG) / 255;
  1952. dstB = (srcB * dstB) / 255;
  1953. break;
  1954. }
  1955. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1956. *dst = dstpixel;
  1957. posx += incx;
  1958. ++dst;
  1959. }
  1960. posy += incy;
  1961. info->dst += info->dst_pitch;
  1962. }
  1963. }
  1964. static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info)
  1965. {
  1966. Uint32 pixel;
  1967. Uint32 R, G, B, A;
  1968. int srcy, srcx;
  1969. int posy, posx;
  1970. int incy, incx;
  1971. srcy = 0;
  1972. posy = 0;
  1973. incy = (info->src_h << 16) / info->dst_h;
  1974. incx = (info->src_w << 16) / info->dst_w;
  1975. while (info->dst_h--) {
  1976. Uint32 *src = 0;
  1977. Uint32 *dst = (Uint32 *)info->dst;
  1978. int n = info->dst_w;
  1979. srcx = -1;
  1980. posx = 0x10000L;
  1981. while (posy >= 0x10000L) {
  1982. ++srcy;
  1983. posy -= 0x10000L;
  1984. }
  1985. while (n--) {
  1986. if (posx >= 0x10000L) {
  1987. while (posx >= 0x10000L) {
  1988. ++srcx;
  1989. posx -= 0x10000L;
  1990. }
  1991. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1992. }
  1993. pixel = *src;
  1994. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  1995. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1996. *dst = pixel;
  1997. posx += incx;
  1998. ++dst;
  1999. }
  2000. posy += incy;
  2001. info->dst += info->dst_pitch;
  2002. }
  2003. }
  2004. static void SDL_Blit_BGR888_ARGB8888_Blend(SDL_BlitInfo *info)
  2005. {
  2006. const int flags = info->flags;
  2007. Uint32 srcpixel;
  2008. Uint32 srcR, srcG, srcB, srcA;
  2009. Uint32 dstpixel;
  2010. Uint32 dstR, dstG, dstB, dstA;
  2011. while (info->dst_h--) {
  2012. Uint32 *src = (Uint32 *)info->src;
  2013. Uint32 *dst = (Uint32 *)info->dst;
  2014. int n = info->dst_w;
  2015. while (n--) {
  2016. srcpixel = *src;
  2017. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  2018. dstpixel = *dst;
  2019. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  2020. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2021. /* This goes away if we ever use premultiplied alpha */
  2022. if (srcA < 255) {
  2023. srcR = (srcR * srcA) / 255;
  2024. srcG = (srcG * srcA) / 255;
  2025. srcB = (srcB * srcA) / 255;
  2026. }
  2027. }
  2028. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2029. case SDL_COPY_BLEND:
  2030. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2031. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2032. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2033. break;
  2034. case SDL_COPY_ADD:
  2035. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2036. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2037. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2038. break;
  2039. case SDL_COPY_MOD:
  2040. dstR = (srcR * dstR) / 255;
  2041. dstG = (srcG * dstG) / 255;
  2042. dstB = (srcB * dstB) / 255;
  2043. break;
  2044. }
  2045. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  2046. *dst = dstpixel;
  2047. ++src;
  2048. ++dst;
  2049. }
  2050. info->src += info->src_pitch;
  2051. info->dst += info->dst_pitch;
  2052. }
  2053. }
  2054. static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  2055. {
  2056. const int flags = info->flags;
  2057. Uint32 srcpixel;
  2058. Uint32 srcR, srcG, srcB, srcA;
  2059. Uint32 dstpixel;
  2060. Uint32 dstR, dstG, dstB, dstA;
  2061. int srcy, srcx;
  2062. int posy, posx;
  2063. int incy, incx;
  2064. srcy = 0;
  2065. posy = 0;
  2066. incy = (info->src_h << 16) / info->dst_h;
  2067. incx = (info->src_w << 16) / info->dst_w;
  2068. while (info->dst_h--) {
  2069. Uint32 *src = 0;
  2070. Uint32 *dst = (Uint32 *)info->dst;
  2071. int n = info->dst_w;
  2072. srcx = -1;
  2073. posx = 0x10000L;
  2074. while (posy >= 0x10000L) {
  2075. ++srcy;
  2076. posy -= 0x10000L;
  2077. }
  2078. while (n--) {
  2079. if (posx >= 0x10000L) {
  2080. while (posx >= 0x10000L) {
  2081. ++srcx;
  2082. posx -= 0x10000L;
  2083. }
  2084. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2085. }
  2086. srcpixel = *src;
  2087. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  2088. dstpixel = *dst;
  2089. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  2090. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2091. /* This goes away if we ever use premultiplied alpha */
  2092. if (srcA < 255) {
  2093. srcR = (srcR * srcA) / 255;
  2094. srcG = (srcG * srcA) / 255;
  2095. srcB = (srcB * srcA) / 255;
  2096. }
  2097. }
  2098. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2099. case SDL_COPY_BLEND:
  2100. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2101. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2102. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2103. break;
  2104. case SDL_COPY_ADD:
  2105. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2106. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2107. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2108. break;
  2109. case SDL_COPY_MOD:
  2110. dstR = (srcR * dstR) / 255;
  2111. dstG = (srcG * dstG) / 255;
  2112. dstB = (srcB * dstB) / 255;
  2113. break;
  2114. }
  2115. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  2116. *dst = dstpixel;
  2117. posx += incx;
  2118. ++dst;
  2119. }
  2120. posy += incy;
  2121. info->dst += info->dst_pitch;
  2122. }
  2123. }
  2124. static void SDL_Blit_BGR888_ARGB8888_Modulate(SDL_BlitInfo *info)
  2125. {
  2126. const int flags = info->flags;
  2127. const Uint32 modulateR = info->r;
  2128. const Uint32 modulateG = info->g;
  2129. const Uint32 modulateB = info->b;
  2130. const Uint32 modulateA = info->a;
  2131. Uint32 pixel;
  2132. Uint32 R, G, B, A;
  2133. while (info->dst_h--) {
  2134. Uint32 *src = (Uint32 *)info->src;
  2135. Uint32 *dst = (Uint32 *)info->dst;
  2136. int n = info->dst_w;
  2137. while (n--) {
  2138. pixel = *src;
  2139. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  2140. if (flags & SDL_COPY_MODULATE_COLOR) {
  2141. R = (R * modulateR) / 255;
  2142. G = (G * modulateG) / 255;
  2143. B = (B * modulateB) / 255;
  2144. }
  2145. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2146. A = (A * modulateA) / 255;
  2147. }
  2148. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  2149. *dst = pixel;
  2150. ++src;
  2151. ++dst;
  2152. }
  2153. info->src += info->src_pitch;
  2154. info->dst += info->dst_pitch;
  2155. }
  2156. }
  2157. static void SDL_Blit_BGR888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  2158. {
  2159. const int flags = info->flags;
  2160. const Uint32 modulateR = info->r;
  2161. const Uint32 modulateG = info->g;
  2162. const Uint32 modulateB = info->b;
  2163. const Uint32 modulateA = info->a;
  2164. Uint32 pixel;
  2165. Uint32 R, G, B, A;
  2166. int srcy, srcx;
  2167. int posy, posx;
  2168. int incy, incx;
  2169. srcy = 0;
  2170. posy = 0;
  2171. incy = (info->src_h << 16) / info->dst_h;
  2172. incx = (info->src_w << 16) / info->dst_w;
  2173. while (info->dst_h--) {
  2174. Uint32 *src = 0;
  2175. Uint32 *dst = (Uint32 *)info->dst;
  2176. int n = info->dst_w;
  2177. srcx = -1;
  2178. posx = 0x10000L;
  2179. while (posy >= 0x10000L) {
  2180. ++srcy;
  2181. posy -= 0x10000L;
  2182. }
  2183. while (n--) {
  2184. if (posx >= 0x10000L) {
  2185. while (posx >= 0x10000L) {
  2186. ++srcx;
  2187. posx -= 0x10000L;
  2188. }
  2189. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2190. }
  2191. pixel = *src;
  2192. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  2193. if (flags & SDL_COPY_MODULATE_COLOR) {
  2194. R = (R * modulateR) / 255;
  2195. G = (G * modulateG) / 255;
  2196. B = (B * modulateB) / 255;
  2197. }
  2198. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2199. A = (A * modulateA) / 255;
  2200. }
  2201. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  2202. *dst = pixel;
  2203. posx += incx;
  2204. ++dst;
  2205. }
  2206. posy += incy;
  2207. info->dst += info->dst_pitch;
  2208. }
  2209. }
  2210. static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  2211. {
  2212. const int flags = info->flags;
  2213. const Uint32 modulateR = info->r;
  2214. const Uint32 modulateG = info->g;
  2215. const Uint32 modulateB = info->b;
  2216. const Uint32 modulateA = info->a;
  2217. Uint32 srcpixel;
  2218. Uint32 srcR, srcG, srcB, srcA;
  2219. Uint32 dstpixel;
  2220. Uint32 dstR, dstG, dstB, dstA;
  2221. while (info->dst_h--) {
  2222. Uint32 *src = (Uint32 *)info->src;
  2223. Uint32 *dst = (Uint32 *)info->dst;
  2224. int n = info->dst_w;
  2225. while (n--) {
  2226. srcpixel = *src;
  2227. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  2228. dstpixel = *dst;
  2229. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  2230. if (flags & SDL_COPY_MODULATE_COLOR) {
  2231. srcR = (srcR * modulateR) / 255;
  2232. srcG = (srcG * modulateG) / 255;
  2233. srcB = (srcB * modulateB) / 255;
  2234. }
  2235. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2236. srcA = (srcA * modulateA) / 255;
  2237. }
  2238. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2239. /* This goes away if we ever use premultiplied alpha */
  2240. if (srcA < 255) {
  2241. srcR = (srcR * srcA) / 255;
  2242. srcG = (srcG * srcA) / 255;
  2243. srcB = (srcB * srcA) / 255;
  2244. }
  2245. }
  2246. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2247. case SDL_COPY_BLEND:
  2248. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2249. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2250. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2251. break;
  2252. case SDL_COPY_ADD:
  2253. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2254. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2255. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2256. break;
  2257. case SDL_COPY_MOD:
  2258. dstR = (srcR * dstR) / 255;
  2259. dstG = (srcG * dstG) / 255;
  2260. dstB = (srcB * dstB) / 255;
  2261. break;
  2262. }
  2263. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  2264. *dst = dstpixel;
  2265. ++src;
  2266. ++dst;
  2267. }
  2268. info->src += info->src_pitch;
  2269. info->dst += info->dst_pitch;
  2270. }
  2271. }
  2272. static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  2273. {
  2274. const int flags = info->flags;
  2275. const Uint32 modulateR = info->r;
  2276. const Uint32 modulateG = info->g;
  2277. const Uint32 modulateB = info->b;
  2278. const Uint32 modulateA = info->a;
  2279. Uint32 srcpixel;
  2280. Uint32 srcR, srcG, srcB, srcA;
  2281. Uint32 dstpixel;
  2282. Uint32 dstR, dstG, dstB, dstA;
  2283. int srcy, srcx;
  2284. int posy, posx;
  2285. int incy, incx;
  2286. srcy = 0;
  2287. posy = 0;
  2288. incy = (info->src_h << 16) / info->dst_h;
  2289. incx = (info->src_w << 16) / info->dst_w;
  2290. while (info->dst_h--) {
  2291. Uint32 *src = 0;
  2292. Uint32 *dst = (Uint32 *)info->dst;
  2293. int n = info->dst_w;
  2294. srcx = -1;
  2295. posx = 0x10000L;
  2296. while (posy >= 0x10000L) {
  2297. ++srcy;
  2298. posy -= 0x10000L;
  2299. }
  2300. while (n--) {
  2301. if (posx >= 0x10000L) {
  2302. while (posx >= 0x10000L) {
  2303. ++srcx;
  2304. posx -= 0x10000L;
  2305. }
  2306. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2307. }
  2308. srcpixel = *src;
  2309. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
  2310. dstpixel = *dst;
  2311. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  2312. if (flags & SDL_COPY_MODULATE_COLOR) {
  2313. srcR = (srcR * modulateR) / 255;
  2314. srcG = (srcG * modulateG) / 255;
  2315. srcB = (srcB * modulateB) / 255;
  2316. }
  2317. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2318. srcA = (srcA * modulateA) / 255;
  2319. }
  2320. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2321. /* This goes away if we ever use premultiplied alpha */
  2322. if (srcA < 255) {
  2323. srcR = (srcR * srcA) / 255;
  2324. srcG = (srcG * srcA) / 255;
  2325. srcB = (srcB * srcA) / 255;
  2326. }
  2327. }
  2328. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2329. case SDL_COPY_BLEND:
  2330. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2331. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2332. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2333. break;
  2334. case SDL_COPY_ADD:
  2335. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2336. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2337. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2338. break;
  2339. case SDL_COPY_MOD:
  2340. dstR = (srcR * dstR) / 255;
  2341. dstG = (srcG * dstG) / 255;
  2342. dstB = (srcB * dstB) / 255;
  2343. break;
  2344. }
  2345. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  2346. *dst = dstpixel;
  2347. posx += incx;
  2348. ++dst;
  2349. }
  2350. posy += incy;
  2351. info->dst += info->dst_pitch;
  2352. }
  2353. }
  2354. static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
  2355. {
  2356. Uint32 pixel;
  2357. Uint32 R, G, B, A;
  2358. int srcy, srcx;
  2359. int posy, posx;
  2360. int incy, incx;
  2361. srcy = 0;
  2362. posy = 0;
  2363. incy = (info->src_h << 16) / info->dst_h;
  2364. incx = (info->src_w << 16) / info->dst_w;
  2365. while (info->dst_h--) {
  2366. Uint32 *src = 0;
  2367. Uint32 *dst = (Uint32 *)info->dst;
  2368. int n = info->dst_w;
  2369. srcx = -1;
  2370. posx = 0x10000L;
  2371. while (posy >= 0x10000L) {
  2372. ++srcy;
  2373. posy -= 0x10000L;
  2374. }
  2375. while (n--) {
  2376. if (posx >= 0x10000L) {
  2377. while (posx >= 0x10000L) {
  2378. ++srcx;
  2379. posx -= 0x10000L;
  2380. }
  2381. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2382. }
  2383. pixel = *src;
  2384. A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2385. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  2386. *dst = pixel;
  2387. posx += incx;
  2388. ++dst;
  2389. }
  2390. posy += incy;
  2391. info->dst += info->dst_pitch;
  2392. }
  2393. }
  2394. static void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
  2395. {
  2396. const int flags = info->flags;
  2397. Uint32 srcpixel;
  2398. Uint32 srcR, srcG, srcB, srcA;
  2399. Uint32 dstpixel;
  2400. Uint32 dstR, dstG, dstB, dstA;
  2401. while (info->dst_h--) {
  2402. Uint32 *src = (Uint32 *)info->src;
  2403. Uint32 *dst = (Uint32 *)info->dst;
  2404. int n = info->dst_w;
  2405. while (n--) {
  2406. srcpixel = *src;
  2407. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  2408. dstpixel = *dst;
  2409. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  2410. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2411. /* This goes away if we ever use premultiplied alpha */
  2412. if (srcA < 255) {
  2413. srcR = (srcR * srcA) / 255;
  2414. srcG = (srcG * srcA) / 255;
  2415. srcB = (srcB * srcA) / 255;
  2416. }
  2417. }
  2418. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2419. case SDL_COPY_BLEND:
  2420. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2421. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2422. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2423. break;
  2424. case SDL_COPY_ADD:
  2425. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2426. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2427. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2428. break;
  2429. case SDL_COPY_MOD:
  2430. dstR = (srcR * dstR) / 255;
  2431. dstG = (srcG * dstG) / 255;
  2432. dstB = (srcB * dstB) / 255;
  2433. break;
  2434. }
  2435. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  2436. *dst = dstpixel;
  2437. ++src;
  2438. ++dst;
  2439. }
  2440. info->src += info->src_pitch;
  2441. info->dst += info->dst_pitch;
  2442. }
  2443. }
  2444. static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  2445. {
  2446. const int flags = info->flags;
  2447. Uint32 srcpixel;
  2448. Uint32 srcR, srcG, srcB, srcA;
  2449. Uint32 dstpixel;
  2450. Uint32 dstR, dstG, dstB, dstA;
  2451. int srcy, srcx;
  2452. int posy, posx;
  2453. int incy, incx;
  2454. srcy = 0;
  2455. posy = 0;
  2456. incy = (info->src_h << 16) / info->dst_h;
  2457. incx = (info->src_w << 16) / info->dst_w;
  2458. while (info->dst_h--) {
  2459. Uint32 *src = 0;
  2460. Uint32 *dst = (Uint32 *)info->dst;
  2461. int n = info->dst_w;
  2462. srcx = -1;
  2463. posx = 0x10000L;
  2464. while (posy >= 0x10000L) {
  2465. ++srcy;
  2466. posy -= 0x10000L;
  2467. }
  2468. while (n--) {
  2469. if (posx >= 0x10000L) {
  2470. while (posx >= 0x10000L) {
  2471. ++srcx;
  2472. posx -= 0x10000L;
  2473. }
  2474. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2475. }
  2476. srcpixel = *src;
  2477. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  2478. dstpixel = *dst;
  2479. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  2480. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2481. /* This goes away if we ever use premultiplied alpha */
  2482. if (srcA < 255) {
  2483. srcR = (srcR * srcA) / 255;
  2484. srcG = (srcG * srcA) / 255;
  2485. srcB = (srcB * srcA) / 255;
  2486. }
  2487. }
  2488. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2489. case SDL_COPY_BLEND:
  2490. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2491. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2492. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2493. break;
  2494. case SDL_COPY_ADD:
  2495. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2496. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2497. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2498. break;
  2499. case SDL_COPY_MOD:
  2500. dstR = (srcR * dstR) / 255;
  2501. dstG = (srcG * dstG) / 255;
  2502. dstB = (srcB * dstB) / 255;
  2503. break;
  2504. }
  2505. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  2506. *dst = dstpixel;
  2507. posx += incx;
  2508. ++dst;
  2509. }
  2510. posy += incy;
  2511. info->dst += info->dst_pitch;
  2512. }
  2513. }
  2514. static void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
  2515. {
  2516. const int flags = info->flags;
  2517. const Uint32 modulateR = info->r;
  2518. const Uint32 modulateG = info->g;
  2519. const Uint32 modulateB = info->b;
  2520. const Uint32 modulateA = info->a;
  2521. Uint32 pixel;
  2522. Uint32 R, G, B, A;
  2523. while (info->dst_h--) {
  2524. Uint32 *src = (Uint32 *)info->src;
  2525. Uint32 *dst = (Uint32 *)info->dst;
  2526. int n = info->dst_w;
  2527. while (n--) {
  2528. pixel = *src;
  2529. A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2530. if (flags & SDL_COPY_MODULATE_COLOR) {
  2531. R = (R * modulateR) / 255;
  2532. G = (G * modulateG) / 255;
  2533. B = (B * modulateB) / 255;
  2534. }
  2535. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2536. A = (A * modulateA) / 255;
  2537. }
  2538. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  2539. *dst = pixel;
  2540. ++src;
  2541. ++dst;
  2542. }
  2543. info->src += info->src_pitch;
  2544. info->dst += info->dst_pitch;
  2545. }
  2546. }
  2547. static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  2548. {
  2549. const int flags = info->flags;
  2550. const Uint32 modulateR = info->r;
  2551. const Uint32 modulateG = info->g;
  2552. const Uint32 modulateB = info->b;
  2553. const Uint32 modulateA = info->a;
  2554. Uint32 pixel;
  2555. Uint32 R, G, B, A;
  2556. int srcy, srcx;
  2557. int posy, posx;
  2558. int incy, incx;
  2559. srcy = 0;
  2560. posy = 0;
  2561. incy = (info->src_h << 16) / info->dst_h;
  2562. incx = (info->src_w << 16) / info->dst_w;
  2563. while (info->dst_h--) {
  2564. Uint32 *src = 0;
  2565. Uint32 *dst = (Uint32 *)info->dst;
  2566. int n = info->dst_w;
  2567. srcx = -1;
  2568. posx = 0x10000L;
  2569. while (posy >= 0x10000L) {
  2570. ++srcy;
  2571. posy -= 0x10000L;
  2572. }
  2573. while (n--) {
  2574. if (posx >= 0x10000L) {
  2575. while (posx >= 0x10000L) {
  2576. ++srcx;
  2577. posx -= 0x10000L;
  2578. }
  2579. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2580. }
  2581. pixel = *src;
  2582. A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2583. if (flags & SDL_COPY_MODULATE_COLOR) {
  2584. R = (R * modulateR) / 255;
  2585. G = (G * modulateG) / 255;
  2586. B = (B * modulateB) / 255;
  2587. }
  2588. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2589. A = (A * modulateA) / 255;
  2590. }
  2591. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  2592. *dst = pixel;
  2593. posx += incx;
  2594. ++dst;
  2595. }
  2596. posy += incy;
  2597. info->dst += info->dst_pitch;
  2598. }
  2599. }
  2600. static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  2601. {
  2602. const int flags = info->flags;
  2603. const Uint32 modulateR = info->r;
  2604. const Uint32 modulateG = info->g;
  2605. const Uint32 modulateB = info->b;
  2606. const Uint32 modulateA = info->a;
  2607. Uint32 srcpixel;
  2608. Uint32 srcR, srcG, srcB, srcA;
  2609. Uint32 dstpixel;
  2610. Uint32 dstR, dstG, dstB, dstA;
  2611. while (info->dst_h--) {
  2612. Uint32 *src = (Uint32 *)info->src;
  2613. Uint32 *dst = (Uint32 *)info->dst;
  2614. int n = info->dst_w;
  2615. while (n--) {
  2616. srcpixel = *src;
  2617. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  2618. dstpixel = *dst;
  2619. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  2620. if (flags & SDL_COPY_MODULATE_COLOR) {
  2621. srcR = (srcR * modulateR) / 255;
  2622. srcG = (srcG * modulateG) / 255;
  2623. srcB = (srcB * modulateB) / 255;
  2624. }
  2625. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2626. srcA = (srcA * modulateA) / 255;
  2627. }
  2628. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2629. /* This goes away if we ever use premultiplied alpha */
  2630. if (srcA < 255) {
  2631. srcR = (srcR * srcA) / 255;
  2632. srcG = (srcG * srcA) / 255;
  2633. srcB = (srcB * srcA) / 255;
  2634. }
  2635. }
  2636. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2637. case SDL_COPY_BLEND:
  2638. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2639. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2640. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2641. break;
  2642. case SDL_COPY_ADD:
  2643. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2644. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2645. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2646. break;
  2647. case SDL_COPY_MOD:
  2648. dstR = (srcR * dstR) / 255;
  2649. dstG = (srcG * dstG) / 255;
  2650. dstB = (srcB * dstB) / 255;
  2651. break;
  2652. }
  2653. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  2654. *dst = dstpixel;
  2655. ++src;
  2656. ++dst;
  2657. }
  2658. info->src += info->src_pitch;
  2659. info->dst += info->dst_pitch;
  2660. }
  2661. }
  2662. static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  2663. {
  2664. const int flags = info->flags;
  2665. const Uint32 modulateR = info->r;
  2666. const Uint32 modulateG = info->g;
  2667. const Uint32 modulateB = info->b;
  2668. const Uint32 modulateA = info->a;
  2669. Uint32 srcpixel;
  2670. Uint32 srcR, srcG, srcB, srcA;
  2671. Uint32 dstpixel;
  2672. Uint32 dstR, dstG, dstB, dstA;
  2673. int srcy, srcx;
  2674. int posy, posx;
  2675. int incy, incx;
  2676. srcy = 0;
  2677. posy = 0;
  2678. incy = (info->src_h << 16) / info->dst_h;
  2679. incx = (info->src_w << 16) / info->dst_w;
  2680. while (info->dst_h--) {
  2681. Uint32 *src = 0;
  2682. Uint32 *dst = (Uint32 *)info->dst;
  2683. int n = info->dst_w;
  2684. srcx = -1;
  2685. posx = 0x10000L;
  2686. while (posy >= 0x10000L) {
  2687. ++srcy;
  2688. posy -= 0x10000L;
  2689. }
  2690. while (n--) {
  2691. if (posx >= 0x10000L) {
  2692. while (posx >= 0x10000L) {
  2693. ++srcx;
  2694. posx -= 0x10000L;
  2695. }
  2696. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2697. }
  2698. srcpixel = *src;
  2699. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  2700. dstpixel = *dst;
  2701. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  2702. if (flags & SDL_COPY_MODULATE_COLOR) {
  2703. srcR = (srcR * modulateR) / 255;
  2704. srcG = (srcG * modulateG) / 255;
  2705. srcB = (srcB * modulateB) / 255;
  2706. }
  2707. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2708. srcA = (srcA * modulateA) / 255;
  2709. }
  2710. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2711. /* This goes away if we ever use premultiplied alpha */
  2712. if (srcA < 255) {
  2713. srcR = (srcR * srcA) / 255;
  2714. srcG = (srcG * srcA) / 255;
  2715. srcB = (srcB * srcA) / 255;
  2716. }
  2717. }
  2718. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2719. case SDL_COPY_BLEND:
  2720. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2721. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2722. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2723. break;
  2724. case SDL_COPY_ADD:
  2725. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2726. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2727. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2728. break;
  2729. case SDL_COPY_MOD:
  2730. dstR = (srcR * dstR) / 255;
  2731. dstG = (srcG * dstG) / 255;
  2732. dstB = (srcB * dstB) / 255;
  2733. break;
  2734. }
  2735. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  2736. *dst = dstpixel;
  2737. posx += incx;
  2738. ++dst;
  2739. }
  2740. posy += incy;
  2741. info->dst += info->dst_pitch;
  2742. }
  2743. }
  2744. static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
  2745. {
  2746. Uint32 pixel;
  2747. Uint32 R, G, B, A;
  2748. int srcy, srcx;
  2749. int posy, posx;
  2750. int incy, incx;
  2751. srcy = 0;
  2752. posy = 0;
  2753. incy = (info->src_h << 16) / info->dst_h;
  2754. incx = (info->src_w << 16) / info->dst_w;
  2755. while (info->dst_h--) {
  2756. Uint32 *src = 0;
  2757. Uint32 *dst = (Uint32 *)info->dst;
  2758. int n = info->dst_w;
  2759. srcx = -1;
  2760. posx = 0x10000L;
  2761. while (posy >= 0x10000L) {
  2762. ++srcy;
  2763. posy -= 0x10000L;
  2764. }
  2765. while (n--) {
  2766. if (posx >= 0x10000L) {
  2767. while (posx >= 0x10000L) {
  2768. ++srcx;
  2769. posx -= 0x10000L;
  2770. }
  2771. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2772. }
  2773. pixel = *src;
  2774. A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2775. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  2776. *dst = pixel;
  2777. posx += incx;
  2778. ++dst;
  2779. }
  2780. posy += incy;
  2781. info->dst += info->dst_pitch;
  2782. }
  2783. }
  2784. static void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
  2785. {
  2786. const int flags = info->flags;
  2787. Uint32 srcpixel;
  2788. Uint32 srcR, srcG, srcB, srcA;
  2789. Uint32 dstpixel;
  2790. Uint32 dstR, dstG, dstB, dstA;
  2791. while (info->dst_h--) {
  2792. Uint32 *src = (Uint32 *)info->src;
  2793. Uint32 *dst = (Uint32 *)info->dst;
  2794. int n = info->dst_w;
  2795. while (n--) {
  2796. srcpixel = *src;
  2797. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  2798. dstpixel = *dst;
  2799. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  2800. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2801. /* This goes away if we ever use premultiplied alpha */
  2802. if (srcA < 255) {
  2803. srcR = (srcR * srcA) / 255;
  2804. srcG = (srcG * srcA) / 255;
  2805. srcB = (srcB * srcA) / 255;
  2806. }
  2807. }
  2808. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2809. case SDL_COPY_BLEND:
  2810. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2811. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2812. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2813. break;
  2814. case SDL_COPY_ADD:
  2815. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2816. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2817. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2818. break;
  2819. case SDL_COPY_MOD:
  2820. dstR = (srcR * dstR) / 255;
  2821. dstG = (srcG * dstG) / 255;
  2822. dstB = (srcB * dstB) / 255;
  2823. break;
  2824. }
  2825. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  2826. *dst = dstpixel;
  2827. ++src;
  2828. ++dst;
  2829. }
  2830. info->src += info->src_pitch;
  2831. info->dst += info->dst_pitch;
  2832. }
  2833. }
  2834. static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  2835. {
  2836. const int flags = info->flags;
  2837. Uint32 srcpixel;
  2838. Uint32 srcR, srcG, srcB, srcA;
  2839. Uint32 dstpixel;
  2840. Uint32 dstR, dstG, dstB, dstA;
  2841. int srcy, srcx;
  2842. int posy, posx;
  2843. int incy, incx;
  2844. srcy = 0;
  2845. posy = 0;
  2846. incy = (info->src_h << 16) / info->dst_h;
  2847. incx = (info->src_w << 16) / info->dst_w;
  2848. while (info->dst_h--) {
  2849. Uint32 *src = 0;
  2850. Uint32 *dst = (Uint32 *)info->dst;
  2851. int n = info->dst_w;
  2852. srcx = -1;
  2853. posx = 0x10000L;
  2854. while (posy >= 0x10000L) {
  2855. ++srcy;
  2856. posy -= 0x10000L;
  2857. }
  2858. while (n--) {
  2859. if (posx >= 0x10000L) {
  2860. while (posx >= 0x10000L) {
  2861. ++srcx;
  2862. posx -= 0x10000L;
  2863. }
  2864. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2865. }
  2866. srcpixel = *src;
  2867. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  2868. dstpixel = *dst;
  2869. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  2870. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2871. /* This goes away if we ever use premultiplied alpha */
  2872. if (srcA < 255) {
  2873. srcR = (srcR * srcA) / 255;
  2874. srcG = (srcG * srcA) / 255;
  2875. srcB = (srcB * srcA) / 255;
  2876. }
  2877. }
  2878. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  2879. case SDL_COPY_BLEND:
  2880. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2881. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2882. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2883. break;
  2884. case SDL_COPY_ADD:
  2885. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2886. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2887. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2888. break;
  2889. case SDL_COPY_MOD:
  2890. dstR = (srcR * dstR) / 255;
  2891. dstG = (srcG * dstG) / 255;
  2892. dstB = (srcB * dstB) / 255;
  2893. break;
  2894. }
  2895. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  2896. *dst = dstpixel;
  2897. posx += incx;
  2898. ++dst;
  2899. }
  2900. posy += incy;
  2901. info->dst += info->dst_pitch;
  2902. }
  2903. }
  2904. static void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
  2905. {
  2906. const int flags = info->flags;
  2907. const Uint32 modulateR = info->r;
  2908. const Uint32 modulateG = info->g;
  2909. const Uint32 modulateB = info->b;
  2910. const Uint32 modulateA = info->a;
  2911. Uint32 pixel;
  2912. Uint32 R, G, B, A;
  2913. while (info->dst_h--) {
  2914. Uint32 *src = (Uint32 *)info->src;
  2915. Uint32 *dst = (Uint32 *)info->dst;
  2916. int n = info->dst_w;
  2917. while (n--) {
  2918. pixel = *src;
  2919. A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2920. if (flags & SDL_COPY_MODULATE_COLOR) {
  2921. R = (R * modulateR) / 255;
  2922. G = (G * modulateG) / 255;
  2923. B = (B * modulateB) / 255;
  2924. }
  2925. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2926. A = (A * modulateA) / 255;
  2927. }
  2928. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  2929. *dst = pixel;
  2930. ++src;
  2931. ++dst;
  2932. }
  2933. info->src += info->src_pitch;
  2934. info->dst += info->dst_pitch;
  2935. }
  2936. }
  2937. static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  2938. {
  2939. const int flags = info->flags;
  2940. const Uint32 modulateR = info->r;
  2941. const Uint32 modulateG = info->g;
  2942. const Uint32 modulateB = info->b;
  2943. const Uint32 modulateA = info->a;
  2944. Uint32 pixel;
  2945. Uint32 R, G, B, A;
  2946. int srcy, srcx;
  2947. int posy, posx;
  2948. int incy, incx;
  2949. srcy = 0;
  2950. posy = 0;
  2951. incy = (info->src_h << 16) / info->dst_h;
  2952. incx = (info->src_w << 16) / info->dst_w;
  2953. while (info->dst_h--) {
  2954. Uint32 *src = 0;
  2955. Uint32 *dst = (Uint32 *)info->dst;
  2956. int n = info->dst_w;
  2957. srcx = -1;
  2958. posx = 0x10000L;
  2959. while (posy >= 0x10000L) {
  2960. ++srcy;
  2961. posy -= 0x10000L;
  2962. }
  2963. while (n--) {
  2964. if (posx >= 0x10000L) {
  2965. while (posx >= 0x10000L) {
  2966. ++srcx;
  2967. posx -= 0x10000L;
  2968. }
  2969. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2970. }
  2971. pixel = *src;
  2972. A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2973. if (flags & SDL_COPY_MODULATE_COLOR) {
  2974. R = (R * modulateR) / 255;
  2975. G = (G * modulateG) / 255;
  2976. B = (B * modulateB) / 255;
  2977. }
  2978. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2979. A = (A * modulateA) / 255;
  2980. }
  2981. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  2982. *dst = pixel;
  2983. posx += incx;
  2984. ++dst;
  2985. }
  2986. posy += incy;
  2987. info->dst += info->dst_pitch;
  2988. }
  2989. }
  2990. static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  2991. {
  2992. const int flags = info->flags;
  2993. const Uint32 modulateR = info->r;
  2994. const Uint32 modulateG = info->g;
  2995. const Uint32 modulateB = info->b;
  2996. const Uint32 modulateA = info->a;
  2997. Uint32 srcpixel;
  2998. Uint32 srcR, srcG, srcB, srcA;
  2999. Uint32 dstpixel;
  3000. Uint32 dstR, dstG, dstB, dstA;
  3001. while (info->dst_h--) {
  3002. Uint32 *src = (Uint32 *)info->src;
  3003. Uint32 *dst = (Uint32 *)info->dst;
  3004. int n = info->dst_w;
  3005. while (n--) {
  3006. srcpixel = *src;
  3007. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3008. dstpixel = *dst;
  3009. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3010. if (flags & SDL_COPY_MODULATE_COLOR) {
  3011. srcR = (srcR * modulateR) / 255;
  3012. srcG = (srcG * modulateG) / 255;
  3013. srcB = (srcB * modulateB) / 255;
  3014. }
  3015. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3016. srcA = (srcA * modulateA) / 255;
  3017. }
  3018. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3019. /* This goes away if we ever use premultiplied alpha */
  3020. if (srcA < 255) {
  3021. srcR = (srcR * srcA) / 255;
  3022. srcG = (srcG * srcA) / 255;
  3023. srcB = (srcB * srcA) / 255;
  3024. }
  3025. }
  3026. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3027. case SDL_COPY_BLEND:
  3028. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3029. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3030. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3031. break;
  3032. case SDL_COPY_ADD:
  3033. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3034. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3035. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3036. break;
  3037. case SDL_COPY_MOD:
  3038. dstR = (srcR * dstR) / 255;
  3039. dstG = (srcG * dstG) / 255;
  3040. dstB = (srcB * dstB) / 255;
  3041. break;
  3042. }
  3043. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3044. *dst = dstpixel;
  3045. ++src;
  3046. ++dst;
  3047. }
  3048. info->src += info->src_pitch;
  3049. info->dst += info->dst_pitch;
  3050. }
  3051. }
  3052. static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3053. {
  3054. const int flags = info->flags;
  3055. const Uint32 modulateR = info->r;
  3056. const Uint32 modulateG = info->g;
  3057. const Uint32 modulateB = info->b;
  3058. const Uint32 modulateA = info->a;
  3059. Uint32 srcpixel;
  3060. Uint32 srcR, srcG, srcB, srcA;
  3061. Uint32 dstpixel;
  3062. Uint32 dstR, dstG, dstB, dstA;
  3063. int srcy, srcx;
  3064. int posy, posx;
  3065. int incy, incx;
  3066. srcy = 0;
  3067. posy = 0;
  3068. incy = (info->src_h << 16) / info->dst_h;
  3069. incx = (info->src_w << 16) / info->dst_w;
  3070. while (info->dst_h--) {
  3071. Uint32 *src = 0;
  3072. Uint32 *dst = (Uint32 *)info->dst;
  3073. int n = info->dst_w;
  3074. srcx = -1;
  3075. posx = 0x10000L;
  3076. while (posy >= 0x10000L) {
  3077. ++srcy;
  3078. posy -= 0x10000L;
  3079. }
  3080. while (n--) {
  3081. if (posx >= 0x10000L) {
  3082. while (posx >= 0x10000L) {
  3083. ++srcx;
  3084. posx -= 0x10000L;
  3085. }
  3086. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3087. }
  3088. srcpixel = *src;
  3089. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3090. dstpixel = *dst;
  3091. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3092. if (flags & SDL_COPY_MODULATE_COLOR) {
  3093. srcR = (srcR * modulateR) / 255;
  3094. srcG = (srcG * modulateG) / 255;
  3095. srcB = (srcB * modulateB) / 255;
  3096. }
  3097. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3098. srcA = (srcA * modulateA) / 255;
  3099. }
  3100. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3101. /* This goes away if we ever use premultiplied alpha */
  3102. if (srcA < 255) {
  3103. srcR = (srcR * srcA) / 255;
  3104. srcG = (srcG * srcA) / 255;
  3105. srcB = (srcB * srcA) / 255;
  3106. }
  3107. }
  3108. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3109. case SDL_COPY_BLEND:
  3110. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3111. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3112. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3113. break;
  3114. case SDL_COPY_ADD:
  3115. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3116. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3117. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3118. break;
  3119. case SDL_COPY_MOD:
  3120. dstR = (srcR * dstR) / 255;
  3121. dstG = (srcG * dstG) / 255;
  3122. dstB = (srcB * dstB) / 255;
  3123. break;
  3124. }
  3125. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3126. *dst = dstpixel;
  3127. posx += incx;
  3128. ++dst;
  3129. }
  3130. posy += incy;
  3131. info->dst += info->dst_pitch;
  3132. }
  3133. }
  3134. static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
  3135. {
  3136. int srcy, srcx;
  3137. int posy, posx;
  3138. int incy, incx;
  3139. srcy = 0;
  3140. posy = 0;
  3141. incy = (info->src_h << 16) / info->dst_h;
  3142. incx = (info->src_w << 16) / info->dst_w;
  3143. while (info->dst_h--) {
  3144. Uint32 *src = 0;
  3145. Uint32 *dst = (Uint32 *)info->dst;
  3146. int n = info->dst_w;
  3147. srcx = -1;
  3148. posx = 0x10000L;
  3149. while (posy >= 0x10000L) {
  3150. ++srcy;
  3151. posy -= 0x10000L;
  3152. }
  3153. while (n--) {
  3154. if (posx >= 0x10000L) {
  3155. while (posx >= 0x10000L) {
  3156. ++srcx;
  3157. posx -= 0x10000L;
  3158. }
  3159. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3160. }
  3161. *dst = *src;
  3162. posx += incx;
  3163. ++dst;
  3164. }
  3165. posy += incy;
  3166. info->dst += info->dst_pitch;
  3167. }
  3168. }
  3169. static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
  3170. {
  3171. const int flags = info->flags;
  3172. Uint32 srcpixel;
  3173. Uint32 srcR, srcG, srcB, srcA;
  3174. Uint32 dstpixel;
  3175. Uint32 dstR, dstG, dstB, dstA;
  3176. while (info->dst_h--) {
  3177. Uint32 *src = (Uint32 *)info->src;
  3178. Uint32 *dst = (Uint32 *)info->dst;
  3179. int n = info->dst_w;
  3180. while (n--) {
  3181. srcpixel = *src;
  3182. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3183. dstpixel = *dst;
  3184. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3185. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3186. /* This goes away if we ever use premultiplied alpha */
  3187. if (srcA < 255) {
  3188. srcR = (srcR * srcA) / 255;
  3189. srcG = (srcG * srcA) / 255;
  3190. srcB = (srcB * srcA) / 255;
  3191. }
  3192. }
  3193. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3194. case SDL_COPY_BLEND:
  3195. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3196. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3197. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3198. break;
  3199. case SDL_COPY_ADD:
  3200. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3201. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3202. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3203. break;
  3204. case SDL_COPY_MOD:
  3205. dstR = (srcR * dstR) / 255;
  3206. dstG = (srcG * dstG) / 255;
  3207. dstB = (srcB * dstB) / 255;
  3208. break;
  3209. }
  3210. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3211. *dst = dstpixel;
  3212. ++src;
  3213. ++dst;
  3214. }
  3215. info->src += info->src_pitch;
  3216. info->dst += info->dst_pitch;
  3217. }
  3218. }
  3219. static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  3220. {
  3221. const int flags = info->flags;
  3222. Uint32 srcpixel;
  3223. Uint32 srcR, srcG, srcB, srcA;
  3224. Uint32 dstpixel;
  3225. Uint32 dstR, dstG, dstB, dstA;
  3226. int srcy, srcx;
  3227. int posy, posx;
  3228. int incy, incx;
  3229. srcy = 0;
  3230. posy = 0;
  3231. incy = (info->src_h << 16) / info->dst_h;
  3232. incx = (info->src_w << 16) / info->dst_w;
  3233. while (info->dst_h--) {
  3234. Uint32 *src = 0;
  3235. Uint32 *dst = (Uint32 *)info->dst;
  3236. int n = info->dst_w;
  3237. srcx = -1;
  3238. posx = 0x10000L;
  3239. while (posy >= 0x10000L) {
  3240. ++srcy;
  3241. posy -= 0x10000L;
  3242. }
  3243. while (n--) {
  3244. if (posx >= 0x10000L) {
  3245. while (posx >= 0x10000L) {
  3246. ++srcx;
  3247. posx -= 0x10000L;
  3248. }
  3249. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3250. }
  3251. srcpixel = *src;
  3252. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3253. dstpixel = *dst;
  3254. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3255. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3256. /* This goes away if we ever use premultiplied alpha */
  3257. if (srcA < 255) {
  3258. srcR = (srcR * srcA) / 255;
  3259. srcG = (srcG * srcA) / 255;
  3260. srcB = (srcB * srcA) / 255;
  3261. }
  3262. }
  3263. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3264. case SDL_COPY_BLEND:
  3265. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3266. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3267. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3268. break;
  3269. case SDL_COPY_ADD:
  3270. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3271. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3272. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3273. break;
  3274. case SDL_COPY_MOD:
  3275. dstR = (srcR * dstR) / 255;
  3276. dstG = (srcG * dstG) / 255;
  3277. dstB = (srcB * dstB) / 255;
  3278. break;
  3279. }
  3280. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3281. *dst = dstpixel;
  3282. posx += incx;
  3283. ++dst;
  3284. }
  3285. posy += incy;
  3286. info->dst += info->dst_pitch;
  3287. }
  3288. }
  3289. static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  3290. {
  3291. const int flags = info->flags;
  3292. const Uint32 modulateR = info->r;
  3293. const Uint32 modulateG = info->g;
  3294. const Uint32 modulateB = info->b;
  3295. const Uint32 modulateA = info->a;
  3296. Uint32 pixel;
  3297. Uint32 R, G, B, A;
  3298. while (info->dst_h--) {
  3299. Uint32 *src = (Uint32 *)info->src;
  3300. Uint32 *dst = (Uint32 *)info->dst;
  3301. int n = info->dst_w;
  3302. while (n--) {
  3303. pixel = *src;
  3304. A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3305. if (flags & SDL_COPY_MODULATE_COLOR) {
  3306. R = (R * modulateR) / 255;
  3307. G = (G * modulateG) / 255;
  3308. B = (B * modulateB) / 255;
  3309. }
  3310. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3311. A = (A * modulateA) / 255;
  3312. }
  3313. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3314. *dst = pixel;
  3315. ++src;
  3316. ++dst;
  3317. }
  3318. info->src += info->src_pitch;
  3319. info->dst += info->dst_pitch;
  3320. }
  3321. }
  3322. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  3323. {
  3324. const int flags = info->flags;
  3325. const Uint32 modulateR = info->r;
  3326. const Uint32 modulateG = info->g;
  3327. const Uint32 modulateB = info->b;
  3328. const Uint32 modulateA = info->a;
  3329. Uint32 pixel;
  3330. Uint32 R, G, B, A;
  3331. int srcy, srcx;
  3332. int posy, posx;
  3333. int incy, incx;
  3334. srcy = 0;
  3335. posy = 0;
  3336. incy = (info->src_h << 16) / info->dst_h;
  3337. incx = (info->src_w << 16) / info->dst_w;
  3338. while (info->dst_h--) {
  3339. Uint32 *src = 0;
  3340. Uint32 *dst = (Uint32 *)info->dst;
  3341. int n = info->dst_w;
  3342. srcx = -1;
  3343. posx = 0x10000L;
  3344. while (posy >= 0x10000L) {
  3345. ++srcy;
  3346. posy -= 0x10000L;
  3347. }
  3348. while (n--) {
  3349. if (posx >= 0x10000L) {
  3350. while (posx >= 0x10000L) {
  3351. ++srcx;
  3352. posx -= 0x10000L;
  3353. }
  3354. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3355. }
  3356. pixel = *src;
  3357. A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3358. if (flags & SDL_COPY_MODULATE_COLOR) {
  3359. R = (R * modulateR) / 255;
  3360. G = (G * modulateG) / 255;
  3361. B = (B * modulateB) / 255;
  3362. }
  3363. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3364. A = (A * modulateA) / 255;
  3365. }
  3366. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3367. *dst = pixel;
  3368. posx += incx;
  3369. ++dst;
  3370. }
  3371. posy += incy;
  3372. info->dst += info->dst_pitch;
  3373. }
  3374. }
  3375. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  3376. {
  3377. const int flags = info->flags;
  3378. const Uint32 modulateR = info->r;
  3379. const Uint32 modulateG = info->g;
  3380. const Uint32 modulateB = info->b;
  3381. const Uint32 modulateA = info->a;
  3382. Uint32 srcpixel;
  3383. Uint32 srcR, srcG, srcB, srcA;
  3384. Uint32 dstpixel;
  3385. Uint32 dstR, dstG, dstB, dstA;
  3386. while (info->dst_h--) {
  3387. Uint32 *src = (Uint32 *)info->src;
  3388. Uint32 *dst = (Uint32 *)info->dst;
  3389. int n = info->dst_w;
  3390. while (n--) {
  3391. srcpixel = *src;
  3392. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3393. dstpixel = *dst;
  3394. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3395. if (flags & SDL_COPY_MODULATE_COLOR) {
  3396. srcR = (srcR * modulateR) / 255;
  3397. srcG = (srcG * modulateG) / 255;
  3398. srcB = (srcB * modulateB) / 255;
  3399. }
  3400. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3401. srcA = (srcA * modulateA) / 255;
  3402. }
  3403. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3404. /* This goes away if we ever use premultiplied alpha */
  3405. if (srcA < 255) {
  3406. srcR = (srcR * srcA) / 255;
  3407. srcG = (srcG * srcA) / 255;
  3408. srcB = (srcB * srcA) / 255;
  3409. }
  3410. }
  3411. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3412. case SDL_COPY_BLEND:
  3413. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3414. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3415. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3416. break;
  3417. case SDL_COPY_ADD:
  3418. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3419. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3420. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3421. break;
  3422. case SDL_COPY_MOD:
  3423. dstR = (srcR * dstR) / 255;
  3424. dstG = (srcG * dstG) / 255;
  3425. dstB = (srcB * dstB) / 255;
  3426. break;
  3427. }
  3428. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3429. *dst = dstpixel;
  3430. ++src;
  3431. ++dst;
  3432. }
  3433. info->src += info->src_pitch;
  3434. info->dst += info->dst_pitch;
  3435. }
  3436. }
  3437. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3438. {
  3439. const int flags = info->flags;
  3440. const Uint32 modulateR = info->r;
  3441. const Uint32 modulateG = info->g;
  3442. const Uint32 modulateB = info->b;
  3443. const Uint32 modulateA = info->a;
  3444. Uint32 srcpixel;
  3445. Uint32 srcR, srcG, srcB, srcA;
  3446. Uint32 dstpixel;
  3447. Uint32 dstR, dstG, dstB, dstA;
  3448. int srcy, srcx;
  3449. int posy, posx;
  3450. int incy, incx;
  3451. srcy = 0;
  3452. posy = 0;
  3453. incy = (info->src_h << 16) / info->dst_h;
  3454. incx = (info->src_w << 16) / info->dst_w;
  3455. while (info->dst_h--) {
  3456. Uint32 *src = 0;
  3457. Uint32 *dst = (Uint32 *)info->dst;
  3458. int n = info->dst_w;
  3459. srcx = -1;
  3460. posx = 0x10000L;
  3461. while (posy >= 0x10000L) {
  3462. ++srcy;
  3463. posy -= 0x10000L;
  3464. }
  3465. while (n--) {
  3466. if (posx >= 0x10000L) {
  3467. while (posx >= 0x10000L) {
  3468. ++srcx;
  3469. posx -= 0x10000L;
  3470. }
  3471. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3472. }
  3473. srcpixel = *src;
  3474. srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  3475. dstpixel = *dst;
  3476. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3477. if (flags & SDL_COPY_MODULATE_COLOR) {
  3478. srcR = (srcR * modulateR) / 255;
  3479. srcG = (srcG * modulateG) / 255;
  3480. srcB = (srcB * modulateB) / 255;
  3481. }
  3482. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3483. srcA = (srcA * modulateA) / 255;
  3484. }
  3485. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3486. /* This goes away if we ever use premultiplied alpha */
  3487. if (srcA < 255) {
  3488. srcR = (srcR * srcA) / 255;
  3489. srcG = (srcG * srcA) / 255;
  3490. srcB = (srcB * srcA) / 255;
  3491. }
  3492. }
  3493. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3494. case SDL_COPY_BLEND:
  3495. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3496. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3497. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3498. break;
  3499. case SDL_COPY_ADD:
  3500. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3501. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3502. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3503. break;
  3504. case SDL_COPY_MOD:
  3505. dstR = (srcR * dstR) / 255;
  3506. dstG = (srcG * dstG) / 255;
  3507. dstB = (srcB * dstB) / 255;
  3508. break;
  3509. }
  3510. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3511. *dst = dstpixel;
  3512. posx += incx;
  3513. ++dst;
  3514. }
  3515. posy += incy;
  3516. info->dst += info->dst_pitch;
  3517. }
  3518. }
  3519. static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
  3520. {
  3521. Uint32 pixel;
  3522. Uint32 R, G, B, A;
  3523. int srcy, srcx;
  3524. int posy, posx;
  3525. int incy, incx;
  3526. srcy = 0;
  3527. posy = 0;
  3528. incy = (info->src_h << 16) / info->dst_h;
  3529. incx = (info->src_w << 16) / info->dst_w;
  3530. while (info->dst_h--) {
  3531. Uint32 *src = 0;
  3532. Uint32 *dst = (Uint32 *)info->dst;
  3533. int n = info->dst_w;
  3534. srcx = -1;
  3535. posx = 0x10000L;
  3536. while (posy >= 0x10000L) {
  3537. ++srcy;
  3538. posy -= 0x10000L;
  3539. }
  3540. while (n--) {
  3541. if (posx >= 0x10000L) {
  3542. while (posx >= 0x10000L) {
  3543. ++srcx;
  3544. posx -= 0x10000L;
  3545. }
  3546. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3547. }
  3548. pixel = *src;
  3549. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3550. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3551. *dst = pixel;
  3552. posx += incx;
  3553. ++dst;
  3554. }
  3555. posy += incy;
  3556. info->dst += info->dst_pitch;
  3557. }
  3558. }
  3559. static void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info)
  3560. {
  3561. const int flags = info->flags;
  3562. Uint32 srcpixel;
  3563. Uint32 srcR, srcG, srcB, srcA;
  3564. Uint32 dstpixel;
  3565. Uint32 dstR, dstG, dstB, dstA;
  3566. while (info->dst_h--) {
  3567. Uint32 *src = (Uint32 *)info->src;
  3568. Uint32 *dst = (Uint32 *)info->dst;
  3569. int n = info->dst_w;
  3570. while (n--) {
  3571. srcpixel = *src;
  3572. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3573. dstpixel = *dst;
  3574. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3575. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3576. /* This goes away if we ever use premultiplied alpha */
  3577. if (srcA < 255) {
  3578. srcR = (srcR * srcA) / 255;
  3579. srcG = (srcG * srcA) / 255;
  3580. srcB = (srcB * srcA) / 255;
  3581. }
  3582. }
  3583. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3584. case SDL_COPY_BLEND:
  3585. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3586. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3587. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3588. break;
  3589. case SDL_COPY_ADD:
  3590. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3591. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3592. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3593. break;
  3594. case SDL_COPY_MOD:
  3595. dstR = (srcR * dstR) / 255;
  3596. dstG = (srcG * dstG) / 255;
  3597. dstB = (srcB * dstB) / 255;
  3598. break;
  3599. }
  3600. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3601. *dst = dstpixel;
  3602. ++src;
  3603. ++dst;
  3604. }
  3605. info->src += info->src_pitch;
  3606. info->dst += info->dst_pitch;
  3607. }
  3608. }
  3609. static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3610. {
  3611. const int flags = info->flags;
  3612. Uint32 srcpixel;
  3613. Uint32 srcR, srcG, srcB, srcA;
  3614. Uint32 dstpixel;
  3615. Uint32 dstR, dstG, dstB, dstA;
  3616. int srcy, srcx;
  3617. int posy, posx;
  3618. int incy, incx;
  3619. srcy = 0;
  3620. posy = 0;
  3621. incy = (info->src_h << 16) / info->dst_h;
  3622. incx = (info->src_w << 16) / info->dst_w;
  3623. while (info->dst_h--) {
  3624. Uint32 *src = 0;
  3625. Uint32 *dst = (Uint32 *)info->dst;
  3626. int n = info->dst_w;
  3627. srcx = -1;
  3628. posx = 0x10000L;
  3629. while (posy >= 0x10000L) {
  3630. ++srcy;
  3631. posy -= 0x10000L;
  3632. }
  3633. while (n--) {
  3634. if (posx >= 0x10000L) {
  3635. while (posx >= 0x10000L) {
  3636. ++srcx;
  3637. posx -= 0x10000L;
  3638. }
  3639. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3640. }
  3641. srcpixel = *src;
  3642. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3643. dstpixel = *dst;
  3644. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3645. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3646. /* This goes away if we ever use premultiplied alpha */
  3647. if (srcA < 255) {
  3648. srcR = (srcR * srcA) / 255;
  3649. srcG = (srcG * srcA) / 255;
  3650. srcB = (srcB * srcA) / 255;
  3651. }
  3652. }
  3653. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3654. case SDL_COPY_BLEND:
  3655. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3656. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3657. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3658. break;
  3659. case SDL_COPY_ADD:
  3660. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3661. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3662. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3663. break;
  3664. case SDL_COPY_MOD:
  3665. dstR = (srcR * dstR) / 255;
  3666. dstG = (srcG * dstG) / 255;
  3667. dstB = (srcB * dstB) / 255;
  3668. break;
  3669. }
  3670. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3671. *dst = dstpixel;
  3672. posx += incx;
  3673. ++dst;
  3674. }
  3675. posy += incy;
  3676. info->dst += info->dst_pitch;
  3677. }
  3678. }
  3679. static void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info)
  3680. {
  3681. const int flags = info->flags;
  3682. const Uint32 modulateR = info->r;
  3683. const Uint32 modulateG = info->g;
  3684. const Uint32 modulateB = info->b;
  3685. const Uint32 modulateA = info->a;
  3686. Uint32 pixel;
  3687. Uint32 R, G, B, A;
  3688. while (info->dst_h--) {
  3689. Uint32 *src = (Uint32 *)info->src;
  3690. Uint32 *dst = (Uint32 *)info->dst;
  3691. int n = info->dst_w;
  3692. while (n--) {
  3693. pixel = *src;
  3694. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3695. if (flags & SDL_COPY_MODULATE_COLOR) {
  3696. R = (R * modulateR) / 255;
  3697. G = (G * modulateG) / 255;
  3698. B = (B * modulateB) / 255;
  3699. }
  3700. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3701. A = (A * modulateA) / 255;
  3702. }
  3703. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3704. *dst = pixel;
  3705. ++src;
  3706. ++dst;
  3707. }
  3708. info->src += info->src_pitch;
  3709. info->dst += info->dst_pitch;
  3710. }
  3711. }
  3712. static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3713. {
  3714. const int flags = info->flags;
  3715. const Uint32 modulateR = info->r;
  3716. const Uint32 modulateG = info->g;
  3717. const Uint32 modulateB = info->b;
  3718. const Uint32 modulateA = info->a;
  3719. Uint32 pixel;
  3720. Uint32 R, G, B, A;
  3721. int srcy, srcx;
  3722. int posy, posx;
  3723. int incy, incx;
  3724. srcy = 0;
  3725. posy = 0;
  3726. incy = (info->src_h << 16) / info->dst_h;
  3727. incx = (info->src_w << 16) / info->dst_w;
  3728. while (info->dst_h--) {
  3729. Uint32 *src = 0;
  3730. Uint32 *dst = (Uint32 *)info->dst;
  3731. int n = info->dst_w;
  3732. srcx = -1;
  3733. posx = 0x10000L;
  3734. while (posy >= 0x10000L) {
  3735. ++srcy;
  3736. posy -= 0x10000L;
  3737. }
  3738. while (n--) {
  3739. if (posx >= 0x10000L) {
  3740. while (posx >= 0x10000L) {
  3741. ++srcx;
  3742. posx -= 0x10000L;
  3743. }
  3744. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3745. }
  3746. pixel = *src;
  3747. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3748. if (flags & SDL_COPY_MODULATE_COLOR) {
  3749. R = (R * modulateR) / 255;
  3750. G = (G * modulateG) / 255;
  3751. B = (B * modulateB) / 255;
  3752. }
  3753. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3754. A = (A * modulateA) / 255;
  3755. }
  3756. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  3757. *dst = pixel;
  3758. posx += incx;
  3759. ++dst;
  3760. }
  3761. posy += incy;
  3762. info->dst += info->dst_pitch;
  3763. }
  3764. }
  3765. static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3766. {
  3767. const int flags = info->flags;
  3768. const Uint32 modulateR = info->r;
  3769. const Uint32 modulateG = info->g;
  3770. const Uint32 modulateB = info->b;
  3771. const Uint32 modulateA = info->a;
  3772. Uint32 srcpixel;
  3773. Uint32 srcR, srcG, srcB, srcA;
  3774. Uint32 dstpixel;
  3775. Uint32 dstR, dstG, dstB, dstA;
  3776. while (info->dst_h--) {
  3777. Uint32 *src = (Uint32 *)info->src;
  3778. Uint32 *dst = (Uint32 *)info->dst;
  3779. int n = info->dst_w;
  3780. while (n--) {
  3781. srcpixel = *src;
  3782. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3783. dstpixel = *dst;
  3784. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3785. if (flags & SDL_COPY_MODULATE_COLOR) {
  3786. srcR = (srcR * modulateR) / 255;
  3787. srcG = (srcG * modulateG) / 255;
  3788. srcB = (srcB * modulateB) / 255;
  3789. }
  3790. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3791. srcA = (srcA * modulateA) / 255;
  3792. }
  3793. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3794. /* This goes away if we ever use premultiplied alpha */
  3795. if (srcA < 255) {
  3796. srcR = (srcR * srcA) / 255;
  3797. srcG = (srcG * srcA) / 255;
  3798. srcB = (srcB * srcA) / 255;
  3799. }
  3800. }
  3801. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3802. case SDL_COPY_BLEND:
  3803. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3804. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3805. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3806. break;
  3807. case SDL_COPY_ADD:
  3808. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3809. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3810. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3811. break;
  3812. case SDL_COPY_MOD:
  3813. dstR = (srcR * dstR) / 255;
  3814. dstG = (srcG * dstG) / 255;
  3815. dstB = (srcB * dstB) / 255;
  3816. break;
  3817. }
  3818. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3819. *dst = dstpixel;
  3820. ++src;
  3821. ++dst;
  3822. }
  3823. info->src += info->src_pitch;
  3824. info->dst += info->dst_pitch;
  3825. }
  3826. }
  3827. static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3828. {
  3829. const int flags = info->flags;
  3830. const Uint32 modulateR = info->r;
  3831. const Uint32 modulateG = info->g;
  3832. const Uint32 modulateB = info->b;
  3833. const Uint32 modulateA = info->a;
  3834. Uint32 srcpixel;
  3835. Uint32 srcR, srcG, srcB, srcA;
  3836. Uint32 dstpixel;
  3837. Uint32 dstR, dstG, dstB, dstA;
  3838. int srcy, srcx;
  3839. int posy, posx;
  3840. int incy, incx;
  3841. srcy = 0;
  3842. posy = 0;
  3843. incy = (info->src_h << 16) / info->dst_h;
  3844. incx = (info->src_w << 16) / info->dst_w;
  3845. while (info->dst_h--) {
  3846. Uint32 *src = 0;
  3847. Uint32 *dst = (Uint32 *)info->dst;
  3848. int n = info->dst_w;
  3849. srcx = -1;
  3850. posx = 0x10000L;
  3851. while (posy >= 0x10000L) {
  3852. ++srcy;
  3853. posy -= 0x10000L;
  3854. }
  3855. while (n--) {
  3856. if (posx >= 0x10000L) {
  3857. while (posx >= 0x10000L) {
  3858. ++srcx;
  3859. posx -= 0x10000L;
  3860. }
  3861. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3862. }
  3863. srcpixel = *src;
  3864. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3865. dstpixel = *dst;
  3866. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  3867. if (flags & SDL_COPY_MODULATE_COLOR) {
  3868. srcR = (srcR * modulateR) / 255;
  3869. srcG = (srcG * modulateG) / 255;
  3870. srcB = (srcB * modulateB) / 255;
  3871. }
  3872. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3873. srcA = (srcA * modulateA) / 255;
  3874. }
  3875. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3876. /* This goes away if we ever use premultiplied alpha */
  3877. if (srcA < 255) {
  3878. srcR = (srcR * srcA) / 255;
  3879. srcG = (srcG * srcA) / 255;
  3880. srcB = (srcB * srcA) / 255;
  3881. }
  3882. }
  3883. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3884. case SDL_COPY_BLEND:
  3885. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3886. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3887. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3888. break;
  3889. case SDL_COPY_ADD:
  3890. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3891. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3892. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3893. break;
  3894. case SDL_COPY_MOD:
  3895. dstR = (srcR * dstR) / 255;
  3896. dstG = (srcG * dstG) / 255;
  3897. dstB = (srcB * dstB) / 255;
  3898. break;
  3899. }
  3900. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  3901. *dst = dstpixel;
  3902. posx += incx;
  3903. ++dst;
  3904. }
  3905. posy += incy;
  3906. info->dst += info->dst_pitch;
  3907. }
  3908. }
  3909. static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info)
  3910. {
  3911. Uint32 pixel;
  3912. Uint32 R, G, B, A;
  3913. int srcy, srcx;
  3914. int posy, posx;
  3915. int incy, incx;
  3916. srcy = 0;
  3917. posy = 0;
  3918. incy = (info->src_h << 16) / info->dst_h;
  3919. incx = (info->src_w << 16) / info->dst_w;
  3920. while (info->dst_h--) {
  3921. Uint32 *src = 0;
  3922. Uint32 *dst = (Uint32 *)info->dst;
  3923. int n = info->dst_w;
  3924. srcx = -1;
  3925. posx = 0x10000L;
  3926. while (posy >= 0x10000L) {
  3927. ++srcy;
  3928. posy -= 0x10000L;
  3929. }
  3930. while (n--) {
  3931. if (posx >= 0x10000L) {
  3932. while (posx >= 0x10000L) {
  3933. ++srcx;
  3934. posx -= 0x10000L;
  3935. }
  3936. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3937. }
  3938. pixel = *src;
  3939. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  3940. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  3941. *dst = pixel;
  3942. posx += incx;
  3943. ++dst;
  3944. }
  3945. posy += incy;
  3946. info->dst += info->dst_pitch;
  3947. }
  3948. }
  3949. static void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info)
  3950. {
  3951. const int flags = info->flags;
  3952. Uint32 srcpixel;
  3953. Uint32 srcR, srcG, srcB, srcA;
  3954. Uint32 dstpixel;
  3955. Uint32 dstR, dstG, dstB, dstA;
  3956. while (info->dst_h--) {
  3957. Uint32 *src = (Uint32 *)info->src;
  3958. Uint32 *dst = (Uint32 *)info->dst;
  3959. int n = info->dst_w;
  3960. while (n--) {
  3961. srcpixel = *src;
  3962. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3963. dstpixel = *dst;
  3964. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  3965. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3966. /* This goes away if we ever use premultiplied alpha */
  3967. if (srcA < 255) {
  3968. srcR = (srcR * srcA) / 255;
  3969. srcG = (srcG * srcA) / 255;
  3970. srcB = (srcB * srcA) / 255;
  3971. }
  3972. }
  3973. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  3974. case SDL_COPY_BLEND:
  3975. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3976. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3977. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3978. break;
  3979. case SDL_COPY_ADD:
  3980. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3981. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3982. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3983. break;
  3984. case SDL_COPY_MOD:
  3985. dstR = (srcR * dstR) / 255;
  3986. dstG = (srcG * dstG) / 255;
  3987. dstB = (srcB * dstB) / 255;
  3988. break;
  3989. }
  3990. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  3991. *dst = dstpixel;
  3992. ++src;
  3993. ++dst;
  3994. }
  3995. info->src += info->src_pitch;
  3996. info->dst += info->dst_pitch;
  3997. }
  3998. }
  3999. static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  4000. {
  4001. const int flags = info->flags;
  4002. Uint32 srcpixel;
  4003. Uint32 srcR, srcG, srcB, srcA;
  4004. Uint32 dstpixel;
  4005. Uint32 dstR, dstG, dstB, dstA;
  4006. int srcy, srcx;
  4007. int posy, posx;
  4008. int incy, incx;
  4009. srcy = 0;
  4010. posy = 0;
  4011. incy = (info->src_h << 16) / info->dst_h;
  4012. incx = (info->src_w << 16) / info->dst_w;
  4013. while (info->dst_h--) {
  4014. Uint32 *src = 0;
  4015. Uint32 *dst = (Uint32 *)info->dst;
  4016. int n = info->dst_w;
  4017. srcx = -1;
  4018. posx = 0x10000L;
  4019. while (posy >= 0x10000L) {
  4020. ++srcy;
  4021. posy -= 0x10000L;
  4022. }
  4023. while (n--) {
  4024. if (posx >= 0x10000L) {
  4025. while (posx >= 0x10000L) {
  4026. ++srcx;
  4027. posx -= 0x10000L;
  4028. }
  4029. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4030. }
  4031. srcpixel = *src;
  4032. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4033. dstpixel = *dst;
  4034. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  4035. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4036. /* This goes away if we ever use premultiplied alpha */
  4037. if (srcA < 255) {
  4038. srcR = (srcR * srcA) / 255;
  4039. srcG = (srcG * srcA) / 255;
  4040. srcB = (srcB * srcA) / 255;
  4041. }
  4042. }
  4043. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4044. case SDL_COPY_BLEND:
  4045. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4046. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4047. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4048. break;
  4049. case SDL_COPY_ADD:
  4050. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4051. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4052. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4053. break;
  4054. case SDL_COPY_MOD:
  4055. dstR = (srcR * dstR) / 255;
  4056. dstG = (srcG * dstG) / 255;
  4057. dstB = (srcB * dstB) / 255;
  4058. break;
  4059. }
  4060. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  4061. *dst = dstpixel;
  4062. posx += incx;
  4063. ++dst;
  4064. }
  4065. posy += incy;
  4066. info->dst += info->dst_pitch;
  4067. }
  4068. }
  4069. static void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info)
  4070. {
  4071. const int flags = info->flags;
  4072. const Uint32 modulateR = info->r;
  4073. const Uint32 modulateG = info->g;
  4074. const Uint32 modulateB = info->b;
  4075. const Uint32 modulateA = info->a;
  4076. Uint32 pixel;
  4077. Uint32 R, G, B, A;
  4078. while (info->dst_h--) {
  4079. Uint32 *src = (Uint32 *)info->src;
  4080. Uint32 *dst = (Uint32 *)info->dst;
  4081. int n = info->dst_w;
  4082. while (n--) {
  4083. pixel = *src;
  4084. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  4085. if (flags & SDL_COPY_MODULATE_COLOR) {
  4086. R = (R * modulateR) / 255;
  4087. G = (G * modulateG) / 255;
  4088. B = (B * modulateB) / 255;
  4089. }
  4090. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4091. A = (A * modulateA) / 255;
  4092. }
  4093. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  4094. *dst = pixel;
  4095. ++src;
  4096. ++dst;
  4097. }
  4098. info->src += info->src_pitch;
  4099. info->dst += info->dst_pitch;
  4100. }
  4101. }
  4102. static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  4103. {
  4104. const int flags = info->flags;
  4105. const Uint32 modulateR = info->r;
  4106. const Uint32 modulateG = info->g;
  4107. const Uint32 modulateB = info->b;
  4108. const Uint32 modulateA = info->a;
  4109. Uint32 pixel;
  4110. Uint32 R, G, B, A;
  4111. int srcy, srcx;
  4112. int posy, posx;
  4113. int incy, incx;
  4114. srcy = 0;
  4115. posy = 0;
  4116. incy = (info->src_h << 16) / info->dst_h;
  4117. incx = (info->src_w << 16) / info->dst_w;
  4118. while (info->dst_h--) {
  4119. Uint32 *src = 0;
  4120. Uint32 *dst = (Uint32 *)info->dst;
  4121. int n = info->dst_w;
  4122. srcx = -1;
  4123. posx = 0x10000L;
  4124. while (posy >= 0x10000L) {
  4125. ++srcy;
  4126. posy -= 0x10000L;
  4127. }
  4128. while (n--) {
  4129. if (posx >= 0x10000L) {
  4130. while (posx >= 0x10000L) {
  4131. ++srcx;
  4132. posx -= 0x10000L;
  4133. }
  4134. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4135. }
  4136. pixel = *src;
  4137. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  4138. if (flags & SDL_COPY_MODULATE_COLOR) {
  4139. R = (R * modulateR) / 255;
  4140. G = (G * modulateG) / 255;
  4141. B = (B * modulateB) / 255;
  4142. }
  4143. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4144. A = (A * modulateA) / 255;
  4145. }
  4146. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  4147. *dst = pixel;
  4148. posx += incx;
  4149. ++dst;
  4150. }
  4151. posy += incy;
  4152. info->dst += info->dst_pitch;
  4153. }
  4154. }
  4155. static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  4156. {
  4157. const int flags = info->flags;
  4158. const Uint32 modulateR = info->r;
  4159. const Uint32 modulateG = info->g;
  4160. const Uint32 modulateB = info->b;
  4161. const Uint32 modulateA = info->a;
  4162. Uint32 srcpixel;
  4163. Uint32 srcR, srcG, srcB, srcA;
  4164. Uint32 dstpixel;
  4165. Uint32 dstR, dstG, dstB, dstA;
  4166. while (info->dst_h--) {
  4167. Uint32 *src = (Uint32 *)info->src;
  4168. Uint32 *dst = (Uint32 *)info->dst;
  4169. int n = info->dst_w;
  4170. while (n--) {
  4171. srcpixel = *src;
  4172. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4173. dstpixel = *dst;
  4174. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  4175. if (flags & SDL_COPY_MODULATE_COLOR) {
  4176. srcR = (srcR * modulateR) / 255;
  4177. srcG = (srcG * modulateG) / 255;
  4178. srcB = (srcB * modulateB) / 255;
  4179. }
  4180. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4181. srcA = (srcA * modulateA) / 255;
  4182. }
  4183. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4184. /* This goes away if we ever use premultiplied alpha */
  4185. if (srcA < 255) {
  4186. srcR = (srcR * srcA) / 255;
  4187. srcG = (srcG * srcA) / 255;
  4188. srcB = (srcB * srcA) / 255;
  4189. }
  4190. }
  4191. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4192. case SDL_COPY_BLEND:
  4193. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4194. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4195. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4196. break;
  4197. case SDL_COPY_ADD:
  4198. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4199. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4200. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4201. break;
  4202. case SDL_COPY_MOD:
  4203. dstR = (srcR * dstR) / 255;
  4204. dstG = (srcG * dstG) / 255;
  4205. dstB = (srcB * dstB) / 255;
  4206. break;
  4207. }
  4208. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  4209. *dst = dstpixel;
  4210. ++src;
  4211. ++dst;
  4212. }
  4213. info->src += info->src_pitch;
  4214. info->dst += info->dst_pitch;
  4215. }
  4216. }
  4217. static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4218. {
  4219. const int flags = info->flags;
  4220. const Uint32 modulateR = info->r;
  4221. const Uint32 modulateG = info->g;
  4222. const Uint32 modulateB = info->b;
  4223. const Uint32 modulateA = info->a;
  4224. Uint32 srcpixel;
  4225. Uint32 srcR, srcG, srcB, srcA;
  4226. Uint32 dstpixel;
  4227. Uint32 dstR, dstG, dstB, dstA;
  4228. int srcy, srcx;
  4229. int posy, posx;
  4230. int incy, incx;
  4231. srcy = 0;
  4232. posy = 0;
  4233. incy = (info->src_h << 16) / info->dst_h;
  4234. incx = (info->src_w << 16) / info->dst_w;
  4235. while (info->dst_h--) {
  4236. Uint32 *src = 0;
  4237. Uint32 *dst = (Uint32 *)info->dst;
  4238. int n = info->dst_w;
  4239. srcx = -1;
  4240. posx = 0x10000L;
  4241. while (posy >= 0x10000L) {
  4242. ++srcy;
  4243. posy -= 0x10000L;
  4244. }
  4245. while (n--) {
  4246. if (posx >= 0x10000L) {
  4247. while (posx >= 0x10000L) {
  4248. ++srcx;
  4249. posx -= 0x10000L;
  4250. }
  4251. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4252. }
  4253. srcpixel = *src;
  4254. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4255. dstpixel = *dst;
  4256. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  4257. if (flags & SDL_COPY_MODULATE_COLOR) {
  4258. srcR = (srcR * modulateR) / 255;
  4259. srcG = (srcG * modulateG) / 255;
  4260. srcB = (srcB * modulateB) / 255;
  4261. }
  4262. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4263. srcA = (srcA * modulateA) / 255;
  4264. }
  4265. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4266. /* This goes away if we ever use premultiplied alpha */
  4267. if (srcA < 255) {
  4268. srcR = (srcR * srcA) / 255;
  4269. srcG = (srcG * srcA) / 255;
  4270. srcB = (srcB * srcA) / 255;
  4271. }
  4272. }
  4273. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4274. case SDL_COPY_BLEND:
  4275. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4276. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4277. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4278. break;
  4279. case SDL_COPY_ADD:
  4280. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4281. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4282. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4283. break;
  4284. case SDL_COPY_MOD:
  4285. dstR = (srcR * dstR) / 255;
  4286. dstG = (srcG * dstG) / 255;
  4287. dstB = (srcB * dstB) / 255;
  4288. break;
  4289. }
  4290. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  4291. *dst = dstpixel;
  4292. posx += incx;
  4293. ++dst;
  4294. }
  4295. posy += incy;
  4296. info->dst += info->dst_pitch;
  4297. }
  4298. }
  4299. static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  4300. {
  4301. Uint32 pixel;
  4302. Uint32 R, G, B, A;
  4303. int srcy, srcx;
  4304. int posy, posx;
  4305. int incy, incx;
  4306. srcy = 0;
  4307. posy = 0;
  4308. incy = (info->src_h << 16) / info->dst_h;
  4309. incx = (info->src_w << 16) / info->dst_w;
  4310. while (info->dst_h--) {
  4311. Uint32 *src = 0;
  4312. Uint32 *dst = (Uint32 *)info->dst;
  4313. int n = info->dst_w;
  4314. srcx = -1;
  4315. posx = 0x10000L;
  4316. while (posy >= 0x10000L) {
  4317. ++srcy;
  4318. posy -= 0x10000L;
  4319. }
  4320. while (n--) {
  4321. if (posx >= 0x10000L) {
  4322. while (posx >= 0x10000L) {
  4323. ++srcx;
  4324. posx -= 0x10000L;
  4325. }
  4326. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4327. }
  4328. pixel = *src;
  4329. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  4330. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  4331. *dst = pixel;
  4332. posx += incx;
  4333. ++dst;
  4334. }
  4335. posy += incy;
  4336. info->dst += info->dst_pitch;
  4337. }
  4338. }
  4339. static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  4340. {
  4341. const int flags = info->flags;
  4342. Uint32 srcpixel;
  4343. Uint32 srcR, srcG, srcB, srcA;
  4344. Uint32 dstpixel;
  4345. Uint32 dstR, dstG, dstB, dstA;
  4346. while (info->dst_h--) {
  4347. Uint32 *src = (Uint32 *)info->src;
  4348. Uint32 *dst = (Uint32 *)info->dst;
  4349. int n = info->dst_w;
  4350. while (n--) {
  4351. srcpixel = *src;
  4352. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4353. dstpixel = *dst;
  4354. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  4355. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4356. /* This goes away if we ever use premultiplied alpha */
  4357. if (srcA < 255) {
  4358. srcR = (srcR * srcA) / 255;
  4359. srcG = (srcG * srcA) / 255;
  4360. srcB = (srcB * srcA) / 255;
  4361. }
  4362. }
  4363. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4364. case SDL_COPY_BLEND:
  4365. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4366. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4367. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4368. break;
  4369. case SDL_COPY_ADD:
  4370. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4371. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4372. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4373. break;
  4374. case SDL_COPY_MOD:
  4375. dstR = (srcR * dstR) / 255;
  4376. dstG = (srcG * dstG) / 255;
  4377. dstB = (srcB * dstB) / 255;
  4378. break;
  4379. }
  4380. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  4381. *dst = dstpixel;
  4382. ++src;
  4383. ++dst;
  4384. }
  4385. info->src += info->src_pitch;
  4386. info->dst += info->dst_pitch;
  4387. }
  4388. }
  4389. static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  4390. {
  4391. const int flags = info->flags;
  4392. Uint32 srcpixel;
  4393. Uint32 srcR, srcG, srcB, srcA;
  4394. Uint32 dstpixel;
  4395. Uint32 dstR, dstG, dstB, dstA;
  4396. int srcy, srcx;
  4397. int posy, posx;
  4398. int incy, incx;
  4399. srcy = 0;
  4400. posy = 0;
  4401. incy = (info->src_h << 16) / info->dst_h;
  4402. incx = (info->src_w << 16) / info->dst_w;
  4403. while (info->dst_h--) {
  4404. Uint32 *src = 0;
  4405. Uint32 *dst = (Uint32 *)info->dst;
  4406. int n = info->dst_w;
  4407. srcx = -1;
  4408. posx = 0x10000L;
  4409. while (posy >= 0x10000L) {
  4410. ++srcy;
  4411. posy -= 0x10000L;
  4412. }
  4413. while (n--) {
  4414. if (posx >= 0x10000L) {
  4415. while (posx >= 0x10000L) {
  4416. ++srcx;
  4417. posx -= 0x10000L;
  4418. }
  4419. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4420. }
  4421. srcpixel = *src;
  4422. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4423. dstpixel = *dst;
  4424. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  4425. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4426. /* This goes away if we ever use premultiplied alpha */
  4427. if (srcA < 255) {
  4428. srcR = (srcR * srcA) / 255;
  4429. srcG = (srcG * srcA) / 255;
  4430. srcB = (srcB * srcA) / 255;
  4431. }
  4432. }
  4433. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4434. case SDL_COPY_BLEND:
  4435. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4436. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4437. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4438. break;
  4439. case SDL_COPY_ADD:
  4440. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4441. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4442. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4443. break;
  4444. case SDL_COPY_MOD:
  4445. dstR = (srcR * dstR) / 255;
  4446. dstG = (srcG * dstG) / 255;
  4447. dstB = (srcB * dstB) / 255;
  4448. break;
  4449. }
  4450. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  4451. *dst = dstpixel;
  4452. posx += incx;
  4453. ++dst;
  4454. }
  4455. posy += incy;
  4456. info->dst += info->dst_pitch;
  4457. }
  4458. }
  4459. static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  4460. {
  4461. const int flags = info->flags;
  4462. const Uint32 modulateR = info->r;
  4463. const Uint32 modulateG = info->g;
  4464. const Uint32 modulateB = info->b;
  4465. const Uint32 modulateA = info->a;
  4466. Uint32 pixel;
  4467. Uint32 R, G, B, A;
  4468. while (info->dst_h--) {
  4469. Uint32 *src = (Uint32 *)info->src;
  4470. Uint32 *dst = (Uint32 *)info->dst;
  4471. int n = info->dst_w;
  4472. while (n--) {
  4473. pixel = *src;
  4474. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  4475. if (flags & SDL_COPY_MODULATE_COLOR) {
  4476. R = (R * modulateR) / 255;
  4477. G = (G * modulateG) / 255;
  4478. B = (B * modulateB) / 255;
  4479. }
  4480. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4481. A = (A * modulateA) / 255;
  4482. }
  4483. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  4484. *dst = pixel;
  4485. ++src;
  4486. ++dst;
  4487. }
  4488. info->src += info->src_pitch;
  4489. info->dst += info->dst_pitch;
  4490. }
  4491. }
  4492. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  4493. {
  4494. const int flags = info->flags;
  4495. const Uint32 modulateR = info->r;
  4496. const Uint32 modulateG = info->g;
  4497. const Uint32 modulateB = info->b;
  4498. const Uint32 modulateA = info->a;
  4499. Uint32 pixel;
  4500. Uint32 R, G, B, A;
  4501. int srcy, srcx;
  4502. int posy, posx;
  4503. int incy, incx;
  4504. srcy = 0;
  4505. posy = 0;
  4506. incy = (info->src_h << 16) / info->dst_h;
  4507. incx = (info->src_w << 16) / info->dst_w;
  4508. while (info->dst_h--) {
  4509. Uint32 *src = 0;
  4510. Uint32 *dst = (Uint32 *)info->dst;
  4511. int n = info->dst_w;
  4512. srcx = -1;
  4513. posx = 0x10000L;
  4514. while (posy >= 0x10000L) {
  4515. ++srcy;
  4516. posy -= 0x10000L;
  4517. }
  4518. while (n--) {
  4519. if (posx >= 0x10000L) {
  4520. while (posx >= 0x10000L) {
  4521. ++srcx;
  4522. posx -= 0x10000L;
  4523. }
  4524. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4525. }
  4526. pixel = *src;
  4527. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  4528. if (flags & SDL_COPY_MODULATE_COLOR) {
  4529. R = (R * modulateR) / 255;
  4530. G = (G * modulateG) / 255;
  4531. B = (B * modulateB) / 255;
  4532. }
  4533. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4534. A = (A * modulateA) / 255;
  4535. }
  4536. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  4537. *dst = pixel;
  4538. posx += incx;
  4539. ++dst;
  4540. }
  4541. posy += incy;
  4542. info->dst += info->dst_pitch;
  4543. }
  4544. }
  4545. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  4546. {
  4547. const int flags = info->flags;
  4548. const Uint32 modulateR = info->r;
  4549. const Uint32 modulateG = info->g;
  4550. const Uint32 modulateB = info->b;
  4551. const Uint32 modulateA = info->a;
  4552. Uint32 srcpixel;
  4553. Uint32 srcR, srcG, srcB, srcA;
  4554. Uint32 dstpixel;
  4555. Uint32 dstR, dstG, dstB, dstA;
  4556. while (info->dst_h--) {
  4557. Uint32 *src = (Uint32 *)info->src;
  4558. Uint32 *dst = (Uint32 *)info->dst;
  4559. int n = info->dst_w;
  4560. while (n--) {
  4561. srcpixel = *src;
  4562. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4563. dstpixel = *dst;
  4564. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  4565. if (flags & SDL_COPY_MODULATE_COLOR) {
  4566. srcR = (srcR * modulateR) / 255;
  4567. srcG = (srcG * modulateG) / 255;
  4568. srcB = (srcB * modulateB) / 255;
  4569. }
  4570. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4571. srcA = (srcA * modulateA) / 255;
  4572. }
  4573. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4574. /* This goes away if we ever use premultiplied alpha */
  4575. if (srcA < 255) {
  4576. srcR = (srcR * srcA) / 255;
  4577. srcG = (srcG * srcA) / 255;
  4578. srcB = (srcB * srcA) / 255;
  4579. }
  4580. }
  4581. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4582. case SDL_COPY_BLEND:
  4583. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4584. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4585. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4586. break;
  4587. case SDL_COPY_ADD:
  4588. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4589. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4590. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4591. break;
  4592. case SDL_COPY_MOD:
  4593. dstR = (srcR * dstR) / 255;
  4594. dstG = (srcG * dstG) / 255;
  4595. dstB = (srcB * dstB) / 255;
  4596. break;
  4597. }
  4598. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  4599. *dst = dstpixel;
  4600. ++src;
  4601. ++dst;
  4602. }
  4603. info->src += info->src_pitch;
  4604. info->dst += info->dst_pitch;
  4605. }
  4606. }
  4607. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4608. {
  4609. const int flags = info->flags;
  4610. const Uint32 modulateR = info->r;
  4611. const Uint32 modulateG = info->g;
  4612. const Uint32 modulateB = info->b;
  4613. const Uint32 modulateA = info->a;
  4614. Uint32 srcpixel;
  4615. Uint32 srcR, srcG, srcB, srcA;
  4616. Uint32 dstpixel;
  4617. Uint32 dstR, dstG, dstB, dstA;
  4618. int srcy, srcx;
  4619. int posy, posx;
  4620. int incy, incx;
  4621. srcy = 0;
  4622. posy = 0;
  4623. incy = (info->src_h << 16) / info->dst_h;
  4624. incx = (info->src_w << 16) / info->dst_w;
  4625. while (info->dst_h--) {
  4626. Uint32 *src = 0;
  4627. Uint32 *dst = (Uint32 *)info->dst;
  4628. int n = info->dst_w;
  4629. srcx = -1;
  4630. posx = 0x10000L;
  4631. while (posy >= 0x10000L) {
  4632. ++srcy;
  4633. posy -= 0x10000L;
  4634. }
  4635. while (n--) {
  4636. if (posx >= 0x10000L) {
  4637. while (posx >= 0x10000L) {
  4638. ++srcx;
  4639. posx -= 0x10000L;
  4640. }
  4641. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4642. }
  4643. srcpixel = *src;
  4644. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4645. dstpixel = *dst;
  4646. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  4647. if (flags & SDL_COPY_MODULATE_COLOR) {
  4648. srcR = (srcR * modulateR) / 255;
  4649. srcG = (srcG * modulateG) / 255;
  4650. srcB = (srcB * modulateB) / 255;
  4651. }
  4652. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4653. srcA = (srcA * modulateA) / 255;
  4654. }
  4655. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4656. /* This goes away if we ever use premultiplied alpha */
  4657. if (srcA < 255) {
  4658. srcR = (srcR * srcA) / 255;
  4659. srcG = (srcG * srcA) / 255;
  4660. srcB = (srcB * srcA) / 255;
  4661. }
  4662. }
  4663. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4664. case SDL_COPY_BLEND:
  4665. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4666. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4667. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4668. break;
  4669. case SDL_COPY_ADD:
  4670. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4671. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4672. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4673. break;
  4674. case SDL_COPY_MOD:
  4675. dstR = (srcR * dstR) / 255;
  4676. dstG = (srcG * dstG) / 255;
  4677. dstB = (srcB * dstB) / 255;
  4678. break;
  4679. }
  4680. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  4681. *dst = dstpixel;
  4682. posx += incx;
  4683. ++dst;
  4684. }
  4685. posy += incy;
  4686. info->dst += info->dst_pitch;
  4687. }
  4688. }
  4689. static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info)
  4690. {
  4691. Uint32 pixel;
  4692. Uint32 R, G, B, A;
  4693. int srcy, srcx;
  4694. int posy, posx;
  4695. int incy, incx;
  4696. srcy = 0;
  4697. posy = 0;
  4698. incy = (info->src_h << 16) / info->dst_h;
  4699. incx = (info->src_w << 16) / info->dst_w;
  4700. while (info->dst_h--) {
  4701. Uint32 *src = 0;
  4702. Uint32 *dst = (Uint32 *)info->dst;
  4703. int n = info->dst_w;
  4704. srcx = -1;
  4705. posx = 0x10000L;
  4706. while (posy >= 0x10000L) {
  4707. ++srcy;
  4708. posy -= 0x10000L;
  4709. }
  4710. while (n--) {
  4711. if (posx >= 0x10000L) {
  4712. while (posx >= 0x10000L) {
  4713. ++srcx;
  4714. posx -= 0x10000L;
  4715. }
  4716. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4717. }
  4718. pixel = *src;
  4719. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  4720. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  4721. *dst = pixel;
  4722. posx += incx;
  4723. ++dst;
  4724. }
  4725. posy += incy;
  4726. info->dst += info->dst_pitch;
  4727. }
  4728. }
  4729. static void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info)
  4730. {
  4731. const int flags = info->flags;
  4732. Uint32 srcpixel;
  4733. Uint32 srcR, srcG, srcB, srcA;
  4734. Uint32 dstpixel;
  4735. Uint32 dstR, dstG, dstB, dstA;
  4736. while (info->dst_h--) {
  4737. Uint32 *src = (Uint32 *)info->src;
  4738. Uint32 *dst = (Uint32 *)info->dst;
  4739. int n = info->dst_w;
  4740. while (n--) {
  4741. srcpixel = *src;
  4742. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  4743. dstpixel = *dst;
  4744. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  4745. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4746. /* This goes away if we ever use premultiplied alpha */
  4747. if (srcA < 255) {
  4748. srcR = (srcR * srcA) / 255;
  4749. srcG = (srcG * srcA) / 255;
  4750. srcB = (srcB * srcA) / 255;
  4751. }
  4752. }
  4753. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4754. case SDL_COPY_BLEND:
  4755. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4756. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4757. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4758. break;
  4759. case SDL_COPY_ADD:
  4760. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4761. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4762. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4763. break;
  4764. case SDL_COPY_MOD:
  4765. dstR = (srcR * dstR) / 255;
  4766. dstG = (srcG * dstG) / 255;
  4767. dstB = (srcB * dstB) / 255;
  4768. break;
  4769. }
  4770. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  4771. *dst = dstpixel;
  4772. ++src;
  4773. ++dst;
  4774. }
  4775. info->src += info->src_pitch;
  4776. info->dst += info->dst_pitch;
  4777. }
  4778. }
  4779. static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  4780. {
  4781. const int flags = info->flags;
  4782. Uint32 srcpixel;
  4783. Uint32 srcR, srcG, srcB, srcA;
  4784. Uint32 dstpixel;
  4785. Uint32 dstR, dstG, dstB, dstA;
  4786. int srcy, srcx;
  4787. int posy, posx;
  4788. int incy, incx;
  4789. srcy = 0;
  4790. posy = 0;
  4791. incy = (info->src_h << 16) / info->dst_h;
  4792. incx = (info->src_w << 16) / info->dst_w;
  4793. while (info->dst_h--) {
  4794. Uint32 *src = 0;
  4795. Uint32 *dst = (Uint32 *)info->dst;
  4796. int n = info->dst_w;
  4797. srcx = -1;
  4798. posx = 0x10000L;
  4799. while (posy >= 0x10000L) {
  4800. ++srcy;
  4801. posy -= 0x10000L;
  4802. }
  4803. while (n--) {
  4804. if (posx >= 0x10000L) {
  4805. while (posx >= 0x10000L) {
  4806. ++srcx;
  4807. posx -= 0x10000L;
  4808. }
  4809. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4810. }
  4811. srcpixel = *src;
  4812. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  4813. dstpixel = *dst;
  4814. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  4815. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4816. /* This goes away if we ever use premultiplied alpha */
  4817. if (srcA < 255) {
  4818. srcR = (srcR * srcA) / 255;
  4819. srcG = (srcG * srcA) / 255;
  4820. srcB = (srcB * srcA) / 255;
  4821. }
  4822. }
  4823. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4824. case SDL_COPY_BLEND:
  4825. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4826. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4827. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4828. break;
  4829. case SDL_COPY_ADD:
  4830. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4831. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4832. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4833. break;
  4834. case SDL_COPY_MOD:
  4835. dstR = (srcR * dstR) / 255;
  4836. dstG = (srcG * dstG) / 255;
  4837. dstB = (srcB * dstB) / 255;
  4838. break;
  4839. }
  4840. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  4841. *dst = dstpixel;
  4842. posx += incx;
  4843. ++dst;
  4844. }
  4845. posy += incy;
  4846. info->dst += info->dst_pitch;
  4847. }
  4848. }
  4849. static void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info)
  4850. {
  4851. const int flags = info->flags;
  4852. const Uint32 modulateR = info->r;
  4853. const Uint32 modulateG = info->g;
  4854. const Uint32 modulateB = info->b;
  4855. const Uint32 modulateA = info->a;
  4856. Uint32 pixel;
  4857. Uint32 R, G, B, A;
  4858. while (info->dst_h--) {
  4859. Uint32 *src = (Uint32 *)info->src;
  4860. Uint32 *dst = (Uint32 *)info->dst;
  4861. int n = info->dst_w;
  4862. while (n--) {
  4863. pixel = *src;
  4864. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  4865. if (flags & SDL_COPY_MODULATE_COLOR) {
  4866. R = (R * modulateR) / 255;
  4867. G = (G * modulateG) / 255;
  4868. B = (B * modulateB) / 255;
  4869. }
  4870. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4871. A = (A * modulateA) / 255;
  4872. }
  4873. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  4874. *dst = pixel;
  4875. ++src;
  4876. ++dst;
  4877. }
  4878. info->src += info->src_pitch;
  4879. info->dst += info->dst_pitch;
  4880. }
  4881. }
  4882. static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  4883. {
  4884. const int flags = info->flags;
  4885. const Uint32 modulateR = info->r;
  4886. const Uint32 modulateG = info->g;
  4887. const Uint32 modulateB = info->b;
  4888. const Uint32 modulateA = info->a;
  4889. Uint32 pixel;
  4890. Uint32 R, G, B, A;
  4891. int srcy, srcx;
  4892. int posy, posx;
  4893. int incy, incx;
  4894. srcy = 0;
  4895. posy = 0;
  4896. incy = (info->src_h << 16) / info->dst_h;
  4897. incx = (info->src_w << 16) / info->dst_w;
  4898. while (info->dst_h--) {
  4899. Uint32 *src = 0;
  4900. Uint32 *dst = (Uint32 *)info->dst;
  4901. int n = info->dst_w;
  4902. srcx = -1;
  4903. posx = 0x10000L;
  4904. while (posy >= 0x10000L) {
  4905. ++srcy;
  4906. posy -= 0x10000L;
  4907. }
  4908. while (n--) {
  4909. if (posx >= 0x10000L) {
  4910. while (posx >= 0x10000L) {
  4911. ++srcx;
  4912. posx -= 0x10000L;
  4913. }
  4914. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4915. }
  4916. pixel = *src;
  4917. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  4918. if (flags & SDL_COPY_MODULATE_COLOR) {
  4919. R = (R * modulateR) / 255;
  4920. G = (G * modulateG) / 255;
  4921. B = (B * modulateB) / 255;
  4922. }
  4923. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4924. A = (A * modulateA) / 255;
  4925. }
  4926. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  4927. *dst = pixel;
  4928. posx += incx;
  4929. ++dst;
  4930. }
  4931. posy += incy;
  4932. info->dst += info->dst_pitch;
  4933. }
  4934. }
  4935. static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  4936. {
  4937. const int flags = info->flags;
  4938. const Uint32 modulateR = info->r;
  4939. const Uint32 modulateG = info->g;
  4940. const Uint32 modulateB = info->b;
  4941. const Uint32 modulateA = info->a;
  4942. Uint32 srcpixel;
  4943. Uint32 srcR, srcG, srcB, srcA;
  4944. Uint32 dstpixel;
  4945. Uint32 dstR, dstG, dstB, dstA;
  4946. while (info->dst_h--) {
  4947. Uint32 *src = (Uint32 *)info->src;
  4948. Uint32 *dst = (Uint32 *)info->dst;
  4949. int n = info->dst_w;
  4950. while (n--) {
  4951. srcpixel = *src;
  4952. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  4953. dstpixel = *dst;
  4954. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  4955. if (flags & SDL_COPY_MODULATE_COLOR) {
  4956. srcR = (srcR * modulateR) / 255;
  4957. srcG = (srcG * modulateG) / 255;
  4958. srcB = (srcB * modulateB) / 255;
  4959. }
  4960. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4961. srcA = (srcA * modulateA) / 255;
  4962. }
  4963. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4964. /* This goes away if we ever use premultiplied alpha */
  4965. if (srcA < 255) {
  4966. srcR = (srcR * srcA) / 255;
  4967. srcG = (srcG * srcA) / 255;
  4968. srcB = (srcB * srcA) / 255;
  4969. }
  4970. }
  4971. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  4972. case SDL_COPY_BLEND:
  4973. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4974. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4975. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4976. break;
  4977. case SDL_COPY_ADD:
  4978. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4979. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4980. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4981. break;
  4982. case SDL_COPY_MOD:
  4983. dstR = (srcR * dstR) / 255;
  4984. dstG = (srcG * dstG) / 255;
  4985. dstB = (srcB * dstB) / 255;
  4986. break;
  4987. }
  4988. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  4989. *dst = dstpixel;
  4990. ++src;
  4991. ++dst;
  4992. }
  4993. info->src += info->src_pitch;
  4994. info->dst += info->dst_pitch;
  4995. }
  4996. }
  4997. static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4998. {
  4999. const int flags = info->flags;
  5000. const Uint32 modulateR = info->r;
  5001. const Uint32 modulateG = info->g;
  5002. const Uint32 modulateB = info->b;
  5003. const Uint32 modulateA = info->a;
  5004. Uint32 srcpixel;
  5005. Uint32 srcR, srcG, srcB, srcA;
  5006. Uint32 dstpixel;
  5007. Uint32 dstR, dstG, dstB, dstA;
  5008. int srcy, srcx;
  5009. int posy, posx;
  5010. int incy, incx;
  5011. srcy = 0;
  5012. posy = 0;
  5013. incy = (info->src_h << 16) / info->dst_h;
  5014. incx = (info->src_w << 16) / info->dst_w;
  5015. while (info->dst_h--) {
  5016. Uint32 *src = 0;
  5017. Uint32 *dst = (Uint32 *)info->dst;
  5018. int n = info->dst_w;
  5019. srcx = -1;
  5020. posx = 0x10000L;
  5021. while (posy >= 0x10000L) {
  5022. ++srcy;
  5023. posy -= 0x10000L;
  5024. }
  5025. while (n--) {
  5026. if (posx >= 0x10000L) {
  5027. while (posx >= 0x10000L) {
  5028. ++srcx;
  5029. posx -= 0x10000L;
  5030. }
  5031. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5032. }
  5033. srcpixel = *src;
  5034. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5035. dstpixel = *dst;
  5036. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  5037. if (flags & SDL_COPY_MODULATE_COLOR) {
  5038. srcR = (srcR * modulateR) / 255;
  5039. srcG = (srcG * modulateG) / 255;
  5040. srcB = (srcB * modulateB) / 255;
  5041. }
  5042. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5043. srcA = (srcA * modulateA) / 255;
  5044. }
  5045. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5046. /* This goes away if we ever use premultiplied alpha */
  5047. if (srcA < 255) {
  5048. srcR = (srcR * srcA) / 255;
  5049. srcG = (srcG * srcA) / 255;
  5050. srcB = (srcB * srcA) / 255;
  5051. }
  5052. }
  5053. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5054. case SDL_COPY_BLEND:
  5055. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5056. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5057. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5058. break;
  5059. case SDL_COPY_ADD:
  5060. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5061. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5062. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5063. break;
  5064. case SDL_COPY_MOD:
  5065. dstR = (srcR * dstR) / 255;
  5066. dstG = (srcG * dstG) / 255;
  5067. dstB = (srcB * dstB) / 255;
  5068. break;
  5069. }
  5070. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  5071. *dst = dstpixel;
  5072. posx += incx;
  5073. ++dst;
  5074. }
  5075. posy += incy;
  5076. info->dst += info->dst_pitch;
  5077. }
  5078. }
  5079. static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
  5080. {
  5081. Uint32 pixel;
  5082. Uint32 R, G, B, A;
  5083. int srcy, srcx;
  5084. int posy, posx;
  5085. int incy, incx;
  5086. srcy = 0;
  5087. posy = 0;
  5088. incy = (info->src_h << 16) / info->dst_h;
  5089. incx = (info->src_w << 16) / info->dst_w;
  5090. while (info->dst_h--) {
  5091. Uint32 *src = 0;
  5092. Uint32 *dst = (Uint32 *)info->dst;
  5093. int n = info->dst_w;
  5094. srcx = -1;
  5095. posx = 0x10000L;
  5096. while (posy >= 0x10000L) {
  5097. ++srcy;
  5098. posy -= 0x10000L;
  5099. }
  5100. while (n--) {
  5101. if (posx >= 0x10000L) {
  5102. while (posx >= 0x10000L) {
  5103. ++srcx;
  5104. posx -= 0x10000L;
  5105. }
  5106. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5107. }
  5108. pixel = *src;
  5109. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5110. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  5111. *dst = pixel;
  5112. posx += incx;
  5113. ++dst;
  5114. }
  5115. posy += incy;
  5116. info->dst += info->dst_pitch;
  5117. }
  5118. }
  5119. static void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info)
  5120. {
  5121. const int flags = info->flags;
  5122. Uint32 srcpixel;
  5123. Uint32 srcR, srcG, srcB, srcA;
  5124. Uint32 dstpixel;
  5125. Uint32 dstR, dstG, dstB, dstA;
  5126. while (info->dst_h--) {
  5127. Uint32 *src = (Uint32 *)info->src;
  5128. Uint32 *dst = (Uint32 *)info->dst;
  5129. int n = info->dst_w;
  5130. while (n--) {
  5131. srcpixel = *src;
  5132. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5133. dstpixel = *dst;
  5134. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  5135. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5136. /* This goes away if we ever use premultiplied alpha */
  5137. if (srcA < 255) {
  5138. srcR = (srcR * srcA) / 255;
  5139. srcG = (srcG * srcA) / 255;
  5140. srcB = (srcB * srcA) / 255;
  5141. }
  5142. }
  5143. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5144. case SDL_COPY_BLEND:
  5145. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5146. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5147. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5148. break;
  5149. case SDL_COPY_ADD:
  5150. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5151. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5152. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5153. break;
  5154. case SDL_COPY_MOD:
  5155. dstR = (srcR * dstR) / 255;
  5156. dstG = (srcG * dstG) / 255;
  5157. dstB = (srcB * dstB) / 255;
  5158. break;
  5159. }
  5160. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  5161. *dst = dstpixel;
  5162. ++src;
  5163. ++dst;
  5164. }
  5165. info->src += info->src_pitch;
  5166. info->dst += info->dst_pitch;
  5167. }
  5168. }
  5169. static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  5170. {
  5171. const int flags = info->flags;
  5172. Uint32 srcpixel;
  5173. Uint32 srcR, srcG, srcB, srcA;
  5174. Uint32 dstpixel;
  5175. Uint32 dstR, dstG, dstB, dstA;
  5176. int srcy, srcx;
  5177. int posy, posx;
  5178. int incy, incx;
  5179. srcy = 0;
  5180. posy = 0;
  5181. incy = (info->src_h << 16) / info->dst_h;
  5182. incx = (info->src_w << 16) / info->dst_w;
  5183. while (info->dst_h--) {
  5184. Uint32 *src = 0;
  5185. Uint32 *dst = (Uint32 *)info->dst;
  5186. int n = info->dst_w;
  5187. srcx = -1;
  5188. posx = 0x10000L;
  5189. while (posy >= 0x10000L) {
  5190. ++srcy;
  5191. posy -= 0x10000L;
  5192. }
  5193. while (n--) {
  5194. if (posx >= 0x10000L) {
  5195. while (posx >= 0x10000L) {
  5196. ++srcx;
  5197. posx -= 0x10000L;
  5198. }
  5199. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5200. }
  5201. srcpixel = *src;
  5202. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5203. dstpixel = *dst;
  5204. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  5205. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5206. /* This goes away if we ever use premultiplied alpha */
  5207. if (srcA < 255) {
  5208. srcR = (srcR * srcA) / 255;
  5209. srcG = (srcG * srcA) / 255;
  5210. srcB = (srcB * srcA) / 255;
  5211. }
  5212. }
  5213. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5214. case SDL_COPY_BLEND:
  5215. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5216. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5217. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5218. break;
  5219. case SDL_COPY_ADD:
  5220. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5221. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5222. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5223. break;
  5224. case SDL_COPY_MOD:
  5225. dstR = (srcR * dstR) / 255;
  5226. dstG = (srcG * dstG) / 255;
  5227. dstB = (srcB * dstB) / 255;
  5228. break;
  5229. }
  5230. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  5231. *dst = dstpixel;
  5232. posx += incx;
  5233. ++dst;
  5234. }
  5235. posy += incy;
  5236. info->dst += info->dst_pitch;
  5237. }
  5238. }
  5239. static void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info)
  5240. {
  5241. const int flags = info->flags;
  5242. const Uint32 modulateR = info->r;
  5243. const Uint32 modulateG = info->g;
  5244. const Uint32 modulateB = info->b;
  5245. const Uint32 modulateA = info->a;
  5246. Uint32 pixel;
  5247. Uint32 R, G, B, A;
  5248. while (info->dst_h--) {
  5249. Uint32 *src = (Uint32 *)info->src;
  5250. Uint32 *dst = (Uint32 *)info->dst;
  5251. int n = info->dst_w;
  5252. while (n--) {
  5253. pixel = *src;
  5254. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5255. if (flags & SDL_COPY_MODULATE_COLOR) {
  5256. R = (R * modulateR) / 255;
  5257. G = (G * modulateG) / 255;
  5258. B = (B * modulateB) / 255;
  5259. }
  5260. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5261. A = (A * modulateA) / 255;
  5262. }
  5263. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  5264. *dst = pixel;
  5265. ++src;
  5266. ++dst;
  5267. }
  5268. info->src += info->src_pitch;
  5269. info->dst += info->dst_pitch;
  5270. }
  5271. }
  5272. static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  5273. {
  5274. const int flags = info->flags;
  5275. const Uint32 modulateR = info->r;
  5276. const Uint32 modulateG = info->g;
  5277. const Uint32 modulateB = info->b;
  5278. const Uint32 modulateA = info->a;
  5279. Uint32 pixel;
  5280. Uint32 R, G, B, A;
  5281. int srcy, srcx;
  5282. int posy, posx;
  5283. int incy, incx;
  5284. srcy = 0;
  5285. posy = 0;
  5286. incy = (info->src_h << 16) / info->dst_h;
  5287. incx = (info->src_w << 16) / info->dst_w;
  5288. while (info->dst_h--) {
  5289. Uint32 *src = 0;
  5290. Uint32 *dst = (Uint32 *)info->dst;
  5291. int n = info->dst_w;
  5292. srcx = -1;
  5293. posx = 0x10000L;
  5294. while (posy >= 0x10000L) {
  5295. ++srcy;
  5296. posy -= 0x10000L;
  5297. }
  5298. while (n--) {
  5299. if (posx >= 0x10000L) {
  5300. while (posx >= 0x10000L) {
  5301. ++srcx;
  5302. posx -= 0x10000L;
  5303. }
  5304. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5305. }
  5306. pixel = *src;
  5307. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5308. if (flags & SDL_COPY_MODULATE_COLOR) {
  5309. R = (R * modulateR) / 255;
  5310. G = (G * modulateG) / 255;
  5311. B = (B * modulateB) / 255;
  5312. }
  5313. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5314. A = (A * modulateA) / 255;
  5315. }
  5316. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  5317. *dst = pixel;
  5318. posx += incx;
  5319. ++dst;
  5320. }
  5321. posy += incy;
  5322. info->dst += info->dst_pitch;
  5323. }
  5324. }
  5325. static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  5326. {
  5327. const int flags = info->flags;
  5328. const Uint32 modulateR = info->r;
  5329. const Uint32 modulateG = info->g;
  5330. const Uint32 modulateB = info->b;
  5331. const Uint32 modulateA = info->a;
  5332. Uint32 srcpixel;
  5333. Uint32 srcR, srcG, srcB, srcA;
  5334. Uint32 dstpixel;
  5335. Uint32 dstR, dstG, dstB, dstA;
  5336. while (info->dst_h--) {
  5337. Uint32 *src = (Uint32 *)info->src;
  5338. Uint32 *dst = (Uint32 *)info->dst;
  5339. int n = info->dst_w;
  5340. while (n--) {
  5341. srcpixel = *src;
  5342. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5343. dstpixel = *dst;
  5344. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  5345. if (flags & SDL_COPY_MODULATE_COLOR) {
  5346. srcR = (srcR * modulateR) / 255;
  5347. srcG = (srcG * modulateG) / 255;
  5348. srcB = (srcB * modulateB) / 255;
  5349. }
  5350. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5351. srcA = (srcA * modulateA) / 255;
  5352. }
  5353. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5354. /* This goes away if we ever use premultiplied alpha */
  5355. if (srcA < 255) {
  5356. srcR = (srcR * srcA) / 255;
  5357. srcG = (srcG * srcA) / 255;
  5358. srcB = (srcB * srcA) / 255;
  5359. }
  5360. }
  5361. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5362. case SDL_COPY_BLEND:
  5363. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5364. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5365. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5366. break;
  5367. case SDL_COPY_ADD:
  5368. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5369. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5370. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5371. break;
  5372. case SDL_COPY_MOD:
  5373. dstR = (srcR * dstR) / 255;
  5374. dstG = (srcG * dstG) / 255;
  5375. dstB = (srcB * dstB) / 255;
  5376. break;
  5377. }
  5378. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  5379. *dst = dstpixel;
  5380. ++src;
  5381. ++dst;
  5382. }
  5383. info->src += info->src_pitch;
  5384. info->dst += info->dst_pitch;
  5385. }
  5386. }
  5387. static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5388. {
  5389. const int flags = info->flags;
  5390. const Uint32 modulateR = info->r;
  5391. const Uint32 modulateG = info->g;
  5392. const Uint32 modulateB = info->b;
  5393. const Uint32 modulateA = info->a;
  5394. Uint32 srcpixel;
  5395. Uint32 srcR, srcG, srcB, srcA;
  5396. Uint32 dstpixel;
  5397. Uint32 dstR, dstG, dstB, dstA;
  5398. int srcy, srcx;
  5399. int posy, posx;
  5400. int incy, incx;
  5401. srcy = 0;
  5402. posy = 0;
  5403. incy = (info->src_h << 16) / info->dst_h;
  5404. incx = (info->src_w << 16) / info->dst_w;
  5405. while (info->dst_h--) {
  5406. Uint32 *src = 0;
  5407. Uint32 *dst = (Uint32 *)info->dst;
  5408. int n = info->dst_w;
  5409. srcx = -1;
  5410. posx = 0x10000L;
  5411. while (posy >= 0x10000L) {
  5412. ++srcy;
  5413. posy -= 0x10000L;
  5414. }
  5415. while (n--) {
  5416. if (posx >= 0x10000L) {
  5417. while (posx >= 0x10000L) {
  5418. ++srcx;
  5419. posx -= 0x10000L;
  5420. }
  5421. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5422. }
  5423. srcpixel = *src;
  5424. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5425. dstpixel = *dst;
  5426. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  5427. if (flags & SDL_COPY_MODULATE_COLOR) {
  5428. srcR = (srcR * modulateR) / 255;
  5429. srcG = (srcG * modulateG) / 255;
  5430. srcB = (srcB * modulateB) / 255;
  5431. }
  5432. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5433. srcA = (srcA * modulateA) / 255;
  5434. }
  5435. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5436. /* This goes away if we ever use premultiplied alpha */
  5437. if (srcA < 255) {
  5438. srcR = (srcR * srcA) / 255;
  5439. srcG = (srcG * srcA) / 255;
  5440. srcB = (srcB * srcA) / 255;
  5441. }
  5442. }
  5443. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5444. case SDL_COPY_BLEND:
  5445. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5446. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5447. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5448. break;
  5449. case SDL_COPY_ADD:
  5450. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5451. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5452. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5453. break;
  5454. case SDL_COPY_MOD:
  5455. dstR = (srcR * dstR) / 255;
  5456. dstG = (srcG * dstG) / 255;
  5457. dstB = (srcB * dstB) / 255;
  5458. break;
  5459. }
  5460. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  5461. *dst = dstpixel;
  5462. posx += incx;
  5463. ++dst;
  5464. }
  5465. posy += incy;
  5466. info->dst += info->dst_pitch;
  5467. }
  5468. }
  5469. static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
  5470. {
  5471. Uint32 pixel;
  5472. Uint32 R, G, B, A;
  5473. int srcy, srcx;
  5474. int posy, posx;
  5475. int incy, incx;
  5476. srcy = 0;
  5477. posy = 0;
  5478. incy = (info->src_h << 16) / info->dst_h;
  5479. incx = (info->src_w << 16) / info->dst_w;
  5480. while (info->dst_h--) {
  5481. Uint32 *src = 0;
  5482. Uint32 *dst = (Uint32 *)info->dst;
  5483. int n = info->dst_w;
  5484. srcx = -1;
  5485. posx = 0x10000L;
  5486. while (posy >= 0x10000L) {
  5487. ++srcy;
  5488. posy -= 0x10000L;
  5489. }
  5490. while (n--) {
  5491. if (posx >= 0x10000L) {
  5492. while (posx >= 0x10000L) {
  5493. ++srcx;
  5494. posx -= 0x10000L;
  5495. }
  5496. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5497. }
  5498. pixel = *src;
  5499. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5500. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  5501. *dst = pixel;
  5502. posx += incx;
  5503. ++dst;
  5504. }
  5505. posy += incy;
  5506. info->dst += info->dst_pitch;
  5507. }
  5508. }
  5509. static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
  5510. {
  5511. const int flags = info->flags;
  5512. Uint32 srcpixel;
  5513. Uint32 srcR, srcG, srcB, srcA;
  5514. Uint32 dstpixel;
  5515. Uint32 dstR, dstG, dstB, dstA;
  5516. while (info->dst_h--) {
  5517. Uint32 *src = (Uint32 *)info->src;
  5518. Uint32 *dst = (Uint32 *)info->dst;
  5519. int n = info->dst_w;
  5520. while (n--) {
  5521. srcpixel = *src;
  5522. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5523. dstpixel = *dst;
  5524. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5525. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5526. /* This goes away if we ever use premultiplied alpha */
  5527. if (srcA < 255) {
  5528. srcR = (srcR * srcA) / 255;
  5529. srcG = (srcG * srcA) / 255;
  5530. srcB = (srcB * srcA) / 255;
  5531. }
  5532. }
  5533. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5534. case SDL_COPY_BLEND:
  5535. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5536. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5537. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5538. break;
  5539. case SDL_COPY_ADD:
  5540. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5541. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5542. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5543. break;
  5544. case SDL_COPY_MOD:
  5545. dstR = (srcR * dstR) / 255;
  5546. dstG = (srcG * dstG) / 255;
  5547. dstB = (srcB * dstB) / 255;
  5548. break;
  5549. }
  5550. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  5551. *dst = dstpixel;
  5552. ++src;
  5553. ++dst;
  5554. }
  5555. info->src += info->src_pitch;
  5556. info->dst += info->dst_pitch;
  5557. }
  5558. }
  5559. static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  5560. {
  5561. const int flags = info->flags;
  5562. Uint32 srcpixel;
  5563. Uint32 srcR, srcG, srcB, srcA;
  5564. Uint32 dstpixel;
  5565. Uint32 dstR, dstG, dstB, dstA;
  5566. int srcy, srcx;
  5567. int posy, posx;
  5568. int incy, incx;
  5569. srcy = 0;
  5570. posy = 0;
  5571. incy = (info->src_h << 16) / info->dst_h;
  5572. incx = (info->src_w << 16) / info->dst_w;
  5573. while (info->dst_h--) {
  5574. Uint32 *src = 0;
  5575. Uint32 *dst = (Uint32 *)info->dst;
  5576. int n = info->dst_w;
  5577. srcx = -1;
  5578. posx = 0x10000L;
  5579. while (posy >= 0x10000L) {
  5580. ++srcy;
  5581. posy -= 0x10000L;
  5582. }
  5583. while (n--) {
  5584. if (posx >= 0x10000L) {
  5585. while (posx >= 0x10000L) {
  5586. ++srcx;
  5587. posx -= 0x10000L;
  5588. }
  5589. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5590. }
  5591. srcpixel = *src;
  5592. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5593. dstpixel = *dst;
  5594. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5595. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5596. /* This goes away if we ever use premultiplied alpha */
  5597. if (srcA < 255) {
  5598. srcR = (srcR * srcA) / 255;
  5599. srcG = (srcG * srcA) / 255;
  5600. srcB = (srcB * srcA) / 255;
  5601. }
  5602. }
  5603. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5604. case SDL_COPY_BLEND:
  5605. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5606. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5607. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5608. break;
  5609. case SDL_COPY_ADD:
  5610. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5611. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5612. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5613. break;
  5614. case SDL_COPY_MOD:
  5615. dstR = (srcR * dstR) / 255;
  5616. dstG = (srcG * dstG) / 255;
  5617. dstB = (srcB * dstB) / 255;
  5618. break;
  5619. }
  5620. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  5621. *dst = dstpixel;
  5622. posx += incx;
  5623. ++dst;
  5624. }
  5625. posy += incy;
  5626. info->dst += info->dst_pitch;
  5627. }
  5628. }
  5629. static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  5630. {
  5631. const int flags = info->flags;
  5632. const Uint32 modulateR = info->r;
  5633. const Uint32 modulateG = info->g;
  5634. const Uint32 modulateB = info->b;
  5635. const Uint32 modulateA = info->a;
  5636. Uint32 pixel;
  5637. Uint32 R, G, B, A;
  5638. while (info->dst_h--) {
  5639. Uint32 *src = (Uint32 *)info->src;
  5640. Uint32 *dst = (Uint32 *)info->dst;
  5641. int n = info->dst_w;
  5642. while (n--) {
  5643. pixel = *src;
  5644. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5645. if (flags & SDL_COPY_MODULATE_COLOR) {
  5646. R = (R * modulateR) / 255;
  5647. G = (G * modulateG) / 255;
  5648. B = (B * modulateB) / 255;
  5649. }
  5650. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5651. A = (A * modulateA) / 255;
  5652. }
  5653. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  5654. *dst = pixel;
  5655. ++src;
  5656. ++dst;
  5657. }
  5658. info->src += info->src_pitch;
  5659. info->dst += info->dst_pitch;
  5660. }
  5661. }
  5662. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  5663. {
  5664. const int flags = info->flags;
  5665. const Uint32 modulateR = info->r;
  5666. const Uint32 modulateG = info->g;
  5667. const Uint32 modulateB = info->b;
  5668. const Uint32 modulateA = info->a;
  5669. Uint32 pixel;
  5670. Uint32 R, G, B, A;
  5671. int srcy, srcx;
  5672. int posy, posx;
  5673. int incy, incx;
  5674. srcy = 0;
  5675. posy = 0;
  5676. incy = (info->src_h << 16) / info->dst_h;
  5677. incx = (info->src_w << 16) / info->dst_w;
  5678. while (info->dst_h--) {
  5679. Uint32 *src = 0;
  5680. Uint32 *dst = (Uint32 *)info->dst;
  5681. int n = info->dst_w;
  5682. srcx = -1;
  5683. posx = 0x10000L;
  5684. while (posy >= 0x10000L) {
  5685. ++srcy;
  5686. posy -= 0x10000L;
  5687. }
  5688. while (n--) {
  5689. if (posx >= 0x10000L) {
  5690. while (posx >= 0x10000L) {
  5691. ++srcx;
  5692. posx -= 0x10000L;
  5693. }
  5694. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5695. }
  5696. pixel = *src;
  5697. A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5698. if (flags & SDL_COPY_MODULATE_COLOR) {
  5699. R = (R * modulateR) / 255;
  5700. G = (G * modulateG) / 255;
  5701. B = (B * modulateB) / 255;
  5702. }
  5703. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5704. A = (A * modulateA) / 255;
  5705. }
  5706. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  5707. *dst = pixel;
  5708. posx += incx;
  5709. ++dst;
  5710. }
  5711. posy += incy;
  5712. info->dst += info->dst_pitch;
  5713. }
  5714. }
  5715. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  5716. {
  5717. const int flags = info->flags;
  5718. const Uint32 modulateR = info->r;
  5719. const Uint32 modulateG = info->g;
  5720. const Uint32 modulateB = info->b;
  5721. const Uint32 modulateA = info->a;
  5722. Uint32 srcpixel;
  5723. Uint32 srcR, srcG, srcB, srcA;
  5724. Uint32 dstpixel;
  5725. Uint32 dstR, dstG, dstB, dstA;
  5726. while (info->dst_h--) {
  5727. Uint32 *src = (Uint32 *)info->src;
  5728. Uint32 *dst = (Uint32 *)info->dst;
  5729. int n = info->dst_w;
  5730. while (n--) {
  5731. srcpixel = *src;
  5732. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5733. dstpixel = *dst;
  5734. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5735. if (flags & SDL_COPY_MODULATE_COLOR) {
  5736. srcR = (srcR * modulateR) / 255;
  5737. srcG = (srcG * modulateG) / 255;
  5738. srcB = (srcB * modulateB) / 255;
  5739. }
  5740. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5741. srcA = (srcA * modulateA) / 255;
  5742. }
  5743. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5744. /* This goes away if we ever use premultiplied alpha */
  5745. if (srcA < 255) {
  5746. srcR = (srcR * srcA) / 255;
  5747. srcG = (srcG * srcA) / 255;
  5748. srcB = (srcB * srcA) / 255;
  5749. }
  5750. }
  5751. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5752. case SDL_COPY_BLEND:
  5753. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5754. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5755. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5756. break;
  5757. case SDL_COPY_ADD:
  5758. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5759. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5760. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5761. break;
  5762. case SDL_COPY_MOD:
  5763. dstR = (srcR * dstR) / 255;
  5764. dstG = (srcG * dstG) / 255;
  5765. dstB = (srcB * dstB) / 255;
  5766. break;
  5767. }
  5768. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  5769. *dst = dstpixel;
  5770. ++src;
  5771. ++dst;
  5772. }
  5773. info->src += info->src_pitch;
  5774. info->dst += info->dst_pitch;
  5775. }
  5776. }
  5777. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5778. {
  5779. const int flags = info->flags;
  5780. const Uint32 modulateR = info->r;
  5781. const Uint32 modulateG = info->g;
  5782. const Uint32 modulateB = info->b;
  5783. const Uint32 modulateA = info->a;
  5784. Uint32 srcpixel;
  5785. Uint32 srcR, srcG, srcB, srcA;
  5786. Uint32 dstpixel;
  5787. Uint32 dstR, dstG, dstB, dstA;
  5788. int srcy, srcx;
  5789. int posy, posx;
  5790. int incy, incx;
  5791. srcy = 0;
  5792. posy = 0;
  5793. incy = (info->src_h << 16) / info->dst_h;
  5794. incx = (info->src_w << 16) / info->dst_w;
  5795. while (info->dst_h--) {
  5796. Uint32 *src = 0;
  5797. Uint32 *dst = (Uint32 *)info->dst;
  5798. int n = info->dst_w;
  5799. srcx = -1;
  5800. posx = 0x10000L;
  5801. while (posy >= 0x10000L) {
  5802. ++srcy;
  5803. posy -= 0x10000L;
  5804. }
  5805. while (n--) {
  5806. if (posx >= 0x10000L) {
  5807. while (posx >= 0x10000L) {
  5808. ++srcx;
  5809. posx -= 0x10000L;
  5810. }
  5811. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5812. }
  5813. srcpixel = *src;
  5814. srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  5815. dstpixel = *dst;
  5816. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5817. if (flags & SDL_COPY_MODULATE_COLOR) {
  5818. srcR = (srcR * modulateR) / 255;
  5819. srcG = (srcG * modulateG) / 255;
  5820. srcB = (srcB * modulateB) / 255;
  5821. }
  5822. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5823. srcA = (srcA * modulateA) / 255;
  5824. }
  5825. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5826. /* This goes away if we ever use premultiplied alpha */
  5827. if (srcA < 255) {
  5828. srcR = (srcR * srcA) / 255;
  5829. srcG = (srcG * srcA) / 255;
  5830. srcB = (srcB * srcA) / 255;
  5831. }
  5832. }
  5833. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5834. case SDL_COPY_BLEND:
  5835. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5836. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5837. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5838. break;
  5839. case SDL_COPY_ADD:
  5840. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5841. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5842. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5843. break;
  5844. case SDL_COPY_MOD:
  5845. dstR = (srcR * dstR) / 255;
  5846. dstG = (srcG * dstG) / 255;
  5847. dstB = (srcB * dstB) / 255;
  5848. break;
  5849. }
  5850. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  5851. *dst = dstpixel;
  5852. posx += incx;
  5853. ++dst;
  5854. }
  5855. posy += incy;
  5856. info->dst += info->dst_pitch;
  5857. }
  5858. }
  5859. static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info)
  5860. {
  5861. Uint32 pixel;
  5862. Uint32 R, G, B, A;
  5863. int srcy, srcx;
  5864. int posy, posx;
  5865. int incy, incx;
  5866. srcy = 0;
  5867. posy = 0;
  5868. incy = (info->src_h << 16) / info->dst_h;
  5869. incx = (info->src_w << 16) / info->dst_w;
  5870. while (info->dst_h--) {
  5871. Uint32 *src = 0;
  5872. Uint32 *dst = (Uint32 *)info->dst;
  5873. int n = info->dst_w;
  5874. srcx = -1;
  5875. posx = 0x10000L;
  5876. while (posy >= 0x10000L) {
  5877. ++srcy;
  5878. posy -= 0x10000L;
  5879. }
  5880. while (n--) {
  5881. if (posx >= 0x10000L) {
  5882. while (posx >= 0x10000L) {
  5883. ++srcx;
  5884. posx -= 0x10000L;
  5885. }
  5886. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5887. }
  5888. pixel = *src;
  5889. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  5890. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  5891. *dst = pixel;
  5892. posx += incx;
  5893. ++dst;
  5894. }
  5895. posy += incy;
  5896. info->dst += info->dst_pitch;
  5897. }
  5898. }
  5899. static void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info)
  5900. {
  5901. const int flags = info->flags;
  5902. Uint32 srcpixel;
  5903. Uint32 srcR, srcG, srcB, srcA;
  5904. Uint32 dstpixel;
  5905. Uint32 dstR, dstG, dstB, dstA;
  5906. while (info->dst_h--) {
  5907. Uint32 *src = (Uint32 *)info->src;
  5908. Uint32 *dst = (Uint32 *)info->dst;
  5909. int n = info->dst_w;
  5910. while (n--) {
  5911. srcpixel = *src;
  5912. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5913. dstpixel = *dst;
  5914. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  5915. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5916. /* This goes away if we ever use premultiplied alpha */
  5917. if (srcA < 255) {
  5918. srcR = (srcR * srcA) / 255;
  5919. srcG = (srcG * srcA) / 255;
  5920. srcB = (srcB * srcA) / 255;
  5921. }
  5922. }
  5923. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5924. case SDL_COPY_BLEND:
  5925. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5926. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5927. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5928. break;
  5929. case SDL_COPY_ADD:
  5930. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5931. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5932. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5933. break;
  5934. case SDL_COPY_MOD:
  5935. dstR = (srcR * dstR) / 255;
  5936. dstG = (srcG * dstG) / 255;
  5937. dstB = (srcB * dstB) / 255;
  5938. break;
  5939. }
  5940. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  5941. *dst = dstpixel;
  5942. ++src;
  5943. ++dst;
  5944. }
  5945. info->src += info->src_pitch;
  5946. info->dst += info->dst_pitch;
  5947. }
  5948. }
  5949. static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  5950. {
  5951. const int flags = info->flags;
  5952. Uint32 srcpixel;
  5953. Uint32 srcR, srcG, srcB, srcA;
  5954. Uint32 dstpixel;
  5955. Uint32 dstR, dstG, dstB, dstA;
  5956. int srcy, srcx;
  5957. int posy, posx;
  5958. int incy, incx;
  5959. srcy = 0;
  5960. posy = 0;
  5961. incy = (info->src_h << 16) / info->dst_h;
  5962. incx = (info->src_w << 16) / info->dst_w;
  5963. while (info->dst_h--) {
  5964. Uint32 *src = 0;
  5965. Uint32 *dst = (Uint32 *)info->dst;
  5966. int n = info->dst_w;
  5967. srcx = -1;
  5968. posx = 0x10000L;
  5969. while (posy >= 0x10000L) {
  5970. ++srcy;
  5971. posy -= 0x10000L;
  5972. }
  5973. while (n--) {
  5974. if (posx >= 0x10000L) {
  5975. while (posx >= 0x10000L) {
  5976. ++srcx;
  5977. posx -= 0x10000L;
  5978. }
  5979. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5980. }
  5981. srcpixel = *src;
  5982. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5983. dstpixel = *dst;
  5984. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  5985. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5986. /* This goes away if we ever use premultiplied alpha */
  5987. if (srcA < 255) {
  5988. srcR = (srcR * srcA) / 255;
  5989. srcG = (srcG * srcA) / 255;
  5990. srcB = (srcB * srcA) / 255;
  5991. }
  5992. }
  5993. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  5994. case SDL_COPY_BLEND:
  5995. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5996. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5997. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5998. break;
  5999. case SDL_COPY_ADD:
  6000. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6001. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6002. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6003. break;
  6004. case SDL_COPY_MOD:
  6005. dstR = (srcR * dstR) / 255;
  6006. dstG = (srcG * dstG) / 255;
  6007. dstB = (srcB * dstB) / 255;
  6008. break;
  6009. }
  6010. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  6011. *dst = dstpixel;
  6012. posx += incx;
  6013. ++dst;
  6014. }
  6015. posy += incy;
  6016. info->dst += info->dst_pitch;
  6017. }
  6018. }
  6019. static void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info)
  6020. {
  6021. const int flags = info->flags;
  6022. const Uint32 modulateR = info->r;
  6023. const Uint32 modulateG = info->g;
  6024. const Uint32 modulateB = info->b;
  6025. const Uint32 modulateA = info->a;
  6026. Uint32 pixel;
  6027. Uint32 R, G, B, A;
  6028. while (info->dst_h--) {
  6029. Uint32 *src = (Uint32 *)info->src;
  6030. Uint32 *dst = (Uint32 *)info->dst;
  6031. int n = info->dst_w;
  6032. while (n--) {
  6033. pixel = *src;
  6034. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6035. if (flags & SDL_COPY_MODULATE_COLOR) {
  6036. R = (R * modulateR) / 255;
  6037. G = (G * modulateG) / 255;
  6038. B = (B * modulateB) / 255;
  6039. }
  6040. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6041. A = (A * modulateA) / 255;
  6042. }
  6043. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  6044. *dst = pixel;
  6045. ++src;
  6046. ++dst;
  6047. }
  6048. info->src += info->src_pitch;
  6049. info->dst += info->dst_pitch;
  6050. }
  6051. }
  6052. static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  6053. {
  6054. const int flags = info->flags;
  6055. const Uint32 modulateR = info->r;
  6056. const Uint32 modulateG = info->g;
  6057. const Uint32 modulateB = info->b;
  6058. const Uint32 modulateA = info->a;
  6059. Uint32 pixel;
  6060. Uint32 R, G, B, A;
  6061. int srcy, srcx;
  6062. int posy, posx;
  6063. int incy, incx;
  6064. srcy = 0;
  6065. posy = 0;
  6066. incy = (info->src_h << 16) / info->dst_h;
  6067. incx = (info->src_w << 16) / info->dst_w;
  6068. while (info->dst_h--) {
  6069. Uint32 *src = 0;
  6070. Uint32 *dst = (Uint32 *)info->dst;
  6071. int n = info->dst_w;
  6072. srcx = -1;
  6073. posx = 0x10000L;
  6074. while (posy >= 0x10000L) {
  6075. ++srcy;
  6076. posy -= 0x10000L;
  6077. }
  6078. while (n--) {
  6079. if (posx >= 0x10000L) {
  6080. while (posx >= 0x10000L) {
  6081. ++srcx;
  6082. posx -= 0x10000L;
  6083. }
  6084. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6085. }
  6086. pixel = *src;
  6087. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6088. if (flags & SDL_COPY_MODULATE_COLOR) {
  6089. R = (R * modulateR) / 255;
  6090. G = (G * modulateG) / 255;
  6091. B = (B * modulateB) / 255;
  6092. }
  6093. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6094. A = (A * modulateA) / 255;
  6095. }
  6096. pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  6097. *dst = pixel;
  6098. posx += incx;
  6099. ++dst;
  6100. }
  6101. posy += incy;
  6102. info->dst += info->dst_pitch;
  6103. }
  6104. }
  6105. static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  6106. {
  6107. const int flags = info->flags;
  6108. const Uint32 modulateR = info->r;
  6109. const Uint32 modulateG = info->g;
  6110. const Uint32 modulateB = info->b;
  6111. const Uint32 modulateA = info->a;
  6112. Uint32 srcpixel;
  6113. Uint32 srcR, srcG, srcB, srcA;
  6114. Uint32 dstpixel;
  6115. Uint32 dstR, dstG, dstB, dstA;
  6116. while (info->dst_h--) {
  6117. Uint32 *src = (Uint32 *)info->src;
  6118. Uint32 *dst = (Uint32 *)info->dst;
  6119. int n = info->dst_w;
  6120. while (n--) {
  6121. srcpixel = *src;
  6122. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6123. dstpixel = *dst;
  6124. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  6125. if (flags & SDL_COPY_MODULATE_COLOR) {
  6126. srcR = (srcR * modulateR) / 255;
  6127. srcG = (srcG * modulateG) / 255;
  6128. srcB = (srcB * modulateB) / 255;
  6129. }
  6130. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6131. srcA = (srcA * modulateA) / 255;
  6132. }
  6133. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6134. /* This goes away if we ever use premultiplied alpha */
  6135. if (srcA < 255) {
  6136. srcR = (srcR * srcA) / 255;
  6137. srcG = (srcG * srcA) / 255;
  6138. srcB = (srcB * srcA) / 255;
  6139. }
  6140. }
  6141. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6142. case SDL_COPY_BLEND:
  6143. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6144. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6145. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6146. break;
  6147. case SDL_COPY_ADD:
  6148. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6149. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6150. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6151. break;
  6152. case SDL_COPY_MOD:
  6153. dstR = (srcR * dstR) / 255;
  6154. dstG = (srcG * dstG) / 255;
  6155. dstB = (srcB * dstB) / 255;
  6156. break;
  6157. }
  6158. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  6159. *dst = dstpixel;
  6160. ++src;
  6161. ++dst;
  6162. }
  6163. info->src += info->src_pitch;
  6164. info->dst += info->dst_pitch;
  6165. }
  6166. }
  6167. static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6168. {
  6169. const int flags = info->flags;
  6170. const Uint32 modulateR = info->r;
  6171. const Uint32 modulateG = info->g;
  6172. const Uint32 modulateB = info->b;
  6173. const Uint32 modulateA = info->a;
  6174. Uint32 srcpixel;
  6175. Uint32 srcR, srcG, srcB, srcA;
  6176. Uint32 dstpixel;
  6177. Uint32 dstR, dstG, dstB, dstA;
  6178. int srcy, srcx;
  6179. int posy, posx;
  6180. int incy, incx;
  6181. srcy = 0;
  6182. posy = 0;
  6183. incy = (info->src_h << 16) / info->dst_h;
  6184. incx = (info->src_w << 16) / info->dst_w;
  6185. while (info->dst_h--) {
  6186. Uint32 *src = 0;
  6187. Uint32 *dst = (Uint32 *)info->dst;
  6188. int n = info->dst_w;
  6189. srcx = -1;
  6190. posx = 0x10000L;
  6191. while (posy >= 0x10000L) {
  6192. ++srcy;
  6193. posy -= 0x10000L;
  6194. }
  6195. while (n--) {
  6196. if (posx >= 0x10000L) {
  6197. while (posx >= 0x10000L) {
  6198. ++srcx;
  6199. posx -= 0x10000L;
  6200. }
  6201. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6202. }
  6203. srcpixel = *src;
  6204. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6205. dstpixel = *dst;
  6206. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  6207. if (flags & SDL_COPY_MODULATE_COLOR) {
  6208. srcR = (srcR * modulateR) / 255;
  6209. srcG = (srcG * modulateG) / 255;
  6210. srcB = (srcB * modulateB) / 255;
  6211. }
  6212. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6213. srcA = (srcA * modulateA) / 255;
  6214. }
  6215. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6216. /* This goes away if we ever use premultiplied alpha */
  6217. if (srcA < 255) {
  6218. srcR = (srcR * srcA) / 255;
  6219. srcG = (srcG * srcA) / 255;
  6220. srcB = (srcB * srcA) / 255;
  6221. }
  6222. }
  6223. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6224. case SDL_COPY_BLEND:
  6225. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6226. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6227. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6228. break;
  6229. case SDL_COPY_ADD:
  6230. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6231. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6232. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6233. break;
  6234. case SDL_COPY_MOD:
  6235. dstR = (srcR * dstR) / 255;
  6236. dstG = (srcG * dstG) / 255;
  6237. dstB = (srcB * dstB) / 255;
  6238. break;
  6239. }
  6240. dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  6241. *dst = dstpixel;
  6242. posx += incx;
  6243. ++dst;
  6244. }
  6245. posy += incy;
  6246. info->dst += info->dst_pitch;
  6247. }
  6248. }
  6249. static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
  6250. {
  6251. Uint32 pixel;
  6252. Uint32 R, G, B, A;
  6253. int srcy, srcx;
  6254. int posy, posx;
  6255. int incy, incx;
  6256. srcy = 0;
  6257. posy = 0;
  6258. incy = (info->src_h << 16) / info->dst_h;
  6259. incx = (info->src_w << 16) / info->dst_w;
  6260. while (info->dst_h--) {
  6261. Uint32 *src = 0;
  6262. Uint32 *dst = (Uint32 *)info->dst;
  6263. int n = info->dst_w;
  6264. srcx = -1;
  6265. posx = 0x10000L;
  6266. while (posy >= 0x10000L) {
  6267. ++srcy;
  6268. posy -= 0x10000L;
  6269. }
  6270. while (n--) {
  6271. if (posx >= 0x10000L) {
  6272. while (posx >= 0x10000L) {
  6273. ++srcx;
  6274. posx -= 0x10000L;
  6275. }
  6276. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6277. }
  6278. pixel = *src;
  6279. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6280. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  6281. *dst = pixel;
  6282. posx += incx;
  6283. ++dst;
  6284. }
  6285. posy += incy;
  6286. info->dst += info->dst_pitch;
  6287. }
  6288. }
  6289. static void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info)
  6290. {
  6291. const int flags = info->flags;
  6292. Uint32 srcpixel;
  6293. Uint32 srcR, srcG, srcB, srcA;
  6294. Uint32 dstpixel;
  6295. Uint32 dstR, dstG, dstB, dstA;
  6296. while (info->dst_h--) {
  6297. Uint32 *src = (Uint32 *)info->src;
  6298. Uint32 *dst = (Uint32 *)info->dst;
  6299. int n = info->dst_w;
  6300. while (n--) {
  6301. srcpixel = *src;
  6302. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6303. dstpixel = *dst;
  6304. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  6305. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6306. /* This goes away if we ever use premultiplied alpha */
  6307. if (srcA < 255) {
  6308. srcR = (srcR * srcA) / 255;
  6309. srcG = (srcG * srcA) / 255;
  6310. srcB = (srcB * srcA) / 255;
  6311. }
  6312. }
  6313. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6314. case SDL_COPY_BLEND:
  6315. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6316. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6317. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6318. break;
  6319. case SDL_COPY_ADD:
  6320. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6321. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6322. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6323. break;
  6324. case SDL_COPY_MOD:
  6325. dstR = (srcR * dstR) / 255;
  6326. dstG = (srcG * dstG) / 255;
  6327. dstB = (srcB * dstB) / 255;
  6328. break;
  6329. }
  6330. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  6331. *dst = dstpixel;
  6332. ++src;
  6333. ++dst;
  6334. }
  6335. info->src += info->src_pitch;
  6336. info->dst += info->dst_pitch;
  6337. }
  6338. }
  6339. static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  6340. {
  6341. const int flags = info->flags;
  6342. Uint32 srcpixel;
  6343. Uint32 srcR, srcG, srcB, srcA;
  6344. Uint32 dstpixel;
  6345. Uint32 dstR, dstG, dstB, dstA;
  6346. int srcy, srcx;
  6347. int posy, posx;
  6348. int incy, incx;
  6349. srcy = 0;
  6350. posy = 0;
  6351. incy = (info->src_h << 16) / info->dst_h;
  6352. incx = (info->src_w << 16) / info->dst_w;
  6353. while (info->dst_h--) {
  6354. Uint32 *src = 0;
  6355. Uint32 *dst = (Uint32 *)info->dst;
  6356. int n = info->dst_w;
  6357. srcx = -1;
  6358. posx = 0x10000L;
  6359. while (posy >= 0x10000L) {
  6360. ++srcy;
  6361. posy -= 0x10000L;
  6362. }
  6363. while (n--) {
  6364. if (posx >= 0x10000L) {
  6365. while (posx >= 0x10000L) {
  6366. ++srcx;
  6367. posx -= 0x10000L;
  6368. }
  6369. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6370. }
  6371. srcpixel = *src;
  6372. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6373. dstpixel = *dst;
  6374. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  6375. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6376. /* This goes away if we ever use premultiplied alpha */
  6377. if (srcA < 255) {
  6378. srcR = (srcR * srcA) / 255;
  6379. srcG = (srcG * srcA) / 255;
  6380. srcB = (srcB * srcA) / 255;
  6381. }
  6382. }
  6383. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6384. case SDL_COPY_BLEND:
  6385. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6386. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6387. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6388. break;
  6389. case SDL_COPY_ADD:
  6390. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6391. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6392. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6393. break;
  6394. case SDL_COPY_MOD:
  6395. dstR = (srcR * dstR) / 255;
  6396. dstG = (srcG * dstG) / 255;
  6397. dstB = (srcB * dstB) / 255;
  6398. break;
  6399. }
  6400. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  6401. *dst = dstpixel;
  6402. posx += incx;
  6403. ++dst;
  6404. }
  6405. posy += incy;
  6406. info->dst += info->dst_pitch;
  6407. }
  6408. }
  6409. static void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info)
  6410. {
  6411. const int flags = info->flags;
  6412. const Uint32 modulateR = info->r;
  6413. const Uint32 modulateG = info->g;
  6414. const Uint32 modulateB = info->b;
  6415. const Uint32 modulateA = info->a;
  6416. Uint32 pixel;
  6417. Uint32 R, G, B, A;
  6418. while (info->dst_h--) {
  6419. Uint32 *src = (Uint32 *)info->src;
  6420. Uint32 *dst = (Uint32 *)info->dst;
  6421. int n = info->dst_w;
  6422. while (n--) {
  6423. pixel = *src;
  6424. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6425. if (flags & SDL_COPY_MODULATE_COLOR) {
  6426. R = (R * modulateR) / 255;
  6427. G = (G * modulateG) / 255;
  6428. B = (B * modulateB) / 255;
  6429. }
  6430. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6431. A = (A * modulateA) / 255;
  6432. }
  6433. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  6434. *dst = pixel;
  6435. ++src;
  6436. ++dst;
  6437. }
  6438. info->src += info->src_pitch;
  6439. info->dst += info->dst_pitch;
  6440. }
  6441. }
  6442. static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  6443. {
  6444. const int flags = info->flags;
  6445. const Uint32 modulateR = info->r;
  6446. const Uint32 modulateG = info->g;
  6447. const Uint32 modulateB = info->b;
  6448. const Uint32 modulateA = info->a;
  6449. Uint32 pixel;
  6450. Uint32 R, G, B, A;
  6451. int srcy, srcx;
  6452. int posy, posx;
  6453. int incy, incx;
  6454. srcy = 0;
  6455. posy = 0;
  6456. incy = (info->src_h << 16) / info->dst_h;
  6457. incx = (info->src_w << 16) / info->dst_w;
  6458. while (info->dst_h--) {
  6459. Uint32 *src = 0;
  6460. Uint32 *dst = (Uint32 *)info->dst;
  6461. int n = info->dst_w;
  6462. srcx = -1;
  6463. posx = 0x10000L;
  6464. while (posy >= 0x10000L) {
  6465. ++srcy;
  6466. posy -= 0x10000L;
  6467. }
  6468. while (n--) {
  6469. if (posx >= 0x10000L) {
  6470. while (posx >= 0x10000L) {
  6471. ++srcx;
  6472. posx -= 0x10000L;
  6473. }
  6474. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6475. }
  6476. pixel = *src;
  6477. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6478. if (flags & SDL_COPY_MODULATE_COLOR) {
  6479. R = (R * modulateR) / 255;
  6480. G = (G * modulateG) / 255;
  6481. B = (B * modulateB) / 255;
  6482. }
  6483. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6484. A = (A * modulateA) / 255;
  6485. }
  6486. pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  6487. *dst = pixel;
  6488. posx += incx;
  6489. ++dst;
  6490. }
  6491. posy += incy;
  6492. info->dst += info->dst_pitch;
  6493. }
  6494. }
  6495. static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  6496. {
  6497. const int flags = info->flags;
  6498. const Uint32 modulateR = info->r;
  6499. const Uint32 modulateG = info->g;
  6500. const Uint32 modulateB = info->b;
  6501. const Uint32 modulateA = info->a;
  6502. Uint32 srcpixel;
  6503. Uint32 srcR, srcG, srcB, srcA;
  6504. Uint32 dstpixel;
  6505. Uint32 dstR, dstG, dstB, dstA;
  6506. while (info->dst_h--) {
  6507. Uint32 *src = (Uint32 *)info->src;
  6508. Uint32 *dst = (Uint32 *)info->dst;
  6509. int n = info->dst_w;
  6510. while (n--) {
  6511. srcpixel = *src;
  6512. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6513. dstpixel = *dst;
  6514. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  6515. if (flags & SDL_COPY_MODULATE_COLOR) {
  6516. srcR = (srcR * modulateR) / 255;
  6517. srcG = (srcG * modulateG) / 255;
  6518. srcB = (srcB * modulateB) / 255;
  6519. }
  6520. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6521. srcA = (srcA * modulateA) / 255;
  6522. }
  6523. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6524. /* This goes away if we ever use premultiplied alpha */
  6525. if (srcA < 255) {
  6526. srcR = (srcR * srcA) / 255;
  6527. srcG = (srcG * srcA) / 255;
  6528. srcB = (srcB * srcA) / 255;
  6529. }
  6530. }
  6531. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6532. case SDL_COPY_BLEND:
  6533. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6534. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6535. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6536. break;
  6537. case SDL_COPY_ADD:
  6538. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6539. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6540. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6541. break;
  6542. case SDL_COPY_MOD:
  6543. dstR = (srcR * dstR) / 255;
  6544. dstG = (srcG * dstG) / 255;
  6545. dstB = (srcB * dstB) / 255;
  6546. break;
  6547. }
  6548. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  6549. *dst = dstpixel;
  6550. ++src;
  6551. ++dst;
  6552. }
  6553. info->src += info->src_pitch;
  6554. info->dst += info->dst_pitch;
  6555. }
  6556. }
  6557. static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6558. {
  6559. const int flags = info->flags;
  6560. const Uint32 modulateR = info->r;
  6561. const Uint32 modulateG = info->g;
  6562. const Uint32 modulateB = info->b;
  6563. const Uint32 modulateA = info->a;
  6564. Uint32 srcpixel;
  6565. Uint32 srcR, srcG, srcB, srcA;
  6566. Uint32 dstpixel;
  6567. Uint32 dstR, dstG, dstB, dstA;
  6568. int srcy, srcx;
  6569. int posy, posx;
  6570. int incy, incx;
  6571. srcy = 0;
  6572. posy = 0;
  6573. incy = (info->src_h << 16) / info->dst_h;
  6574. incx = (info->src_w << 16) / info->dst_w;
  6575. while (info->dst_h--) {
  6576. Uint32 *src = 0;
  6577. Uint32 *dst = (Uint32 *)info->dst;
  6578. int n = info->dst_w;
  6579. srcx = -1;
  6580. posx = 0x10000L;
  6581. while (posy >= 0x10000L) {
  6582. ++srcy;
  6583. posy -= 0x10000L;
  6584. }
  6585. while (n--) {
  6586. if (posx >= 0x10000L) {
  6587. while (posx >= 0x10000L) {
  6588. ++srcx;
  6589. posx -= 0x10000L;
  6590. }
  6591. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6592. }
  6593. srcpixel = *src;
  6594. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6595. dstpixel = *dst;
  6596. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  6597. if (flags & SDL_COPY_MODULATE_COLOR) {
  6598. srcR = (srcR * modulateR) / 255;
  6599. srcG = (srcG * modulateG) / 255;
  6600. srcB = (srcB * modulateB) / 255;
  6601. }
  6602. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6603. srcA = (srcA * modulateA) / 255;
  6604. }
  6605. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6606. /* This goes away if we ever use premultiplied alpha */
  6607. if (srcA < 255) {
  6608. srcR = (srcR * srcA) / 255;
  6609. srcG = (srcG * srcA) / 255;
  6610. srcB = (srcB * srcA) / 255;
  6611. }
  6612. }
  6613. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6614. case SDL_COPY_BLEND:
  6615. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6616. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6617. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6618. break;
  6619. case SDL_COPY_ADD:
  6620. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6621. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6622. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6623. break;
  6624. case SDL_COPY_MOD:
  6625. dstR = (srcR * dstR) / 255;
  6626. dstG = (srcG * dstG) / 255;
  6627. dstB = (srcB * dstB) / 255;
  6628. break;
  6629. }
  6630. dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  6631. *dst = dstpixel;
  6632. posx += incx;
  6633. ++dst;
  6634. }
  6635. posy += incy;
  6636. info->dst += info->dst_pitch;
  6637. }
  6638. }
  6639. static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  6640. {
  6641. Uint32 pixel;
  6642. Uint32 R, G, B, A;
  6643. int srcy, srcx;
  6644. int posy, posx;
  6645. int incy, incx;
  6646. srcy = 0;
  6647. posy = 0;
  6648. incy = (info->src_h << 16) / info->dst_h;
  6649. incx = (info->src_w << 16) / info->dst_w;
  6650. while (info->dst_h--) {
  6651. Uint32 *src = 0;
  6652. Uint32 *dst = (Uint32 *)info->dst;
  6653. int n = info->dst_w;
  6654. srcx = -1;
  6655. posx = 0x10000L;
  6656. while (posy >= 0x10000L) {
  6657. ++srcy;
  6658. posy -= 0x10000L;
  6659. }
  6660. while (n--) {
  6661. if (posx >= 0x10000L) {
  6662. while (posx >= 0x10000L) {
  6663. ++srcx;
  6664. posx -= 0x10000L;
  6665. }
  6666. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6667. }
  6668. pixel = *src;
  6669. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6670. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  6671. *dst = pixel;
  6672. posx += incx;
  6673. ++dst;
  6674. }
  6675. posy += incy;
  6676. info->dst += info->dst_pitch;
  6677. }
  6678. }
  6679. static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  6680. {
  6681. const int flags = info->flags;
  6682. Uint32 srcpixel;
  6683. Uint32 srcR, srcG, srcB, srcA;
  6684. Uint32 dstpixel;
  6685. Uint32 dstR, dstG, dstB, dstA;
  6686. while (info->dst_h--) {
  6687. Uint32 *src = (Uint32 *)info->src;
  6688. Uint32 *dst = (Uint32 *)info->dst;
  6689. int n = info->dst_w;
  6690. while (n--) {
  6691. srcpixel = *src;
  6692. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6693. dstpixel = *dst;
  6694. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  6695. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6696. /* This goes away if we ever use premultiplied alpha */
  6697. if (srcA < 255) {
  6698. srcR = (srcR * srcA) / 255;
  6699. srcG = (srcG * srcA) / 255;
  6700. srcB = (srcB * srcA) / 255;
  6701. }
  6702. }
  6703. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6704. case SDL_COPY_BLEND:
  6705. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6706. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6707. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6708. break;
  6709. case SDL_COPY_ADD:
  6710. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6711. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6712. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6713. break;
  6714. case SDL_COPY_MOD:
  6715. dstR = (srcR * dstR) / 255;
  6716. dstG = (srcG * dstG) / 255;
  6717. dstB = (srcB * dstB) / 255;
  6718. break;
  6719. }
  6720. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  6721. *dst = dstpixel;
  6722. ++src;
  6723. ++dst;
  6724. }
  6725. info->src += info->src_pitch;
  6726. info->dst += info->dst_pitch;
  6727. }
  6728. }
  6729. static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  6730. {
  6731. const int flags = info->flags;
  6732. Uint32 srcpixel;
  6733. Uint32 srcR, srcG, srcB, srcA;
  6734. Uint32 dstpixel;
  6735. Uint32 dstR, dstG, dstB, dstA;
  6736. int srcy, srcx;
  6737. int posy, posx;
  6738. int incy, incx;
  6739. srcy = 0;
  6740. posy = 0;
  6741. incy = (info->src_h << 16) / info->dst_h;
  6742. incx = (info->src_w << 16) / info->dst_w;
  6743. while (info->dst_h--) {
  6744. Uint32 *src = 0;
  6745. Uint32 *dst = (Uint32 *)info->dst;
  6746. int n = info->dst_w;
  6747. srcx = -1;
  6748. posx = 0x10000L;
  6749. while (posy >= 0x10000L) {
  6750. ++srcy;
  6751. posy -= 0x10000L;
  6752. }
  6753. while (n--) {
  6754. if (posx >= 0x10000L) {
  6755. while (posx >= 0x10000L) {
  6756. ++srcx;
  6757. posx -= 0x10000L;
  6758. }
  6759. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6760. }
  6761. srcpixel = *src;
  6762. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6763. dstpixel = *dst;
  6764. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  6765. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6766. /* This goes away if we ever use premultiplied alpha */
  6767. if (srcA < 255) {
  6768. srcR = (srcR * srcA) / 255;
  6769. srcG = (srcG * srcA) / 255;
  6770. srcB = (srcB * srcA) / 255;
  6771. }
  6772. }
  6773. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6774. case SDL_COPY_BLEND:
  6775. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6776. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6777. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6778. break;
  6779. case SDL_COPY_ADD:
  6780. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6781. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6782. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6783. break;
  6784. case SDL_COPY_MOD:
  6785. dstR = (srcR * dstR) / 255;
  6786. dstG = (srcG * dstG) / 255;
  6787. dstB = (srcB * dstB) / 255;
  6788. break;
  6789. }
  6790. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  6791. *dst = dstpixel;
  6792. posx += incx;
  6793. ++dst;
  6794. }
  6795. posy += incy;
  6796. info->dst += info->dst_pitch;
  6797. }
  6798. }
  6799. static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  6800. {
  6801. const int flags = info->flags;
  6802. const Uint32 modulateR = info->r;
  6803. const Uint32 modulateG = info->g;
  6804. const Uint32 modulateB = info->b;
  6805. const Uint32 modulateA = info->a;
  6806. Uint32 pixel;
  6807. Uint32 R, G, B, A;
  6808. while (info->dst_h--) {
  6809. Uint32 *src = (Uint32 *)info->src;
  6810. Uint32 *dst = (Uint32 *)info->dst;
  6811. int n = info->dst_w;
  6812. while (n--) {
  6813. pixel = *src;
  6814. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6815. if (flags & SDL_COPY_MODULATE_COLOR) {
  6816. R = (R * modulateR) / 255;
  6817. G = (G * modulateG) / 255;
  6818. B = (B * modulateB) / 255;
  6819. }
  6820. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6821. A = (A * modulateA) / 255;
  6822. }
  6823. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  6824. *dst = pixel;
  6825. ++src;
  6826. ++dst;
  6827. }
  6828. info->src += info->src_pitch;
  6829. info->dst += info->dst_pitch;
  6830. }
  6831. }
  6832. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  6833. {
  6834. const int flags = info->flags;
  6835. const Uint32 modulateR = info->r;
  6836. const Uint32 modulateG = info->g;
  6837. const Uint32 modulateB = info->b;
  6838. const Uint32 modulateA = info->a;
  6839. Uint32 pixel;
  6840. Uint32 R, G, B, A;
  6841. int srcy, srcx;
  6842. int posy, posx;
  6843. int incy, incx;
  6844. srcy = 0;
  6845. posy = 0;
  6846. incy = (info->src_h << 16) / info->dst_h;
  6847. incx = (info->src_w << 16) / info->dst_w;
  6848. while (info->dst_h--) {
  6849. Uint32 *src = 0;
  6850. Uint32 *dst = (Uint32 *)info->dst;
  6851. int n = info->dst_w;
  6852. srcx = -1;
  6853. posx = 0x10000L;
  6854. while (posy >= 0x10000L) {
  6855. ++srcy;
  6856. posy -= 0x10000L;
  6857. }
  6858. while (n--) {
  6859. if (posx >= 0x10000L) {
  6860. while (posx >= 0x10000L) {
  6861. ++srcx;
  6862. posx -= 0x10000L;
  6863. }
  6864. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6865. }
  6866. pixel = *src;
  6867. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6868. if (flags & SDL_COPY_MODULATE_COLOR) {
  6869. R = (R * modulateR) / 255;
  6870. G = (G * modulateG) / 255;
  6871. B = (B * modulateB) / 255;
  6872. }
  6873. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6874. A = (A * modulateA) / 255;
  6875. }
  6876. pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  6877. *dst = pixel;
  6878. posx += incx;
  6879. ++dst;
  6880. }
  6881. posy += incy;
  6882. info->dst += info->dst_pitch;
  6883. }
  6884. }
  6885. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  6886. {
  6887. const int flags = info->flags;
  6888. const Uint32 modulateR = info->r;
  6889. const Uint32 modulateG = info->g;
  6890. const Uint32 modulateB = info->b;
  6891. const Uint32 modulateA = info->a;
  6892. Uint32 srcpixel;
  6893. Uint32 srcR, srcG, srcB, srcA;
  6894. Uint32 dstpixel;
  6895. Uint32 dstR, dstG, dstB, dstA;
  6896. while (info->dst_h--) {
  6897. Uint32 *src = (Uint32 *)info->src;
  6898. Uint32 *dst = (Uint32 *)info->dst;
  6899. int n = info->dst_w;
  6900. while (n--) {
  6901. srcpixel = *src;
  6902. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6903. dstpixel = *dst;
  6904. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  6905. if (flags & SDL_COPY_MODULATE_COLOR) {
  6906. srcR = (srcR * modulateR) / 255;
  6907. srcG = (srcG * modulateG) / 255;
  6908. srcB = (srcB * modulateB) / 255;
  6909. }
  6910. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6911. srcA = (srcA * modulateA) / 255;
  6912. }
  6913. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6914. /* This goes away if we ever use premultiplied alpha */
  6915. if (srcA < 255) {
  6916. srcR = (srcR * srcA) / 255;
  6917. srcG = (srcG * srcA) / 255;
  6918. srcB = (srcB * srcA) / 255;
  6919. }
  6920. }
  6921. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  6922. case SDL_COPY_BLEND:
  6923. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6924. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6925. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6926. break;
  6927. case SDL_COPY_ADD:
  6928. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6929. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6930. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6931. break;
  6932. case SDL_COPY_MOD:
  6933. dstR = (srcR * dstR) / 255;
  6934. dstG = (srcG * dstG) / 255;
  6935. dstB = (srcB * dstB) / 255;
  6936. break;
  6937. }
  6938. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  6939. *dst = dstpixel;
  6940. ++src;
  6941. ++dst;
  6942. }
  6943. info->src += info->src_pitch;
  6944. info->dst += info->dst_pitch;
  6945. }
  6946. }
  6947. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6948. {
  6949. const int flags = info->flags;
  6950. const Uint32 modulateR = info->r;
  6951. const Uint32 modulateG = info->g;
  6952. const Uint32 modulateB = info->b;
  6953. const Uint32 modulateA = info->a;
  6954. Uint32 srcpixel;
  6955. Uint32 srcR, srcG, srcB, srcA;
  6956. Uint32 dstpixel;
  6957. Uint32 dstR, dstG, dstB, dstA;
  6958. int srcy, srcx;
  6959. int posy, posx;
  6960. int incy, incx;
  6961. srcy = 0;
  6962. posy = 0;
  6963. incy = (info->src_h << 16) / info->dst_h;
  6964. incx = (info->src_w << 16) / info->dst_w;
  6965. while (info->dst_h--) {
  6966. Uint32 *src = 0;
  6967. Uint32 *dst = (Uint32 *)info->dst;
  6968. int n = info->dst_w;
  6969. srcx = -1;
  6970. posx = 0x10000L;
  6971. while (posy >= 0x10000L) {
  6972. ++srcy;
  6973. posy -= 0x10000L;
  6974. }
  6975. while (n--) {
  6976. if (posx >= 0x10000L) {
  6977. while (posx >= 0x10000L) {
  6978. ++srcx;
  6979. posx -= 0x10000L;
  6980. }
  6981. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6982. }
  6983. srcpixel = *src;
  6984. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6985. dstpixel = *dst;
  6986. dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  6987. if (flags & SDL_COPY_MODULATE_COLOR) {
  6988. srcR = (srcR * modulateR) / 255;
  6989. srcG = (srcG * modulateG) / 255;
  6990. srcB = (srcB * modulateB) / 255;
  6991. }
  6992. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6993. srcA = (srcA * modulateA) / 255;
  6994. }
  6995. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6996. /* This goes away if we ever use premultiplied alpha */
  6997. if (srcA < 255) {
  6998. srcR = (srcR * srcA) / 255;
  6999. srcG = (srcG * srcA) / 255;
  7000. srcB = (srcB * srcA) / 255;
  7001. }
  7002. }
  7003. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  7004. case SDL_COPY_BLEND:
  7005. dstR = srcR + ((255 - srcA) * dstR) / 255;
  7006. dstG = srcG + ((255 - srcA) * dstG) / 255;
  7007. dstB = srcB + ((255 - srcA) * dstB) / 255;
  7008. break;
  7009. case SDL_COPY_ADD:
  7010. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7011. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7012. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7013. break;
  7014. case SDL_COPY_MOD:
  7015. dstR = (srcR * dstR) / 255;
  7016. dstG = (srcG * dstG) / 255;
  7017. dstB = (srcB * dstB) / 255;
  7018. break;
  7019. }
  7020. dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  7021. *dst = dstpixel;
  7022. posx += incx;
  7023. ++dst;
  7024. }
  7025. posy += incy;
  7026. info->dst += info->dst_pitch;
  7027. }
  7028. }
  7029. SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
  7030. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
  7031. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
  7032. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
  7033. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate },
  7034. { 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 },
  7035. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend },
  7036. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale },
  7037. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Scale },
  7038. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend },
  7039. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale },
  7040. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate },
  7041. { 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 },
  7042. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend },
  7043. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale },
  7044. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Scale },
  7045. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend },
  7046. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend_Scale },
  7047. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate },
  7048. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Scale },
  7049. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend },
  7050. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale },
  7051. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale },
  7052. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend },
  7053. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale },
  7054. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate },
  7055. { 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 },
  7056. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend },
  7057. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale },
  7058. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Scale },
  7059. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend },
  7060. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale },
  7061. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate },
  7062. { 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 },
  7063. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend },
  7064. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale },
  7065. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Scale },
  7066. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend },
  7067. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend_Scale },
  7068. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate },
  7069. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Scale },
  7070. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend },
  7071. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale },
  7072. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale },
  7073. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend },
  7074. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale },
  7075. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate },
  7076. { 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 },
  7077. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend },
  7078. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale },
  7079. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Scale },
  7080. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend },
  7081. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale },
  7082. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate },
  7083. { 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 },
  7084. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend },
  7085. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale },
  7086. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale },
  7087. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
  7088. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
  7089. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate },
  7090. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale },
  7091. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
  7092. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
  7093. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale },
  7094. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend },
  7095. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale },
  7096. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate },
  7097. { 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 },
  7098. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend },
  7099. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale },
  7100. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Scale },
  7101. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend },
  7102. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale },
  7103. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate },
  7104. { 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 },
  7105. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend },
  7106. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale },
  7107. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale },
  7108. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
  7109. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
  7110. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate },
  7111. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale },
  7112. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
  7113. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
  7114. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale },
  7115. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend },
  7116. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale },
  7117. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate },
  7118. { 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 },
  7119. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend },
  7120. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale },
  7121. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Scale },
  7122. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend },
  7123. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale },
  7124. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate },
  7125. { 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 },
  7126. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend },
  7127. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale },
  7128. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale },
  7129. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
  7130. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
  7131. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate },
  7132. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale },
  7133. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
  7134. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
  7135. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale },
  7136. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend },
  7137. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale },
  7138. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate },
  7139. { 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 },
  7140. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend },
  7141. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale },
  7142. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Scale },
  7143. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend },
  7144. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale },
  7145. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate },
  7146. { 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 },
  7147. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend },
  7148. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale },
  7149. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale },
  7150. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
  7151. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
  7152. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate },
  7153. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale },
  7154. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
  7155. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
  7156. { 0, 0, 0, 0, NULL }
  7157. };
  7158. /* *INDENT-ON* */
  7159. /* vi: set ts=4 sw=4 expandtab: */