|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Creates converters. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 |
|
23 #include "CMIDConvertFactory.h" |
|
24 |
|
25 #include "TMID4444Format.h" |
|
26 #include "TMID444Format.h" |
|
27 #include "TMID565Format.h" |
|
28 #include "TMID8888Format.h" |
|
29 #include "TMID888Format.h" |
|
30 #include "TMID888AFormat.h" |
|
31 #include "TMIDGray1.h" |
|
32 #include "TMIDGray1Vertical.h" |
|
33 |
|
34 |
|
35 CMIDConvertFactory::CMIDConvertFactory() |
|
36 { |
|
37 } |
|
38 |
|
39 CMIDConvertFactory::~CMIDConvertFactory() |
|
40 { |
|
41 delete iLastUsedConverter; |
|
42 } |
|
43 |
|
44 TMIDFormatConverter* CMIDConvertFactory::ConverterL(TInt aFormat) |
|
45 { |
|
46 if (aFormat != iFormat) |
|
47 { |
|
48 TMIDFormatConverter* converter = NewConverterL(aFormat); |
|
49 delete iLastUsedConverter; |
|
50 iLastUsedConverter = converter; |
|
51 iFormat = aFormat; |
|
52 } |
|
53 return iLastUsedConverter; |
|
54 } |
|
55 |
|
56 TMIDFormatConverter* CMIDConvertFactory::NewConverterL(TInt aFormat) |
|
57 { |
|
58 switch (aFormat) |
|
59 { |
|
60 case KMIDTypeUshort4444ARGB: |
|
61 { |
|
62 return new(ELeave)TMID4444Format(); |
|
63 } |
|
64 case KMIDTypeUshort444RGB: |
|
65 { |
|
66 return new(ELeave)TMID444Format(); |
|
67 } |
|
68 case KMIDTypeUshort565RGB: |
|
69 { |
|
70 return new(ELeave)TMID565Format(); |
|
71 } |
|
72 case KMIDTypeInt8888ARGB: |
|
73 { |
|
74 return new(ELeave)TMID8888Format(); |
|
75 } |
|
76 case KMIDTypeInt888RGB: |
|
77 { |
|
78 return new(ELeave)TMID888Format(); |
|
79 } |
|
80 case KMIDTypeInt888ARGB: |
|
81 { |
|
82 return new(ELeave)TMID888AFormat(); |
|
83 } |
|
84 case KMIDTypeByte1Gray: |
|
85 { |
|
86 return new(ELeave)TMIDGray1(); |
|
87 } |
|
88 case KMIDTypeByte1GrayVertical: |
|
89 { |
|
90 return new(ELeave)TMIDGray1Vertical(); |
|
91 } |
|
92 default: |
|
93 { |
|
94 User::Leave(KFormatNotSupported); |
|
95 } |
|
96 } |
|
97 // not possible to come here. |
|
98 ASSERT(false); |
|
99 return NULL; |
|
100 } |
|
101 |
|
102 TInt CMIDConvertFactory::GetPixelFormat(const TDisplayMode& aDisplayMode) |
|
103 { |
|
104 TInt nativePixelFormat(KFormatNotSupported); |
|
105 switch (aDisplayMode) |
|
106 { |
|
107 case EGray2: |
|
108 { |
|
109 nativePixelFormat = KMIDTypeByte1Gray; |
|
110 break; |
|
111 } |
|
112 case EColor64K: |
|
113 { |
|
114 nativePixelFormat = KMIDTypeUshort565RGB; |
|
115 break; |
|
116 } |
|
117 case EColor16MA: |
|
118 case EColor16M: |
|
119 { |
|
120 nativePixelFormat = KMIDTypeInt8888ARGB; |
|
121 break; |
|
122 } |
|
123 case ERgb: |
|
124 { |
|
125 nativePixelFormat = KMIDTypeInt888RGB; |
|
126 break; |
|
127 } |
|
128 case EColor4K: |
|
129 { |
|
130 nativePixelFormat = KMIDTypeUshort4444ARGB; |
|
131 break; |
|
132 } |
|
133 case EColor16MU: |
|
134 { |
|
135 nativePixelFormat = KMIDTypeInt888RGB; |
|
136 break; |
|
137 } |
|
138 default: |
|
139 { |
|
140 nativePixelFormat = KFormatNotSupported; |
|
141 break; |
|
142 } |
|
143 } |
|
144 return nativePixelFormat; |
|
145 } |