os/graphics/graphicsresourceservices/graphicsresourceadaptation/src/sgpixelformats.cpp
Update contrib.
1 // Copyright (c) 2007-2009 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.
17 #include "sgdriverimpl.h"
20 TInt SgMinDataStride(TInt aWidth, TUidPixelFormat aPixelFormat)
24 case EUidPixelFormatXRGB_8888:
25 case EUidPixelFormatBGRX_8888:
26 case EUidPixelFormatXBGR_8888:
27 case EUidPixelFormatBGRA_8888:
28 case EUidPixelFormatARGB_8888:
29 case EUidPixelFormatABGR_8888:
30 case EUidPixelFormatARGB_8888_PRE:
31 case EUidPixelFormatABGR_8888_PRE:
32 case EUidPixelFormatBGRA_8888_PRE:
33 case EUidPixelFormatARGB_2101010:
34 case EUidPixelFormatABGR_2101010:
36 case EUidPixelFormatBGR_888:
37 case EUidPixelFormatRGB_888:
39 case EUidPixelFormatRGB_565:
40 case EUidPixelFormatBGR_565:
41 case EUidPixelFormatARGB_1555:
42 case EUidPixelFormatXRGB_1555:
43 case EUidPixelFormatARGB_4444:
44 case EUidPixelFormatARGB_8332:
45 case EUidPixelFormatBGRX_5551:
46 case EUidPixelFormatBGRA_5551:
47 case EUidPixelFormatBGRA_4444:
48 case EUidPixelFormatBGRX_4444:
49 case EUidPixelFormatAP_88:
50 case EUidPixelFormatXRGB_4444:
51 case EUidPixelFormatXBGR_4444:
53 case EUidPixelFormatRGB_332:
54 case EUidPixelFormatA_8:
55 case EUidPixelFormatBGR_332:
56 case EUidPixelFormatP_8:
58 case EUidPixelFormatP_4:
59 return (aWidth + 1) / 2;
60 case EUidPixelFormatP_2:
61 return (aWidth + 3) / 4;
62 case EUidPixelFormatP_1:
63 return (aWidth + 7) / 8;
65 return KErrNotSupported;
70 const TUint32 KSgSupportedConstantSources = ESgUsageDirectGdiSource
71 | ESgUsageOpenGlesTexture2D | ESgUsageOpenVgImage | ESgUsageOpenGles2Texture2D | ESgUsageWindowGcSource;
72 const TUint32 KSgSupportedCpuSources = ESgUsageDirectGdiSource | ESgUsageCompositionSource
73 | ESgUsageOpenGlesTexture2D | ESgUsageOpenVgImage | ESgUsageOpenGles2Texture2D | ESgUsageWindowGcSource;
74 const TUint32 KSgSupportedOffScreenSources = ESgUsageDirectGdiSource | ESgUsageCompositionSource | ESgUsageScreenSource
75 | ESgUsageOpenGlesTexture2D | ESgUsageOpenVgImage | ESgUsageOpenGles2Texture2D | ESgUsageWindowGcSource;
77 const TUidPixelFormat KSgSupportedOpaqueTargetFormat = EUidPixelFormatXRGB_8888;
78 const TUidPixelFormat KSgSupportedAlphaTargetFormat = EUidPixelFormatARGB_8888_PRE;
80 #ifdef SYMBIAN_GRAPHICS_USE_NUMA
81 const TSgCpuAccess KSgSupportedOffScreenCpuAccess = ESgCpuAccessNone;
83 const TSgCpuAccess KSgSupportedOffScreenCpuAccess = ESgCpuAccessReadWrite;
86 const TSgPixelFormatTableEntry KSgAnyScreenPixelFormatTableEntries[] =
88 // Support for constant images
89 {EUidPixelFormatRGB_565, KSgSupportedConstantSources, ESgCpuAccessNone, KSgScreenIdAny},
90 {EUidPixelFormatXRGB_8888, KSgSupportedConstantSources, ESgCpuAccessNone, KSgScreenIdAny},
91 {EUidPixelFormatARGB_8888, KSgSupportedConstantSources, ESgCpuAccessNone, KSgScreenIdAny},
92 {EUidPixelFormatARGB_8888_PRE, KSgSupportedConstantSources, ESgCpuAccessNone, KSgScreenIdAny},
95 const TSgPixelFormatTableEntry KSgPerScreenPixelFormatTableEntries[] =
97 // Support for CPU rendering
98 {EUidPixelFormatRGB_565, KSgSupportedCpuSources, ESgCpuAccessReadWrite, KSgScreenIdMain},
99 {EUidPixelFormatXRGB_8888, KSgSupportedCpuSources, ESgCpuAccessReadWrite, KSgScreenIdMain},
100 {EUidPixelFormatARGB_8888, KSgSupportedCpuSources, ESgCpuAccessReadWrite, KSgScreenIdMain},
101 {EUidPixelFormatARGB_8888_PRE, KSgSupportedCpuSources, ESgCpuAccessReadWrite, KSgScreenIdMain},
103 // Support for off-screen rendering
104 {KSgSupportedOpaqueTargetFormat, KSgSupportedOffScreenSources|ESgUsageDirectGdiTarget|ESgUsageOpenGlesTarget|ESgUsageOpenGles2Target|ESgUsageOpenVgTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
105 {KSgSupportedAlphaTargetFormat, KSgSupportedOffScreenSources|ESgUsageDirectGdiTarget|ESgUsageOpenGlesTarget|ESgUsageOpenGles2Target|ESgUsageOpenVgTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
106 {EUidPixelFormatRGB_565, KSgSupportedOffScreenSources|ESgUsageDirectGdiTarget|ESgUsageOpenGlesTarget|ESgUsageOpenGles2Target|ESgUsageOpenVgTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
108 {KSgSupportedOpaqueTargetFormat, KSgSupportedOffScreenSources|ESgUsageCompositionTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
109 {KSgSupportedAlphaTargetFormat, KSgSupportedOffScreenSources|ESgUsageCompositionTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
110 {EUidPixelFormatRGB_565, KSgSupportedOffScreenSources|ESgUsageCompositionTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
112 {KSgSupportedOpaqueTargetFormat, KSgSupportedOffScreenSources|ESgUsageEglCopyBuffersTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
113 {KSgSupportedAlphaTargetFormat, KSgSupportedOffScreenSources|ESgUsageEglCopyBuffersTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
114 {EUidPixelFormatRGB_565, KSgSupportedOffScreenSources|ESgUsageEglCopyBuffersTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain},
118 TInt XSgDriverImpl::ConstructPixelFormatTable()
120 TInt numberOfScreens;
121 TInt err = HAL::Get(HAL::EDisplayNumberOfScreens, numberOfScreens);
126 for (TInt i = 0; i < sizeof(KSgAnyScreenPixelFormatTableEntries) / sizeof(TSgPixelFormatTableEntry); ++i)
128 RHeap* prevHeap = User::SwitchHeap(iHeap);
129 err = iPixelFormatTable.Append(KSgAnyScreenPixelFormatTableEntries[i]);
130 User::SwitchHeap(prevHeap);
136 for (TInt screenId = 0; screenId < numberOfScreens; ++screenId)
138 for (TInt i = 0; i < sizeof(KSgPerScreenPixelFormatTableEntries) / sizeof(TSgPixelFormatTableEntry); ++i)
140 TSgPixelFormatTableEntry entry = KSgPerScreenPixelFormatTableEntries[i];
141 entry.iScreenId = screenId;
142 RHeap* prevHeap = User::SwitchHeap(iHeap);
143 err = iPixelFormatTable.Append(entry);
144 User::SwitchHeap(prevHeap);