107 CEglDriver* drv = CEglDriver::GetDriver(); |
103 CEglDriver* drv = CEglDriver::GetDriver(); |
108 __ASSERT_DEBUG(drv, User::Panic(KEglPanicCategory, EEglPanicDriverNull)); |
104 __ASSERT_DEBUG(drv, User::Panic(KEglPanicCategory, EEglPanicDriverNull)); |
109 |
105 |
110 // create session object on default thread's heap |
106 // create session object on default thread's heap |
111 es = new CEglThreadSession(*drv); |
107 es = new CEglThreadSession(*drv); |
112 RDebug::Printf("In CEglThreadSession::Static(),CEglThreadSession Addr of CEglThreadSession Ptr = %x\n", &es); |
|
113 RDebug::Printf("In CEglThreadSession::Static(),CEglThreadSession Addr of CEglThreadSession= %x\n", es); |
|
114 //RDebug::Printf("In CEglThreadSession::Static(),Thread Id %Lu",(RThread().Id().Id())); |
|
115 RDebug::Printf("In CEglThreadSession::Static(),Thread Id %Lu",(RThread().Id())); |
|
116 if (!es || Dll::SetTls(es)!= KErrNone) |
108 if (!es || Dll::SetTls(es)!= KErrNone) |
117 { |
109 { |
118 delete es; |
110 delete es; |
119 return NULL; |
111 return NULL; |
120 } |
112 } |
181 if (err != KErrNone) |
173 if (err != KErrNone) |
182 { |
174 { |
183 SetError(EGL_NOT_INITIALIZED); |
175 SetError(EGL_NOT_INITIALIZED); |
184 return EGL_FALSE; |
176 return EGL_FALSE; |
185 } |
177 } |
|
178 |
186 EGL* pEgl = NULL; |
179 EGL* pEgl = NULL; |
187 pEgl = new EGL(); |
180 |
188 |
181 try |
189 iEgl = pEgl; |
182 { |
|
183 pEgl = new EGL(); |
|
184 iEgl = pEgl; |
|
185 } |
|
186 catch(std::bad_alloc) |
|
187 { |
|
188 SetError(EGL_BAD_ALLOC); |
|
189 return EGL_FALSE; |
|
190 } |
190 |
191 |
191 RIEGLDisplay* Egldisplay = iEgl->getDisplay(aDisplay); |
192 RIEGLDisplay* Egldisplay = iEgl->getDisplay(aDisplay); |
192 //create the current display |
193 //create the current display |
193 //if a context and a surface are bound by the time of eglTerminate, they remain bound until eglMakeCurrent is called |
194 |
194 RIEGLDisplay* newDisplay = NULL; |
195 RIEGLDisplay* newDisplay = NULL; |
195 try |
196 try |
196 { |
197 { |
197 newDisplay = new RIEGLDisplay(aDisplay); //throws bad_alloc |
198 newDisplay = new RIEGLDisplay(aDisplay); //throws bad_alloc |
198 iEgl->addDisplay(newDisplay); //throws bad_alloc |
199 iEgl->addDisplay(newDisplay); //throws bad_alloc |
199 Egldisplay = newDisplay; |
200 Egldisplay = newDisplay; |
200 RI_ASSERT(Egldisplay); |
201 RI_ASSERT(Egldisplay); |
201 } |
202 } |
202 catch(std::bad_alloc) |
203 catch(std::bad_alloc) |
203 { |
204 { |
|
205 RI_DELETE(pEgl); |
204 RI_DELETE(newDisplay); |
206 RI_DELETE(newDisplay); |
205 // EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE); //TODO Need to enable this later. Jose |
207 SetError(EGL_BAD_DISPLAY); |
206 } |
208 return EGL_FALSE; |
207 |
209 } |
208 //need to think of deleting egl if anything goes wrong. |
210 |
209 if (aMajor) |
211 if (aMajor) |
210 { |
212 { |
211 *aMajor = KEglMajorVersion; |
213 *aMajor = KEglMajorVersion; |
212 } |
214 } |
213 if (aMinor) |
215 if (aMinor) |