mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
example stress: revise the sample.
use canvas::paints() instead of a local list.
This commit is contained in:
parent
0e97d21752
commit
1ed48ccbdb
1 changed files with 17 additions and 16 deletions
|
@ -34,11 +34,12 @@ static bool rendered = false;
|
||||||
static int xCnt = 0;
|
static int xCnt = 0;
|
||||||
static int yCnt = 0;
|
static int yCnt = 0;
|
||||||
static int frame = 0;
|
static int frame = 0;
|
||||||
static std::vector<tvg::Picture*> pictures;
|
|
||||||
static double t1, t2, t3, t4;
|
static double t1, t2, t3, t4;
|
||||||
|
|
||||||
void svgDirCallback(const char* name, const char* path, void* data)
|
void svgDirCallback(const char* name, const char* path, void* data)
|
||||||
{
|
{
|
||||||
|
tvg::Canvas* canvas = static_cast<tvg::Canvas*>(data);
|
||||||
|
|
||||||
if (yCnt > NUM_PER_LINE) return; //Load maximum to NUM_PER_LINE
|
if (yCnt > NUM_PER_LINE) return; //Load maximum to NUM_PER_LINE
|
||||||
|
|
||||||
//ignore if not svgs.
|
//ignore if not svgs.
|
||||||
|
@ -72,14 +73,14 @@ void svgDirCallback(const char* name, const char* path, void* data)
|
||||||
|
|
||||||
//Duplicates
|
//Duplicates
|
||||||
for (int i = 0; i < NUM_PER_LINE - 1; i++) {
|
for (int i = 0; i < NUM_PER_LINE - 1; i++) {
|
||||||
tvg::Picture* dup = static_cast<tvg::Picture*>(picture->duplicate());
|
auto dup = tvg::cast<tvg::Picture>(picture->duplicate());
|
||||||
dup->translate((xCnt % NUM_PER_LINE) * SIZE + shiftX, SIZE * (xCnt / NUM_PER_LINE) + shiftY);
|
dup->translate((xCnt % NUM_PER_LINE) * SIZE + shiftX, SIZE * (xCnt / NUM_PER_LINE) + shiftY);
|
||||||
pictures.push_back(dup);
|
canvas->push(std::move(dup));
|
||||||
++xCnt;
|
++xCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "SVG: " << buf << endl;
|
cout << "SVG: " << buf << endl;
|
||||||
pictures.push_back(picture.release());
|
canvas->push(std::move(picture));
|
||||||
|
|
||||||
++yCnt;
|
++yCnt;
|
||||||
}
|
}
|
||||||
|
@ -96,14 +97,6 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, svgDirCallback, canvas);
|
eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, svgDirCallback, canvas);
|
||||||
|
|
||||||
/* This showcase shows you asynchrounous loading of svg.
|
|
||||||
For this, pushing pictures at a certian sync time.
|
|
||||||
This means it earns the time to finish loading svg resources,
|
|
||||||
otherwise you can push pictures immediately. */
|
|
||||||
for (auto picture : pictures) {
|
|
||||||
canvas->push(tvg::cast<tvg::Picture>(picture));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,11 +140,15 @@ void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progre
|
||||||
|
|
||||||
t1 = ecore_time_get();
|
t1 = ecore_time_get();
|
||||||
|
|
||||||
for (auto picture : pictures) {
|
auto& list = swCanvas->paints();
|
||||||
|
|
||||||
|
for (auto picture : list) {
|
||||||
|
if (picture->identifier() != tvg::Picture::identifier()) continue;
|
||||||
picture->rotate(progress * 360);
|
picture->rotate(progress * 360);
|
||||||
swCanvas->update(picture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swCanvas->update();
|
||||||
|
|
||||||
t2 = ecore_time_get();
|
t2 = ecore_time_get();
|
||||||
|
|
||||||
//Update Efl Canvas
|
//Update Efl Canvas
|
||||||
|
@ -197,10 +194,14 @@ void drawGLview(Evas_Object *obj)
|
||||||
|
|
||||||
void transitGlCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
|
void transitGlCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
|
||||||
{
|
{
|
||||||
for (auto picture : pictures) {
|
auto& list = glCanvas->paints();
|
||||||
|
|
||||||
|
for (auto picture : list) {
|
||||||
|
if (picture->identifier() != tvg::Picture::identifier()) continue;
|
||||||
picture->rotate(progress * 360);
|
picture->rotate(progress * 360);
|
||||||
glCanvas->update(picture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glCanvas->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue