[HEADERS]
[reactos.git] / rosapps / applications / sysutils / utils / rosperf / gradient.c
1 /*
2 * ReactOS RosPerf - ReactOS GUI performance test program (gradient.c)
3 *
4 * Copyright 2006 Timo Kreuzer <timo.kreuzer@web.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include <windows.h>
22 #include "rosperf.h"
23
24 void
25 GradientProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
26 {
27 unsigned Rep;
28 HDC Dc;
29 TRIVERTEX vert[6];
30 static GRADIENT_TRIANGLE gcap[4];
31
32 Dc = PerfInfo->ForegroundDc;
33 vert[0].x = 0;
34 vert[0].y = 0;
35 vert[0].Red = 0xff00;
36 vert[0].Green = 0;
37 vert[0].Blue = 0;
38 vert[0].Alpha = 0;
39 vert[1].x = PerfInfo->WndWidth;;
40 vert[1].y = 0;
41 vert[1].Red = 0;
42 vert[1].Green = 0xff00;
43 vert[1].Blue = 0;
44 vert[1].Alpha = 0;
45 vert[2].x = PerfInfo->WndWidth;
46 vert[2].y = PerfInfo->WndHeight;
47 vert[2].Red = 0;
48 vert[2].Green = 0;
49 vert[2].Blue = 0xff00;
50 vert[2].Alpha = 0;
51 vert[3].x = 0;
52 vert[3].y = PerfInfo->WndHeight;
53 vert[3].Red = 0;
54 vert[3].Green = 0xff00;
55 vert[3].Blue = 0;
56 vert[3].Alpha = 0;
57 vert[4].Red = 0;
58 vert[4].Green = 0;
59 vert[4].Blue = 0;
60 vert[4].Alpha = 0;
61 vert[5].Red = 0;
62 vert[5].Green = 0;
63 vert[5].Blue = 0;
64 vert[5].Alpha = 0;
65
66 for (Rep = 0; Rep < Reps; Rep++)
67 {
68 switch (2 * Rep / Reps)
69 {
70 case 0:
71 vert[4].x = PerfInfo->WndWidth * 2 * Rep / Reps;
72 vert[4].y = 0;
73 vert[5].x = PerfInfo->WndWidth - vert[4].x;
74 vert[5].y = PerfInfo->WndHeight;
75 gcap[0].Vertex1 = 5; gcap[0].Vertex2 = 0; gcap[0].Vertex3 = 4;
76 gcap[1].Vertex1 = 5; gcap[1].Vertex2 = 4; gcap[1].Vertex3 = 1;
77 gcap[2].Vertex1 = 5; gcap[2].Vertex2 = 1; gcap[2].Vertex3 = 2;
78 gcap[3].Vertex1 = 5; gcap[3].Vertex2 = 3; gcap[3].Vertex3 = 0;
79 break;
80 case 1:
81 vert[4].x = PerfInfo->WndWidth;
82 vert[4].y = PerfInfo->WndHeight * 2 * Rep / Reps - PerfInfo->WndHeight;
83 vert[5].x = 0;
84 vert[5].y = PerfInfo->WndHeight - vert[4].y;
85 gcap[0].Vertex1 = 5; gcap[0].Vertex2 = 1; gcap[0].Vertex3 = 4;
86 gcap[1].Vertex1 = 5; gcap[1].Vertex2 = 4; gcap[1].Vertex3 = 2;
87 gcap[2].Vertex1 = 5; gcap[2].Vertex2 = 2; gcap[2].Vertex3 = 3;
88 gcap[3].Vertex1 = 5; gcap[3].Vertex2 = 0; gcap[3].Vertex3 = 1;
89 break;
90 }
91
92 GradientFill(Dc, vert, 6, &gcap, 4, GRADIENT_FILL_TRIANGLE);
93 }
94 }
95
96 void
97 GradientHorizontalProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
98 {
99 unsigned Rep;
100 HDC Dc;
101 TRIVERTEX vert[2];
102 static GRADIENT_RECT gcap = {0, 1};
103
104 Dc = PerfInfo->ForegroundDc;
105 for (Rep = 0; Rep < Reps; Rep++)
106 {
107 vert[0].x = 0;
108 vert[0].y = 0;
109 vert[0].Red = 0xff00;
110 vert[0].Green = 0xff00 - 0xff00 * Rep / Reps;
111 vert[0].Blue = 0xff00 * Rep / Reps;
112 vert[0].Alpha = 0;
113
114 vert[1].x = PerfInfo->WndWidth;
115 vert[1].y = PerfInfo->WndHeight;
116 vert[1].Red = 0xff00 - 0xff00 * Rep / Reps;
117 vert[1].Green = 0xff00 * Rep / Reps;
118 vert[1].Blue = 0xff00;
119 vert[1].Alpha = 0;
120
121 GradientFill(Dc, vert, 2, &gcap, 1, GRADIENT_FILL_RECT_H);
122 }
123 }
124
125 void
126 GradientVerticalProc(void *Context, PPERF_INFO PerfInfo, unsigned Reps)
127 {
128 unsigned Rep;
129 HDC Dc;
130 TRIVERTEX vert[2];
131 static GRADIENT_RECT gcap = {0, 1};
132
133 Dc = PerfInfo->ForegroundDc;
134 for (Rep = 0; Rep < Reps; Rep++)
135 {
136 vert[0].x = 0;
137 vert[0].y = 0;
138 vert[0].Red = 0xff00 * Rep / Reps;
139 vert[0].Green = 0xff00 - 0xff00 * Rep / Reps;
140 vert[0].Blue = 0xff00;
141 vert[0].Alpha = 0;
142
143 vert[1].x = PerfInfo->WndWidth;
144 vert[1].y = PerfInfo->WndHeight;
145 vert[1].Red = 0xff00 - 0xff00 * Rep / Reps;
146 vert[1].Green = 0xff00;
147 vert[1].Blue = 0xff00 * Rep / Reps;
148 vert[1].Alpha = 0;
149
150 GradientFill(Dc, vert, 2, &gcap, 1, GRADIENT_FILL_RECT_V);
151 }
152 }
153
154 /* EOF */