xref: /haiku/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp (revision e5f9dfebd72c747fd0096fe2499f346fa1ba85ac)
182afdb09SMichael Pfeiffer /*
282afdb09SMichael Pfeiffer  * Copyright 2007, Haiku. All rights reserved.
382afdb09SMichael Pfeiffer  * Distributed under the terms of the MIT License.
482afdb09SMichael Pfeiffer  *
582afdb09SMichael Pfeiffer  * Authors:
682afdb09SMichael Pfeiffer  *		Michael Pfeiffer
782afdb09SMichael Pfeiffer  */
882afdb09SMichael Pfeiffer 
982afdb09SMichael Pfeiffer #include "PictureTestCases.h"
1082afdb09SMichael Pfeiffer 
11abf565b1SStefano Ceccherini #include <GradientLinear.h>
12abf565b1SStefano Ceccherini #include <GradientRadial.h>
13abf565b1SStefano Ceccherini #include <GradientRadialFocus.h>
14abf565b1SStefano Ceccherini #include <GradientDiamond.h>
15abf565b1SStefano Ceccherini #include <GradientConic.h>
16abf565b1SStefano Ceccherini 
178247141fSMichael Pfeiffer #include <stdio.h>
188247141fSMichael Pfeiffer 
1954730332SMichael Pfeiffer static const rgb_color kBlack = {0, 0, 0};
2054730332SMichael Pfeiffer static const rgb_color kWhite = {255, 255, 255};
2154730332SMichael Pfeiffer static const rgb_color kRed = {255, 0, 0};
2254730332SMichael Pfeiffer static const rgb_color kGreen = {0, 255, 0};
2354730332SMichael Pfeiffer static const rgb_color kBlue = {0, 0, 255};
2454730332SMichael Pfeiffer 
2554730332SMichael Pfeiffer static BPoint centerPoint(BRect rect)
2654730332SMichael Pfeiffer {
2754730332SMichael Pfeiffer 	int x = (int)(rect.left + rect.IntegerWidth() / 2);
2854730332SMichael Pfeiffer 	int y = (int)(rect.top + rect.IntegerHeight() / 2);
2954730332SMichael Pfeiffer 	return BPoint(x, y);
3054730332SMichael Pfeiffer }
3154730332SMichael Pfeiffer 
3254730332SMichael Pfeiffer static void testNoOp(BView *view, BRect frame)
3382afdb09SMichael Pfeiffer {
3482afdb09SMichael Pfeiffer 	// no op
3582afdb09SMichael Pfeiffer }
3682afdb09SMichael Pfeiffer 
3754730332SMichael Pfeiffer static void testDrawChar(BView *view, BRect frame)
3854730332SMichael Pfeiffer {
3954730332SMichael Pfeiffer 	view->MovePenTo(frame.left, frame.bottom - 5);
4054730332SMichael Pfeiffer 	view->DrawChar('A');
4154730332SMichael Pfeiffer 
4254730332SMichael Pfeiffer 	view->DrawChar('B', BPoint(frame.left + 20, frame.bottom - 5));
4354730332SMichael Pfeiffer }
4454730332SMichael Pfeiffer 
4554730332SMichael Pfeiffer static void testDrawString(BView *view, BRect frame)
4682afdb09SMichael Pfeiffer {
4782afdb09SMichael Pfeiffer 	BFont font;
4882afdb09SMichael Pfeiffer 	view->GetFont(&font);
4982afdb09SMichael Pfeiffer 	font_height height;
5082afdb09SMichael Pfeiffer 	font.GetHeight(&height);
5182afdb09SMichael Pfeiffer 	float baseline = frame.bottom - height.descent;
5282afdb09SMichael Pfeiffer 	// draw base line
5354730332SMichael Pfeiffer 	view->SetHighColor(kGreen);
5482afdb09SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, baseline - 1), BPoint(frame.right, baseline -1));
5582afdb09SMichael Pfeiffer 
5654730332SMichael Pfeiffer 	view->SetHighColor(kBlack);
5782afdb09SMichael Pfeiffer 	view->DrawString("Haiku [ÖÜÄöüä]", BPoint(frame.left, baseline));
5882afdb09SMichael Pfeiffer }
5982afdb09SMichael Pfeiffer 
6054730332SMichael Pfeiffer static void testDrawStringWithLength(BView *view, BRect frame)
6154730332SMichael Pfeiffer {
6254730332SMichael Pfeiffer 	BFont font;
6354730332SMichael Pfeiffer 	view->GetFont(&font);
6454730332SMichael Pfeiffer 	font_height height;
6554730332SMichael Pfeiffer 	font.GetHeight(&height);
6654730332SMichael Pfeiffer 	float baseline = frame.bottom - height.descent;
6754730332SMichael Pfeiffer 	// draw base line
6854730332SMichael Pfeiffer 	view->SetHighColor(kGreen);
6954730332SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, baseline - 1), BPoint(frame.right, baseline -1));
7054730332SMichael Pfeiffer 
7154730332SMichael Pfeiffer 	view->SetHighColor(kBlack);
7254730332SMichael Pfeiffer 	view->DrawString("Haiku [ÖÜÄöüä]", 13, BPoint(frame.left, baseline));
7354730332SMichael Pfeiffer }
7454730332SMichael Pfeiffer 
75abf565b1SStefano Ceccherini 
76abf565b1SStefano Ceccherini static void testDrawStringWithOffsets(BView* view, BRect frame)
77abf565b1SStefano Ceccherini {
78abf565b1SStefano Ceccherini 	BFont font;
79abf565b1SStefano Ceccherini 	view->GetFont(&font);
80abf565b1SStefano Ceccherini 	font_height height;
81abf565b1SStefano Ceccherini 	font.GetHeight(&height);
82abf565b1SStefano Ceccherini 	float baseline = frame.bottom - height.descent;
83abf565b1SStefano Ceccherini 	// draw base line
84abf565b1SStefano Ceccherini 	view->SetHighColor(kGreen);
85abf565b1SStefano Ceccherini 	view->StrokeLine(BPoint(frame.left, baseline - 1), BPoint(frame.right, baseline -1));
86abf565b1SStefano Ceccherini 
87abf565b1SStefano Ceccherini 	view->SetHighColor(kBlack);
88abf565b1SStefano Ceccherini 	const BPoint pointArray[] = { BPoint(frame.left, baseline) };
89abf565b1SStefano Ceccherini 	view->DrawString("Haiku [ÖÜÄöüä]", pointArray, sizeof(pointArray) / sizeof(pointArray[0]));
90abf565b1SStefano Ceccherini }
91abf565b1SStefano Ceccherini 
92abf565b1SStefano Ceccherini 
9354730332SMichael Pfeiffer static void testFillArc(BView *view, BRect frame)
9482afdb09SMichael Pfeiffer {
9582afdb09SMichael Pfeiffer 	frame.InsetBy(2, 2);
9654730332SMichael Pfeiffer 	view->FillArc(frame, 45, 180);
9754730332SMichael Pfeiffer }
9854730332SMichael Pfeiffer 
9954730332SMichael Pfeiffer static void testStrokeArc(BView *view, BRect frame)
10054730332SMichael Pfeiffer {
10154730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
10254730332SMichael Pfeiffer 	view->StrokeArc(frame, 45, 180);
10354730332SMichael Pfeiffer }
10454730332SMichael Pfeiffer 
10554730332SMichael Pfeiffer static void testFillBezier(BView *view, BRect frame)
10654730332SMichael Pfeiffer {
10754730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
10854730332SMichael Pfeiffer 	BPoint points[4];
10954730332SMichael Pfeiffer 	points[0] = BPoint(frame.left, frame.bottom);
11054730332SMichael Pfeiffer 	points[1] = BPoint(frame.left, frame.top);
11154730332SMichael Pfeiffer 	points[1] = BPoint(frame.left, frame.top);
11254730332SMichael Pfeiffer 	points[3] = BPoint(frame.right, frame.top);
11354730332SMichael Pfeiffer 	view->FillBezier(points);
11454730332SMichael Pfeiffer }
11554730332SMichael Pfeiffer 
11654730332SMichael Pfeiffer static void testStrokeBezier(BView *view, BRect frame)
11754730332SMichael Pfeiffer {
11854730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
11954730332SMichael Pfeiffer 	BPoint points[4];
12054730332SMichael Pfeiffer 	points[0] = BPoint(frame.left, frame.bottom);
12154730332SMichael Pfeiffer 	points[1] = BPoint(frame.left, frame.top);
12254730332SMichael Pfeiffer 	points[1] = BPoint(frame.left, frame.top);
12354730332SMichael Pfeiffer 	points[3] = BPoint(frame.right, frame.top);
12454730332SMichael Pfeiffer 	view->StrokeBezier(points);
12554730332SMichael Pfeiffer }
12654730332SMichael Pfeiffer 
12754730332SMichael Pfeiffer static void testFillEllipse(BView *view, BRect frame)
12854730332SMichael Pfeiffer {
12954730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
13054730332SMichael Pfeiffer 	view->FillEllipse(frame);
13154730332SMichael Pfeiffer 
13254730332SMichael Pfeiffer 	view->SetHighColor(kRed);
13354730332SMichael Pfeiffer 	float r = frame.Width() / 3;
13454730332SMichael Pfeiffer 	float s = frame.Height() / 4;
13554730332SMichael Pfeiffer 	view->FillEllipse(centerPoint(frame), r, s);
13654730332SMichael Pfeiffer }
13754730332SMichael Pfeiffer 
13854730332SMichael Pfeiffer static void testStrokeEllipse(BView *view, BRect frame)
13954730332SMichael Pfeiffer {
14054730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
14154730332SMichael Pfeiffer 	view->StrokeEllipse(frame);
14254730332SMichael Pfeiffer 
14354730332SMichael Pfeiffer 	view->SetHighColor(kRed);
14454730332SMichael Pfeiffer 	float r = frame.Width() / 3;
14554730332SMichael Pfeiffer 	float s = frame.Height() / 4;
14654730332SMichael Pfeiffer 	view->StrokeEllipse(centerPoint(frame), r, s);
14754730332SMichael Pfeiffer }
14854730332SMichael Pfeiffer 
14954730332SMichael Pfeiffer static void testFillPolygon(BView *view, BRect frame)
15054730332SMichael Pfeiffer {
15154730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
15254730332SMichael Pfeiffer 
15354730332SMichael Pfeiffer 	BPoint points[4];
15454730332SMichael Pfeiffer 	points[0] = BPoint(frame.left, frame.top);
15554730332SMichael Pfeiffer 	points[1] = BPoint(frame.right, frame.bottom);
15654730332SMichael Pfeiffer 	points[2] = BPoint(frame.right, frame.top);
15754730332SMichael Pfeiffer 	points[3] = BPoint(frame.left, frame.bottom);
15854730332SMichael Pfeiffer 
15954730332SMichael Pfeiffer 	view->FillPolygon(points, 4);
16054730332SMichael Pfeiffer }
16154730332SMichael Pfeiffer 
16254730332SMichael Pfeiffer static void testStrokePolygon(BView *view, BRect frame)
16354730332SMichael Pfeiffer {
16454730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
16554730332SMichael Pfeiffer 
16654730332SMichael Pfeiffer 	BPoint points[4];
16754730332SMichael Pfeiffer 	points[0] = BPoint(frame.left, frame.top);
16854730332SMichael Pfeiffer 	points[1] = BPoint(frame.right, frame.bottom);
16954730332SMichael Pfeiffer 	points[2] = BPoint(frame.right, frame.top);
17054730332SMichael Pfeiffer 	points[3] = BPoint(frame.left, frame.bottom);
17154730332SMichael Pfeiffer 
17254730332SMichael Pfeiffer 	view->StrokePolygon(points, 4);
17354730332SMichael Pfeiffer }
17454730332SMichael Pfeiffer 
17554730332SMichael Pfeiffer static void testFillRect(BView *view, BRect frame)
17654730332SMichael Pfeiffer {
17754730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
17882afdb09SMichael Pfeiffer 	view->FillRect(frame);
17982afdb09SMichael Pfeiffer }
18082afdb09SMichael Pfeiffer 
181abf565b1SStefano Ceccherini static void testFillRectGradientLinear(BView* view, BRect frame)
182abf565b1SStefano Ceccherini {
183abf565b1SStefano Ceccherini 	BGradientLinear gradient(0, 0, frame.right, frame.bottom);
184abf565b1SStefano Ceccherini 	gradient.AddColor(kRed, 0);
185abf565b1SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
186abf565b1SStefano Ceccherini 	frame.InsetBy(2, 2);
187abf565b1SStefano Ceccherini 	view->FillRect(frame, gradient);
188abf565b1SStefano Ceccherini }
189abf565b1SStefano Ceccherini 
190abf565b1SStefano Ceccherini static void testFillRectGradientRadial(BView* view, BRect frame)
191abf565b1SStefano Ceccherini {
192abf565b1SStefano Ceccherini 	BGradientRadial gradient(10, 10, 10);
193abf565b1SStefano Ceccherini 	gradient.AddColor(kRed, 0);
194abf565b1SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
195abf565b1SStefano Ceccherini 	frame.InsetBy(2, 2);
196abf565b1SStefano Ceccherini 	view->FillRect(frame, gradient);
197abf565b1SStefano Ceccherini }
198abf565b1SStefano Ceccherini 
199abf565b1SStefano Ceccherini static void testFillRectGradientRadialFocus(BView* view, BRect frame)
200abf565b1SStefano Ceccherini {
201abf565b1SStefano Ceccherini 	BGradientRadialFocus gradient(0, 0, 10, 10, 5);
202abf565b1SStefano Ceccherini 	gradient.AddColor(kRed, 0);
203abf565b1SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
204abf565b1SStefano Ceccherini 	frame.InsetBy(2, 2);
205abf565b1SStefano Ceccherini 	view->FillRect(frame, gradient);
206abf565b1SStefano Ceccherini }
207abf565b1SStefano Ceccherini 
208abf565b1SStefano Ceccherini static void testFillRectGradientDiamond(BView* view, BRect frame)
209abf565b1SStefano Ceccherini {
210abf565b1SStefano Ceccherini 	BGradientDiamond gradient(0, 10);
211abf565b1SStefano Ceccherini 	gradient.AddColor(kRed, 0);
212abf565b1SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
213abf565b1SStefano Ceccherini 	frame.InsetBy(2, 2);
214abf565b1SStefano Ceccherini 	view->FillRect(frame, gradient);
215abf565b1SStefano Ceccherini }
216abf565b1SStefano Ceccherini 
217abf565b1SStefano Ceccherini static void testFillRectGradientConic(BView* view, BRect frame)
218abf565b1SStefano Ceccherini {
219abf565b1SStefano Ceccherini 	BGradientConic gradient(0, 0, 10);
220abf565b1SStefano Ceccherini 	gradient.AddColor(kRed, 0);
221abf565b1SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
222abf565b1SStefano Ceccherini 	frame.InsetBy(2, 2);
223abf565b1SStefano Ceccherini 	view->FillRect(frame, gradient);
224abf565b1SStefano Ceccherini }
225abf565b1SStefano Ceccherini 
22654730332SMichael Pfeiffer static void testStrokeRect(BView *view, BRect frame)
22782afdb09SMichael Pfeiffer {
22882afdb09SMichael Pfeiffer 	frame.InsetBy(2, 2);
22982afdb09SMichael Pfeiffer 	view->StrokeRect(frame);
23082afdb09SMichael Pfeiffer }
23182afdb09SMichael Pfeiffer 
23254730332SMichael Pfeiffer static void testFillRegion(BView *view, BRect frame)
23382afdb09SMichael Pfeiffer {
23454730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
23554730332SMichael Pfeiffer 	BRegion region(frame);
236b8c65995SStefano Ceccherini 	frame.InsetBy(10, 10);
23754730332SMichael Pfeiffer 	region.Exclude(frame);
23854730332SMichael Pfeiffer 	view->FillRegion(&region);
23954730332SMichael Pfeiffer }
24054730332SMichael Pfeiffer 
241b8c65995SStefano Ceccherini static void testFillRegionGradientLinear(BView* view, BRect frame)
242b8c65995SStefano Ceccherini {
243b8c65995SStefano Ceccherini 	BGradientLinear gradient(0, 0, frame.right, frame.bottom);
244b8c65995SStefano Ceccherini 	gradient.AddColor(kRed, 0);
245b8c65995SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
246b8c65995SStefano Ceccherini 	frame.InsetBy(2, 2);
247b8c65995SStefano Ceccherini 	BRegion region(frame);
248b8c65995SStefano Ceccherini 	frame.InsetBy(10, 10);
249b8c65995SStefano Ceccherini 	region.Exclude(frame);
250b8c65995SStefano Ceccherini 	view->FillRegion(&region, gradient);
251b8c65995SStefano Ceccherini }
252b8c65995SStefano Ceccherini 
253b8c65995SStefano Ceccherini static void testFillRegionGradientRadial(BView* view, BRect frame)
254b8c65995SStefano Ceccherini {
255b8c65995SStefano Ceccherini 	BGradientRadial gradient(10, 10, 10);
256b8c65995SStefano Ceccherini 	gradient.AddColor(kRed, 0);
257b8c65995SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
258b8c65995SStefano Ceccherini 	frame.InsetBy(2, 2);
259b8c65995SStefano Ceccherini 	BRegion region(frame);
260b8c65995SStefano Ceccherini 	frame.InsetBy(10, 10);
261b8c65995SStefano Ceccherini 	region.Exclude(frame);
262b8c65995SStefano Ceccherini 	view->FillRegion(&region, gradient);
263b8c65995SStefano Ceccherini }
264b8c65995SStefano Ceccherini 
265b8c65995SStefano Ceccherini static void testFillRegionGradientRadialFocus(BView* view, BRect frame)
266b8c65995SStefano Ceccherini {
267b8c65995SStefano Ceccherini 	BGradientRadialFocus gradient(0, 0, 10, 10, 5);
268b8c65995SStefano Ceccherini 	gradient.AddColor(kRed, 0);
269b8c65995SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
270b8c65995SStefano Ceccherini 	frame.InsetBy(2, 2);
271b8c65995SStefano Ceccherini 	BRegion region(frame);
272b8c65995SStefano Ceccherini 	frame.InsetBy(10, 10);
273b8c65995SStefano Ceccherini 	region.Exclude(frame);
274b8c65995SStefano Ceccherini 	view->FillRegion(&region, gradient);
275b8c65995SStefano Ceccherini }
276b8c65995SStefano Ceccherini 
277b8c65995SStefano Ceccherini static void testFillRegionGradientDiamond(BView* view, BRect frame)
278b8c65995SStefano Ceccherini {
279b8c65995SStefano Ceccherini 	BGradientDiamond gradient(0, 10);
280b8c65995SStefano Ceccherini 	gradient.AddColor(kRed, 0);
281b8c65995SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
282b8c65995SStefano Ceccherini 	frame.InsetBy(2, 2);
283b8c65995SStefano Ceccherini 	BRegion region(frame);
284b8c65995SStefano Ceccherini 	frame.InsetBy(10, 10);
285b8c65995SStefano Ceccherini 	region.Exclude(frame);
286b8c65995SStefano Ceccherini 	view->FillRegion(&region, gradient);
287b8c65995SStefano Ceccherini }
288b8c65995SStefano Ceccherini 
289b8c65995SStefano Ceccherini static void testFillRegionGradientConic(BView* view, BRect frame)
290b8c65995SStefano Ceccherini {
291b8c65995SStefano Ceccherini 	BGradientConic gradient(0, 0, 10);
292b8c65995SStefano Ceccherini 	gradient.AddColor(kRed, 0);
293b8c65995SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
294b8c65995SStefano Ceccherini 	frame.InsetBy(2, 2);
295b8c65995SStefano Ceccherini 	BRegion region(frame);
296b8c65995SStefano Ceccherini 	frame.InsetBy(10, 10);
297b8c65995SStefano Ceccherini 	region.Exclude(frame);
298b8c65995SStefano Ceccherini 	view->FillRegion(&region, gradient);
299b8c65995SStefano Ceccherini }
300b8c65995SStefano Ceccherini 
30154730332SMichael Pfeiffer static void testFillRoundRect(BView *view, BRect frame)
30254730332SMichael Pfeiffer {
30354730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
30454730332SMichael Pfeiffer 	view->FillRoundRect(frame, 5, 3);
30554730332SMichael Pfeiffer }
30654730332SMichael Pfeiffer 
30700c573d6SStefano Ceccherini static void testFillRoundRectGradientLinear(BView* view, BRect frame)
30800c573d6SStefano Ceccherini {
30900c573d6SStefano Ceccherini 	BGradientLinear gradient(0, 0, frame.right, frame.bottom);
31000c573d6SStefano Ceccherini 	gradient.AddColor(kRed, 0);
31100c573d6SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
31200c573d6SStefano Ceccherini 	frame.InsetBy(2, 2);
31300c573d6SStefano Ceccherini 	view->FillRoundRect(frame, 5, 3, gradient);
31400c573d6SStefano Ceccherini }
31500c573d6SStefano Ceccherini 
31600c573d6SStefano Ceccherini static void testFillRoundRectGradientRadial(BView* view, BRect frame)
31700c573d6SStefano Ceccherini {
31800c573d6SStefano Ceccherini 	BGradientRadial gradient(10, 10, 10);
31900c573d6SStefano Ceccherini 	gradient.AddColor(kRed, 0);
32000c573d6SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
32100c573d6SStefano Ceccherini 	frame.InsetBy(2, 2);
32200c573d6SStefano Ceccherini 	view->FillRoundRect(frame, 5, 3, gradient);
32300c573d6SStefano Ceccherini }
32400c573d6SStefano Ceccherini 
32500c573d6SStefano Ceccherini static void testFillRoundRectGradientRadialFocus(BView* view, BRect frame)
32600c573d6SStefano Ceccherini {
32700c573d6SStefano Ceccherini 	BGradientRadialFocus gradient(0, 0, 10, 10, 5);
32800c573d6SStefano Ceccherini 	gradient.AddColor(kRed, 0);
32900c573d6SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
33000c573d6SStefano Ceccherini 	view->FillRoundRect(frame, 5, 3, gradient);
33100c573d6SStefano Ceccherini }
33200c573d6SStefano Ceccherini 
33300c573d6SStefano Ceccherini static void testFillRoundRectGradientDiamond(BView* view, BRect frame)
33400c573d6SStefano Ceccherini {
33500c573d6SStefano Ceccherini 	BGradientDiamond gradient(0, 10);
33600c573d6SStefano Ceccherini 	gradient.AddColor(kRed, 0);
33700c573d6SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
33800c573d6SStefano Ceccherini 	frame.InsetBy(2, 2);
33900c573d6SStefano Ceccherini 	view->FillRoundRect(frame, 5, 3, gradient);
34000c573d6SStefano Ceccherini }
34100c573d6SStefano Ceccherini 
34200c573d6SStefano Ceccherini static void testFillRoundRectGradientConic(BView* view, BRect frame)
34300c573d6SStefano Ceccherini {
34400c573d6SStefano Ceccherini 	BGradientConic gradient(0, 0, 10);
34500c573d6SStefano Ceccherini 	gradient.AddColor(kRed, 0);
34600c573d6SStefano Ceccherini 	gradient.AddColor(kBlue, 255);
34700c573d6SStefano Ceccherini 	frame.InsetBy(2, 2);
34800c573d6SStefano Ceccherini 	view->FillRoundRect(frame, 5, 3, gradient);
34900c573d6SStefano Ceccherini }
35000c573d6SStefano Ceccherini 
35154730332SMichael Pfeiffer static void testStrokeRoundRect(BView *view, BRect frame)
35254730332SMichael Pfeiffer {
35354730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
35454730332SMichael Pfeiffer 	view->StrokeRoundRect(frame, 5, 3);
35554730332SMichael Pfeiffer }
35654730332SMichael Pfeiffer 
35754730332SMichael Pfeiffer static void testFillTriangle(BView *view, BRect frame)
35854730332SMichael Pfeiffer {
35954730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
36054730332SMichael Pfeiffer 	BPoint points[3];
36154730332SMichael Pfeiffer 	points[0] = BPoint(frame.left, frame.bottom);
36254730332SMichael Pfeiffer 	points[1] = BPoint(centerPoint(frame).x, frame.top);
36354730332SMichael Pfeiffer 	points[2] = BPoint(frame.right, frame.bottom);
36454730332SMichael Pfeiffer 	view->FillTriangle(points[0], points[1], points[2]);
36554730332SMichael Pfeiffer }
36654730332SMichael Pfeiffer 
367*e5f9dfebSStefano Ceccherini static void testFillTriangleGradientLinear(BView* view, BRect frame)
368*e5f9dfebSStefano Ceccherini {
369*e5f9dfebSStefano Ceccherini 	BGradientLinear gradient(0, 0, frame.right, frame.bottom);
370*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kRed, 0);
371*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kBlue, 255);
372*e5f9dfebSStefano Ceccherini 	frame.InsetBy(2, 2);
373*e5f9dfebSStefano Ceccherini 	BPoint points[3];
374*e5f9dfebSStefano Ceccherini 	points[0] = BPoint(frame.left, frame.bottom);
375*e5f9dfebSStefano Ceccherini 	points[1] = BPoint(centerPoint(frame).x, frame.top);
376*e5f9dfebSStefano Ceccherini 	points[2] = BPoint(frame.right, frame.bottom);
377*e5f9dfebSStefano Ceccherini 	view->FillTriangle(points[0], points[1], points[2], gradient);
378*e5f9dfebSStefano Ceccherini }
379*e5f9dfebSStefano Ceccherini 
380*e5f9dfebSStefano Ceccherini static void testFillTriangleGradientRadial(BView* view, BRect frame)
381*e5f9dfebSStefano Ceccherini {
382*e5f9dfebSStefano Ceccherini 	BGradientRadial gradient(10, 10, 10);
383*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kRed, 0);
384*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kBlue, 255);
385*e5f9dfebSStefano Ceccherini 	frame.InsetBy(2, 2);
386*e5f9dfebSStefano Ceccherini 	BPoint points[3];
387*e5f9dfebSStefano Ceccherini 	points[0] = BPoint(frame.left, frame.bottom);
388*e5f9dfebSStefano Ceccherini 	points[1] = BPoint(centerPoint(frame).x, frame.top);
389*e5f9dfebSStefano Ceccherini 	points[2] = BPoint(frame.right, frame.bottom);
390*e5f9dfebSStefano Ceccherini 	view->FillTriangle(points[0], points[1], points[2], gradient);
391*e5f9dfebSStefano Ceccherini }
392*e5f9dfebSStefano Ceccherini 
393*e5f9dfebSStefano Ceccherini static void testFillTriangleGradientRadialFocus(BView* view, BRect frame)
394*e5f9dfebSStefano Ceccherini {
395*e5f9dfebSStefano Ceccherini 	BGradientRadialFocus gradient(0, 0, 10, 10, 5);
396*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kRed, 0);
397*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kBlue, 255);
398*e5f9dfebSStefano Ceccherini 	frame.InsetBy(2, 2);
399*e5f9dfebSStefano Ceccherini 	BPoint points[3];
400*e5f9dfebSStefano Ceccherini 	points[0] = BPoint(frame.left, frame.bottom);
401*e5f9dfebSStefano Ceccherini 	points[1] = BPoint(centerPoint(frame).x, frame.top);
402*e5f9dfebSStefano Ceccherini 	points[2] = BPoint(frame.right, frame.bottom);
403*e5f9dfebSStefano Ceccherini 	view->FillTriangle(points[0], points[1], points[2], gradient);
404*e5f9dfebSStefano Ceccherini }
405*e5f9dfebSStefano Ceccherini 
406*e5f9dfebSStefano Ceccherini static void testFillTriangleGradientDiamond(BView* view, BRect frame)
407*e5f9dfebSStefano Ceccherini {
408*e5f9dfebSStefano Ceccherini 	BGradientDiamond gradient(0, 10);
409*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kRed, 0);
410*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kBlue, 255);
411*e5f9dfebSStefano Ceccherini 	frame.InsetBy(2, 2);
412*e5f9dfebSStefano Ceccherini 	BPoint points[3];
413*e5f9dfebSStefano Ceccherini 	points[0] = BPoint(frame.left, frame.bottom);
414*e5f9dfebSStefano Ceccherini 	points[1] = BPoint(centerPoint(frame).x, frame.top);
415*e5f9dfebSStefano Ceccherini 	points[2] = BPoint(frame.right, frame.bottom);
416*e5f9dfebSStefano Ceccherini 	view->FillTriangle(points[0], points[1], points[2], gradient);
417*e5f9dfebSStefano Ceccherini }
418*e5f9dfebSStefano Ceccherini 
419*e5f9dfebSStefano Ceccherini static void testFillTriangleGradientConic(BView* view, BRect frame)
420*e5f9dfebSStefano Ceccherini {
421*e5f9dfebSStefano Ceccherini 	BGradientConic gradient(0, 0, 10);
422*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kRed, 0);
423*e5f9dfebSStefano Ceccherini 	gradient.AddColor(kBlue, 255);
424*e5f9dfebSStefano Ceccherini 	frame.InsetBy(2, 2);
425*e5f9dfebSStefano Ceccherini 	BPoint points[3];
426*e5f9dfebSStefano Ceccherini 	points[0] = BPoint(frame.left, frame.bottom);
427*e5f9dfebSStefano Ceccherini 	points[1] = BPoint(centerPoint(frame).x, frame.top);
428*e5f9dfebSStefano Ceccherini 	points[2] = BPoint(frame.right, frame.bottom);
429*e5f9dfebSStefano Ceccherini 	view->FillTriangle(points[0], points[1], points[2], gradient);
430*e5f9dfebSStefano Ceccherini }
431*e5f9dfebSStefano Ceccherini 
43254730332SMichael Pfeiffer static void testStrokeTriangle(BView *view, BRect frame)
43354730332SMichael Pfeiffer {
43454730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
43554730332SMichael Pfeiffer 	BPoint points[3];
43654730332SMichael Pfeiffer 	points[0] = BPoint(frame.left, frame.bottom);
43754730332SMichael Pfeiffer 	points[1] = BPoint(centerPoint(frame).x, frame.top);
43854730332SMichael Pfeiffer 	points[2] = BPoint(frame.right, frame.bottom);
43954730332SMichael Pfeiffer 	view->StrokeTriangle(points[0], points[1], points[2]);
44054730332SMichael Pfeiffer }
44154730332SMichael Pfeiffer 
44254730332SMichael Pfeiffer static void testStrokeLine(BView *view, BRect frame)
44354730332SMichael Pfeiffer {
44454730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
44554730332SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top));
44654730332SMichael Pfeiffer 
44754730332SMichael Pfeiffer 	frame.top += 2;
44854730332SMichael Pfeiffer 	frame.bottom -= 2;
44982afdb09SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.bottom));
45054730332SMichael Pfeiffer 
45154730332SMichael Pfeiffer 	frame.bottom += 2;;
45254730332SMichael Pfeiffer 	frame.top = frame.bottom;
45354730332SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.right, frame.top), BPoint(frame.left, frame.top));
45482afdb09SMichael Pfeiffer }
45582afdb09SMichael Pfeiffer 
45654730332SMichael Pfeiffer static void testFillShape(BView *view, BRect frame)
45782afdb09SMichael Pfeiffer {
45854730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
45954730332SMichael Pfeiffer 	BShape shape;
46054730332SMichael Pfeiffer 	shape.MoveTo(BPoint(frame.left, frame.bottom));
46154730332SMichael Pfeiffer 	shape.LineTo(BPoint(frame.right, frame.top));
46254730332SMichael Pfeiffer 	shape.LineTo(BPoint(frame.left, frame.top));
46354730332SMichael Pfeiffer 	shape.LineTo(BPoint(frame.right, frame.bottom));
46454730332SMichael Pfeiffer 	view->FillShape(&shape);
46582afdb09SMichael Pfeiffer }
46682afdb09SMichael Pfeiffer 
46754730332SMichael Pfeiffer static void testStrokeShape(BView *view, BRect frame)
46854730332SMichael Pfeiffer {
46954730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
47054730332SMichael Pfeiffer 	BShape shape;
47154730332SMichael Pfeiffer 	shape.MoveTo(BPoint(frame.left, frame.bottom));
47254730332SMichael Pfeiffer 	shape.LineTo(BPoint(frame.right, frame.top));
47354730332SMichael Pfeiffer 	shape.LineTo(BPoint(frame.left, frame.top));
47454730332SMichael Pfeiffer 	shape.LineTo(BPoint(frame.right, frame.bottom));
47554730332SMichael Pfeiffer 	view->StrokeShape(&shape);
47654730332SMichael Pfeiffer }
47754730332SMichael Pfeiffer 
47854730332SMichael Pfeiffer static void testRecordPicture(BView *view, BRect frame)
47982afdb09SMichael Pfeiffer {
48082afdb09SMichael Pfeiffer 	BPicture *picture = new BPicture();
48182afdb09SMichael Pfeiffer 	view->BeginPicture(picture);
48282afdb09SMichael Pfeiffer 	view->FillRect(frame);
48382afdb09SMichael Pfeiffer 	view->EndPicture();
48482afdb09SMichael Pfeiffer 	delete picture;
48582afdb09SMichael Pfeiffer }
48682afdb09SMichael Pfeiffer 
48754730332SMichael Pfeiffer static void testRecordAndPlayPicture(BView *view, BRect frame)
48882afdb09SMichael Pfeiffer {
48982afdb09SMichael Pfeiffer 	BPicture *picture = new BPicture();
49082afdb09SMichael Pfeiffer 	view->BeginPicture(picture);
49182afdb09SMichael Pfeiffer 	frame.InsetBy(2, 2);
49282afdb09SMichael Pfeiffer 	view->FillRect(frame);
49382afdb09SMichael Pfeiffer 	view->EndPicture();
49482afdb09SMichael Pfeiffer 	view->DrawPicture(picture);
49582afdb09SMichael Pfeiffer 	delete picture;
49682afdb09SMichael Pfeiffer }
49782afdb09SMichael Pfeiffer 
49854730332SMichael Pfeiffer static void testRecordAndPlayPictureWithOffset(BView *view, BRect frame)
49982afdb09SMichael Pfeiffer {
50082afdb09SMichael Pfeiffer 	BPicture *picture = new BPicture();
50182afdb09SMichael Pfeiffer 	view->BeginPicture(picture);
50282afdb09SMichael Pfeiffer 	frame.InsetBy(frame.Width() / 4, frame.Height() / 4);
50382afdb09SMichael Pfeiffer 	frame.OffsetTo(0, 0);
50482afdb09SMichael Pfeiffer 	view->FillRect(frame);
50582afdb09SMichael Pfeiffer 	view->EndPicture();
50682afdb09SMichael Pfeiffer 
50782afdb09SMichael Pfeiffer 	view->DrawPicture(picture, BPoint(10, 10));
50882afdb09SMichael Pfeiffer 	// color of picture should not change
50954730332SMichael Pfeiffer 	view->SetLowColor(kGreen);
51054730332SMichael Pfeiffer 	view->SetLowColor(kRed);
51182afdb09SMichael Pfeiffer 	view->DrawPicture(picture, BPoint(0, 0));
51282afdb09SMichael Pfeiffer 	delete picture;
51382afdb09SMichael Pfeiffer }
51482afdb09SMichael Pfeiffer 
51554730332SMichael Pfeiffer static void testAppendToPicture(BView *view, BRect frame)
51654730332SMichael Pfeiffer {
51754730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
51854730332SMichael Pfeiffer 	view->BeginPicture(new BPicture());
51954730332SMichael Pfeiffer 	view->FillRect(frame);
52054730332SMichael Pfeiffer 	BPicture* picture = view->EndPicture();
52154730332SMichael Pfeiffer 	if (picture == NULL)
52254730332SMichael Pfeiffer 		return;
52354730332SMichael Pfeiffer 
52454730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
52554730332SMichael Pfeiffer 	view->AppendToPicture(picture);
52654730332SMichael Pfeiffer 	view->SetHighColor(kRed);
52754730332SMichael Pfeiffer 	view->FillRect(frame);
52854730332SMichael Pfeiffer 	if (view->EndPicture() != picture)
52954730332SMichael Pfeiffer 		return;
53054730332SMichael Pfeiffer 
53154730332SMichael Pfeiffer 	view->DrawPicture(picture);
53254730332SMichael Pfeiffer 	delete picture;
53354730332SMichael Pfeiffer }
53454730332SMichael Pfeiffer 
5358247141fSMichael Pfeiffer static void testDrawScaledPicture(BView* view, BRect frame)
5368247141fSMichael Pfeiffer {
5378247141fSMichael Pfeiffer 	view->BeginPicture(new BPicture());
5388247141fSMichael Pfeiffer 	view->FillRect(BRect(0, 0, 15, 15));
5398247141fSMichael Pfeiffer 	BPicture* picture = view->EndPicture();
5408247141fSMichael Pfeiffer 
5418247141fSMichael Pfeiffer 	// first unscaled at left, top
5428247141fSMichael Pfeiffer 	view->DrawPicture(picture, BPoint(2, 2));
5438247141fSMichael Pfeiffer 
5448247141fSMichael Pfeiffer 	// draw scaled at middle top
5458247141fSMichael Pfeiffer 	view->SetScale(0.5);
5468247141fSMichael Pfeiffer 	// the drawing offset must be scaled too!
547ff973abcSMichael Pfeiffer 	view->DrawPicture(picture, BPoint(frame.Width(), 4));
5488247141fSMichael Pfeiffer 
5498247141fSMichael Pfeiffer 	delete picture;
5508247141fSMichael Pfeiffer }
5518247141fSMichael Pfeiffer 
55254730332SMichael Pfeiffer static void testLineArray(BView *view, BRect frame)
55354730332SMichael Pfeiffer {
55454730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
55554730332SMichael Pfeiffer 	view->BeginLineArray(3);
55654730332SMichael Pfeiffer 	view->AddLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top), kBlack);
55754730332SMichael Pfeiffer 
55854730332SMichael Pfeiffer 	frame.top += 2;
55954730332SMichael Pfeiffer 	frame.bottom -= 2;
56054730332SMichael Pfeiffer 	view->AddLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.bottom), kRed);
56154730332SMichael Pfeiffer 
56254730332SMichael Pfeiffer 	frame.bottom += 2;;
56354730332SMichael Pfeiffer 	frame.top = frame.bottom;
56454730332SMichael Pfeiffer 	view->AddLine(BPoint(frame.right, frame.top), BPoint(frame.left, frame.top), kGreen);
56554730332SMichael Pfeiffer 
56654730332SMichael Pfeiffer 	view->EndLineArray();
56754730332SMichael Pfeiffer }
56854730332SMichael Pfeiffer 
56954730332SMichael Pfeiffer static void testInvertRect(BView *view, BRect frame)
57054730332SMichael Pfeiffer {
57154730332SMichael Pfeiffer 	frame.InsetBy(2, 2);
57254730332SMichael Pfeiffer 	view->InvertRect(frame);
57354730332SMichael Pfeiffer }
57454730332SMichael Pfeiffer 
5757cf26360SStefano Ceccherini static void testInvertRectSetDrawingMode(BView *view, BRect frame)
5767cf26360SStefano Ceccherini {
5777cf26360SStefano Ceccherini 	view->SetDrawingMode(B_OP_ALPHA);
5787cf26360SStefano Ceccherini 	view->SetHighColor(128, 128, 128, 128);
5797cf26360SStefano Ceccherini 	frame.InsetBy(2, 2);
5807cf26360SStefano Ceccherini 	view->InvertRect(frame);
5817cf26360SStefano Ceccherini 	frame.InsetBy(10, 10);
5827cf26360SStefano Ceccherini 	view->FillRect(frame, B_SOLID_HIGH);
5837cf26360SStefano Ceccherini }
5847cf26360SStefano Ceccherini 
5854f422578SMichael Pfeiffer static bool isBorder(int32 x, int32 y, int32 width, int32 height) {
5864f422578SMichael Pfeiffer 	return x == 0 || y == 0 || x == width - 1 || y == height - 1;
5874f422578SMichael Pfeiffer }
5884f422578SMichael Pfeiffer 
5894f422578SMichael Pfeiffer static void fillBitmap(BBitmap &bitmap) {
5904f422578SMichael Pfeiffer 	int32 height = bitmap.Bounds().IntegerHeight()+1;
5914f422578SMichael Pfeiffer 	int32 width = bitmap.Bounds().IntegerWidth()+1;
5924f422578SMichael Pfeiffer 	for (int32 y = 0; y < height; y ++) {
5934f422578SMichael Pfeiffer 		for (int32 x = 0; x < width; x ++) {
59482afdb09SMichael Pfeiffer 			char *pixel = (char*)bitmap.Bits();
59582afdb09SMichael Pfeiffer 			pixel += bitmap.BytesPerRow() * y + 4 * x;
5964f422578SMichael Pfeiffer 			if (isBorder(x, y, width, height)) {
5974f422578SMichael Pfeiffer 				// fill with green
5984f422578SMichael Pfeiffer 				pixel[0] = 255;
5994f422578SMichael Pfeiffer 				pixel[1] = 0;
6004f422578SMichael Pfeiffer 				pixel[2] = 255;
6014f422578SMichael Pfeiffer 				pixel[3] = 0;
6024f422578SMichael Pfeiffer 			} else  {
60382afdb09SMichael Pfeiffer 				// fill with blue
60482afdb09SMichael Pfeiffer 				pixel[0] = 255;
60582afdb09SMichael Pfeiffer 				pixel[1] = 0;
60682afdb09SMichael Pfeiffer 				pixel[2] = 0;
60782afdb09SMichael Pfeiffer 				pixel[3] = 255;
60882afdb09SMichael Pfeiffer 			}
60982afdb09SMichael Pfeiffer 		}
6104f422578SMichael Pfeiffer 	}
6114f422578SMichael Pfeiffer }
6124f422578SMichael Pfeiffer 
6134f422578SMichael Pfeiffer static void testDrawBitmap(BView *view, BRect frame) {
6144f422578SMichael Pfeiffer 	BBitmap bitmap(frame, B_RGBA32);
6154f422578SMichael Pfeiffer 	fillBitmap(bitmap);
61682afdb09SMichael Pfeiffer 	view->DrawBitmap(&bitmap, BPoint(0, 0));
61782afdb09SMichael Pfeiffer }
61882afdb09SMichael Pfeiffer 
6194f422578SMichael Pfeiffer static void testDrawBitmapAtPoint(BView *view, BRect frame) {
6204f422578SMichael Pfeiffer 	frame.InsetBy(2, 2);
6214f422578SMichael Pfeiffer 
6224f422578SMichael Pfeiffer 	BRect bounds(frame);
6234f422578SMichael Pfeiffer 	bounds.OffsetTo(0, 0);
6244f422578SMichael Pfeiffer 	bounds.right /= 2;
6254f422578SMichael Pfeiffer 	bounds.bottom /= 2;
6264f422578SMichael Pfeiffer 
6274f422578SMichael Pfeiffer 	BBitmap bitmap(bounds, B_RGBA32);
6284f422578SMichael Pfeiffer 	fillBitmap(bitmap);
6294f422578SMichael Pfeiffer 	view->DrawBitmap(&bitmap, centerPoint(frame));
6304f422578SMichael Pfeiffer }
6314f422578SMichael Pfeiffer 
6324f422578SMichael Pfeiffer static void testDrawBitmapAtRect(BView *view, BRect frame) {
6334f422578SMichael Pfeiffer 	BRect bounds(frame);
6344f422578SMichael Pfeiffer 	BBitmap bitmap(bounds, B_RGBA32);
6354f422578SMichael Pfeiffer 	fillBitmap(bitmap);
6364f422578SMichael Pfeiffer 	frame.InsetBy(2, 2);
6374f422578SMichael Pfeiffer 	view->DrawBitmap(&bitmap, frame);
6384f422578SMichael Pfeiffer }
6394f422578SMichael Pfeiffer 
6404f422578SMichael Pfeiffer static void testDrawLargeBitmap(BView *view, BRect frame) {
6414f422578SMichael Pfeiffer 	BRect bounds(frame);
6424f422578SMichael Pfeiffer 	bounds.OffsetTo(0, 0);
6438247141fSMichael Pfeiffer 	bounds.right *= 4;
6448247141fSMichael Pfeiffer 	bounds.bottom *= 4;
6454f422578SMichael Pfeiffer 	BBitmap bitmap(bounds, B_RGBA32);
6464f422578SMichael Pfeiffer 	fillBitmap(bitmap);
6474f422578SMichael Pfeiffer 	frame.InsetBy(2, 2);
6484f422578SMichael Pfeiffer 	view->DrawBitmap(&bitmap, frame);
6494f422578SMichael Pfeiffer }
6504f422578SMichael Pfeiffer 
651c43f0163SMichael Pfeiffer static void testConstrainClippingRegion(BView *view, BRect frame)
652c43f0163SMichael Pfeiffer {
653c43f0163SMichael Pfeiffer 	frame.InsetBy(2, 2);
654c43f0163SMichael Pfeiffer 	// draw background
655c43f0163SMichael Pfeiffer 	view->SetHighColor(kRed);
656c43f0163SMichael Pfeiffer 	view->FillRect(frame);
657c43f0163SMichael Pfeiffer 
658c43f0163SMichael Pfeiffer 	frame.InsetBy(1, 1);
659c43f0163SMichael Pfeiffer 	BRegion region(frame);
660c43f0163SMichael Pfeiffer 	BRect r(frame);
661c43f0163SMichael Pfeiffer 	r.InsetBy(r.IntegerWidth() / 4, r.IntegerHeight() / 4);
662c43f0163SMichael Pfeiffer 	region.Exclude(r);
663c43f0163SMichael Pfeiffer 	view->ConstrainClippingRegion(&region);
664c43f0163SMichael Pfeiffer 
665c43f0163SMichael Pfeiffer 	frame.InsetBy(-1, -1);
666c43f0163SMichael Pfeiffer 	view->SetHighColor(kBlack);
667c43f0163SMichael Pfeiffer 	view->FillRect(frame);
668c43f0163SMichael Pfeiffer 	// a filled black rectangle with a red one pixel border
669c43f0163SMichael Pfeiffer 	// and inside a red rectangle should be drawn.
670c43f0163SMichael Pfeiffer }
671c43f0163SMichael Pfeiffer 
672c43f0163SMichael Pfeiffer static void testClipToPicture(BView *view, BRect frame)
673c43f0163SMichael Pfeiffer {
674c43f0163SMichael Pfeiffer 	frame.InsetBy(2, 2);
675c43f0163SMichael Pfeiffer 	view->BeginPicture(new BPicture());
676c43f0163SMichael Pfeiffer 	view->FillEllipse(frame);
677c43f0163SMichael Pfeiffer 	BPicture *picture = view->EndPicture();
678c43f0163SMichael Pfeiffer 	if (picture == NULL)
679c43f0163SMichael Pfeiffer 		return;
680c43f0163SMichael Pfeiffer 
681c43f0163SMichael Pfeiffer 	view->ClipToPicture(picture);
682c43f0163SMichael Pfeiffer 	delete picture;
683c43f0163SMichael Pfeiffer 
684c43f0163SMichael Pfeiffer 	view->FillRect(frame);
685c43f0163SMichael Pfeiffer 	// black ellipse should be drawn
686c43f0163SMichael Pfeiffer }
687c43f0163SMichael Pfeiffer 
688c43f0163SMichael Pfeiffer static void testClipToInversePicture(BView *view, BRect frame)
689c43f0163SMichael Pfeiffer {
690c43f0163SMichael Pfeiffer 	frame.InsetBy(2, 2);
691c43f0163SMichael Pfeiffer 
692c43f0163SMichael Pfeiffer 	view->BeginPicture(new BPicture());
693c43f0163SMichael Pfeiffer 	view->FillEllipse(frame);
694c43f0163SMichael Pfeiffer 	BPicture *picture = view->EndPicture();
695c43f0163SMichael Pfeiffer 	if (picture == NULL)
696c43f0163SMichael Pfeiffer 		return;
697c43f0163SMichael Pfeiffer 
698c43f0163SMichael Pfeiffer 	view->ClipToInversePicture(picture);
699c43f0163SMichael Pfeiffer 	delete picture;
700c43f0163SMichael Pfeiffer 
701c43f0163SMichael Pfeiffer 	view->FillRect(frame);
702c43f0163SMichael Pfeiffer 	// white ellipse inside a black rectangle
703c43f0163SMichael Pfeiffer }
704c43f0163SMichael Pfeiffer 
705c43f0163SMichael Pfeiffer static void testSetPenSize(BView *view, BRect frame)
706c43f0163SMichael Pfeiffer {
707c43f0163SMichael Pfeiffer 	frame.InsetBy(8, 2);
708c43f0163SMichael Pfeiffer 	float x = centerPoint(frame).x;
709c43f0163SMichael Pfeiffer 
710c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top));
711c43f0163SMichael Pfeiffer 
712c43f0163SMichael Pfeiffer 	frame.OffsetBy(0, 5);
713c43f0163SMichael Pfeiffer 	view->SetPenSize(1);
714c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(x, frame.top));
715c43f0163SMichael Pfeiffer 	view->SetPenSize(0);
716c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(x+1, frame.top), BPoint(frame.right, frame.top));
717c43f0163SMichael Pfeiffer 
718c43f0163SMichael Pfeiffer 	frame.OffsetBy(0, 5);
719c43f0163SMichael Pfeiffer 	view->SetPenSize(1);
720c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(x, frame.top));
721c43f0163SMichael Pfeiffer 	view->SetPenSize(2);
722c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(x+1, frame.top), BPoint(frame.right, frame.top));
723c43f0163SMichael Pfeiffer 
724c43f0163SMichael Pfeiffer 	frame.OffsetBy(0, 5);
725c43f0163SMichael Pfeiffer 	view->SetPenSize(1);
726c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(x, frame.top));
727c43f0163SMichael Pfeiffer 	view->SetPenSize(3);
728c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(x+1, frame.top), BPoint(frame.right, frame.top));
729c43f0163SMichael Pfeiffer 
730c43f0163SMichael Pfeiffer 	frame.OffsetBy(0, 5);
731c43f0163SMichael Pfeiffer 	view->SetPenSize(1);
732c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(x, frame.top));
733c43f0163SMichael Pfeiffer 	view->SetPenSize(4);
734c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(x+1, frame.top), BPoint(frame.right, frame.top));
735c43f0163SMichael Pfeiffer }
736c43f0163SMichael Pfeiffer 
737c43f0163SMichael Pfeiffer static void testSetPenSize2(BView *view, BRect frame)
738c43f0163SMichael Pfeiffer {
739c43f0163SMichael Pfeiffer 	// test if pen size is scaled too
740c43f0163SMichael Pfeiffer 	frame.InsetBy(2, 2);
741c43f0163SMichael Pfeiffer 	frame.OffsetBy(0, 5);
742c43f0163SMichael Pfeiffer 	view->SetPenSize(4);
743c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top));
744c43f0163SMichael Pfeiffer 	view->SetScale(0.5);
745c43f0163SMichael Pfeiffer 	view->StrokeLine(BPoint(frame.left + 2, frame.bottom), BPoint(frame.right + 2, frame.bottom));
746c43f0163SMichael Pfeiffer 
747c43f0163SMichael Pfeiffer 	// black line from left to right, 4 pixel size
748c43f0163SMichael Pfeiffer 	// below black line with half the length of the first one
749c43f0163SMichael Pfeiffer 	// and 2 pixel size
750c43f0163SMichael Pfeiffer }
751c43f0163SMichael Pfeiffer 
752c43f0163SMichael Pfeiffer static void testPattern(BView *view, BRect frame)
753c43f0163SMichael Pfeiffer {
754c43f0163SMichael Pfeiffer 	frame.InsetBy(2, 2);
755c43f0163SMichael Pfeiffer 	int x = frame.IntegerWidth() / 3;
756c43f0163SMichael Pfeiffer 	frame.right = frame.left + x - 2;
757c43f0163SMichael Pfeiffer 		// -2 for an empty pixel row between
758c43f0163SMichael Pfeiffer 		// filled rectangles
759c43f0163SMichael Pfeiffer 
760c43f0163SMichael Pfeiffer 	view->SetLowColor(kGreen);
761c43f0163SMichael Pfeiffer 	view->SetHighColor(kRed);
762c43f0163SMichael Pfeiffer 
763c43f0163SMichael Pfeiffer 	view->FillRect(frame, B_SOLID_HIGH);
764c43f0163SMichael Pfeiffer 
765c43f0163SMichael Pfeiffer 	frame.OffsetBy(x, 0);
766c43f0163SMichael Pfeiffer 	view->FillRect(frame, B_MIXED_COLORS);
767c43f0163SMichael Pfeiffer 
768c43f0163SMichael Pfeiffer 	frame.OffsetBy(x, 0);
769c43f0163SMichael Pfeiffer 	view->FillRect(frame, B_SOLID_LOW);
770c43f0163SMichael Pfeiffer }
771c43f0163SMichael Pfeiffer 
772c43f0163SMichael Pfeiffer static void testSetOrigin(BView *view, BRect frame)
773c43f0163SMichael Pfeiffer {
774c43f0163SMichael Pfeiffer 	BPoint origin = view->Origin();
775c43f0163SMichael Pfeiffer 	BPoint center = centerPoint(frame);
776c43f0163SMichael Pfeiffer 	view->SetOrigin(center);
777c43f0163SMichael Pfeiffer 
778c43f0163SMichael Pfeiffer 	BRect r(0, 0, center.x, center.y);
779c43f0163SMichael Pfeiffer 	view->SetHighColor(kBlue);
780c43f0163SMichael Pfeiffer 	view->FillRect(r);
781c43f0163SMichael Pfeiffer 
782c43f0163SMichael Pfeiffer 	view->SetOrigin(origin);
783c43f0163SMichael Pfeiffer 	view->SetHighColor(kRed);
784c43f0163SMichael Pfeiffer 	view->FillRect(r);
785c43f0163SMichael Pfeiffer 
786c43f0163SMichael Pfeiffer 	// red rectangle in left, top corner
787c43f0163SMichael Pfeiffer 	// blue rectangle in right, bottom corner
788c43f0163SMichael Pfeiffer 	// the red rectangle overwrites the
789c43f0163SMichael Pfeiffer 	// top, left pixel of the blue rectangle
790c43f0163SMichael Pfeiffer }
791c43f0163SMichael Pfeiffer 
792c43f0163SMichael Pfeiffer static void testSetOrigin2(BView *view, BRect frame)
793c43f0163SMichael Pfeiffer {
794c43f0163SMichael Pfeiffer 	BPoint center = centerPoint(frame);
795c43f0163SMichael Pfeiffer 	BRect r(0, 0, center.x, center.y);
796c43f0163SMichael Pfeiffer 	view->SetOrigin(center);
797c43f0163SMichael Pfeiffer 	view->PushState();
798c43f0163SMichael Pfeiffer 		view->SetOrigin(BPoint(-center.x, 0));
799c43f0163SMichael Pfeiffer 		view->FillRect(r);
800c43f0163SMichael Pfeiffer 	view->PopState();
801c43f0163SMichael Pfeiffer 	// black rectangle in left, bottom corner
802c43f0163SMichael Pfeiffer }
803c43f0163SMichael Pfeiffer 
804c43f0163SMichael Pfeiffer static void testSetScale(BView *view, BRect frame)
805c43f0163SMichael Pfeiffer {
806c43f0163SMichael Pfeiffer 	view->SetScale(0.5);
807c43f0163SMichael Pfeiffer 	view->FillRect(frame);
808c43f0163SMichael Pfeiffer 	// black rectangle in left, top corner
809c43f0163SMichael Pfeiffer }
810c43f0163SMichael Pfeiffer 
811c43f0163SMichael Pfeiffer static void testSetScale2(BView *view, BRect frame)
812c43f0163SMichael Pfeiffer {
813c43f0163SMichael Pfeiffer 	view->SetScale(0.5);
814c43f0163SMichael Pfeiffer 	view->PushState();
815c43f0163SMichael Pfeiffer 		view->SetScale(0.5);
816c43f0163SMichael Pfeiffer 		view->FillRect(frame);
817c43f0163SMichael Pfeiffer 	view->PopState();
818c43f0163SMichael Pfeiffer 	// black rectangle in left, top corner
819c43f0163SMichael Pfeiffer 	// with half the size of the rectangle
820c43f0163SMichael Pfeiffer 	// from test testSetScaling
821c43f0163SMichael Pfeiffer }
822c43f0163SMichael Pfeiffer 
823c43f0163SMichael Pfeiffer static void testSetScale3(BView *view, BRect frame)
824c43f0163SMichael Pfeiffer {
825c43f0163SMichael Pfeiffer 	view->SetScale(0.5);
826c43f0163SMichael Pfeiffer 	view->PushState();
827c43f0163SMichael Pfeiffer 		// if the second scale value differs slightly
828c43f0163SMichael Pfeiffer 		// the bug under BeOS R5 in testSetScale2
829c43f0163SMichael Pfeiffer 		// does not occur
830c43f0163SMichael Pfeiffer 		view->SetScale(0.5000001);
831c43f0163SMichael Pfeiffer 		view->FillRect(frame);
832c43f0163SMichael Pfeiffer 	view->PopState();
833c43f0163SMichael Pfeiffer 	// black rectangle in left, top corner
834c43f0163SMichael Pfeiffer 	// with half the size of the rectangle
835c43f0163SMichael Pfeiffer 	// from test testSetScaling
836c43f0163SMichael Pfeiffer }
837c43f0163SMichael Pfeiffer 
838c9c4a80aSMichael Pfeiffer static void testSetOriginAndScale(BView *view, BRect frame)
839c9c4a80aSMichael Pfeiffer {
840c9c4a80aSMichael Pfeiffer 	frame.InsetBy(2, 2);
841c9c4a80aSMichael Pfeiffer 	BPoint center = centerPoint(frame);
842c9c4a80aSMichael Pfeiffer 
843c9c4a80aSMichael Pfeiffer 	BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2);
844c9c4a80aSMichael Pfeiffer 	view->SetOrigin(center);
845c9c4a80aSMichael Pfeiffer 	view->FillRect(r);
846c9c4a80aSMichael Pfeiffer 
847c9c4a80aSMichael Pfeiffer 	view->SetScale(0.5);
848c9c4a80aSMichael Pfeiffer 	view->SetHighColor(kRed);
849c9c4a80aSMichael Pfeiffer 	view->FillRect(r);
850c9c4a80aSMichael Pfeiffer }
851c9c4a80aSMichael Pfeiffer 
8524b05331dSMichael Pfeiffer static void testSetOriginAndScale2(BView *view, BRect frame)
8534b05331dSMichael Pfeiffer {
8544b05331dSMichael Pfeiffer 	frame.InsetBy(2, 2);
8554b05331dSMichael Pfeiffer 	BPoint center = centerPoint(frame);
8564b05331dSMichael Pfeiffer 
8574b05331dSMichael Pfeiffer 	BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2);
8584b05331dSMichael Pfeiffer 	view->SetOrigin(center);
8594b05331dSMichael Pfeiffer 	view->FillRect(r);
8604b05331dSMichael Pfeiffer 
8614b05331dSMichael Pfeiffer 	view->SetScale(0.5);
8624b05331dSMichael Pfeiffer 	view->SetHighColor(kRed);
8634b05331dSMichael Pfeiffer 	view->FillRect(r);
8644b05331dSMichael Pfeiffer 
8654b05331dSMichael Pfeiffer 	view->SetOrigin(0, 0);
8664b05331dSMichael Pfeiffer 	view->SetHighColor(kGreen);
8674b05331dSMichael Pfeiffer 	view->FillRect(r);
8684b05331dSMichael Pfeiffer }
8694b05331dSMichael Pfeiffer 
8704b05331dSMichael Pfeiffer static void testSetOriginAndScale3(BView *view, BRect frame)
8714b05331dSMichael Pfeiffer {
8724b05331dSMichael Pfeiffer 	frame.InsetBy(2, 2);
8734b05331dSMichael Pfeiffer 	BPoint center = centerPoint(frame);
8744b05331dSMichael Pfeiffer 
8754b05331dSMichael Pfeiffer 	BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2);
8764b05331dSMichael Pfeiffer 	view->SetOrigin(center);
8774b05331dSMichael Pfeiffer 	view->FillRect(r);
8784b05331dSMichael Pfeiffer 
8794b05331dSMichael Pfeiffer 	view->SetScale(0.5);
8804b05331dSMichael Pfeiffer 	view->SetHighColor(kRed);
8814b05331dSMichael Pfeiffer 	view->FillRect(r);
8824b05331dSMichael Pfeiffer 
8834b05331dSMichael Pfeiffer 	view->SetScale(0.25);
8844b05331dSMichael Pfeiffer 	view->SetHighColor(kGreen);
8854b05331dSMichael Pfeiffer 	view->FillRect(r);
8864b05331dSMichael Pfeiffer }
8874b05331dSMichael Pfeiffer 
8884b05331dSMichael Pfeiffer static void testSetOriginAndScale4(BView *view, BRect frame)
8894b05331dSMichael Pfeiffer {
8904b05331dSMichael Pfeiffer 	frame.InsetBy(2, 2);
8914b05331dSMichael Pfeiffer 	BPoint center = centerPoint(frame);
8924b05331dSMichael Pfeiffer 
8934b05331dSMichael Pfeiffer 	BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2);
8944b05331dSMichael Pfeiffer 	view->SetOrigin(center);
8954b05331dSMichael Pfeiffer 	view->FillRect(r);
8964b05331dSMichael Pfeiffer 
8974b05331dSMichael Pfeiffer 	view->SetScale(0.5);
8984b05331dSMichael Pfeiffer 	view->SetHighColor(kRed);
8994b05331dSMichael Pfeiffer 	view->FillRect(r);
9004b05331dSMichael Pfeiffer 
9014b05331dSMichael Pfeiffer 	view->PushState();
9024b05331dSMichael Pfeiffer 		//
9034b05331dSMichael Pfeiffer 		view->SetOrigin(center.x+1, center.y);
9044b05331dSMichael Pfeiffer 			// +1 to work around BeOS bug
9054b05331dSMichael Pfeiffer 			// where setting the origin has no
9064b05331dSMichael Pfeiffer 			// effect if it is the same as
9074b05331dSMichael Pfeiffer 			// the previous value althou
9084b05331dSMichael Pfeiffer 			// it is from the "outer" coordinate
9094b05331dSMichael Pfeiffer 			// system
9104b05331dSMichael Pfeiffer 		view->SetHighColor(kGreen);
9114b05331dSMichael Pfeiffer 		view->FillRect(r);
9124b05331dSMichael Pfeiffer 	view->PopState();
9134b05331dSMichael Pfeiffer }
9144b05331dSMichael Pfeiffer 
9154b05331dSMichael Pfeiffer static void testSetOriginAndScale5(BView *view, BRect frame)
9164b05331dSMichael Pfeiffer {
9174b05331dSMichael Pfeiffer 	frame.InsetBy(2, 2);
9184b05331dSMichael Pfeiffer 	BPoint center = centerPoint(frame);
9194b05331dSMichael Pfeiffer 
9204b05331dSMichael Pfeiffer 	BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2);
9214b05331dSMichael Pfeiffer 	view->SetOrigin(center);
9224b05331dSMichael Pfeiffer 	view->FillRect(r);
9234b05331dSMichael Pfeiffer 
9244b05331dSMichael Pfeiffer 	view->SetScale(0.5);
9254b05331dSMichael Pfeiffer 	view->SetHighColor(kRed);
9264b05331dSMichael Pfeiffer 	view->FillRect(r);
9274b05331dSMichael Pfeiffer 
9284b05331dSMichael Pfeiffer 	view->PushState();
9294b05331dSMichael Pfeiffer 	view->SetScale(0.75);
9304b05331dSMichael Pfeiffer 	view->SetHighColor(kGreen);
9314b05331dSMichael Pfeiffer 	view->FillRect(r);
9324b05331dSMichael Pfeiffer 	view->PopState();
9334b05331dSMichael Pfeiffer }
9344b05331dSMichael Pfeiffer 
935c43f0163SMichael Pfeiffer static void testSetFontSize(BView *view, BRect frame)
936c43f0163SMichael Pfeiffer {
937c43f0163SMichael Pfeiffer 	frame.InsetBy(2, 2);
938c43f0163SMichael Pfeiffer 	int size = frame.IntegerHeight() / 3;
939c43f0163SMichael Pfeiffer 
940c43f0163SMichael Pfeiffer 	frame.OffsetBy(0, size);
941c43f0163SMichael Pfeiffer 	view->MovePenTo(BPoint(frame.left, frame.top));
942c43f0163SMichael Pfeiffer 	view->SetFontSize(size);
943c43f0163SMichael Pfeiffer 	view->DrawString("Haiku");
944c43f0163SMichael Pfeiffer 
945c43f0163SMichael Pfeiffer 	size *= 2;
946c43f0163SMichael Pfeiffer 	frame.OffsetBy(0, size);
947c43f0163SMichael Pfeiffer 	view->MovePenTo(BPoint(frame.left, frame.top));
948c43f0163SMichael Pfeiffer 	view->SetFontSize(size);
949c43f0163SMichael Pfeiffer 	view->DrawString("Haiku");
950c43f0163SMichael Pfeiffer }
951c43f0163SMichael Pfeiffer 
9522fb98dccSStefano Ceccherini static void testSetFontFamilyAndStyle(BView *view, BRect frame)
9532fb98dccSStefano Ceccherini {
9542fb98dccSStefano Ceccherini 	view->DrawString("This is a test", BPoint(2, 6));
9552fb98dccSStefano Ceccherini 
9562fb98dccSStefano Ceccherini 	BFont font;
9572fb98dccSStefano Ceccherini 	view->GetFont(&font);
9582fb98dccSStefano Ceccherini 
9592fb98dccSStefano Ceccherini 	int32 families = count_font_families();
9602fb98dccSStefano Ceccherini 	font_family familyName;
9612fb98dccSStefano Ceccherini 	get_font_family(families - 1, &familyName);
9622fb98dccSStefano Ceccherini 
9632fb98dccSStefano Ceccherini 	int32 styles = count_font_styles(familyName);
9642fb98dccSStefano Ceccherini 	font_style styleName;
9652fb98dccSStefano Ceccherini 	get_font_style(familyName, styles - 1, &styleName);
9662fb98dccSStefano Ceccherini 	font.SetFamilyAndStyle(familyName, styleName);
9672fb98dccSStefano Ceccherini 	view->SetFont(&font);
9682fb98dccSStefano Ceccherini 	view->DrawString( "This is a test", BPoint(2, 19));
9692fb98dccSStefano Ceccherini }
9702fb98dccSStefano Ceccherini 
97115cf50e0SStefano Ceccherini static void testSetDrawingMode(BView *view, BRect frame)
97215cf50e0SStefano Ceccherini {
973ed70c5f3SStefano Ceccherini 	frame.InsetBy(2, 2);
97415cf50e0SStefano Ceccherini 	view->StrokeLine(frame.LeftTop(), frame.RightBottom());
97515cf50e0SStefano Ceccherini 	view->StrokeLine(frame.LeftBottom(), frame.RightTop());
97615cf50e0SStefano Ceccherini 	view->SetDrawingMode(B_OP_ALPHA);
97715cf50e0SStefano Ceccherini 	rgb_color color = kRed;
97815cf50e0SStefano Ceccherini 	color.alpha = 127;
97915cf50e0SStefano Ceccherini 	view->SetHighColor(color);
98015cf50e0SStefano Ceccherini 	view->FillRect(frame, B_SOLID_HIGH);
98115cf50e0SStefano Ceccherini }
98215cf50e0SStefano Ceccherini 
983ed70c5f3SStefano Ceccherini static void testPushPopState(BView *view, BRect frame)
984ed70c5f3SStefano Ceccherini {
985ed70c5f3SStefano Ceccherini 	frame.InsetBy(2, 2);
986ed70c5f3SStefano Ceccherini 	view->SetHighColor(kGreen);
987ed70c5f3SStefano Ceccherini 	view->PushState();
988ed70c5f3SStefano Ceccherini 	view->SetHighColor(kRed);
989ed70c5f3SStefano Ceccherini 	view->PopState();
990ed70c5f3SStefano Ceccherini 
991ed70c5f3SStefano Ceccherini 	view->FillRect(frame, B_SOLID_HIGH);
992ed70c5f3SStefano Ceccherini }
993ed70c5f3SStefano Ceccherini 
9948247141fSMichael Pfeiffer static void testFontRotation(BView* view, BRect frame)
9958247141fSMichael Pfeiffer {
9968247141fSMichael Pfeiffer 	BFont font;
9978247141fSMichael Pfeiffer 	view->GetFont(&font);
9988247141fSMichael Pfeiffer 
9998247141fSMichael Pfeiffer 	font.SetRotation(90);
10008247141fSMichael Pfeiffer 	view->SetFont(&font, B_FONT_ROTATION);
10018247141fSMichael Pfeiffer 	view->DrawString("This is a test!", BPoint(frame.Width() / 2, frame.bottom - 3));
10028247141fSMichael Pfeiffer 
10038247141fSMichael Pfeiffer 	view->GetFont(&font);
10048247141fSMichael Pfeiffer 	if (font.Rotation() != 90.0)
10058247141fSMichael Pfeiffer 		fprintf(stderr, "Error: Rotation is %f but should be 90.0\n", font.Rotation());
10068247141fSMichael Pfeiffer }
100715cf50e0SStefano Ceccherini 
1008abf565b1SStefano Ceccherini 
1009abf565b1SStefano Ceccherini 
1010abf565b1SStefano Ceccherini 
1011c43f0163SMichael Pfeiffer // TODO
1012c43f0163SMichael Pfeiffer // - blending mode
1013c43f0163SMichael Pfeiffer // - line mode
1014c43f0163SMichael Pfeiffer // - push/pop state
1015c43f0163SMichael Pfeiffer // - move pen
1016c43f0163SMichael Pfeiffer // - set font
1017c43f0163SMichael Pfeiffer 
1018c43f0163SMichael Pfeiffer 
101982afdb09SMichael Pfeiffer TestCase gTestCases[] = {
102054730332SMichael Pfeiffer 	{ "Test No Operation", testNoOp },
102154730332SMichael Pfeiffer 	{ "Test DrawChar", testDrawChar },
102282afdb09SMichael Pfeiffer 	{ "Test Draw String", testDrawString },
102354730332SMichael Pfeiffer 	{ "Test Draw String With Length", testDrawStringWithLength },
1024abf565b1SStefano Ceccherini 	{ "Test Draw String With Offsets", testDrawStringWithOffsets },
1025abf565b1SStefano Ceccherini 
102654730332SMichael Pfeiffer 	{ "Test FillArc", testFillArc },
102754730332SMichael Pfeiffer 	{ "Test StrokeArc", testStrokeArc },
1028c43f0163SMichael Pfeiffer 	// testFillBezier fails under BeOS because the
1029c43f0163SMichael Pfeiffer 	// direct draw version is not correct
103054730332SMichael Pfeiffer 	{ "Test FillBezier", testFillBezier },
103154730332SMichael Pfeiffer 	{ "Test StrokeBezier", testStrokeBezier },
103254730332SMichael Pfeiffer 	{ "Test FillEllipse", testFillEllipse },
103354730332SMichael Pfeiffer 	{ "Test StrokeEllipse", testStrokeEllipse },
103454730332SMichael Pfeiffer 	{ "Test FillPolygon", testFillPolygon },
103554730332SMichael Pfeiffer 	{ "Test StrokePolygon", testStrokePolygon },
103654730332SMichael Pfeiffer 	{ "Test FillRect", testFillRect },
1037abf565b1SStefano Ceccherini 	{ "Test FillRectGradientLinear", testFillRectGradientLinear },
1038abf565b1SStefano Ceccherini 	{ "Test FillRectGradientRadial", testFillRectGradientRadial },
1039abf565b1SStefano Ceccherini 	{ "Test FillRectGradientRadialFocus", testFillRectGradientRadialFocus },
1040abf565b1SStefano Ceccherini 	{ "Test FillRectGradientDiamond", testFillRectGradientDiamond },
1041abf565b1SStefano Ceccherini 	{ "Test FillRectGradientConic", testFillRectGradientConic },
104254730332SMichael Pfeiffer 	{ "Test StrokeRect", testStrokeRect },
104354730332SMichael Pfeiffer 	{ "Test FillRegion", testFillRegion },
1044b8c65995SStefano Ceccherini 	{ "Test FillRegionGradientLinear", testFillRegionGradientLinear },
1045b8c65995SStefano Ceccherini 	{ "Test FillRegionGradientRadial", testFillRegionGradientRadial },
1046b8c65995SStefano Ceccherini 	{ "Test FillRegionGradientRadialFocus", testFillRegionGradientRadialFocus },
1047b8c65995SStefano Ceccherini 	{ "Test FillRegionGradientDiamond", testFillRegionGradientDiamond },
1048b8c65995SStefano Ceccherini 	{ "Test FillRegionGradientConic", testFillRegionGradientConic },
104954730332SMichael Pfeiffer 	{ "Test FillRoundRect", testFillRoundRect },
105000c573d6SStefano Ceccherini 	{ "Test FillRoundRectGradientLinear", testFillRoundRectGradientLinear },
105100c573d6SStefano Ceccherini 	{ "Test FillRoundRectGradientRadial", testFillRoundRectGradientRadial },
105200c573d6SStefano Ceccherini 	{ "Test FillRoundRectGradientRadialFocus", testFillRoundRectGradientRadialFocus },
105300c573d6SStefano Ceccherini 	{ "Test FillRoundRectGradientDiamond", testFillRoundRectGradientDiamond },
105400c573d6SStefano Ceccherini 	{ "Test FillRoundRectGradientConic", testFillRoundRectGradientConic },
105554730332SMichael Pfeiffer 	{ "Test StrokeRoundRect", testStrokeRoundRect },
105654730332SMichael Pfeiffer 	{ "Test FillTriangle", testFillTriangle },
1057*e5f9dfebSStefano Ceccherini 	{ "Test FillTriangleGradientLinear", testFillTriangleGradientLinear },
1058*e5f9dfebSStefano Ceccherini 	{ "Test FillTriangleGradientRadial", testFillTriangleGradientRadial },
1059*e5f9dfebSStefano Ceccherini 	{ "Test FillTriangleGradientRadialFocus", testFillTriangleGradientRadialFocus },
1060*e5f9dfebSStefano Ceccherini 	{ "Test FillTriangleGradientDiamond", testFillTriangleGradientDiamond },
1061*e5f9dfebSStefano Ceccherini 	{ "Test FillTriangleGradientConic", testFillTriangleGradientConic },
106254730332SMichael Pfeiffer 	{ "Test StrokeTriangle", testStrokeTriangle },
106354730332SMichael Pfeiffer 	{ "Test StrokeLine", testStrokeLine },
106454730332SMichael Pfeiffer 	{ "Test FillShape", testFillShape },
106554730332SMichael Pfeiffer 	{ "Test StrokeShape", testStrokeShape },
106682afdb09SMichael Pfeiffer 	{ "Test Record Picture", testRecordPicture },
106782afdb09SMichael Pfeiffer 	{ "Test Record And Play Picture", testRecordAndPlayPicture },
106882afdb09SMichael Pfeiffer 	{ "Test Record And Play Picture With Offset", testRecordAndPlayPictureWithOffset },
106954730332SMichael Pfeiffer 	{ "Test AppendToPicture", testAppendToPicture },
10708247141fSMichael Pfeiffer 	{ "Test Draw Scaled Picture", testDrawScaledPicture },
107154730332SMichael Pfeiffer 	{ "Test LineArray", testLineArray },
107254730332SMichael Pfeiffer 	{ "Test InvertRect", testInvertRect },
10737cf26360SStefano Ceccherini 	{ "Test InvertRectSetDrawingMode", testInvertRectSetDrawingMode },
10744f422578SMichael Pfeiffer 	{ "Test DrawBitmap", testDrawBitmap },
10754f422578SMichael Pfeiffer 	{ "Test DrawBitmapAtPoint", testDrawBitmapAtPoint },
10764f422578SMichael Pfeiffer 	{ "Test DrawBitmapAtRect", testDrawBitmapAtRect },
10775f380e34SMichael Pfeiffer 	{ "Test DrawLargeBitmap", testDrawLargeBitmap },
1078c43f0163SMichael Pfeiffer 	{ "Test ConstrainClippingRegion", testConstrainClippingRegion },
1079c43f0163SMichael Pfeiffer 	{ "Test ClipToPicture", testClipToPicture },
1080c43f0163SMichael Pfeiffer 	{ "Test ClipToInversePicture", testClipToInversePicture },
1081c43f0163SMichael Pfeiffer 	{ "Test SetPenSize", testSetPenSize },
1082c43f0163SMichael Pfeiffer 	{ "Test SetPenSize2", testSetPenSize2 },
1083c43f0163SMichael Pfeiffer 	{ "Test Pattern", testPattern },
1084c43f0163SMichael Pfeiffer 	{ "Test SetOrigin", testSetOrigin },
1085c43f0163SMichael Pfeiffer 	{ "Test SetOrigin2", testSetOrigin2 },
1086c43f0163SMichael Pfeiffer 	{ "Test SetScale", testSetScale },
1087c43f0163SMichael Pfeiffer 	// testSetScale2 fails under BeOS. The picture versions of the
1088c43f0163SMichael Pfeiffer 	// rectangle are twice as large as the direct draw version
1089b8c65995SStefano Ceccherini 	{ "Test SetScale2", testSetScale2 },
1090c43f0163SMichael Pfeiffer 	{ "Test SetScale3", testSetScale3 },
1091c9c4a80aSMichael Pfeiffer 	{ "Test SetOriginAndScale", testSetOriginAndScale },
10924b05331dSMichael Pfeiffer 	{ "Test SetOriginAndScale2", testSetOriginAndScale2 },
10934b05331dSMichael Pfeiffer 	{ "Test SetOriginAndScale3", testSetOriginAndScale3 },
10944b05331dSMichael Pfeiffer 	{ "Test SetOriginAndScale4", testSetOriginAndScale4 },
10954b05331dSMichael Pfeiffer 	{ "Test SetOriginAndScale5", testSetOriginAndScale5 },
1096c43f0163SMichael Pfeiffer 	{ "Test SetFontSize", testSetFontSize },
10972fb98dccSStefano Ceccherini 	{ "Test SetFontFamilyAndStyle", testSetFontFamilyAndStyle },
109815cf50e0SStefano Ceccherini 	{ "Test SetDrawingMode", testSetDrawingMode },
1099ed70c5f3SStefano Ceccherini 	{ "Test PushPopState", testPushPopState },
11008247141fSMichael Pfeiffer 	{ "Test FontRotation", testFontRotation },
110182afdb09SMichael Pfeiffer 	{ NULL, NULL }
110282afdb09SMichael Pfeiffer };
110362c7fd0fSMichael Pfeiffer 
11042fb98dccSStefano Ceccherini 
1105