/**
- * @class PaintNode
+ * @class Paint
*
* @ingroup TizenVG
*
* @brief description...
*
*/
-class TIZENVG_EXPORT PaintNode
+class TIZENVG_EXPORT Paint
{
public:
- virtual ~PaintNode() {}
+ virtual ~Paint() {}
virtual int update(RenderMethod*) = 0;
};
virtual ~Canvas();
int reserve(size_t n) noexcept;
- virtual int push(std::unique_ptr<PaintNode> paint) noexcept;
+ virtual int push(std::unique_ptr<Paint> paint) noexcept;
virtual int clear() noexcept;
virtual int update() noexcept;
virtual int draw(bool async = true) noexcept;
/**
- * @class ShapeNode
+ * @class Shape
*
* @ingroup TizenVG
*
* @brief description...
*
*/
-class TIZENVG_EXPORT ShapeNode final : public PaintNode
+class TIZENVG_EXPORT Shape final : public Paint
{
public:
- ~ShapeNode();
+ ~Shape();
int update(RenderMethod* engine) noexcept override;
int reset() noexcept;
int pathCoords(const Point** pts) const noexcept;
int fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept;
- static std::unique_ptr<ShapeNode> gen() noexcept;
+ static std::unique_ptr<Shape> gen() noexcept;
//FIXME: Ugly... Better design?
void *engine() noexcept;
- _TIZENVG_DECLARE_PRIVATE(ShapeNode);
+ _TIZENVG_DECLARE_PRIVATE(Shape);
};
/**
- * @class SceneNode
+ * @class Scene
*
* @ingroup TizenVG
*
* @brief description...
*
*/
-class TIZENVG_EXPORT SceneNode final : public PaintNode
+class TIZENVG_EXPORT Scene final : public Paint
{
public:
- ~SceneNode();
+ ~Scene();
int update(RenderMethod* engine) noexcept override;
- int push(std::unique_ptr<ShapeNode> shape) noexcept;
+ int push(std::unique_ptr<Shape> shape) noexcept;
- static std::unique_ptr<SceneNode> gen() noexcept;
+ static std::unique_ptr<Scene> gen() noexcept;
- _TIZENVG_DECLARE_PRIVATE(SceneNode);
+ _TIZENVG_DECLARE_PRIVATE(Scene);
};
return true;
}
-bool GlRenderer::render(const ShapeNode& shape, void *data)
+bool GlRenderer::render(const Shape& shape, void *data)
{
GlShape* sdata = static_cast<GlShape*>(data);
if (!sdata) return false;
}
-bool GlRenderer::dispose(const ShapeNode& shape, void *data)
+bool GlRenderer::dispose(const Shape& shape, void *data)
{
GlShape* sdata = static_cast<GlShape*>(data);
if (!sdata) return false;
}
-void* GlRenderer::prepare(const ShapeNode& shape, void* data, UpdateFlag flags)
+void* GlRenderer::prepare(const Shape& shape, void* data, UpdateFlag flags)
{
//prepare shape data
GlShape* sdata = static_cast<GlShape*>(data);
class GlRenderer : public RenderMethod
{
public:
- void* prepare(const ShapeNode& shape, void* data, UpdateFlag flags) override;
- bool dispose(const ShapeNode& shape, void *data) override;
- bool render(const ShapeNode& shape, void *data) override;
+ void* prepare(const Shape& shape, void* data, UpdateFlag flags) override;
+ bool dispose(const Shape& shape, void *data) override;
+ bool render(const Shape& shape, void *data) override;
bool clear() override;
size_t ref() override;
size_t unref() override;
'tvgCanvas.cpp',
'tvgSwCanvas.cpp',
'tvgGlCanvas.cpp',
- 'tvgSceneNode.cpp',
- 'tvgShapeNode.cpp'
+ 'tvgScene.cpp',
+ 'tvgShape.cpp'
]
src_dep = declare_dependency(
};
void shapeReset(SwShape& sdata);
-bool shapeGenOutline(const ShapeNode& shape, SwShape& sdata);
-void shapeDelOutline(const ShapeNode& shape, SwShape& sdata);
-bool shapeGenRle(const ShapeNode& shape, SwShape& sdata, const SwSize& clip);
-bool shapeTransformOutline(const ShapeNode& shape, SwShape& sdata);
+bool shapeGenOutline(const Shape& shape, SwShape& sdata);
+void shapeDelOutline(const Shape& shape, SwShape& sdata);
+bool shapeGenRle(const Shape& shape, SwShape& sdata, const SwSize& clip);
+bool shapeTransformOutline(const Shape& shape, SwShape& sdata);
SwRleData* rleRender(const SwShape& sdata, const SwSize& clip);
bool rasterShape(Surface& surface, SwShape& sdata, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
}
-bool SwRenderer::render(const ShapeNode& shape, void *data)
+bool SwRenderer::render(const Shape& shape, void *data)
{
SwShape* sdata = static_cast<SwShape*>(data);
if (!sdata) return false;
}
-bool SwRenderer::dispose(const ShapeNode& shape, void *data)
+bool SwRenderer::dispose(const Shape& shape, void *data)
{
SwShape* sdata = static_cast<SwShape*>(data);
if (!sdata) return false;
return true;
}
-void* SwRenderer::prepare(const ShapeNode& shape, void* data, UpdateFlag flags)
+void* SwRenderer::prepare(const Shape& shape, void* data, UpdateFlag flags)
{
//prepare shape data
SwShape* sdata = static_cast<SwShape*>(data);
public:
Surface surface;
- void* prepare(const ShapeNode& shape, void* data, UpdateFlag flags) override;
- bool dispose(const ShapeNode& shape, void *data) override;
- bool render(const ShapeNode& shape, void *data) override;
+ void* prepare(const Shape& shape, void* data, UpdateFlag flags) override;
+ bool dispose(const Shape& shape, void *data) override;
+ bool render(const Shape& shape, void *data) override;
bool target(uint32_t* buffer, size_t stride, size_t w, size_t h);
bool clear() override;
size_t ref() override;
/* External Class Implementation */
/************************************************************************/
-bool shapeTransformOutline(const ShapeNode& shape, SwShape& sdata)
+bool shapeTransformOutline(const Shape& shape, SwShape& sdata)
{
//TODO:
return true;
}
-bool shapeGenRle(const ShapeNode& shape, SwShape& sdata, const SwSize& clip)
+bool shapeGenRle(const Shape& shape, SwShape& sdata, const SwSize& clip)
{
if (sdata.outline->ptsCnt == 0 || sdata.outline->cntrsCnt <= 0) goto end;
if (!_updateBBox(sdata)) goto end;
}
-bool shapeGenOutline(const ShapeNode& shape, SwShape& sdata)
+bool shapeGenOutline(const Shape& shape, SwShape& sdata)
{
const PathCommand* cmds = nullptr;
auto cmdCnt = shape.pathCommands(&cmds);
struct Canvas::Impl
{
- vector<PaintNode*> nodes;
+ vector<Paint*> nodes;
RenderMethod* renderer;
- Impl(RenderMethod *pRenderer):renderer(pRenderer)
+ Impl(RenderMethod* pRenderer):renderer(pRenderer)
{
renderer->ref();
}
return 0;
}
- int push(unique_ptr<PaintNode> paint)
+ int push(unique_ptr<Paint> paint)
{
- PaintNode *node = paint.release();
+ Paint* node = paint.release();
assert(node);
nodes.push_back(node);
return node->update(renderer);
assert(renderer);
for (auto node : nodes) {
- if (SceneNode *scene = dynamic_cast<SceneNode *>(node)) {
+ if (Scene* scene = dynamic_cast<Scene*>(node)) {
cout << "TODO: " << scene << endl;
- } else if (ShapeNode *shape = dynamic_cast<ShapeNode *>(node)) {
+ } else if (Shape *shape = dynamic_cast<Shape*>(node)) {
if (!renderer->dispose(*shape, shape->engine())) return -1;
}
delete(node);
if (!renderer->clear()) return -1;
for(auto node: nodes) {
- if (SceneNode *scene = dynamic_cast<SceneNode *>(node)) {
+ if (Scene* scene = dynamic_cast<Scene*>(node)) {
cout << "TODO: " << scene << endl;
- } else if (ShapeNode *shape = dynamic_cast<ShapeNode *>(node)) {
+ } else if (Shape *shape = dynamic_cast<Shape*>(node)) {
if (!renderer->render(*shape, shape->engine())) return -1;
}
}
}
-int Canvas::push(unique_ptr<PaintNode> paint) noexcept
+int Canvas::push(unique_ptr<Paint> paint) noexcept
{
auto impl = pImpl.get();
assert(impl);
public:
enum UpdateFlag { None = 0, Path = 1, Fill = 2, All = 3 };
virtual ~RenderMethod() {}
- virtual void* prepare(const ShapeNode& shape, void* data, UpdateFlag flags) = 0;
- virtual bool dispose(const ShapeNode& shape, void *data) = 0;
- virtual bool render(const ShapeNode& shape, void *data) = 0;
+ virtual void* prepare(const Shape& shape, void* data, UpdateFlag flags) = 0;
+ virtual bool dispose(const Shape& shape, void *data) = 0;
+ virtual bool render(const Shape& shape, void *data) = 0;
virtual bool clear() = 0;
virtual size_t ref() = 0;
virtual size_t unref() = 0;
* limitations under the License.
*
*/
-#ifndef _TVG_SCENE_NODE_CPP_
-#define _TVG_SCENE_NODE_CPP_
+#ifndef _TVG_SCENE_CPP_
+#define _TVG_SCENE_CPP_
#include "tvgCommon.h"
/* Internal Class Implementation */
/************************************************************************/
-struct SceneNode::Impl
+struct Scene::Impl
{
};
/* External Class Implementation */
/************************************************************************/
-SceneNode::SceneNode() : pImpl(make_unique<Impl>())
+Scene::Scene() : pImpl(make_unique<Impl>())
{
}
-SceneNode::~SceneNode()
+Scene::~Scene()
{
- cout << "SceneNode(" << this << ") destroyed!" << endl;
+ cout << "Scene(" << this << ") destroyed!" << endl;
}
-unique_ptr<SceneNode> SceneNode::gen() noexcept
+unique_ptr<Scene> Scene::gen() noexcept
{
- return unique_ptr<SceneNode>(new SceneNode);
+ return unique_ptr<Scene>(new Scene);
}
-int SceneNode::push(unique_ptr<ShapeNode> shape) noexcept
+int Scene::push(unique_ptr<Shape> shape) noexcept
{
return 0;
}
-int SceneNode::update(RenderMethod* engine) noexcept
+int Scene::update(RenderMethod* engine) noexcept
{
return 0;
}
-#endif /* _TVG_SCENE_NODE_CPP_ */
+#endif /* _TVG_SCENE_CPP_ */
* limitations under the License.
*
*/
-#ifndef _TVG_SHAPE_NODE_CPP_
-#define _TVG_SHAPE_NODE_CPP_
+#ifndef _TVG_SHAPE_CPP_
+#define _TVG_SHAPE_CPP_
#include "tvgCommon.h"
#include "tvgShapePath.h"
};
-struct ShapeNode::Impl
+struct Shape::Impl
{
ShapeTransform *transform = nullptr;
ShapeFill *fill = nullptr;
/* External Class Implementation */
/************************************************************************/
-ShapeNode :: ShapeNode() : pImpl(make_unique<Impl>())
+Shape :: Shape() : pImpl(make_unique<Impl>())
{
}
-ShapeNode :: ~ShapeNode()
+Shape :: ~Shape()
{
}
-unique_ptr<ShapeNode> ShapeNode::gen() noexcept
+unique_ptr<Shape> Shape::gen() noexcept
{
- return unique_ptr<ShapeNode>(new ShapeNode);
+ return unique_ptr<Shape>(new Shape);
}
-void* ShapeNode::engine() noexcept
+void* Shape::engine() noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::update(RenderMethod* engine) noexcept
+int Shape::update(RenderMethod* engine) noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::reset() noexcept
+int Shape::reset() noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::pathCommands(const PathCommand** cmds) const noexcept
+int Shape::pathCommands(const PathCommand** cmds) const noexcept
{
auto impl = pImpl.get();
assert(impl && cmds);
}
-int ShapeNode::pathCoords(const Point** pts) const noexcept
+int Shape::pathCoords(const Point** pts) const noexcept
{
auto impl = pImpl.get();
assert(impl && pts);
}
-int ShapeNode::appendPath(const PathCommand *cmds, size_t cmdCnt, const Point* pts, size_t ptsCnt) noexcept
+int Shape::appendPath(const PathCommand *cmds, size_t cmdCnt, const Point* pts, size_t ptsCnt) noexcept
{
if (cmdCnt < 0 || ptsCnt < 0) return -1;
assert(cmds && pts);
}
-int ShapeNode::moveTo(float x, float y) noexcept
+int Shape::moveTo(float x, float y) noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::lineTo(float x, float y) noexcept
+int Shape::lineTo(float x, float y) noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept
+int Shape::cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::close() noexcept
+int Shape::close() noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::appendCircle(float cx, float cy, float radiusW, float radiusH) noexcept
+int Shape::appendCircle(float cx, float cy, float radiusW, float radiusH) noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::appendRect(float x, float y, float w, float h, float cornerRadius) noexcept
+int Shape::appendRect(float x, float y, float w, float h, float cornerRadius) noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::fill(size_t r, size_t g, size_t b, size_t a) noexcept
+int Shape::fill(size_t r, size_t g, size_t b, size_t a) noexcept
{
auto impl = pImpl.get();
assert(impl);
}
-int ShapeNode::fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
+int Shape::fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
{
auto impl = pImpl.get();
assert(impl);
return 0;
}
-#endif //_TVG_SHAPE_NODE_CPP_
+#endif //_TVG_SHAPE_CPP_
canvas->reserve(5);
//Prepare Round Rectangle
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50); //x, y, w, h, cornerRadius
shape1->fill(0, 255, 0, 255); //r, g, b, a
canvas->push(move(shape1));
//Prepare Circle
- auto shape2 = tvg::ShapeNode::gen();
+ auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
shape2->fill(170, 170, 0, 170); //r, g, b, a
canvas->push(move(shape2));
//Prepare Ellipse
- auto shape3 = tvg::ShapeNode::gen();
+ auto shape3 = tvg::Shape::gen();
shape3->appendCircle(400, 400, 250, 100); //cx, cy, radiusW, radiusH
shape3->fill(100, 100, 100, 100); //r, g, b, a
canvas->push(move(shape3));
//Prepare Star
- auto shape4 = tvg::ShapeNode::gen();
+ auto shape4 = tvg::Shape::gen();
shape4->moveTo(199, 234);
shape4->lineTo(253, 343);
shape4->lineTo(374, 360);
canvas->push(move(shape4));
//Prepare Opaque Ellipse
- auto shape5 = tvg::ShapeNode::gen();
+ auto shape5 = tvg::Shape::gen();
shape5->appendCircle(600, 650, 200, 150);
shape5->fill(0, 0, 255, 255);
canvas->push(move(shape5));
canvas->reserve(5); //reserve 5 shape nodes (optional)
//Prepare Shape1
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->appendRect(-100, -100, 1000, 1000, 50);
shape1->fill(255, 255, 255, 255);
canvas->push(move(shape1));
//Prepare Shape2
- auto shape2 = tvg::ShapeNode::gen();
+ auto shape2 = tvg::Shape::gen();
shape2->appendRect(-100, -100, 250, 250, 50);
shape2->fill(0, 0, 255, 255);
canvas->push(move(shape2));
//Prepare Shape3
- auto shape3 = tvg::ShapeNode::gen();
+ auto shape3 = tvg::Shape::gen();
shape3->appendRect(500, 500, 550, 550, 0);
shape3->fill(0, 255, 255, 255);
canvas->push(move(shape3));
//Prepare Shape4
- auto shape4 = tvg::ShapeNode::gen();
+ auto shape4 = tvg::Shape::gen();
shape4->appendCircle(800, 100, 200, 200);
shape4->fill(255, 255, 0, 255);
canvas->push(move(shape4));
//Prepare Shape5
- auto shape5 = tvg::ShapeNode::gen();
+ auto shape5 = tvg::Shape::gen();
shape5->appendCircle(200, 650, 250, 200);
shape5->fill(0, 0, 0, 255);
canvas->push(move(shape5));
auto canvas2 = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
//Create a Shape
- auto shape = tvg::ShapeNode::gen();
+ auto shape = tvg::Shape::gen();
shape->composite(canvas, tvg::CompMaskAdd);
//Draw the Scene onto the Canvas
static uint32_t buffer[WIDTH * HEIGHT];
unique_ptr<tvg::SwCanvas> canvas = nullptr;
-tvg::ShapeNode* pShape = nullptr;
+tvg::Shape* pShape = nullptr;
void tvgtest()
{
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Shape
- auto shape = tvg::ShapeNode::gen();
+ auto shape = tvg::Shape::gen();
/* Acquire shape pointer to access it again.
instead, you should consider not to interrupt this pointer life-cycle. */
auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
//Prepare a Shape
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->rect(0, 0, 400, 400, 0.1); //x, y, w, h, corner_radius
//Linear Gradient Fill
canvas->push(move(shape1));
//Prepare Circle
- auto shape2 = tvg::ShapeNode::gen();
+ auto shape2 = tvg::Shape::gen();
shape2->circle(400, 400, 200); //cx, cy, radius
//Radial Gradient Fill
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Prepare a Shape (Rectangle + Rectangle + Circle + Circle)
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 200, 200, 0); //x, y, w, h, cornerRadius
shape1->appendRect(100, 100, 300, 300, 100); //x, y, w, h, cornerRadius
shape1->appendCircle(400, 400, 100, 100); //cx, cy, radiusW, radiusH
canvas->reserve(3); //reserve 3 shape nodes (optional)
//Prepare Round Rectangle
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50); //x, y, w, h, cornerRadius
shape1->fill(0, 255, 0, 255); //r, g, b, a
canvas->push(move(shape1));
//Prepare Circle
- auto shape2 = tvg::ShapeNode::gen();
+ auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
shape2->fill(255, 255, 0, 255); //r, g, b, a
canvas->push(move(shape2));
//Prepare Ellipse
- auto shape3 = tvg::ShapeNode::gen();
+ auto shape3 = tvg::Shape::gen();
shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH
shape3->fill(0, 255, 255, 255); //r, g, b, a
canvas->push(move(shape3));
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Star
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
//Appends Paths
shape1->moveTo(199, 34);
canvas->push(move(shape1));
//Circle
- auto shape2 = tvg::ShapeNode::gen();
+ auto shape2 = tvg::Shape::gen();
auto cx = 550.0f;
auto cy = 550.0f;
pts[8] = {26, 161}; //LineTo
pts[9] = {146, 143}; //LineTo
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->appendPath(cmds, 11, pts, 10); //copy path data
shape1->fill(0, 255, 0, 255);
canvas->push(move(shape1));
pts2[11] = {cx - halfRadius, cy - radius}; //Ctrl2
pts2[12] = {cx, cy - radius}; //To
- auto shape2 = tvg::ShapeNode::gen();
+ auto shape2 = tvg::Shape::gen();
shape2->appendPath(cmds2, 6, pts2, 13); //copy path data
shape2->fill(255, 255, 0, 255);
canvas->push(move(shape2));
auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
//Create a Scene
- auto scene = tvg::SceneNode::gen();
+ auto scene = tvg::Scene::gen();
scene->reserve(3); //reserve 3 shape nodes (optional)
//Shape1
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->rect(0, 0, 400, 400, 0.1);
shape1->fill(255, 0, 0, 255);
shape1->rotate(0, 0, 45); //axis x, y, z
scene->push(move(shape1));
//Shape2
- auto shape2 = tvg::ShapeNode::gen();
+ auto shape2 = tvg::Shape::gen();
shape2->rect(0, 0, 400, 400, 0.1);
shape2->fill(0, 255, 0, 255);
shape2->transform(matrix); //by matrix (var matrix[4 * 4];)
scene->push(move(shape2));
//Shape3
- auto shape3 = tvg::ShapeNode::gen();
+ auto shape3 = tvg::Shape::gen();
shape3->rect(0, 0, 400, 400, 0.1);
shape3->fill(0, 0, 255, 255);
shape3->origin(100, 100); //offset
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Prepare a Shape (Rectangle)
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->appendRect(100, 100, 400, 400, 0); //x, y, w, h, cornerRadius
shape1->fill(255, 0, 0, 255); //r, g, b, a
auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
//Prepare a Shape
- auto shape1 = tvg::ShapeNode::gen();
+ auto shape1 = tvg::Shape::gen();
shape1->rect(0, 0, 400, 400, 0.1); //x, y, w, h, cornerRadius
shape1->fill(0, 255, 0, 255);
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Shape
- auto shape = tvg::ShapeNode::gen();
+ auto shape = tvg::Shape::gen();
shape->appendRect(-100, -100, 200, 200, 0);
shape->fill(255, 255, 255, 255);
canvas->push(move(shape));
canvas->clear();
//Shape
- auto shape = tvg::ShapeNode::gen();
+ auto shape = tvg::Shape::gen();
shape->appendRect(-100 + (800 * progress), -100 + (800 * progress), 200, 200, (100 * progress));
shape->fill(rand()%255, rand()%255, rand()%255, 255);
canvas->push(move(shape));