mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-24 00:43:56 +00:00
infra: add the partial rendering build option
allow users to set partial rendering as option to use, enabled by deault. -Dextra="partial_render, ..."
This commit is contained in:
parent
2aabddd5a5
commit
caec92ddd3
4 changed files with 68 additions and 39 deletions
|
@ -126,6 +126,12 @@ endif
|
|||
|
||||
|
||||
#Extra
|
||||
partial_render = get_option('extra').contains('partial_render')
|
||||
|
||||
if partial_render
|
||||
config_h.set10('THORVG_PARTIAL_RENDER_SUPPORT', true)
|
||||
endif
|
||||
|
||||
lottie_expressions = lottie_loader and get_option('extra').contains('lottie_expressions')
|
||||
|
||||
if lottie_expressions
|
||||
|
@ -230,6 +236,7 @@ summary(
|
|||
|
||||
summary(
|
||||
{
|
||||
'Partial Rendering': partial_render,
|
||||
'Lottie Expressions': lottie_expressions,
|
||||
'OpenGL Variant': gl_variant,
|
||||
},
|
||||
|
|
|
@ -65,6 +65,6 @@ option('file',
|
|||
|
||||
option('extra',
|
||||
type: 'array',
|
||||
choices: ['', 'opengl_es', 'lottie_expressions'],
|
||||
value: ['lottie_expressions'],
|
||||
choices: ['', 'partial_render', 'opengl_es', 'lottie_expressions'],
|
||||
value: ['partial_render', 'lottie_expressions'],
|
||||
description: '"Enable support for extra options')
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "tvgMath.h"
|
||||
#include "tvgRender.h"
|
||||
|
||||
|
@ -131,6 +130,9 @@ void RenderRegion::intersect(const RenderRegion& rhs)
|
|||
if (max.y < min.y) max.y = min.y;
|
||||
}
|
||||
|
||||
#ifdef THORVG_PARTIAL_RENDER_SUPPORT
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
void RenderDirtyRegion::init(uint32_t w, uint32_t h)
|
||||
{
|
||||
|
@ -311,6 +313,8 @@ void RenderDirtyRegion::commit()
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
/* RenderTrimPath Class Implementation */
|
||||
/************************************************************************/
|
||||
|
|
|
@ -155,51 +155,69 @@ struct RenderRegion
|
|||
uint32_t h() const { return (uint32_t) sh(); }
|
||||
};
|
||||
|
||||
struct RenderDirtyRegion
|
||||
{
|
||||
public:
|
||||
static constexpr const int PARTITIONING = 16; //must be N*N
|
||||
|
||||
void init(uint32_t w, uint32_t h);
|
||||
void commit();
|
||||
void add(const RenderRegion* prv, const RenderRegion* cur); //collect the old and new dirty regions together
|
||||
void clear();
|
||||
|
||||
bool deactivate(bool on)
|
||||
#ifdef THORVG_PARTIAL_RENDER_SUPPORT
|
||||
struct RenderDirtyRegion
|
||||
{
|
||||
std::swap(on, disabled);
|
||||
return on;
|
||||
}
|
||||
public:
|
||||
static constexpr const int PARTITIONING = 16; //must be N*N
|
||||
|
||||
bool deactivated()
|
||||
{
|
||||
return disabled;
|
||||
}
|
||||
void init(uint32_t w, uint32_t h);
|
||||
void commit();
|
||||
void add(const RenderRegion* prv, const RenderRegion* cur); //collect the old and new dirty regions together
|
||||
void clear();
|
||||
|
||||
const RenderRegion& partition(int idx)
|
||||
{
|
||||
return partitions[idx].region;
|
||||
}
|
||||
bool deactivate(bool on)
|
||||
{
|
||||
std::swap(on, disabled);
|
||||
return on;
|
||||
}
|
||||
|
||||
const Array<RenderRegion>& get(int idx)
|
||||
{
|
||||
return partitions[idx].list[partitions[idx].current];
|
||||
}
|
||||
bool deactivated()
|
||||
{
|
||||
return disabled;
|
||||
}
|
||||
|
||||
private:
|
||||
void subdivide(Array<RenderRegion>& targets, uint32_t idx, RenderRegion& lhs, RenderRegion& rhs);
|
||||
const RenderRegion& partition(int idx)
|
||||
{
|
||||
return partitions[idx].region;
|
||||
}
|
||||
|
||||
struct Partition
|
||||
{
|
||||
RenderRegion region;
|
||||
Array<RenderRegion> list[2]; //double buffer swapping
|
||||
uint8_t current = 0; //double buffer swapping list index. 0 or 1
|
||||
const Array<RenderRegion>& get(int idx)
|
||||
{
|
||||
return partitions[idx].list[partitions[idx].current];
|
||||
}
|
||||
|
||||
private:
|
||||
void subdivide(Array<RenderRegion>& targets, uint32_t idx, RenderRegion& lhs, RenderRegion& rhs);
|
||||
|
||||
struct Partition
|
||||
{
|
||||
RenderRegion region;
|
||||
Array<RenderRegion> list[2]; //double buffer swapping
|
||||
uint8_t current = 0; //double buffer swapping list index. 0 or 1
|
||||
};
|
||||
|
||||
Key key;
|
||||
Partition partitions[PARTITIONING];
|
||||
bool disabled = false;
|
||||
};
|
||||
#else
|
||||
struct RenderDirtyRegion
|
||||
{
|
||||
static constexpr const int PARTITIONING = 16; //must be N*N
|
||||
|
||||
void init(uint32_t w, uint32_t h) {}
|
||||
void commit() {}
|
||||
void add(TVG_UNUSED const RenderRegion* prv, TVG_UNUSED const RenderRegion* cur) {}
|
||||
void clear() {}
|
||||
bool deactivate(TVG_UNUSED bool on) { return true; }
|
||||
bool deactivated() { return true; }
|
||||
const RenderRegion& partition(TVG_UNUSED int idx) { static RenderRegion tmp{}; return tmp; }
|
||||
const Array<RenderRegion>& get(TVG_UNUSED int idx) { static Array<RenderRegion> tmp; return tmp; }
|
||||
};
|
||||
#endif
|
||||
|
||||
Key key;
|
||||
Partition partitions[PARTITIONING];
|
||||
bool disabled = false;
|
||||
};
|
||||
|
||||
struct RenderPath
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue