Skip to content

Commit

Permalink
Allow mirroring of lottie frames.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Sep 16, 2021
1 parent a8ffe6c commit ddeb78f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lottie/lottie_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum class Error {
struct FrameRequest {
QSize box;
std::optional<QColor> colored;
bool mirrorHorizontal = false;

[[nodiscard]] bool empty() const {
return box.isEmpty();
Expand All @@ -46,7 +47,8 @@ struct FrameRequest {

[[nodiscard]] bool operator==(const FrameRequest &other) const {
return (box == other.box)
&& (colored == other.colored);
&& (colored == other.colored)
&& (mirrorHorizontal == other.mirrorHorizontal);
}
[[nodiscard]] bool operator!=(const FrameRequest &other) const {
return !(*this == other);
Expand Down
5 changes: 4 additions & 1 deletion lottie/lottie_frame_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class FrameRendererObject final {
const FrameRequest &request) {
if (request.box.isEmpty()) {
return true;
} else if (request.colored.has_value()) {
} else if (request.colored.has_value() || request.mirrorHorizontal) {
return false;
}
const auto size = image.size();
Expand All @@ -112,6 +112,9 @@ class FrameRendererObject final {
p.setRenderHint(QPainter::SmoothPixmapTransform);
p.drawImage(QRect(QPoint(), size), original);
}
if (request.mirrorHorizontal) {
storage = std::move(storage).mirrored(true, false);
}
if (request.colored.has_value()) {
storage = Images::prepareColored(*request.colored, std::move(storage));
}
Expand Down

0 comments on commit ddeb78f

Please sign in to comment.