|
1 // glinfo.cpp |
|
2 // |
|
3 // Copyright (c) 2009 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <fshell/ioutils.h> |
|
14 #include <egl/egl.h> |
|
15 #include <vg/openvg.h> |
|
16 #include <fshell/common.mmh> |
|
17 |
|
18 using namespace IoUtils; |
|
19 |
|
20 class CCmdGlInfo : public CCommandBase |
|
21 { |
|
22 public: |
|
23 static CCommandBase* NewLC(); |
|
24 ~CCmdGlInfo(); |
|
25 private: |
|
26 CCmdGlInfo(); |
|
27 |
|
28 #ifdef FSHELL_EGL_SUPPORT |
|
29 void PrintElgInfoL(); |
|
30 void PrintElgQueryString(EGLDisplay aDisplay, EGLint aName, const TDesC8& aSymbol); |
|
31 #endif // FSHELL_EGL_SUPPORT |
|
32 |
|
33 #ifdef FSHELL_OPENVG_SUPPORT |
|
34 void PrintOpenVgInfoL(); |
|
35 void PrintOpenVgString(VGStringID aName, const TDesC8& aSymbol); |
|
36 #endif // FSHELL_OPENVG_SUPPORT |
|
37 |
|
38 private: // From CCommandBase. |
|
39 virtual const TDesC& Name() const; |
|
40 virtual void DoRunL(); |
|
41 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
42 virtual void OptionsL(RCommandOptionList& aOptions); |
|
43 private: |
|
44 enum |
|
45 { |
|
46 ELibEgl, |
|
47 ELibOpenVg |
|
48 } iLibrary; |
|
49 }; |
|
50 |
|
51 |
|
52 CCommandBase* CCmdGlInfo::NewLC() |
|
53 { |
|
54 CCmdGlInfo* self = new(ELeave) CCmdGlInfo(); |
|
55 CleanupStack::PushL(self); |
|
56 self->BaseConstructL(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 CCmdGlInfo::~CCmdGlInfo() |
|
61 { |
|
62 } |
|
63 |
|
64 CCmdGlInfo::CCmdGlInfo() |
|
65 { |
|
66 } |
|
67 |
|
68 #ifdef FSHELL_EGL_SUPPORT |
|
69 |
|
70 void CCmdGlInfo::PrintElgInfoL() |
|
71 { |
|
72 EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
|
73 EGLint major; |
|
74 EGLint minor; |
|
75 if (!eglInitialize(dpy, &major, &minor)) |
|
76 { |
|
77 LeaveIfErr(KErrGeneral, _L("Couldn't initialize EGL display")); |
|
78 } |
|
79 PrintElgQueryString(dpy, EGL_CLIENT_APIS, _L8("EGL_CLIENT_APIS")); |
|
80 PrintElgQueryString(dpy, EGL_EXTENSIONS, _L8("EGL_EXTENSIONS")); |
|
81 PrintElgQueryString(dpy, EGL_VENDOR, _L8("EGL_VENDOR")); |
|
82 PrintElgQueryString(dpy, EGL_VERSION, _L8("EGL_VERSION")); |
|
83 if (!eglTerminate(dpy)) |
|
84 { |
|
85 LeaveIfErr(KErrGeneral, _L("Couldn't terminate EGL display")); |
|
86 } |
|
87 } |
|
88 |
|
89 void CCmdGlInfo::PrintElgQueryString(EGLDisplay aDisplay, EGLint aName, const TDesC8& aSymbol) |
|
90 { |
|
91 const char* string = eglQueryString(aDisplay, aName); |
|
92 if (string == NULL) |
|
93 { |
|
94 string = "Unknown"; |
|
95 } |
|
96 Printf(_L8("%S: %s\r\n"), &aSymbol, string); |
|
97 } |
|
98 |
|
99 #endif // FSHELL_EGL_SUPPORT |
|
100 |
|
101 #ifdef FSHELL_OPENVG_SUPPORT |
|
102 |
|
103 void CCmdGlInfo::PrintOpenVgInfoL() |
|
104 { |
|
105 PrintOpenVgString(VG_VENDOR, _L8("VG_VENDOR")); |
|
106 PrintOpenVgString(VG_RENDERER, _L8("VG_RENDERER")); |
|
107 PrintOpenVgString(VG_EXTENSIONS, _L8("VG_EXTENSIONS")); |
|
108 PrintOpenVgString(VG_VERSION, _L8("VG_VERSION")); |
|
109 } |
|
110 |
|
111 void CCmdGlInfo::PrintOpenVgString(VGStringID aName, const TDesC8& aSymbol) |
|
112 { |
|
113 const VGubyte* string = vgGetString(aName); |
|
114 if (string == NULL) |
|
115 { |
|
116 string = (const VGubyte*)"Unknown"; |
|
117 } |
|
118 Printf(_L8("%S: %s\r\n"), &aSymbol, string); |
|
119 } |
|
120 |
|
121 #endif // FSHELL_OPENVG_SUPPORT |
|
122 |
|
123 const TDesC& CCmdGlInfo::Name() const |
|
124 { |
|
125 _LIT(KName, "glinfo"); |
|
126 return KName; |
|
127 } |
|
128 |
|
129 void CCmdGlInfo::DoRunL() |
|
130 { |
|
131 switch (iLibrary) |
|
132 { |
|
133 #ifdef FSHELL_EGL_SUPPORT |
|
134 case ELibEgl: |
|
135 { |
|
136 PrintElgInfoL(); |
|
137 break; |
|
138 } |
|
139 #endif // FSHELL_EGL_SUPPORT |
|
140 #ifdef FSHELL_OPENVG_SUPPORT |
|
141 case ELibOpenVg: |
|
142 { |
|
143 PrintOpenVgInfoL(); |
|
144 break; |
|
145 } |
|
146 #endif // FSHELL_OPENVG_SUPPORT |
|
147 default: |
|
148 { |
|
149 User::Leave(KErrNotSupported); |
|
150 } |
|
151 } |
|
152 } |
|
153 |
|
154 void CCmdGlInfo::ArgumentsL(RCommandArgumentList& aArguments) |
|
155 { |
|
156 _LIT(KArgLibrary, "library"); |
|
157 aArguments.AppendEnumL((TInt&)iLibrary, KArgLibrary); |
|
158 } |
|
159 |
|
160 void CCmdGlInfo::OptionsL(RCommandOptionList&) |
|
161 { |
|
162 } |
|
163 |
|
164 |
|
165 EXE_BOILER_PLATE(CCmdGlInfo) |
|
166 |