equal
deleted
inserted
replaced
24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #include "hbsgimagerenderer_p.h" |
26 #include "hbsgimagerenderer_p.h" |
27 #include "hbnvg_p.h" |
27 #include "hbnvg_p.h" |
28 |
28 |
|
29 #include <sgresource/sgerror.h> |
29 #include <QDebug> |
30 #include <QDebug> |
30 QHash<unsigned long long, RSgImage*> HbSgImageRenderer::sgImageHash; |
31 QHash<unsigned long long, RSgImage*> HbSgImageRenderer::sgImageHash; |
31 |
32 |
32 Q_GLOBAL_STATIC(HbSgImageRenderer, instance) |
33 Q_GLOBAL_STATIC(HbSgImageRenderer, instance) |
33 |
34 |
79 } |
80 } |
80 engine = new HbNvgEngine; |
81 engine = new HbNvgEngine; |
81 } |
82 } |
82 |
83 |
83 init = true; |
84 init = true; |
|
85 errorCode = KErrNone; |
84 return true; |
86 return true; |
85 } |
87 } |
86 |
88 |
87 void HbSgImageRenderer::terminate() |
89 void HbSgImageRenderer::terminate() |
88 { |
90 { |
99 eglReleaseThread(); |
101 eglReleaseThread(); |
100 display = EGL_NO_DISPLAY; |
102 display = EGL_NO_DISPLAY; |
101 delete engine; |
103 delete engine; |
102 engine = 0; |
104 engine = 0; |
103 init = false; |
105 init = false; |
|
106 errorCode = KErrNone; |
104 } |
107 } |
105 } |
108 } |
106 |
109 |
107 bool HbSgImageRenderer::createContext(RSgImage * sgImage) |
110 bool HbSgImageRenderer::createContext(RSgImage * sgImage) |
108 { |
111 { |
121 if (eglChooseConfig(display, KConfigAttributes, &eglConfig, 1, &numConfigs) == EGL_FALSE) { |
124 if (eglChooseConfig(display, KConfigAttributes, &eglConfig, 1, &numConfigs) == EGL_FALSE) { |
122 return false; |
125 return false; |
123 } |
126 } |
124 |
127 |
125 eglContext = eglCreateContext(display, eglConfig, EGL_NO_CONTEXT, 0); |
128 eglContext = eglCreateContext(display, eglConfig, EGL_NO_CONTEXT, 0); |
126 |
129 if ( eglContext == EGL_NO_CONTEXT ) { |
|
130 if ((eglGetError() == EGL_BAD_ALLOC)) { |
|
131 setLastError(KErrNoGraphicsMemory); |
|
132 } |
|
133 } |
127 return eglContext != EGL_NO_CONTEXT; |
134 return eglContext != EGL_NO_CONTEXT; |
128 } |
135 } |
129 |
136 |
130 bool HbSgImageRenderer::beginRendering(RSgImage * sgImage) |
137 bool HbSgImageRenderer::beginRendering(RSgImage * sgImage) |
131 { |
138 { |
138 EGL_NONE |
145 EGL_NONE |
139 }; |
146 }; |
140 |
147 |
141 currentSurface = eglCreatePixmapSurface(display, eglConfig, sgImage, KPixmapAttributes); |
148 currentSurface = eglCreatePixmapSurface(display, eglConfig, sgImage, KPixmapAttributes); |
142 if (currentSurface == EGL_NO_SURFACE) { |
149 if (currentSurface == EGL_NO_SURFACE) { |
|
150 if ((eglGetError() == EGL_BAD_ALLOC)){ |
|
151 setLastError(KErrNoGraphicsMemory); |
|
152 } |
143 return false; |
153 return false; |
144 } |
154 } |
145 |
155 |
146 if (eglMakeCurrent(display, currentSurface, currentSurface, eglContext) == EGL_FALSE) { |
156 if (eglMakeCurrent(display, currentSurface, currentSurface, eglContext) == EGL_FALSE) { |
147 eglDestroySurface(display, currentSurface); |
157 eglDestroySurface(display, currentSurface); |
176 sgImage->Close(); |
186 sgImage->Close(); |
177 delete sgImage; |
187 delete sgImage; |
178 sgImageHash.remove(id); |
188 sgImageHash.remove(id); |
179 } |
189 } |
180 } |
190 } |
181 |
191 int HbSgImageRenderer::lastError() |
182 #ifdef HB_ICON_CACHE_DEBUG |
192 { |
|
193 return errorCode; |
|
194 } |
|
195 void HbSgImageRenderer::setLastError(int lastError) |
|
196 { |
|
197 errorCode = lastError; |
|
198 } |
|
199 |
183 unsigned long HbSgImageRenderer::totalGPUMemory() |
200 unsigned long HbSgImageRenderer::totalGPUMemory() |
184 { |
201 { |
185 qDebug() <<"Inside HbSgImageRenderer::totalGPUMemory() " ; |
202 qDebug() <<"Inside HbSgImageRenderer::totalGPUMemory() " ; |
186 EGLint data_count; |
203 EGLint data_count; |
187 |
204 |
314 return 0; |
331 return 0; |
315 } |
332 } |
316 |
333 |
317 return prof_data; |
334 return prof_data; |
318 } |
335 } |
319 #endif //HB_ICON_CACHE_DEBUG |
|