Fix crash disabling GPU acceleration on Skia/Win port

This commit is contained in:
David Capello 2015-12-28 15:56:41 -03:00
parent 49ad91dd79
commit a43f7cfa66
3 changed files with 21 additions and 2 deletions

View File

@ -23,7 +23,8 @@ SkiaDisplay::SkiaDisplay(int width, int height, int scale)
, m_customSurface(false) , m_customSurface(false)
, m_nativeCursor(kArrowCursor) , m_nativeCursor(kArrowCursor)
{ {
m_surface->create(width, height); m_surface->create(width / scale,
height / scale);
m_window.setScale(scale); m_window.setScale(scale);
m_window.setVisible(true); m_window.setVisible(true);
} }
@ -35,6 +36,19 @@ void SkiaDisplay::setSkiaSurface(SkiaSurface* surface)
m_customSurface = true; m_customSurface = true;
} }
void SkiaDisplay::resetSkiaSurface()
{
if (m_surface) {
m_surface->dispose();
m_surface = nullptr;
}
gfx::Size size = m_window.clientSize() / m_window.scale();
m_surface = new SkiaSurface;
m_surface->create(size.w, size.h);
m_customSurface = false;
}
void SkiaDisplay::resize(const gfx::Size& size) void SkiaDisplay::resize(const gfx::Size& size)
{ {
Event ev; Event ev;

View File

@ -21,6 +21,7 @@ public:
SkiaDisplay(int width, int height, int scale); SkiaDisplay(int width, int height, int scale);
void setSkiaSurface(SkiaSurface* surface); void setSkiaSurface(SkiaSurface* surface);
void resetSkiaSurface();
void resize(const gfx::Size& size); void resize(const gfx::Size& size);
void dispose() override; void dispose() override;

View File

@ -10,6 +10,7 @@
#include "she/skia/skia_window_win.h" #include "she/skia/skia_window_win.h"
#include "base/log.h"
#include "she/event_queue.h" #include "she/event_queue.h"
#include "she/skia/skia_display.h" #include "she/skia/skia_display.h"
#include "she/system.h" #include "she/system.h"
@ -157,7 +158,7 @@ bool SkiaWindow::attachGL()
(GrBackendContext)m_glCtx->gl())); (GrBackendContext)m_glCtx->gl()));
} }
catch (const std::exception& ex) { catch (const std::exception& ex) {
//LOG("Cannot create GL context: %s\n", ex.what()); LOG("Cannot create GL context: %s\n", ex.what());
detachGL(); detachGL();
} }
} }
@ -179,6 +180,9 @@ bool SkiaWindow::attachANGLE()
void SkiaWindow::detachGL() void SkiaWindow::detachGL()
{ {
if (m_glCtx && m_display)
m_display->resetSkiaSurface();
m_skSurfaceDirect.reset(nullptr); m_skSurfaceDirect.reset(nullptr);
m_skSurface.reset(nullptr); m_skSurface.reset(nullptr);
m_grRenderTarget.reset(nullptr); m_grRenderTarget.reset(nullptr);