⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283299 in webkit


Ignore:
Timestamp:
Sep 29, 2021, 10:17:38 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Cocoa GraphicsContextGLOpenGL should be more robust in destruction
https://bugs.webkit.org/show_bug.cgi?id=230940

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-09-29
Reviewed by Antti Koivisto.

Delete resources based on checking if they exist, not based on
a flag that should cause them to exist. Currently the constructor can return early,
so various resources might not exist even if their flag condition would
indicate they should.

No new tests, refactor.

  • platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:

(WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r283296 r283299  
     12021-09-29  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        Cocoa GraphicsContextGLOpenGL should be more robust in destruction
     4        https://bugs.webkit.org/show_bug.cgi?id=230940
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Delete resources based on checking if they exist, not based on
     9        a flag that should cause them to exist. Currently the constructor can return early,
     10        so various resources might not exist even if their flag condition would
     11        indicate they should.
     12
     13        No new tests, refactor.
     14
     15        * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
     16        (WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):
     17
    1182021-09-29  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm

    r283238 r283299  
    430430    GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
    431431    if (makeContextCurrent()) {
    432         GraphicsContextGLAttributes attrs = contextAttributes();
    433         gl::DeleteTextures(1, &m_texture);
    434 
    435         if (attrs.antialias) {
     432        if (m_texture)
     433            gl::DeleteTextures(1, &m_texture);
     434        if (m_multisampleColorBuffer)
    436435            gl::DeleteRenderbuffers(1, &m_multisampleColorBuffer);
    437             if (attrs.stencil || attrs.depth)
    438                 gl::DeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
     436        if (m_multisampleDepthStencilBuffer)
     437            gl::DeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
     438        if (m_multisampleFBO)
    439439            gl::DeleteFramebuffers(1, &m_multisampleFBO);
    440         } else {
    441             if (attrs.stencil || attrs.depth)
    442                 gl::DeleteRenderbuffers(1, &m_depthStencilBuffer);
    443         }
    444         gl::DeleteFramebuffers(1, &m_fbo);
     440        if (m_depthStencilBuffer)
     441            gl::DeleteRenderbuffers(1, &m_depthStencilBuffer);
     442        if (m_fbo)
     443            gl::DeleteFramebuffers(1, &m_fbo);
    445444        if (m_preserveDrawingBufferTexture)
    446445            gl::DeleteTextures(1, &m_preserveDrawingBufferTexture);
     
    454453            fence.abandon();
    455454    }
    456     if (m_displayBufferPbuffer) {
     455    if (m_displayBufferPbuffer)
    457456        EGL_DestroySurface(m_displayObj, m_displayBufferPbuffer);
     457    if (m_swapChain) {
    458458        auto recycledBuffer = m_swapChain->recycleBuffer();
    459459        if (recycledBuffer.handle)
     
    466466        clearCurrentContext();
    467467        EGL_DestroyContext(m_displayObj, m_contextObj);
    468     } else
    469         ASSERT(currentContext != this);
     468    }
     469    ASSERT(currentContext != this);
    470470    LOG(WebGL, "Destroyed a GraphicsContextGLOpenGL (%p).", this);
    471471}
Note: See TracChangeset for help on using the changeset viewer.