|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <hal.h> |
|
17 #include "sgdriverimpl.h" |
|
18 |
|
19 |
|
20 TInt SgMinDataStride(TInt aWidth, TUidPixelFormat aPixelFormat) |
|
21 { |
|
22 switch (aPixelFormat) |
|
23 { |
|
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: |
|
35 return aWidth * 4; |
|
36 case EUidPixelFormatBGR_888: |
|
37 case EUidPixelFormatRGB_888: |
|
38 return aWidth * 3; |
|
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: |
|
52 return aWidth * 2; |
|
53 case EUidPixelFormatRGB_332: |
|
54 case EUidPixelFormatA_8: |
|
55 case EUidPixelFormatBGR_332: |
|
56 case EUidPixelFormatP_8: |
|
57 return aWidth; |
|
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; |
|
64 default: |
|
65 return KErrNotSupported; |
|
66 } |
|
67 } |
|
68 |
|
69 |
|
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; |
|
76 |
|
77 const TUidPixelFormat KSgSupportedOpaqueTargetFormat = EUidPixelFormatXRGB_8888; |
|
78 const TUidPixelFormat KSgSupportedAlphaTargetFormat = EUidPixelFormatARGB_8888_PRE; |
|
79 |
|
80 #ifdef SYMBIAN_GRAPHICS_USE_NUMA |
|
81 const TSgCpuAccess KSgSupportedOffScreenCpuAccess = ESgCpuAccessNone; |
|
82 #else |
|
83 const TSgCpuAccess KSgSupportedOffScreenCpuAccess = ESgCpuAccessReadWrite; |
|
84 #endif |
|
85 |
|
86 const TSgPixelFormatTableEntry KSgAnyScreenPixelFormatTableEntries[] = |
|
87 { |
|
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}, |
|
93 }; |
|
94 |
|
95 const TSgPixelFormatTableEntry KSgPerScreenPixelFormatTableEntries[] = |
|
96 { |
|
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}, |
|
102 |
|
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}, |
|
107 |
|
108 {KSgSupportedOpaqueTargetFormat, KSgSupportedOffScreenSources|ESgUsageCompositionTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain}, |
|
109 {KSgSupportedAlphaTargetFormat, KSgSupportedOffScreenSources|ESgUsageCompositionTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain}, |
|
110 {EUidPixelFormatRGB_565, KSgSupportedOffScreenSources|ESgUsageCompositionTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain}, |
|
111 |
|
112 {KSgSupportedOpaqueTargetFormat, KSgSupportedOffScreenSources|ESgUsageEglCopyBuffersTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain}, |
|
113 {KSgSupportedAlphaTargetFormat, KSgSupportedOffScreenSources|ESgUsageEglCopyBuffersTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain}, |
|
114 {EUidPixelFormatRGB_565, KSgSupportedOffScreenSources|ESgUsageEglCopyBuffersTarget, KSgSupportedOffScreenCpuAccess, KSgScreenIdMain}, |
|
115 }; |
|
116 |
|
117 |
|
118 TInt XSgDriverImpl::ConstructPixelFormatTable() |
|
119 { |
|
120 TInt numberOfScreens; |
|
121 TInt err = HAL::Get(HAL::EDisplayNumberOfScreens, numberOfScreens); |
|
122 if (err != KErrNone) |
|
123 { |
|
124 return err; |
|
125 } |
|
126 for (TInt i = 0; i < sizeof(KSgAnyScreenPixelFormatTableEntries) / sizeof(TSgPixelFormatTableEntry); ++i) |
|
127 { |
|
128 RHeap* prevHeap = User::SwitchHeap(iHeap); |
|
129 err = iPixelFormatTable.Append(KSgAnyScreenPixelFormatTableEntries[i]); |
|
130 User::SwitchHeap(prevHeap); |
|
131 if (err != KErrNone) |
|
132 { |
|
133 return err; |
|
134 } |
|
135 } |
|
136 for (TInt screenId = 0; screenId < numberOfScreens; ++screenId) |
|
137 { |
|
138 for (TInt i = 0; i < sizeof(KSgPerScreenPixelFormatTableEntries) / sizeof(TSgPixelFormatTableEntry); ++i) |
|
139 { |
|
140 TSgPixelFormatTableEntry entry = KSgPerScreenPixelFormatTableEntries[i]; |
|
141 entry.iScreenId = screenId; |
|
142 RHeap* prevHeap = User::SwitchHeap(iHeap); |
|
143 err = iPixelFormatTable.Append(entry); |
|
144 User::SwitchHeap(prevHeap); |
|
145 if (err != KErrNone) |
|
146 { |
|
147 return err; |
|
148 } |
|
149 } |
|
150 } |
|
151 return KErrNone; |
|
152 } |