|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Provides the palette methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "Palette.h" |
|
20 #include "NokiaBlue.h" |
|
21 #include "PaletteConstants.h" |
|
22 |
|
23 #ifndef DISABLE_256_COLOR_PALETTE_SWITCHING |
|
24 #include "NokiaGreen.h" |
|
25 #include "NokiaPurple.h" |
|
26 #include "NokiaGrey.h" |
|
27 #include "SchemeRed.h" |
|
28 #include "SchemePink.h" |
|
29 #include "SchemeOrange.h" |
|
30 #include "Palette1.h" |
|
31 #include "Palette2.h" |
|
32 #include "Palette3.h" |
|
33 #include "Palette4.h" |
|
34 #include "Palette5.h" |
|
35 #include "Palette6.h" |
|
36 #include "Palette7.h" |
|
37 #include "Palette8.h" |
|
38 #include "Palette9.h" |
|
39 #include "Palette10.h" |
|
40 #include "Palette11.h" |
|
41 #include "Palette12.h" |
|
42 #include "Palette13.h" |
|
43 #endif |
|
44 |
|
45 class TColorSchemeStore |
|
46 { |
|
47 public: |
|
48 static TSeries60ColorScheme Get(); |
|
49 static void Set(TSeries60ColorScheme aScheme); |
|
50 }; |
|
51 |
|
52 enum TPalettePanic |
|
53 { |
|
54 EBadScheme |
|
55 }; |
|
56 |
|
57 _LIT(KPanic, "Palette"); |
|
58 void Panic(TPalettePanic aCode) |
|
59 { |
|
60 User::Panic(KPanic, aCode); |
|
61 } |
|
62 |
|
63 |
|
64 const TUint32 color16array[16] = { |
|
65 0x00000000, 0x00555555, 0x00000080, 0x00008080, |
|
66 0x00008000, 0x000000ff, 0x0000ffff, 0x0000ff00, |
|
67 0x00ff00ff, 0x00ff0000, 0x00ffff00, 0x00800080, |
|
68 0x00800000, 0x00808000,0x00aaaaaa, 0x00ffffff }; |
|
69 |
|
70 const TUint8 color16inverse[512] = { |
|
71 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05, |
|
72 0x04, 0x04, 0x01, 0x03, 0x03, 0x03, 0x05, 0x05, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x05, |
|
73 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x06, 0x06, |
|
74 0x07, 0x07, 0x07, 0x03, 0x03, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, |
|
75 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x05, 0x05, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x05, 0x05, |
|
76 0x04, 0x01, 0x01, 0x01, 0x03, 0x03, 0x05, 0x05, 0x04, 0x04, 0x01, 0x03, 0x03, 0x03, 0x03, 0x05, |
|
77 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x06, 0x06, |
|
78 0x07, 0x07, 0x07, 0x03, 0x03, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, |
|
79 0x0c, 0x0c, 0x01, 0x0b, 0x0b, 0x0b, 0x05, 0x05, 0x0c, 0x01, 0x01, 0x01, 0x0b, 0x0b, 0x05, 0x05, |
|
80 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x0d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, |
|
81 0x0d, 0x0d, 0x01, 0x01, 0x03, 0x0e, 0x0e, 0x06, 0x0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, 0x0f, 0x0f |
|
103 }; |
|
104 |
|
105 #ifndef DISABLE_256_COLOR_PALETTE_SWITCHING |
|
106 |
|
107 #define VIDEO_MEMORY_SCHEME_OFFSET(paletteSize, width, height, bytesPerPixel) ((paletteSize) + ((width)*((height)+1)*(bytesPerPixel))) |
|
108 |
|
109 #ifdef __PALETTE_INDEX_ADDRESS_FIXED |
|
110 #if defined __WINS__ |
|
111 |
|
112 TSeries60ColorScheme theSchemeMem = ESeries60ColorSchemeBlue; |
|
113 TSeries60ColorScheme* const theScheme = &theSchemeMem; |
|
114 |
|
115 #else |
|
116 |
|
117 #define DEVICE_SCHEME_OFFSET VIDEO_MEMORY_SCHEME_OFFSET(DEVICE_VIDEO_PALETTE_SIZE, DEVICE_SCREEN_WIDTH, DEVICE_SCREEN_HEIGHT, DEVICE_BYTES_PER_PIXEL) |
|
118 #define DEVICE_SCHEME_ADDR (DEVICE_VIDEO_ADDR + DEVICE_SCHEME_OFFSET) |
|
119 TSeries60ColorScheme* const theScheme = (TSeries60ColorScheme*)(DEVICE_SCHEME_ADDR); |
|
120 |
|
121 #endif |
|
122 #endif |
|
123 #endif // DISABLE_256_COLOR_PALETTE_SWITCHING |
|
124 |
|
125 |
|
126 EXPORT_C const TUint32* DynamicPalette::Color16array() |
|
127 { |
|
128 return color16array; |
|
129 } |
|
130 |
|
131 EXPORT_C const TUint8* DynamicPalette::Color16inverse() |
|
132 { |
|
133 return color16inverse; |
|
134 } |
|
135 |
|
136 /** |
|
137 * |
|
138 * Returns the current system palette. Depending on the |
|
139 * implementation this value depends on the current color |
|
140 * scheme set using SetColorScheme. |
|
141 * |
|
142 * @returns "const TColor256Util*" |
|
143 * Current system palette. |
|
144 */ |
|
145 EXPORT_C const TColor256Util* DynamicPalette::DefaultColor256Util() |
|
146 { |
|
147 #ifdef DISABLE_256_COLOR_PALETTE_SWITCHING |
|
148 |
|
149 return &KNokiaBlueColor256Util; |
|
150 |
|
151 #else // DISABLE_256_COLOR_PALETTE_SWITCHING |
|
152 |
|
153 #ifndef __PALETTE_INDEX_ADDRESS_FIXED |
|
154 TSeries60ColorScheme* theScheme = (TSeries60ColorScheme*)Dll::Tls(); |
|
155 if (!theScheme) |
|
156 { |
|
157 TPckgBuf<TScreenInfoV01> info; |
|
158 UserSvr::ScreenInfo(info); |
|
159 TInt offset = VIDEO_MEMORY_SCHEME_OFFSET(DEVICE_VIDEO_PALETTE_SIZE, info().iScreenSize.iWidth, info().iScreenSize.iHeight, DEVICE_BYTES_PER_PIXEL); |
|
160 theScheme = (TSeries60ColorScheme*)(((TUint8*)info().iScreenAddress) + offset); |
|
161 Dll::SetTls(theScheme); |
|
162 } |
|
163 #endif |
|
164 switch (*theScheme) |
|
165 { |
|
166 case EIndex0: |
|
167 return &KNokiaBlueColor256Util; |
|
168 |
|
169 case EIndex1: |
|
170 return &KNokiaGreenColor256Util; |
|
171 |
|
172 case EIndex2: |
|
173 return &KNokiaPurpleColor256Util; |
|
174 |
|
175 case EIndex3: |
|
176 return &KSchemeRedColor256Util; |
|
177 |
|
178 case EIndex4: |
|
179 return &KSchemePinkColor256Util; |
|
180 |
|
181 case EIndex5: |
|
182 return &KSchemeOrangeColor256Util; |
|
183 |
|
184 case EIndex6: |
|
185 return &KNokiaGreyColor256Util; |
|
186 |
|
187 case EIndex7: |
|
188 return &KPalette1Color256Util; |
|
189 |
|
190 case EIndex8: |
|
191 return &KPalette2Color256Util; |
|
192 |
|
193 case EIndex9: |
|
194 return &KPalette3Color256Util; |
|
195 |
|
196 case EIndex10: |
|
197 return &KPalette4Color256Util; |
|
198 |
|
199 case EIndex11: |
|
200 return &KPalette5Color256Util; |
|
201 |
|
202 case EIndex12: |
|
203 return &KPalette6Color256Util; |
|
204 |
|
205 case EIndex13: |
|
206 return &KPalette7Color256Util; |
|
207 |
|
208 case EIndex14: |
|
209 return &KPalette8Color256Util; |
|
210 |
|
211 case EIndex15: |
|
212 return &KPalette9Color256Util; |
|
213 |
|
214 case EIndex16: |
|
215 return &KPalette10Color256Util; |
|
216 |
|
217 case EIndex17: |
|
218 return &KPalette11Color256Util; |
|
219 |
|
220 case EIndex18: |
|
221 return &KPalette12Color256Util; |
|
222 |
|
223 case EIndex19: |
|
224 return &KPalette13Color256Util; |
|
225 |
|
226 default: |
|
227 return &KNokiaBlueColor256Util; |
|
228 } |
|
229 |
|
230 #endif // DISABLE_256_COLOR_PALETTE_SWITCHING |
|
231 } |
|
232 |
|
233 /** |
|
234 * |
|
235 * Sets the current color palette. |
|
236 * |
|
237 */ |
|
238 #ifdef DISABLE_256_COLOR_PALETTE_SWITCHING |
|
239 |
|
240 EXPORT_C void DynamicPalette::SetColor256Util(DynamicPalette::TIndex /*aScheme*/) |
|
241 { |
|
242 } |
|
243 |
|
244 #else // DISABLE_256_COLOR_PALETTE_SWITCHING |
|
245 EXPORT_C void DynamicPalette::SetColor256Util(DynamicPalette::TIndex aScheme) |
|
246 { |
|
247 #ifndef __PALETTE_INDEX_ADDRESS_FIXED |
|
248 TSeries60ColorScheme* theScheme = (TSeries60ColorScheme*)Dll::Tls(); |
|
249 if (!theScheme) |
|
250 { |
|
251 TPckgBuf<TScreenInfoV01> info; |
|
252 UserSvr::ScreenInfo(info); |
|
253 TInt offset = VIDEO_MEMORY_SCHEME_OFFSET(DEVICE_VIDEO_PALETTE_SIZE, info().iScreenSize.iWidth, info().iScreenSize.iHeight, DEVICE_BYTES_PER_PIXEL); |
|
254 theScheme = (TSeries60ColorScheme*)(((TUint8*)info().iScreenAddress) + offset); |
|
255 Dll::SetTls(theScheme); |
|
256 } |
|
257 #endif |
|
258 *theScheme = (TSeries60ColorScheme)(aScheme); |
|
259 } |
|
260 #endif // DISABLE_256_COLOR_PALETTE_SWITCHING |
|
261 |
|
262 // End of File |