fbs/fontandbitmapserver/tfbs/tfbsglyphdata.cpp
changeset 136 62bb7c97884c
parent 121 d72fc2aace31
equal deleted inserted replaced
121:d72fc2aace31 136:62bb7c97884c
    16 /**
    16 /**
    17  @file
    17  @file
    18  @internalComponent - Internal Symbian test code
    18  @internalComponent - Internal Symbian test code
    19 */
    19 */
    20 
    20 
       
    21 #include <test/graphicsfontutils.h>
    21 #include <EGL/egl.h>
    22 #include <EGL/egl.h>
    22 #include <VG/openvg.h>
    23 #include <VG/openvg.h>
    23 #include <graphics/fbsglyphmetricsarray.h> 
    24 #include <graphics/fbsglyphmetricsarray.h> 
    24 #include <graphics/fbsglyphdataiterator.h>
    25 #include <graphics/fbsglyphdataiterator.h>
    25 #include <sgresource/sgimage.h>
    26 #include <sgresource/sgimage.h>
    45 
    46 
    46 // Please note the following macros which enable helper functions, and are declared in the header.
    47 // Please note the following macros which enable helper functions, and are declared in the header.
    47 // SAVEGLYPHSTOMBMDURINGCOMPARISON and
    48 // SAVEGLYPHSTOMBMDURINGCOMPARISON and
    48 // SAVEGLYPHSTOMBMDEBUGFUNCTION
    49 // SAVEGLYPHSTOMBMDEBUGFUNCTION
    49 
    50 
    50 /*
    51 // Utility function declarations - utilities used by the tests
    51 Lookup table to convert from ascii code to
       
    52 glyph code for the Deja Vu family of fonts.
       
    53  */
       
    54 const TUint DejaVuASCIIToGlyphCode[] = 
       
    55 	{
       
    56 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       
    57 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       
    58 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       
    59 	0, 0, 3, 4, 5, 6, 7, 8, 9, 10,
       
    60 	11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
       
    61 	21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
       
    62 	31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
       
    63 	41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
       
    64 	51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
       
    65 	61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
       
    66 	71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
       
    67 	81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
       
    68 	91, 92, 93, 94, 95, 96, 97, 98,
       
    69 	};
       
    70 
       
    71 // Utility function declations - utilities used by the tests
       
    72 static TFontSpec GenerateDejaVuFontSpec(TInt aSeed);
    52 static TFontSpec GenerateDejaVuFontSpec(TInt aSeed);
    73 static void CopyCharLine(TUint32*& aBinaryDataPtr,TInt aBufferWords,const TUint8* aData,TInt aBitShift,TInt aCharWidth, TInt16 aRepeatCount);
    53 static void CopyCharLine(TUint32*& aBinaryDataPtr,TInt aBufferWords,const TUint8* aData,TInt aBitShift,TInt aCharWidth, TInt16 aRepeatCount);
    74 static void DecodeBinaryData(const TSize& aDataSize, const TUint8* aData, TInt aStride,	TUint32* aBinaryData);
    54 static void DecodeBinaryData(const TSize& aDataSize, const TUint8* aData, TInt aStride,	TUint32* aBinaryData);
    75 static TInt CreateSgImageFromCharacterData(const TUint8* aData, const TSize& aSize, TGlyphBitmapType aType, RSgImage& aImage);
    55 static TInt CreateSgImageFromCharacterData(const TUint8* aData, const TSize& aSize, TGlyphBitmapType aType, RSgImage& aImage);
    76 static TInt CreateSgImageFromCharacterData(const TUint8* aData, const TSize& aSize, TGlyphBitmapType aType, RSgImage& aImage, TUint8* aBuffer1, TUint8* aBuffer2);
    56 static TInt CreateSgImageFromCharacterData(const TUint8* aData, const TSize& aSize, TGlyphBitmapType aType, RSgImage& aImage, TUint8* aBuffer1, TUint8* aBuffer2);
   511 	iFbs = RFbsSession::GetSession();
   491 	iFbs = RFbsSession::GetSession();
   512 	iTs = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL);
   492 	iTs = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL);
   513 	User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont, TFontSpec(KTypefaceName, 15)));
   493 	User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont, TFontSpec(KTypefaceName, 15)));
   514 	User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont2, TFontSpec(KTypefaceName, 8)));
   494 	User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont2, TFontSpec(KTypefaceName, 8)));
   515 	
   495 	
       
   496 	CCharCodeConverter* converter = CCharCodeConverter::NewLC();
       
   497 	converter->UseFontL(iFont);
   516 	iGlyphCodesLatin = new(ELeave) TUint[KNumGlyphCodesLatin];
   498 	iGlyphCodesLatin = new(ELeave) TUint[KNumGlyphCodesLatin];
   517 	for (TInt ii = 0; ii < KNumGlyphCodesLatin; ++ii)
   499 	for (TInt ii = 0; ii < KNumGlyphCodesLatin; ++ii)
   518 		{
   500 		{
   519 		TUint asciiCode = ii+0x20; // ASCII characters from 0020 to 007F
   501 		TUint asciiCode = ii+0x20; // ASCII characters from 0020 to 007F
   520 		iGlyphCodesLatin[ii] = DejaVuASCIIToGlyphCode[asciiCode];
   502 		iGlyphCodesLatin[ii] = converter->GlyphCodeL(asciiCode);
   521 		}
   503 		}
       
   504 	CleanupStack::PopAndDestroy(1); // converter
   522 	
   505 	
   523 	User::LeaveIfError(iSgDriver.Open());
   506 	User::LeaveIfError(iSgDriver.Open());
   524 	iEGL = CEGLHelper::NewL();
   507 	iEGL = CEGLHelper::NewL();
   525 	
   508 	
   526 	// Creating a CFbsBitmap will force the RFbsSession to allocate a scanline buffer
   509 	// Creating a CFbsBitmap will force the RFbsSession to allocate a scanline buffer
  2047 void CTFbsGlyphData::TestGlyphDataIteratorSameGlyphCodes()
  2030 void CTFbsGlyphData::TestGlyphDataIteratorSameGlyphCodes()
  2048 	{
  2031 	{
  2049 	INFO_PRINTF1(_L("White box test - Ensure that the same RSgImage is used for repeated requests for the same glyph in the same call to Open()"));
  2032 	INFO_PRINTF1(_L("White box test - Ensure that the same RSgImage is used for repeated requests for the same glyph in the same call to Open()"));
  2050 	__UHEAP_MARK;
  2033 	__UHEAP_MARK;
  2051 
  2034 
  2052 	const TUint KSameRepeatedGlyphCode = DejaVuASCIIToGlyphCode[0x004B]; // 'K'
  2035 	const TUint KSameRepeatedGlyphCode = iGlyphCodesLatin['A' - 0x20];
  2053 	const TInt KNumGlyphs = 10;
  2036 	const TInt KNumGlyphs = 10;
  2054 	TUint* sameRepeatedGlyphCodes = new TUint[KNumGlyphs];
  2037 	TUint* sameRepeatedGlyphCodes = new TUint[KNumGlyphs];
  2055 	for (TInt ii = 0; ii < KNumGlyphs; ++ii)
  2038 	for (TInt ii = 0; ii < KNumGlyphs; ++ii)
  2056 		{
  2039 		{
  2057 		sameRepeatedGlyphCodes[ii] = KSameRepeatedGlyphCode;
  2040 		sameRepeatedGlyphCodes[ii] = KSameRepeatedGlyphCode;