@@ -17,7 +17,9 @@ static EGLResult<EGLContext> CreateContext(EGLDisplay display, EGLConfig config,
17
17
EGLint attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2 , EGL_NONE};
18
18
19
19
EGLContext context = eglCreateContext (display, config, share, attributes);
20
-
20
+ if (context == EGL_NO_CONTEXT) {
21
+ LogLastEGLError ();
22
+ }
21
23
return {context != EGL_NO_CONTEXT, context};
22
24
}
23
25
@@ -41,6 +43,7 @@ static EGLResult<EGLConfig> ChooseEGLConfiguration(EGLDisplay display) {
41
43
42
44
if (eglChooseConfig (display, attributes, &egl_config, 1 , &config_count) !=
43
45
EGL_TRUE) {
46
+ LogLastEGLError ();
44
47
return {false , nullptr };
45
48
}
46
49
@@ -50,8 +53,10 @@ static EGLResult<EGLConfig> ChooseEGLConfiguration(EGLDisplay display) {
50
53
}
51
54
52
55
TizenEGLSurface::~TizenEGLSurface () {
53
- eglDestroySurface (tizen_native_egl_window_->GetEGLDisplayHandle (),
54
- egl_surface_);
56
+ if (eglDestroySurface (tizen_native_egl_window_->GetEGLDisplayHandle (),
57
+ egl_surface_) != EGL_TRUE) {
58
+ LogLastEGLError ();
59
+ }
55
60
tizen_native_egl_window_ = nullptr ;
56
61
}
57
62
@@ -81,45 +86,51 @@ TizenEGLContext::TizenEGLContext(
81
86
egl_resource_context_ = resource_ctx.second ;
82
87
}
83
88
84
- std::unique_ptr<TizenEGLSurface>
85
- TizenEGLContext::CreateTizenEGLWindowSurface () {
86
- const EGLint attribs[] = {EGL_NONE};
87
- EGLSurface surface = eglCreateWindowSurface (
88
- tizen_native_egl_window_->GetEGLDisplayHandle (), egl_config_,
89
- ecore_wl2_egl_window_native_get (
90
- tizen_native_egl_window_->GetEglWindowHandle ()),
91
- attribs);
92
-
93
- return std::make_unique<TizenEGLSurface>(tizen_native_egl_window_, surface);
94
- }
95
-
96
89
TizenEGLContext::~TizenEGLContext () {
97
90
if (eglDestroyContext (tizen_native_egl_window_->GetEGLDisplayHandle (),
98
91
egl_context_) != EGL_TRUE) {
99
92
FT_LOGE (" Failed to destroy egl context" );
93
+ LogLastEGLError ();
100
94
}
101
95
if (eglDestroyContext (tizen_native_egl_window_->GetEGLDisplayHandle (),
102
96
egl_resource_context_) != EGL_TRUE) {
103
97
FT_LOGE (" Failed to destroy egl resource context" );
98
+ LogLastEGLError ();
104
99
}
105
100
tizen_native_egl_window_ = nullptr ;
106
101
}
107
102
103
+ bool TizenEGLContext::IsValid () {
104
+ return tizen_native_egl_window_ && tizen_native_egl_window_->IsValid () &&
105
+ egl_config_ != nullptr && egl_context_ != EGL_NO_CONTEXT &&
106
+ egl_resource_context_ != EGL_NO_CONTEXT;
107
+ }
108
+
109
+ std::unique_ptr<TizenEGLSurface>
110
+ TizenEGLContext::CreateTizenEGLWindowSurface () {
111
+ const EGLint attribs[] = {EGL_NONE};
112
+ EGLSurface surface = eglCreateWindowSurface (
113
+ tizen_native_egl_window_->GetEGLDisplayHandle (), egl_config_,
114
+ ecore_wl2_egl_window_native_get (
115
+ tizen_native_egl_window_->GetEglWindowHandle ()),
116
+ attribs);
117
+ if (surface == EGL_NO_SURFACE) {
118
+ LogLastEGLError ();
119
+ }
120
+ return std::make_unique<TizenEGLSurface>(tizen_native_egl_window_, surface);
121
+ }
122
+
108
123
std::unique_ptr<TizenEGLSurface>
109
124
TizenEGLContext::CreateTizenEGLPbufferSurface () {
110
125
const EGLint attribs[] = {EGL_WIDTH, 1 , EGL_HEIGHT, 1 , EGL_NONE};
111
126
EGLSurface surface = eglCreatePbufferSurface (
112
127
tizen_native_egl_window_->GetEGLDisplayHandle (), egl_config_, attribs);
113
-
128
+ if (surface == EGL_NO_SURFACE) {
129
+ LogLastEGLError ();
130
+ }
114
131
return std::make_unique<TizenEGLSurface>(tizen_native_egl_window_, surface);
115
132
}
116
133
117
- bool TizenEGLContext::IsValid () {
118
- return tizen_native_egl_window_ && tizen_native_egl_window_->IsValid () &&
119
- egl_config_ != nullptr && egl_context_ != EGL_NO_CONTEXT &&
120
- egl_resource_context_ != EGL_NO_CONTEXT;
121
- }
122
-
123
134
TizenSurfaceGL::TizenSurfaceGL (
124
135
std::shared_ptr<TizenNativeWindow> tizen_native_window)
125
136
: tizen_native_window_(tizen_native_window) {
@@ -162,6 +173,7 @@ bool TizenSurfaceGL::OnMakeCurrent() {
162
173
tizen_egl_window_surface_->GetEGLSurfaceHandle (),
163
174
tizen_context_gl_->GetEGLContextHandle ()) != EGL_TRUE) {
164
175
FT_LOGE (" Could not make the onscreen context current" );
176
+ LogLastEGLError ();
165
177
return false ;
166
178
}
167
179
return true ;
@@ -179,6 +191,7 @@ bool TizenSurfaceGL::OnMakeResourceCurrent() {
179
191
tizen_context_gl_->GetEGLResourceContextHandle ()) !=
180
192
EGL_TRUE) {
181
193
FT_LOGE (" Could not make the offscreen context current" );
194
+ LogLastEGLError ();
182
195
return false ;
183
196
}
184
197
return true ;
@@ -195,6 +208,7 @@ bool TizenSurfaceGL::OnClearCurrent() {
195
208
EGL_NO_SURFACE, EGL_NO_SURFACE,
196
209
EGL_NO_CONTEXT) != EGL_TRUE) {
197
210
FT_LOGE (" Could not clear context" );
211
+ LogLastEGLError ();
198
212
return false ;
199
213
}
200
214
return true ;
@@ -211,6 +225,7 @@ bool TizenSurfaceGL::OnPresent() {
211
225
tizen_egl_window_surface_->GetEGLSurfaceHandle ()) !=
212
226
EGL_TRUE) {
213
227
FT_LOGE (" Could not swap EGl buffer" );
228
+ LogLastEGLError ();
214
229
return false ;
215
230
}
216
231
return true ;
@@ -348,16 +363,9 @@ void* TizenSurfaceGL::OnProcResolver(const char* name) {
348
363
#undef GL_FUNC
349
364
350
365
TizenSurfaceGL::~TizenSurfaceGL () {
366
+ OnClearCurrent ();
351
367
tizen_egl_window_surface_ = nullptr ;
352
368
tizen_egl_pbuffer_surface_ = nullptr ;
353
369
tizen_context_gl_ = nullptr ;
354
370
tizen_native_window_ = nullptr ;
355
371
}
356
-
357
- void TizenSurfaceGL::SetSize (int32_t width, int32_t height) {
358
- // FIXME : I think we have to find another way.
359
- FT_LOGD (" Resize egl window %d %d" , width, height);
360
- ecore_wl2_egl_window_resize_with_rotation (
361
- tizen_native_window_->GetTizenNativeEGLWindow ()->GetEglWindowHandle (), 0 ,
362
- 0 , width, height, 0 );
363
- }
0 commit comments