Skip to content

Commit

Permalink
Switch to use SbWindowGetDisplayHandle
Browse files Browse the repository at this point in the history
b/157237252
  • Loading branch information
kaidokert committed Mar 24, 2024
1 parent 8b62f4a commit d4650d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cobalt/renderer/backend/egl/graphics_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,18 @@ GraphicsSystemEGL::GraphicsSystemEGL(
glimp::SetTraceEventImplementation(&s_glimp_to_base_trace_event_bridge);
#endif // #if defined(ENABLE_GLIMP_TRACING)

#if STARBOARD >= 16
display _ = SbWindowGetDisplayHandle(window_);
// Fall back to SB_EGL_DEFAULT_DISPLAY
if (SB_EGL_NO_DISPLAY != display_) {
display_ = EGL_CALL_SIMPLE(eglGetDisplay(SB_EGL_DEFAULT_DISPLAY));
SB_CHECK(SB_EGL_SUCCESS == EGL_CALL_SIMPLE(eglGetError()));
}
#else
display_ = EGL_CALL_SIMPLE(eglGetDisplay(EGL_DEFAULT_DISPLAY));
CHECK_NE(EGL_NO_DISPLAY, display_);
CHECK_EQ(EGL_SUCCESS, EGL_CALL_SIMPLE(eglGetError()));
#endif
CHECK_NE(EGL_NO_DISPLAY, display_);

{
// Despite eglTerminate() being used in the destructor, the current
Expand Down
9 changes: 9 additions & 0 deletions starboard/examples/glclear/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,17 @@ Application::Application() {
window_ = SbWindowCreate(&options);
SB_CHECK(SbWindowIsValid(window_));

#if STARBOARD >= 16
display _ = SbWindowGetDisplayHandle(window_);
// Fall back to SB_EGL_DEFAULT_DISPLAY
if (SB_EGL_NO_DISPLAY != display_) {
display_ = EGL_CALL_SIMPLE(eglGetDisplay(SB_EGL_DEFAULT_DISPLAY));
SB_CHECK(SB_EGL_SUCCESS == EGL_CALL_SIMPLE(eglGetError()));
}
#else
display_ = EGL_CALL_SIMPLE(eglGetDisplay(SB_EGL_DEFAULT_DISPLAY));
SB_CHECK(SB_EGL_SUCCESS == EGL_CALL_SIMPLE(eglGetError()));
#endif
SB_CHECK(SB_EGL_NO_DISPLAY != display_);

EGL_CALL(eglInitialize(display_, NULL, NULL));
Expand Down

0 comments on commit d4650d3

Please sign in to comment.