ReactOS  0.4.13-dev-651-g5dbc677
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 
23 typedef struct _ALPHABLEND_CONTEXT {
27 
28 unsigned
29 AlphaBlendInit(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 
51 void
53 {
55  DeleteDC(ctx->BitmapDc);
56  DeleteObject(ctx->Bitmap);
57  HeapFree(GetProcessHeap(), 0, ctx);
58 }
59 
60 
61 ULONG
62 DbgPrint(
63  IN PCSTR Format,
64  IN ...);
65 
66 void
67 AlphaBlendProc(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 */
#define IN
Definition: typedefs.h:38
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HDC BackgroundDc
Definition: rosperf.h:30
struct _ALPHABLEND_CONTEXT * PALPHABLEND_CONTEXT
INT WndHeight
Definition: rosperf.h:32
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:93
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
ULONG DbgPrint(IN PCSTR Format, IN ...)
BYTE SourceConstantAlpha
Definition: wingdi.h:2739
#define RGB(r, g, b)
Definition: wingdi.h:2918
void AlphaBlendCleanup(void *Context, PPERF_INFO PerfInfo)
Definition: alphablend.c:52
#define AC_SRC_OVER
Definition: wingdi.h:1351
unsigned AlphaBlendInit(void **Context, PPERF_INFO PerfInfo, unsigned Reps)
Definition: alphablend.c:29
#define PATCOPY
Definition: wingdi.h:334
struct _ALPHABLEND_CONTEXT ALPHABLEND_CONTEXT
BOOL WINAPI DeleteDC(_In_ HDC)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define AlphaBlend
Definition: misc.c:293
struct tagContext Context
Definition: acpixf.h:1012
unsigned int ULONG
Definition: retypes.h:1
static HBITMAP
Definition: button.c:44
const char * PCSTR
Definition: typedefs.h:51
BLENDFUNCTION BlendFunc
Definition: general.c:32
void AlphaBlendProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
Definition: alphablend.c:67
#define HeapFree(x, y, z)
Definition: compat.h:394
INT WndWidth
Definition: rosperf.h:31