mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
sw_engine: fix missing shape update issue.
It missed to update shape data if visilibity is changed from false to true by alpha. Also, it needs to update engine shape data for every requests. There scenario can be allowed, 1. update shape 2. change shape property 3. update shape 4. draw previously engine could skip step 3, its result was not properly expected. @fix #84
This commit is contained in:
parent
77ccbcc6fe
commit
2a239714af
4 changed files with 26 additions and 5 deletions
|
@ -8,6 +8,7 @@
|
||||||
#define NUM_PER_LINE 16
|
#define NUM_PER_LINE 16
|
||||||
#define SIZE 50
|
#define SIZE 50
|
||||||
|
|
||||||
|
static bool rendered = false;
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
static int frame = 0;
|
static int frame = 0;
|
||||||
static std::vector<tvg::Picture*> pictures;
|
static std::vector<tvg::Picture*> pictures;
|
||||||
|
@ -108,10 +109,14 @@ void drawSwView(void* data, Eo* obj)
|
||||||
|
|
||||||
t4 = ecore_time_get();
|
t4 = ecore_time_get();
|
||||||
printf("[%5d]: total[%fs] update[%fs], render[%fs]\n", ++frame, t4 - t1, t2 - t1, t4 - t3);
|
printf("[%5d]: total[%fs] update[%fs], render[%fs]\n", ++frame, t4 - t1, t2 - t1, t4 - t3);
|
||||||
|
|
||||||
|
rendered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
|
void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
|
||||||
{
|
{
|
||||||
|
if (!rendered) return;
|
||||||
|
|
||||||
t1 = ecore_time_get();
|
t1 = ecore_time_get();
|
||||||
|
|
||||||
for (auto picture : pictures) {
|
for (auto picture : pictures) {
|
||||||
|
@ -124,7 +129,9 @@ void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progre
|
||||||
//Update Efl Canvas
|
//Update Efl Canvas
|
||||||
auto img = (Eo*) effect;
|
auto img = (Eo*) effect;
|
||||||
evas_object_image_pixels_dirty_set(img, EINA_TRUE);
|
evas_object_image_pixels_dirty_set(img, EINA_TRUE);
|
||||||
evas_object_image_data_update_add(img, 0, 0, WIDTH, HEIGHT);
|
evas_object_image_data_update_add(img, 0, 0, WIDTH, HEIGHT);
|
||||||
|
|
||||||
|
rendered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,7 @@ SwFixed mathMean(SwFixed angle1, SwFixed angle2);
|
||||||
void shapeReset(SwShape* shape);
|
void shapeReset(SwShape* shape);
|
||||||
bool shapeGenOutline(SwShape* shape, const Shape* sdata, const Matrix* transform);
|
bool shapeGenOutline(SwShape* shape, const Shape* sdata, const Matrix* transform);
|
||||||
bool shapePrepare(SwShape* shape, const Shape* sdata, const SwSize& clip, const Matrix* transform);
|
bool shapePrepare(SwShape* shape, const Shape* sdata, const SwSize& clip, const Matrix* transform);
|
||||||
|
bool shapePrepared(SwShape* shape);
|
||||||
bool shapeGenRle(SwShape* shape, const Shape* sdata, const SwSize& clip, bool antiAlias, bool hasComposite);
|
bool shapeGenRle(SwShape* shape, const Shape* sdata, const SwSize& clip, bool antiAlias, bool hasComposite);
|
||||||
void shapeDelOutline(SwShape* shape);
|
void shapeDelOutline(SwShape* shape);
|
||||||
void shapeResetStroke(SwShape* shape, const Shape* sdata, const Matrix* transform);
|
void shapeResetStroke(SwShape* shape, const Shape* sdata, const Matrix* transform);
|
||||||
|
|
|
@ -49,13 +49,17 @@ struct SwTask : Task
|
||||||
|
|
||||||
SwSize clip = {static_cast<SwCoord>(surface->w), static_cast<SwCoord>(surface->h)};
|
SwSize clip = {static_cast<SwCoord>(surface->w), static_cast<SwCoord>(surface->h)};
|
||||||
|
|
||||||
|
//Invisiable shape turned to visible by alpha.
|
||||||
|
auto prepareShape = false;
|
||||||
|
if (!shapePrepared(&shape) && (flags & RenderUpdateFlag::Color)) prepareShape = true;
|
||||||
|
|
||||||
//Shape
|
//Shape
|
||||||
if (flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform)) {
|
if (flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform) || prepareShape) {
|
||||||
shapeReset(&shape);
|
|
||||||
uint8_t alpha = 0;
|
uint8_t alpha = 0;
|
||||||
sdata->fill(nullptr, nullptr, nullptr, &alpha);
|
sdata->fill(nullptr, nullptr, nullptr, &alpha);
|
||||||
bool renderShape = (alpha > 0 || sdata->fill());
|
bool renderShape = (alpha > 0 || sdata->fill());
|
||||||
if (renderShape || strokeAlpha) {
|
if (renderShape || strokeAlpha) {
|
||||||
|
shapeReset(&shape);
|
||||||
if (!shapePrepare(&shape, sdata, clip, transform)) return;
|
if (!shapePrepare(&shape, sdata, clip, transform)) return;
|
||||||
if (renderShape) {
|
if (renderShape) {
|
||||||
auto antiAlias = (strokeAlpha > 0 && strokeWidth >= 2) ? false : true;
|
auto antiAlias = (strokeAlpha > 0 && strokeWidth >= 2) ? false : true;
|
||||||
|
@ -209,12 +213,15 @@ void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform*
|
||||||
if (!task) return nullptr;
|
if (!task) return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags == RenderUpdateFlag::None || task->valid()) return task;
|
if (flags == RenderUpdateFlag::None) return task;
|
||||||
|
|
||||||
|
//Finish previous task if it has duplicated request.
|
||||||
|
if (task->valid()) task->get();
|
||||||
|
|
||||||
task->sdata = &sdata;
|
task->sdata = &sdata;
|
||||||
|
|
||||||
if (compList.size() > 0) {
|
if (compList.size() > 0) {
|
||||||
//Gurantee composition targets get ready.
|
//Guarantee composition targets get ready.
|
||||||
for (auto comp : compList) static_cast<SwTask*>(comp.edata)->get();
|
for (auto comp : compList) static_cast<SwTask*>(comp.edata)->get();
|
||||||
task->compList.assign(compList.begin(), compList.end());
|
task->compList.assign(compList.begin(), compList.end());
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,6 +459,12 @@ bool shapePrepare(SwShape* shape, const Shape* sdata, const SwSize& clip, const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool shapePrepared(SwShape* shape)
|
||||||
|
{
|
||||||
|
return shape->rle ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool shapeGenRle(SwShape* shape, TVG_UNUSED const Shape* sdata, const SwSize& clip, bool antiAlias, bool hasComposite)
|
bool shapeGenRle(SwShape* shape, TVG_UNUSED const Shape* sdata, const SwSize& clip, bool antiAlias, bool hasComposite)
|
||||||
{
|
{
|
||||||
//FIXME: Should we draw it?
|
//FIXME: Should we draw it?
|
||||||
|
|
Loading…
Add table
Reference in a new issue