mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
test: ++code safety
added null check for exceptional case. Change-Id: I12a5e9724149f607188b67a84e46a033a16270f7
This commit is contained in:
parent
56c0235dc5
commit
a5d1542e44
20 changed files with 63 additions and 14 deletions
|
@ -10,6 +10,8 @@ static unsigned cnt = 0;
|
|||
|
||||
bool tvgUpdateCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return false;
|
||||
|
||||
auto t = ecore_time_get();
|
||||
|
||||
//Explicitly clear all retained paint nodes.
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
canvas->reserve(5);
|
||||
|
||||
//Prepare Round Rectangle
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
canvas->reserve(5); //reserve 5 shape nodes (optional)
|
||||
|
||||
//Prepare Shape1
|
||||
|
|
|
@ -12,14 +12,13 @@ using namespace std;
|
|||
/************************************************************************/
|
||||
|
||||
void tvgSwTest(uint32_t* buffer);
|
||||
void drawSwView(void* data, Eo* obj);
|
||||
|
||||
void win_del(void *data, Evas_Object *o, void *ev)
|
||||
{
|
||||
elm_exit();
|
||||
}
|
||||
|
||||
void drawSwView(void* data, Eo* obj);
|
||||
|
||||
static Eo* createSwView()
|
||||
{
|
||||
static uint32_t buffer[WIDTH * HEIGHT];
|
||||
|
|
|
@ -7,6 +7,8 @@ tvg::Shape* pShape = nullptr;
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Shape1
|
||||
auto shape = tvg::Shape::gen();
|
||||
|
||||
|
@ -33,6 +35,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
|||
|
||||
void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
/* Update shape directly.
|
||||
You can update only necessary properties of this shape,
|
||||
while retaining other properties. */
|
||||
|
@ -202,4 +206,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ tvg::Shape* pShape = nullptr;
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Shape
|
||||
auto shape = tvg::Shape::gen();
|
||||
|
||||
|
@ -26,6 +28,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
|||
|
||||
void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
/* Update shape directly.
|
||||
You can update only necessary properties of this shape,
|
||||
while retaining other properties. */
|
||||
|
|
|
@ -9,6 +9,8 @@ tvg::Shape* pShape3 = nullptr;
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Shape1
|
||||
auto shape = tvg::Shape::gen();
|
||||
|
||||
|
@ -83,6 +85,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
|||
|
||||
void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
/* Update shape directly.
|
||||
You can update only necessary properties of this shape,
|
||||
while retaining other properties. */
|
||||
|
@ -230,4 +234,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
canvas->reserve(3); //reserve 3 shape nodes (optional)
|
||||
|
||||
//Prepare Round Rectangle
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
canvas->reserve(3); //reserve 3 shape nodes (optional)
|
||||
|
||||
//Prepare Round Rectangle
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Star
|
||||
auto shape1 = tvg::Shape::gen();
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
/* Star */
|
||||
|
||||
//Prepare Path Commands
|
||||
|
@ -182,4 +184,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
canvas->reserve(3); //reserve 3 shape nodes (optional)
|
||||
|
||||
//Prepare Round Rectangle
|
||||
|
@ -168,4 +170,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Create a Scene
|
||||
auto scene = tvg::Scene::gen();
|
||||
scene->reserve(3); //reserve 3 shape nodes (optional)
|
||||
|
@ -175,4 +177,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ tvg::Scene* pScene2 = nullptr;
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Create a Scene1
|
||||
auto scene = tvg::Scene::gen();
|
||||
pScene1 = scene.get();
|
||||
|
@ -90,6 +92,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
|||
|
||||
void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
/* Update scene directly.
|
||||
You can update only necessary properties of this scene,
|
||||
while retaining other properties. */
|
||||
|
@ -226,4 +230,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Prepare a Shape (Rectangle + Rectangle + Circle + Circle)
|
||||
auto shape1 = tvg::Shape::gen();
|
||||
shape1->appendRect(0, 0, 200, 200, 0, 0); //x, y, w, h, rx, ry
|
||||
|
@ -118,4 +120,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Shape 1
|
||||
auto shape1 = tvg::Shape::gen();
|
||||
shape1->appendRect(50, 50, 200, 200, 0, 0);
|
||||
|
@ -165,4 +167,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Test for Stroke Width
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
auto shape = tvg::Shape::gen();
|
||||
|
@ -202,4 +204,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ void svgDirCallback(const char* name, const char* path, void* data)
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Background
|
||||
auto shape = tvg::Shape::gen();
|
||||
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry
|
||||
|
@ -142,4 +144,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ tvg::Shape* pShape3 = nullptr;
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Shape1
|
||||
auto shape = tvg::Shape::gen();
|
||||
|
||||
|
@ -46,6 +48,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
|||
|
||||
void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
/* Update shape directly.
|
||||
You can update only necessary properties of this shape,
|
||||
while retaining other properties. */
|
||||
|
@ -193,4 +197,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Shape
|
||||
auto shape = tvg::Shape::gen();
|
||||
shape->appendRect(-100, -100, 200, 200, 0, 0);
|
||||
|
@ -15,6 +17,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
|||
|
||||
void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
|
||||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Explicitly clear all retained paint nodes.
|
||||
if (canvas->clear() != tvg::Result::Success) return;
|
||||
|
||||
|
@ -154,4 +158,4 @@ int main(int argc, char **argv)
|
|||
cout << "engine is not supported" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue