107 CEglDriver* drv = CEglDriver::GetDriver(); |
104 CEglDriver* drv = CEglDriver::GetDriver(); |
108 __ASSERT_DEBUG(drv, User::Panic(KEglPanicCategory, EEglPanicDriverNull)); |
105 __ASSERT_DEBUG(drv, User::Panic(KEglPanicCategory, EEglPanicDriverNull)); |
109 |
106 |
110 // create session object on default thread's heap |
107 // create session object on default thread's heap |
111 es = new CEglThreadSession(*drv); |
108 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) |
109 if (!es || Dll::SetTls(es)!= KErrNone) |
117 { |
110 { |
118 delete es; |
111 delete es; |
119 return NULL; |
112 return NULL; |
120 } |
113 } |
181 if (err != KErrNone) |
174 if (err != KErrNone) |
182 { |
175 { |
183 SetError(EGL_NOT_INITIALIZED); |
176 SetError(EGL_NOT_INITIALIZED); |
184 return EGL_FALSE; |
177 return EGL_FALSE; |
185 } |
178 } |
|
179 |
186 EGL* pEgl = NULL; |
180 EGL* pEgl = NULL; |
187 pEgl = new EGL(); |
181 |
188 |
182 try |
189 iEgl = pEgl; |
183 { |
190 |
184 pEgl = new EGL(); |
191 RIEGLDisplay* Egldisplay = iEgl->getDisplay(aDisplay); |
185 iEgl = pEgl; |
|
186 } |
|
187 catch(std::bad_alloc) |
|
188 { |
|
189 SetError(EGL_BAD_ALLOC); |
|
190 return EGL_FALSE; |
|
191 } |
|
192 |
|
193 RIEGLDisplay* eglDispaly = iEgl->getDisplay(aDisplay); |
|
194 if(eglDispaly) |
|
195 return EGL_TRUE; |
|
196 |
192 //create the current display |
197 //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 |
198 RIEGLDisplay* newDisplay = NULL; |
194 RIEGLDisplay* newDisplay = NULL; |
|
195 try |
199 try |
196 { |
200 { |
197 newDisplay = new RIEGLDisplay(aDisplay); //throws bad_alloc |
201 newDisplay = new RIEGLDisplay(aDisplay); //throws bad_alloc |
198 iEgl->addDisplay(newDisplay); //throws bad_alloc |
202 iEgl->addDisplay(newDisplay); //throws bad_alloc |
199 Egldisplay = newDisplay; |
203 eglDispaly = newDisplay; |
200 RI_ASSERT(Egldisplay); |
204 RI_ASSERT(eglDispaly); |
201 } |
205 } |
202 catch(std::bad_alloc) |
206 catch(std::bad_alloc) |
203 { |
207 { |
|
208 RI_DELETE(iEgl); |
|
209 iEgl = NULL; |
204 RI_DELETE(newDisplay); |
210 RI_DELETE(newDisplay); |
205 // EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE); //TODO Need to enable this later. Jose |
211 SetError(EGL_BAD_DISPLAY); |
206 } |
212 return EGL_FALSE; |
207 |
213 } |
208 //need to think of deleting egl if anything goes wrong. |
214 |
209 if (aMajor) |
215 if (aMajor) |
210 { |
216 { |
211 *aMajor = KEglMajorVersion; |
217 *aMajor = KEglMajorVersion; |
212 } |
218 } |
213 if (aMinor) |
219 if (aMinor) |