1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/egl/egltest/src/egltestcommonconversion.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,147 @@
1.4 +// Copyright (c) 2007-2009 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 +/**
1.20 + @file
1.21 + @test
1.22 +*/
1.23 +
1.24 +#include "egltestcommonconversion.h"
1.25 +
1.26 +EXPORT_C TEglTestConfig EglTestConversion::VgFormatToWindowSurfaceFormat(VGImageFormat aVgFormat)
1.27 + {
1.28 + switch(aVgFormat)
1.29 + {
1.30 + case VG_sRGB_565:
1.31 + return EWindowAttribsColor64K;
1.32 + case VG_sARGB_8888:
1.33 + return EWindowAttribsColor16MA;
1.34 + case VG_sARGB_8888_PRE:
1.35 + return EWindowAttribsColor16MAP;
1.36 + default:
1.37 + return EEglTestConfigMax;
1.38 + }
1.39 + }
1.40 +
1.41 +EXPORT_C TEglTestConfig EglTestConversion::VgFormatToPBufferSurfaceFormat(VGImageFormat aVgFormat)
1.42 + {
1.43 + switch(aVgFormat)
1.44 + {
1.45 + case VG_sRGB_565:
1.46 + return EPBufferAttribsColor64K;
1.47 + case VG_sXRGB_8888:
1.48 + return EPBufferAttribsColor16MU;
1.49 + case VG_sARGB_8888:
1.50 + return EPBufferAttribsColor16MA;
1.51 + case VG_sARGB_8888_PRE:
1.52 + return EPBufferAttribsColor16MAP;
1.53 + default:
1.54 + return EEglTestConfigMax;
1.55 + }
1.56 + }
1.57 +
1.58 +EXPORT_C TEglTestConfig EglTestConversion::VgFormatToPixmapSgSurfaceFormat(VGImageFormat aVgFormat)
1.59 + {
1.60 + switch(aVgFormat)
1.61 + {
1.62 + case VG_sRGB_565:
1.63 + return EPixmapAttribsColor64K;
1.64 + case VG_sXRGB_8888:
1.65 + return EPixmapAttribsColor16MU;
1.66 + case VG_sARGB_8888_PRE:
1.67 + return EPixmapAttribsColor16MAP;
1.68 + default:
1.69 + return EEglTestConfigMax;
1.70 + }
1.71 + }
1.72 +
1.73 +EXPORT_C TUidPixelFormat EglTestConversion::VgFormatToSgPixelFormat(VGImageFormat aVgFormat)
1.74 + {
1.75 + switch(aVgFormat)
1.76 + {
1.77 + case VG_sRGB_565:
1.78 + return EUidPixelFormatRGB_565;
1.79 + case VG_sXRGB_8888:
1.80 + return EUidPixelFormatXRGB_8888;
1.81 + case VG_sARGB_8888:
1.82 + return EUidPixelFormatARGB_8888;
1.83 + case VG_sARGB_8888_PRE:
1.84 + return EUidPixelFormatARGB_8888_PRE;
1.85 + case VG_A_8:
1.86 + return EUidPixelFormatA_8;
1.87 + default:
1.88 + return EUidPixelFormatUnknown;
1.89 + }
1.90 + }
1.91 +
1.92 +EXPORT_C VGImageFormat EglTestConversion::PixelFormatToVgFormat(TUidPixelFormat aPixelFormat)
1.93 + {
1.94 + switch(aPixelFormat)
1.95 + {
1.96 + case EUidPixelFormatRGB_565:
1.97 + return VG_sRGB_565;
1.98 + case EUidPixelFormatXRGB_8888:
1.99 + return VG_sXRGB_8888;
1.100 + case EUidPixelFormatARGB_8888:
1.101 + return VG_sARGB_8888;
1.102 + case EUidPixelFormatARGB_8888_PRE:
1.103 + return VG_sARGB_8888_PRE;
1.104 + case EUidPixelFormatA_8:
1.105 + return VG_A_8;
1.106 + default:
1.107 + return VG_IMAGE_FORMAT_INVALID;
1.108 + }
1.109 + }
1.110 +
1.111 +EXPORT_C TDisplayMode EglTestConversion::PixelFormatToDisplayMode(TUidPixelFormat aPixelFormat)
1.112 + {
1.113 + switch(aPixelFormat)
1.114 + {
1.115 + case EUidPixelFormatRGB_565:
1.116 + return EColor64K;
1.117 + case EUidPixelFormatXRGB_8888:
1.118 + return EColor16MU;
1.119 + case EUidPixelFormatARGB_8888:
1.120 + return EColor16MA;
1.121 + case EUidPixelFormatARGB_8888_PRE:
1.122 + return EColor16MAP;
1.123 + case EUidPixelFormatA_8:
1.124 + return EGray256;
1.125 + default:
1.126 + return ENone;
1.127 + }
1.128 + }
1.129 +
1.130 +EXPORT_C TDisplayMode EglTestConversion::VgFormatToDisplayMode(VGImageFormat aVgFormat)
1.131 + {
1.132 + return PixelFormatToDisplayMode( VgFormatToSgPixelFormat(aVgFormat) );
1.133 + }
1.134 +
1.135 +EXPORT_C TInt EglTestConversion::BytePerPixel(TUidPixelFormat aPixelFormat)
1.136 + {
1.137 + switch(aPixelFormat)
1.138 + {
1.139 + case EUidPixelFormatRGB_565:
1.140 + return 2;
1.141 + case EUidPixelFormatXRGB_8888:
1.142 + case EUidPixelFormatARGB_8888:
1.143 + case EUidPixelFormatARGB_8888_PRE:
1.144 + return 4;
1.145 + case EUidPixelFormatA_8:
1.146 + return 1;
1.147 + default:
1.148 + return 0;
1.149 + }
1.150 + }