2 * ReactOS RosPerf - ReactOS GUI performance test program
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 typedef struct _ALPHABLEND_CONTEXT
{
26 } ALPHABLEND_CONTEXT
, *PALPHABLEND_CONTEXT
;
29 AlphaBlendInit(void **Context
, PPERF_INFO PerfInfo
, unsigned Reps
)
31 PALPHABLEND_CONTEXT ctx
= HeapAlloc(GetProcessHeap(), 0, sizeof (ALPHABLEND_CONTEXT
));
34 ctx
->BitmapDc
= CreateCompatibleDC(PerfInfo
->BackgroundDc
);
35 ctx
->Bitmap
= CreateCompatibleBitmap(PerfInfo
->BackgroundDc
, PerfInfo
->WndWidth
, PerfInfo
->WndHeight
);
36 SelectObject(ctx
->BitmapDc
, ctx
->Bitmap
);
38 for (y
= 0; y
< PerfInfo
->WndHeight
; y
++)
40 for (x
= 0; x
< PerfInfo
->WndWidth
; x
++)
42 SetPixel(ctx
->BitmapDc
, x
, y
, RGB(0xff, 0x00, 0x00));
52 AlphaBlendCleanup(void *Context
, PPERF_INFO PerfInfo
)
54 PALPHABLEND_CONTEXT ctx
= Context
;
55 DeleteDC(ctx
->BitmapDc
);
56 DeleteObject(ctx
->Bitmap
);
57 HeapFree(GetProcessHeap(), 0, ctx
);
67 AlphaBlendProc(void *Context
, PPERF_INFO PerfInfo
, unsigned Reps
)
69 PALPHABLEND_CONTEXT ctx
= Context
;
71 BLENDFUNCTION BlendFunc
= { AC_SRC_OVER
, 0, 0, 0 };
73 for (Rep
= 0; Rep
< Reps
; Rep
++)
75 BlendFunc
.SourceConstantAlpha
= 255 * Rep
/ Reps
;
77 PatBlt(PerfInfo
->BackgroundDc
, 0, 0, PerfInfo
->WndWidth
, PerfInfo
->WndHeight
, PATCOPY
);
79 if (!AlphaBlend(PerfInfo
->BackgroundDc
, 0, 0, PerfInfo
->WndWidth
, PerfInfo
->WndHeight
,
80 ctx
->BitmapDc
, 0, 0, PerfInfo
->WndWidth
, PerfInfo
->WndHeight
,
83 DbgPrint("AlphaBlend failed (0x%lx)\n", GetLastError());