common taskscheduler: revise functionalities.
[platform/core/graphics/tizenvg.git] / inc / thorvg.h
index bdca5a2..0de9bc0 100644 (file)
@@ -1,19 +1,3 @@
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *               http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
 #ifndef _THORVG_H_
 #define _THORVG_H_
 
@@ -48,8 +32,10 @@ protected: \
     A() = delete; \
     ~A() = delete
 
-#define _TVG_DECLARE_ACCESSOR(A) \
-    friend A
+#define _TVG_DECLARE_ACCESSOR() \
+    friend Canvas; \
+    friend Scene; \
+    friend Picture
 
 #define _TVG_DECALRE_IDENTIFIER() \
     auto id() const { return _id; } \
@@ -61,6 +47,7 @@ namespace tvg
 
 class RenderMethod;
 class Scene;
+class Picture;
 class Canvas;
 
 
@@ -97,9 +84,16 @@ struct Matrix
 class TVG_EXPORT Paint
 {
 public:
-    virtual ~Paint() {}
+    virtual ~Paint();
 
-    _TVG_DECALRE_IDENTIFIER();
+    Result rotate(float degree) noexcept;
+    Result scale(float factor) noexcept;
+    Result translate(float x, float y) noexcept;
+    Result transform(const Matrix& m) noexcept;
+    Result bounds(float* x, float* y, float* w, float* h) const noexcept;
+
+    _TVG_DECLARE_ACCESSOR();
+    _TVG_DECLARE_PRIVATE(Paint);
 };
 
 
@@ -150,17 +144,14 @@ public:
     Result reserve(uint32_t n) noexcept;
     virtual Result push(std::unique_ptr<Paint> paint) noexcept;
     virtual Result clear() noexcept;
-    virtual Result update() noexcept;
     virtual Result update(Paint* paint) noexcept;
-    virtual Result draw(bool async = true) noexcept;
+    virtual Result draw() noexcept;
     virtual Result sync() noexcept;
 
-    _TVG_DECLARE_ACCESSOR(Scene);
     _TVG_DECLARE_PRIVATE(Canvas);
 };
 
 
-
 /**
  * @class LinearGradient
  *
@@ -230,6 +221,7 @@ public:
     //Shape
     Result appendRect(float x, float y, float w, float h, float rx, float ry) noexcept;
     Result appendCircle(float cx, float cy, float rx, float ry) noexcept;
+    Result appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept;
     Result appendPath(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept;
 
     //Stroke
@@ -243,18 +235,11 @@ public:
     Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept;
     Result fill(std::unique_ptr<Fill> f) noexcept;
 
-    //Transform
-    Result rotate(float degree) noexcept;
-    Result scale(float factor) noexcept;
-    Result translate(float x, float y) noexcept;
-    Result transform(const Matrix& m) noexcept;
-
     //Getters
     uint32_t pathCommands(const PathCommand** cmds) const noexcept;
     uint32_t pathCoords(const Point** pts) const noexcept;
     Result fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept;
     const Fill* fill() const noexcept;
-    Result bounds(float* x, float* y, float* w, float* h) const noexcept;
 
     float strokeWidth() const noexcept;
     Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept;
@@ -265,8 +250,29 @@ public:
     static std::unique_ptr<Shape> gen() noexcept;
 
     _TVG_DECLARE_PRIVATE(Shape);
-    _TVG_DECLARE_ACCESSOR(Canvas);
-    _TVG_DECLARE_ACCESSOR(Scene);
+};
+
+
+/**
+ * @class Picture
+ *
+ * @ingroup ThorVG
+ *
+ * @brief description...
+ *
+ */
+class TVG_EXPORT Picture final : public Paint
+{
+public:
+    ~Picture();
+
+    Result load(const std::string& path) noexcept;
+    Result load(const char* data, uint32_t size) noexcept;
+    Result viewbox(float* x, float* y, float* w, float* h) const noexcept;
+
+    static std::unique_ptr<Picture> gen() noexcept;
+
+    _TVG_DECLARE_PRIVATE(Picture);
 };
 
 
@@ -285,18 +291,9 @@ public:
 
     Result push(std::unique_ptr<Paint> paint) noexcept;
     Result reserve(uint32_t size) noexcept;
-    Result load(const std::string& path) noexcept;
-
-    Result rotate(float degree) noexcept;
-    Result scale(float factor) noexcept;
-    Result translate(float x, float y) noexcept;
-    Result transform(const Matrix& m) noexcept;
-
-    Result bounds(float* x, float* y, float* w, float* h) const noexcept;
 
     static std::unique_ptr<Scene> gen() noexcept;
 
-    _TVG_DECLARE_ACCESSOR(Canvas);
     _TVG_DECLARE_PRIVATE(Scene);
 };
 
@@ -314,7 +311,9 @@ class TVG_EXPORT SwCanvas final : public Canvas
 public:
     ~SwCanvas();
 
-    Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept;
+    enum Colorspace { ABGR8888 = 0, ARGB8888 };
+
+    Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept;
 
     static std::unique_ptr<SwCanvas> gen() noexcept;
 
@@ -367,7 +366,7 @@ public:
      *
      * @see ...
      */
-    static Result init(CanvasEngine engine) noexcept;
+    static Result init(CanvasEngine engine, uint32_t threads) noexcept;
     static Result term(CanvasEngine engine) noexcept;
 
     _TVG_DISABLE_CTOR(Initializer);