ReactOS 0.4.15-dev-7670-g69b08be
alphablend.c
Go to the documentation of this file.
1/*
2 * ReactOS RosPerf - ReactOS GUI performance test program
3 *
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.
8 *
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.
13 *
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.
17 */
18
19#include <windows.h>
20#include <wingdi.h>
21#include "rosperf.h"
22
23typedef struct _ALPHABLEND_CONTEXT {
27
28unsigned
29AlphaBlendInit(void **Context, PPERF_INFO PerfInfo, unsigned Reps)
30{
32 INT x, y;
33
34 ctx->BitmapDc = CreateCompatibleDC(PerfInfo->BackgroundDc);
35 ctx->Bitmap = CreateCompatibleBitmap(PerfInfo->BackgroundDc, PerfInfo->WndWidth, PerfInfo->WndHeight);
36 SelectObject(ctx->BitmapDc, ctx->Bitmap);
37
38 for (y = 0; y < PerfInfo->WndHeight; y++)
39 {
40 for (x = 0; x < PerfInfo->WndWidth; x++)
41 {
42 SetPixel(ctx->BitmapDc, x, y, RGB(0xff, 0x00, 0x00));
43 }
44 }
45
46 *Context = ctx;
47
48 return Reps;
49}
50
51void
53{
55 DeleteDC(ctx->BitmapDc);
56 DeleteObject(ctx->Bitmap);
58}
59
60
64 IN ...);
65
66void
67AlphaBlendProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
68{
70 unsigned Rep;
71 BLENDFUNCTION BlendFunc = { AC_SRC_OVER, 0, 0, 0 };
72
73 for (Rep = 0; Rep < Reps; Rep++)
74 {
75 BlendFunc.SourceConstantAlpha = 255 * Rep / Reps;
76#if 0
77 PatBlt(PerfInfo->BackgroundDc, 0, 0, PerfInfo->WndWidth, PerfInfo->WndHeight, PATCOPY);
78#endif
79 if (!AlphaBlend(PerfInfo->BackgroundDc, 0, 0, PerfInfo->WndWidth, PerfInfo->WndHeight,
80 ctx->BitmapDc, 0, 0, PerfInfo->WndWidth, PerfInfo->WndHeight,
81 BlendFunc))
82 {
83 DbgPrint("AlphaBlend failed (0x%lx)\n", GetLastError());
84 }
85 }
86}
87
88/* EOF */
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:50
static const BLENDFUNCTION BlendFunc
Definition: general.c:34
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define RGB(r, g, b)
Definition: precomp.h:62
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define DbgPrint
Definition: hal.h:12
struct _ALPHABLEND_CONTEXT * PALPHABLEND_CONTEXT
unsigned AlphaBlendInit(void **Context, PPERF_INFO PerfInfo, unsigned Reps)
Definition: alphablend.c:29
void AlphaBlendCleanup(void *Context, PPERF_INFO PerfInfo)
Definition: alphablend.c:52
void AlphaBlendProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
Definition: alphablend.c:67
struct _ALPHABLEND_CONTEXT ALPHABLEND_CONTEXT
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
BYTE SourceConstantAlpha
Definition: wingdi.h:2761
INT WndHeight
Definition: rosperf.h:32
HDC BackgroundDc
Definition: rosperf.h:30
INT WndWidth
Definition: rosperf.h:31
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define AlphaBlend
Definition: misc.c:293
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define AC_SRC_OVER
Definition: wingdi.h:1369
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define PATCOPY
Definition: wingdi.h:335
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI DeleteDC(_In_ HDC)