common loader: code refactoring.
authorHermet Park <chuneon.park@samsung.com>
Wed, 28 Jul 2021 04:40:45 +0000 (13:40 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 29 Jul 2021 01:14:54 +0000 (10:14 +0900)
replace from Scene to Paint at the internal interface.

Picture doesn't need to know the returned Node type.
base class, Paint is enough to in the data passing.

src/lib/tvgLoadModule.h
src/lib/tvgPictureImpl.h
src/loaders/svg/tvgSvgLoader.cpp
src/loaders/svg/tvgSvgLoader.h
src/loaders/tvg/tvgTvgLoader.cpp
src/loaders/tvg/tvgTvgLoader.h

index 04b8a9d..6d214dc 100644 (file)
@@ -40,13 +40,13 @@ public:
 
     virtual ~LoadModule() {}
 
-    virtual bool open(const string& path) { /* Not supported */ return false; };
-    virtual bool open(const char* data, uint32_t size, bool copy) { /* Not supported */ return false; };
-    virtual bool open(const uint32_t* data, uint32_t w, uint32_t h, bool copy) { /* Not supported */ return false; };
+    virtual bool open(const string& path) { return false; };
+    virtual bool open(const char* data, uint32_t size, bool copy) { return false; };
+    virtual bool open(const uint32_t* data, uint32_t w, uint32_t h, bool copy) { return false; };
     virtual bool read() = 0;
     virtual bool close() = 0;
     virtual const uint32_t* pixels() { return nullptr; };
-    virtual unique_ptr<Scene> scene() { return nullptr; };
+    virtual unique_ptr<Paint> paint() { return nullptr; };
 };
 
 }
index c364868..0a56798 100644 (file)
@@ -112,9 +112,8 @@ struct Picture::Impl
     {
         if (loader) {
             if (!paint) {
-                auto scene = loader->scene();
-                if (scene) {
-                    paint = scene.release();
+                if (auto p = loader->paint()) {
+                    paint = p.release();
                     loader->close();
                     if (w != loader->w && h != loader->h) resize();
                     if (paint) return RenderUpdateFlag::None;
index b547be4..3dd8088 100644 (file)
@@ -2885,7 +2885,7 @@ bool SvgLoader::close()
 }
 
 
-unique_ptr<Scene> SvgLoader::scene()
+unique_ptr<Paint> SvgLoader::paint()
 {
     this->done();
     if (root) return move(root);
index 886af40..46af6a8 100644 (file)
@@ -49,7 +49,7 @@ public:
     bool close() override;
     void run(unsigned tid) override;
 
-    unique_ptr<Scene> scene() override;
+    unique_ptr<Paint> paint() override;
 
 private:
     void clear();
index 706372b..5a184fc 100644 (file)
@@ -125,7 +125,7 @@ void TvgLoader::run(unsigned tid)
     if (!root) clear();
 }
 
-unique_ptr<Scene> TvgLoader::scene()
+unique_ptr<Paint> TvgLoader::paint()
 {
     this->done();
     if (root) return move(root);
index cc2c183..5bb7954 100644 (file)
@@ -45,7 +45,7 @@ public:
     bool close() override;
 
     void run(unsigned tid) override;
-    unique_ptr<Scene> scene() override;
+    unique_ptr<Paint> paint() override;
 
 private:
     void clear();