sl@0
|
1 |
// Copyright (c) 2008-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 "trasterizer.h"
|
sl@0
|
17 |
#include "testutils.h"
|
sl@0
|
18 |
#include "examplerasterizer.h"
|
sl@0
|
19 |
#include <fbs.h>
|
sl@0
|
20 |
#include <gdi.h>
|
sl@0
|
21 |
#include <s32mem.h>
|
sl@0
|
22 |
#include <e32math.h>
|
sl@0
|
23 |
#include <e32svr.h>
|
sl@0
|
24 |
#include <u32hal.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
const TDisplayMode KDisplayModes[] = {EGray256, EColor64K, EColor16MU, EColor16MAP};
|
sl@0
|
27 |
const TInt KNumDisplayModes = sizeof(KDisplayModes)/sizeof(KDisplayModes[0]);
|
sl@0
|
28 |
const TRgb KStripeColours[3] = {TRgb(255,255,0), TRgb(255,0,255), TRgb(0,255,255)};
|
sl@0
|
29 |
|
sl@0
|
30 |
CTRasterizer::CTRasterizer()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
SetTestStepName(KTRasterizerStep);
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
/**
|
sl@0
|
36 |
@SYMTestCaseID
|
sl@0
|
37 |
GRAPHICS-FBSERV-RASTERIZER-001
|
sl@0
|
38 |
|
sl@0
|
39 |
@SYMTestPriority
|
sl@0
|
40 |
High
|
sl@0
|
41 |
|
sl@0
|
42 |
@SYMPREQ
|
sl@0
|
43 |
PREQ2096
|
sl@0
|
44 |
|
sl@0
|
45 |
@SYMREQ
|
sl@0
|
46 |
REQ10860
|
sl@0
|
47 |
REQ10861
|
sl@0
|
48 |
|
sl@0
|
49 |
@SYMTestCaseDesc
|
sl@0
|
50 |
Test that the example rasterizer dll "fbsrasterizer_test.dll" has been loaded.
|
sl@0
|
51 |
|
sl@0
|
52 |
@SYMTestActions
|
sl@0
|
53 |
On the emulator check that the rasterizer setting is "fbsrasterizer_test.dll".
|
sl@0
|
54 |
Get a pointer to the rasterizer.
|
sl@0
|
55 |
|
sl@0
|
56 |
@SYMTestExpectedResults
|
sl@0
|
57 |
"fbsrasterizer_test.dll" has been loaded successfully
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
void CTRasterizer::TestLoadRasterizerDllL()
|
sl@0
|
60 |
{
|
sl@0
|
61 |
INFO_PRINTF1(_L("TestLoadRasterizerDll"));
|
sl@0
|
62 |
#ifdef __WINS__
|
sl@0
|
63 |
_LIT8(KTestRasterizerName, "fbsrasterizer_test.dll");
|
sl@0
|
64 |
TUint8* rasterizerSetting = NULL;
|
sl@0
|
65 |
UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalStringProperty, (TAny*)"FBSRASTERIZER_DLL", &rasterizerSetting);
|
sl@0
|
66 |
TESTL(rasterizerSetting != NULL);
|
sl@0
|
67 |
TESTL(TPtrC8(rasterizerSetting).CompareF(KTestRasterizerName) == 0);
|
sl@0
|
68 |
#endif
|
sl@0
|
69 |
GetExampleRasterizerL();
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
/**
|
sl@0
|
73 |
@SYMTestCaseID
|
sl@0
|
74 |
GRAPHICS-FBSERV-RASTERIZER-002
|
sl@0
|
75 |
|
sl@0
|
76 |
@SYMTestPriority
|
sl@0
|
77 |
High
|
sl@0
|
78 |
|
sl@0
|
79 |
@SYMPREQ
|
sl@0
|
80 |
PREQ2096
|
sl@0
|
81 |
|
sl@0
|
82 |
@SYMREQ
|
sl@0
|
83 |
REQ10860
|
sl@0
|
84 |
REQ10861
|
sl@0
|
85 |
|
sl@0
|
86 |
@SYMTestCaseDesc
|
sl@0
|
87 |
Test that a scanline retrieved from the example rasterizer is what we expect.
|
sl@0
|
88 |
|
sl@0
|
89 |
@SYMTestActions
|
sl@0
|
90 |
Create an extended bitmap and set its extended data to three colours followed by a TUint8.
|
sl@0
|
91 |
The example rasterizer interprets this data as the three colours in a tricolour flag drawn
|
sl@0
|
92 |
with either horizontal or vertical stripes depending on the value of the TUint8.
|
sl@0
|
93 |
Draw a scanline of the extended bitmap by calling:
|
sl@0
|
94 |
- CFbsRasterizer::BeginBitmap()
|
sl@0
|
95 |
- CFbsRasterizer::ScanLine()
|
sl@0
|
96 |
- CFbsRasterizer::EndBitmap()
|
sl@0
|
97 |
|
sl@0
|
98 |
@SYMTestExpectedResults
|
sl@0
|
99 |
The scan line returned by the example rasterizer should be exactly the same as the
|
sl@0
|
100 |
corresponding scanline in the test data.
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
void CTRasterizer::TestScanLineL()
|
sl@0
|
103 |
{
|
sl@0
|
104 |
TBuf<32> displayModeDes(TestUtils::DisplayModeToString(iDisplayMode));
|
sl@0
|
105 |
INFO_PRINTF2(_L("TestScanLine, display mode %S"), &displayModeDes);
|
sl@0
|
106 |
|
sl@0
|
107 |
const TInt KNumBeginBitmapCalls = 5;
|
sl@0
|
108 |
|
sl@0
|
109 |
// Get the example rasterizer
|
sl@0
|
110 |
GetExampleRasterizerL();
|
sl@0
|
111 |
|
sl@0
|
112 |
// Test for both stripe styles, 0 for vertical stripes and 1 for horizontal stripes
|
sl@0
|
113 |
for (TInt stripeStyle = 0; stripeStyle < 2; stripeStyle++)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
if (stripeStyle == 0)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
INFO_PRINTF1(_L("... Vertical stripes"));
|
sl@0
|
118 |
}
|
sl@0
|
119 |
else
|
sl@0
|
120 |
{
|
sl@0
|
121 |
INFO_PRINTF1(_L("... Horizontal stripes"));
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
const TSize sizeInPixels(64,32);
|
sl@0
|
125 |
CFbsBitmap* extendedBitmap = CreateExtendedBitmapLC(KStripeColours, stripeStyle, sizeInPixels);
|
sl@0
|
126 |
|
sl@0
|
127 |
// Begin scanline access to the extended bitmap
|
sl@0
|
128 |
CFbsRasterizer::TBitmapDesc bitmapDesc;
|
sl@0
|
129 |
TInt64 bitmapId = extendedBitmap->SerialNumber();
|
sl@0
|
130 |
bitmapDesc.iSizeInPixels = sizeInPixels;
|
sl@0
|
131 |
bitmapDesc.iDispMode = iDisplayMode;
|
sl@0
|
132 |
bitmapDesc.iDataType = KUidExampleExtendedBitmap;
|
sl@0
|
133 |
bitmapDesc.iData = extendedBitmap->DataAddress();
|
sl@0
|
134 |
bitmapDesc.iDataSize = extendedBitmap->DataSize();
|
sl@0
|
135 |
extendedBitmap->BeginDataAccess();
|
sl@0
|
136 |
// test calling BeginBitmap more than once as each additional call should just increment as reference count
|
sl@0
|
137 |
for (TInt i = 0; i < KNumBeginBitmapCalls; i++)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
iRasterizer->BeginBitmap(bitmapId, bitmapDesc, NULL);
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
TInt scanlineLength;
|
sl@0
|
143 |
TPoint startPixel;
|
sl@0
|
144 |
TRgb bufferColour;
|
sl@0
|
145 |
// The width or height of a stripe in the tricolour flag that the extended bitmap rasterizer draws
|
sl@0
|
146 |
TInt stripeSize = (stripeStyle == 0) ? sizeInPixels.iWidth/3 : sizeInPixels.iHeight/3;
|
sl@0
|
147 |
for (TInt h = 0; h < sizeInPixels.iHeight; h++)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
// Get a full scanline from the extended bitmap using the rasterizer
|
sl@0
|
150 |
startPixel = TPoint(0, h);
|
sl@0
|
151 |
scanlineLength = sizeInPixels.iWidth;
|
sl@0
|
152 |
const TUint8* scanline = reinterpret_cast<const TUint8*>(iRasterizer->ScanLine(bitmapId, startPixel, scanlineLength));
|
sl@0
|
153 |
TESTL(scanline != NULL);
|
sl@0
|
154 |
|
sl@0
|
155 |
// Make sure each pixel in the scanline is the colour that we expect
|
sl@0
|
156 |
TRgb compareColour;
|
sl@0
|
157 |
|
sl@0
|
158 |
for (TInt w = 0; w < scanlineLength; w++)
|
sl@0
|
159 |
{
|
sl@0
|
160 |
if (((stripeStyle == 0) && (w < stripeSize))
|
sl@0
|
161 |
|| ((stripeStyle == 1) && (h < stripeSize)))
|
sl@0
|
162 |
{
|
sl@0
|
163 |
compareColour = KStripeColours[0]; // left or top
|
sl@0
|
164 |
}
|
sl@0
|
165 |
else if (((stripeStyle == 0) && (w >= sizeInPixels.iWidth-stripeSize))
|
sl@0
|
166 |
|| ((stripeStyle == 1) && (h >= sizeInPixels.iHeight-stripeSize)))
|
sl@0
|
167 |
{
|
sl@0
|
168 |
compareColour = KStripeColours[2]; // right or bottom
|
sl@0
|
169 |
}
|
sl@0
|
170 |
else
|
sl@0
|
171 |
{
|
sl@0
|
172 |
compareColour = KStripeColours[1]; // middle
|
sl@0
|
173 |
}
|
sl@0
|
174 |
bufferColour = ExtractRgb(scanline, w, iDisplayMode);
|
sl@0
|
175 |
if (((iDisplayMode != EGray256) && (bufferColour != compareColour))
|
sl@0
|
176 |
|| ((iDisplayMode == EGray256) && (bufferColour != TRgb::Gray256(compareColour.Gray256()))))
|
sl@0
|
177 |
{
|
sl@0
|
178 |
INFO_PRINTF3(_L("Pixel comparison failed for pixel %d,%d"), w, h);
|
sl@0
|
179 |
TEST(EFalse);
|
sl@0
|
180 |
}
|
sl@0
|
181 |
}
|
sl@0
|
182 |
}
|
sl@0
|
183 |
|
sl@0
|
184 |
// End scanline access to the extended bitmap
|
sl@0
|
185 |
for (TInt i = 0; i < KNumBeginBitmapCalls; i++)
|
sl@0
|
186 |
{
|
sl@0
|
187 |
iRasterizer->EndBitmap(bitmapId);
|
sl@0
|
188 |
}
|
sl@0
|
189 |
extendedBitmap->EndDataAccess();
|
sl@0
|
190 |
|
sl@0
|
191 |
// Clean up
|
sl@0
|
192 |
CleanupStack::Pop(1, extendedBitmap);
|
sl@0
|
193 |
}
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
/**
|
sl@0
|
197 |
@SYMTestCaseID
|
sl@0
|
198 |
GRAPHICS-FBSERV-RASTERIZER-003
|
sl@0
|
199 |
|
sl@0
|
200 |
@SYMTestPriority
|
sl@0
|
201 |
High
|
sl@0
|
202 |
|
sl@0
|
203 |
@SYMPREQ
|
sl@0
|
204 |
PREQ2096
|
sl@0
|
205 |
|
sl@0
|
206 |
@SYMREQ
|
sl@0
|
207 |
REQ10860
|
sl@0
|
208 |
REQ10861
|
sl@0
|
209 |
|
sl@0
|
210 |
@SYMTestCaseDesc
|
sl@0
|
211 |
Test that we can get scanlines from 3 extended bitmaps simultaneously using the example rasterizer.
|
sl@0
|
212 |
|
sl@0
|
213 |
@SYMTestActions
|
sl@0
|
214 |
Load a normal bitmap.
|
sl@0
|
215 |
Create 3 extended bitmaps and set their extended data to be vertically striped colours.
|
sl@0
|
216 |
Draw a scanline of each extended bitmap by calling:
|
sl@0
|
217 |
- CFbsRasterizer::BeginBitmap() for each extended bitmap
|
sl@0
|
218 |
- CFbsRasterizer::ScanLine() for each extended bitmap
|
sl@0
|
219 |
- CFbsRasterizer::EndBitmap() for each extended bitmap
|
sl@0
|
220 |
Compare the first pixel of each scanline and the last pixel of each scanline against the
|
sl@0
|
221 |
expected colour.
|
sl@0
|
222 |
|
sl@0
|
223 |
@SYMTestExpectedResults
|
sl@0
|
224 |
The rasterizer should be able to handle rasterizing up to 3 extended bitmaps at once,
|
sl@0
|
225 |
all three scanlines should be returned with no errors.
|
sl@0
|
226 |
The colours compared should match exactly.
|
sl@0
|
227 |
*/
|
sl@0
|
228 |
void CTRasterizer::TestMultipleScanLinesL()
|
sl@0
|
229 |
{
|
sl@0
|
230 |
TBuf<32> displayModeDes(TestUtils::DisplayModeToString(iDisplayMode));
|
sl@0
|
231 |
INFO_PRINTF2(_L("TestMultipleScanLines, vertical stripes, display mode %S"), &displayModeDes);
|
sl@0
|
232 |
|
sl@0
|
233 |
const TInt KNumBitmaps = 3;
|
sl@0
|
234 |
const TInt KBaseSize = 10;
|
sl@0
|
235 |
RArray<CFbsBitmap*> bitmaps;
|
sl@0
|
236 |
CleanupClosePushL(bitmaps);
|
sl@0
|
237 |
|
sl@0
|
238 |
// Get the example rasterizer
|
sl@0
|
239 |
GetExampleRasterizerL();
|
sl@0
|
240 |
|
sl@0
|
241 |
// Create the three differently sized extended bitmaps each coloured with vertical stripes
|
sl@0
|
242 |
for (TInt i = 0; i < KNumBitmaps; i++)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
const TSize KSizeInPixels = TSize(KBaseSize*(i+1), KBaseSize*(i+1));
|
sl@0
|
245 |
CFbsBitmap* extendedBitmap = CreateExtendedBitmapLC(KStripeColours, EFalse, KSizeInPixels);
|
sl@0
|
246 |
bitmaps.AppendL(extendedBitmap);
|
sl@0
|
247 |
}
|
sl@0
|
248 |
|
sl@0
|
249 |
// Begin scanline access to the extended bitmaps
|
sl@0
|
250 |
for (TInt i = 0; i < KNumBitmaps; i++)
|
sl@0
|
251 |
{
|
sl@0
|
252 |
bitmaps[i]->BeginDataAccess();
|
sl@0
|
253 |
|
sl@0
|
254 |
CFbsRasterizer::TBitmapDesc bitmapDesc;
|
sl@0
|
255 |
TInt64 bitmapId = bitmaps[i]->SerialNumber();
|
sl@0
|
256 |
bitmapDesc.iSizeInPixels = bitmaps[i]->SizeInPixels();
|
sl@0
|
257 |
bitmapDesc.iDispMode = iDisplayMode;
|
sl@0
|
258 |
bitmapDesc.iDataType = KUidExampleExtendedBitmap;
|
sl@0
|
259 |
bitmapDesc.iData = bitmaps[i]->DataAddress();
|
sl@0
|
260 |
bitmapDesc.iDataSize = bitmaps[i]->DataSize();
|
sl@0
|
261 |
iRasterizer->BeginBitmap(bitmapId, bitmapDesc, NULL);
|
sl@0
|
262 |
}
|
sl@0
|
263 |
|
sl@0
|
264 |
// Get scanlines from each extended bitmap and check that the first and last pixel in each is the correct colour
|
sl@0
|
265 |
for (TInt h = 0; h < KBaseSize; h++)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
for (TInt i = 0; i < KNumBitmaps; i++)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
const TUint8* scanline = reinterpret_cast<const TUint8*>(iRasterizer->ScanLine(bitmaps[i]->SerialNumber(), TPoint(0,h), KBaseSize*(i+1)));
|
sl@0
|
270 |
TESTL(scanline != NULL);
|
sl@0
|
271 |
|
sl@0
|
272 |
// Test that the first pixel is the correct colour (the first pixel in each scanline should be KStripeColours[0]
|
sl@0
|
273 |
// as the bitmaps should have all been drawn with vertical stripes with the first stripe being KStripeColours[0]
|
sl@0
|
274 |
TRgb bufferColour = ExtractRgb(scanline, 0, iDisplayMode);
|
sl@0
|
275 |
if (((iDisplayMode != EGray256) && (bufferColour != KStripeColours[0]))
|
sl@0
|
276 |
|| ((iDisplayMode == EGray256) && (bufferColour != TRgb::Gray256(KStripeColours[0].Gray256()))))
|
sl@0
|
277 |
{
|
sl@0
|
278 |
INFO_PRINTF3(_L("Pixel comparison failed for bitmap %d, pixel 0,%d"), i, h);
|
sl@0
|
279 |
TEST(EFalse);
|
sl@0
|
280 |
}
|
sl@0
|
281 |
// The last pixel should be KStripeColours[2]
|
sl@0
|
282 |
bufferColour = ExtractRgb(scanline, (KBaseSize*(i+1))-1, iDisplayMode);
|
sl@0
|
283 |
if (((iDisplayMode != EGray256) && (bufferColour != KStripeColours[2]))
|
sl@0
|
284 |
|| ((iDisplayMode == EGray256) && (bufferColour != TRgb::Gray256(KStripeColours[2].Gray256()))))
|
sl@0
|
285 |
{
|
sl@0
|
286 |
INFO_PRINTF4(_L("Pixel comparison failed for bitmap %d, pixel %d,%d"), i, (KBaseSize*(i+1))-1, h);
|
sl@0
|
287 |
TEST(EFalse);
|
sl@0
|
288 |
}
|
sl@0
|
289 |
}
|
sl@0
|
290 |
}
|
sl@0
|
291 |
|
sl@0
|
292 |
// Unregister each extended bitmap
|
sl@0
|
293 |
for (TInt i = 0; i < KNumBitmaps; i++)
|
sl@0
|
294 |
{
|
sl@0
|
295 |
iRasterizer->EndBitmap(bitmaps[i]->SerialNumber());
|
sl@0
|
296 |
bitmaps[i]->EndDataAccess();
|
sl@0
|
297 |
}
|
sl@0
|
298 |
|
sl@0
|
299 |
// Cleanup
|
sl@0
|
300 |
CleanupStack::PopAndDestroy(KNumBitmaps+1);
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
/**
|
sl@0
|
304 |
@SYMTestCaseID
|
sl@0
|
305 |
GRAPHICS-FBSERV-RASTERIZER-004
|
sl@0
|
306 |
|
sl@0
|
307 |
@SYMTestPriority
|
sl@0
|
308 |
High
|
sl@0
|
309 |
|
sl@0
|
310 |
@SYMPREQ
|
sl@0
|
311 |
PREQ2096
|
sl@0
|
312 |
|
sl@0
|
313 |
@SYMREQ
|
sl@0
|
314 |
REQ10860
|
sl@0
|
315 |
REQ10861
|
sl@0
|
316 |
|
sl@0
|
317 |
@SYMTestCaseDesc
|
sl@0
|
318 |
Test that the rasterizer returns portions of scanline correctly
|
sl@0
|
319 |
when a region of interest is specified.
|
sl@0
|
320 |
|
sl@0
|
321 |
@SYMTestActions
|
sl@0
|
322 |
Create an extended bitmap.
|
sl@0
|
323 |
Rasterize it specifying a region of interest that has three regions that roughly
|
sl@0
|
324 |
form a squared off C shape.
|
sl@0
|
325 |
|
sl@0
|
326 |
@SYMTestExpectedResults
|
sl@0
|
327 |
Check that scanlines returned are correct in the specified region of interest.
|
sl@0
|
328 |
(Anything outside the region of interest does not matter).
|
sl@0
|
329 |
*/
|
sl@0
|
330 |
void CTRasterizer::TestRegionOfInterestL()
|
sl@0
|
331 |
{
|
sl@0
|
332 |
TBuf<32> displayModeDes(TestUtils::DisplayModeToString(iDisplayMode));
|
sl@0
|
333 |
INFO_PRINTF2(_L("TestRegionOfInterest, horizontal stripes, display mode %S"), &displayModeDes);
|
sl@0
|
334 |
|
sl@0
|
335 |
// Get the example rasterizer
|
sl@0
|
336 |
GetExampleRasterizerL();
|
sl@0
|
337 |
|
sl@0
|
338 |
// Create an extended bitmap with horizontal stripes
|
sl@0
|
339 |
const TSize sizeInPixels(24,24);
|
sl@0
|
340 |
CFbsBitmap* extendedBitmap = CreateExtendedBitmapLC(KStripeColours, ETrue, sizeInPixels);
|
sl@0
|
341 |
|
sl@0
|
342 |
// Create a region of interest in the shape of a square with a hole in the middle
|
sl@0
|
343 |
TRegionFix<4> regionOfInterest;
|
sl@0
|
344 |
const TInt KStripeSize = sizeInPixels.iHeight/3;
|
sl@0
|
345 |
const TInt KEdgeOffset = 2;
|
sl@0
|
346 |
regionOfInterest.AddRect(TRect(TPoint(KEdgeOffset,KEdgeOffset), TSize(sizeInPixels.iWidth-(KEdgeOffset*2),KStripeSize))); // top of the square
|
sl@0
|
347 |
regionOfInterest.AddRect(TRect(TPoint(KEdgeOffset,sizeInPixels.iHeight-KEdgeOffset-KStripeSize), TSize(sizeInPixels.iWidth-(KEdgeOffset*2),KStripeSize))); // bottom of the square
|
sl@0
|
348 |
regionOfInterest.AddRect(TRect(TPoint(KEdgeOffset,KEdgeOffset+KStripeSize), TSize(KStripeSize,sizeInPixels.iHeight-(KEdgeOffset*2)-(KStripeSize*2)))); // left of the square
|
sl@0
|
349 |
regionOfInterest.AddRect(TRect(TPoint(sizeInPixels.iWidth-KEdgeOffset-KStripeSize,KEdgeOffset+KStripeSize), TSize(KStripeSize,sizeInPixels.iHeight-(KEdgeOffset*2)-(KStripeSize*2)))); // right of the square
|
sl@0
|
350 |
TEST(regionOfInterest.CheckError() == EFalse);
|
sl@0
|
351 |
|
sl@0
|
352 |
// Begin scanline access to the extended bitmap
|
sl@0
|
353 |
CFbsRasterizer::TBitmapDesc bitmapDesc;
|
sl@0
|
354 |
TInt64 bitmapId = extendedBitmap->SerialNumber();
|
sl@0
|
355 |
bitmapDesc.iSizeInPixels = sizeInPixels;
|
sl@0
|
356 |
bitmapDesc.iDispMode = iDisplayMode;
|
sl@0
|
357 |
bitmapDesc.iDataType = KUidExampleExtendedBitmap;
|
sl@0
|
358 |
bitmapDesc.iData = extendedBitmap->DataAddress();
|
sl@0
|
359 |
bitmapDesc.iDataSize = extendedBitmap->DataSize();
|
sl@0
|
360 |
extendedBitmap->BeginDataAccess();
|
sl@0
|
361 |
iRasterizer->BeginBitmap(bitmapId, bitmapDesc, ®ionOfInterest);
|
sl@0
|
362 |
|
sl@0
|
363 |
TInt scanlineLength;
|
sl@0
|
364 |
TPoint startPixel;
|
sl@0
|
365 |
TRgb bufferColour;
|
sl@0
|
366 |
|
sl@0
|
367 |
for (TInt h = 0; h < sizeInPixels.iHeight; h++)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
// Get scanlines from the extended bitmap using the rasterizer
|
sl@0
|
370 |
startPixel = TPoint(0, h);
|
sl@0
|
371 |
scanlineLength = sizeInPixels.iWidth;
|
sl@0
|
372 |
const TUint8* scanline = reinterpret_cast<const TUint8*>(iRasterizer->ScanLine(bitmapId, startPixel, scanlineLength));
|
sl@0
|
373 |
TESTL(scanline != NULL);
|
sl@0
|
374 |
|
sl@0
|
375 |
// Make sure each pixel in the scanline is the colour that we expect
|
sl@0
|
376 |
for (TInt w = 0; w < sizeInPixels.iWidth; w++)
|
sl@0
|
377 |
{
|
sl@0
|
378 |
bufferColour = ExtractRgb(scanline, w, iDisplayMode);
|
sl@0
|
379 |
|
sl@0
|
380 |
// Pixels that lie inside the region should be set to a flag stripe colour, pixels
|
sl@0
|
381 |
// outside of the region should be white
|
sl@0
|
382 |
if (regionOfInterest.Contains(TPoint(w,h)))
|
sl@0
|
383 |
{
|
sl@0
|
384 |
if (((iDisplayMode != EGray256) && (bufferColour != KStripeColours[h/KStripeSize]))
|
sl@0
|
385 |
|| ((iDisplayMode == EGray256) && (bufferColour != TRgb::Gray256(KStripeColours[h/KStripeSize].Gray256()))))
|
sl@0
|
386 |
{
|
sl@0
|
387 |
INFO_PRINTF3(_L("Pixel comparison failed for pixel %d,%d"), w, h);
|
sl@0
|
388 |
TEST(EFalse);
|
sl@0
|
389 |
}
|
sl@0
|
390 |
}
|
sl@0
|
391 |
else
|
sl@0
|
392 |
{
|
sl@0
|
393 |
if (bufferColour != KRgbWhite)
|
sl@0
|
394 |
{
|
sl@0
|
395 |
INFO_PRINTF3(_L("Pixel comparison failed for pixel %d,%d"), w, h);
|
sl@0
|
396 |
TEST(EFalse);
|
sl@0
|
397 |
}
|
sl@0
|
398 |
}
|
sl@0
|
399 |
}
|
sl@0
|
400 |
}
|
sl@0
|
401 |
|
sl@0
|
402 |
// End scanline access to the extended bitmap
|
sl@0
|
403 |
iRasterizer->EndBitmap(bitmapId);
|
sl@0
|
404 |
extendedBitmap->EndDataAccess();
|
sl@0
|
405 |
|
sl@0
|
406 |
// Clean up
|
sl@0
|
407 |
CleanupStack::Pop(1, extendedBitmap);
|
sl@0
|
408 |
}
|
sl@0
|
409 |
|
sl@0
|
410 |
/**
|
sl@0
|
411 |
Override of base class pure virtual
|
sl@0
|
412 |
Lists the tests to be run
|
sl@0
|
413 |
*/
|
sl@0
|
414 |
TVerdict CTRasterizer::doTestStepL()
|
sl@0
|
415 |
{
|
sl@0
|
416 |
TestLoadRasterizerDllL();
|
sl@0
|
417 |
|
sl@0
|
418 |
// Tests that require testing in multiple display modes
|
sl@0
|
419 |
for (TInt i = 0; i < KNumDisplayModes; i++)
|
sl@0
|
420 |
{
|
sl@0
|
421 |
iDisplayMode = KDisplayModes[i];
|
sl@0
|
422 |
|
sl@0
|
423 |
TestScanLineL();
|
sl@0
|
424 |
TestMultipleScanLinesL();
|
sl@0
|
425 |
TestRegionOfInterestL();
|
sl@0
|
426 |
}
|
sl@0
|
427 |
|
sl@0
|
428 |
return TestStepResult();
|
sl@0
|
429 |
}
|
sl@0
|
430 |
|
sl@0
|
431 |
/** Helper function for getting a TRgb colour value from a buffer given a pixel offset and
|
sl@0
|
432 |
a display mode.
|
sl@0
|
433 |
@param aBuffer A buffer to extract the TRgb from
|
sl@0
|
434 |
@param aPixelOffset The pixel position in the buffer to extract the TRgb from
|
sl@0
|
435 |
@param aDispMode The display mode of the buffer
|
sl@0
|
436 |
@return The TRgb value found at the pixel position specified
|
sl@0
|
437 |
*/
|
sl@0
|
438 |
TRgb CTRasterizer::ExtractRgb(const TUint8* aBuffer, TInt aPixelOffset, TDisplayMode aDispMode)
|
sl@0
|
439 |
{
|
sl@0
|
440 |
switch (aDispMode)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
case EGray2:
|
sl@0
|
443 |
{
|
sl@0
|
444 |
TUint8 byte = *(aBuffer + (aPixelOffset >> 3));
|
sl@0
|
445 |
if (byte & (1 << (aPixelOffset & 7)))
|
sl@0
|
446 |
return KRgbWhite;
|
sl@0
|
447 |
return KRgbBlack;
|
sl@0
|
448 |
}
|
sl@0
|
449 |
case EGray4:
|
sl@0
|
450 |
{
|
sl@0
|
451 |
TUint8 byte = *(aBuffer + (aPixelOffset >> 2));
|
sl@0
|
452 |
byte >>= ((aPixelOffset & 3) << 1);
|
sl@0
|
453 |
return TRgb::Gray4(byte & 3);
|
sl@0
|
454 |
}
|
sl@0
|
455 |
case EGray16:
|
sl@0
|
456 |
{
|
sl@0
|
457 |
TUint8 byte = *(aBuffer + (aPixelOffset >> 1));
|
sl@0
|
458 |
if (aPixelOffset & 1)
|
sl@0
|
459 |
byte >>= 4;
|
sl@0
|
460 |
return TRgb::Gray16(byte & 0xf);
|
sl@0
|
461 |
}
|
sl@0
|
462 |
case EGray256:
|
sl@0
|
463 |
return TRgb::Gray256(*(aBuffer + aPixelOffset));
|
sl@0
|
464 |
case EColor16:
|
sl@0
|
465 |
{
|
sl@0
|
466 |
TUint8 byte = *(aBuffer + (aPixelOffset >> 1));
|
sl@0
|
467 |
if (aPixelOffset & 1)
|
sl@0
|
468 |
byte >>= 4;
|
sl@0
|
469 |
return TRgb::Color16(byte & 0xf);
|
sl@0
|
470 |
}
|
sl@0
|
471 |
case EColor256:
|
sl@0
|
472 |
return TRgb::Color256(*(aBuffer + aPixelOffset));
|
sl@0
|
473 |
case EColor4K:
|
sl@0
|
474 |
{
|
sl@0
|
475 |
TUint16 doubleByte = *(((TUint16*)aBuffer) + aPixelOffset);
|
sl@0
|
476 |
return TRgb::Color4K(doubleByte & 0xfff);
|
sl@0
|
477 |
}
|
sl@0
|
478 |
case EColor64K:
|
sl@0
|
479 |
{
|
sl@0
|
480 |
TUint16 doubleByte = *(((TUint16*)aBuffer) + aPixelOffset);
|
sl@0
|
481 |
return TRgb::Color64K(doubleByte);
|
sl@0
|
482 |
}
|
sl@0
|
483 |
case EColor16M:
|
sl@0
|
484 |
{
|
sl@0
|
485 |
aBuffer += aPixelOffset * 3;
|
sl@0
|
486 |
TInt value = *aBuffer++;
|
sl@0
|
487 |
value |= *aBuffer++ << 8;
|
sl@0
|
488 |
value |= *aBuffer << 16;
|
sl@0
|
489 |
return TRgb::Color16M(value);
|
sl@0
|
490 |
}
|
sl@0
|
491 |
case ERgb:
|
sl@0
|
492 |
return *(((TRgb*)aBuffer) + aPixelOffset);
|
sl@0
|
493 |
case EColor16MU:
|
sl@0
|
494 |
{
|
sl@0
|
495 |
// Note this is | with 0xFF000000 to match the example rasterizer which sets
|
sl@0
|
496 |
// the alpha to 0xFF when drawing using EColor16MU
|
sl@0
|
497 |
return TRgb::Color16MU((*(((TUint32*)aBuffer) + aPixelOffset)) | 0xFF000000);
|
sl@0
|
498 |
}
|
sl@0
|
499 |
case EColor16MA:
|
sl@0
|
500 |
{
|
sl@0
|
501 |
return TRgb::Color16MA(*(((TUint32*)aBuffer) + aPixelOffset));
|
sl@0
|
502 |
}
|
sl@0
|
503 |
case EColor16MAP:
|
sl@0
|
504 |
{
|
sl@0
|
505 |
return TRgb::_Color16MAP(*(((TUint32*)aBuffer) + aPixelOffset));
|
sl@0
|
506 |
}
|
sl@0
|
507 |
default:
|
sl@0
|
508 |
break;
|
sl@0
|
509 |
};
|
sl@0
|
510 |
return KRgbBlack;
|
sl@0
|
511 |
}
|
sl@0
|
512 |
|
sl@0
|
513 |
/** Helper function for creating an extended bitmap.
|
sl@0
|
514 |
@param aColours A pointer to an array of three colours to use when creating the extended bitmap,
|
sl@0
|
515 |
these colours define the colours used when drawing the stripes in the extended bitmap.
|
sl@0
|
516 |
@param aHorizontalStripe ETrue for horizontal stripes, EFalse for vertical stripes.
|
sl@0
|
517 |
@param aSizeInPixels The size of the extended bitmap to create.
|
sl@0
|
518 |
@return A pointer to a newly created extended bitmap that has been pushed on to the cleanup stack.
|
sl@0
|
519 |
*/
|
sl@0
|
520 |
CFbsBitmap* CTRasterizer::CreateExtendedBitmapLC(const TRgb* aColours, TBool aHorizontalStripe, TSize aSizeInPixels)
|
sl@0
|
521 |
{
|
sl@0
|
522 |
// Set up the buffer containing the three TRgb values and one TUint8 value that the rasterizer expects
|
sl@0
|
523 |
TInt dataSize = (sizeof(TRgb)*3) + sizeof(TUint8); // estimate the size to be written
|
sl@0
|
524 |
TUint8* data = new (ELeave)TUint8[dataSize];
|
sl@0
|
525 |
CleanupArrayDeletePushL(data);
|
sl@0
|
526 |
RMemWriteStream writeStream;
|
sl@0
|
527 |
writeStream.Open(data, dataSize);
|
sl@0
|
528 |
CleanupClosePushL(writeStream);
|
sl@0
|
529 |
writeStream << aColours[0];
|
sl@0
|
530 |
writeStream << aColours[1];
|
sl@0
|
531 |
writeStream << aColours[2];
|
sl@0
|
532 |
TUint8 stripe = aHorizontalStripe; // EFalse is vertical stripes, ETrue is horizontal stripes
|
sl@0
|
533 |
writeStream << stripe;
|
sl@0
|
534 |
dataSize = writeStream.Sink()->TellL(MStreamBuf::EWrite).Offset(); // get the actual size written
|
sl@0
|
535 |
CleanupStack::PopAndDestroy(&writeStream);
|
sl@0
|
536 |
|
sl@0
|
537 |
CFbsBitmap* extendedBitmap = new(ELeave) CFbsBitmap;
|
sl@0
|
538 |
|
sl@0
|
539 |
TInt err = extendedBitmap->CreateExtendedBitmap(aSizeInPixels,
|
sl@0
|
540 |
iDisplayMode,
|
sl@0
|
541 |
KUidExampleExtendedBitmap,
|
sl@0
|
542 |
data,
|
sl@0
|
543 |
dataSize);
|
sl@0
|
544 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
545 |
CleanupStack::PushL(extendedBitmap);
|
sl@0
|
546 |
TESTL(err == KErrNone);
|
sl@0
|
547 |
|
sl@0
|
548 |
return extendedBitmap;
|
sl@0
|
549 |
}
|