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 "tvgimagecache.h"
|
sl@0
|
17 |
#include <graphics/directgdiengine.h>
|
sl@0
|
18 |
|
sl@0
|
19 |
_LIT(KRomBitmap, "z:\\system\\data\\dgdi32bit.mbm");
|
sl@0
|
20 |
|
sl@0
|
21 |
CTVgImageCache::CTVgImageCache()
|
sl@0
|
22 |
{
|
sl@0
|
23 |
SetTestStepName(KTDirectGdiVgImageCacheStep);
|
sl@0
|
24 |
}
|
sl@0
|
25 |
|
sl@0
|
26 |
CTVgImageCache::~CTVgImageCache()
|
sl@0
|
27 |
{
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
/**
|
sl@0
|
31 |
@SYMTestCaseID
|
sl@0
|
32 |
GRAPHICS-DIRECTGDI-VGIMAGECACHE-0001
|
sl@0
|
33 |
|
sl@0
|
34 |
@SYMPREQ
|
sl@0
|
35 |
PREQ39
|
sl@0
|
36 |
|
sl@0
|
37 |
@SYMREQ
|
sl@0
|
38 |
REQ9195
|
sl@0
|
39 |
REQ9201
|
sl@0
|
40 |
REQ9202
|
sl@0
|
41 |
REQ9222
|
sl@0
|
42 |
REQ9223
|
sl@0
|
43 |
REQ9236
|
sl@0
|
44 |
REQ9237
|
sl@0
|
45 |
|
sl@0
|
46 |
@SYMTestCaseDesc
|
sl@0
|
47 |
Test entries are added to the cache.
|
sl@0
|
48 |
|
sl@0
|
49 |
@SYMTestStatus
|
sl@0
|
50 |
Implemented
|
sl@0
|
51 |
|
sl@0
|
52 |
@SYMTestPriority
|
sl@0
|
53 |
High
|
sl@0
|
54 |
|
sl@0
|
55 |
@SYMTestActions
|
sl@0
|
56 |
1. Create bitmaps and bitmap masks. Blit them so that they are stored in the cache.
|
sl@0
|
57 |
Check the VGImages created from the bitmaps are stored in the cache.
|
sl@0
|
58 |
2. Blit the bitmaps again in a different order.
|
sl@0
|
59 |
Check the order that the bitmaps are stored in the cache.
|
sl@0
|
60 |
|
sl@0
|
61 |
@SYMTestExpectedResults
|
sl@0
|
62 |
1. There are entries for each bitmap and bitmap mask.
|
sl@0
|
63 |
2. The bitmaps are stored in the cache in order of most-recently used to least-recently used.
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
void CTVgImageCache::TestAddEntriesL()
|
sl@0
|
66 |
{
|
sl@0
|
67 |
_LIT(KTestName, "Test Bitmaps Are Added To Cache");
|
sl@0
|
68 |
if(!iRunningOomTests)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
INFO_PRINTF1(KTestName);
|
sl@0
|
71 |
}
|
sl@0
|
72 |
CFbsBitmap* romBitmap = new(ELeave) CFbsBitmap;
|
sl@0
|
73 |
TInt err = romBitmap->Load(KRomBitmap);
|
sl@0
|
74 |
TESTNOERRORL(err);
|
sl@0
|
75 |
CleanupStack::PushL(romBitmap);
|
sl@0
|
76 |
|
sl@0
|
77 |
TSize bitmapSize(48,48);
|
sl@0
|
78 |
TRect bitmapRect(TPoint(0,0), bitmapSize);
|
sl@0
|
79 |
CFbsBitmap* bitmap1 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (20, 20));
|
sl@0
|
80 |
TESTL(bitmap1 != NULL);
|
sl@0
|
81 |
CleanupStack::PushL(bitmap1);
|
sl@0
|
82 |
CFbsBitmap* bitmap2 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (10, 10));
|
sl@0
|
83 |
TESTL(bitmap2 != NULL);
|
sl@0
|
84 |
CleanupStack::PushL(bitmap2);
|
sl@0
|
85 |
CFbsBitmap* bitmap3 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (8, 8));
|
sl@0
|
86 |
TESTL(bitmap3 != NULL);
|
sl@0
|
87 |
CleanupStack::PushL(bitmap3);
|
sl@0
|
88 |
CFbsBitmap* mask1 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (4, 4));
|
sl@0
|
89 |
TESTL(mask1 != NULL);
|
sl@0
|
90 |
CleanupStack::PushL(mask1);
|
sl@0
|
91 |
CFbsBitmap* mask2 = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (2, 2));
|
sl@0
|
92 |
TESTL(mask2 != NULL);
|
sl@0
|
93 |
CleanupStack::PushL(mask2);
|
sl@0
|
94 |
|
sl@0
|
95 |
ResetGc();
|
sl@0
|
96 |
CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache));
|
sl@0
|
97 |
|
sl@0
|
98 |
iGc->BitBlt(TPoint(0,0), *romBitmap);
|
sl@0
|
99 |
iGc->DrawBitmap(bitmapRect, *bitmap1);
|
sl@0
|
100 |
iGc->BitBltMasked(TPoint(0,0), *bitmap2, bitmapRect, *mask1, EFalse);
|
sl@0
|
101 |
iGc->DrawBitmapMasked(bitmapRect, *bitmap3, bitmapRect, *mask2, EFalse);
|
sl@0
|
102 |
|
sl@0
|
103 |
// Check bitmaps added
|
sl@0
|
104 |
TInt numEntries = iVgImageCache->NumEntries();
|
sl@0
|
105 |
TEST(numEntries == 6);
|
sl@0
|
106 |
// The following tests must leave if they fail,
|
sl@0
|
107 |
// otherwise a panic will occur in the ordered cache entry test
|
sl@0
|
108 |
TESTL(iVgImageCache->IsInCache(romBitmap->SerialNumber()));
|
sl@0
|
109 |
TESTL(iVgImageCache->IsInCache(bitmap1->SerialNumber()));
|
sl@0
|
110 |
TESTL(iVgImageCache->IsInCache(bitmap2->SerialNumber()));
|
sl@0
|
111 |
TESTL(iVgImageCache->IsInCache(bitmap3->SerialNumber()));
|
sl@0
|
112 |
TESTL(iVgImageCache->IsInCache(mask1->SerialNumber()));
|
sl@0
|
113 |
TESTL(iVgImageCache->IsInCache(mask2->SerialNumber()));
|
sl@0
|
114 |
|
sl@0
|
115 |
//Blit a few more times and check order of items in cache
|
sl@0
|
116 |
iGc->BitBlt(TPoint(0,0), *bitmap3);
|
sl@0
|
117 |
iGc->BitBlt(TPoint(0,0), *bitmap1);
|
sl@0
|
118 |
iGc->BitBlt(TPoint(0,0), *romBitmap);
|
sl@0
|
119 |
iGc->BitBlt(TPoint(0,0), *mask2);
|
sl@0
|
120 |
iGc->BitBlt(TPoint(0,0), *bitmap2);
|
sl@0
|
121 |
|
sl@0
|
122 |
// Expect the most recently used to be at the head of the list
|
sl@0
|
123 |
// i.e. bitmap2, mask2, romBitmap, bitmap1, bitmap3, mask1
|
sl@0
|
124 |
TInt64* serialNumList = new TInt64[numEntries];
|
sl@0
|
125 |
TESTL(serialNumList != NULL);
|
sl@0
|
126 |
iVgImageCache->GetOrderedCacheEntries(*serialNumList,numEntries);
|
sl@0
|
127 |
TEST(serialNumList[0] == bitmap2->SerialNumber());
|
sl@0
|
128 |
TEST(serialNumList[1] == mask2->SerialNumber());
|
sl@0
|
129 |
TEST(serialNumList[2] == romBitmap->SerialNumber());
|
sl@0
|
130 |
TEST(serialNumList[3] == bitmap1->SerialNumber());
|
sl@0
|
131 |
TEST(serialNumList[4] == bitmap3->SerialNumber());
|
sl@0
|
132 |
TEST(serialNumList[5] == mask1->SerialNumber());
|
sl@0
|
133 |
delete[] serialNumList;
|
sl@0
|
134 |
|
sl@0
|
135 |
CleanupStack::PopAndDestroy(7, romBitmap);
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
/**
|
sl@0
|
139 |
@SYMTestCaseID
|
sl@0
|
140 |
GRAPHICS-DIRECTGDI-VGIMAGECACHE-0002
|
sl@0
|
141 |
|
sl@0
|
142 |
@SYMPREQ
|
sl@0
|
143 |
PREQ39
|
sl@0
|
144 |
|
sl@0
|
145 |
@SYMREQ
|
sl@0
|
146 |
REQ9195
|
sl@0
|
147 |
REQ9201
|
sl@0
|
148 |
REQ9202
|
sl@0
|
149 |
REQ9222
|
sl@0
|
150 |
REQ9223
|
sl@0
|
151 |
REQ9236
|
sl@0
|
152 |
REQ9237
|
sl@0
|
153 |
|
sl@0
|
154 |
@SYMTestCaseDesc
|
sl@0
|
155 |
Test entries are added to the cache.
|
sl@0
|
156 |
|
sl@0
|
157 |
@SYMTestStatus
|
sl@0
|
158 |
Implemented
|
sl@0
|
159 |
|
sl@0
|
160 |
@SYMTestPriority
|
sl@0
|
161 |
High
|
sl@0
|
162 |
|
sl@0
|
163 |
@SYMTestActions
|
sl@0
|
164 |
Create a bitmap. Blit it so that it is stored in the cache.
|
sl@0
|
165 |
Check there is an entry for that bitmap in the cache.
|
sl@0
|
166 |
Resize the bitmap (so that the bitmap's touch count is increased).
|
sl@0
|
167 |
Blit the bitmap again.
|
sl@0
|
168 |
Check the value of the touch count stored in the cache.
|
sl@0
|
169 |
|
sl@0
|
170 |
@SYMTestExpectedResults
|
sl@0
|
171 |
Entry exists for bitmap and touch count value stored in cache
|
sl@0
|
172 |
is same as the bitmap after it was resized.
|
sl@0
|
173 |
|
sl@0
|
174 |
*/
|
sl@0
|
175 |
void CTVgImageCache::TestBitmapResizedL()
|
sl@0
|
176 |
{
|
sl@0
|
177 |
_LIT(KTestName, "Test That Images In Cache Are Updated When Associated Bitmap Is Resized");
|
sl@0
|
178 |
if(!iRunningOomTests)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
INFO_PRINTF1(KTestName);
|
sl@0
|
181 |
}
|
sl@0
|
182 |
TSize bitmapSize(48,48);
|
sl@0
|
183 |
CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (8, 8));
|
sl@0
|
184 |
TESTL(bitmap != NULL);
|
sl@0
|
185 |
|
sl@0
|
186 |
ResetGc();
|
sl@0
|
187 |
|
sl@0
|
188 |
iGc->BitBlt(TPoint(0,0), *bitmap);
|
sl@0
|
189 |
TInt64 serialNumber = bitmap->SerialNumber();
|
sl@0
|
190 |
// Check bitmaps added
|
sl@0
|
191 |
TEST(iVgImageCache->IsInCache(serialNumber));
|
sl@0
|
192 |
TInt oldTouchCount = iVgImageCache->TouchCount(serialNumber);
|
sl@0
|
193 |
TEST(oldTouchCount == bitmap->TouchCount());
|
sl@0
|
194 |
|
sl@0
|
195 |
//Resize bitmap
|
sl@0
|
196 |
TESTNOERROR(bitmap->Resize(TSize(80,24)));
|
sl@0
|
197 |
iGc->BitBlt(TPoint(0,0), *bitmap);
|
sl@0
|
198 |
TEST(iVgImageCache->TouchCount(serialNumber) != oldTouchCount);
|
sl@0
|
199 |
TEST(iVgImageCache->TouchCount(serialNumber) == bitmap->TouchCount());
|
sl@0
|
200 |
|
sl@0
|
201 |
delete bitmap;
|
sl@0
|
202 |
iVgImageCache->ResetCache();
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
|
sl@0
|
206 |
/**
|
sl@0
|
207 |
@SYMTestCaseID
|
sl@0
|
208 |
GRAPHICS-DIRECTGDI-VGIMAGECACHE-0003
|
sl@0
|
209 |
|
sl@0
|
210 |
@SYMPREQ
|
sl@0
|
211 |
PREQ39
|
sl@0
|
212 |
|
sl@0
|
213 |
@SYMREQ
|
sl@0
|
214 |
REQ9195
|
sl@0
|
215 |
REQ9201
|
sl@0
|
216 |
REQ9202
|
sl@0
|
217 |
REQ9222
|
sl@0
|
218 |
REQ9223
|
sl@0
|
219 |
REQ9236
|
sl@0
|
220 |
REQ9237
|
sl@0
|
221 |
|
sl@0
|
222 |
@SYMTestCaseDesc
|
sl@0
|
223 |
Test entries are added to the cache.
|
sl@0
|
224 |
|
sl@0
|
225 |
@SYMTestStatus
|
sl@0
|
226 |
Implemented
|
sl@0
|
227 |
|
sl@0
|
228 |
@SYMTestPriority
|
sl@0
|
229 |
High
|
sl@0
|
230 |
|
sl@0
|
231 |
@SYMTestActions
|
sl@0
|
232 |
Create a bitmap. Blit it so that it is stored in the cache.
|
sl@0
|
233 |
Check there is an entry for that bitmap in the cache.
|
sl@0
|
234 |
Swap the width and height of the bitmap (so that the bitmap's touch count is increased).
|
sl@0
|
235 |
Blit the bitmap again.
|
sl@0
|
236 |
Check the value of the touch count stored in the cache.
|
sl@0
|
237 |
|
sl@0
|
238 |
@SYMTestExpectedResults
|
sl@0
|
239 |
Entry exists for bitmap and touch count value stored in cache
|
sl@0
|
240 |
is same as the bitmap after its width and height were swapped.
|
sl@0
|
241 |
|
sl@0
|
242 |
*/
|
sl@0
|
243 |
void CTVgImageCache::TestBitmapSwapWidthAndHeightL()
|
sl@0
|
244 |
{
|
sl@0
|
245 |
_LIT(KTestName, "Test That Images In Cache Are Updated When Associated Bitmap Swaps Height and Width");
|
sl@0
|
246 |
if(!iRunningOomTests)
|
sl@0
|
247 |
{
|
sl@0
|
248 |
INFO_PRINTF1(KTestName);
|
sl@0
|
249 |
}
|
sl@0
|
250 |
TSize bitmapSize(40,60);
|
sl@0
|
251 |
CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (8, 8));
|
sl@0
|
252 |
TESTL(bitmap != NULL);
|
sl@0
|
253 |
|
sl@0
|
254 |
ResetGc();
|
sl@0
|
255 |
iVgImageCache->ResetCache();
|
sl@0
|
256 |
|
sl@0
|
257 |
iGc->BitBlt(TPoint(0,0), *bitmap);
|
sl@0
|
258 |
// Check bitmap is added to cache
|
sl@0
|
259 |
TEST(iVgImageCache->IsInCache(bitmap->SerialNumber()));
|
sl@0
|
260 |
TInt oldTouchCount = bitmap->TouchCount();
|
sl@0
|
261 |
TEST(oldTouchCount == iVgImageCache->TouchCount(bitmap->SerialNumber()));
|
sl@0
|
262 |
|
sl@0
|
263 |
// Swap width & height of bitmap within a Begin/End bounds
|
sl@0
|
264 |
// so that touch count increases
|
sl@0
|
265 |
TESTNOERROR(bitmap->SwapWidthAndHeight());
|
sl@0
|
266 |
TInt newTouchCount = bitmap->TouchCount();
|
sl@0
|
267 |
iGc->BitBlt(TPoint(0,0), *bitmap);
|
sl@0
|
268 |
// Check touch count is now different
|
sl@0
|
269 |
TEST(newTouchCount != oldTouchCount);
|
sl@0
|
270 |
// Expect cache to update entry for bitmap
|
sl@0
|
271 |
TEST(iVgImageCache->TouchCount(bitmap->SerialNumber()) == newTouchCount);
|
sl@0
|
272 |
|
sl@0
|
273 |
delete bitmap;
|
sl@0
|
274 |
iVgImageCache->ResetCache();
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
/**
|
sl@0
|
278 |
@SYMTestCaseID
|
sl@0
|
279 |
GRAPHICS-DIRECTGDI-VGIMAGECACHE-0004
|
sl@0
|
280 |
|
sl@0
|
281 |
@SYMPREQ
|
sl@0
|
282 |
PREQ39
|
sl@0
|
283 |
|
sl@0
|
284 |
@SYMREQ
|
sl@0
|
285 |
REQ9195
|
sl@0
|
286 |
REQ9201
|
sl@0
|
287 |
REQ9202
|
sl@0
|
288 |
REQ9222
|
sl@0
|
289 |
REQ9223
|
sl@0
|
290 |
REQ9236
|
sl@0
|
291 |
REQ9237
|
sl@0
|
292 |
|
sl@0
|
293 |
@SYMTestCaseDesc
|
sl@0
|
294 |
Test entries are not added to the cache for volatile bitmaps.
|
sl@0
|
295 |
|
sl@0
|
296 |
@SYMTestStatus
|
sl@0
|
297 |
Implemented
|
sl@0
|
298 |
|
sl@0
|
299 |
@SYMTestPriority
|
sl@0
|
300 |
High
|
sl@0
|
301 |
|
sl@0
|
302 |
@SYMTestActions
|
sl@0
|
303 |
Create Font Image Storage. In the cycle request Glyph Image entry for particular Glyph
|
sl@0
|
304 |
code and font ID.
|
sl@0
|
305 |
Delete Glyph Storage.
|
sl@0
|
306 |
|
sl@0
|
307 |
@SYMTestExpectedResults
|
sl@0
|
308 |
No entry exists for the bitmap in the cache.
|
sl@0
|
309 |
|
sl@0
|
310 |
*/
|
sl@0
|
311 |
void CTVgImageCache::TestVolatileBitmapL()
|
sl@0
|
312 |
{
|
sl@0
|
313 |
_LIT(KTestName, "Test That Volatile Bitmaps Are not Stored In Cache");
|
sl@0
|
314 |
if(!iRunningOomTests)
|
sl@0
|
315 |
{
|
sl@0
|
316 |
INFO_PRINTF1(KTestName);
|
sl@0
|
317 |
}
|
sl@0
|
318 |
TSize bitmapSize(40,60);
|
sl@0
|
319 |
CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, TSize (8, 8));
|
sl@0
|
320 |
TESTL(bitmap != NULL);
|
sl@0
|
321 |
|
sl@0
|
322 |
ResetGc();
|
sl@0
|
323 |
iVgImageCache->ResetCache();
|
sl@0
|
324 |
|
sl@0
|
325 |
// Make bitmap volatile
|
sl@0
|
326 |
bitmap->DataAddress();
|
sl@0
|
327 |
iGc->BitBlt(TPoint(0,0), *bitmap);
|
sl@0
|
328 |
// Check bitmap is added to cache
|
sl@0
|
329 |
TEST(!iVgImageCache->IsInCache(bitmap->SerialNumber()));
|
sl@0
|
330 |
|
sl@0
|
331 |
delete bitmap;
|
sl@0
|
332 |
iVgImageCache->ResetCache();
|
sl@0
|
333 |
}
|
sl@0
|
334 |
|
sl@0
|
335 |
/**
|
sl@0
|
336 |
@SYMTestCaseID
|
sl@0
|
337 |
GRAPHICS-DIRECTGDI-VGIMAGECACHE-0005
|
sl@0
|
338 |
|
sl@0
|
339 |
@SYMPREQ
|
sl@0
|
340 |
PREQ39
|
sl@0
|
341 |
|
sl@0
|
342 |
@SYMREQ
|
sl@0
|
343 |
REQ9195
|
sl@0
|
344 |
REQ9201
|
sl@0
|
345 |
REQ9202
|
sl@0
|
346 |
REQ9222
|
sl@0
|
347 |
REQ9223
|
sl@0
|
348 |
REQ9236
|
sl@0
|
349 |
REQ9237
|
sl@0
|
350 |
|
sl@0
|
351 |
@SYMTestCaseDesc
|
sl@0
|
352 |
Test least recently used entries are deleted when the cache is full and a new entry is added to the cache.
|
sl@0
|
353 |
|
sl@0
|
354 |
@SYMTestStatus
|
sl@0
|
355 |
Implemented
|
sl@0
|
356 |
|
sl@0
|
357 |
@SYMTestPriority
|
sl@0
|
358 |
High
|
sl@0
|
359 |
|
sl@0
|
360 |
@SYMTestActions
|
sl@0
|
361 |
Fill the cache up (by blitting many different bitmaps).
|
sl@0
|
362 |
Blit one more bitmap so that the cache has to delete an entry.
|
sl@0
|
363 |
Get the driver's MDirectGdiDriverCacheSize extension interface.
|
sl@0
|
364 |
Check that a new maximum cache size cannot be set that is smaller
|
sl@0
|
365 |
than the existing cache size.
|
sl@0
|
366 |
|
sl@0
|
367 |
@SYMTestExpectedResults
|
sl@0
|
368 |
An entry was deleted and that entry was the least recently used.
|
sl@0
|
369 |
A cache size cannot be set that is smaller than the existing cache size.
|
sl@0
|
370 |
*/
|
sl@0
|
371 |
void CTVgImageCache::TestFullCacheL()
|
sl@0
|
372 |
{
|
sl@0
|
373 |
_LIT(KTestName, "Test Adding Image to Cache when Cache is Full");
|
sl@0
|
374 |
if(!iRunningOomTests)
|
sl@0
|
375 |
{
|
sl@0
|
376 |
INFO_PRINTF1(KTestName);
|
sl@0
|
377 |
}
|
sl@0
|
378 |
|
sl@0
|
379 |
ResetGc();
|
sl@0
|
380 |
iVgImageCache->ResetCache();
|
sl@0
|
381 |
CleanupStack::PushL(TCleanupItem(ResetCache, iVgImageCache));
|
sl@0
|
382 |
TInt maxCacheSize = iVgImageCache->MaxCacheSize();
|
sl@0
|
383 |
|
sl@0
|
384 |
TSize bitmapSize(200,200);
|
sl@0
|
385 |
TInt dataStride = CFbsBitmap::ScanLineLength(bitmapSize.iWidth, TDisplayModeMapping::MapPixelFormatToDisplayMode(iTestParams.iSourcePixelFormat));
|
sl@0
|
386 |
TInt imageSizeInBytes = bitmapSize.iHeight * dataStride;
|
sl@0
|
387 |
TSize checksPerAxis(1,1);
|
sl@0
|
388 |
// Create the first bitmap to be added to the cache.
|
sl@0
|
389 |
// This is also be the bitmap to be removed from the cache when full.
|
sl@0
|
390 |
CFbsBitmap* firstBitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, checksPerAxis);
|
sl@0
|
391 |
TESTL(firstBitmap != NULL);
|
sl@0
|
392 |
CleanupStack::PushL(firstBitmap);
|
sl@0
|
393 |
iGc->BitBlt(TPoint(0,0), *firstBitmap);
|
sl@0
|
394 |
TEST(iVgImageCache->IsInCache(firstBitmap->SerialNumber()));
|
sl@0
|
395 |
|
sl@0
|
396 |
// Fill the cache up.
|
sl@0
|
397 |
while(imageSizeInBytes + iVgImageCache->CacheSizeInBytes() < maxCacheSize)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, checksPerAxis);
|
sl@0
|
400 |
TESTL(bitmap != NULL);
|
sl@0
|
401 |
iGc->BitBlt(TPoint(0,0), *bitmap);
|
sl@0
|
402 |
delete bitmap;
|
sl@0
|
403 |
}
|
sl@0
|
404 |
|
sl@0
|
405 |
// Add one more entry to the cache
|
sl@0
|
406 |
CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, bitmapSize, checksPerAxis);
|
sl@0
|
407 |
TESTL(bitmap != NULL);
|
sl@0
|
408 |
TEST(!iVgImageCache->IsInCache(bitmap->SerialNumber()));
|
sl@0
|
409 |
TEST(iVgImageCache->IsInCache(firstBitmap->SerialNumber()));
|
sl@0
|
410 |
iGc->BitBlt(TPoint(0,0), *bitmap);
|
sl@0
|
411 |
|
sl@0
|
412 |
// firstBitmap should now have been removed from the cache as it was the least recently used.
|
sl@0
|
413 |
TEST(!iVgImageCache->IsInCache(firstBitmap->SerialNumber()));
|
sl@0
|
414 |
// last bitmap should be in cache
|
sl@0
|
415 |
TEST(iVgImageCache->IsInCache(bitmap->SerialNumber()));
|
sl@0
|
416 |
|
sl@0
|
417 |
// get the driver's MDirectGdiDriverCacheSize extension interface and attempt
|
sl@0
|
418 |
// to set the maximum cache size to be smaller than the existing cache size
|
sl@0
|
419 |
CDirectGdiDriver* driver = CDirectGdiDriver::Static();
|
sl@0
|
420 |
TESTL(driver != NULL);
|
sl@0
|
421 |
MDirectGdiDriverCacheSize* driverCacheSize = NULL;
|
sl@0
|
422 |
TInt res = driver->GetInterface(TUid::Uid(KDirectGdiDriverCacheSizeUid), (TAny*&)driverCacheSize);
|
sl@0
|
423 |
TESTNOERRORL(res);
|
sl@0
|
424 |
// save the original cache size
|
sl@0
|
425 |
TInt originalCacheSize = driverCacheSize->MaxImageCacheSize();
|
sl@0
|
426 |
// setting the cache size to a size smaller than the existing cache should fail
|
sl@0
|
427 |
res = driverCacheSize->SetMaxImageCacheSize(iVgImageCache->CacheSizeInBytes()-1);
|
sl@0
|
428 |
TEST(res == KErrArgument);
|
sl@0
|
429 |
// setting the cache size to the same size as the existing cache should pass
|
sl@0
|
430 |
res = driverCacheSize->SetMaxImageCacheSize(iVgImageCache->CacheSizeInBytes());
|
sl@0
|
431 |
TESTNOERROR(res);
|
sl@0
|
432 |
TEST(iVgImageCache->CacheSizeInBytes() == driverCacheSize->MaxImageCacheSize());
|
sl@0
|
433 |
// reset the original driver cache size
|
sl@0
|
434 |
res = driverCacheSize->SetMaxImageCacheSize(originalCacheSize);
|
sl@0
|
435 |
TESTNOERROR(res);
|
sl@0
|
436 |
|
sl@0
|
437 |
delete bitmap;
|
sl@0
|
438 |
CleanupStack::PopAndDestroy(firstBitmap);
|
sl@0
|
439 |
CleanupStack::PopAndDestroy(iVgImageCache);
|
sl@0
|
440 |
}
|
sl@0
|
441 |
|
sl@0
|
442 |
/**
|
sl@0
|
443 |
@SYMTestCaseID
|
sl@0
|
444 |
GRAPHICS-DIRECTGDI-VGIMAGECACHE-0006
|
sl@0
|
445 |
|
sl@0
|
446 |
@SYMPREQ
|
sl@0
|
447 |
PREQ39
|
sl@0
|
448 |
|
sl@0
|
449 |
@SYMREQ
|
sl@0
|
450 |
REQ9195
|
sl@0
|
451 |
REQ9201
|
sl@0
|
452 |
REQ9202
|
sl@0
|
453 |
REQ9222
|
sl@0
|
454 |
REQ9223
|
sl@0
|
455 |
REQ9236
|
sl@0
|
456 |
REQ9237
|
sl@0
|
457 |
|
sl@0
|
458 |
@SYMTestCaseDesc
|
sl@0
|
459 |
Test adding a bitmap larger than maximum size of cache.
|
sl@0
|
460 |
|
sl@0
|
461 |
@SYMTestStatus
|
sl@0
|
462 |
Implemented
|
sl@0
|
463 |
|
sl@0
|
464 |
@SYMTestPriority
|
sl@0
|
465 |
High
|
sl@0
|
466 |
|
sl@0
|
467 |
@SYMTestActions.
|
sl@0
|
468 |
Blit a small bitmap which is added to the cache.
|
sl@0
|
469 |
Blit a bitmap whose size in pixels is more than the maximum size of the cache.
|
sl@0
|
470 |
|
sl@0
|
471 |
@SYMTestExpectedResults
|
sl@0
|
472 |
An entry for the large bitmap should not appear in the cache.
|
sl@0
|
473 |
An entry for the small bitmap should appear in the cache.
|
sl@0
|
474 |
|
sl@0
|
475 |
*/
|
sl@0
|
476 |
void CTVgImageCache::TestImageLargerThanCacheL()
|
sl@0
|
477 |
{
|
sl@0
|
478 |
_LIT(KTestName, "Test Adding Image Larger Than Cache");
|
sl@0
|
479 |
if(!iRunningOomTests)
|
sl@0
|
480 |
{
|
sl@0
|
481 |
INFO_PRINTF1(KTestName);
|
sl@0
|
482 |
}
|
sl@0
|
483 |
|
sl@0
|
484 |
ResetGc();
|
sl@0
|
485 |
iVgImageCache->ResetCache();
|
sl@0
|
486 |
TInt maxCacheSize = iVgImageCache->MaxCacheSize();
|
sl@0
|
487 |
|
sl@0
|
488 |
// Calculate height of bitmap whose width is 512 pixels so that the total size in bytes of the bitmap
|
sl@0
|
489 |
// is the same as the maximum cache size.
|
sl@0
|
490 |
TInt dataStride = CFbsBitmap::ScanLineLength(512, TDisplayModeMapping::MapPixelFormatToDisplayMode(iTestParams.iSourcePixelFormat));
|
sl@0
|
491 |
TInt largeBitmapHeight = maxCacheSize / dataStride;
|
sl@0
|
492 |
// Want bitmap with a larger size in bytes than cache,
|
sl@0
|
493 |
// so create a bitmap with width of 550 pixels and largeBitmapHeight
|
sl@0
|
494 |
TSize largeBitmapSize(550,largeBitmapHeight);
|
sl@0
|
495 |
|
sl@0
|
496 |
TSize smallBitmapSize(200,200);
|
sl@0
|
497 |
|
sl@0
|
498 |
TSize checksPerAxis(1,1);
|
sl@0
|
499 |
|
sl@0
|
500 |
// Create a small bitmap to be added to the cache.
|
sl@0
|
501 |
CFbsBitmap* smallBitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, smallBitmapSize, checksPerAxis);
|
sl@0
|
502 |
TESTL(smallBitmap != NULL);
|
sl@0
|
503 |
CleanupStack::PushL(smallBitmap);
|
sl@0
|
504 |
// Create large bitmap which is too large to fit in cache
|
sl@0
|
505 |
CFbsBitmap* largeBitmap = CreateCheckedBoardBitmapL(iTestParams.iSourcePixelFormat, largeBitmapSize, checksPerAxis);
|
sl@0
|
506 |
TESTL(largeBitmap != NULL);
|
sl@0
|
507 |
|
sl@0
|
508 |
// Add small bitmap to cache
|
sl@0
|
509 |
iGc->BitBlt(TPoint(0,0), *smallBitmap);
|
sl@0
|
510 |
TEST(iVgImageCache->IsInCache(smallBitmap->SerialNumber()));
|
sl@0
|
511 |
|
sl@0
|
512 |
// Blit large bitmap
|
sl@0
|
513 |
iGc->BitBlt(TPoint(0,0), *largeBitmap);
|
sl@0
|
514 |
TEST(!iVgImageCache->IsInCache(largeBitmap->SerialNumber()));
|
sl@0
|
515 |
TEST(iVgImageCache->IsInCache(smallBitmap->SerialNumber()));
|
sl@0
|
516 |
|
sl@0
|
517 |
delete largeBitmap;
|
sl@0
|
518 |
CleanupStack::PopAndDestroy(smallBitmap);
|
sl@0
|
519 |
iVgImageCache->ResetCache();
|
sl@0
|
520 |
}
|
sl@0
|
521 |
|
sl@0
|
522 |
/**
|
sl@0
|
523 |
Override of base class virtual
|
sl@0
|
524 |
@leave Gets system wide error code
|
sl@0
|
525 |
@return - TVerdict code
|
sl@0
|
526 |
*/
|
sl@0
|
527 |
TVerdict CTVgImageCache::doTestStepPreambleL()
|
sl@0
|
528 |
{
|
sl@0
|
529 |
CTDirectGdiStepBase::doTestStepPreambleL();
|
sl@0
|
530 |
return TestStepResult();
|
sl@0
|
531 |
}
|
sl@0
|
532 |
|
sl@0
|
533 |
/**
|
sl@0
|
534 |
Override of base class pure virtual
|
sl@0
|
535 |
Our implementation only gets called if the base class doTestStepPreambleL() did
|
sl@0
|
536 |
not leave. That being the case, the current test result value will be EPass.
|
sl@0
|
537 |
@leave Gets system wide error code
|
sl@0
|
538 |
@return TVerdict code
|
sl@0
|
539 |
*/
|
sl@0
|
540 |
TVerdict CTVgImageCache::doTestStepL()
|
sl@0
|
541 |
{
|
sl@0
|
542 |
if (iUseDirectGdi)
|
sl@0
|
543 |
{
|
sl@0
|
544 |
// Test independent of target pixel formats, so just use first.
|
sl@0
|
545 |
iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[0];
|
sl@0
|
546 |
// Test needs a VG compatible source pixel format.
|
sl@0
|
547 |
iTestParams.iSourcePixelFormat = EUidPixelFormatRGB_565;
|
sl@0
|
548 |
SetTargetL(iTestParams.iTargetPixelFormat);
|
sl@0
|
549 |
if (!iUseSwDirectGdi)
|
sl@0
|
550 |
{
|
sl@0
|
551 |
RunTestsL();
|
sl@0
|
552 |
RunOomTestsL();
|
sl@0
|
553 |
}
|
sl@0
|
554 |
else
|
sl@0
|
555 |
{
|
sl@0
|
556 |
INFO_PRINTF1(_L("SW DirectGDI has no image cache to test!"));
|
sl@0
|
557 |
}
|
sl@0
|
558 |
|
sl@0
|
559 |
}
|
sl@0
|
560 |
else
|
sl@0
|
561 |
{
|
sl@0
|
562 |
INFO_PRINTF1(_L("BitGDI has no image cache to test!"));
|
sl@0
|
563 |
}
|
sl@0
|
564 |
return TestStepResult();
|
sl@0
|
565 |
}
|
sl@0
|
566 |
|
sl@0
|
567 |
/**
|
sl@0
|
568 |
Override of base class pure virtual
|
sl@0
|
569 |
Lists the tests to be run
|
sl@0
|
570 |
*/
|
sl@0
|
571 |
void CTVgImageCache::RunTestsL()
|
sl@0
|
572 |
{
|
sl@0
|
573 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0001"));
|
sl@0
|
574 |
TestAddEntriesL();
|
sl@0
|
575 |
RecordTestResultL();
|
sl@0
|
576 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0005"));
|
sl@0
|
577 |
TestFullCacheL();
|
sl@0
|
578 |
RecordTestResultL();
|
sl@0
|
579 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0006"));
|
sl@0
|
580 |
TestImageLargerThanCacheL();
|
sl@0
|
581 |
RecordTestResultL();
|
sl@0
|
582 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0002"));
|
sl@0
|
583 |
TestBitmapResizedL();
|
sl@0
|
584 |
RecordTestResultL();
|
sl@0
|
585 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0003"));
|
sl@0
|
586 |
TestBitmapSwapWidthAndHeightL();
|
sl@0
|
587 |
RecordTestResultL();
|
sl@0
|
588 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-VGIMAGECACHE-0004"));
|
sl@0
|
589 |
TestVolatileBitmapL();
|
sl@0
|
590 |
RecordTestResultL();
|
sl@0
|
591 |
}
|