diff --git a/src/composite.cpp b/src/composite.cpp index 0b767767ec..9b6d010e89 100644 --- a/src/composite.cpp +++ b/src/composite.cpp @@ -15,10 +15,14 @@ #include "effects.h" #include "ftrace.h" #include "internal_client.h" +#include "openglbackend.h" #include "overlaywindow.h" #include "platform.h" +#include "qpainterbackend.h" #include "renderloop.h" #include "scene.h" +#include "scenes/opengl/scene_opengl.h" +#include "scenes/qpainter/scene_qpainter.h" #include "screens.h" #include "shadow.h" #include "surfaceitem_x11.h" @@ -36,7 +40,6 @@ #include #include -#include #include #include @@ -157,6 +160,61 @@ Compositor::~Compositor() s_compositor = nullptr; } +bool Compositor::attemptOpenGLCompositing() +{ + // Some broken drivers crash on glXQuery() so to prevent constant KWin crashes: + if (kwinApp()->platform()->openGLCompositingIsBroken()) { + qCWarning(KWIN_CORE) << "KWin has detected that your OpenGL library is unsafe to use"; + return false; + } + + kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PreInit); + qScopeGuard([]() { + kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PostInit); + }); + + QScopedPointer backend(kwinApp()->platform()->createOpenGLBackend()); + if (!backend) { + return false; + } + if (!backend->isFailed()) { + backend->init(); + } + if (backend->isFailed()) { + return false; + } + + QScopedPointer scene(SceneOpenGL::createScene(backend.data(), this)); + if (!scene || scene->initFailed()) { + return false; + } + + m_backend = backend.take(); + m_scene = scene.take(); + + qCDebug(KWIN_CORE) << "OpenGL compositing has been successfully initialized"; + return true; +} + +bool Compositor::attemptQPainterCompositing() +{ + QScopedPointer backend(kwinApp()->platform()->createQPainterBackend()); + if (!backend || backend->isFailed()) { + return false; + } + + QScopedPointer scene(SceneQPainter::createScene(backend.data(), this)); + if (!scene || scene->initFailed()) { + return false; + } + + m_backend = backend.take(); + m_scene = scene.take(); + + qCDebug(KWIN_CORE) << "QPainter compositing has been successfully initialized"; + return true; +} + bool Compositor::setupStart() { if (kwinApp()->isTerminating()) { @@ -195,51 +253,25 @@ bool Compositor::setupStart() << "Configured compositor not supported by Platform. Falling back to defaults"; } - const auto availablePlugins = KPluginMetaData::findPlugins(QStringLiteral("org.kde.kwin.scenes")); - - for (const KPluginMetaData &pluginMetaData : availablePlugins) { - qCDebug(KWIN_CORE) << "Available scene plugin:" << pluginMetaData.fileName(); - } - for (auto type : qAsConst(supportedCompositors)) { + bool stop = false; switch (type) { case OpenGLCompositing: qCDebug(KWIN_CORE) << "Attempting to load the OpenGL scene"; + stop = attemptOpenGLCompositing(); break; case QPainterCompositing: qCDebug(KWIN_CORE) << "Attempting to load the QPainter scene"; + stop = attemptQPainterCompositing(); break; case NoCompositing: qCDebug(KWIN_CORE) << "Starting without compositing..."; + stop = true; break; } - const auto pluginIt = std::find_if(availablePlugins.begin(), availablePlugins.end(), - [type] (const auto &plugin) { - const auto &metaData = plugin.rawData(); - auto it = metaData.find(QStringLiteral("CompositingType")); - if (it != metaData.end()) { - if ((*it).toInt() == int{type}) { - return true; - } - } - return false; - }); - if (pluginIt != availablePlugins.end()) { - std::unique_ptr - factory{ qobject_cast(pluginIt->instantiate()) }; - if (factory) { - m_scene = factory->create(this); - if (m_scene) { - if (!m_scene->initFailed()) { - qCDebug(KWIN_CORE) << "Instantiated compositing plugin:" - << pluginIt->name(); - break; - } else { - delete m_scene; - m_scene = nullptr; - } - } - } + + if (stop) { + break; } } @@ -470,6 +502,9 @@ void Compositor::stop() delete m_scene; m_scene = nullptr; + delete m_backend; + m_backend = nullptr; + m_state = State::Off; Q_EMIT compositingToggled(false); } diff --git a/src/composite.h b/src/composite.h index 2d51d168ac..b50d23f498 100644 --- a/src/composite.h +++ b/src/composite.h @@ -135,6 +135,9 @@ private: void registerRenderLoop(RenderLoop *renderLoop, AbstractOutput *output); void unregisterRenderLoop(RenderLoop *renderLoop); + bool attemptOpenGLCompositing(); + bool attemptQPainterCompositing(); + State m_state; CompositorSelectionOwner *m_selectionOwner; @@ -142,6 +145,7 @@ private: QList m_unusedSupportProperties; QTimer m_unusedSupportPropertyTimer; Scene *m_scene; + QObject *m_backend = nullptr; QMap m_renderLoops; }; diff --git a/src/scene.cpp b/src/scene.cpp index 985ec2fc27..0bec29e4d8 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -762,13 +762,4 @@ Scene::EffectFrame::~EffectFrame() { } -SceneFactory::SceneFactory(QObject *parent) - : QObject(parent) -{ -} - -SceneFactory::~SceneFactory() -{ -} - } // namespace diff --git a/src/scene.h b/src/scene.h index 8e8d3aaccd..c44c87849d 100644 --- a/src/scene.h +++ b/src/scene.h @@ -263,24 +263,6 @@ private: int m_paintScreenCount = 0; }; -/** - * Factory class to create a Scene. Needs to be implemented by the plugins. - */ -class KWIN_EXPORT SceneFactory : public QObject -{ - Q_OBJECT -public: - ~SceneFactory() override; - - /** - * @returns The created Scene, may be @c nullptr. - */ - virtual Scene *create(QObject *parent = nullptr) const = 0; - -protected: - explicit SceneFactory(QObject *parent); -}; - // The base class for windows representations in composite backends class Scene::Window : public QObject { @@ -422,6 +404,4 @@ Toplevel* Scene::Window::window() const } // namespace -Q_DECLARE_INTERFACE(KWin::SceneFactory, "org.kde.kwin.Scene") - #endif diff --git a/src/scenes/opengl/CMakeLists.txt b/src/scenes/opengl/CMakeLists.txt index 93ce2c326e..b61ff5bd98 100644 --- a/src/scenes/opengl/CMakeLists.txt +++ b/src/scenes/opengl/CMakeLists.txt @@ -1,29 +1,5 @@ -set(SCENE_OPENGL_SRCS +target_sources(kwin PRIVATE lanczosfilter.cpp + lanczosresources.qrc scene_opengl.cpp ) - -include(ECMQtDeclareLoggingCategory) -ecm_qt_declare_logging_category( - SCENE_OPENGL_SRCS HEADER - logging.h - IDENTIFIER - KWIN_OPENGL - CATEGORY_NAME - kwin_scene_opengl - DEFAULT_SEVERITY - Critical -) - -qt5_add_resources(SCENE_OPENGL_SRCS resources.qrc) - -add_library(KWinSceneOpenGL MODULE ${SCENE_OPENGL_SRCS}) -set_target_properties(KWinSceneOpenGL PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kwin.scenes/") -target_link_libraries(KWinSceneOpenGL kwin) - -install( - TARGETS - KWinSceneOpenGL - DESTINATION - ${KDE_INSTALL_PLUGINDIR}/org.kde.kwin.scenes/ -) diff --git a/src/scenes/opengl/resources.qrc b/src/scenes/opengl/lanczosresources.qrc similarity index 100% rename from src/scenes/opengl/resources.qrc rename to src/scenes/opengl/lanczosresources.qrc diff --git a/src/scenes/opengl/opengl.json b/src/scenes/opengl/opengl.json deleted file mode 100644 index 3f965ddaa1..0000000000 --- a/src/scenes/opengl/opengl.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "CompositingType": 1, - "KPlugin": { - "Description": "KWin Compositor plugin rendering through OpenGL", - "Description[ar]": "ملحقة لمؤلف كوين للتصيير عن طريق OpenGL", - "Description[az]": "OpenGL vasitəsi ilə qoşulmuş KWin birləşdirici modulunu formalaşdırmaq", - "Description[ca@valencia]": "Connector del Compositor de KWin que renderitza a través d'OpenGL", - "Description[ca]": "Connector del Compositor del KWin que renderitza a través de l'OpenGL", - "Description[da]": "KWin-compositorplugin som renderer via OpenGL", - "Description[de]": "KWin-Compositor-Modul zum Rendern mit OpenGL", - "Description[en_GB]": "KWin Compositor plugin rendering through OpenGL", - "Description[es]": "Complemento compositor de KWin renderizando mediante OpenGL", - "Description[et]": "KWini komposiitori plugin renderdamiseks OpenGL abil", - "Description[eu]": "Kwin konposatzailearen plugina OpenGL bidez errendatzen", - "Description[fi]": "OpenGL:llä hahmontava KWin-koostajaliitännäinen", - "Description[fr]": "Module du compositeur KWin effectuant le rendu avec OpenGL", - "Description[gl]": "Complemento de compositor de KWin que renderiza a través de OpenGL.", - "Description[hu]": "KWin összeállító bővítmény OpenGL leképezéssel", - "Description[ia]": "Plugin de Compositor KWin rendente transverso OpenGL", - "Description[id]": "Plugin KWin Compositor perenderan melalui OpenGL", - "Description[it]": "Estensione del compositore di KWin per la resa tramite OpenGL", - "Description[ko]": "OpenGL로 렌더링하는 KWin 컴포지터 플러그인", - "Description[lt]": "KWin kompozitoriaus priedas atvaizdavimui per OpenGL", - "Description[nl]": "KWin-compositor-plug-in rendering via OpenGL", - "Description[nn]": "KWin-samansetjartillegg som brukar OpenGL", - "Description[pl]": "Wtyczka kompozytora KWin wyświetlająca przez OpenGL", - "Description[pt]": "'Plugin' de Composição do KWin com desenho via OpenGL", - "Description[pt_BR]": "Plugin do compositor KWin renderizando pelo OpenGL", - "Description[ru]": "Отрисовка подключаемым модулем компоновщика KWin через OpenGL", - "Description[sk]": "Renderovací plugin kompozítora KWin cez OpenGL", - "Description[sl]": "Izrisovanje vstavka upravljalnika skladnje KWin preko OpenGL-ja", - "Description[sr@ijekavian]": "К‑винов прикључак слагача за рендеровање кроз опенГЛ", - "Description[sr@ijekavianlatin]": "KWinov priključak slagača za renderovanje kroz OpenGL", - "Description[sr@latin]": "KWinov priključak slagača za renderovanje kroz OpenGL", - "Description[sr]": "К‑винов прикључак слагача за рендеровање кроз опенГЛ", - "Description[sv]": "Kwin sammansättningsinsticksprogram återger via OpenGL", - "Description[tr]": "OpenGL üzerinden gerçekleme yapan KWin Dizgici eklentisi", - "Description[uk]": "Додаток засобу композиції KWin для обробки з використанням OpenGL", - "Description[vi]": "Phần cài cắm trình kết hợp KWin kết xuất thông qua OpenGL", - "Description[x-test]": "xxKWin Compositor plugin rendering through OpenGLxx", - "Description[zh_CN]": "使用 OpenGL 渲染的 KWin 显示特效混合器插件", - "Description[zh_TW]": "透過 OpenGL 繪製 KWin 合成器附加元件", - "Id": "KWinSceneOpenGL", - "Name": "SceneOpenGL", - "Name[ar]": "SceneOpenGL", - "Name[az]": "SceneOpenGL", - "Name[ca@valencia]": "SceneOpenGL", - "Name[ca]": "SceneOpenGL", - "Name[cs]": "SceneOpenGL", - "Name[da]": "SceneOpenGL", - "Name[de]": "SceneOpenGL", - "Name[en_GB]": "SceneOpenGL", - "Name[es]": "SceneOpenGL", - "Name[et]": "SceneOpenGL", - "Name[eu]": "SceneOpenGL", - "Name[fi]": "SceneOpenGL", - "Name[fr]": "SceneOpenGL", - "Name[gl]": "SceneOpenGL", - "Name[hu]": "SceneOpenGL", - "Name[ia]": "SceneOpenGL", - "Name[id]": "SceneOpenGL", - "Name[it]": "SceneOpenGL", - "Name[ko]": "SceneOpenGL", - "Name[lt]": "SceneOpenGL", - "Name[nl]": "SceneOpenGL", - "Name[nn]": "SceneOpenGL", - "Name[pa]": "ਸੀਨ-ਓਪਨ-ਜੀਐਲ", - "Name[pl]": "OpenGL sceny", - "Name[pt]": "SceneOpenGL", - "Name[pt_BR]": "SceneOpenGL", - "Name[ro]": "SceneOpenGL", - "Name[ru]": "SceneOpenGL", - "Name[sk]": "SceneOpenGL", - "Name[sl]": "SceneOpenGL", - "Name[sr@ijekavian]": "ОпенГЛ-сцена", - "Name[sr@ijekavianlatin]": "OpenGL-scena", - "Name[sr@latin]": "OpenGL-scena", - "Name[sr]": "ОпенГЛ-сцена", - "Name[sv]": "Scen OpenGL", - "Name[tr]": "SceneOpenGL", - "Name[uk]": "SceneOpenGL", - "Name[vi]": "SceneOpenGL", - "Name[x-test]": "xxSceneOpenGLxx", - "Name[zh_CN]": "SceneOpenGL", - "Name[zh_TW]": "SceneOpenGL" - } -} diff --git a/src/scenes/opengl/scene_opengl.cpp b/src/scenes/opengl/scene_opengl.cpp index fa839b347f..2c77debd6c 100644 --- a/src/scenes/opengl/scene_opengl.cpp +++ b/src/scenes/opengl/scene_opengl.cpp @@ -117,9 +117,6 @@ SceneOpenGL::~SceneOpenGL() m_lanczosFilter = nullptr; } SceneOpenGL::EffectFrame::cleanup(); - - // backend might be still needed for a different scene - delete m_backend; } @@ -198,38 +195,13 @@ void SceneOpenGL::initDebugOutput() GL_DEBUG_SEVERITY_LOW, message.length(), message.constData()); } -SceneOpenGL *SceneOpenGL::createScene(QObject *parent) +SceneOpenGL *SceneOpenGL::createScene(OpenGLBackend *backend, QObject *parent) { - QScopedPointer backend(kwinApp()->platform()->createOpenGLBackend()); - if (!backend) { - return nullptr; - } - if (!backend->isFailed()) { - backend->init(); - } - if (backend->isFailed()) { - return nullptr; - } - SceneOpenGL *scene = nullptr; - // first let's try an OpenGL 2 scene - if (SceneOpenGL::supported(backend.data())) { - scene = new SceneOpenGL(backend.take(), parent); - if (scene->initFailed()) { - delete scene; - scene = nullptr; - } else { - return scene; - } - } - if (!scene) { - if (GLPlatform::instance()->recommendedCompositor() == QPainterCompositing) { - qCCritical(KWIN_OPENGL) << "OpenGL driver recommends QPainter based compositing. Falling back to QPainter."; - qCCritical(KWIN_OPENGL) << "To overwrite the detection use the environment variable KWIN_COMPOSE"; - qCCritical(KWIN_OPENGL) << "For more information see https://community.kde.org/KWin/Environment_Variables#KWIN_COMPOSE"; - } + if (SceneOpenGL::supported(backend)) { + return new SceneOpenGL(backend, parent); } - return scene; + return nullptr; } OverlayWindow *SceneOpenGL::overlayWindow() const @@ -1915,30 +1887,4 @@ void SceneOpenGLDecorationRenderer::resizeTexture() } } -OpenGLFactory::OpenGLFactory(QObject *parent) - : SceneFactory(parent) -{ -} - -OpenGLFactory::~OpenGLFactory() = default; - -Scene *OpenGLFactory::create(QObject *parent) const -{ - qCDebug(KWIN_OPENGL) << "Initializing OpenGL compositing"; - - // Some broken drivers crash on glXQuery() so to prevent constant KWin crashes: - if (kwinApp()->platform()->openGLCompositingIsBroken()) { - qCWarning(KWIN_OPENGL) << "KWin has detected that your OpenGL library is unsafe to use"; - return nullptr; - } - kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PreInit); - auto s = SceneOpenGL::createScene(parent); - kwinApp()->platform()->createOpenGLSafePoint(Platform::OpenGLSafePoint::PostInit); - if (s && s->initFailed()) { - delete s; - return nullptr; - } - return s; -} - } // namespace diff --git a/src/scenes/opengl/scene_opengl.h b/src/scenes/opengl/scene_opengl.h index d84d544b0a..f9dd0c8450 100644 --- a/src/scenes/opengl/scene_opengl.h +++ b/src/scenes/opengl/scene_opengl.h @@ -61,7 +61,7 @@ public: QMatrix4x4 projectionMatrix() const { return m_projectionMatrix; } QMatrix4x4 screenProjectionMatrix() const override { return m_screenProjectionMatrix; } - static SceneOpenGL *createScene(QObject *parent); + static SceneOpenGL *createScene(OpenGLBackend *backend, QObject *parent); static bool supported(OpenGLBackend *backend); protected: @@ -226,19 +226,6 @@ private: QScopedPointer m_texture; }; -class KWIN_EXPORT OpenGLFactory : public SceneFactory -{ - Q_OBJECT - Q_INTERFACES(KWin::SceneFactory) - Q_PLUGIN_METADATA(IID "org.kde.kwin.Scene" FILE "opengl.json") - -public: - explicit OpenGLFactory(QObject *parent = nullptr); - ~OpenGLFactory() override; - - Scene *create(QObject *parent = nullptr) const override; -}; - } // namespace #endif diff --git a/src/scenes/qpainter/CMakeLists.txt b/src/scenes/qpainter/CMakeLists.txt index d26dd858b2..14f24096fe 100644 --- a/src/scenes/qpainter/CMakeLists.txt +++ b/src/scenes/qpainter/CMakeLists.txt @@ -1,12 +1,3 @@ -set(SCENE_QPAINTER_SRCS scene_qpainter.cpp) - -add_library(KWinSceneQPainter MODULE scene_qpainter.cpp) -set_target_properties(KWinSceneQPainter PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kwin.scenes/") -target_link_libraries(KWinSceneQPainter kwin) - -install( - TARGETS - KWinSceneQPainter - DESTINATION - ${KDE_INSTALL_PLUGINDIR}/org.kde.kwin.scenes/ +target_sources(kwin PRIVATE + scene_qpainter.cpp ) diff --git a/src/scenes/qpainter/qpainter.json b/src/scenes/qpainter/qpainter.json deleted file mode 100644 index 98a331d59d..0000000000 --- a/src/scenes/qpainter/qpainter.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "CompositingType": 4, - "KPlugin": { - "Description": "KWin Compositor plugin rendering through QPainter", - "Description[ar]": "ملحقة لمؤلف كوين للتصيير عن طريق QPainter", - "Description[az]": "QPainter vasitəsi ilə KWin birləşdirici əlavəsini formalaşdırmaq", - "Description[ca@valencia]": "Connector del Compositor de KWin que renderitza a través de QPainter", - "Description[ca]": "Connector del Compositor del KWin que renderitza a través del QPainter", - "Description[da]": "KWin-compositorplugin som renderer igennem QPainter", - "Description[de]": "KWin-Compositor-Modul zum Rendern mit QPainter", - "Description[el]": "Αποτύπωση πρσοθέτου συνθέτη KWin μέσω QPainter", - "Description[en_GB]": "KWin Compositor plugin rendering through QPainter", - "Description[es]": "Complemento compositor de KWin renderizando mediante QPainter", - "Description[et]": "KWini komposiitori plugin renderdamiseks QPainteri abil", - "Description[eu]": "Kwin konposatzailearen plugina QPainter bidez errendatzen", - "Description[fi]": "QPainterillä hahmontava KWin-koostajaliitännäinen", - "Description[fr]": "Module du compositeur KWin effectuant le rendu avec QPainter", - "Description[gl]": "Complemento de compositor de KWin que renderiza a través de QPainter.", - "Description[hu]": "KWin összeállító bővítmény QPainter leképezéssel", - "Description[ia]": "Plugin de Compositor KWin rendente transverso QPainter", - "Description[id]": "Plugin KWin Compositor perenderan melalui QPainter", - "Description[it]": "Estensione del compositore di KWin per la resa tramite QPainter", - "Description[ko]": "QPainter로 렌더링하는 KWin 컴포지터 플러그인", - "Description[lt]": "KWin kompozitoriaus priedas atvaizdavimui per QPainter", - "Description[nl]": "KWin-compositor-plug-in rendering via QPainter", - "Description[nn]": "KWin-samansetjartillegg som brukar QPainter", - "Description[pl]": "Wtyczka kompozytora KWin wyświetlająca przez QPainter", - "Description[pt]": "'Plugin' de Composição do KWin com desenho via QPainter", - "Description[pt_BR]": "Plugin do compositor KWin renderizando pelo QPainter", - "Description[ru]": "Отрисовка подключаемым модулем компоновщика KWin через QPainter", - "Description[sk]": "Renderovací plugin kompozítora KWin cez QPainter", - "Description[sl]": "Izrisovanje vstavka upravljalnika skladnje KWin preko QPainter-ja", - "Description[sr@ijekavian]": "К‑винов прикључак слагача за рендеровање кроз QPainter", - "Description[sr@ijekavianlatin]": "KWinov priključak slagača za renderovanje kroz QPainter", - "Description[sr@latin]": "KWinov priključak slagača za renderovanje kroz QPainter", - "Description[sr]": "К‑винов прикључак слагача за рендеровање кроз QPainter", - "Description[sv]": "Kwin sammansättningsinsticksprogram återger via QPainter", - "Description[tr]": "QPainter üzerinden KWin Dizgici eklentisi oluşturma", - "Description[uk]": "Додаток засобу композиції KWin для обробки з використанням QPainter", - "Description[vi]": "Phần cài cắm trình kết hợp KWin kết xuất thông qua QPainter", - "Description[x-test]": "xxKWin Compositor plugin rendering through QPainterxx", - "Description[zh_CN]": "使用 QPainter 渲染的 KWin 显示特效混合器插件", - "Description[zh_TW]": "透過 QPainter 繪製 KWin 合成器附加元件", - "Id": "KWinSceneQPainter", - "Name": "SceneQPainter", - "Name[ar]": "SceneQPainter", - "Name[az]": "SceneQPainter", - "Name[ca@valencia]": "SceneQPainter", - "Name[ca]": "SceneQPainter", - "Name[cs]": "SceneQPainter", - "Name[da]": "SceneQPainter", - "Name[de]": "SceneQPainter", - "Name[el]": "SceneQPainter", - "Name[en_GB]": "SceneQPainter", - "Name[es]": "SceneQPainter", - "Name[et]": "SceneQPainter", - "Name[eu]": "SceneQPainter", - "Name[fi]": "SceneQPainter", - "Name[fr]": "SceneQPainter", - "Name[gl]": "SceneQPainter", - "Name[hu]": "SceneQPainter", - "Name[ia]": "SceneQPainter", - "Name[id]": "SceneQPainter", - "Name[it]": "SceneQPainter", - "Name[ko]": "SceneQPainter", - "Name[lt]": "SceneQPainter", - "Name[nl]": "SceneQPainter", - "Name[nn]": "SceneQPainter", - "Name[pa]": "ਸੀਨ-ਕਿਊ-ਪੇਂਟਰ", - "Name[pl]": "QPainter sceny", - "Name[pt]": "SceneQPainter", - "Name[pt_BR]": "SceneQPainter", - "Name[ro]": "SceneQPainter", - "Name[ru]": "SceneQPainter", - "Name[sk]": "SceneQPainter", - "Name[sl]": "SceneQPainter", - "Name[sr@ijekavian]": "QPainter-сцена", - "Name[sr@ijekavianlatin]": "QPainter-scena", - "Name[sr@latin]": "QPainter-scena", - "Name[sr]": "QPainter-сцена", - "Name[sv]": "Scen QPainter", - "Name[tr]": "SceneQPainter", - "Name[uk]": "SceneQPainter", - "Name[vi]": "SceneQPainter", - "Name[x-test]": "xxSceneQPainterxx", - "Name[zh_CN]": "SceneQPainter", - "Name[zh_TW]": "SceneQPainter" - } -} diff --git a/src/scenes/qpainter/scene_qpainter.cpp b/src/scenes/qpainter/scene_qpainter.cpp index 8e8ccb9de8..aba1b5bdfc 100644 --- a/src/scenes/qpainter/scene_qpainter.cpp +++ b/src/scenes/qpainter/scene_qpainter.cpp @@ -38,16 +38,9 @@ namespace KWin //**************************************** // SceneQPainter //**************************************** -SceneQPainter *SceneQPainter::createScene(QObject *parent) +SceneQPainter *SceneQPainter::createScene(QPainterBackend *backend, QObject *parent) { - QScopedPointer backend(kwinApp()->platform()->createQPainterBackend()); - if (backend.isNull()) { - return nullptr; - } - if (backend->isFailed()) { - return nullptr; - } - return new SceneQPainter(backend.take(), parent); + return new SceneQPainter(backend, parent); } SceneQPainter::SceneQPainter(QPainterBackend *backend, QObject *parent) @@ -493,21 +486,4 @@ void SceneQPainterDecorationRenderer::resizeImages() checkAndCreate(int(DecorationPart::Bottom), bottom.size()); } -QPainterFactory::QPainterFactory(QObject *parent) - : SceneFactory(parent) -{ -} - -QPainterFactory::~QPainterFactory() = default; - -Scene *QPainterFactory::create(QObject *parent) const -{ - auto s = SceneQPainter::createScene(parent); - if (s && s->initFailed()) { - delete s; - s = nullptr; - } - return s; -} - } // KWin diff --git a/src/scenes/qpainter/scene_qpainter.h b/src/scenes/qpainter/scene_qpainter.h index a04c2df9b1..343a605a13 100644 --- a/src/scenes/qpainter/scene_qpainter.h +++ b/src/scenes/qpainter/scene_qpainter.h @@ -43,10 +43,10 @@ public: QImage *qpainterRenderBuffer(AbstractOutput *output) const override; QPainterBackend *backend() const { - return m_backend.data(); + return m_backend; } - static SceneQPainter *createScene(QObject *parent); + static SceneQPainter *createScene(QPainterBackend *backend, QObject *parent); protected: void paintBackground(const QRegion ®ion) override; @@ -56,7 +56,7 @@ protected: private: explicit SceneQPainter(QPainterBackend *backend, QObject *parent = nullptr); - QScopedPointer m_backend; + QPainterBackend *m_backend; QScopedPointer m_painter; class Window; }; @@ -124,19 +124,6 @@ private: QImage m_images[int(DecorationPart::Count)]; }; -class KWIN_EXPORT QPainterFactory : public SceneFactory -{ - Q_OBJECT - Q_INTERFACES(KWin::SceneFactory) - Q_PLUGIN_METADATA(IID "org.kde.kwin.Scene" FILE "qpainter.json") - -public: - explicit QPainterFactory(QObject *parent = nullptr); - ~QPainterFactory() override; - - Scene *create(QObject *parent = nullptr) const override; -}; - inline OverlayWindow* SceneQPainter::overlayWindow() const {