mirror of
https://github.com/aseprite/aseprite.git
synced 2024-11-20 14:21:45 +00:00
Catch exceptions if GL context cannot be created on Skia/OSX
This commit is contained in:
parent
72965b14d2
commit
2e5f051e7d
@ -37,7 +37,10 @@ public:
|
||||
int width, int height, int scale)
|
||||
: m_display(display)
|
||||
, m_backend(Backend::NONE)
|
||||
, m_nsGL(nil) {
|
||||
#if SK_SUPPORT_GPU
|
||||
, m_nsGL(nil)
|
||||
#endif
|
||||
{
|
||||
m_closing = false;
|
||||
m_window = [[OSXWindow alloc] initWithImpl:this
|
||||
width:width
|
||||
@ -166,24 +169,33 @@ public:
|
||||
}
|
||||
|
||||
void onWindowChanged() override {
|
||||
#ifdef SK_SUPPORT_GPU
|
||||
if (m_nsGL)
|
||||
[m_nsGL setView:[m_window contentView]];
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
#if SK_SUPPORT_GPU
|
||||
bool attachGL() {
|
||||
if (!m_glCtx) {
|
||||
auto ctx = new GLContextSkia<GLContextCGL>(nullptr);
|
||||
try {
|
||||
auto ctx = new GLContextSkia<GLContextCGL>(nullptr);
|
||||
|
||||
m_glCtx.reset(ctx);
|
||||
m_grCtx.reset(GrContext::Create(kOpenGL_GrBackend,
|
||||
(GrBackendContext)m_glCtx->gl()));
|
||||
m_glCtx.reset(ctx);
|
||||
m_grCtx.reset(GrContext::Create(kOpenGL_GrBackend,
|
||||
(GrBackendContext)m_glCtx->gl()));
|
||||
|
||||
m_nsGL = [[NSOpenGLContext alloc]
|
||||
initWithCGLContextObj:m_glCtx->cglContext()];
|
||||
m_nsGL = [[NSOpenGLContext alloc]
|
||||
initWithCGLContextObj:m_glCtx->cglContext()];
|
||||
|
||||
[m_nsGL setView:[m_window contentView]];
|
||||
[m_nsGL setView:m_window.contentView];
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
LOG("Cannot create GL context: %s\n", ex.what());
|
||||
detachGL();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user