sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "tdirectgdiresource.h"
|
sl@0
|
17 |
#include <s32mem.h>
|
sl@0
|
18 |
#include <graphics/directgditypes.h>
|
sl@0
|
19 |
#include <graphics/directgdicontext.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
_LIT(KClip, "Clip");
|
sl@0
|
22 |
_LIT(KWriteAlpha, "WriteAlpha");
|
sl@0
|
23 |
|
sl@0
|
24 |
const DirectGdi::TGraphicsRotation TestRot[] =
|
sl@0
|
25 |
{
|
sl@0
|
26 |
DirectGdi::EGraphicsRotationNone,
|
sl@0
|
27 |
DirectGdi::EGraphicsRotation90,
|
sl@0
|
28 |
DirectGdi::EGraphicsRotation180,
|
sl@0
|
29 |
DirectGdi::EGraphicsRotation270
|
sl@0
|
30 |
};
|
sl@0
|
31 |
|
sl@0
|
32 |
CTDirectGdiResource::CTDirectGdiResource() :
|
sl@0
|
33 |
CActive(CActive::EPriorityStandard),
|
sl@0
|
34 |
iCurrentState(EStartup)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
SetTestStepName(KTDirectGdiResourceStep);
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
CTDirectGdiResource::~CTDirectGdiResource()
|
sl@0
|
40 |
{
|
sl@0
|
41 |
Cancel();
|
sl@0
|
42 |
DestroyCommonResource();
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
/**
|
sl@0
|
46 |
Writes output image to file. Append dest + src pixel format to the given file name.
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
void CTDirectGdiResource::SaveOutput(const TDesC& aName)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
TBuf<KFileNameLength> postfix;
|
sl@0
|
51 |
postfix.Append(KSourceString);
|
sl@0
|
52 |
postfix.Append(KSeparator);
|
sl@0
|
53 |
postfix.Append(TDisplayModeMapping::ConvertPixelFormatToShortPixelFormatString(
|
sl@0
|
54 |
iTestParams.iSourceResourcePixelFormat));
|
sl@0
|
55 |
|
sl@0
|
56 |
TESTNOERROR(WriteTargetOutput(iTestParams, aName, &postfix));
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
Check to see if the current source resource pixel format contains alpha.
|
sl@0
|
61 |
@return ETrue if the current source resource pixel format contais alpha, EFalse otherwise.
|
sl@0
|
62 |
*/
|
sl@0
|
63 |
TBool CTDirectGdiResource::SourceResourceHasAlpha() const
|
sl@0
|
64 |
{
|
sl@0
|
65 |
return iTestParams.iSourceResourcePixelFormat==EUidPixelFormatARGB_8888 ||
|
sl@0
|
66 |
iTestParams.iSourceResourcePixelFormat==EUidPixelFormatARGB_8888_PRE;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
/**
|
sl@0
|
70 |
Check to see if tests should run that only need to be run with one pixel format,
|
sl@0
|
71 |
for example tests to check that clipping regions are working correctly. Tests that are
|
sl@0
|
72 |
only run once are run when the target pixel format and the source pixel format are
|
sl@0
|
73 |
both EUidPixelFormatARGB_8888_PRE.
|
sl@0
|
74 |
@return ETrue if both the current source and target pixel formats are EUidPixelFormatARGB_8888_PRE.
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
TBool CTDirectGdiResource::OneTimeTestEnabled() const
|
sl@0
|
77 |
{
|
sl@0
|
78 |
return iTestParams.iTargetPixelFormat==iTestParams.iSourceResourcePixelFormat &&
|
sl@0
|
79 |
iTestParams.iTargetPixelFormat==EUidPixelFormatARGB_8888_PRE;
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
Draws an image with 4 different orientation using given position as the
|
sl@0
|
84 |
origin e.g
|
sl@0
|
85 |
A B
|
sl@0
|
86 |
o
|
sl@0
|
87 |
D C
|
sl@0
|
88 |
*/
|
sl@0
|
89 |
void CTDirectGdiResource::DrawTestPattern1(const TPoint& aPos)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
const TInt w = iImgSz.iWidth;
|
sl@0
|
92 |
const TInt h = iImgSz.iHeight;
|
sl@0
|
93 |
|
sl@0
|
94 |
iGc->DrawResource(TPoint(aPos.iX-w, aPos.iY-h), iImgSrc, DirectGdi::EGraphicsRotationNone);
|
sl@0
|
95 |
iGc->DrawResource(TPoint(aPos.iX, aPos.iY-w), iImgSrc, DirectGdi::EGraphicsRotation90);
|
sl@0
|
96 |
iGc->DrawResource(aPos, iImgSrc, DirectGdi::EGraphicsRotation180);
|
sl@0
|
97 |
iGc->DrawResource(TPoint(aPos.iX-h, aPos.iY), iImgSrc, DirectGdi::EGraphicsRotation270);
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
/**
|
sl@0
|
101 |
Draws two drawables to fit dest rect in the following pattern:
|
sl@0
|
102 |
AB
|
sl@0
|
103 |
*/
|
sl@0
|
104 |
void CTDirectGdiResource::DrawTestPattern1(const TRect& aDestRect,
|
sl@0
|
105 |
const TDrawableSourceAndEquivRotatedBmps& aDrawable1, const TDrawableSourceAndEquivRotatedBmps& aDrawable2)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
const TInt dw = aDestRect.Width();
|
sl@0
|
108 |
const TInt dh = aDestRect.Height();
|
sl@0
|
109 |
const TInt xu = dw/2;
|
sl@0
|
110 |
const TInt yu = dh;
|
sl@0
|
111 |
|
sl@0
|
112 |
iGc->DrawResource(TRect(aDestRect.iTl, TSize(xu, yu)), aDrawable1, KNullDesC8);
|
sl@0
|
113 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY), TSize(xu, yu)),
|
sl@0
|
114 |
aDrawable2, KNullDesC8);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
/**
|
sl@0
|
118 |
Draws two drawables to fit dest rect in the following pattern:
|
sl@0
|
119 |
A
|
sl@0
|
120 |
B
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
void CTDirectGdiResource::DrawTestPattern2(const TRect& aDestRect,
|
sl@0
|
123 |
const TDrawableSourceAndEquivRotatedBmps& aDrawable1, const TDrawableSourceAndEquivRotatedBmps& aDrawable2)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
const TInt dw = aDestRect.Width();
|
sl@0
|
126 |
const TInt dh = aDestRect.Height();
|
sl@0
|
127 |
const TInt xu = dw;
|
sl@0
|
128 |
const TInt yu = dh/2;
|
sl@0
|
129 |
|
sl@0
|
130 |
iGc->DrawResource(TRect(aDestRect.iTl, TSize(xu, yu)), aDrawable1, KNullDesC8);
|
sl@0
|
131 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+yu), TSize(xu, yu)),
|
sl@0
|
132 |
aDrawable2, KNullDesC8);
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
/**
|
sl@0
|
136 |
Draws image rotated to fit dest rect in the following pattern:
|
sl@0
|
137 |
AB
|
sl@0
|
138 |
CC
|
sl@0
|
139 |
DD
|
sl@0
|
140 |
*/
|
sl@0
|
141 |
void CTDirectGdiResource::DrawTestPattern1(const TRect& aDestRect, const TRect* aSrcRect)
|
sl@0
|
142 |
{
|
sl@0
|
143 |
const TInt dw = aDestRect.Width();
|
sl@0
|
144 |
const TInt dh = aDestRect.Height();
|
sl@0
|
145 |
const TInt xu = dw/2;
|
sl@0
|
146 |
const TInt yu = dh/5;
|
sl@0
|
147 |
|
sl@0
|
148 |
if (aSrcRect)
|
sl@0
|
149 |
{
|
sl@0
|
150 |
// use DrawResource(destRect, img, srcRect, rot) API
|
sl@0
|
151 |
iGc->DrawResource(TRect(aDestRect.iTl, TSize(xu, yu)), iImgSrc, *aSrcRect, DirectGdi::EGraphicsRotationNone);
|
sl@0
|
152 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY), TSize(xu, yu)), iImgSrc,
|
sl@0
|
153 |
*aSrcRect, DirectGdi::EGraphicsRotation180);
|
sl@0
|
154 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+yu), TSize(dw, 2*yu)), iImgSrc,
|
sl@0
|
155 |
*aSrcRect, DirectGdi::EGraphicsRotationNone);
|
sl@0
|
156 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+3*yu), TSize(dw, 2*yu)), iImgSrc,
|
sl@0
|
157 |
*aSrcRect, DirectGdi::EGraphicsRotation180);
|
sl@0
|
158 |
}
|
sl@0
|
159 |
else
|
sl@0
|
160 |
{
|
sl@0
|
161 |
// use DrawResource(destRect, img, rot) API
|
sl@0
|
162 |
iGc->DrawResource(TRect(aDestRect.iTl, TSize(xu, yu)), iImgSrc, DirectGdi::EGraphicsRotationNone);
|
sl@0
|
163 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY), TSize(xu, yu)), iImgSrc,
|
sl@0
|
164 |
DirectGdi::EGraphicsRotation180);
|
sl@0
|
165 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+yu), TSize(dw, 2*yu)), iImgSrc,
|
sl@0
|
166 |
DirectGdi::EGraphicsRotationNone);
|
sl@0
|
167 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+3*yu), TSize(dw, 2*yu)), iImgSrc,
|
sl@0
|
168 |
DirectGdi::EGraphicsRotation180);
|
sl@0
|
169 |
}
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
/**
|
sl@0
|
173 |
Draws image rotated to fit dest rect in the following pattern:
|
sl@0
|
174 |
ACD
|
sl@0
|
175 |
BCD
|
sl@0
|
176 |
*/
|
sl@0
|
177 |
void CTDirectGdiResource::DrawTestPattern2(const TRect& aDestRect, const TRect* aSrcRect)
|
sl@0
|
178 |
{
|
sl@0
|
179 |
const TInt dw = aDestRect.Width();
|
sl@0
|
180 |
const TInt dh = aDestRect.Height();
|
sl@0
|
181 |
const TInt xu = dw/5;
|
sl@0
|
182 |
const TInt yu = dh/2;
|
sl@0
|
183 |
|
sl@0
|
184 |
if (aSrcRect)
|
sl@0
|
185 |
{
|
sl@0
|
186 |
// use DrawResource(destRect, img, srcRect, rot) API
|
sl@0
|
187 |
iGc->DrawResource(TRect(aDestRect.iTl, TSize(xu, yu)), iImgSrc, *aSrcRect, DirectGdi::EGraphicsRotation90);
|
sl@0
|
188 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+yu), TSize(xu, yu)), iImgSrc,
|
sl@0
|
189 |
*aSrcRect, DirectGdi::EGraphicsRotation270);
|
sl@0
|
190 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY), TSize(2*xu, dh)), iImgSrc,
|
sl@0
|
191 |
*aSrcRect, DirectGdi::EGraphicsRotation90);
|
sl@0
|
192 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+3*xu, aDestRect.iTl.iY), TSize(2*xu, dh)), iImgSrc,
|
sl@0
|
193 |
*aSrcRect, DirectGdi::EGraphicsRotation270);
|
sl@0
|
194 |
}
|
sl@0
|
195 |
else
|
sl@0
|
196 |
{
|
sl@0
|
197 |
// use DrawResource(destRect, img, rot) API
|
sl@0
|
198 |
iGc->DrawResource(TRect(aDestRect.iTl, TSize(xu, yu)), iImgSrc, DirectGdi::EGraphicsRotation90);
|
sl@0
|
199 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+yu), TSize(xu, yu)), iImgSrc,
|
sl@0
|
200 |
DirectGdi::EGraphicsRotation270);
|
sl@0
|
201 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY), TSize(2*xu, dh)), iImgSrc,
|
sl@0
|
202 |
DirectGdi::EGraphicsRotation90);
|
sl@0
|
203 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+3*xu, aDestRect.iTl.iY), TSize(2*xu, dh)), iImgSrc,
|
sl@0
|
204 |
DirectGdi::EGraphicsRotation270);
|
sl@0
|
205 |
}
|
sl@0
|
206 |
}
|
sl@0
|
207 |
|
sl@0
|
208 |
/**
|
sl@0
|
209 |
Draws image rotated to fit dest rect in the following pattern:
|
sl@0
|
210 |
AB
|
sl@0
|
211 |
CD
|
sl@0
|
212 |
*/
|
sl@0
|
213 |
void CTDirectGdiResource::DrawTestPattern3(const TRect& aDestRect, const TRect* aSrcRect)
|
sl@0
|
214 |
{
|
sl@0
|
215 |
TInt dw = aDestRect.Width();
|
sl@0
|
216 |
TInt dh = aDestRect.Height();
|
sl@0
|
217 |
TInt xu = dw/2;
|
sl@0
|
218 |
TInt yu = dh/2;
|
sl@0
|
219 |
|
sl@0
|
220 |
if (aSrcRect)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
// use DrawResource(destRect, img, srcRect, rot) API
|
sl@0
|
223 |
iGc->DrawResource(TRect(aDestRect.iTl, TSize(xu, yu)), iImgSrc, *aSrcRect, DirectGdi::EGraphicsRotationNone);
|
sl@0
|
224 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY), TSize(xu, yu)), iImgSrc,
|
sl@0
|
225 |
*aSrcRect, DirectGdi::EGraphicsRotation180);
|
sl@0
|
226 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+yu), TSize(xu, yu)), iImgSrc,
|
sl@0
|
227 |
*aSrcRect, DirectGdi::EGraphicsRotation90);
|
sl@0
|
228 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY+yu), TSize(xu, yu)), iImgSrc,
|
sl@0
|
229 |
*aSrcRect, DirectGdi::EGraphicsRotation270);
|
sl@0
|
230 |
}
|
sl@0
|
231 |
else
|
sl@0
|
232 |
{
|
sl@0
|
233 |
// use DrawResource(destRect, img, rot) API
|
sl@0
|
234 |
iGc->DrawResource(TRect(aDestRect.iTl, TSize(xu, yu)), iImgSrc, DirectGdi::EGraphicsRotationNone);
|
sl@0
|
235 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY), TSize(xu, yu)), iImgSrc,
|
sl@0
|
236 |
DirectGdi::EGraphicsRotation180);
|
sl@0
|
237 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX, aDestRect.iTl.iY+yu), TSize(xu, yu)), iImgSrc,
|
sl@0
|
238 |
DirectGdi::EGraphicsRotation90);
|
sl@0
|
239 |
iGc->DrawResource(TRect(TPoint(aDestRect.iTl.iX+xu, aDestRect.iTl.iY+yu), TSize(xu, yu)), iImgSrc,
|
sl@0
|
240 |
DirectGdi::EGraphicsRotation270);
|
sl@0
|
241 |
}
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
/**
|
sl@0
|
245 |
@SYMTestCaseID
|
sl@0
|
246 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0001
|
sl@0
|
247 |
|
sl@0
|
248 |
@SYMTestPriority
|
sl@0
|
249 |
Critical
|
sl@0
|
250 |
|
sl@0
|
251 |
@SYMPREQ
|
sl@0
|
252 |
PREQ39
|
sl@0
|
253 |
|
sl@0
|
254 |
@SYMREQ
|
sl@0
|
255 |
REQ9178
|
sl@0
|
256 |
REQ9200
|
sl@0
|
257 |
REQ9201
|
sl@0
|
258 |
REQ9202
|
sl@0
|
259 |
REQ9203
|
sl@0
|
260 |
REQ9222
|
sl@0
|
261 |
REQ9228
|
sl@0
|
262 |
REQ9223
|
sl@0
|
263 |
REQ9236
|
sl@0
|
264 |
REQ9237
|
sl@0
|
265 |
|
sl@0
|
266 |
@SYMTestStatus
|
sl@0
|
267 |
Implemented
|
sl@0
|
268 |
|
sl@0
|
269 |
@SYMTestCaseDesc
|
sl@0
|
270 |
Draws drawable resources created from RSgDrawable and RSgImage objects.
|
sl@0
|
271 |
|
sl@0
|
272 |
@SYMTestActions
|
sl@0
|
273 |
Draw drawble resources with the various combination of parameters:
|
sl@0
|
274 |
-with and without clipping region
|
sl@0
|
275 |
-drawable from RSgDrawable and RSgImage
|
sl@0
|
276 |
-in various destination positions and scaling factor
|
sl@0
|
277 |
-using write or blend
|
sl@0
|
278 |
|
sl@0
|
279 |
@SYMTestExpectedResults
|
sl@0
|
280 |
Resources are drawn on the given position, scaled to fit the destination
|
sl@0
|
281 |
rectangle, clipped to current clipping region (if set).
|
sl@0
|
282 |
*/
|
sl@0
|
283 |
void CTDirectGdiResource::TestDrawResource_ImageAsDrawableL()
|
sl@0
|
284 |
{
|
sl@0
|
285 |
_LIT(KTestName, "DrawResource_ImageAsDrawable");
|
sl@0
|
286 |
if(!iRunningOomTests)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
INFO_PRINTF1(KTestName);
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|
sl@0
|
291 |
TBuf<KFileNameLength> tag;
|
sl@0
|
292 |
tag.Append(KTestName);
|
sl@0
|
293 |
|
sl@0
|
294 |
ResetGc();
|
sl@0
|
295 |
if (iEnableClipRegion)
|
sl@0
|
296 |
{
|
sl@0
|
297 |
iGc->SetClippingRegion(iClip);
|
sl@0
|
298 |
tag.Append(KClip);
|
sl@0
|
299 |
}
|
sl@0
|
300 |
|
sl@0
|
301 |
if (iUseWriteAlpha)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
|
sl@0
|
304 |
tag.Append(KWriteAlpha);
|
sl@0
|
305 |
}
|
sl@0
|
306 |
|
sl@0
|
307 |
DrawTestPattern1(TRect(0,0,100,20), iDwbSrc[0], iDwbSrc[1]);
|
sl@0
|
308 |
DrawTestPattern2(TRect(0,20,100,100), iDwbSrc[0], iDwbSrc[1]);
|
sl@0
|
309 |
DrawTestPattern1(TRect(0,100,100,200), iDwbSrc[0], iDwbSrc[1]);
|
sl@0
|
310 |
DrawTestPattern2(TRect(100,0,200,200), iDwbSrc[0], iDwbSrc[1]);
|
sl@0
|
311 |
|
sl@0
|
312 |
if (iEnableClipRegion)
|
sl@0
|
313 |
{
|
sl@0
|
314 |
iGc->ResetClippingRegion();
|
sl@0
|
315 |
iGc->SetDrawMode(DirectGdi::EDrawModePEN);
|
sl@0
|
316 |
}
|
sl@0
|
317 |
|
sl@0
|
318 |
SaveOutput(tag);
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
/**
|
sl@0
|
322 |
@SYMTestCaseID
|
sl@0
|
323 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0002
|
sl@0
|
324 |
|
sl@0
|
325 |
@SYMTestPriority
|
sl@0
|
326 |
Critical
|
sl@0
|
327 |
|
sl@0
|
328 |
@SYMPREQ
|
sl@0
|
329 |
PREQ39
|
sl@0
|
330 |
|
sl@0
|
331 |
@SYMREQ
|
sl@0
|
332 |
REQ9178
|
sl@0
|
333 |
REQ9200
|
sl@0
|
334 |
REQ9201
|
sl@0
|
335 |
REQ9202
|
sl@0
|
336 |
REQ9203
|
sl@0
|
337 |
REQ9222
|
sl@0
|
338 |
REQ9228
|
sl@0
|
339 |
REQ9223
|
sl@0
|
340 |
REQ9236
|
sl@0
|
341 |
REQ9237
|
sl@0
|
342 |
|
sl@0
|
343 |
@SYMTestStatus
|
sl@0
|
344 |
Implemented
|
sl@0
|
345 |
|
sl@0
|
346 |
@SYMTestCaseDesc
|
sl@0
|
347 |
Draw an image resource created from RSgImage object.
|
sl@0
|
348 |
|
sl@0
|
349 |
@SYMTestActions
|
sl@0
|
350 |
Draw an image resource with the various combination of parameters:
|
sl@0
|
351 |
-with and without clipping region
|
sl@0
|
352 |
-in various destination positions on/off target
|
sl@0
|
353 |
-using write or blend
|
sl@0
|
354 |
-no scaling is performed in this test
|
sl@0
|
355 |
|
sl@0
|
356 |
@SYMTestExpectedResults
|
sl@0
|
357 |
Resources are drawn on the given position, unscaled, rotated and
|
sl@0
|
358 |
clipped to current clipping region (if set).
|
sl@0
|
359 |
*/
|
sl@0
|
360 |
void CTDirectGdiResource::TestDrawResource_PosL()
|
sl@0
|
361 |
{
|
sl@0
|
362 |
_LIT(KTestName, "DrawResource_Pos");
|
sl@0
|
363 |
if(!iRunningOomTests)
|
sl@0
|
364 |
{
|
sl@0
|
365 |
INFO_PRINTF1(KTestName);
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
TBuf<KFileNameLength> tag;
|
sl@0
|
369 |
tag.Append(KTestName);
|
sl@0
|
370 |
|
sl@0
|
371 |
ResetGc();
|
sl@0
|
372 |
|
sl@0
|
373 |
if (iEnableClipRegion)
|
sl@0
|
374 |
{
|
sl@0
|
375 |
iGc->SetClippingRegion(iClip);
|
sl@0
|
376 |
tag.Append(KClip);
|
sl@0
|
377 |
}
|
sl@0
|
378 |
|
sl@0
|
379 |
if (iUseWriteAlpha)
|
sl@0
|
380 |
{
|
sl@0
|
381 |
iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
|
sl@0
|
382 |
tag.Append(KWriteAlpha);
|
sl@0
|
383 |
}
|
sl@0
|
384 |
|
sl@0
|
385 |
DrawTestPattern1(TPoint(0,0));
|
sl@0
|
386 |
DrawTestPattern1(TPoint(100,0));
|
sl@0
|
387 |
DrawTestPattern1(TPoint(200,0));
|
sl@0
|
388 |
|
sl@0
|
389 |
DrawTestPattern1(TPoint(50,50));
|
sl@0
|
390 |
DrawTestPattern1(TPoint(150,50));
|
sl@0
|
391 |
|
sl@0
|
392 |
DrawTestPattern1(TPoint(0,100));
|
sl@0
|
393 |
DrawTestPattern1(TPoint(100,100));
|
sl@0
|
394 |
DrawTestPattern1(TPoint(200,100));
|
sl@0
|
395 |
|
sl@0
|
396 |
DrawTestPattern1(TPoint(50,150));
|
sl@0
|
397 |
DrawTestPattern1(TPoint(150,150));
|
sl@0
|
398 |
|
sl@0
|
399 |
DrawTestPattern1(TPoint(0,200));
|
sl@0
|
400 |
DrawTestPattern1(TPoint(100,200));
|
sl@0
|
401 |
DrawTestPattern1(TPoint(200,200));
|
sl@0
|
402 |
|
sl@0
|
403 |
if (iEnableClipRegion)
|
sl@0
|
404 |
{
|
sl@0
|
405 |
iGc->ResetClippingRegion();
|
sl@0
|
406 |
iGc->SetDrawMode(DirectGdi::EDrawModePEN);
|
sl@0
|
407 |
}
|
sl@0
|
408 |
|
sl@0
|
409 |
SaveOutput(tag);
|
sl@0
|
410 |
}
|
sl@0
|
411 |
|
sl@0
|
412 |
/**
|
sl@0
|
413 |
@SYMTestCaseID
|
sl@0
|
414 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0003
|
sl@0
|
415 |
|
sl@0
|
416 |
@SYMTestPriority
|
sl@0
|
417 |
Critical
|
sl@0
|
418 |
|
sl@0
|
419 |
@SYMPREQ
|
sl@0
|
420 |
PREQ39
|
sl@0
|
421 |
|
sl@0
|
422 |
@SYMREQ
|
sl@0
|
423 |
REQ9178
|
sl@0
|
424 |
REQ9200
|
sl@0
|
425 |
REQ9201
|
sl@0
|
426 |
REQ9202
|
sl@0
|
427 |
REQ9203
|
sl@0
|
428 |
REQ9222
|
sl@0
|
429 |
REQ9228
|
sl@0
|
430 |
REQ9223
|
sl@0
|
431 |
REQ9236
|
sl@0
|
432 |
REQ9237
|
sl@0
|
433 |
|
sl@0
|
434 |
@SYMTestStatus
|
sl@0
|
435 |
Implemented
|
sl@0
|
436 |
|
sl@0
|
437 |
@SYMTestCaseDesc
|
sl@0
|
438 |
Draw a scaled image resource created from RSgImage object.
|
sl@0
|
439 |
|
sl@0
|
440 |
@SYMTestActions
|
sl@0
|
441 |
Draw a scaled image resource with the various combination of parameters:
|
sl@0
|
442 |
-with and without clipping region
|
sl@0
|
443 |
-in various destination positions and scaling factor
|
sl@0
|
444 |
-using write or blend
|
sl@0
|
445 |
-the destination rectangle that the image is drawn to scaled
|
sl@0
|
446 |
|
sl@0
|
447 |
@SYMTestExpectedResults
|
sl@0
|
448 |
Resources are drawn on the given position, scaled to fit the
|
sl@0
|
449 |
destination rectangle, rotated and clipped to current clipping region (if set).
|
sl@0
|
450 |
*/
|
sl@0
|
451 |
void CTDirectGdiResource::TestDrawResource_DestRectL()
|
sl@0
|
452 |
{
|
sl@0
|
453 |
_LIT(KTestName, "DrawResource_DestRect");
|
sl@0
|
454 |
if(!iRunningOomTests)
|
sl@0
|
455 |
{
|
sl@0
|
456 |
INFO_PRINTF1(KTestName);
|
sl@0
|
457 |
}
|
sl@0
|
458 |
|
sl@0
|
459 |
TBuf<KFileNameLength> tag;
|
sl@0
|
460 |
tag.Append(KTestName);
|
sl@0
|
461 |
|
sl@0
|
462 |
ResetGc();
|
sl@0
|
463 |
|
sl@0
|
464 |
if (iEnableClipRegion)
|
sl@0
|
465 |
{
|
sl@0
|
466 |
iGc->SetClippingRegion(iClip);
|
sl@0
|
467 |
tag.Append(KClip);
|
sl@0
|
468 |
}
|
sl@0
|
469 |
|
sl@0
|
470 |
if (iUseWriteAlpha)
|
sl@0
|
471 |
{
|
sl@0
|
472 |
iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
|
sl@0
|
473 |
tag.Append(KWriteAlpha);
|
sl@0
|
474 |
}
|
sl@0
|
475 |
|
sl@0
|
476 |
DrawTestPattern1(TRect(0,0,100,100));
|
sl@0
|
477 |
DrawTestPattern2(TRect(100,0,200,100));
|
sl@0
|
478 |
DrawTestPattern3(TRect(0,100,100,200));
|
sl@0
|
479 |
DrawTestPattern1(TRect(100,100,150,150));
|
sl@0
|
480 |
DrawTestPattern2(TRect(150,100,200,150));
|
sl@0
|
481 |
DrawTestPattern3(TRect(100,150,200,200));
|
sl@0
|
482 |
|
sl@0
|
483 |
if (iEnableClipRegion)
|
sl@0
|
484 |
{
|
sl@0
|
485 |
iGc->ResetClippingRegion();
|
sl@0
|
486 |
iGc->SetDrawMode(DirectGdi::EDrawModePEN);
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
SaveOutput(tag);
|
sl@0
|
490 |
}
|
sl@0
|
491 |
|
sl@0
|
492 |
/**
|
sl@0
|
493 |
@SYMTestCaseID
|
sl@0
|
494 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0004
|
sl@0
|
495 |
|
sl@0
|
496 |
@SYMTestPriority
|
sl@0
|
497 |
Critical
|
sl@0
|
498 |
|
sl@0
|
499 |
@SYMPREQ
|
sl@0
|
500 |
PREQ39
|
sl@0
|
501 |
|
sl@0
|
502 |
@SYMREQ
|
sl@0
|
503 |
REQ9178
|
sl@0
|
504 |
REQ9200
|
sl@0
|
505 |
REQ9201
|
sl@0
|
506 |
REQ9202
|
sl@0
|
507 |
REQ9203
|
sl@0
|
508 |
REQ9222
|
sl@0
|
509 |
REQ9228
|
sl@0
|
510 |
REQ9223
|
sl@0
|
511 |
REQ9236
|
sl@0
|
512 |
REQ9237
|
sl@0
|
513 |
|
sl@0
|
514 |
@SYMTestStatus
|
sl@0
|
515 |
Implemented
|
sl@0
|
516 |
|
sl@0
|
517 |
@SYMTestCaseDesc
|
sl@0
|
518 |
Draw a scaled portion of an image resource created from RSgImage object.
|
sl@0
|
519 |
|
sl@0
|
520 |
@SYMTestActions
|
sl@0
|
521 |
Draw a scaled portion of an image resource with the various combination of parameters:
|
sl@0
|
522 |
-with and without clipping region
|
sl@0
|
523 |
-various destination positions and size
|
sl@0
|
524 |
-using write or blend
|
sl@0
|
525 |
-only a portion of the image resource is drawn, it is drawn scaled
|
sl@0
|
526 |
|
sl@0
|
527 |
@SYMTestExpectedResults
|
sl@0
|
528 |
Resources are drawn on the given position, scaled to fit the
|
sl@0
|
529 |
destination rectangle, rotated and clipped to current clipping region (if set).
|
sl@0
|
530 |
*/
|
sl@0
|
531 |
void CTDirectGdiResource::TestDrawResource_DestRectSrcRectL()
|
sl@0
|
532 |
{
|
sl@0
|
533 |
_LIT(KTestName, "DrawResource_DestRectSrcRect");
|
sl@0
|
534 |
if(!iRunningOomTests)
|
sl@0
|
535 |
{
|
sl@0
|
536 |
INFO_PRINTF1(KTestName);
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
TBuf<KFileNameLength> tag;
|
sl@0
|
540 |
tag.Append(KTestName);
|
sl@0
|
541 |
|
sl@0
|
542 |
ResetGc();
|
sl@0
|
543 |
if (iEnableClipRegion)
|
sl@0
|
544 |
{
|
sl@0
|
545 |
iGc->SetClippingRegion(iClip);
|
sl@0
|
546 |
tag.Append(KClip);
|
sl@0
|
547 |
}
|
sl@0
|
548 |
|
sl@0
|
549 |
if (iUseWriteAlpha)
|
sl@0
|
550 |
{
|
sl@0
|
551 |
iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
|
sl@0
|
552 |
tag.Append(KWriteAlpha);
|
sl@0
|
553 |
}
|
sl@0
|
554 |
|
sl@0
|
555 |
TRect srcRect(TPoint(1,1), TSize(48,18));
|
sl@0
|
556 |
DrawTestPattern1(TRect(0,0,100,100), &srcRect);
|
sl@0
|
557 |
DrawTestPattern2(TRect(100,0,200,100), &srcRect);
|
sl@0
|
558 |
DrawTestPattern3(TRect(0,100,100,200), &srcRect);
|
sl@0
|
559 |
DrawTestPattern1(TRect(100,100,150,150), &srcRect);
|
sl@0
|
560 |
DrawTestPattern2(TRect(150,100,200,150), &srcRect);
|
sl@0
|
561 |
DrawTestPattern3(TRect(100,150,200,200), &srcRect);
|
sl@0
|
562 |
|
sl@0
|
563 |
if (iEnableClipRegion)
|
sl@0
|
564 |
{
|
sl@0
|
565 |
iGc->ResetClippingRegion();
|
sl@0
|
566 |
iGc->SetDrawMode(DirectGdi::EDrawModePEN);
|
sl@0
|
567 |
}
|
sl@0
|
568 |
|
sl@0
|
569 |
SaveOutput(tag);
|
sl@0
|
570 |
}
|
sl@0
|
571 |
|
sl@0
|
572 |
/**
|
sl@0
|
573 |
@SYMTestCaseID
|
sl@0
|
574 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0005
|
sl@0
|
575 |
|
sl@0
|
576 |
@SYMTestPriority
|
sl@0
|
577 |
Critical
|
sl@0
|
578 |
|
sl@0
|
579 |
@SYMPREQ
|
sl@0
|
580 |
PREQ39
|
sl@0
|
581 |
|
sl@0
|
582 |
@SYMREQ
|
sl@0
|
583 |
REQ9178
|
sl@0
|
584 |
REQ9200
|
sl@0
|
585 |
REQ9201
|
sl@0
|
586 |
REQ9202
|
sl@0
|
587 |
REQ9203
|
sl@0
|
588 |
REQ9222
|
sl@0
|
589 |
REQ9228
|
sl@0
|
590 |
REQ9223
|
sl@0
|
591 |
REQ9236
|
sl@0
|
592 |
REQ9237
|
sl@0
|
593 |
|
sl@0
|
594 |
@SYMTestStatus
|
sl@0
|
595 |
Implemented
|
sl@0
|
596 |
|
sl@0
|
597 |
@SYMTestCaseDesc
|
sl@0
|
598 |
Attempt to draw a resource with a NULL handle for each of the DrawResource methods
|
sl@0
|
599 |
that draw image sources to improve code coverage.
|
sl@0
|
600 |
|
sl@0
|
601 |
@SYMTestActions
|
sl@0
|
602 |
Create an RSgImage,
|
sl@0
|
603 |
Create a RDirectGdiDrawableSource from it,
|
sl@0
|
604 |
Attempt to draw the RDirectGdiDrawableSource with each of the DrawResource methods.
|
sl@0
|
605 |
Each method should set an error of KErrBadHandle.
|
sl@0
|
606 |
|
sl@0
|
607 |
@SYMTestExpectedResults
|
sl@0
|
608 |
Driver returns KErrBadHandle for each attempt to draw invalid resource.
|
sl@0
|
609 |
*/
|
sl@0
|
610 |
void CTDirectGdiResource::TestDrawResource_NullHandleL()
|
sl@0
|
611 |
{
|
sl@0
|
612 |
_LIT(KTestName, "DrawResource_NullHandle");
|
sl@0
|
613 |
if(!iRunningOomTests)
|
sl@0
|
614 |
{
|
sl@0
|
615 |
INFO_PRINTF1(KTestName);
|
sl@0
|
616 |
}
|
sl@0
|
617 |
|
sl@0
|
618 |
ResetGc();
|
sl@0
|
619 |
|
sl@0
|
620 |
CDirectGdiDriver* drv = CDirectGdiDriver::Static();
|
sl@0
|
621 |
TESTL(drv != NULL);
|
sl@0
|
622 |
|
sl@0
|
623 |
// null handle
|
sl@0
|
624 |
//
|
sl@0
|
625 |
RDirectGdiDrawableSource dwb(*drv);
|
sl@0
|
626 |
RDirectGdiDrawableSource img(*drv);
|
sl@0
|
627 |
|
sl@0
|
628 |
// Convert the image source, drawable source and bitmaps to TDrawableSourceAndEquivRotatedBmps so it can be
|
sl@0
|
629 |
// drawn using the BitGdi test code as well as the DirectGdi code
|
sl@0
|
630 |
TDrawableSourceAndEquivRotatedBmps imageSource;
|
sl@0
|
631 |
imageSource.iDrawableSrc = &img;
|
sl@0
|
632 |
TDrawableSourceAndEquivRotatedBmps drawableSource;
|
sl@0
|
633 |
drawableSource.iDrawableSrc = &dwb;
|
sl@0
|
634 |
|
sl@0
|
635 |
TPoint pos;
|
sl@0
|
636 |
TRect dstRect(pos, TSize(100,100));
|
sl@0
|
637 |
TRect srcRect(pos, TSize(10,10));
|
sl@0
|
638 |
|
sl@0
|
639 |
// DrawResource(const TRect&, const RDirectGdiDrawableSource&, const TDesC8&)
|
sl@0
|
640 |
iGc->DrawResource(dstRect, drawableSource, KNullDesC8);
|
sl@0
|
641 |
TESTL(iGc->GetError() == KErrBadHandle);
|
sl@0
|
642 |
|
sl@0
|
643 |
for (TInt rot=0; rot<sizeof(TestRot)/sizeof(TestRot[0]); ++rot)
|
sl@0
|
644 |
{
|
sl@0
|
645 |
// DrawResource(const TPoint&, const RDirectGdiDrawableSource&, DirectGdi::TGraphicsRotation)
|
sl@0
|
646 |
iGc->DrawResource(pos, imageSource, TestRot[rot]);
|
sl@0
|
647 |
TESTL(iGc->GetError() == KErrBadHandle);
|
sl@0
|
648 |
|
sl@0
|
649 |
// DrawResource(const TRect&, const RDirectGdiDrawableSource&, DirectGdi::TGraphicsRotation)
|
sl@0
|
650 |
iGc->DrawResource(dstRect, imageSource, TestRot[rot]);
|
sl@0
|
651 |
TESTL(iGc->GetError() == KErrBadHandle);
|
sl@0
|
652 |
|
sl@0
|
653 |
// DrawResource(const TRectt&, const RDirectGdiDrawableSource&, const TRect&, DirectGdi::TGraphicsRotation)
|
sl@0
|
654 |
iGc->DrawResource(dstRect, imageSource, srcRect, TestRot[rot]);
|
sl@0
|
655 |
TESTL(iGc->GetError() == KErrBadHandle);
|
sl@0
|
656 |
}
|
sl@0
|
657 |
}
|
sl@0
|
658 |
|
sl@0
|
659 |
/**
|
sl@0
|
660 |
@SYMTestCaseID
|
sl@0
|
661 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0006
|
sl@0
|
662 |
|
sl@0
|
663 |
@SYMTestPriority
|
sl@0
|
664 |
Critical
|
sl@0
|
665 |
|
sl@0
|
666 |
@SYMPREQ
|
sl@0
|
667 |
PREQ39
|
sl@0
|
668 |
|
sl@0
|
669 |
@SYMREQ
|
sl@0
|
670 |
REQ9178
|
sl@0
|
671 |
REQ9200
|
sl@0
|
672 |
REQ9201
|
sl@0
|
673 |
REQ9202
|
sl@0
|
674 |
REQ9203
|
sl@0
|
675 |
REQ9222
|
sl@0
|
676 |
REQ9228
|
sl@0
|
677 |
REQ9223
|
sl@0
|
678 |
REQ9236
|
sl@0
|
679 |
REQ9237
|
sl@0
|
680 |
|
sl@0
|
681 |
@SYMTestStatus
|
sl@0
|
682 |
Implemented
|
sl@0
|
683 |
|
sl@0
|
684 |
@SYMTestCaseDesc
|
sl@0
|
685 |
Draw onto an RSgImage as a target, then convert to it a source and draw that
|
sl@0
|
686 |
as a resource.
|
sl@0
|
687 |
|
sl@0
|
688 |
@SYMTestActions
|
sl@0
|
689 |
Test the use case where we:
|
sl@0
|
690 |
Draw red, green and blue rectangles to a target.
|
sl@0
|
691 |
Create a source from the targets' bitmap.
|
sl@0
|
692 |
Clear the target.
|
sl@0
|
693 |
Draw the source to the target.
|
sl@0
|
694 |
|
sl@0
|
695 |
@SYMTestExpectedResults
|
sl@0
|
696 |
The three rectangles should have been appear when the source is copied to the target.
|
sl@0
|
697 |
*/
|
sl@0
|
698 |
void CTDirectGdiResource::TestDrawTargetAsSourceL()
|
sl@0
|
699 |
{
|
sl@0
|
700 |
_LIT(KTestName, "DrawResource_TestDrawTargetAsSource");
|
sl@0
|
701 |
if(!iRunningOomTests)
|
sl@0
|
702 |
{
|
sl@0
|
703 |
INFO_PRINTF1(KTestName);
|
sl@0
|
704 |
}
|
sl@0
|
705 |
|
sl@0
|
706 |
ResetGc();
|
sl@0
|
707 |
|
sl@0
|
708 |
// draw to the current target
|
sl@0
|
709 |
TRect rect(20,20,100,100);
|
sl@0
|
710 |
iGc->SetPenColor(TRgb(255,0,0));
|
sl@0
|
711 |
iGc->DrawRect(rect);
|
sl@0
|
712 |
iGc->SetPenColor(TRgb(0,255,0));
|
sl@0
|
713 |
rect.Move(20,20);
|
sl@0
|
714 |
iGc->DrawRect(rect);
|
sl@0
|
715 |
iGc->SetPenColor(TRgb(0,0,255));
|
sl@0
|
716 |
rect.Move(20,20);
|
sl@0
|
717 |
iGc->DrawRect(rect);
|
sl@0
|
718 |
TESTNOERROR(iGc->GetError());
|
sl@0
|
719 |
|
sl@0
|
720 |
// Only do the second part of the test if using DirectGdi. The resultant test bitmap should looks the
|
sl@0
|
721 |
// same when using DirectGdi as the one drawn using BitGdi that only uses the above calls.
|
sl@0
|
722 |
if (iUseDirectGdi)
|
sl@0
|
723 |
{
|
sl@0
|
724 |
iGdiTarget->Finish();
|
sl@0
|
725 |
TESTNOERROR(iGc->GetError());
|
sl@0
|
726 |
|
sl@0
|
727 |
// get the target bitmap
|
sl@0
|
728 |
CFbsBitmap* bitmap = iGdiTarget->GetTargetFbsBitmapL();
|
sl@0
|
729 |
TESTL(bitmap != NULL);
|
sl@0
|
730 |
|
sl@0
|
731 |
// Create an RSgImage using the target bitmap
|
sl@0
|
732 |
TSgImageInfo imageInfo;
|
sl@0
|
733 |
imageInfo.iSizeInPixels = bitmap->SizeInPixels();
|
sl@0
|
734 |
imageInfo.iPixelFormat = iTestParams.iTargetPixelFormat; // only call this test when the target and the source resource pixel format are the same
|
sl@0
|
735 |
imageInfo.iUsage = ESgUsageDirectGdiSource;
|
sl@0
|
736 |
RSgImage sgImage;
|
sl@0
|
737 |
TInt err = sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride());
|
sl@0
|
738 |
CleanupClosePushL(sgImage);
|
sl@0
|
739 |
TESTNOERRORL(err);
|
sl@0
|
740 |
|
sl@0
|
741 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
742 |
TESTL(dgdiDriver != NULL);
|
sl@0
|
743 |
|
sl@0
|
744 |
// Create a RDirectGdiDrawableSource from the RSgImage
|
sl@0
|
745 |
RDirectGdiDrawableSource dgdiImageSource(*dgdiDriver);
|
sl@0
|
746 |
err = dgdiImageSource.Create(sgImage);
|
sl@0
|
747 |
TESTNOERRORL(err);
|
sl@0
|
748 |
|
sl@0
|
749 |
iGc->Clear();
|
sl@0
|
750 |
|
sl@0
|
751 |
// Convert the image source and bitmap to TDrawableSourceAndEquivRotatedBmps so it can be
|
sl@0
|
752 |
// drawn using the BitGdi test code as well as the DirectGdi code
|
sl@0
|
753 |
TDrawableSourceAndEquivRotatedBmps imageSource;
|
sl@0
|
754 |
imageSource.iDrawableSrc = &dgdiImageSource;
|
sl@0
|
755 |
imageSource.iBmpRotNone = bitmap;
|
sl@0
|
756 |
|
sl@0
|
757 |
// Draw the RDirectGdiDrawableSource using CDirectGdiContext::DrawResource
|
sl@0
|
758 |
iGc->DrawResource(TPoint(0,0), imageSource);
|
sl@0
|
759 |
|
sl@0
|
760 |
dgdiImageSource.Close();
|
sl@0
|
761 |
CleanupStack::PopAndDestroy(1, &sgImage);
|
sl@0
|
762 |
}
|
sl@0
|
763 |
|
sl@0
|
764 |
// Output the target image to make sure it contains what was drawn onto the source
|
sl@0
|
765 |
TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
|
sl@0
|
766 |
}
|
sl@0
|
767 |
|
sl@0
|
768 |
/**
|
sl@0
|
769 |
@SYMTestCaseID
|
sl@0
|
770 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0007
|
sl@0
|
771 |
|
sl@0
|
772 |
@SYMTestPriority
|
sl@0
|
773 |
Critical
|
sl@0
|
774 |
|
sl@0
|
775 |
@SYMPREQ
|
sl@0
|
776 |
PREQ39
|
sl@0
|
777 |
|
sl@0
|
778 |
@SYMREQ
|
sl@0
|
779 |
REQ9178
|
sl@0
|
780 |
REQ9200
|
sl@0
|
781 |
REQ9201
|
sl@0
|
782 |
REQ9202
|
sl@0
|
783 |
REQ9203
|
sl@0
|
784 |
REQ9222
|
sl@0
|
785 |
REQ9228
|
sl@0
|
786 |
REQ9223
|
sl@0
|
787 |
REQ9236
|
sl@0
|
788 |
REQ9237
|
sl@0
|
789 |
|
sl@0
|
790 |
@SYMTestStatus
|
sl@0
|
791 |
Implemented
|
sl@0
|
792 |
|
sl@0
|
793 |
@SYMTestCaseDesc
|
sl@0
|
794 |
Create two CDirectGdiImageSource object from the same RSgImage
|
sl@0
|
795 |
|
sl@0
|
796 |
@SYMTestActions
|
sl@0
|
797 |
Test the use case where we:
|
sl@0
|
798 |
Create an RSgImage
|
sl@0
|
799 |
Create two CDirectGdiImageSource objects.
|
sl@0
|
800 |
The CDirectGdiImageSource objects should share the EGL image created from
|
sl@0
|
801 |
the RSgImage
|
sl@0
|
802 |
as only one EGL image can be created per RSgImage per process.
|
sl@0
|
803 |
If the EGL image sharing is not working an error will occur when creating the
|
sl@0
|
804 |
second CDirectGdiImageSource object.
|
sl@0
|
805 |
|
sl@0
|
806 |
@SYMTestExpectedResults
|
sl@0
|
807 |
This test does not output an image, it is just for testing that no errors or panics occur.
|
sl@0
|
808 |
*/
|
sl@0
|
809 |
void CTDirectGdiResource::TestShareEGLImageBetweenSourcesL()
|
sl@0
|
810 |
{
|
sl@0
|
811 |
_LIT(KTestName, "ShareEGLImageBetweenSources");
|
sl@0
|
812 |
if(!iRunningOomTests)
|
sl@0
|
813 |
{
|
sl@0
|
814 |
INFO_PRINTF1(KTestName);
|
sl@0
|
815 |
}
|
sl@0
|
816 |
|
sl@0
|
817 |
ResetGc();
|
sl@0
|
818 |
|
sl@0
|
819 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
820 |
TESTL(dgdiDriver != NULL);
|
sl@0
|
821 |
|
sl@0
|
822 |
// Create a CFbsBitmap
|
sl@0
|
823 |
TSize patternSize(90,50);
|
sl@0
|
824 |
TRect rect(0,0,90,50);
|
sl@0
|
825 |
CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourceResourcePixelFormat, patternSize);
|
sl@0
|
826 |
TESTL(NULL != bitmap);
|
sl@0
|
827 |
CleanupStack::PushL(bitmap);
|
sl@0
|
828 |
|
sl@0
|
829 |
// Create an RSgImage from the CFbsBitmap
|
sl@0
|
830 |
TSgImageInfo imageInfo;
|
sl@0
|
831 |
imageInfo.iSizeInPixels = patternSize;
|
sl@0
|
832 |
imageInfo.iPixelFormat = iTestParams.iSourceResourcePixelFormat;
|
sl@0
|
833 |
imageInfo.iUsage = ESgUsageDirectGdiSource;
|
sl@0
|
834 |
RSgImage sgImage;
|
sl@0
|
835 |
TInt res = sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride());
|
sl@0
|
836 |
TESTNOERRORL(res);
|
sl@0
|
837 |
CleanupClosePushL(sgImage);
|
sl@0
|
838 |
|
sl@0
|
839 |
// Create a RDirectGdiDrawableSource from the RSgImage
|
sl@0
|
840 |
RDirectGdiDrawableSource dgdiImageSource1(*dgdiDriver);
|
sl@0
|
841 |
res = dgdiImageSource1.Create(sgImage);
|
sl@0
|
842 |
TESTNOERRORL(res);
|
sl@0
|
843 |
CleanupClosePushL(dgdiImageSource1);
|
sl@0
|
844 |
|
sl@0
|
845 |
// Create a second RDirectGdiDrawableSource from the same RSgImage,
|
sl@0
|
846 |
// no error should occur here, the underlying EGL images created should be
|
sl@0
|
847 |
// shared between sources
|
sl@0
|
848 |
RDirectGdiDrawableSource dgdiImageSource2(*dgdiDriver);
|
sl@0
|
849 |
res = dgdiImageSource2.Create(sgImage);
|
sl@0
|
850 |
TESTNOERRORL(res);
|
sl@0
|
851 |
|
sl@0
|
852 |
dgdiImageSource1.Close();
|
sl@0
|
853 |
dgdiImageSource2.Close();
|
sl@0
|
854 |
CleanupStack::PopAndDestroy(3, bitmap);
|
sl@0
|
855 |
}
|
sl@0
|
856 |
|
sl@0
|
857 |
/**
|
sl@0
|
858 |
@SYMTestCaseID
|
sl@0
|
859 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0008
|
sl@0
|
860 |
|
sl@0
|
861 |
@SYMTestPriority
|
sl@0
|
862 |
Critical
|
sl@0
|
863 |
|
sl@0
|
864 |
@SYMPREQ
|
sl@0
|
865 |
PREQ39
|
sl@0
|
866 |
|
sl@0
|
867 |
@SYMREQ
|
sl@0
|
868 |
REQ9178
|
sl@0
|
869 |
REQ9200
|
sl@0
|
870 |
REQ9201
|
sl@0
|
871 |
REQ9202
|
sl@0
|
872 |
REQ9203
|
sl@0
|
873 |
REQ9222
|
sl@0
|
874 |
REQ9228
|
sl@0
|
875 |
REQ9223
|
sl@0
|
876 |
REQ9236
|
sl@0
|
877 |
REQ9237
|
sl@0
|
878 |
|
sl@0
|
879 |
@SYMTestStatus
|
sl@0
|
880 |
Implemented
|
sl@0
|
881 |
|
sl@0
|
882 |
@SYMTestCaseDesc
|
sl@0
|
883 |
Draw resource with valid resource but other invalid parameters
|
sl@0
|
884 |
|
sl@0
|
885 |
@SYMTestActions
|
sl@0
|
886 |
Draw valid RDirectGdiDrawableSource objects with invalid
|
sl@0
|
887 |
parameters. Test the following for each valid rotation:
|
sl@0
|
888 |
- drawing a resource where the source rectangle does not intersect the actual image extent
|
sl@0
|
889 |
- drawing a resource where the source rectangle is not fully contained by the image extent
|
sl@0
|
890 |
|
sl@0
|
891 |
|
sl@0
|
892 |
@SYMTestExpectedResults
|
sl@0
|
893 |
Driver returns KErrArgument for each attempt to draw resource with invalid parameters.
|
sl@0
|
894 |
*/
|
sl@0
|
895 |
void CTDirectGdiResource::TestDrawResource_InvalidParameterL()
|
sl@0
|
896 |
{
|
sl@0
|
897 |
_LIT(KTestName, "DrawResource_InvalidParameter");
|
sl@0
|
898 |
if(!iRunningOomTests)
|
sl@0
|
899 |
{
|
sl@0
|
900 |
INFO_PRINTF1(KTestName);
|
sl@0
|
901 |
}
|
sl@0
|
902 |
|
sl@0
|
903 |
ResetGc();
|
sl@0
|
904 |
|
sl@0
|
905 |
// destRect can be anything
|
sl@0
|
906 |
TPoint pos;
|
sl@0
|
907 |
TRect dstRect(pos, iImgSz);
|
sl@0
|
908 |
|
sl@0
|
909 |
// srcRect doesn't intersect image extent at all
|
sl@0
|
910 |
TRect srcRect1(TPoint(1000,1000), TSize(1,1));
|
sl@0
|
911 |
// srcRect is not fully contained within image extent
|
sl@0
|
912 |
TRect srcRect2(TPoint(10,10), TSize(1000,1000));
|
sl@0
|
913 |
TRect srcRect3(TPoint(-10,0), iImgSz);
|
sl@0
|
914 |
|
sl@0
|
915 |
for (TInt rot=0; rot<sizeof(TestRot)/sizeof(TestRot[0]); ++rot)
|
sl@0
|
916 |
{
|
sl@0
|
917 |
iGc->DrawResource(dstRect, iImgSrc, srcRect1, TestRot[rot]);
|
sl@0
|
918 |
TESTL(iGc->GetError() == KErrArgument);
|
sl@0
|
919 |
|
sl@0
|
920 |
iGc->DrawResource(dstRect, iImgSrc, srcRect2, TestRot[rot]);
|
sl@0
|
921 |
TESTL(iGc->GetError() == KErrArgument);
|
sl@0
|
922 |
|
sl@0
|
923 |
iGc->DrawResource(dstRect, iImgSrc, srcRect3, TestRot[rot]);
|
sl@0
|
924 |
TESTL(iGc->GetError() == KErrArgument);
|
sl@0
|
925 |
}
|
sl@0
|
926 |
}
|
sl@0
|
927 |
|
sl@0
|
928 |
/**
|
sl@0
|
929 |
@SYMTestCaseID
|
sl@0
|
930 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0009
|
sl@0
|
931 |
|
sl@0
|
932 |
@SYMTestPriority
|
sl@0
|
933 |
Critical
|
sl@0
|
934 |
|
sl@0
|
935 |
@SYMPREQ
|
sl@0
|
936 |
PREQ39
|
sl@0
|
937 |
|
sl@0
|
938 |
@SYMREQ
|
sl@0
|
939 |
REQ9178
|
sl@0
|
940 |
REQ9200
|
sl@0
|
941 |
REQ9201
|
sl@0
|
942 |
REQ9202
|
sl@0
|
943 |
REQ9203
|
sl@0
|
944 |
REQ9222
|
sl@0
|
945 |
REQ9228
|
sl@0
|
946 |
REQ9223
|
sl@0
|
947 |
REQ9236
|
sl@0
|
948 |
REQ9237
|
sl@0
|
949 |
|
sl@0
|
950 |
@SYMTestStatus
|
sl@0
|
951 |
Implemented
|
sl@0
|
952 |
|
sl@0
|
953 |
@SYMTestCaseDesc
|
sl@0
|
954 |
Draw resources with a non-zero origin set.
|
sl@0
|
955 |
|
sl@0
|
956 |
@SYMTestActions
|
sl@0
|
957 |
Set drawing context origin to various non-zero values and draw RDirectGdiDrawableSource
|
sl@0
|
958 |
objects using generic underlying DrawResource implementation that takes destination
|
sl@0
|
959 |
and source rectangle.
|
sl@0
|
960 |
|
sl@0
|
961 |
@SYMTestExpectedResults
|
sl@0
|
962 |
Resource drawn at the specified location relative to drawing context origin.
|
sl@0
|
963 |
*/
|
sl@0
|
964 |
void CTDirectGdiResource::TestDrawResource_NonZeroOriginL()
|
sl@0
|
965 |
{
|
sl@0
|
966 |
_LIT(KTestName, "DrawResource_NonZeroOrigin");
|
sl@0
|
967 |
if(!iRunningOomTests)
|
sl@0
|
968 |
{
|
sl@0
|
969 |
INFO_PRINTF1(KTestName);
|
sl@0
|
970 |
}
|
sl@0
|
971 |
|
sl@0
|
972 |
const TPoint origin[] =
|
sl@0
|
973 |
{
|
sl@0
|
974 |
TPoint(-100,-100),
|
sl@0
|
975 |
TPoint(100,-100),
|
sl@0
|
976 |
TPoint(100,0),
|
sl@0
|
977 |
TPoint(-100,100),
|
sl@0
|
978 |
TPoint(0,100),
|
sl@0
|
979 |
TPoint(100,100)
|
sl@0
|
980 |
};
|
sl@0
|
981 |
|
sl@0
|
982 |
for (TInt idx=0; idx<sizeof(origin)/sizeof(origin[0]); ++idx)
|
sl@0
|
983 |
{
|
sl@0
|
984 |
TBuf<KFileNameLength> tag;
|
sl@0
|
985 |
tag.Append(KTestName);
|
sl@0
|
986 |
tag.AppendNum(idx);
|
sl@0
|
987 |
|
sl@0
|
988 |
ResetGc();
|
sl@0
|
989 |
iGc->SetOrigin(origin[idx]);
|
sl@0
|
990 |
|
sl@0
|
991 |
TRect srcRect(TPoint(0,0), iImgSz);
|
sl@0
|
992 |
|
sl@0
|
993 |
DrawTestPattern1(TRect(0,0,100,100), &srcRect);
|
sl@0
|
994 |
DrawTestPattern2(TRect(100,0,200,100), &srcRect);
|
sl@0
|
995 |
DrawTestPattern3(TRect(0,100,100,200), &srcRect);
|
sl@0
|
996 |
DrawTestPattern1(TRect(100,100,150,150), &srcRect);
|
sl@0
|
997 |
DrawTestPattern2(TRect(150,100,200,150), &srcRect);
|
sl@0
|
998 |
DrawTestPattern3(TRect(100,150,200,200), &srcRect);
|
sl@0
|
999 |
|
sl@0
|
1000 |
SaveOutput(tag);
|
sl@0
|
1001 |
}
|
sl@0
|
1002 |
}
|
sl@0
|
1003 |
|
sl@0
|
1004 |
/**
|
sl@0
|
1005 |
@SYMTestCaseID
|
sl@0
|
1006 |
GRAPHICS-DIRECTGDI-DRAWRESOURCE-0010
|
sl@0
|
1007 |
|
sl@0
|
1008 |
@SYMTestPriority
|
sl@0
|
1009 |
Critical
|
sl@0
|
1010 |
|
sl@0
|
1011 |
@SYMPREQ
|
sl@0
|
1012 |
PREQ39
|
sl@0
|
1013 |
|
sl@0
|
1014 |
@SYMREQ
|
sl@0
|
1015 |
REQ9178
|
sl@0
|
1016 |
REQ9200
|
sl@0
|
1017 |
REQ9201
|
sl@0
|
1018 |
REQ9202
|
sl@0
|
1019 |
REQ9203
|
sl@0
|
1020 |
REQ9222
|
sl@0
|
1021 |
REQ9228
|
sl@0
|
1022 |
REQ9223
|
sl@0
|
1023 |
REQ9236
|
sl@0
|
1024 |
REQ9237
|
sl@0
|
1025 |
|
sl@0
|
1026 |
@SYMTestCaseDesc
|
sl@0
|
1027 |
Tests if DirectGDI methods returns an error when called on a not constructed RDirectGdiDrawableSource object.
|
sl@0
|
1028 |
|
sl@0
|
1029 |
@SYMTestActions
|
sl@0
|
1030 |
Create a CFbsBitmap.
|
sl@0
|
1031 |
Create an RSgImage from the CFbsBitmap.
|
sl@0
|
1032 |
Allocate a RDirectGdiDrawableSource but do not call Create() method.
|
sl@0
|
1033 |
Draw the RDirectGdiDrawableSource using CDirectGdiContext::DrawResource.
|
sl@0
|
1034 |
|
sl@0
|
1035 |
@SYMTestExpectedResults
|
sl@0
|
1036 |
CDirectGdiContext::DrawResource should return KErrBadHandle.
|
sl@0
|
1037 |
*/
|
sl@0
|
1038 |
void CTDirectGdiResource::TestDrawResourceSourceNotCreatedL()
|
sl@0
|
1039 |
{
|
sl@0
|
1040 |
_LIT(KTestName, "DrawResource_SourceNotCreated");
|
sl@0
|
1041 |
if(!iRunningOomTests)
|
sl@0
|
1042 |
{
|
sl@0
|
1043 |
INFO_PRINTF1(KTestName);
|
sl@0
|
1044 |
}
|
sl@0
|
1045 |
|
sl@0
|
1046 |
if (iUseDirectGdi)
|
sl@0
|
1047 |
{
|
sl@0
|
1048 |
ResetGc();
|
sl@0
|
1049 |
|
sl@0
|
1050 |
TInt res = CDirectGdiDriver::Open();
|
sl@0
|
1051 |
TESTNOERRORL(res);
|
sl@0
|
1052 |
|
sl@0
|
1053 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
1054 |
TESTL(dgdiDriver != NULL);
|
sl@0
|
1055 |
CleanupClosePushL(*dgdiDriver);
|
sl@0
|
1056 |
|
sl@0
|
1057 |
// Create a CFbsBitmap
|
sl@0
|
1058 |
TSize patternSize(90,50);
|
sl@0
|
1059 |
CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourceResourcePixelFormat, patternSize);
|
sl@0
|
1060 |
TESTL(NULL != bitmap);
|
sl@0
|
1061 |
CleanupStack::PushL(bitmap);
|
sl@0
|
1062 |
|
sl@0
|
1063 |
// Create an RSgImage from the CFbsBitmap
|
sl@0
|
1064 |
TSgImageInfo imageInfo;
|
sl@0
|
1065 |
imageInfo.iSizeInPixels = patternSize;
|
sl@0
|
1066 |
imageInfo.iPixelFormat = iTestParams.iSourceResourcePixelFormat;
|
sl@0
|
1067 |
imageInfo.iUsage = ESgUsageDirectGdiSource;
|
sl@0
|
1068 |
RSgImage sgImage;
|
sl@0
|
1069 |
res = sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride());
|
sl@0
|
1070 |
CleanupClosePushL(sgImage);
|
sl@0
|
1071 |
TESTNOERRORL(res);
|
sl@0
|
1072 |
|
sl@0
|
1073 |
//allocate RDirectGdiDrawableSource, but do not call Create() method
|
sl@0
|
1074 |
RDirectGdiDrawableSource dgdiImageSource(*dgdiDriver);
|
sl@0
|
1075 |
|
sl@0
|
1076 |
// Draw the RDirectGdiDrawableSource using CDirectGdiContext::DrawResource
|
sl@0
|
1077 |
TDrawableSourceAndEquivRotatedBmps imageSource;
|
sl@0
|
1078 |
imageSource.iDrawableSrc = &dgdiImageSource;
|
sl@0
|
1079 |
iGc->DrawResource(TPoint(10,10), imageSource);
|
sl@0
|
1080 |
TESTL(iGc->GetError() == KErrBadHandle);
|
sl@0
|
1081 |
dgdiImageSource.Close();
|
sl@0
|
1082 |
CleanupStack::PopAndDestroy(3, dgdiDriver);
|
sl@0
|
1083 |
}
|
sl@0
|
1084 |
}
|
sl@0
|
1085 |
|
sl@0
|
1086 |
/**
|
sl@0
|
1087 |
Override of base class pure virtual
|
sl@0
|
1088 |
Our implementation only gets called if the base class doTestStepPreambleL() did
|
sl@0
|
1089 |
not leave. That being the case, the current test result value will be EPass.
|
sl@0
|
1090 |
@leave Gets system wide error code
|
sl@0
|
1091 |
@return TVerdict code
|
sl@0
|
1092 |
*/
|
sl@0
|
1093 |
TVerdict CTDirectGdiResource::doTestStepL()
|
sl@0
|
1094 |
{
|
sl@0
|
1095 |
INFO_PRINTF1(_L("DirectGdi Resource Tests"));
|
sl@0
|
1096 |
|
sl@0
|
1097 |
// Test for each target pixel format
|
sl@0
|
1098 |
for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--)
|
sl@0
|
1099 |
{
|
sl@0
|
1100 |
iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex];
|
sl@0
|
1101 |
TBuf<KPixelFormatNameLength> targetPixelFormatName(TDisplayModeMapping::ConvertPixelFormatToPixelFormatString(iTestParams.iTargetPixelFormat));
|
sl@0
|
1102 |
// Test for each source pixel format
|
sl@0
|
1103 |
for (TInt sourceResourcePixelFormatIndex = iSourceResourcePixelFormatArray.Count() - 1; sourceResourcePixelFormatIndex >= 0; sourceResourcePixelFormatIndex--)
|
sl@0
|
1104 |
{
|
sl@0
|
1105 |
TBool doOOM = EFalse;
|
sl@0
|
1106 |
iTestParams.iSourceResourcePixelFormat = iSourceResourcePixelFormatArray[sourceResourcePixelFormatIndex];
|
sl@0
|
1107 |
if(EUidPixelFormatXRGB_8888 == iTestParams.iSourceResourcePixelFormat)
|
sl@0
|
1108 |
doOOM = ETrue;
|
sl@0
|
1109 |
TBuf<KPixelFormatNameLength> sourcePixelFormatName(TDisplayModeMapping::ConvertPixelFormatToPixelFormatString(iTestParams.iSourceResourcePixelFormat));
|
sl@0
|
1110 |
INFO_PRINTF3(_L("Target Pixel Format: %S; Source Resource Pixel Format: %S"), &targetPixelFormatName, &sourcePixelFormatName);
|
sl@0
|
1111 |
|
sl@0
|
1112 |
SetTargetL(iTestParams.iTargetPixelFormat);
|
sl@0
|
1113 |
CreateCommonResourceL();
|
sl@0
|
1114 |
|
sl@0
|
1115 |
RunTestsL();
|
sl@0
|
1116 |
|
sl@0
|
1117 |
// only run OOM tests for one target pixel format to prevent duplication of tests
|
sl@0
|
1118 |
if (targetPixelFormatIndex == 0 && doOOM)
|
sl@0
|
1119 |
{
|
sl@0
|
1120 |
RunOomTestsL(); // from base class
|
sl@0
|
1121 |
}
|
sl@0
|
1122 |
|
sl@0
|
1123 |
DestroyCommonResource();
|
sl@0
|
1124 |
}
|
sl@0
|
1125 |
}
|
sl@0
|
1126 |
CloseTMSGraphicsStep();
|
sl@0
|
1127 |
return TestStepResult();
|
sl@0
|
1128 |
}
|
sl@0
|
1129 |
|
sl@0
|
1130 |
/**
|
sl@0
|
1131 |
Helper function used to create the resources that are shared between all the tests in this file.
|
sl@0
|
1132 |
*/
|
sl@0
|
1133 |
void CTDirectGdiResource::CreateCommonResourceL()
|
sl@0
|
1134 |
{
|
sl@0
|
1135 |
// Create a CFbsBitmap
|
sl@0
|
1136 |
CFbsBitmap* bitmap;
|
sl@0
|
1137 |
RSgDrawable sgDwb;
|
sl@0
|
1138 |
|
sl@0
|
1139 |
// Generate tiled color pattern, test expects original image size to be 50x20 and has alpha values
|
sl@0
|
1140 |
TSize patternSize(50,20);
|
sl@0
|
1141 |
bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourceResourcePixelFormat, patternSize, TSize(10, 10), ETrue);
|
sl@0
|
1142 |
iImgSrc.iBmpRotNone = bitmap;
|
sl@0
|
1143 |
iImgSz = bitmap->SizeInPixels();
|
sl@0
|
1144 |
|
sl@0
|
1145 |
// Create rotated versions of the bitmap so they can be used when drawing BitGdi equivalent
|
sl@0
|
1146 |
// test images for the new DrawResource methods
|
sl@0
|
1147 |
iImgSrc.iBmpRot90 = new(ELeave) CFbsBitmap;
|
sl@0
|
1148 |
iImgSrc.iBmpRot180 = new(ELeave) CFbsBitmap;
|
sl@0
|
1149 |
iImgSrc.iBmpRot270 = new(ELeave) CFbsBitmap;
|
sl@0
|
1150 |
|
sl@0
|
1151 |
// Create an RSgImage from the CFbsBitmap
|
sl@0
|
1152 |
TSgImageInfo imageInfo;
|
sl@0
|
1153 |
imageInfo.iSizeInPixels = iImgSz;
|
sl@0
|
1154 |
imageInfo.iPixelFormat = iTestParams.iSourceResourcePixelFormat;
|
sl@0
|
1155 |
imageInfo.iUsage = ESgUsageDirectGdiSource;
|
sl@0
|
1156 |
|
sl@0
|
1157 |
RSgImage sgImage;
|
sl@0
|
1158 |
TInt res = sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride());
|
sl@0
|
1159 |
TESTNOERRORL(res);
|
sl@0
|
1160 |
CleanupClosePushL(sgImage);
|
sl@0
|
1161 |
|
sl@0
|
1162 |
if (iUseDirectGdi)
|
sl@0
|
1163 |
{
|
sl@0
|
1164 |
// Create a RDirectGdiDrawableSource from the RSgImage
|
sl@0
|
1165 |
|
sl@0
|
1166 |
// Driver must've been initialised by framework, no need to re-open
|
sl@0
|
1167 |
//
|
sl@0
|
1168 |
// Driver behaviour i.e. Sg::Open/Close, CDirectGdiDriver::Open/Close should be tested
|
sl@0
|
1169 |
// somewhere else not in details drawing ops test like this
|
sl@0
|
1170 |
CDirectGdiDriver* drv = CDirectGdiDriver::Static();
|
sl@0
|
1171 |
TEST(drv != NULL);
|
sl@0
|
1172 |
|
sl@0
|
1173 |
iImgSrc.iDrawableSrc = new RDirectGdiDrawableSource(*drv);
|
sl@0
|
1174 |
TEST(iImgSrc.iDrawableSrc != NULL);
|
sl@0
|
1175 |
res = iImgSrc.iDrawableSrc->Create(sgImage);
|
sl@0
|
1176 |
TESTNOERRORL(res);
|
sl@0
|
1177 |
|
sl@0
|
1178 |
// Create drawable source from drawable
|
sl@0
|
1179 |
res = sgDwb.Open(sgImage.Id());
|
sl@0
|
1180 |
TESTNOERRORL(res);
|
sl@0
|
1181 |
CleanupClosePushL(sgDwb);
|
sl@0
|
1182 |
|
sl@0
|
1183 |
iDwbSrc[0].iDrawableSrc = new RDirectGdiDrawableSource(*drv);
|
sl@0
|
1184 |
TEST(iDwbSrc[0].iDrawableSrc != NULL);
|
sl@0
|
1185 |
res = iDwbSrc[0].iDrawableSrc->Create(sgDwb);
|
sl@0
|
1186 |
TESTNOERRORL(res);
|
sl@0
|
1187 |
|
sl@0
|
1188 |
// Create drawable source from image
|
sl@0
|
1189 |
iDwbSrc[1].iDrawableSrc = new RDirectGdiDrawableSource(*drv);
|
sl@0
|
1190 |
TEST(iDwbSrc[1].iDrawableSrc != NULL);
|
sl@0
|
1191 |
res = iDwbSrc[1].iDrawableSrc->Create(sgImage);
|
sl@0
|
1192 |
TESTNOERRORL(res);
|
sl@0
|
1193 |
}
|
sl@0
|
1194 |
else
|
sl@0
|
1195 |
{
|
sl@0
|
1196 |
// Share the bitmaps from iImgSrc with this drawable for testing
|
sl@0
|
1197 |
iDwbSrc[0].iBmpRotNone = iImgSrc.iBmpRotNone;
|
sl@0
|
1198 |
iDwbSrc[0].iBmpRot90 = iImgSrc.iBmpRot90;
|
sl@0
|
1199 |
iDwbSrc[0].iBmpRot180 = iImgSrc.iBmpRot180;
|
sl@0
|
1200 |
iDwbSrc[0].iBmpRot270 = iImgSrc.iBmpRot270;
|
sl@0
|
1201 |
|
sl@0
|
1202 |
// Share the bitmaps from iImgSrc with this drawable for testing
|
sl@0
|
1203 |
iDwbSrc[1].iBmpRotNone = iImgSrc.iBmpRotNone;
|
sl@0
|
1204 |
iDwbSrc[1].iBmpRot90 = iImgSrc.iBmpRot90;
|
sl@0
|
1205 |
iDwbSrc[1].iBmpRot180 = iImgSrc.iBmpRot180;
|
sl@0
|
1206 |
iDwbSrc[1].iBmpRot270 = iImgSrc.iBmpRot270;
|
sl@0
|
1207 |
}
|
sl@0
|
1208 |
|
sl@0
|
1209 |
// Create horizontal and vertical stripe clipping region
|
sl@0
|
1210 |
TInt w = 1;
|
sl@0
|
1211 |
TBool on = EFalse;
|
sl@0
|
1212 |
for (TInt x=0; x<50; x+=w)
|
sl@0
|
1213 |
{
|
sl@0
|
1214 |
on = !on;
|
sl@0
|
1215 |
if (on && x+w<50)
|
sl@0
|
1216 |
{
|
sl@0
|
1217 |
TRect r1(TPoint(x,0), TSize(w, 200));
|
sl@0
|
1218 |
TRect r2(TPoint(100+x,0), TSize(w, 200));
|
sl@0
|
1219 |
iClip.AddRect(r1);
|
sl@0
|
1220 |
iClip.AddRect(r2);
|
sl@0
|
1221 |
}
|
sl@0
|
1222 |
++w;
|
sl@0
|
1223 |
}
|
sl@0
|
1224 |
TInt h = 1;
|
sl@0
|
1225 |
on = EFalse;
|
sl@0
|
1226 |
for (TInt y=0; y<200; y+=h)
|
sl@0
|
1227 |
{
|
sl@0
|
1228 |
on = !on;
|
sl@0
|
1229 |
if (on && y+h<200)
|
sl@0
|
1230 |
{
|
sl@0
|
1231 |
TRect r1(TPoint(0,y), TSize(100, h));
|
sl@0
|
1232 |
TRect r2(TPoint(100,y), TSize(100, h));
|
sl@0
|
1233 |
iClip.AddRect(r1);
|
sl@0
|
1234 |
iClip.AddRect(r2);
|
sl@0
|
1235 |
}
|
sl@0
|
1236 |
++h;
|
sl@0
|
1237 |
}
|
sl@0
|
1238 |
|
sl@0
|
1239 |
if (!iUseDirectGdi)
|
sl@0
|
1240 |
{
|
sl@0
|
1241 |
// We need to create 3 rotated copies of the bitmap we are drawing when testing using BitGdi
|
sl@0
|
1242 |
// using the CBitmapRotator active object, start rotating the first one here
|
sl@0
|
1243 |
iCurrentState = ERotatingBitmap90;
|
sl@0
|
1244 |
iBitmapRotator->Rotate(&iStatus, *bitmap, *(iImgSrc.iBmpRot90), CBitmapRotator::ERotation90DegreesClockwise);
|
sl@0
|
1245 |
SetActive();
|
sl@0
|
1246 |
CActiveScheduler::Start();
|
sl@0
|
1247 |
}
|
sl@0
|
1248 |
|
sl@0
|
1249 |
// Destroy bitmap, image and drawable.
|
sl@0
|
1250 |
CleanupStack::PopAndDestroy(iUseDirectGdi ? 2 : 1, &sgImage);
|
sl@0
|
1251 |
}
|
sl@0
|
1252 |
|
sl@0
|
1253 |
/**
|
sl@0
|
1254 |
Helper function used to destroy the resources that are shared between all the tests in this file.
|
sl@0
|
1255 |
*/
|
sl@0
|
1256 |
void CTDirectGdiResource::DestroyCommonResource()
|
sl@0
|
1257 |
{
|
sl@0
|
1258 |
if (iImgSrc.iDrawableSrc)
|
sl@0
|
1259 |
{
|
sl@0
|
1260 |
iImgSrc.iDrawableSrc->Close();
|
sl@0
|
1261 |
delete iImgSrc.iDrawableSrc;
|
sl@0
|
1262 |
iImgSrc.iDrawableSrc = NULL;
|
sl@0
|
1263 |
}
|
sl@0
|
1264 |
|
sl@0
|
1265 |
delete iImgSrc.iBmpRotNone;
|
sl@0
|
1266 |
iImgSrc.iBmpRotNone = NULL;
|
sl@0
|
1267 |
delete iImgSrc.iBmpRot90;
|
sl@0
|
1268 |
iImgSrc.iBmpRot90 = NULL;
|
sl@0
|
1269 |
delete iImgSrc.iBmpRot180;
|
sl@0
|
1270 |
iImgSrc.iBmpRot180 = NULL;
|
sl@0
|
1271 |
delete iImgSrc.iBmpRot270;
|
sl@0
|
1272 |
iImgSrc.iBmpRot270 = NULL;
|
sl@0
|
1273 |
|
sl@0
|
1274 |
for (TInt ii=0; ii<2; ++ii)
|
sl@0
|
1275 |
{
|
sl@0
|
1276 |
if (iDwbSrc[ii].iDrawableSrc)
|
sl@0
|
1277 |
{
|
sl@0
|
1278 |
iDwbSrc[ii].iDrawableSrc->Close();
|
sl@0
|
1279 |
delete iDwbSrc[ii].iDrawableSrc;
|
sl@0
|
1280 |
iDwbSrc[ii].iDrawableSrc = NULL;
|
sl@0
|
1281 |
}
|
sl@0
|
1282 |
|
sl@0
|
1283 |
iDwbSrc[ii].iBmpRotNone = NULL;
|
sl@0
|
1284 |
iDwbSrc[ii].iBmpRot90 = NULL;
|
sl@0
|
1285 |
iDwbSrc[ii].iBmpRot180 = NULL;
|
sl@0
|
1286 |
iDwbSrc[ii].iBmpRot270 = NULL;
|
sl@0
|
1287 |
}
|
sl@0
|
1288 |
|
sl@0
|
1289 |
iClip.Close();
|
sl@0
|
1290 |
}
|
sl@0
|
1291 |
|
sl@0
|
1292 |
/**
|
sl@0
|
1293 |
Override of base class virtual
|
sl@0
|
1294 |
@leave Gets system wide error code
|
sl@0
|
1295 |
@return - TVerdict code
|
sl@0
|
1296 |
*/
|
sl@0
|
1297 |
TVerdict CTDirectGdiResource::doTestStepPreambleL()
|
sl@0
|
1298 |
{
|
sl@0
|
1299 |
CTDirectGdiStepBase::doTestStepPreambleL();
|
sl@0
|
1300 |
CActiveScheduler::Add(this);
|
sl@0
|
1301 |
iBitmapRotator = CBitmapRotator::NewL();
|
sl@0
|
1302 |
return TestStepResult();
|
sl@0
|
1303 |
}
|
sl@0
|
1304 |
|
sl@0
|
1305 |
/**
|
sl@0
|
1306 |
Override of base class virtual
|
sl@0
|
1307 |
@leave Gets system wide error code
|
sl@0
|
1308 |
@return - TVerdict code
|
sl@0
|
1309 |
*/
|
sl@0
|
1310 |
TVerdict CTDirectGdiResource::doTestStepPostambleL()
|
sl@0
|
1311 |
{
|
sl@0
|
1312 |
delete iBitmapRotator;
|
sl@0
|
1313 |
iBitmapRotator = NULL;
|
sl@0
|
1314 |
CTDirectGdiStepBase::doTestStepPostambleL();
|
sl@0
|
1315 |
return TestStepResult();
|
sl@0
|
1316 |
}
|
sl@0
|
1317 |
|
sl@0
|
1318 |
void CTDirectGdiResource::DoDrawTestL()
|
sl@0
|
1319 |
{
|
sl@0
|
1320 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0001"));
|
sl@0
|
1321 |
TestDrawResource_ImageAsDrawableL();
|
sl@0
|
1322 |
RecordTestResultL();
|
sl@0
|
1323 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0002"));
|
sl@0
|
1324 |
TestDrawResource_PosL();
|
sl@0
|
1325 |
RecordTestResultL();
|
sl@0
|
1326 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0003"));
|
sl@0
|
1327 |
TestDrawResource_DestRectL();
|
sl@0
|
1328 |
RecordTestResultL();
|
sl@0
|
1329 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0004"));
|
sl@0
|
1330 |
TestDrawResource_DestRectSrcRectL();
|
sl@0
|
1331 |
RecordTestResultL();
|
sl@0
|
1332 |
}
|
sl@0
|
1333 |
|
sl@0
|
1334 |
/**
|
sl@0
|
1335 |
Override of base class pure virtual
|
sl@0
|
1336 |
Lists the tests to be run
|
sl@0
|
1337 |
*/
|
sl@0
|
1338 |
void CTDirectGdiResource::RunTestsL()
|
sl@0
|
1339 |
{
|
sl@0
|
1340 |
// For all combination of destination and source pixel format do the following tests
|
sl@0
|
1341 |
//
|
sl@0
|
1342 |
DoDrawTestL();
|
sl@0
|
1343 |
|
sl@0
|
1344 |
// Extra test using EDrawModeWriteAlpha. Geometry tests are irrelevant here, only contents tests are.
|
sl@0
|
1345 |
//
|
sl@0
|
1346 |
if (SourceResourceHasAlpha())
|
sl@0
|
1347 |
{
|
sl@0
|
1348 |
iUseWriteAlpha = ETrue;
|
sl@0
|
1349 |
DoDrawTestL();
|
sl@0
|
1350 |
iUseWriteAlpha = EFalse;
|
sl@0
|
1351 |
}
|
sl@0
|
1352 |
|
sl@0
|
1353 |
// Geometry and negative tests doesn't need repeating, do it once
|
sl@0
|
1354 |
//
|
sl@0
|
1355 |
if (OneTimeTestEnabled())
|
sl@0
|
1356 |
{
|
sl@0
|
1357 |
iEnableClipRegion = ETrue;
|
sl@0
|
1358 |
DoDrawTestL();
|
sl@0
|
1359 |
iEnableClipRegion = EFalse;
|
sl@0
|
1360 |
|
sl@0
|
1361 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0009"));
|
sl@0
|
1362 |
TestDrawResource_NonZeroOriginL();
|
sl@0
|
1363 |
RecordTestResultL();
|
sl@0
|
1364 |
if (iUseDirectGdi)
|
sl@0
|
1365 |
{
|
sl@0
|
1366 |
// These test for errors being set that are specific to DirectGdi and
|
sl@0
|
1367 |
// have no output so there is no need to run for BitGdi
|
sl@0
|
1368 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0005"));
|
sl@0
|
1369 |
TestDrawResource_NullHandleL();
|
sl@0
|
1370 |
RecordTestResultL();
|
sl@0
|
1371 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0008"));
|
sl@0
|
1372 |
TestDrawResource_InvalidParameterL();
|
sl@0
|
1373 |
RecordTestResultL();
|
sl@0
|
1374 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0010"));
|
sl@0
|
1375 |
TestDrawResourceSourceNotCreatedL();
|
sl@0
|
1376 |
RecordTestResultL();
|
sl@0
|
1377 |
}
|
sl@0
|
1378 |
}
|
sl@0
|
1379 |
|
sl@0
|
1380 |
// This test uses the target as a source, so only call it when the target
|
sl@0
|
1381 |
// pixel format is the same as the source resource pixel format
|
sl@0
|
1382 |
//
|
sl@0
|
1383 |
if (iTestParams.iTargetPixelFormat == iTestParams.iSourceResourcePixelFormat)
|
sl@0
|
1384 |
{
|
sl@0
|
1385 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0006"));
|
sl@0
|
1386 |
TestDrawTargetAsSourceL();
|
sl@0
|
1387 |
RecordTestResultL();
|
sl@0
|
1388 |
}
|
sl@0
|
1389 |
|
sl@0
|
1390 |
if (iUseDirectGdi)
|
sl@0
|
1391 |
{
|
sl@0
|
1392 |
// This test is only appropriate when using DirectGdi as it tests sharing of EGL images
|
sl@0
|
1393 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-DRAWRESOURCE-0007"));
|
sl@0
|
1394 |
TestShareEGLImageBetweenSourcesL();
|
sl@0
|
1395 |
RecordTestResultL();
|
sl@0
|
1396 |
}
|
sl@0
|
1397 |
}
|
sl@0
|
1398 |
|
sl@0
|
1399 |
/**
|
sl@0
|
1400 |
From CActive
|
sl@0
|
1401 |
*/
|
sl@0
|
1402 |
void CTDirectGdiResource::RunL()
|
sl@0
|
1403 |
{
|
sl@0
|
1404 |
switch (iCurrentState)
|
sl@0
|
1405 |
{
|
sl@0
|
1406 |
case ERotatingBitmap90:
|
sl@0
|
1407 |
// Rotate the next bitmap (180)
|
sl@0
|
1408 |
iCurrentState = ERotatingBitmap180;
|
sl@0
|
1409 |
iBitmapRotator->Rotate(&iStatus, *(iImgSrc.iBmpRotNone), *(iImgSrc.iBmpRot180), CBitmapRotator::ERotation180DegreesClockwise);
|
sl@0
|
1410 |
SetActive();
|
sl@0
|
1411 |
break;
|
sl@0
|
1412 |
|
sl@0
|
1413 |
case ERotatingBitmap180:
|
sl@0
|
1414 |
// Rotate the next bitmap (270)
|
sl@0
|
1415 |
iCurrentState = ERotatingBitmap270;
|
sl@0
|
1416 |
iBitmapRotator->Rotate(&iStatus, *(iImgSrc.iBmpRotNone), *(iImgSrc.iBmpRot270), CBitmapRotator::ERotation270DegreesClockwise);
|
sl@0
|
1417 |
SetActive();
|
sl@0
|
1418 |
break;
|
sl@0
|
1419 |
|
sl@0
|
1420 |
case ERotatingBitmap270:
|
sl@0
|
1421 |
// Finished rotating the bitmaps, run the tests now
|
sl@0
|
1422 |
iCurrentState = EDone;
|
sl@0
|
1423 |
CActiveScheduler::Stop();
|
sl@0
|
1424 |
break;
|
sl@0
|
1425 |
}
|
sl@0
|
1426 |
}
|
sl@0
|
1427 |
|
sl@0
|
1428 |
/**
|
sl@0
|
1429 |
From CActive
|
sl@0
|
1430 |
*/
|
sl@0
|
1431 |
void CTDirectGdiResource::DoCancel()
|
sl@0
|
1432 |
{
|
sl@0
|
1433 |
}
|