mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 22:23:27 +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
|
||||
|
||||
#include <mutex>
|
||||
#include "tvgTaskScheduler.h"
|
||||
|
||||
namespace tvg {
|
||||
|
||||
|
@ -42,13 +43,17 @@ namespace tvg {
|
|||
|
||||
ScopedLock(Key& k)
|
||||
{
|
||||
k.mtx.lock();
|
||||
key = &k;
|
||||
if (TaskScheduler::threads() > 0) {
|
||||
k.mtx.lock();
|
||||
key = &k;
|
||||
}
|
||||
}
|
||||
|
||||
~ScopedLock()
|
||||
{
|
||||
key->mtx.unlock();
|
||||
if (TaskScheduler::threads() > 0) {
|
||||
key->mtx.unlock();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -32,6 +32,20 @@
|
|||
/* 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)
|
||||
{
|
||||
this->m = m;
|
||||
|
|
|
@ -248,17 +248,8 @@ private:
|
|||
Key key;
|
||||
|
||||
public:
|
||||
uint32_t ref()
|
||||
{
|
||||
ScopedLock lock(key);
|
||||
return (++refCnt);
|
||||
}
|
||||
|
||||
uint32_t unref()
|
||||
{
|
||||
ScopedLock lock(key);
|
||||
return (--refCnt);
|
||||
}
|
||||
uint32_t ref();
|
||||
uint32_t unref();
|
||||
|
||||
virtual ~RenderMethod() {}
|
||||
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