• Gil Dekel's avatar
    media/gpu: ScopedVASurface in VaapiImageDecoder · 301fe942
    Gil Dekel authored
    This CL refactors VaapiImageDecoder to use
    std::unique_ptr<ScopedVASurface>, together with a custom deleter to
    destroy the associated context. This ensures the decoder owns and
    properly clean the underlying VA surface and VA context. This is useful
    because it removes clean-up responsibilities from clients of
    ScopedVASurface.
    
    Unfortunately, we have noticed that VaapiWrapper would reduce the manual
    ref count of the VaDisplayState upon its demise, which may cause some
    ScopedVASurfaces with stale copies of VADisplay to not be able to
    self-clean. Therefore this CL introduces a (hopefully) temporary
    modification to ScopedVASurface in which it holds a scoped_refptr to the
    VaapiWrapper that created it and uses it to self clean.
    
    In addition, the API of image decoders is changed slightly. A
    scoped_refptr<VASurface> is no longer returned upon Decode() requests.
    Should a client need access to the ScopedVASurface, the API exposes a
    GetScopedVASurface(), which returns a const raw pointer to the decoder's
    ScopedVASurface. This should feel familiar due to the get() call in
    unique_ptrs.
    
    Finally, this CL fixes some of the call-sites that use VaapiJpegDecoder
    (i.e. VaapiImageDecoder's new API).
    
    Bug: 877694, 980379
    Test: jpeg_decode_accelerator_unittest
    Change-Id: I834c3af64813e3004f8a62da4e2ef529585be465
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1696012
    Commit-Queue: Gil Dekel <gildekel@chromium.org>
    Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
    Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#677035}
    301fe942
vaapi_wrapper.cc 76.5 KB