DSOutput: change the DSOutput into IDSOutput 92/241592/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 9 Jul 2020 11:38:35 +0000 (20:38 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 09:46:09 +0000 (18:46 +0900)
make the DSOutput be the interface for hiding the internal information
like IDSDisplayDeviceOutput interface.

Change-Id: I48f28eea03e3179e6bb221401c901c7c3f7d77d8

17 files changed:
samples/exampleCompositor.cpp
src/DSCompositor/DSCompositor.h
src/DSDisplayArea/DSDisplayArea.cpp
src/DSDisplayArea/DSDisplayArea.h
src/DSDisplayArea/DSDisplayAreaPrivate.h
src/DSOutput/DSOutput.cpp [deleted file]
src/DSOutput/DSOutput.h [deleted file]
src/DSOutput/DSOutputImpl.cpp [new file with mode: 0644]
src/DSOutput/DSOutputImpl.h [new file with mode: 0644]
src/DSOutput/IDSOutput.h [new file with mode: 0644]
src/meson.build
tests/DSCanvas-test.cpp
tests/DSCompositor-test.cpp
tests/DSDisplayArea-test.cpp
tests/DSOutput-test.cpp [deleted file]
tests/DSOutputImpl-test.cpp [new file with mode: 0644]
tests/meson.build

index a53ea35..6fd2a2e 100644 (file)
@@ -1,5 +1,5 @@
 #include <DSCompositor.h>
-#include <DSOutput.h>
+#include <IDSOutput.h>
 #include <DSInput.h>
 #include <DSCanvas.h>
 #include <DSSeat.h>
@@ -35,8 +35,8 @@ using namespace display_server;
 
 // DSCompositor listen signals. OutputAdd/Remove/ResolutionSet and InputAdd/Remove.
 // compositor->connectSignal(DSOuptut::ADD_SIGNAL, DSCompositor::OutputAdd);
-// compositor->connectSignal(DSOutput::REMOVE_SIGNAL, DSCompositor::OutputRemove);
-// compositor->connectSignal(DSOutput::RESOLUTION_SET_SIGNAL, DSCompositor::OutputResolutionSet);
+// compositor->connectSignal(IDSOutput::REMOVE_SIGNAL, DSCompositor::OutputRemove);
+// compositor->connectSignal(IDSOutput::RESOLUTION_SET_SIGNAL, DSCompositor::OutputResolutionSet);
 // compositor->connectSignal(DSInput::ADD_SIGNAL, DSCompositor::InputAdd);
 // compositor->connectSignal(DSInput::REMOVE_SIGNAL, DSCompositor::InputRemove);
 
@@ -69,7 +69,7 @@ public:
                __canvas->attachDisplayArea(__displayArea);
        }
 
-       void _onOutputAdded(std::shared_ptr<DSOutput> output) override
+       void _onOutputAdded(std::shared_ptr<IDSOutput> output) override
        {
                // set the resolution.
                output->applyResolutionAuto();
@@ -80,7 +80,7 @@ public:
                __displayArea->setSize(output->getResolutionWidth(), output->getResolutionHeight());
        }
 
-       void _onOutputRemoved(std::shared_ptr<DSOutput> output) override
+       void _onOutputRemoved(std::shared_ptr<IDSOutput> output) override
        {
                __displayArea.reset(); // delete shared_ptr
        }
index 5963cce..4d9ae43 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <DSCore.h>
 #include <DSObject.h>
-#include <DSOutput.h>
+#include <IDSOutput.h>
 #include <DSInput.h>
 #include <memory>
 
@@ -24,8 +24,8 @@ public:
 
 protected:
        virtual void _onPrepareCanvas() = 0;
-       virtual void _onOutputAdded(std::shared_ptr<DSOutput> output) = 0;
-       virtual void _onOutputRemoved(std::shared_ptr<DSOutput> output) = 0;
+       virtual void _onOutputAdded(std::shared_ptr<IDSOutput> output) = 0;
+       virtual void _onOutputRemoved(std::shared_ptr<IDSOutput> output) = 0;
        virtual void _onInputAdded(std::shared_ptr<DSInput> input) = 0;
        virtual void _onInputRemoved(std::shared_ptr<DSInput> input) = 0;
 };
index 52c4e0a..32c931f 100644 (file)
@@ -5,7 +5,7 @@
 namespace display_server
 {
 
-DSDisplayArea::DSDisplayArea(std::shared_ptr<DSOutput> output)
+DSDisplayArea::DSDisplayArea(std::shared_ptr<IDSOutput> output)
        : _d_ptr(std::make_unique<DSDisplayAreaPrivate>(this, output))
 {}
 
@@ -46,14 +46,14 @@ int DSDisplayArea::getHeight()
        return priv->getHeight();
 }
 
-std::shared_ptr<DSOutput> DSDisplayArea::getOutput()
+std::shared_ptr<IDSOutput> DSDisplayArea::getOutput()
 {
        DS_GET_PRIV(DSDisplayArea);
 
        return priv->getOutput();
 }
 
-DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr<DSOutput> output)
+DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr<IDSOutput> output)
        : DSObjectPrivate(p_ptr),
          __p_ptr(p_ptr),
          __output(output),
@@ -98,7 +98,7 @@ int DSDisplayAreaPrivate::getHeight()
        return __height;
 }
 
-std::shared_ptr<DSOutput> DSDisplayAreaPrivate::getOutput()
+std::shared_ptr<IDSOutput> DSDisplayAreaPrivate::getOutput()
 {
        return __output;
 }
index 6c1f1bf..84543c4 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <DSCore.h>
 #include <DSObject.h>
-#include <DSOutput.h>
+#include <IDSOutput.h>
 #include <memory>
 
 namespace display_server
@@ -14,14 +14,14 @@ class DSDisplayArea : public DSObject
 {
 DS_PIMPL_USE_PRIVATE(DSDisplayArea);
 public:
-       explicit DSDisplayArea(std::shared_ptr<DSOutput> output);
+       explicit DSDisplayArea(std::shared_ptr<IDSOutput> output);
        virtual ~DSDisplayArea();
 
        bool setPosition(int x, int y);
        bool setSize(int width, int height);
        int getWidth();
        int getHeight();
-       std::shared_ptr<DSOutput> getOutput();
+       std::shared_ptr<IDSOutput> getOutput();
 };
 
 }
index 761c03b..e397b2d 100644 (file)
@@ -2,7 +2,7 @@
 #define __DS_DISPLAY_AREA_PRIVATE_H__
 
 #include "DSDisplayArea.h"
-#include <DSOutput.h>
+#include <IDSOutput.h>
 #include <memory>
 
 namespace display_server
@@ -13,7 +13,7 @@ class DSDisplayAreaPrivate : public DSObjectPrivate
 DS_PIMPL_USE_PUBLIC(DSDisplayArea);
 public:
        DSDisplayAreaPrivate() = delete;
-       DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr<DSOutput> output);
+       DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr<IDSOutput> output);
        virtual ~DSDisplayAreaPrivate();
 
        bool setPosition(int x, int y);
@@ -21,11 +21,11 @@ public:
        int getWidth();
        int getHeight();
 
-       bool setOutput(std::shared_ptr<DSOutput> output);
-       std::shared_ptr<DSOutput> getOutput();
+       bool setOutput(std::shared_ptr<IDSOutput> output);
+       std::shared_ptr<IDSOutput> getOutput();
 
 private:
-       std::shared_ptr<DSOutput> __output;
+       std::shared_ptr<IDSOutput> __output;
        int __x, __y;
        int __width, __height;
 };
diff --git a/src/DSOutput/DSOutput.cpp b/src/DSOutput/DSOutput.cpp
deleted file mode 100644 (file)
index 095fc9c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "DSOutput.h"
-
-namespace display_server
-{
-DSOutput::DSOutput()
-       : __resolutionWidth{0},
-         __resolutionHeight{0}
-{}
-
-DSOutput::~DSOutput()
-{}
-
-int DSOutput::getResolutionWidth()
-{
-       return __resolutionWidth;
-}
-
-int DSOutput::getResolutionHeight()
-{
-       return __resolutionHeight;
-}
-
-bool DSOutput::applyResolutionAuto()
-{
-       return false;
-}
-
-} // namespace display_server
diff --git a/src/DSOutput/DSOutput.h b/src/DSOutput/DSOutput.h
deleted file mode 100644 (file)
index 2587ca6..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _DSOUTPUT_H_
-#define _DSOUTPUT_H_
-
-#include <memory>
-
-namespace display_server
-{
-
-class DSOutput
-{
-public:
-       DSOutput();
-       virtual ~DSOutput();
-
-       int getResolutionWidth();
-       int getResolutionHeight();
-       bool applyResolutionAuto();
-
-private:
-       int __resolutionWidth;
-       int __resolutionHeight;
-};
-
-}
-
-#endif
diff --git a/src/DSOutput/DSOutputImpl.cpp b/src/DSOutput/DSOutputImpl.cpp
new file mode 100644 (file)
index 0000000..ac43483
--- /dev/null
@@ -0,0 +1,64 @@
+#include "DSOutputImpl.h"
+#include "DSDebugLog.h"
+
+namespace display_server
+{
+
+DSOutputImpl::DSOutputImpl(std::shared_ptr<IDSDisplayDeviceOutput> displayDeviceOutput)
+       : __resolutionWidth{0},
+         __resolutionHeight{0},
+         __displayDeviceOutput{displayDeviceOutput}
+{}
+
+DSOutputImpl::~DSOutputImpl()
+{}
+
+int DSOutputImpl::getResolutionWidth()
+{
+       return __resolutionWidth;
+}
+
+int DSOutputImpl::getResolutionHeight()
+{
+       return __resolutionHeight;
+}
+
+bool DSOutputImpl::applyResolutionAuto()
+{
+       if (!__displayDeviceOutput) {
+               DSLOG_ERR("DSOutputImpl", "__displayDeviceOutput is null.");
+               return false;
+       }
+
+       std::list<std::shared_ptr<IDSDisplayDeviceOutputMode>> modes = __displayDeviceOutput->getAvailableModes();
+       if (modes.empty()) {
+               DSLOG_ERR("DSOutputImpl", "modes are empty.");
+               return false;
+       }
+
+       auto bestMode = modes.front();
+       if (!bestMode) {
+               DSLOG_ERR("DSOutputImpl", "bestMode is null.");
+               return false;
+       }
+
+       if (!__displayDeviceOutput->setMode(bestMode)) {
+               DSLOG_ERR("DSOutputImpl", "output->setMode(bestMode) fails.");
+               return false;
+       }
+
+       return true;
+}
+
+std::shared_ptr<IDSBufferQueue> DSOutputImpl::getDisplayBufferQueue()
+{
+       std::shared_ptr<IDSDisplayDeviceHWC> displayDeviceHWC = __displayDeviceOutput->getHWC();
+       if (!displayDeviceHWC) {
+               DSLOG_ERR("DSOutputImpl", "displayDeviceHWC is NULL.");
+               return nullptr;
+       }
+
+       return displayDeviceHWC->getTargetBufferQueue();
+}
+
+} // namespace display_server
diff --git a/src/DSOutput/DSOutputImpl.h b/src/DSOutput/DSOutputImpl.h
new file mode 100644 (file)
index 0000000..a16c546
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __I_DS_OUTPUT_IMPL_H__
+#define __I_DS_OUTPUT_IMPL_H__
+
+#include "IDSOutput.h"
+#include "IDSDisplayDeviceOutput.h"
+
+namespace display_server
+{
+
+class DSOutputImpl : public IDSOutput
+{
+public:
+       DSOutputImpl(std::shared_ptr<IDSDisplayDeviceOutput> displayDeviceOutput);
+       ~DSOutputImpl();
+
+       int getResolutionWidth() override;
+       int getResolutionHeight() override;
+       bool applyResolutionAuto() override;
+
+       std::shared_ptr<IDSBufferQueue> getDisplayBufferQueue();
+
+private:
+       int __resolutionWidth;
+       int __resolutionHeight;
+       std::shared_ptr<IDSDisplayDeviceOutput> __displayDeviceOutput;
+};
+
+}
+
+#endif
\ No newline at end of file
diff --git a/src/DSOutput/IDSOutput.h b/src/DSOutput/IDSOutput.h
new file mode 100644 (file)
index 0000000..c3c8fc5
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef __I_DS_OUTPUT_H__
+#define __I_DS_OUTPUT_H__
+
+#include <memory>
+
+namespace display_server
+{
+
+class IDSOutput
+{
+public:
+       virtual ~IDSOutput() = default;
+
+       virtual int getResolutionWidth() = 0;
+       virtual int getResolutionHeight() = 0;
+       virtual bool applyResolutionAuto() = 0;
+};
+
+}
+
+#endif
\ No newline at end of file
index 7b24fbd..c1063be 100644 (file)
@@ -24,7 +24,7 @@ libds_srcs = [
        'DSObject/DSObject.h',
        'DSObject/DSObjectPrivate.cpp',
        'DSObject/DSObjectPrivate.h',
-       'DSOutput/DSOutput.cpp',
+       'DSOutput/DSOutputImpl.cpp',
        'DSPolicyArea/DSPolicyArea.cpp',
        'DSProperty/DSProperty.cpp',
        'DSProperty/DSProperty.h',
index 3850ba5..5256163 100644 (file)
@@ -1,5 +1,9 @@
 #include "libds-tests.h"
 #include "DSCanvas.h"
+#include "IDSOutput.h"
+#include "DSOutputImpl.h"
+#include "IDSDisplayDeviceOutput.h"
+#include "DSDisplayDeviceOutputTDMImpl.h"
 
 using namespace display_server;
 
@@ -31,7 +35,9 @@ TEST_F(DSCanvasTest, displayArea_Negetive1)
 {
        std::unique_ptr<DSCanvas> canvas = std::make_unique<DSCanvas>();
        EXPECT_TRUE(canvas != nullptr);
-       auto output = std::make_shared<DSOutput>();
+       auto displayDeviceOutput = std::make_shared<DSDisplayDeviceOutputTDMImpl>();
+       EXPECT_TRUE(displayDeviceOutput != nullptr);
+       auto output = std::make_shared<DSOutputImpl>(displayDeviceOutput);
        EXPECT_TRUE(output != nullptr);
        auto displayArea = std::make_shared<DSDisplayArea>(output);
        EXPECT_TRUE(displayArea != nullptr);
index 8404f23..15bf9fc 100644 (file)
@@ -27,10 +27,10 @@ public:
        void _onPrepareCanvas() override
        {}
 
-       void _onOutputAdded(std::shared_ptr<DSOutput> output) override
+       void _onOutputAdded(std::shared_ptr<IDSOutput> output) override
        {}
 
-       void _onOutputRemoved(std::shared_ptr<DSOutput> output) override
+       void _onOutputRemoved(std::shared_ptr<IDSOutput> output) override
        {}
 
        void _onInputAdded(std::shared_ptr<DSInput> input) override
index 1361d83..2cbc48c 100644 (file)
@@ -1,5 +1,9 @@
 #include "libds-tests.h"
 #include "DSDisplayArea.h"
+#include "IDSOutput.h"
+#include "DSOutputImpl.h"
+#include "IDSDisplayDeviceOutput.h"
+#include "DSDisplayDeviceOutputTDMImpl.h"
 
 using namespace display_server;
 
@@ -19,7 +23,9 @@ public:
 
 TEST_F(DSDisplayAreaTest, NewDSDisplayArea)
 {
-       auto output = std::make_shared<DSOutput>();
+       auto displayDeviceOutput = std::make_shared<DSDisplayDeviceOutputTDMImpl>();
+       EXPECT_TRUE(displayDeviceOutput != nullptr);
+       auto output = std::make_shared<DSOutputImpl>(displayDeviceOutput);
        EXPECT_TRUE(output != nullptr);
 
        auto displayArea = std::make_unique<DSDisplayArea>(output);
@@ -28,7 +34,9 @@ TEST_F(DSDisplayAreaTest, NewDSDisplayArea)
 
 TEST_F(DSDisplayAreaTest, BasicMethods)
 {
-       auto output = std::make_shared<DSOutput>();
+       auto displayDeviceOutput = std::make_shared<DSDisplayDeviceOutputTDMImpl>();
+       EXPECT_TRUE(displayDeviceOutput != nullptr);
+       auto output = std::make_shared<DSOutputImpl>(displayDeviceOutput);
        EXPECT_TRUE(output != nullptr);
 
        auto displayArea = std::make_unique<DSDisplayArea>(output);
diff --git a/tests/DSOutput-test.cpp b/tests/DSOutput-test.cpp
deleted file mode 100644 (file)
index 9ac5a15..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "libds-tests.h"
-#include "DSOutput.h"
-
-using namespace display_server;
-
-class DSOutputTest : public ::testing::Test
-{
-public:
-       void SetUp(void) override
-       {}
-       void TearDown(void) override
-       {}
-};
-
-TEST_F(DSOutputTest, NewDSOutput)
-{
-       std::shared_ptr<DSOutput> output = std::make_shared<DSOutput>();
-       EXPECT_TRUE(output != nullptr);
-}
-
-TEST_F(DSOutputTest, BasicMethods)
-{
-       DSOutput output;
-
-       EXPECT_TRUE(output.getResolutionWidth() != 0);
-       EXPECT_TRUE(output.getResolutionHeight() != 0);
-       EXPECT_TRUE(output.applyResolutionAuto() == true);
-}
diff --git a/tests/DSOutputImpl-test.cpp b/tests/DSOutputImpl-test.cpp
new file mode 100644 (file)
index 0000000..6e49d3f
--- /dev/null
@@ -0,0 +1,36 @@
+#include "libds-tests.h"
+#include "IDSOutput.h"
+#include "DSOutputImpl.h"
+#include "IDSDisplayDeviceOutput.h"
+#include "DSDisplayDeviceOutputTDMImpl.h"
+
+using namespace display_server;
+
+class DSOutputTest : public ::testing::Test
+{
+public:
+       void SetUp(void) override
+       {}
+       void TearDown(void) override
+       {}
+};
+
+TEST_F(DSOutputTest, NewDSOutput)
+{
+       auto displayDeviceOutput = std::make_shared<DSDisplayDeviceOutputTDMImpl>();
+       EXPECT_TRUE(displayDeviceOutput != nullptr);
+       auto output = std::make_shared<DSOutputImpl>(displayDeviceOutput);
+       EXPECT_TRUE(output != nullptr);
+}
+
+TEST_F(DSOutputTest, BasicMethods)
+{
+       auto displayDeviceOutput = std::make_shared<DSDisplayDeviceOutputTDMImpl>();
+       EXPECT_TRUE(displayDeviceOutput != nullptr);
+       auto output = std::make_shared<DSOutputImpl>(displayDeviceOutput);
+       EXPECT_TRUE(output != nullptr);
+
+       EXPECT_TRUE(output->getResolutionWidth() != 0);
+       EXPECT_TRUE(output->getResolutionHeight() != 0);
+       EXPECT_TRUE(output->applyResolutionAuto() == true);
+}
index a0991d3..08ee43a 100644 (file)
@@ -6,7 +6,7 @@ libds_tests_srcs = [
        'DSRenderEngineEcoreEvasImpl-test.cpp',
        'DSRenderEngineDaliImpl-test.cpp',
        'DSCompositor-test.cpp',
-       'DSOutput-test.cpp',
+       'DSOutputImpl-test.cpp',
        'DSInput-test.cpp',
        'DSCanvas-test.cpp',
        'DSSeat-test.cpp',