mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 06:32:42 +00:00
Avoid deleting two times the direct SkSurface
This commit is contained in:
parent
9c653ef86e
commit
87e5be45a9
@ -39,6 +39,7 @@ SkiaWindow::SkiaWindow(EventQueue* queue, SkiaDisplay* display,
|
||||
, m_display(display)
|
||||
, m_backend(Backend::NONE)
|
||||
#if SK_SUPPORT_GPU
|
||||
, m_skSurface(nullptr)
|
||||
, m_sampleCount(0)
|
||||
, m_stencilBits(0)
|
||||
#endif
|
||||
@ -191,8 +192,8 @@ void SkiaWindow::detachGL()
|
||||
if (m_glCtx && m_display)
|
||||
m_display->resetSkiaSurface();
|
||||
|
||||
setSurface(nullptr);
|
||||
m_skSurfaceDirect.reset(nullptr);
|
||||
m_skSurface.reset(nullptr);
|
||||
m_grRenderTarget.reset(nullptr);
|
||||
m_grCtx.reset(nullptr);
|
||||
m_glCtx.reset(nullptr);
|
||||
@ -212,14 +213,16 @@ void SkiaWindow::createRenderTarget(const gfx::Size& size)
|
||||
desc.fStencilBits = m_stencilBits;
|
||||
desc.fRenderTargetHandle = 0; // direct frame buffer
|
||||
m_grRenderTarget.reset(m_grCtx->textureProvider()->wrapBackendRenderTarget(desc));
|
||||
|
||||
setSurface(nullptr); // set m_skSurface comparing with the old m_skSurfaceDirect
|
||||
m_skSurfaceDirect.reset(
|
||||
SkSurface::NewRenderTargetDirect(m_grRenderTarget));
|
||||
|
||||
if (scale == 1) {
|
||||
m_skSurface.reset(m_skSurfaceDirect);
|
||||
setSurface(m_skSurfaceDirect);
|
||||
}
|
||||
else {
|
||||
m_skSurface.reset(
|
||||
setSurface(
|
||||
SkSurface::NewRenderTarget(
|
||||
m_grCtx,
|
||||
SkSurface::kYes_Budgeted,
|
||||
@ -234,6 +237,13 @@ void SkiaWindow::createRenderTarget(const gfx::Size& size)
|
||||
m_display->setSkiaSurface(new SkiaSurface(m_skSurface));
|
||||
}
|
||||
|
||||
void SkiaWindow::setSurface(SkSurface* surface)
|
||||
{
|
||||
if (m_skSurface && m_skSurface != m_skSurfaceDirect)
|
||||
delete m_skSurface;
|
||||
m_skSurface = surface;
|
||||
}
|
||||
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
void SkiaWindow::resizeImpl(const gfx::Size& size)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// SHE library
|
||||
// Copyright (C) 2012-2015 David Capello
|
||||
// Copyright (C) 2012-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -45,6 +45,7 @@ private:
|
||||
#endif // SK_ANGLE
|
||||
void detachGL();
|
||||
void createRenderTarget(const gfx::Size& size);
|
||||
void setSurface(SkSurface* surface);
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
EventQueue* m_queue;
|
||||
@ -55,7 +56,7 @@ private:
|
||||
SkAutoTUnref<GrContext> m_grCtx;
|
||||
SkAutoTUnref<GrRenderTarget> m_grRenderTarget;
|
||||
SkAutoTDelete<SkSurface> m_skSurfaceDirect;
|
||||
SkAutoTDelete<SkSurface> m_skSurface;
|
||||
SkSurface* m_skSurface;
|
||||
int m_sampleCount;
|
||||
int m_stencilBits;
|
||||
gfx::Size m_lastSize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user