os/graphics/fbs/fontandbitmapserver/tfbs/tfbsglyphdata.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2009-2010 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
#ifndef TFBSGLYPHDATA_H
sl@0
    17
#define TFBSGLYPHDATA_H
sl@0
    18
sl@0
    19
#include <EGL/eglext.h>
sl@0
    20
#include <VG/openvg.h>
sl@0
    21
#include <sgresource/sgresource.h>
sl@0
    22
#include "test/TGraphicsHarness.h"
sl@0
    23
class RSgImage;
sl@0
    24
class CEGLHelper;
sl@0
    25
sl@0
    26
//#define SAVEGLYPHSTOMBMDURINGCOMPARISON // Enable saving of glyphs in the CompareSgImages()function
sl@0
    27
//#define SAVEGLYPHSTOMBMDEBUGFUNCTION //  Enable compilation of the member function SaveRSgImagesAsMbms(). Occasionally useful.
sl@0
    28
sl@0
    29
typedef EGLBoolean (*TvgCreateEGLImageTargetKHRTypefPtr) (VGeglImageKHR image);
sl@0
    30
sl@0
    31
/**
sl@0
    32
Multi-thread test enum.
sl@0
    33
 */
sl@0
    34
enum EGlyphDataMultithreadTest
sl@0
    35
	{
sl@0
    36
	EGlyphDataMultiSessionTestShareGlyphs,
sl@0
    37
	EGlyphDataMultiSessionTestStressAtlas
sl@0
    38
	};
sl@0
    39
sl@0
    40
/**
sl@0
    41
Struct passed to multi-thread test functions.
sl@0
    42
 */
sl@0
    43
struct TGlyphDataMultithreadParams
sl@0
    44
	{
sl@0
    45
	TFontSpec iFontSpec;
sl@0
    46
	TUint* iGlyphCodes;
sl@0
    47
	TInt iGlyphCodesCount;
sl@0
    48
	CEGLHelper* iEGL;
sl@0
    49
	};
sl@0
    50
sl@0
    51
/**
sl@0
    52
Struct used to define the mutlithreaded test to run when launching a new thread.
sl@0
    53
 */
sl@0
    54
struct TGlyphDataThreadInfo
sl@0
    55
	{
sl@0
    56
	EGlyphDataMultithreadTest iTest;
sl@0
    57
	TGlyphDataMultithreadParams iParams;
sl@0
    58
	TInt iThreadNum;
sl@0
    59
	CTestStep* iStep;
sl@0
    60
	};
sl@0
    61
sl@0
    62
sl@0
    63
/**
sl@0
    64
 *
sl@0
    65
 * Class to provide a dummy font for test purposes
sl@0
    66
 * See CTFbsGlyphData::TestGlyphDataIteratorNotSupportedFontL()
sl@0
    67
 */
sl@0
    68
class CTestFont : public CFont
sl@0
    69
	{
sl@0
    70
public:
sl@0
    71
	TUid DoTypeUid() const {return TUid::Uid(12345);}
sl@0
    72
	TInt DoHeightInPixels() const {return 12;}
sl@0
    73
	TInt DoAscentInPixels() const {return 10;}
sl@0
    74
	TInt DoCharWidthInPixels(TChar /*aChar*/) const  {return 0;}
sl@0
    75
	TInt DoTextWidthInPixels(const TDesC& /*aText*/) const {return 0;}
sl@0
    76
	TInt DoBaselineOffsetInPixels() const {return 0;}
sl@0
    77
	TInt DoTextCount(const TDesC& /*aText*/,TInt /*aWidthInPixels*/) const {return 0;}
sl@0
    78
	TInt DoTextCount(const TDesC& /*aText*/,TInt /*aWidthInPixels*/,TInt& /*aExcessWidthInPixels*/) const {return 0;}
sl@0
    79
	TInt DoMaxCharWidthInPixels() const  {return 0;}
sl@0
    80
	TInt DoMaxNormalCharWidthInPixels() const  {return 0;}
sl@0
    81
	TFontSpec DoFontSpecInTwips() const  {return TFontSpec();}
sl@0
    82
	};
sl@0
    83
sl@0
    84
/**
sl@0
    85
Created by each process/thread that needs to do RSgImage image comparison.
sl@0
    86
The class can be shared in a process between threads and handles synchronisation
sl@0
    87
with EGL itself.
sl@0
    88
 */
sl@0
    89
class CEGLHelper : public CBase
sl@0
    90
	{
sl@0
    91
public:
sl@0
    92
	~CEGLHelper();
sl@0
    93
	static CEGLHelper* NewL();
sl@0
    94
		
sl@0
    95
	TInt GetSgImageData(const RSgImage& aSgImage, const TRect& aRect, TUint8*& aBuf);
sl@0
    96
	
sl@0
    97
private:
sl@0
    98
	CEGLHelper();
sl@0
    99
	void ConstructL();
sl@0
   100
sl@0
   101
private:
sl@0
   102
	RMutex iMutex;
sl@0
   103
	RSgDriver iSgDriver;
sl@0
   104
	EGLDisplay iDisplay;
sl@0
   105
	EGLContext iContext;
sl@0
   106
	EGLSurface iSurface;
sl@0
   107
	// Function pointer for creation and destruction of EGLImages, and the creation
sl@0
   108
	// of VGImages from EGLImages.
sl@0
   109
	TvgCreateEGLImageTargetKHRTypefPtr vgCreateImageTargetKHR;
sl@0
   110
	PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
sl@0
   111
	PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
sl@0
   112
	};
sl@0
   113
sl@0
   114
/**
sl@0
   115
Test class for the glyph data extensions RFbsGlyphDataIterator and 
sl@0
   116
RFbsGlyphMetricsArray. Positive and negative tests
sl@0
   117
*/
sl@0
   118
class CTFbsGlyphData : public CTGraphicsBase
sl@0
   119
	{
sl@0
   120
public:
sl@0
   121
	CTFbsGlyphData(CTestStep* aStep);
sl@0
   122
	~CTFbsGlyphData();
sl@0
   123
protected:
sl@0
   124
//from 	CTGraphicsBase
sl@0
   125
	virtual void RunTestCaseL(TInt aCurTestCase);
sl@0
   126
	void ConstructL();
sl@0
   127
	
sl@0
   128
private:
sl@0
   129
	// Test Cases
sl@0
   130
	void TestConsistencyWithGetCharacterData();
sl@0
   131
	void TestInvalidGlyphCode();
sl@0
   132
	void TestGlyphMetricsArrayParameters();
sl@0
   133
	void TestGlyphMetricsArrayReuse();
sl@0
   134
	void TestGlyphDataIteratorClose();
sl@0
   135
	void TestGlyphDataIteratorSequence();
sl@0
   136
	void TestGlyphDataIteratorMultipleUsesOnMultipleFonts();
sl@0
   137
	void TestGlyphDataIteratorImageValidity();
sl@0
   138
	void TestGlyphDataIteratorOpenInvalidCode();
sl@0
   139
	void TestGlyphDataIteratorOpenTwice();
sl@0
   140
	void TestGlyphDataIteratorOpenTwiceWithDifferentFonts();
sl@0
   141
	void TestGlyphDataIteratorOpenTooBigFont();
sl@0
   142
	void TestGlyphDataIteratorOpenWithWrongArgument();
sl@0
   143
	void TestGlyphDataIteratorImageMemoryLeak();
sl@0
   144
	void TestGlyphDataIteratorLargeFontStress();
sl@0
   145
	void TestGlyphDataIteratorManyFontsStressL();
sl@0
   146
	void TestGlyphDataIteratorNoGraphicsMemory();
sl@0
   147
	void TestGlyphDataIteratorNextIsAtomic();
sl@0
   148
	void TestGlyphDataIteratorManyArraySizes();
sl@0
   149
	void TestBitmapFontSupport();
sl@0
   150
	// White-Box Test Cases
sl@0
   151
	void TestGlyphDataIteratorSameGlyphCodes();
sl@0
   152
	void TestMultithreadShareSingleFont();
sl@0
   153
	void TestMultithreadStressAtlas();
sl@0
   154
	// Out-of-system-memory tests
sl@0
   155
	void TestGlyphMetricsArrayHeapOOML();
sl@0
   156
	void TestGlyphDataIteratorHeapOOML();
sl@0
   157
	// Multithread funtions
sl@0
   158
	static void ThreadShareGlyphsL(TInt aThreadNum, TGlyphDataMultithreadParams& aParam, CTestStep* aStep);
sl@0
   159
	static void ThreadStressAtlasL(TInt aThreadNum, TGlyphDataMultithreadParams& aParam, CTestStep* aStep);	
sl@0
   160
sl@0
   161
	// Utility functions for the test cases.
sl@0
   162
	static TInt ThreadFunction(TAny* aParam); 
sl@0
   163
	TInt GetImageDataFromSgImage(const RSgImage& aSgImage, const TRect& aRect, TUint8*& aBuf);
sl@0
   164
	TUint32 CompareMetrics(const TOpenFontCharMetrics& aMetrics1, const TOpenFontCharMetrics& aMetrics2);
sl@0
   165
	static TInt CompareSgImages(CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, const RSgImage& aImageB, const TRect& aRectB, TBool& aMatch);
sl@0
   166
	static TInt CompareSgImages(CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, TUint8* aBufferA, const RSgImage& aImageB, const TRect& aRectB, TUint8* aBufferB, TBool& aMatch);
sl@0
   167
#ifdef SAVEGLYPHSTOMBMDEBUGFUNCTION
sl@0
   168
	void SaveRSgImagesAsMbms( CEGLHelper* aEGL, const RSgImage& aImageA, const TRect& aRectA, const RSgImage& aImageB, const TRect& aRectB );
sl@0
   169
#endif // SAVEGLYPHSTOMBMDEBUGFUNCTION
sl@0
   170
	void InfoPrintFontSpec(const CFont& aFont);
sl@0
   171
	void SetupEglL();
sl@0
   172
	
sl@0
   173
private:
sl@0
   174
	RFbsSession* iFbs;
sl@0
   175
	CFbsTypefaceStore* iTs;
sl@0
   176
	TUint* iGlyphCodesLatin;
sl@0
   177
	
sl@0
   178
	CFbsFont* iFont;
sl@0
   179
	CFbsFont* iFont2;
sl@0
   180
sl@0
   181
	TUint8* iTempBuf1;
sl@0
   182
	TUint8* iTempBuf2;
sl@0
   183
	RSgDriver iSgDriver;
sl@0
   184
	CEGLHelper* iEGL;
sl@0
   185
	};
sl@0
   186
sl@0
   187
sl@0
   188
class CTFbsGlyphDataStep : public CTGraphicsStep
sl@0
   189
	{
sl@0
   190
public:
sl@0
   191
	CTFbsGlyphDataStep();
sl@0
   192
protected:	
sl@0
   193
	//from CTGraphicsStep
sl@0
   194
	virtual CTGraphicsBase* CreateTestL();
sl@0
   195
	};
sl@0
   196
sl@0
   197
_LIT(KTFbsGlyphDataStep,"TFbsGlyphData");
sl@0
   198
sl@0
   199
#endif /* TFBSGLYPHDATA_H */