From 123f76e7ed28430771c2fa8dd083918ff507e682 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 9 Aug 2018 10:10:44 +0900 Subject: [PATCH] lottie/player: take buffer argument by value. As we have async rendering, we can't rely on the caller to keep the buffer alive till render finish. Change-Id: Ic7f9670a5e5003424c2b695c171a13717e531b21 --- inc/lottieplayer.h | 14 +++++++------- src/lottie/lottieplayer.cpp | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/inc/lottieplayer.h b/inc/lottieplayer.h index 795a347..1fcdb77 100644 --- a/inc/lottieplayer.h +++ b/inc/lottieplayer.h @@ -30,11 +30,11 @@ class LOTPlayerPrivate; class LOTNode; struct LOT_EXPORT LOTBuffer { - uint32_t *buffer; - int width; - int height; - int bytesPerLine; - bool clear; + uint32_t *buffer = nullptr; + int width = 0; + int height = 0; + int bytesPerLine = 0; + bool clear = true; }; class LOT_EXPORT LOTPlayer { @@ -54,8 +54,8 @@ public: // TODO: Consider correct position... void setSize(int width, int height); void size(int &width, int &height) const; - std::future render(float pos, LOTBuffer &buffer); - bool renderSync(float pos, LOTBuffer &buffer); + std::future render(float pos, LOTBuffer buffer); + bool renderSync(float pos, LOTBuffer buffer); public: LOTPlayerPrivate *d; diff --git a/src/lottie/lottieplayer.cpp b/src/lottie/lottieplayer.cpp index 8683b8e..382bf2c 100644 --- a/src/lottie/lottieplayer.cpp +++ b/src/lottie/lottieplayer.cpp @@ -200,12 +200,12 @@ public: } std::future render(LOTPlayerPrivate *impl, float pos, - LOTBuffer &buffer) + LOTBuffer &&buffer) { RenderTask *task = new RenderTask(); task->playerImpl = impl; task->pos = pos; - task->buffer = buffer; + task->buffer = std::move(buffer); return async(task); } }; @@ -262,12 +262,12 @@ const std::vector &LOTPlayer::renderList() const return d->renderList(); } -std::future LOTPlayer::render(float pos, LOTBuffer &buffer) +std::future LOTPlayer::render(float pos, LOTBuffer buffer) { - return render_scheduler.render(d, pos, buffer); + return render_scheduler.render(d, pos, std::move(buffer)); } -bool LOTPlayer::renderSync(float pos, LOTBuffer &buffer) +bool LOTPlayer::renderSync(float pos, LOTBuffer buffer) { return d->render(pos, buffer); } -- 2.7.4