[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: automatically release the IDCompositionDevice3 by using WRL

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Jun 5 15:19:35 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
2ceca598 by Steve Lhomme at 2024-06-05T13:58:59+00:00
qt: automatically release the IDCompositionDevice3 by using WRL

It was not released otherwise and we don't need to micromanage its lifecycle.

- - - - -
66e0db3c by Steve Lhomme at 2024-06-05T13:58:59+00:00
qt: use IID_PPV_ARGS() to call DCompositionCreateDevice

It's safer with regards to the type of the variable read.

- - - - -
c7c55ad4 by Steve Lhomme at 2024-06-05T13:58:59+00:00
qt: use WRL to check for IDCompositionDevice availability

- - - - -


3 changed files:

- modules/gui/qt/maininterface/compositor_dcomp.cpp
- modules/gui/qt/maininterface/compositor_dcomp_acrylicsurface.cpp
- modules/gui/qt/maininterface/compositor_dcomp_acrylicsurface.hpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor_dcomp.cpp
=====================================
@@ -125,16 +125,13 @@ bool CompositorDirectComposition::preInit(qt_intf_t *intf)
     DCompositionCreateDeviceFuncPtr func = reinterpret_cast<DCompositionCreateDeviceFuncPtr>(
         dcomplib.resolve("DCompositionCreateDevice"));
 
-    IDCompositionDevice *device = nullptr;
-    if (!func || FAILED(func(nullptr, __uuidof(IDCompositionDevice), reinterpret_cast<void **>(&device))))
+    Microsoft::WRL::ComPtr<IDCompositionDevice> device;
+    if (!func || FAILED(func(nullptr, IID_PPV_ARGS(&device))))
     {
         msg_Warn(intf, "Can not create DCompositionDevice. CompositorDirectComposition will not work.");
         return false;
     }
 
-    if (device)
-        device->Release();
-
     return true;
 }
 


=====================================
modules/gui/qt/maininterface/compositor_dcomp_acrylicsurface.cpp
=====================================
@@ -107,7 +107,7 @@ CompositorDCompositionAcrylicSurface::CompositorDCompositionAcrylicSurface(qt_in
     , m_mainCtx {mainCtx}
 {
     assert(device);
-    device->QueryInterface(__uuidof(IDCompositionDevice3), (void**)&m_dcompDevice);
+    device->QueryInterface(IID_PPV_ARGS(&m_dcompDevice));
 
     if (!m_dcompDevice)
         throw std::runtime_error("DCompositionDevice is not DCompositionDevice3.");
@@ -301,7 +301,7 @@ try
     thumbnail.rcSource = RECT{ 0, 0, desktopWidth, desktopHeight };
 
     HTHUMBNAIL desktopThumbnail;
-    HR(lDwmpCreateSharedThumbnailVisual(hwnd(), desktopWindow, 2, &thumbnail, m_dcompDevice, &m_desktopVisual, &desktopThumbnail), "create desktop visual");
+    HR(lDwmpCreateSharedThumbnailVisual(hwnd(), desktopWindow, 2, &thumbnail, m_dcompDevice.Get(), &m_desktopVisual, &desktopThumbnail), "create desktop visual");
     HR(m_rootVisual->AddVisual(m_desktopVisual.Get(), FALSE, nullptr), "Add desktop visual");
 
     return true;
@@ -333,7 +333,7 @@ try
     lSetWindowCompositionAttribute(m_dummyWindow, &CompositionAttribute);
 
     vlc_assert(!m_backHostVisual);
-    HR(lDwmpCreateSharedMultiWindowVisual(m_dummyWindow, m_dcompDevice, &m_backHostVisual, &m_backHostThumbnail)
+    HR(lDwmpCreateSharedMultiWindowVisual(m_dummyWindow, m_dcompDevice.Get(), &m_backHostVisual, &m_backHostThumbnail)
        , "failed to create shared multi visual");
 
     updateVisual();


=====================================
modules/gui/qt/maininterface/compositor_dcomp_acrylicsurface.hpp
=====================================
@@ -32,6 +32,7 @@
 #include "compositor_dcomp_error.hpp"
 
 class IDCompositionVisual2;
+class IDCompositionDevice3;
 
 // Windows Private APIs, taken from https://blog.adeltax.com/dwm-thumbnails-but-with-idcompositionvisual/
 
@@ -203,7 +204,7 @@ private:
     HTHUMBNAIL m_backHostThumbnail = NULL;
     HWND m_dummyWindow {};
 
-    class IDCompositionDevice3 *m_dcompDevice;
+    Microsoft::WRL::ComPtr<IDCompositionDevice3> m_dcompDevice;
     Microsoft::WRL::ComPtr<IDCompositionVisual2> m_rootVisual;
     Microsoft::WRL::ComPtr<IDCompositionVisual2> m_backHostVisual;
     Microsoft::WRL::ComPtr<IDCompositionVisual2> m_desktopVisual;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c0ea8ba07dc315ca7034d11dc03736cffeb23f76...c7c55ad4923bfe64bd149fa0c9230a936684e6c3

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c0ea8ba07dc315ca7034d11dc03736cffeb23f76...c7c55ad4923bfe64bd149fa0c9230a936684e6c3
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list