os/graphics/fbs/fontandbitmapserver/tfbs/tfbsglyphdata.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/tfbs/tfbsglyphdata.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,199 @@
     1.4 +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef TFBSGLYPHDATA_H
    1.20 +#define TFBSGLYPHDATA_H
    1.21 +
    1.22 +#include <EGL/eglext.h>
    1.23 +#include <VG/openvg.h>
    1.24 +#include <sgresource/sgresource.h>
    1.25 +#include "test/TGraphicsHarness.h"
    1.26 +class RSgImage;
    1.27 +class CEGLHelper;
    1.28 +
    1.29 +//#define SAVEGLYPHSTOMBMDURINGCOMPARISON // Enable saving of glyphs in the CompareSgImages()function
    1.30 +//#define SAVEGLYPHSTOMBMDEBUGFUNCTION //  Enable compilation of the member function SaveRSgImagesAsMbms(). Occasionally useful.
    1.31 +
    1.32 +typedef EGLBoolean (*TvgCreateEGLImageTargetKHRTypefPtr) (VGeglImageKHR image);
    1.33 +
    1.34 +/**
    1.35 +Multi-thread test enum.
    1.36 + */
    1.37 +enum EGlyphDataMultithreadTest
    1.38 +	{
    1.39 +	EGlyphDataMultiSessionTestShareGlyphs,
    1.40 +	EGlyphDataMultiSessionTestStressAtlas
    1.41 +	};
    1.42 +
    1.43 +/**
    1.44 +Struct passed to multi-thread test functions.
    1.45 + */
    1.46 +struct TGlyphDataMultithreadParams
    1.47 +	{
    1.48 +	TFontSpec iFontSpec;
    1.49 +	TUint* iGlyphCodes;
    1.50 +	TInt iGlyphCodesCount;
    1.51 +	CEGLHelper* iEGL;
    1.52 +	};
    1.53 +
    1.54 +/**
    1.55 +Struct used to define the mutlithreaded test to run when launching a new thread.
    1.56 + */
    1.57 +struct TGlyphDataThreadInfo
    1.58 +	{
    1.59 +	EGlyphDataMultithreadTest iTest;
    1.60 +	TGlyphDataMultithreadParams iParams;
    1.61 +	TInt iThreadNum;
    1.62 +	CTestStep* iStep;
    1.63 +	};
    1.64 +
    1.65 +
    1.66 +/**
    1.67 + *
    1.68 + * Class to provide a dummy font for test purposes
    1.69 + * See CTFbsGlyphData::TestGlyphDataIteratorNotSupportedFontL()
    1.70 + */
    1.71 +class CTestFont : public CFont
    1.72 +	{
    1.73 +public:
    1.74 +	TUid DoTypeUid() const {return TUid::Uid(12345);}
    1.75 +	TInt DoHeightInPixels() const {return 12;}
    1.76 +	TInt DoAscentInPixels() const {return 10;}
    1.77 +	TInt DoCharWidthInPixels(TChar /*aChar*/) const  {return 0;}
    1.78 +	TInt DoTextWidthInPixels(const TDesC& /*aText*/) const {return 0;}
    1.79 +	TInt DoBaselineOffsetInPixels() const {return 0;}
    1.80 +	TInt DoTextCount(const TDesC& /*aText*/,TInt /*aWidthInPixels*/) const {return 0;}
    1.81 +	TInt DoTextCount(const TDesC& /*aText*/,TInt /*aWidthInPixels*/,TInt& /*aExcessWidthInPixels*/) const {return 0;}
    1.82 +	TInt DoMaxCharWidthInPixels() const  {return 0;}
    1.83 +	TInt DoMaxNormalCharWidthInPixels() const  {return 0;}
    1.84 +	TFontSpec DoFontSpecInTwips() const  {return TFontSpec();}
    1.85 +	};
    1.86 +
    1.87 +/**
    1.88 +Created by each process/thread that needs to do RSgImage image comparison.
    1.89 +The class can be shared in a process between threads and handles synchronisation
    1.90 +with EGL itself.
    1.91 + */
    1.92 +class CEGLHelper : public CBase
    1.93 +	{
    1.94 +public:
    1.95 +	~CEGLHelper();
    1.96 +	static CEGLHelper* NewL();
    1.97 +		
    1.98 +	TInt GetSgImageData(const RSgImage& aSgImage, const TRect& aRect, TUint8*& aBuf);
    1.99 +	
   1.100 +private:
   1.101 +	CEGLHelper();
   1.102 +	void ConstructL();
   1.103 +
   1.104 +private:
   1.105 +	RMutex iMutex;
   1.106 +	RSgDriver iSgDriver;
   1.107 +	EGLDisplay iDisplay;
   1.108 +	EGLContext iContext;
   1.109 +	EGLSurface iSurface;
   1.110 +	// Function pointer for creation and destruction of EGLImages, and the creation
   1.111 +	// of VGImages from EGLImages.
   1.112 +	TvgCreateEGLImageTargetKHRTypefPtr vgCreateImageTargetKHR;
   1.113 +	PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
   1.114 +	PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
   1.115 +	};
   1.116 +
   1.117 +/**
   1.118 +Test class for the glyph data extensions RFbsGlyphDataIterator and 
   1.119 +RFbsGlyphMetricsArray. Positive and negative tests
   1.120 +*/
   1.121 +class CTFbsGlyphData : public CTGraphicsBase
   1.122 +	{
   1.123 +public:
   1.124 +	CTFbsGlyphData(CTestStep* aStep);
   1.125 +	~CTFbsGlyphData();
   1.126 +protected:
   1.127 +//from 	CTGraphicsBase
   1.128 +	virtual void RunTestCaseL(TInt aCurTestCase);
   1.129 +	void ConstructL();
   1.130 +	
   1.131 +private:
   1.132 +	// Test Cases
   1.133 +	void TestConsistencyWithGetCharacterData();
   1.134 +	void TestInvalidGlyphCode();
   1.135 +	void TestGlyphMetricsArrayParameters();
   1.136 +	void TestGlyphMetricsArrayReuse();
   1.137 +	void TestGlyphDataIteratorClose();
   1.138 +	void TestGlyphDataIteratorSequence();
   1.139 +	void TestGlyphDataIteratorMultipleUsesOnMultipleFonts();
   1.140 +	void TestGlyphDataIteratorImageValidity();
   1.141 +	void TestGlyphDataIteratorOpenInvalidCode();
   1.142 +	void TestGlyphDataIteratorOpenTwice();
   1.143 +	void TestGlyphDataIteratorOpenTwiceWithDifferentFonts();
   1.144 +	void TestGlyphDataIteratorOpenTooBigFont();
   1.145 +	void TestGlyphDataIteratorOpenWithWrongArgument();
   1.146 +	void TestGlyphDataIteratorImageMemoryLeak();
   1.147 +	void TestGlyphDataIteratorLargeFontStress();
   1.148 +	void TestGlyphDataIteratorManyFontsStressL();
   1.149 +	void TestGlyphDataIteratorNoGraphicsMemory();
   1.150 +	void TestGlyphDataIteratorNextIsAtomic();
   1.151 +	void TestGlyphDataIteratorManyArraySizes();
   1.152 +	void TestBitmapFontSupport();
   1.153 +	// White-Box Test Cases
   1.154 +	void TestGlyphDataIteratorSameGlyphCodes();
   1.155 +	void TestMultithreadShareSingleFont();
   1.156 +	void TestMultithreadStressAtlas();
   1.157 +	// Out-of-system-memory tests
   1.158 +	void TestGlyphMetricsArrayHeapOOML();
   1.159 +	void TestGlyphDataIteratorHeapOOML();
   1.160 +	// Multithread funtions
   1.161 +	static void ThreadShareGlyphsL(TInt aThreadNum, TGlyphDataMultithreadParams& aParam, CTestStep* aStep);
   1.162 +	static void ThreadStressAtlasL(TInt aThreadNum, TGlyphDataMultithreadParams& aParam, CTestStep* aStep);	
   1.163 +
   1.164 +	// Utility functions for the test cases.
   1.165 +	static TInt ThreadFunction(TAny* aParam); 
   1.166 +	TInt GetImageDataFromSgImage(const RSgImage& aSgImage, const TRect& aRect, TUint8*& aBuf);
   1.167 +	TUint32 CompareMetrics(const TOpenFontCharMetrics& aMetrics1, const TOpenFontCharMetrics& aMetrics2);
   1.168 +	static TInt CompareSgImages(CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, const RSgImage& aImageB, const TRect& aRectB, TBool& aMatch);
   1.169 +	static TInt CompareSgImages(CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, TUint8* aBufferA, const RSgImage& aImageB, const TRect& aRectB, TUint8* aBufferB, TBool& aMatch);
   1.170 +#ifdef SAVEGLYPHSTOMBMDEBUGFUNCTION
   1.171 +	void SaveRSgImagesAsMbms( CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, const RSgImage& aImageB, const TRect& aRectB );
   1.172 +#endif // SAVEGLYPHSTOMBMDEBUGFUNCTION
   1.173 +	void InfoPrintFontSpec(const CFont& aFont);
   1.174 +	void SetupEglL();
   1.175 +	
   1.176 +private:
   1.177 +	RFbsSession* iFbs;
   1.178 +	CFbsTypefaceStore* iTs;
   1.179 +	TUint* iGlyphCodesLatin;
   1.180 +	
   1.181 +	CFbsFont* iFont;
   1.182 +	CFbsFont* iFont2;
   1.183 +
   1.184 +	TUint8* iTempBuf1;
   1.185 +	TUint8* iTempBuf2;
   1.186 +	RSgDriver iSgDriver;
   1.187 +	CEGLHelper* iEGL;
   1.188 +	};
   1.189 +
   1.190 +
   1.191 +class CTFbsGlyphDataStep : public CTGraphicsStep
   1.192 +	{
   1.193 +public:
   1.194 +	CTFbsGlyphDataStep();
   1.195 +protected:	
   1.196 +	//from CTGraphicsStep
   1.197 +	virtual CTGraphicsBase* CreateTestL();
   1.198 +	};
   1.199 +
   1.200 +_LIT(KTFbsGlyphDataStep,"TFbsGlyphData");
   1.201 +
   1.202 +#endif /* TFBSGLYPHDATA_H */