[plasma/kwin] src: Add OutputFrame default argument to OutputLayer::beginFrame()

Vlad Zahorodnii <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit b1bba6fe3f08242b166c61bd858a7cfcbf939ecf by Vlad Zahorodnii.
Committed on 19/08/2026 at 06:32.
Pushed by vladz into branch 'master'.

Add OutputFrame default argument to OutputLayer::beginFrame()

This allows us to avoid writing code such as beginFrame(nullptr) where
it is unclear what the nullptr is, in other words avoid a pointer
version of boolean traps.

It also communicates that the OutputFrame is optional, although there
are other ways to achieve this too.

M  +1    -1    src/core/outputlayer.h
M  +1    -1    src/plugins/colorpicker/colorpicker.cpp
M  +1    -1    src/plugins/colorpicker/colorpickerlayer.h
M  +1    -1    src/plugins/screencast/outputscreencastsource.cpp
M  +1    -1    src/plugins/screencast/regionscreencastsource.cpp
M  +1    -1    src/plugins/screencast/screencastlayer.h
M  +2    -2    src/plugins/screenshot/screenshot.cpp
M  +1    -1    src/plugins/screenshot/screenshotlayer.h

https://invent.kde.org/plasma/kwin/-/commit/b1bba6fe3f08242b166c61bd858a7cfcbf939ecf

diff --git a/src/core/outputlayer.h b/src/core/outputlayer.h
index 252707c570f..eb2cc0cc7f5 100644
--- a/src/core/outputlayer.h
+++ b/src/core/outputlayer.h
@@ -95,7 +95,7 @@ public:
      */
     virtual bool preparePresentationTest();
 
-    virtual std::optional<OutputLayerBeginFrameInfo> beginFrame(OutputFrame *frame) = 0;
+    virtual std::optional<OutputLayerBeginFrameInfo> beginFrame(OutputFrame *frame = nullptr) = 0;
     virtual bool endFrame(const Region &renderedDeviceRegion, const Region &damagedDeviceRegion, OutputFrame *frame) = 0;
 
     /**
diff --git a/src/plugins/colorpicker/colorpicker.cpp b/src/plugins/colorpicker/colorpicker.cpp
index 9d4e66d95b3..a833f861529 100644
--- a/src/plugins/colorpicker/colorpicker.cpp
+++ b/src/plugins/colorpicker/colorpicker.cpp
@@ -121,7 +121,7 @@ QColor ColorPickerEffect::pick()
             if (!layer.preparePresentationTest()) {
                 return;
             }
-            const auto beginInfo = layer.beginFrame(nullptr);
+            const auto beginInfo = layer.beginFrame();
             if (!beginInfo) {
                 return;
             }
diff --git a/src/plugins/colorpicker/colorpickerlayer.h b/src/plugins/colorpicker/colorpickerlayer.h
index a114069b483..f37d9d6490e 100644
--- a/src/plugins/colorpicker/colorpickerlayer.h
+++ b/src/plugins/colorpicker/colorpickerlayer.h
@@ -19,7 +19,7 @@ public:
     FormatModifierMap supportedDrmFormats() const override;
     void releaseBuffers() override;
 
-    std::optional<OutputLayerBeginFrameInfo> beginFrame(OutputFrame *frame) override;
+    std::optional<OutputLayerBeginFrameInfo> beginFrame(OutputFrame *frame = nullptr) override;
     bool endFrame(const Region &renderedRegion, const Region &damagedRegion, OutputFrame *frame) override;
 
 private:
diff --git a/src/plugins/screencast/outputscreencastsource.cpp b/src/plugins/screencast/outputscreencastsource.cpp
index 43ec1844280..28e56700d69 100644
--- a/src/plugins/screencast/outputscreencastsource.cpp
+++ b/src/plugins/screencast/outputscreencastsource.cpp
@@ -82,7 +82,7 @@ Region OutputScreenCastSource::render(GLFramebuffer *target, const Region &buffe
     if (!m_layer->preparePresentationTest()) {
         return Region{};
     }
-    const auto beginInfo = m_layer->beginFrame(nullptr);
+    const auto beginInfo = m_layer->beginFrame();
     if (!beginInfo) {
         return Region{};
     }
diff --git a/src/plugins/screencast/regionscreencastsource.cpp b/src/plugins/screencast/regionscreencastsource.cpp
index f85d65d04f4..a8ee50518cf 100644
--- a/src/plugins/screencast/regionscreencastsource.cpp
+++ b/src/plugins/screencast/regionscreencastsource.cpp
@@ -77,7 +77,7 @@ Region RegionScreenCastSource::render(GLFramebuffer *target, const Region &buffe
     if (!m_layer->preparePresentationTest()) {
         return Region{};
     }
-    const auto beginInfo = m_layer->beginFrame(nullptr);
+    const auto beginInfo = m_layer->beginFrame();
     if (!beginInfo) {
         return Region{};
     }
diff --git a/src/plugins/screencast/screencastlayer.h b/src/plugins/screencast/screencastlayer.h
index 5300975a87b..fb8cfdabead 100644
--- a/src/plugins/screencast/screencastlayer.h
+++ b/src/plugins/screencast/screencastlayer.h
@@ -19,7 +19,7 @@ public:
     FormatModifierMap supportedDrmFormats() const override;
     void releaseBuffers() override;
 
-    std::optional<OutputLayerBeginFrameInfo> beginFrame(OutputFrame *frame) override;
+    std::optional<OutputLayerBeginFrameInfo> beginFrame(OutputFrame *frame = nullptr) override;
     bool endFrame(const Region &renderedRegion, const Region &damagedRegion, OutputFrame *frame) override;
 
 private:
diff --git a/src/plugins/screenshot/screenshot.cpp b/src/plugins/screenshot/screenshot.cpp
index b1c975a49a5..b34afdfa0f3 100644
--- a/src/plugins/screenshot/screenshot.cpp
+++ b/src/plugins/screenshot/screenshot.cpp
@@ -83,7 +83,7 @@ std::optional<QImage> ScreenShotManager::takeScreenShot(LogicalOutput *screen, S
     if (!layer.preparePresentationTest()) {
         return std::nullopt;
     }
-    const auto beginInfo = layer.beginFrame(nullptr);
+    const auto beginInfo = layer.beginFrame();
     if (!beginInfo) {
         return std::nullopt;
     }
@@ -151,7 +151,7 @@ std::optional<QImage> ScreenShotManager::takeScreenShot(const Rect &area, Screen
     if (!layer.preparePresentationTest()) {
         return std::nullopt;
     }
-    const auto beginInfo = layer.beginFrame(nullptr);
+    const auto beginInfo = layer.beginFrame();
     if (!beginInfo) {
         return std::nullopt;
     }
diff --git a/src/plugins/screenshot/screenshotlayer.h b/src/plugins/screenshot/screenshotlayer.h
index 87cf31115ce..4d7652192fe 100644
--- a/src/plugins/screenshot/screenshotlayer.h
+++ b/src/plugins/screenshot/screenshotlayer.h
@@ -19,7 +19,7 @@ public:
     FormatModifierMap supportedDrmFormats() const override;
     void releaseBuffers() override;
 
-    std::optional<OutputLayerBeginFrameInfo> beginFrame(OutputFrame *frame) override;
+    std::optional<OutputLayerBeginFrameInfo> beginFrame(OutputFrame *frame = nullptr) override;
     bool endFrame(const Region &renderedRegion, const Region &damagedRegion, OutputFrame *frame) override;
 
 private:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.