[Libreoffice-commits] core.git: compilerplugins/clang vcl/headless vcl/inc vcl/qa vcl/source vcl/unx vcl/win

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 20 07:56:20 UTC 2021


 compilerplugins/clang/singlevalfields.results       |    3 -
 compilerplugins/clang/unnecessaryoverride.cxx       |    5 -
 compilerplugins/clang/unusedfields.readonly.results |    2 
 vcl/headless/svpinst.cxx                            |   51 --------------------
 vcl/inc/backend/BackendCapabilities.hxx             |   21 --------
 vcl/inc/headless/svpinst.hxx                        |    4 -
 vcl/inc/salinst.hxx                                 |   16 +++---
 vcl/inc/unx/salinst.h                               |    2 
 vcl/inc/win/salinst.h                               |    1 
 vcl/qa/cppunit/BitmapExTest.cxx                     |    3 -
 vcl/qa/cppunit/BitmapTest.cxx                       |    6 --
 vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx    |    3 -
 vcl/source/app/salvtables.cxx                       |    6 ++
 vcl/source/bitmap/BitmapReadAccess.cxx              |    6 --
 vcl/source/filter/png/PngImageReader.cxx            |    3 -
 vcl/source/opengl/OpenGLHelper.cxx                  |    4 +
 vcl/unx/generic/app/salinst.cxx                     |   16 +-----
 vcl/win/app/salinst.cxx                             |   16 +-----
 18 files changed, 34 insertions(+), 134 deletions(-)

New commits:
commit 9ca30cd1d04cf39411c3ede687805c28ebe2a980
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Aug 19 21:45:42 2021 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Aug 20 09:55:38 2021 +0200

    VCL allow plugins to declare OpenGL support
    
    ... and get rid of the whole GetBackendCapabilities, which was
    just overkill. Maybe this should even be some bitmap + enum
    + set/get function, but I'm too lazy...
    
    In the end add a bool for the OpenGL support of the VCL plugin
    (or maybe sticking it into ImplSVData, which is already some
    catchall for common VCL data).
    
    Change-Id: I9f0ececac482d8e2a94ef6024628e9631b49e773
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120760
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/compilerplugins/clang/singlevalfields.results b/compilerplugins/clang/singlevalfields.results
index b2f91d4d97a1..c426b4a42580 100644
--- a/compilerplugins/clang/singlevalfields.results
+++ b/compilerplugins/clang/singlevalfields.results
@@ -976,9 +976,6 @@ vcl/headless/svpgdi.cxx:598
 vcl/headless/svpgdi.cxx:1641
     SvpSalGraphics::drawPolyLine bDoDirectCairoStroke
     1
-vcl/inc/backend/BackendCapabilities.hxx:18
-    vcl::BackendCapabilities mbSupportsBitmap32
-    0
 vcl/inc/canvasbitmap.hxx:53
     vcl::unotools::VclCanvasBitmap m_nEndianness
     0
diff --git a/compilerplugins/clang/unnecessaryoverride.cxx b/compilerplugins/clang/unnecessaryoverride.cxx
index 5013894aa398..7ce2627cc8fb 100644
--- a/compilerplugins/clang/unnecessaryoverride.cxx
+++ b/compilerplugins/clang/unnecessaryoverride.cxx
@@ -248,11 +248,6 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
         return true;
     }
 
-    auto fdc = loplugin::DeclCheck(methodDecl);
-    // Has code only in #ifdef.
-    if (fdc.Function("GetBackendCapabilities").Class("X11SalInstance").GlobalNamespace())
-        return true;
-
     // If overriding more than one base member function, or one base member
     // function that is available in multiple (non-virtual) base class
     // instances, then this is a disambiguating override:
diff --git a/compilerplugins/clang/unusedfields.readonly.results b/compilerplugins/clang/unusedfields.readonly.results
index c04bf4eeaca0..c0234103d79d 100644
--- a/compilerplugins/clang/unusedfields.readonly.results
+++ b/compilerplugins/clang/unusedfields.readonly.results
@@ -686,8 +686,6 @@ unotools/source/config/pathoptions.cxx:85
     SvtPathOptions_Impl m_aEmptyString class rtl::OUString
 unotools/source/config/saveopt.cxx:83
     (anonymous namespace)::SvtSaveOptions_Impl bROUserAutoSave _Bool
-vcl/inc/backend/BackendCapabilities.hxx:17
-    vcl::BackendCapabilities mbSupportsBitmap32 _Bool
 vcl/inc/bitmap/BitmapFastScaleFilter.hxx:31
     BitmapFastScaleFilter maSize class Size
 vcl/inc/ppdparser.hxx:131
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index b488d54d7527..55bc15325fda 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -35,9 +35,6 @@
 #include <vcl/virdev.hxx>
 #include <vcl/inputtypes.hxx>
 #include <vcl/lok.hxx>
-#if HAVE_FEATURE_UI
-# include <vcl/opengl/OpenGLContext.hxx>
-#endif
 
 #include <headless/svpinst.hxx>
 #include <headless/svpframe.hxx>
@@ -106,6 +103,8 @@ SvpSalInstance::SvpSalInstance( std::unique_ptr<SalYieldMutex> pMutex )
 #if !defined(ANDROID) && !defined(IOS)
     pthread_atfork(nullptr, nullptr, atfork_child);
 #endif
+
+    m_bSupportsOpenGL = false;
 }
 
 SvpSalInstance::~SvpSalInstance()
@@ -583,52 +582,6 @@ void SvpSalInstance::AddToRecentDocumentList(const OUString&, const OUString&, c
 {
 }
 
-std::shared_ptr<vcl::BackendCapabilities> SvpSalInstance::GetBackendCapabilities()
-{
-    auto pBackendCapabilities = SalInstance::GetBackendCapabilities();
-#if 0 // LO code is not yet bitmap32-ready.
-#ifndef IOS
-    // Note: This code is used for iOS, too. Let's not use 32-bit bitmaps with included alpha on iOS for now.
-    pBackendCapabilities->mbSupportsBitmap32 = true;
-#endif
-#endif
-    return pBackendCapabilities;
-}
-
-//obviously doesn't actually do anything, it's just a nonfunctional stub
-
-#if HAVE_FEATURE_UI
-
-namespace {
-
-class SvpOpenGLContext : public OpenGLContext
-{
-    GLWindow m_aGLWin;
-private:
-    virtual const GLWindow& getOpenGLWindow() const override { return m_aGLWin; }
-    virtual GLWindow& getModifiableOpenGLWindow() override { return m_aGLWin; }
-};
-
-}
-
-OpenGLContext* SvpSalInstance::CreateOpenGLContext()
-{
-    return new SvpOpenGLContext;
-}
-
-#else
-
-class SvpOpenGLContext
-{
-};
-
-OpenGLContext* SvpSalInstance::CreateOpenGLContext()
-{
-    return nullptr;
-}
-
-#endif
-
 SvpSalTimer::~SvpSalTimer()
 {
 }
diff --git a/vcl/inc/backend/BackendCapabilities.hxx b/vcl/inc/backend/BackendCapabilities.hxx
deleted file mode 100644
index 2fd49ff47fe5..000000000000
--- a/vcl/inc/backend/BackendCapabilities.hxx
+++ /dev/null
@@ -1,21 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- */
-
-#pragma once
-
-namespace vcl
-{
-struct BackendCapabilities
-{
-    bool mbSupportsBitmap32 = false;
-};
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index 2f48049b4839..51de503c3b24 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -159,8 +159,6 @@ public:
     // SalBitmap
     virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
 
-    std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override;
-
     // wait next event and dispatch
     // must returned by UserEvent (SalFrame::PostEvent)
     // and timer
@@ -169,8 +167,6 @@ public:
     virtual bool            IsMainThread() const override;
     virtual void            updateMainThread() override;
 
-    virtual OpenGLContext*  CreateOpenGLContext() override;
-
     virtual OUString        GetConnectionIdentifier() override;
 
     virtual void            AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override;
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index f38d6f45e44c..1c61dc029cc6 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -26,8 +26,6 @@
 #include <vcl/salgtype.hxx>
 #include <vcl/vclenum.hxx>
 
-#include "backend/BackendCapabilities.hxx"
-
 #include "displayconnectiondispatch.hxx"
 
 #include <com/sun/star/uno/XComponentContext.hpp>
@@ -80,10 +78,17 @@ private:
     const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex;
     css::uno::Reference<css::uno::XInterface> m_clipboard;
 
+protected:
+    bool m_bSupportsBitmap32 = false;
+    bool m_bSupportsOpenGL = true;
+
 public:
     SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex);
     virtual ~SalInstance();
 
+    bool supportsBitmap32() const { return m_bSupportsBitmap32; }
+    bool supportsOpenGL() const { return m_bSupportsOpenGL; }
+
     //called directly after Application::Init
     virtual void            AfterAppInit() {}
     virtual bool            SVMainHook(int*) { return false; }
@@ -128,11 +133,6 @@ public:
     virtual SalSystem*      CreateSalSystem() = 0;
     // SalBitmap
     virtual std::shared_ptr<SalBitmap> CreateSalBitmap() = 0;
-    // BackendCapabilities
-    virtual std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities()
-    {
-        return std::make_shared<vcl::BackendCapabilities>();
-    }
 
     // YieldMutex
     comphelper::SolarMutex* GetYieldMutex();
@@ -158,7 +158,7 @@ public:
     // may return NULL to disable session management, only used by X11 backend
     virtual std::unique_ptr<SalSession> CreateSalSession();
 
-    virtual OpenGLContext*  CreateOpenGLContext() = 0;
+    virtual OpenGLContext*  CreateOpenGLContext();
 
     virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile);
     virtual weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h
index 9378b243a58e..75a5cd6ae5ab 100644
--- a/vcl/inc/unx/salinst.h
+++ b/vcl/inc/unx/salinst.h
@@ -77,8 +77,6 @@ public:
 
     virtual void                AfterAppInit() override;
 
-    std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override;
-
     // dtrans implementation
     virtual css::uno::Reference< css::uno::XInterface >
         CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments ) override;
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index cd98a0231288..bde64dd1bb8d 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -73,7 +73,6 @@ public:
     virtual void                AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override;
 
     virtual OUString            getOSVersion() override;
-    virtual std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override;
     virtual void BeforeAbort(const OUString&, bool) override;
 
     static int WorkaroundExceptionHandlingInUSER32Lib(int nExcept, LPEXCEPTION_POINTERS pExceptionInfo);
diff --git a/vcl/qa/cppunit/BitmapExTest.cxx b/vcl/qa/cppunit/BitmapExTest.cxx
index 6f235237c2f3..a0a6b3096f53 100644
--- a/vcl/qa/cppunit/BitmapExTest.cxx
+++ b/vcl/qa/cppunit/BitmapExTest.cxx
@@ -55,8 +55,7 @@ void BitmapExTest::testGetPixelColor32()
 {
     // Check backend capabilities and return from the test successfully
     // if the backend doesn't support 32-bit bitmap
-    auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
-    if (!pBackendCapabilities->mbSupportsBitmap32)
+    if (!ImplGetSVData()->mpDefInst->supportsBitmap32())
         return;
 
     Bitmap aBitmap(Size(3, 3), vcl::PixelFormat::N32_BPP);
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index 4d033c9e37a3..edb9fe386de6 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -136,8 +136,7 @@ void BitmapTest::testCreation()
 
     // Check backend capabilities and return from the test successfully
     // if the backend doesn't support 32-bit bitmap
-    auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
-    if (pBackendCapabilities->mbSupportsBitmap32)
+    if (ImplGetSVData()->mpDefInst->supportsBitmap32())
     {
         Bitmap aBmp(Size(10, 10), vcl::PixelFormat::N32_BPP);
         Size aSize = aBmp.GetSizePixel();
@@ -507,8 +506,7 @@ void BitmapTest::testBitmap32()
 {
     // Check backend capabilities and return from the test successfully
     // if the backend doesn't support 32-bit bitmap
-    auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
-    if (!pBackendCapabilities->mbSupportsBitmap32)
+    if (!ImplGetSVData()->mpDefInst->supportsBitmap32())
         return;
 
     Bitmap aBitmap(Size(3, 3), vcl::PixelFormat::N32_BPP);
diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
index d4cb8ed1532b..26c1136cbe4d 100644
--- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
+++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
@@ -144,8 +144,7 @@ void BitmapRenderTest::testDrawAlphaBitmapEx()
     aPngReader.read(aBitmapEx);
 
     // Check backend capabilities, if the backend support 32-bit bitmap
-    auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
-    if (pBackendCapabilities->mbSupportsBitmap32)
+    if (ImplGetSVData()->mpDefInst->supportsBitmap32())
     {
         CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N32_BPP, aBitmapEx.GetBitmap().getPixelFormat());
     }
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 3abcd7ad5ecb..da17b8facb40 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -123,6 +123,12 @@ void SalInstance::AcquireYieldMutex(sal_uInt32 nCount) { m_pYieldMutex->acquire(
 
 std::unique_ptr<SalSession> SalInstance::CreateSalSession() { return nullptr; }
 
+OpenGLContext* SalInstance::CreateOpenGLContext()
+{
+    assert(!m_bSupportsOpenGL);
+    std::abort();
+}
+
 std::unique_ptr<SalMenu> SalInstance::CreateMenu(bool, Menu*)
 {
     // default: no native menus
diff --git a/vcl/source/bitmap/BitmapReadAccess.cxx b/vcl/source/bitmap/BitmapReadAccess.cxx
index cf531189913c..6e87debd1ec1 100644
--- a/vcl/source/bitmap/BitmapReadAccess.cxx
+++ b/vcl/source/bitmap/BitmapReadAccess.cxx
@@ -50,11 +50,7 @@ BitmapReadAccess::BitmapReadAccess(Bitmap& rBitmap, BitmapAccessMode nMode)
 
 BitmapReadAccess::~BitmapReadAccess() {}
 
-bool Bitmap32IsPreMultipled()
-{
-    auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
-    return pBackendCapabilities->mbSupportsBitmap32;
-}
+bool Bitmap32IsPreMultipled() { return ImplGetSVData()->mpDefInst->supportsBitmap32(); }
 
 FncGetPixel BitmapReadAccess::GetPixelFunction(ScanlineFormat nFormat)
 {
diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx
index 013254192d3d..6fc182cc24b3 100644
--- a/vcl/source/filter/png/PngImageReader.cxx
+++ b/vcl/source/filter/png/PngImageReader.cxx
@@ -97,9 +97,8 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx,
     BitmapScopedWriteAccess pWriteAccessInstance;
     AlphaScopedWriteAccess pWriteAccessAlphaInstance;
     std::vector<std::vector<png_byte>> aRows;
-    auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
     const bool bFuzzing = utl::ConfigManager::IsFuzzing();
-    const bool bSupportsBitmap32 = pBackendCapabilities->mbSupportsBitmap32 || bFuzzing;
+    const bool bSupportsBitmap32 = bFuzzing || ImplGetSVData()->mpDefInst->supportsBitmap32();
     const bool bOnlyCreateBitmap
         = static_cast<bool>(nImportFlags & GraphicFilterImportFlags::OnlyCreateBitmap);
     const bool bUseExistingBitmap
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 724c692c8925..bf37940511ff 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -38,6 +38,8 @@
 #include <watchdog.hxx>
 #include <vcl/skia/SkiaHelper.hxx>
 #include <vcl/glxtestprocess.hxx>
+#include <salinst.hxx>
+#include <svdata.hxx>
 
 #if USING_X11
 #include <opengl/x11/X11DeviceInfo.hxx>
@@ -790,6 +792,8 @@ bool OpenGLHelper::supportsOpenGL()
 {
     if( getenv("SAL_DISABLEGL") != nullptr )
         return false;
+    if (!ImplGetSVData()->mpDefInst->supportsOpenGL())
+        return false;
     if( isDeviceDenylisted())
         return false;
     if( officecfg::Office::Common::VCL::DisableOpenGL::get())
diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx
index dc53368e3e6e..7a8b761dbb30 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -74,6 +74,10 @@ X11SalInstance::X11SalInstance(std::unique_ptr<SalYieldMutex> pMutex)
     pSVData->maAppData.mxToolkitName = OUString("x11");
 #if HAVE_FEATURE_SKIA
     X11SkiaSalGraphicsImpl::prepareSkia();
+#if SKIA_USE_BITMAP32
+    if (SkiaHelper::isVCLSkiaEnabled())
+        m_bSupportsBitmap32 = true;
+#endif
 #endif
 }
 
@@ -234,16 +238,4 @@ std::unique_ptr<GenPspGraphics> X11SalInstance::CreatePrintGraphics()
     return std::make_unique<GenPspGraphics>();
 }
 
-std::shared_ptr<vcl::BackendCapabilities> X11SalInstance::GetBackendCapabilities()
-{
-    auto pBackendCapabilities = SalInstance::GetBackendCapabilities();
-#if HAVE_FEATURE_SKIA
-#if SKIA_USE_BITMAP32
-    if( SkiaHelper::isVCLSkiaEnabled())
-        pBackendCapabilities->mbSupportsBitmap32 = true;
-#endif
-#endif
-    return pBackendCapabilities;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 50f48b076679..f2981bbd9d1c 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -386,6 +386,10 @@ WinSalInstance::WinSalInstance()
     pSVData->maAppData.mxToolkitName = OUString("win");
 #if HAVE_FEATURE_SKIA
     WinSkiaSalGraphicsImpl::prepareSkia();
+#if SKIA_USE_BITMAP32
+    if (SkiaHelper::isVCLSkiaEnabled())
+        m_bSupportsBitmap32 = true;
+#endif
 #endif
 }
 
@@ -919,18 +923,6 @@ OUString WinSalInstance::getOSVersion()
     return aVer.makeStringAndClear();
 }
 
-std::shared_ptr<vcl::BackendCapabilities> WinSalInstance::GetBackendCapabilities()
-{
-    auto pBackendCapabilities = SalInstance::GetBackendCapabilities();
-#if HAVE_FEATURE_SKIA
-#if SKIA_USE_BITMAP32
-    if( SkiaHelper::isVCLSkiaEnabled())
-        pBackendCapabilities->mbSupportsBitmap32 = true;
-#endif
-#endif
-    return pBackendCapabilities;
-}
-
 void WinSalInstance::BeforeAbort(const OUString&, bool)
 {
     ImplFreeSalGDI();


More information about the Libreoffice-commits mailing list