First public contribution.
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef TFBSGLYPHDATA_H
17 #define TFBSGLYPHDATA_H
19 #include <EGL/eglext.h>
20 #include <VG/openvg.h>
21 #include <sgresource/sgresource.h>
22 #include "test/TGraphicsHarness.h"
26 //#define SAVEGLYPHSTOMBMDURINGCOMPARISON // Enable saving of glyphs in the CompareSgImages()function
27 //#define SAVEGLYPHSTOMBMDEBUGFUNCTION // Enable compilation of the member function SaveRSgImagesAsMbms(). Occasionally useful.
29 typedef EGLBoolean (*TvgCreateEGLImageTargetKHRTypefPtr) (VGeglImageKHR image);
32 Multi-thread test enum.
34 enum EGlyphDataMultithreadTest
36 EGlyphDataMultiSessionTestShareGlyphs,
37 EGlyphDataMultiSessionTestStressAtlas
41 Struct passed to multi-thread test functions.
43 struct TGlyphDataMultithreadParams
47 TInt iGlyphCodesCount;
52 Struct used to define the mutlithreaded test to run when launching a new thread.
54 struct TGlyphDataThreadInfo
56 EGlyphDataMultithreadTest iTest;
57 TGlyphDataMultithreadParams iParams;
65 * Class to provide a dummy font for test purposes
66 * See CTFbsGlyphData::TestGlyphDataIteratorNotSupportedFontL()
68 class CTestFont : public CFont
71 TUid DoTypeUid() const {return TUid::Uid(12345);}
72 TInt DoHeightInPixels() const {return 12;}
73 TInt DoAscentInPixels() const {return 10;}
74 TInt DoCharWidthInPixels(TChar /*aChar*/) const {return 0;}
75 TInt DoTextWidthInPixels(const TDesC& /*aText*/) const {return 0;}
76 TInt DoBaselineOffsetInPixels() const {return 0;}
77 TInt DoTextCount(const TDesC& /*aText*/,TInt /*aWidthInPixels*/) const {return 0;}
78 TInt DoTextCount(const TDesC& /*aText*/,TInt /*aWidthInPixels*/,TInt& /*aExcessWidthInPixels*/) const {return 0;}
79 TInt DoMaxCharWidthInPixels() const {return 0;}
80 TInt DoMaxNormalCharWidthInPixels() const {return 0;}
81 TFontSpec DoFontSpecInTwips() const {return TFontSpec();}
85 Created by each process/thread that needs to do RSgImage image comparison.
86 The class can be shared in a process between threads and handles synchronisation
89 class CEGLHelper : public CBase
93 static CEGLHelper* NewL();
95 TInt GetSgImageData(const RSgImage& aSgImage, const TRect& aRect, TUint8*& aBuf);
107 // Function pointer for creation and destruction of EGLImages, and the creation
108 // of VGImages from EGLImages.
109 TvgCreateEGLImageTargetKHRTypefPtr vgCreateImageTargetKHR;
110 PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
111 PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
115 Test class for the glyph data extensions RFbsGlyphDataIterator and
116 RFbsGlyphMetricsArray. Positive and negative tests
118 class CTFbsGlyphData : public CTGraphicsBase
121 CTFbsGlyphData(CTestStep* aStep);
124 //from CTGraphicsBase
125 virtual void RunTestCaseL(TInt aCurTestCase);
130 void TestConsistencyWithGetCharacterData();
131 void TestInvalidGlyphCode();
132 void TestGlyphMetricsArrayParameters();
133 void TestGlyphMetricsArrayReuse();
134 void TestGlyphDataIteratorClose();
135 void TestGlyphDataIteratorSequence();
136 void TestGlyphDataIteratorMultipleUsesOnMultipleFonts();
137 void TestGlyphDataIteratorImageValidity();
138 void TestGlyphDataIteratorOpenInvalidCode();
139 void TestGlyphDataIteratorOpenTwice();
140 void TestGlyphDataIteratorOpenTwiceWithDifferentFonts();
141 void TestGlyphDataIteratorOpenTooBigFont();
142 void TestGlyphDataIteratorOpenWithWrongArgument();
143 void TestGlyphDataIteratorImageMemoryLeak();
144 void TestGlyphDataIteratorLargeFontStress();
145 void TestGlyphDataIteratorManyFontsStressL();
146 void TestGlyphDataIteratorNoGraphicsMemory();
147 void TestGlyphDataIteratorNextIsAtomic();
148 void TestGlyphDataIteratorManyArraySizes();
149 void TestBitmapFontSupport();
150 // White-Box Test Cases
151 void TestGlyphDataIteratorSameGlyphCodes();
152 void TestMultithreadShareSingleFont();
153 void TestMultithreadStressAtlas();
154 // Out-of-system-memory tests
155 void TestGlyphMetricsArrayHeapOOML();
156 void TestGlyphDataIteratorHeapOOML();
157 // Multithread funtions
158 static void ThreadShareGlyphsL(TInt aThreadNum, TGlyphDataMultithreadParams& aParam, CTestStep* aStep);
159 static void ThreadStressAtlasL(TInt aThreadNum, TGlyphDataMultithreadParams& aParam, CTestStep* aStep);
161 // Utility functions for the test cases.
162 static TInt ThreadFunction(TAny* aParam);
163 TInt GetImageDataFromSgImage(const RSgImage& aSgImage, const TRect& aRect, TUint8*& aBuf);
164 TUint32 CompareMetrics(const TOpenFontCharMetrics& aMetrics1, const TOpenFontCharMetrics& aMetrics2);
165 static TInt CompareSgImages(CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, const RSgImage& aImageB, const TRect& aRectB, TBool& aMatch);
166 static TInt CompareSgImages(CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, TUint8* aBufferA, const RSgImage& aImageB, const TRect& aRectB, TUint8* aBufferB, TBool& aMatch);
167 #ifdef SAVEGLYPHSTOMBMDEBUGFUNCTION
168 void SaveRSgImagesAsMbms( CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, const RSgImage& aImageB, const TRect& aRectB );
169 #endif // SAVEGLYPHSTOMBMDEBUGFUNCTION
170 void InfoPrintFontSpec(const CFont& aFont);
175 CFbsTypefaceStore* iTs;
176 TUint* iGlyphCodesLatin;
188 class CTFbsGlyphDataStep : public CTGraphicsStep
191 CTFbsGlyphDataStep();
193 //from CTGraphicsStep
194 virtual CTGraphicsBase* CreateTestL();
197 _LIT(KTFbsGlyphDataStep,"TFbsGlyphData");
199 #endif /* TFBSGLYPHDATA_H */