mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-15 16:36:36 +00:00
lottie/render: Construct on first use of thread pool instance by moving into a singleton instance() api.
Starting in C++11, scoped static initialization is now thread-safe Change-Id: Ia6933b439407e9dd635be67328eb750acf5b0367
This commit is contained in:
parent
d1c3b19e01
commit
d00a8fe714
@ -120,7 +120,6 @@ class RenderTaskScheduler {
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
RenderTaskScheduler()
|
||||
{
|
||||
for (unsigned n = 0; n != _count; ++n) {
|
||||
@ -128,6 +127,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
static RenderTaskScheduler& instance()
|
||||
{
|
||||
static RenderTaskScheduler singleton;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
~RenderTaskScheduler()
|
||||
{
|
||||
for (auto &e : _q) e.done();
|
||||
@ -159,7 +165,6 @@ public:
|
||||
return async(std::move(task));
|
||||
}
|
||||
};
|
||||
static RenderTaskScheduler render_scheduler;
|
||||
|
||||
/**
|
||||
* \breif Brief abput the Api.
|
||||
@ -236,7 +241,7 @@ Animation::renderTree(size_t frameNo, size_t width, size_t height) const
|
||||
|
||||
std::future<Surface> Animation::render(size_t frameNo, Surface surface)
|
||||
{
|
||||
return render_scheduler.render(d.get(), frameNo, std::move(surface));
|
||||
return RenderTaskScheduler::instance().render(d.get(), frameNo, std::move(surface));
|
||||
}
|
||||
|
||||
void Animation::renderSync(size_t frameNo, Surface surface)
|
||||
|
@ -355,13 +355,18 @@ class RleTaskScheduler {
|
||||
SW_FT_Stroker_Done(stroker);
|
||||
}
|
||||
|
||||
public:
|
||||
RleTaskScheduler()
|
||||
{
|
||||
for (unsigned n = 0; n != _count; ++n) {
|
||||
_threads.emplace_back([&, n] { run(n); });
|
||||
}
|
||||
}
|
||||
public:
|
||||
static RleTaskScheduler& instance()
|
||||
{
|
||||
static RleTaskScheduler singleton;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
~RleTaskScheduler()
|
||||
{
|
||||
@ -412,8 +417,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static RleTaskScheduler raster_scheduler;
|
||||
|
||||
void VRaster::generateFillInfo(RleShare &promise, VPath &&path, VRle &&rle,
|
||||
FillRule fillRule, const VRect &clip)
|
||||
{
|
||||
@ -421,7 +424,7 @@ void VRaster::generateFillInfo(RleShare &promise, VPath &&path, VRle &&rle,
|
||||
promise->set_value(VRle());
|
||||
return;
|
||||
}
|
||||
return raster_scheduler.fillRle(promise, std::move(path), std::move(rle), fillRule, clip);
|
||||
return RleTaskScheduler::instance().fillRle(promise, std::move(path), std::move(rle), fillRule, clip);
|
||||
}
|
||||
|
||||
void VRaster::generateStrokeInfo(RleShare &promise, VPath &&path, VRle &&rle, CapStyle cap,
|
||||
@ -432,7 +435,7 @@ void VRaster::generateStrokeInfo(RleShare &promise, VPath &&path, VRle &&rle, Ca
|
||||
promise->set_value(VRle());
|
||||
return;
|
||||
}
|
||||
return raster_scheduler.strokeRle(promise, std::move(path), std::move(rle), cap, join, width, meterLimit, clip);
|
||||
return RleTaskScheduler::instance().strokeRle(promise, std::move(path), std::move(rle), cap, join, width, meterLimit, clip);
|
||||
}
|
||||
|
||||
V_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user