Remove dead StretchBlt code
[reactos.git] / reactos / subsystems / win32 / win32k / dib / dib16bpp.c
1 /*
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <w32k.h>
21
22 #define NDEBUG
23 #include <debug.h>
24
25 VOID
26 DIB_16BPP_PutPixel(SURFOBJ *SurfObj, LONG x, LONG y, ULONG c)
27 {
28 PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
29 PWORD addr = (PWORD)byteaddr + x;
30
31 *addr = (WORD)c;
32 }
33
34 ULONG
35 DIB_16BPP_GetPixel(SURFOBJ *SurfObj, LONG x, LONG y)
36 {
37 PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
38 PWORD addr = (PWORD)byteaddr + x;
39 return (ULONG)(*addr);
40 }
41
42 VOID
43 DIB_16BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
44 {
45 PDWORD addr = (PDWORD)((PWORD)((PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta) + x1);
46
47 #if defined(_M_IX86) && !defined(_MSC_VER)
48 /* This is about 10% faster than the generic C code below */
49 LONG Count = x2 - x1;
50
51 __asm__ __volatile__ (
52 " cld\n"
53 " mov %0, %%eax\n"
54 " shl $16, %%eax\n"
55 " andl $0xffff, %0\n" /* If the pixel value is "abcd", put "abcdabcd" in %eax */
56 " or %0, %%eax\n"
57 " mov %2, %%edi\n"
58 " test $0x03, %%edi\n" /* Align to fullword boundary */
59 " jz 0f\n"
60 " stosw\n"
61 " dec %1\n"
62 " jz 1f\n"
63 "0:\n"
64 " mov %1,%%ecx\n" /* Setup count of fullwords to fill */
65 " shr $1,%%ecx\n"
66 " rep stosl\n" /* The actual fill */
67 " test $0x01, %1\n" /* One left to do at the right side? */
68 " jz 1f\n"
69 " stosw\n"
70 "1:\n"
71 : /* no output */
72 : "r"(c), "r"(Count), "m"(addr)
73 : "%eax", "%ecx", "%edi");
74 #else /* _M_IX86 */
75 LONG cx = x1;
76 DWORD cc;
77
78 if (0 != (cx & 0x01))
79 {
80 *((PWORD) addr) = c;
81 cx++;
82 addr = (PDWORD)((PWORD)(addr) + 1);
83 }
84 cc = ((c & 0xffff) << 16) | (c & 0xffff);
85 while(cx + 1 < x2)
86 {
87 *addr++ = cc;
88 cx += 2;
89 }
90 if (cx < x2)
91 {
92 *((PWORD) addr) = c;
93 }
94 #endif /* _M_IX86 */
95 }
96
97
98 VOID
99 DIB_16BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
100 {
101 #if defined(_M_IX86) && !defined(_MSC_VER)
102 asm volatile(
103 " testl %2, %2" "\n\t"
104 " jle 2f" "\n\t"
105 " movl %2, %%ecx" "\n\t"
106 " shrl $2, %2" "\n\t"
107 " andl $3, %%ecx" "\n\t"
108 " jz 1f" "\n\t"
109 "0:" "\n\t"
110 " movw %%ax, (%0)" "\n\t"
111 " addl %1, %0" "\n\t"
112 " decl %%ecx" "\n\t"
113 " jnz 0b" "\n\t"
114 " testl %2, %2" "\n\t"
115 " jz 2f" "\n\t"
116 "1:" "\n\t"
117 " movw %%ax, (%0)" "\n\t"
118 " addl %1, %0" "\n\t"
119 " movw %%ax, (%0)" "\n\t"
120 " addl %1, %0" "\n\t"
121 " movw %%ax, (%0)" "\n\t"
122 " addl %1, %0" "\n\t"
123 " movw %%ax, (%0)" "\n\t"
124 " addl %1, %0" "\n\t"
125 " decl %2" "\n\t"
126 " jnz 1b" "\n\t"
127 "2:" "\n\t"
128 : /* no output */
129 : "r"((PBYTE)SurfObj->pvScan0 + (y1 * SurfObj->lDelta) + (x * sizeof (WORD))),
130 "r"(SurfObj->lDelta), "r"(y2 - y1), "a"(c)
131 : "cc", "memory", "%ecx");
132 #else
133 PBYTE byteaddr = (PBYTE)(ULONG_PTR)SurfObj->pvScan0 + y1 * SurfObj->lDelta;
134 PWORD addr = (PWORD)byteaddr + x;
135 LONG lDelta = SurfObj->lDelta;
136
137 byteaddr = (PBYTE)addr;
138 while(y1++ < y2)
139 {
140 *addr = (WORD)c;
141
142 byteaddr += lDelta;
143 addr = (PWORD)byteaddr;
144 }
145 #endif
146 }
147
148 BOOLEAN
149 DIB_16BPP_BitBltSrcCopy(PBLTINFO BltInfo)
150 {
151 LONG i, j, sx, sy, xColor, f1;
152 PBYTE SourceBits, DestBits, SourceLine, DestLine;
153 PBYTE SourceBits_4BPP, SourceLine_4BPP;
154 DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.top * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
155
156 switch(BltInfo->SourceSurface->iBitmapFormat)
157 {
158 case BMF_1BPP:
159 sx = BltInfo->SourcePoint.x;
160 sy = BltInfo->SourcePoint.y;
161 for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
162 {
163 sx = BltInfo->SourcePoint.x;
164 for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
165 {
166 if(DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy) == 0)
167 {
168 DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j,
169 XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 0));
170 }
171 else
172 {
173 DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j,
174 XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 1));
175 }
176 sx++;
177 }
178 sy++;
179 }
180 break;
181
182 case BMF_4BPP:
183 SourceBits_4BPP = (PBYTE)BltInfo->SourceSurface->pvScan0 +
184 (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
185 (BltInfo->SourcePoint.x >> 1);
186
187 for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
188 {
189 SourceLine_4BPP = SourceBits_4BPP;
190 sx = BltInfo->SourcePoint.x;
191 f1 = sx & 1;
192
193 for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
194 {
195 xColor = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest,
196 (*SourceLine_4BPP & altnotmask[f1]) >> (4 * (1 - f1)));
197 DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j, xColor);
198 if(f1 == 1)
199 {
200 SourceLine_4BPP++;
201 f1 = 0;
202 }
203 else
204 {
205 f1 = 1;
206 }
207 sx++;
208 }
209 SourceBits_4BPP += BltInfo->SourceSurface->lDelta;
210 }
211 break;
212
213 case BMF_8BPP:
214 SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
215 (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
216 BltInfo->SourcePoint.x;
217 DestLine = DestBits;
218
219 for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
220 {
221 SourceBits = SourceLine;
222 DestBits = DestLine;
223
224 for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
225 {
226 *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
227 BltInfo->XlateSourceToDest, *SourceBits);
228 SourceBits += 1;
229 DestBits += 2;
230 }
231
232 SourceLine += BltInfo->SourceSurface->lDelta;
233 DestLine += BltInfo->DestSurface->lDelta;
234 }
235 break;
236
237 case BMF_16BPP:
238 if (NULL == BltInfo->XlateSourceToDest || 0 !=
239 (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))
240 {
241 if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
242 {
243 SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 +
244 (BltInfo->SourcePoint.y *
245 BltInfo->SourceSurface->lDelta) + 2 *
246 BltInfo->SourcePoint.x;
247
248 for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
249 {
250 RtlMoveMemory(DestBits, SourceBits,
251 2 * (BltInfo->DestRect.right -
252 BltInfo->DestRect.left));
253
254 SourceBits += BltInfo->SourceSurface->lDelta;
255 DestBits += BltInfo->DestSurface->lDelta;
256 }
257 }
258 else
259 {
260 SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 +
261 ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom -
262 BltInfo->DestRect.top - 1) *
263 BltInfo->SourceSurface->lDelta) + 2 *
264 BltInfo->SourcePoint.x;
265
266 DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 +
267 ((BltInfo->DestRect.bottom - 1) *
268 BltInfo->DestSurface->lDelta) + 2 *
269 BltInfo->DestRect.left;
270
271 for (j = BltInfo->DestRect.bottom - 1;
272 BltInfo->DestRect.top <= j; j--)
273 {
274 RtlMoveMemory(DestBits, SourceBits, 2 *
275 (BltInfo->DestRect.right -
276 BltInfo->DestRect.left));
277
278 SourceBits -= BltInfo->SourceSurface->lDelta;
279 DestBits -= BltInfo->DestSurface->lDelta;
280 }
281 }
282 }
283 else
284 {
285 if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
286 {
287 SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
288 (BltInfo->SourcePoint.y *
289 BltInfo->SourceSurface->lDelta) + 2 *
290 BltInfo->SourcePoint.x;
291
292 DestLine = DestBits;
293 for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
294 {
295 SourceBits = SourceLine;
296 DestBits = DestLine;
297 for (i = BltInfo->DestRect.left; i <
298 BltInfo->DestRect.right; i++)
299 {
300 *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
301 BltInfo->XlateSourceToDest,
302 *((WORD *)SourceBits));
303 SourceBits += 2;
304 DestBits += 2;
305 }
306 SourceLine += BltInfo->SourceSurface->lDelta;
307 DestLine += BltInfo->DestSurface->lDelta;
308 }
309 }
310 else
311 {
312 SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
313 ((BltInfo->SourcePoint.y +
314 BltInfo->DestRect.bottom -
315 BltInfo->DestRect.top - 1) *
316 BltInfo->SourceSurface->lDelta) + 2 *
317 BltInfo->SourcePoint.x;
318
319 DestLine = (PBYTE)BltInfo->DestSurface->pvScan0 +
320 ((BltInfo->DestRect.bottom - 1) *
321 BltInfo->DestSurface->lDelta) + 2 *
322 BltInfo->DestRect.left;
323
324 for (j = BltInfo->DestRect.bottom - 1;
325 BltInfo->DestRect.top <= j; j--)
326 {
327 SourceBits = SourceLine;
328 DestBits = DestLine;
329 for (i = BltInfo->DestRect.left; i <
330 BltInfo->DestRect.right; i++)
331 {
332 *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
333 BltInfo->XlateSourceToDest,
334 *((WORD *)SourceBits));
335 SourceBits += 2;
336 DestBits += 2;
337 }
338 SourceLine -= BltInfo->SourceSurface->lDelta;
339 DestLine -= BltInfo->DestSurface->lDelta;
340 }
341 }
342 }
343 break;
344
345 case BMF_24BPP:
346 SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
347 (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
348 3 * BltInfo->SourcePoint.x;
349
350 DestLine = DestBits;
351
352 for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
353 {
354 SourceBits = SourceLine;
355 DestBits = DestLine;
356
357 for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
358 {
359 xColor = (*(SourceBits + 2) << 0x10) +
360 (*(SourceBits + 1) << 0x08) + (*(SourceBits));
361
362 *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
363 BltInfo->XlateSourceToDest, xColor);
364
365 SourceBits += 3;
366 DestBits += 2;
367 }
368 SourceLine += BltInfo->SourceSurface->lDelta;
369 DestLine += BltInfo->DestSurface->lDelta;
370 }
371 break;
372
373 case BMF_32BPP:
374 SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
375 (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
376 4 * BltInfo->SourcePoint.x;
377
378 DestLine = DestBits;
379
380 for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
381 {
382 SourceBits = SourceLine;
383 DestBits = DestLine;
384
385 for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
386 {
387 *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
388 BltInfo->XlateSourceToDest,
389 *((PDWORD) SourceBits));
390 SourceBits += 4;
391 DestBits += 2;
392 }
393
394 SourceLine += BltInfo->SourceSurface->lDelta;
395 DestLine += BltInfo->DestSurface->lDelta;
396 }
397 break;
398
399 default:
400 DPRINT1("DIB_16BPP_Bitblt: Unhandled Source BPP: %u\n",
401 BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
402 return FALSE;
403 }
404
405 return TRUE;
406 }
407
408 /* Optimize for bitBlt */
409 BOOLEAN
410 DIB_16BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
411 {
412 ULONG DestY;
413
414 #if defined(_M_IX86) && !defined(_MSC_VER)
415 /* This is about 10% faster than the generic C code below */
416 ULONG delta = DestSurface->lDelta;
417 ULONG width = (DestRect->right - DestRect->left) ;
418 PULONG pos = (PULONG) ((PBYTE)DestSurface->pvScan0 + DestRect->top * delta + (DestRect->left<<1));
419 color = (color&0xffff); /* If the color value is "abcd", put "abcdabcd" into color */
420 color += (color<<16);
421
422 for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
423 {
424 __asm__ __volatile__ (
425 " cld\n"
426 " mov %1,%%ebx\n"
427 " mov %2,%%edi\n"
428 " test $0x03, %%edi\n" /* Align to fullword boundary */
429 " jz .FL1\n"
430 " stosw\n"
431 " dec %%ebx\n"
432 " jz .FL2\n"
433 ".FL1:\n"
434 " mov %%ebx,%%ecx\n" /* Setup count of fullwords to fill */
435 " shr $1,%%ecx\n"
436 " rep stosl\n" /* The actual fill */
437 " test $0x01, %%ebx\n" /* One left to do at the right side? */
438 " jz .FL2\n"
439 " stosw\n"
440 ".FL2:\n"
441 :
442 : "a" (color), "r" (width), "m" (pos)
443 : "%ecx", "%ebx", "%edi");
444 pos =(PULONG)((ULONG_PTR)pos + delta);
445 }
446 #else /* _M_IX86 */
447
448 for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
449 {
450 DIB_16BPP_HLine (DestSurface, DestRect->left, DestRect->right, DestY, color);
451 }
452 #endif
453 return TRUE;
454 }
455
456 BOOLEAN
457 DIB_16BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
458 RECTL* DestRect, POINTL *SourcePoint,
459 XLATEOBJ *ColorTranslation, ULONG iTransColor)
460 {
461 ULONG RoundedRight, X, Y, SourceX, SourceY, Source, wd, Dest;
462 ULONG *DestBits;
463
464 RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1);
465 SourceY = SourcePoint->y;
466 DestBits = (ULONG*)((PBYTE)DestSurf->pvScan0 +
467 (DestRect->left << 1) +
468 DestRect->top * DestSurf->lDelta);
469 wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) << 1);
470
471 for(Y = DestRect->top; Y < DestRect->bottom; Y++)
472 {
473 SourceX = SourcePoint->x;
474 for(X = DestRect->left; X < RoundedRight; X += 2, DestBits++, SourceX += 2)
475 {
476 Dest = *DestBits;
477 Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
478
479 if(Source != iTransColor)
480 {
481 Dest &= 0xFFFF0000;
482 Dest |= (XLATEOBJ_iXlate(ColorTranslation, Source) & 0xFFFF);
483 }
484
485 Source = DIB_GetSourceIndex(SourceSurf, SourceX + 1, SourceY);
486 if(Source != iTransColor)
487 {
488 Dest &= 0xFFFF;
489 Dest |= (XLATEOBJ_iXlate(ColorTranslation, Source) << 16);
490 }
491
492 *DestBits = Dest;
493 }
494
495 if(X < DestRect->right)
496 {
497 Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
498 if(Source != iTransColor)
499 {
500 *((USHORT*)DestBits) = (USHORT)XLATEOBJ_iXlate(ColorTranslation,
501 Source);
502 }
503
504 DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
505 }
506
507 SourceY++;
508 DestBits = (ULONG*)((ULONG_PTR)DestBits + wd);
509 }
510
511 return TRUE;
512 }
513
514 typedef union
515 {
516 ULONG ul;
517 struct
518 {
519 UCHAR red;
520 UCHAR green;
521 UCHAR blue;
522 UCHAR alpha;
523 } col;
524 } NICEPIXEL32;
525
526 typedef union
527 {
528 USHORT us;
529 struct
530 {
531 USHORT red:5,
532 green:6,
533 blue:5;
534 } col;
535 } NICEPIXEL16;
536
537 static __inline UCHAR
538 Clamp5(ULONG val)
539 {
540 return (val > 31) ? 31 : val;
541 }
542
543 static __inline UCHAR
544 Clamp6(ULONG val)
545 {
546 return (val > 63) ? 63 : val;
547 }
548
549 BOOLEAN
550 DIB_16BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
551 RECTL* SourceRect, CLIPOBJ* ClipRegion,
552 XLATEOBJ* ColorTranslation, BLENDOBJ* BlendObj)
553 {
554 INT Rows, Cols, SrcX, SrcY;
555 register PUSHORT Dst;
556 ULONG DstDelta;
557 BLENDFUNCTION BlendFunc;
558 register NICEPIXEL16 DstPixel;
559 register NICEPIXEL32 SrcPixel;
560 UCHAR Alpha, SrcBpp;
561
562 DPRINT("DIB_16BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
563 SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
564 DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
565
566 ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
567 DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
568
569 BlendFunc = BlendObj->BlendFunction;
570 if (BlendFunc.BlendOp != AC_SRC_OVER)
571 {
572 DPRINT1("BlendOp != AC_SRC_OVER\n");
573 return FALSE;
574 }
575 if (BlendFunc.BlendFlags != 0)
576 {
577 DPRINT1("BlendFlags != 0\n");
578 return FALSE;
579 }
580 if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
581 {
582 DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
583 return FALSE;
584 }
585 if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
586 BitsPerFormat(Source->iBitmapFormat) != 32)
587 {
588 DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
589 return FALSE;
590 }
591
592 Dst = (PUSHORT)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
593 (DestRect->left << 1));
594 DstDelta = Dest->lDelta - ((DestRect->right - DestRect->left) << 1);
595 SrcBpp = BitsPerFormat(Source->iBitmapFormat);
596
597 Rows = DestRect->bottom - DestRect->top;
598 SrcY = SourceRect->top;
599 while (--Rows >= 0)
600 {
601 Cols = DestRect->right - DestRect->left;
602 SrcX = SourceRect->left;
603 while (--Cols >= 0)
604 {
605 if (SrcBpp <= 16)
606 {
607 DstPixel.us = DIB_GetSource(Source, SrcX++, SrcY, ColorTranslation);
608 SrcPixel.col.red = (DstPixel.col.red << 3) | (DstPixel.col.red >> 2);
609
610 SrcPixel.col.green = (DstPixel.col.green << 2) |
611 (DstPixel.col.green >> 4);
612
613 SrcPixel.col.blue = (DstPixel.col.blue << 3) | (DstPixel.col.blue >> 2);
614 }
615 else
616 {
617 SrcPixel.ul = DIB_GetSourceIndex(Source, SrcX++, SrcY);
618 }
619 SrcPixel.col.red = SrcPixel.col.red *
620 BlendFunc.SourceConstantAlpha / 255;
621
622 SrcPixel.col.green = SrcPixel.col.green *
623 BlendFunc.SourceConstantAlpha / 255;
624
625 SrcPixel.col.blue = SrcPixel.col.blue *
626 BlendFunc.SourceConstantAlpha / 255;
627
628 SrcPixel.col.alpha = (SrcBpp == 32) ?
629 (SrcPixel.col.alpha *
630 BlendFunc.SourceConstantAlpha / 255) :
631 BlendFunc.SourceConstantAlpha;
632
633 Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
634 SrcPixel.col.alpha : BlendFunc.SourceConstantAlpha;
635
636 DstPixel.us = *Dst;
637 DstPixel.col.red = Clamp5(DstPixel.col.red * (255 - Alpha) / 255 +
638 (SrcPixel.col.red >> 3));
639
640 DstPixel.col.green = Clamp6(DstPixel.col.green * (255 - Alpha) / 255 +
641 (SrcPixel.col.green >> 2));
642
643 DstPixel.col.blue = Clamp5(DstPixel.col.blue * (255 - Alpha) / 255 +
644 (SrcPixel.col.blue >> 3));
645
646 *Dst++ = DstPixel.us;
647 }
648
649 Dst = (PUSHORT)((ULONG_PTR)Dst + DstDelta);
650 SrcY++;
651 }
652
653 return TRUE;
654 }
655
656 /* EOF */