mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-11 15:12:08 +00:00
renderer: ++optimization
skip locking if the thread number is 0.
This commit is contained in:
parent
04dbc5f509
commit
19815de7d7
3 changed files with 24 additions and 14 deletions
|
@ -28,6 +28,7 @@
|
||||||
#define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
|
#define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include "tvgTaskScheduler.h"
|
||||||
|
|
||||||
namespace tvg {
|
namespace tvg {
|
||||||
|
|
||||||
|
@ -42,13 +43,17 @@ namespace tvg {
|
||||||
|
|
||||||
ScopedLock(Key& k)
|
ScopedLock(Key& k)
|
||||||
{
|
{
|
||||||
k.mtx.lock();
|
if (TaskScheduler::threads() > 0) {
|
||||||
key = &k;
|
k.mtx.lock();
|
||||||
|
key = &k;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~ScopedLock()
|
~ScopedLock()
|
||||||
{
|
{
|
||||||
key->mtx.unlock();
|
if (TaskScheduler::threads() > 0) {
|
||||||
|
key->mtx.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,20 @@
|
||||||
/* External Class Implementation */
|
/* External Class Implementation */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
uint32_t RenderMethod::ref()
|
||||||
|
{
|
||||||
|
ScopedLock lock(key);
|
||||||
|
return (++refCnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t RenderMethod::unref()
|
||||||
|
{
|
||||||
|
ScopedLock lock(key);
|
||||||
|
return (--refCnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderTransform::override(const Matrix& m)
|
void RenderTransform::override(const Matrix& m)
|
||||||
{
|
{
|
||||||
this->m = m;
|
this->m = m;
|
||||||
|
|
|
@ -248,17 +248,8 @@ private:
|
||||||
Key key;
|
Key key;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t ref()
|
uint32_t ref();
|
||||||
{
|
uint32_t unref();
|
||||||
ScopedLock lock(key);
|
|
||||||
return (++refCnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t unref()
|
|
||||||
{
|
|
||||||
ScopedLock lock(key);
|
|
||||||
return (--refCnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~RenderMethod() {}
|
virtual ~RenderMethod() {}
|
||||||
virtual RenderData prepare(const RenderShape& rshape, RenderData data, const RenderTransform* transform, Array<RenderData>& clips, uint8_t opacity, RenderUpdateFlag flags, bool clipper) = 0;
|
virtual RenderData prepare(const RenderShape& rshape, RenderData data, const RenderTransform* transform, Array<RenderData>& clips, uint8_t opacity, RenderUpdateFlag flags, bool clipper) = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue