diff --git a/src/base/BitmapComposition.cpp b/src/base/BitmapComposition.cpp
index 00c02552a7..7b3a629c80 100644
--- a/src/base/BitmapComposition.cpp
+++ b/src/base/BitmapComposition.cpp
@@ -22,103 +22,103 @@
namespace pag {
BitmapComposition::~BitmapComposition() {
- for (auto sequence : sequences) {
- delete sequence;
- }
+ for (auto sequence : sequences) {
+ delete sequence;
+ }
}
CompositionType BitmapComposition::type() const {
- return CompositionType::Bitmap;
+ return CompositionType::Bitmap;
}
static bool IsEmptyBitmapFrame(BitmapFrame* frame) {
- // There was a bug in PAGExporter that causes an empty frame being exported as 1x1 frame, so we
- // need to identify this kind of empty frame here.
- for (auto bitmap : frame->bitmaps) {
- if (bitmap->x != 0 || bitmap->y != 0) {
- return false;
- }
- if (bitmap->fileBytes->length() > 150) {
- return false;
- }
+ // There was a bug in PAGExporter that causes an empty frame being exported as 1x1 frame, so we
+ // need to identify this kind of empty frame here.
+ for (auto bitmap : frame->bitmaps) {
+ if (bitmap->x != 0 || bitmap->y != 0) {
+ return false;
+ }
+ if (bitmap->fileBytes->length() > 150) {
+ return false;
+ }
- int width = 0;
- int height = 0;
- if (!WebPGetInfo(bitmap->fileBytes->data(), bitmap->fileBytes->length(), &width, &height)) {
- LOGE("Get webP size fail.");
- }
- if (width > 1 || height > 1) {
- return false;
+ int width = 0;
+ int height = 0;
+ if (!WebPGetInfo(bitmap->fileBytes->data(), bitmap->fileBytes->length(), &width, &height)) {
+ LOGE("Get webP size fail.");
+ }
+ if (width > 1 || height > 1) {
+ return false;
+ }
}
- }
- return true;
+ return true;
}
static TimeRange MakeTimeRange(Frame start, Frame end, float timeScale) {
- auto startFrame = static_cast(roundf(start * timeScale));
- auto endFrame = static_cast(roundf(end * timeScale));
- return {startFrame, endFrame};
+ auto startFrame = static_cast(roundf(start * timeScale));
+ auto endFrame = static_cast(roundf(end * timeScale));
+ return {startFrame, endFrame};
}
void BitmapComposition::updateStaticTimeRanges() {
- staticTimeRanges = {};
- if (duration <= 1) {
- return;
- }
- if (!sequences.empty()) {
- Frame start = 0;
- Frame end = 0;
- size_t index = 0;
- auto sequence = sequences[0];
- for (size_t i = 1; i < sequences.size(); i++) {
- auto item = sequences[i];
- if (item->frameRate > sequence->frameRate) {
- sequence = item;
- }
+ staticTimeRanges = {};
+ if (duration <= 1) {
+ return;
}
- float timeScale = frameRate / sequence->frameRate;
- for (auto frame : sequence->frames) {
- if (IsEmptyBitmapFrame(frame)) {
- end = index;
- } else {
+ if (!sequences.empty()) {
+ Frame start = 0;
+ Frame end = 0;
+ size_t index = 0;
+ auto sequence = sequences[0];
+ for (size_t i = 1; i < sequences.size(); i++) {
+ auto item = sequences[i];
+ if (item->frameRate > sequence->frameRate) {
+ sequence = item;
+ }
+ }
+ float timeScale = frameRate / sequence->frameRate;
+ for (auto frame : sequence->frames) {
+ if (IsEmptyBitmapFrame(frame)) {
+ end = index;
+ } else {
+ if (end > start) {
+ auto range = MakeTimeRange(start, end, timeScale);
+ staticTimeRanges.push_back(range);
+ }
+ start = end = index;
+ }
+ index++;
+ }
if (end > start) {
- auto range = MakeTimeRange(start, end, timeScale);
- staticTimeRanges.push_back(range);
+ auto range = MakeTimeRange(start, end, timeScale);
+ staticTimeRanges.push_back(range);
}
- start = end = index;
- }
- index++;
- }
- if (end > start) {
- auto range = MakeTimeRange(start, end, timeScale);
- staticTimeRanges.push_back(range);
+ } else {
+ TimeRange range = {0, duration - 1};
+ staticTimeRanges.push_back(range);
}
- } else {
- TimeRange range = {0, duration - 1};
- staticTimeRanges.push_back(range);
- }
}
bool BitmapComposition::hasImageContent() const {
- return true;
+ return true;
}
bool BitmapComposition::verify() const {
- if (!Composition::verify()) {
- VerifyFailed();
- return false;
- }
- if (sequences.empty()) {
- VerifyFailed();
- return false;
- }
- auto sequenceValid = [](BitmapSequence* sequence) {
- return sequence != nullptr && sequence->verify();
- };
- if (!std::all_of(sequences.begin(), sequences.end(), sequenceValid)) {
- VerifyFailed();
- return false;
- }
- return true;
+ if (!Composition::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ if (sequences.empty()) {
+ VerifyFailed();
+ return false;
+ }
+ auto sequenceValid = [](BitmapSequence* sequence) {
+ return sequence != nullptr && sequence->verify();
+ };
+ if (!std::all_of(sequences.begin(), sequences.end(), sequenceValid)) {
+ VerifyFailed();
+ return false;
+ }
+ return true;
}
} // namespace pag
diff --git a/src/base/BitmapSequence.cpp b/src/base/BitmapSequence.cpp
index 82fdb44062..6b607ad0b5 100644
--- a/src/base/BitmapSequence.cpp
+++ b/src/base/BitmapSequence.cpp
@@ -21,38 +21,40 @@
namespace pag {
BitmapRect::~BitmapRect() {
- delete fileBytes;
+ delete fileBytes;
}
BitmapFrame::~BitmapFrame() {
- for (auto image : bitmaps) {
- delete image;
- }
+ for (auto image : bitmaps) {
+ delete image;
+ }
}
bool BitmapFrame::verify() const {
- auto bitmapNotNull = [](BitmapRect* bitmap) {
- return bitmap != nullptr && bitmap->fileBytes != nullptr;
- };
- VerifyAndReturn(std::all_of(bitmaps.begin(), bitmaps.end(), bitmapNotNull));
+ auto bitmapNotNull = [](BitmapRect* bitmap) {
+ return bitmap != nullptr && bitmap->fileBytes != nullptr;
+ };
+ VerifyAndReturn(std::all_of(bitmaps.begin(), bitmaps.end(), bitmapNotNull));
}
BitmapSequence::~BitmapSequence() {
- for (auto frame : frames) {
- delete frame;
- }
+ for (auto frame : frames) {
+ delete frame;
+ }
}
bool BitmapSequence::verify() const {
- if (!Sequence::verify() || frames.empty()) {
- VerifyFailed();
- return false;
- }
- auto frameNotNull = [](BitmapFrame* frame) { return frame != nullptr && frame->verify(); };
- if (!std::all_of(frames.begin(), frames.end(), frameNotNull)) {
- VerifyFailed();
- return false;
- }
- return true;
+ if (!Sequence::verify() || frames.empty()) {
+ VerifyFailed();
+ return false;
+ }
+ auto frameNotNull = [](BitmapFrame* frame) {
+ return frame != nullptr && frame->verify();
+ };
+ if (!std::all_of(frames.begin(), frames.end(), frameNotNull)) {
+ VerifyFailed();
+ return false;
+ }
+ return true;
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/ByteData.cpp b/src/base/ByteData.cpp
index c3da82a69e..ab026f294a 100644
--- a/src/base/ByteData.cpp
+++ b/src/base/ByteData.cpp
@@ -21,52 +21,52 @@
namespace pag {
std::unique_ptr ByteData::FromPath(const std::string& filePath) {
- auto stream = Stream::MakeFromFile(filePath);
- if (stream == nullptr) {
- return nullptr;
- }
- auto data = ByteData::Make(stream->size());
- if (data == nullptr) {
- return nullptr;
- }
- stream->read(data->data(), stream->size());
- return data;
+ auto stream = Stream::MakeFromFile(filePath);
+ if (stream == nullptr) {
+ return nullptr;
+ }
+ auto data = ByteData::Make(stream->size());
+ if (data == nullptr) {
+ return nullptr;
+ }
+ stream->read(data->data(), stream->size());
+ return data;
}
std::unique_ptr ByteData::MakeCopy(const void* bytes, size_t length) {
- if (length == 0) {
- return Make(0);
- }
- auto data = new (std::nothrow) uint8_t[length];
- if (data == nullptr) {
- return nullptr;
- }
- memcpy(data, bytes, length);
- auto byteData = new ByteData(data, length);
- return std::unique_ptr(byteData);
+ if (length == 0) {
+ return Make(0);
+ }
+ auto data = new (std::nothrow) uint8_t[length];
+ if (data == nullptr) {
+ return nullptr;
+ }
+ memcpy(data, bytes, length);
+ auto byteData = new ByteData(data, length);
+ return std::unique_ptr(byteData);
}
std::unique_ptr ByteData::MakeWithoutCopy(void* data, size_t length) {
- if (length == 0) {
- return Make(0);
- }
- auto byteData = new ByteData(reinterpret_cast(data), length, nullptr);
- return std::unique_ptr(byteData);
+ if (length == 0) {
+ return Make(0);
+ }
+ auto byteData = new ByteData(reinterpret_cast(data), length, nullptr);
+ return std::unique_ptr(byteData);
}
std::unique_ptr ByteData::MakeAdopted(uint8_t* data, size_t length,
- std::function releaseCallback) {
- if (length == 0) {
- data = nullptr;
- }
- auto byteData = new ByteData(data, length, releaseCallback);
- return std::unique_ptr(byteData);
+ std::function releaseCallback) {
+ if (length == 0) {
+ data = nullptr;
+ }
+ auto byteData = new ByteData(data, length, releaseCallback);
+ return std::unique_ptr(byteData);
}
std::unique_ptr ByteData::Make(size_t length) {
- auto data = length > 0 ? new (std::nothrow) uint8_t[length] : nullptr;
- auto byteData = new ByteData(data, length);
- return std::unique_ptr(byteData);
+ auto data = length > 0 ? new (std::nothrow) uint8_t[length] : nullptr;
+ auto byteData = new ByteData(data, length);
+ return std::unique_ptr(byteData);
}
} // namespace pag
diff --git a/src/base/Composition.cpp b/src/base/Composition.cpp
index d35c1f8024..3c09ec55b9 100644
--- a/src/base/Composition.cpp
+++ b/src/base/Composition.cpp
@@ -26,36 +26,36 @@ Composition::Composition() : uniqueID(UniqueID::Next()) {
}
Composition::~Composition() {
- delete cache;
- delete audioBytes;
- for (auto& marker : audioMarkers) {
- delete marker;
- }
+ delete cache;
+ delete audioBytes;
+ for (auto& marker : audioMarkers) {
+ delete marker;
+ }
}
bool Composition::staticContent() const {
- return staticTimeRanges.size() == 1 && staticTimeRanges.front().start == 0 &&
- staticTimeRanges.front().end == duration - 1;
+ return staticTimeRanges.size() == 1 && staticTimeRanges.front().start == 0 &&
+ staticTimeRanges.front().end == duration - 1;
}
bool Composition::hasImageContent() const {
- return false;
+ return false;
}
CompositionType Composition::type() const {
- return CompositionType::Unknown;
+ return CompositionType::Unknown;
}
void Composition::updateStaticTimeRanges() {
- TimeRange timeRange = {0, duration - 1};
- staticTimeRanges = {timeRange};
+ TimeRange timeRange = {0, duration - 1};
+ staticTimeRanges = {timeRange};
}
bool Composition::verify() const {
- if (audioBytes != nullptr && audioBytes->length() == 0) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(width > 0 && height > 0 && duration > 0 && frameRate > 0);
+ if (audioBytes != nullptr && audioBytes->length() == 0) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(width > 0 && height > 0 && duration > 0 && frameRate > 0);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/File.cpp b/src/base/File.cpp
index 08aaf4ae4e..613f5134cf 100644
--- a/src/base/File.cpp
+++ b/src/base/File.cpp
@@ -25,221 +25,221 @@ namespace pag {
static std::mutex globalLocker = {};
static std::unordered_map> weakFileMap =
- std::unordered_map>();
+ std::unordered_map>();
static std::shared_ptr FindFileByPath(const std::string& filePath) {
- std::lock_guard autoLock(globalLocker);
- if (filePath.empty()) {
- return nullptr;
- }
- auto result = weakFileMap.find(filePath);
- if (result != weakFileMap.end()) {
- auto& weak = result->second;
- auto file = weak.lock();
- if (file) {
- return file;
- }
- weakFileMap.erase(result);
- if (weakFileMap.size() > 50) { // do cleaning.
- std::vector needRemoveList = {};
- for (auto& item : weakFileMap) {
- if (item.second.expired()) {
- needRemoveList.push_back(item.first);
+ std::lock_guard autoLock(globalLocker);
+ if (filePath.empty()) {
+ return nullptr;
+ }
+ auto result = weakFileMap.find(filePath);
+ if (result != weakFileMap.end()) {
+ auto& weak = result->second;
+ auto file = weak.lock();
+ if (file) {
+ return file;
+ }
+ weakFileMap.erase(result);
+ if (weakFileMap.size() > 50) { // do cleaning.
+ std::vector needRemoveList = {};
+ for (auto& item : weakFileMap) {
+ if (item.second.expired()) {
+ needRemoveList.push_back(item.first);
+ }
+ }
+ for (auto& item : needRemoveList) {
+ weakFileMap.erase(item);
+ }
}
- }
- for (auto& item : needRemoveList) {
- weakFileMap.erase(item);
- }
}
- }
- return nullptr;
+ return nullptr;
}
std::shared_ptr File::Load(const std::string& filePath) {
- auto byteData = ByteData::FromPath(filePath);
- if (byteData == nullptr) {
- return nullptr;
- }
- return pag::File::Load(byteData->data(), byteData->length(), filePath);
+ auto byteData = ByteData::FromPath(filePath);
+ if (byteData == nullptr) {
+ return nullptr;
+ }
+ return pag::File::Load(byteData->data(), byteData->length(), filePath);
}
uint16_t File::MaxSupportedTagLevel() {
- return Codec::MaxSupportedTagLevel();
+ return Codec::MaxSupportedTagLevel();
}
std::shared_ptr File::Load(const void* bytes, size_t length, const std::string& filePath) {
- auto file = FindFileByPath(filePath);
- if (file != nullptr) {
+ auto file = FindFileByPath(filePath);
+ if (file != nullptr) {
+ return file;
+ }
+ file = Codec::Decode(bytes, static_cast(length), filePath);
+ if (file != nullptr) {
+ std::lock_guard autoLock(globalLocker);
+ std::weak_ptr weak = file;
+ weakFileMap.insert(std::make_pair(filePath, std::move(weak)));
+ }
return file;
- }
- file = Codec::Decode(bytes, static_cast(length), filePath);
- if (file != nullptr) {
- std::lock_guard autoLock(globalLocker);
- std::weak_ptr weak = file;
- weakFileMap.insert(std::make_pair(filePath, std::move(weak)));
- }
- return file;
}
File::File(std::vector compositionList, std::vector imageList)
: images(std::move(imageList)), compositions(std::move(compositionList)) {
- mainComposition = compositions.back();
- scaledTimeRange.start = 0;
- scaledTimeRange.end = mainComposition->duration;
- rootLayer = PreComposeLayer::Wrap(mainComposition).release();
- updateEditables(mainComposition);
- for (auto composition : compositions) {
- if (composition->type() != CompositionType::Vector) {
- _numLayers++;
- continue;
- }
- for (auto layer : static_cast(composition)->layers) {
- if (layer->type() == LayerType::PreCompose) {
- continue;
- }
- _numLayers++;
+ mainComposition = compositions.back();
+ scaledTimeRange.start = 0;
+ scaledTimeRange.end = mainComposition->duration;
+ rootLayer = PreComposeLayer::Wrap(mainComposition).release();
+ updateEditables(mainComposition);
+ for (auto composition : compositions) {
+ if (composition->type() != CompositionType::Vector) {
+ _numLayers++;
+ continue;
+ }
+ for (auto layer : static_cast(composition)->layers) {
+ if (layer->type() == LayerType::PreCompose) {
+ continue;
+ }
+ _numLayers++;
+ }
}
- }
}
File::~File() {
- for (auto& composition : compositions) {
- delete composition;
- }
- for (auto& imageBytes : images) {
- delete imageBytes;
- }
- delete rootLayer;
+ for (auto& composition : compositions) {
+ delete composition;
+ }
+ for (auto& imageBytes : images) {
+ delete imageBytes;
+ }
+ delete rootLayer;
}
void File::updateEditables(Composition* composition) {
- if (composition->type() != CompositionType::Vector) {
- return;
- }
- for (auto layer : static_cast(composition)->layers) {
- if (layer->type() == LayerType::Text) {
- auto textLayer = static_cast(layer);
- // 多个预合成图层指向同一个预合成时,这个预合成里的文本图层需要排重.
- auto result = std::find(textLayers.begin(), textLayers.end(), textLayer);
- if (result == textLayers.end()) {
- textLayers.push_back(textLayer);
- }
- } else if (layer->type() == LayerType::Image) {
- auto imageLayer = static_cast(layer);
- auto imageBytes = imageLayer->imageBytes;
- bool found = false;
- for (auto& list : imageLayers) {
- if (list[0]->imageBytes == imageBytes) {
- list.push_back(imageLayer);
- found = true;
- break;
+ if (composition->type() != CompositionType::Vector) {
+ return;
+ }
+ for (auto layer : static_cast(composition)->layers) {
+ if (layer->type() == LayerType::Text) {
+ auto textLayer = static_cast(layer);
+ // 多个预合成图层指向同一个预合成时,这个预合成里的文本图层需要排重.
+ auto result = std::find(textLayers.begin(), textLayers.end(), textLayer);
+ if (result == textLayers.end()) {
+ textLayers.push_back(textLayer);
+ }
+ } else if (layer->type() == LayerType::Image) {
+ auto imageLayer = static_cast(layer);
+ auto imageBytes = imageLayer->imageBytes;
+ bool found = false;
+ for (auto& list : imageLayers) {
+ if (list[0]->imageBytes == imageBytes) {
+ list.push_back(imageLayer);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ std::vector list = {imageLayer};
+ imageLayers.push_back(list);
+ }
+ } else if (layer->type() == LayerType::PreCompose) {
+ updateEditables(static_cast(layer)->composition);
}
- }
- if (!found) {
- std::vector list = {imageLayer};
- imageLayers.push_back(list);
- }
- } else if (layer->type() == LayerType::PreCompose) {
- updateEditables(static_cast(layer)->composition);
}
- }
}
int64_t File::duration() const {
- return mainComposition->duration;
+ return mainComposition->duration;
}
float File::frameRate() const {
- return mainComposition->frameRate;
+ return mainComposition->frameRate;
}
Color File::backgroundColor() const {
- return mainComposition->backgroundColor;
+ return mainComposition->backgroundColor;
}
int32_t File::width() const {
- return mainComposition->width;
+ return mainComposition->width;
}
int32_t File::height() const {
- return mainComposition->height;
+ return mainComposition->height;
}
uint16_t File::tagLevel() const {
- return _tagLevel;
+ return _tagLevel;
}
int File::numLayers() const {
- return _numLayers;
+ return _numLayers;
}
int File::numTexts() const {
- return static_cast(textLayers.size());
+ return static_cast(textLayers.size());
}
int File::numImages() const {
- return static_cast(imageLayers.size());
+ return static_cast(imageLayers.size());
}
int File::numVideos() const {
- unsigned int count = 0;
- for (auto composition : compositions) {
- if (composition->type() == CompositionType::Video) {
- count++;
+ unsigned int count = 0;
+ for (auto composition : compositions) {
+ if (composition->type() == CompositionType::Video) {
+ count++;
+ }
}
- }
- return static_cast(count);
+ return static_cast(count);
}
TextDocumentHandle File::getTextData(int index) const {
- if (index < 0 || static_cast(index) >= textLayers.size()) {
- return nullptr;
- }
- auto textDocument = textLayers[index]->getTextDocument();
- auto textData = new TextDocument();
- *textData = *textDocument;
- return TextDocumentHandle(textData);
+ if (index < 0 || static_cast(index) >= textLayers.size()) {
+ return nullptr;
+ }
+ auto textDocument = textLayers[index]->getTextDocument();
+ auto textData = new TextDocument();
+ *textData = *textDocument;
+ return TextDocumentHandle(textData);
}
PreComposeLayer* File::getRootLayer() const {
- return rootLayer;
+ return rootLayer;
}
TextLayer* File::getTextAt(int index) const {
- if (index < 0 || static_cast(index) >= textLayers.size()) {
- return nullptr;
- }
- return textLayers[index];
+ if (index < 0 || static_cast(index) >= textLayers.size()) {
+ return nullptr;
+ }
+ return textLayers[index];
}
int File::getEditableIndex(TextLayer* textLayer) const {
- auto result = std::find(textLayers.begin(), textLayers.end(), textLayer);
- if (result != textLayers.end()) {
- return static_cast(result - textLayers.begin());
- }
- return -1;
+ auto result = std::find(textLayers.begin(), textLayers.end(), textLayer);
+ if (result != textLayers.end()) {
+ return static_cast(result - textLayers.begin());
+ }
+ return -1;
}
int File::getEditableIndex(pag::ImageLayer* imageLayer) const {
- int index = 0;
- for (auto& layers : imageLayers) {
- auto result = std::find(layers.begin(), layers.end(), imageLayer);
- if (result != layers.end()) {
- return index;
+ int index = 0;
+ for (auto& layers : imageLayers) {
+ auto result = std::find(layers.begin(), layers.end(), imageLayer);
+ if (result != layers.end()) {
+ return index;
+ }
+ index++;
}
- index++;
- }
- return -1;
+ return -1;
}
std::vector File::getImageAt(int index) const {
- if (index < 0 || static_cast(index) >= imageLayers.size()) {
- return {};
- }
- return imageLayers[index];
+ if (index < 0 || static_cast(index) >= imageLayers.size()) {
+ return {};
+ }
+ return imageLayers[index];
}
bool File::hasScaledTimeRange() const {
- return scaledTimeRange.start != 0 || scaledTimeRange.end != mainComposition->duration;
+ return scaledTimeRange.start != 0 || scaledTimeRange.end != mainComposition->duration;
}
} // namespace pag
diff --git a/src/base/GradientColor.cpp b/src/base/GradientColor.cpp
index cd1a26799b..3262701182 100644
--- a/src/base/GradientColor.cpp
+++ b/src/base/GradientColor.cpp
@@ -21,19 +21,19 @@
namespace pag {
void GradientColor::interpolate(const GradientColor& other, GradientColor* result, float t) {
- result->alphaStops = alphaStops;
- result->colorStops = colorStops;
- auto alphaCount = std::min(alphaStops.size(), other.alphaStops.size());
- for (size_t i = 0; i < alphaCount; i++) {
- auto start = alphaStops[i].opacity;
- auto end = other.alphaStops[i].opacity;
- result->alphaStops[i].opacity = Interpolate(start, end, t);
- }
- auto colorCount = std::min(colorStops.size(), other.colorStops.size());
- for (size_t i = 0; i < colorCount; i++) {
- auto start = colorStops[i].color;
- auto end = other.colorStops[i].color;
- result->colorStops[i].color = Interpolate(start, end, t);
- }
+ result->alphaStops = alphaStops;
+ result->colorStops = colorStops;
+ auto alphaCount = std::min(alphaStops.size(), other.alphaStops.size());
+ for (size_t i = 0; i < alphaCount; i++) {
+ auto start = alphaStops[i].opacity;
+ auto end = other.alphaStops[i].opacity;
+ result->alphaStops[i].opacity = Interpolate(start, end, t);
+ }
+ auto colorCount = std::min(colorStops.size(), other.colorStops.size());
+ for (size_t i = 0; i < colorCount; i++) {
+ auto start = colorStops[i].color;
+ auto end = other.colorStops[i].color;
+ result->colorStops[i].color = Interpolate(start, end, t);
+ }
}
} // namespace pag
diff --git a/src/base/ImageBytes.cpp b/src/base/ImageBytes.cpp
index 50218a4ea2..8eea4fda38 100644
--- a/src/base/ImageBytes.cpp
+++ b/src/base/ImageBytes.cpp
@@ -25,12 +25,12 @@ ImageBytes::ImageBytes() : uniqueID(UniqueID::Next()) {
}
ImageBytes::~ImageBytes() {
- delete cache;
- delete fileBytes;
+ delete cache;
+ delete fileBytes;
}
bool ImageBytes::verify() const {
- VerifyAndReturn(fileBytes != nullptr && fileBytes->length() > 0 && scaleFactor > 0 && width > 0 &&
- height > 0);
+ VerifyAndReturn(fileBytes != nullptr && fileBytes->length() > 0 && scaleFactor > 0 && width > 0 &&
+ height > 0);
}
} // namespace pag
diff --git a/src/base/ImageLayer.cpp b/src/base/ImageLayer.cpp
index 85b7ec877e..521a8ce504 100644
--- a/src/base/ImageLayer.cpp
+++ b/src/base/ImageLayer.cpp
@@ -21,18 +21,18 @@
namespace pag {
ImageFillRule::~ImageFillRule() {
- delete timeRemap;
+ delete timeRemap;
}
ImageLayer::~ImageLayer() {
- delete imageFillRule;
+ delete imageFillRule;
}
bool ImageLayer::verify() const {
- if (!Layer::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(imageBytes != nullptr);
+ if (!Layer::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(imageBytes != nullptr);
}
} // namespace pag
diff --git a/src/base/Layer.cpp b/src/base/Layer.cpp
index eda31c48b2..ce0fdb14b0 100644
--- a/src/base/Layer.cpp
+++ b/src/base/Layer.cpp
@@ -26,113 +26,113 @@ Layer::Layer() : uniqueID(UniqueID::Next()) {
}
Layer::~Layer() {
- delete cache;
- delete transform;
- delete timeRemap;
- for (auto& mask : masks) {
- delete mask;
- }
- for (auto& effect : effects) {
- delete effect;
- }
- for (auto& style : layerStyles) {
- delete style;
- }
- for (auto& marker : markers) {
- delete marker;
- }
+ delete cache;
+ delete transform;
+ delete timeRemap;
+ for (auto& mask : masks) {
+ delete mask;
+ }
+ for (auto& effect : effects) {
+ delete effect;
+ }
+ for (auto& style : layerStyles) {
+ delete style;
+ }
+ for (auto& marker : markers) {
+ delete marker;
+ }
}
void Layer::excludeVaryingRanges(std::vector* timeRanges) {
- transform->excludeVaryingRanges(timeRanges);
- if (timeRemap != nullptr) {
- timeRemap->excludeVaryingRanges(timeRanges);
- }
- for (auto& mask : masks) {
- mask->excludeVaryingRanges(timeRanges);
- }
- for (auto& effect : effects) {
- effect->excludeVaryingRanges(timeRanges);
- }
- for (auto& layerStyle : layerStyles) {
- layerStyle->excludeVaryingRanges(timeRanges);
- }
+ transform->excludeVaryingRanges(timeRanges);
+ if (timeRemap != nullptr) {
+ timeRemap->excludeVaryingRanges(timeRanges);
+ }
+ for (auto& mask : masks) {
+ mask->excludeVaryingRanges(timeRanges);
+ }
+ for (auto& effect : effects) {
+ effect->excludeVaryingRanges(timeRanges);
+ }
+ for (auto& layerStyle : layerStyles) {
+ layerStyle->excludeVaryingRanges(timeRanges);
+ }
}
bool Layer::verify() const {
- if (containingComposition == nullptr || duration <= 0 || transform == nullptr) {
- VerifyFailed();
- return false;
- }
- if (!transform->verify()) {
- VerifyFailed();
- return false;
- }
- for (auto mask : masks) {
- if (mask == nullptr || !mask->verify()) {
- VerifyFailed();
- return false;
- }
- }
- return verifyExtra();
+ if (containingComposition == nullptr || duration <= 0 || transform == nullptr) {
+ VerifyFailed();
+ return false;
+ }
+ if (!transform->verify()) {
+ VerifyFailed();
+ return false;
+ }
+ for (auto mask : masks) {
+ if (mask == nullptr || !mask->verify()) {
+ VerifyFailed();
+ return false;
+ }
+ }
+ return verifyExtra();
}
bool Layer::verifyExtra() const {
- for (auto layerStyle : layerStyles) {
- if (layerStyle == nullptr || !layerStyle->verify()) {
- VerifyFailed();
- return false;
- }
- }
- for (auto effect : effects) {
- if (effect == nullptr || !effect->verify()) {
- VerifyFailed();
- return false;
- }
- }
- for (auto& marker : markers) {
- if (marker == nullptr || marker->comment.empty()) {
- VerifyFailed();
- return false;
- }
- }
- return true;
+ for (auto layerStyle : layerStyles) {
+ if (layerStyle == nullptr || !layerStyle->verify()) {
+ VerifyFailed();
+ return false;
+ }
+ }
+ for (auto effect : effects) {
+ if (effect == nullptr || !effect->verify()) {
+ VerifyFailed();
+ return false;
+ }
+ }
+ for (auto& marker : markers) {
+ if (marker == nullptr || marker->comment.empty()) {
+ VerifyFailed();
+ return false;
+ }
+ }
+ return true;
}
Point Layer::getMaxScaleFactor() {
- auto maxScale = Point::Make(1, 1);
- auto property = transform->scale;
- if (property->animatable()) {
- auto keyframes = static_cast*>(property)->keyframes;
- float scaleX = fabs(keyframes[0]->startValue.x);
- float scaleY = fabs(keyframes[0]->startValue.y);
- for (auto& keyframe : keyframes) {
- auto x = fabs(keyframe->endValue.x);
- auto y = fabs(keyframe->endValue.y);
- if (scaleX < x) {
- scaleX = x;
- }
- if (scaleY < y) {
- scaleY = y;
- }
- }
- maxScale.x = scaleX;
- maxScale.y = scaleY;
- } else {
- maxScale.x = fabs(property->value.x);
- maxScale.y = fabs(property->value.y);
- }
- if (parent != nullptr) {
- auto parentScale = parent->getMaxScaleFactor();
- maxScale.x *= parentScale.x;
- maxScale.y *= parentScale.y;
- }
- return maxScale;
+ auto maxScale = Point::Make(1, 1);
+ auto property = transform->scale;
+ if (property->animatable()) {
+ auto keyframes = static_cast*>(property)->keyframes;
+ float scaleX = fabs(keyframes[0]->startValue.x);
+ float scaleY = fabs(keyframes[0]->startValue.y);
+ for (auto& keyframe : keyframes) {
+ auto x = fabs(keyframe->endValue.x);
+ auto y = fabs(keyframe->endValue.y);
+ if (scaleX < x) {
+ scaleX = x;
+ }
+ if (scaleY < y) {
+ scaleY = y;
+ }
+ }
+ maxScale.x = scaleX;
+ maxScale.y = scaleY;
+ } else {
+ maxScale.x = fabs(property->value.x);
+ maxScale.y = fabs(property->value.y);
+ }
+ if (parent != nullptr) {
+ auto parentScale = parent->getMaxScaleFactor();
+ maxScale.x *= parentScale.x;
+ maxScale.y *= parentScale.y;
+ }
+ return maxScale;
}
TimeRange Layer::visibleRange() {
- TimeRange range = {startTime, startTime + duration - 1};
- return range;
+ TimeRange range = {startTime, startTime + duration - 1};
+ return range;
}
} // namespace pag
diff --git a/src/base/MaskData.cpp b/src/base/MaskData.cpp
index 1c706ea3aa..2151653e8f 100644
--- a/src/base/MaskData.cpp
+++ b/src/base/MaskData.cpp
@@ -21,18 +21,18 @@
namespace pag {
MaskData::~MaskData() {
- delete maskPath;
- delete maskOpacity;
- delete maskExpansion;
+ delete maskPath;
+ delete maskOpacity;
+ delete maskExpansion;
}
void MaskData::excludeVaryingRanges(std::vector* timeRanges) const {
- maskPath->excludeVaryingRanges(timeRanges);
- maskOpacity->excludeVaryingRanges(timeRanges);
- maskExpansion->excludeVaryingRanges(timeRanges);
+ maskPath->excludeVaryingRanges(timeRanges);
+ maskOpacity->excludeVaryingRanges(timeRanges);
+ maskExpansion->excludeVaryingRanges(timeRanges);
}
bool MaskData::verify() const {
- VerifyAndReturn(maskPath != nullptr);
+ VerifyAndReturn(maskPath != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/Matrix.cpp b/src/base/Matrix.cpp
index d4e2a1a438..9bd062718f 100644
--- a/src/base/Matrix.cpp
+++ b/src/base/Matrix.cpp
@@ -22,453 +22,453 @@
namespace pag {
void Matrix::reset() {
- values[SCALE_X] = values[SCALE_Y] = values[PERSP_2] = 1;
- values[SKEW_X] = values[SKEW_Y] = values[TRANS_X] = values[TRANS_Y] = values[PERSP_0] =
- values[PERSP_1] = 0;
+ values[SCALE_X] = values[SCALE_Y] = values[PERSP_2] = 1;
+ values[SKEW_X] = values[SKEW_Y] = values[TRANS_X] = values[TRANS_Y] = values[PERSP_0] =
+ values[PERSP_1] = 0;
}
bool operator==(const Matrix& a, const Matrix& b) {
- const float* ma = a.values;
- const float* mb = b.values;
- return ma[0] == mb[0] && ma[1] == mb[1] && ma[2] == mb[2] && ma[3] == mb[3] && ma[4] == mb[4] &&
- ma[5] == mb[5] && ma[6] == mb[6] && ma[7] == mb[7] && ma[8] == mb[8];
+ const float* ma = a.values;
+ const float* mb = b.values;
+ return ma[0] == mb[0] && ma[1] == mb[1] && ma[2] == mb[2] && ma[3] == mb[3] && ma[4] == mb[4] &&
+ ma[5] == mb[5] && ma[6] == mb[6] && ma[7] == mb[7] && ma[8] == mb[8];
}
void Matrix::setAll(float scaleX, float skewX, float transX, float skewY, float scaleY,
float transY, float persp0, float persp1, float persp2) {
- values[SCALE_X] = scaleX;
- values[SKEW_X] = skewX;
- values[TRANS_X] = transX;
- values[SKEW_Y] = skewY;
- values[SCALE_Y] = scaleY;
- values[TRANS_Y] = transY;
- values[PERSP_0] = persp0;
- values[PERSP_1] = persp1;
- values[PERSP_2] = persp2;
+ values[SCALE_X] = scaleX;
+ values[SKEW_X] = skewX;
+ values[TRANS_X] = transX;
+ values[SKEW_Y] = skewY;
+ values[SCALE_Y] = scaleY;
+ values[TRANS_Y] = transY;
+ values[PERSP_0] = persp0;
+ values[PERSP_1] = persp1;
+ values[PERSP_2] = persp2;
}
void Matrix::setAffine(float a, float b, float c, float d, float tx, float ty) {
- values[SCALE_X] = a;
- values[SKEW_X] = c;
- values[TRANS_X] = tx;
- values[SKEW_Y] = b;
- values[SCALE_Y] = d;
- values[TRANS_Y] = ty;
- values[PERSP_0] = 0;
- values[PERSP_1] = 0;
- values[PERSP_2] = 1;
+ values[SCALE_X] = a;
+ values[SKEW_X] = c;
+ values[TRANS_X] = tx;
+ values[SKEW_Y] = b;
+ values[SCALE_Y] = d;
+ values[TRANS_Y] = ty;
+ values[PERSP_0] = 0;
+ values[PERSP_1] = 0;
+ values[PERSP_2] = 1;
}
void Matrix::setTranslate(float dx, float dy) {
- if ((dx != 0) | (dy != 0)) {
- values[TRANS_X] = dx;
- values[TRANS_Y] = dy;
-
- values[SCALE_X] = values[SCALE_Y] = values[PERSP_2] = 1;
- values[SKEW_X] = values[SKEW_Y] = values[PERSP_0] = values[PERSP_1] = 0;
- } else {
- this->reset();
- }
+ if ((dx != 0) | (dy != 0)) {
+ values[TRANS_X] = dx;
+ values[TRANS_Y] = dy;
+
+ values[SCALE_X] = values[SCALE_Y] = values[PERSP_2] = 1;
+ values[SKEW_X] = values[SKEW_Y] = values[PERSP_0] = values[PERSP_1] = 0;
+ } else {
+ this->reset();
+ }
}
static inline float sdot(float a, float b, float c, float d) {
- return a * b + c * d;
+ return a * b + c * d;
}
void Matrix::preTranslate(float dx, float dy) {
- values[TRANS_X] += sdot(values[SCALE_X], dx, values[SKEW_X], dy);
- values[TRANS_Y] += sdot(values[SKEW_Y], dx, values[SCALE_Y], dy);
+ values[TRANS_X] += sdot(values[SCALE_X], dx, values[SKEW_X], dy);
+ values[TRANS_Y] += sdot(values[SKEW_Y], dx, values[SCALE_Y], dy);
}
void Matrix::postTranslate(float dx, float dy) {
- values[TRANS_X] += dx;
- values[TRANS_Y] += dy;
+ values[TRANS_X] += dx;
+ values[TRANS_Y] += dy;
}
void Matrix::setScaleTranslate(float sx, float sy, float tx, float ty) {
- values[SCALE_X] = sx;
- values[SKEW_X] = 0;
- values[TRANS_X] = tx;
-
- values[SKEW_Y] = 0;
- values[SCALE_Y] = sy;
- values[TRANS_Y] = ty;
-
- values[PERSP_0] = 0;
- values[PERSP_1] = 0;
- values[PERSP_2] = 1;
-}
-
-void Matrix::setScale(float sx, float sy, float px, float py) {
- if (1 == sx && 1 == sy) {
- this->reset();
- } else {
values[SCALE_X] = sx;
values[SKEW_X] = 0;
- values[TRANS_X] = 0;
+ values[TRANS_X] = tx;
values[SKEW_Y] = 0;
values[SCALE_Y] = sy;
- values[TRANS_Y] = 0;
+ values[TRANS_Y] = ty;
values[PERSP_0] = 0;
values[PERSP_1] = 0;
values[PERSP_2] = 1;
- this->setScaleTranslate(sx, sy, px - sx * px, py - sy * py);
- }
}
-void Matrix::setScale(float sx, float sy) {
- if (1 == sx && 1 == sy) {
- this->reset();
- } else {
- values[SCALE_X] = sx;
- values[SCALE_Y] = sy;
- values[PERSP_2] = 1;
-
- values[TRANS_X] = values[TRANS_Y] = values[SKEW_X] = values[SKEW_Y] = values[PERSP_0] =
+void Matrix::setScale(float sx, float sy, float px, float py) {
+ if (1 == sx && 1 == sy) {
+ this->reset();
+ } else {
+ values[SCALE_X] = sx;
+ values[SKEW_X] = 0;
+ values[TRANS_X] = 0;
+
+ values[SKEW_Y] = 0;
+ values[SCALE_Y] = sy;
+ values[TRANS_Y] = 0;
+
+ values[PERSP_0] = 0;
values[PERSP_1] = 0;
- }
+ values[PERSP_2] = 1;
+ this->setScaleTranslate(sx, sy, px - sx * px, py - sy * py);
+ }
+}
+
+void Matrix::setScale(float sx, float sy) {
+ if (1 == sx && 1 == sy) {
+ this->reset();
+ } else {
+ values[SCALE_X] = sx;
+ values[SCALE_Y] = sy;
+ values[PERSP_2] = 1;
+
+ values[TRANS_X] = values[TRANS_Y] = values[SKEW_X] = values[SKEW_Y] = values[PERSP_0] =
+ values[PERSP_1] = 0;
+ }
}
void Matrix::preScale(float sx, float sy, float px, float py) {
- if (1 == sx && 1 == sy) {
- return;
- }
+ if (1 == sx && 1 == sy) {
+ return;
+ }
- Matrix m = {};
- m.setScale(sx, sy, px, py);
- this->preConcat(m);
+ Matrix m = {};
+ m.setScale(sx, sy, px, py);
+ this->preConcat(m);
}
void Matrix::preScale(float sx, float sy) {
- if (1 == sx && 1 == sy) {
- return;
- }
- values[SCALE_X] *= sx;
- values[SKEW_Y] *= sx;
- values[PERSP_0] *= sx;
+ if (1 == sx && 1 == sy) {
+ return;
+ }
+ values[SCALE_X] *= sx;
+ values[SKEW_Y] *= sx;
+ values[PERSP_0] *= sx;
- values[SKEW_X] *= sy;
- values[SCALE_Y] *= sy;
- values[PERSP_1] *= sy;
+ values[SKEW_X] *= sy;
+ values[SCALE_Y] *= sy;
+ values[PERSP_1] *= sy;
}
void Matrix::postScale(float sx, float sy, float px, float py) {
- if (1 == sx && 1 == sy) {
- return;
- }
- Matrix m = {};
- m.setScale(sx, sy, px, py);
- this->postConcat(m);
+ if (1 == sx && 1 == sy) {
+ return;
+ }
+ Matrix m = {};
+ m.setScale(sx, sy, px, py);
+ this->postConcat(m);
}
void Matrix::postScale(float sx, float sy) {
- if (1 == sx && 1 == sy) {
- return;
- }
- Matrix m = {};
- m.setScale(sx, sy);
- this->postConcat(m);
+ if (1 == sx && 1 == sy) {
+ return;
+ }
+ Matrix m = {};
+ m.setScale(sx, sy);
+ this->postConcat(m);
}
void Matrix::setSinCos(float sinV, float cosV, float px, float py) {
- const float oneMinusCosV = 1 - cosV;
+ const float oneMinusCosV = 1 - cosV;
- values[SCALE_X] = cosV;
- values[SKEW_X] = -sinV;
- values[TRANS_X] = sdot(sinV, py, oneMinusCosV, px);
+ values[SCALE_X] = cosV;
+ values[SKEW_X] = -sinV;
+ values[TRANS_X] = sdot(sinV, py, oneMinusCosV, px);
- values[SKEW_Y] = sinV;
- values[SCALE_Y] = cosV;
- values[TRANS_Y] = sdot(-sinV, px, oneMinusCosV, py);
+ values[SKEW_Y] = sinV;
+ values[SCALE_Y] = cosV;
+ values[TRANS_Y] = sdot(-sinV, px, oneMinusCosV, py);
- values[PERSP_0] = values[PERSP_1] = 0;
- values[PERSP_2] = 1;
+ values[PERSP_0] = values[PERSP_1] = 0;
+ values[PERSP_2] = 1;
}
void Matrix::setSinCos(float sinV, float cosV) {
- values[SCALE_X] = cosV;
- values[SKEW_X] = -sinV;
- values[TRANS_X] = 0;
+ values[SCALE_X] = cosV;
+ values[SKEW_X] = -sinV;
+ values[TRANS_X] = 0;
- values[SKEW_Y] = sinV;
- values[SCALE_Y] = cosV;
- values[TRANS_Y] = 0;
+ values[SKEW_Y] = sinV;
+ values[SCALE_Y] = cosV;
+ values[TRANS_Y] = 0;
- values[PERSP_0] = values[PERSP_1] = 0;
- values[PERSP_2] = 1;
+ values[PERSP_0] = values[PERSP_1] = 0;
+ values[PERSP_2] = 1;
}
void Matrix::setRotate(float degrees, float px, float py) {
- float rad = DegreesToRadians(degrees);
- this->setSinCos(SinSnapToZero(rad), CosSnapToZero(rad), px, py);
+ float rad = DegreesToRadians(degrees);
+ this->setSinCos(SinSnapToZero(rad), CosSnapToZero(rad), px, py);
}
void Matrix::setRotate(float degrees) {
- float rad = DegreesToRadians(degrees);
- this->setSinCos(SinSnapToZero(rad), CosSnapToZero(rad));
+ float rad = DegreesToRadians(degrees);
+ this->setSinCos(SinSnapToZero(rad), CosSnapToZero(rad));
}
void Matrix::preRotate(float degrees, float px, float py) {
- Matrix m = {};
- m.setRotate(degrees, px, py);
- this->preConcat(m);
+ Matrix m = {};
+ m.setRotate(degrees, px, py);
+ this->preConcat(m);
}
void Matrix::preRotate(float degrees) {
- Matrix m = {};
- m.setRotate(degrees);
- this->preConcat(m);
+ Matrix m = {};
+ m.setRotate(degrees);
+ this->preConcat(m);
}
void Matrix::postRotate(float degrees, float px, float py) {
- Matrix m = {};
- m.setRotate(degrees, px, py);
- this->postConcat(m);
+ Matrix m = {};
+ m.setRotate(degrees, px, py);
+ this->postConcat(m);
}
void Matrix::postRotate(float degrees) {
- Matrix m = {};
- m.setRotate(degrees);
- this->postConcat(m);
+ Matrix m = {};
+ m.setRotate(degrees);
+ this->postConcat(m);
}
void Matrix::setSkew(float sx, float sy, float px, float py) {
- values[SCALE_X] = 1;
- values[SKEW_X] = sx;
- values[TRANS_X] = -sx * py;
+ values[SCALE_X] = 1;
+ values[SKEW_X] = sx;
+ values[TRANS_X] = -sx * py;
- values[SKEW_Y] = sy;
- values[SCALE_Y] = 1;
- values[TRANS_Y] = -sy * px;
+ values[SKEW_Y] = sy;
+ values[SCALE_Y] = 1;
+ values[TRANS_Y] = -sy * px;
- values[PERSP_0] = values[PERSP_1] = 0;
- values[PERSP_2] = 1;
+ values[PERSP_0] = values[PERSP_1] = 0;
+ values[PERSP_2] = 1;
}
void Matrix::setSkew(float sx, float sy) {
- values[SCALE_X] = 1;
- values[SKEW_X] = sx;
- values[TRANS_X] = 0;
+ values[SCALE_X] = 1;
+ values[SKEW_X] = sx;
+ values[TRANS_X] = 0;
- values[SKEW_Y] = sy;
- values[SCALE_Y] = 1;
- values[TRANS_Y] = 0;
+ values[SKEW_Y] = sy;
+ values[SCALE_Y] = 1;
+ values[TRANS_Y] = 0;
- values[PERSP_0] = values[PERSP_1] = 0;
- values[PERSP_2] = 1;
+ values[PERSP_0] = values[PERSP_1] = 0;
+ values[PERSP_2] = 1;
}
void Matrix::preSkew(float sx, float sy, float px, float py) {
- Matrix m = {};
- m.setSkew(sx, sy, px, py);
- this->preConcat(m);
+ Matrix m = {};
+ m.setSkew(sx, sy, px, py);
+ this->preConcat(m);
}
void Matrix::preSkew(float sx, float sy) {
- Matrix m = {};
- m.setSkew(sx, sy);
- this->preConcat(m);
+ Matrix m = {};
+ m.setSkew(sx, sy);
+ this->preConcat(m);
}
void Matrix::postSkew(float sx, float sy, float px, float py) {
- Matrix m = {};
- m.setSkew(sx, sy, px, py);
- this->postConcat(m);
+ Matrix m = {};
+ m.setSkew(sx, sy, px, py);
+ this->postConcat(m);
}
void Matrix::postSkew(float sx, float sy) {
- Matrix m = {};
- m.setSkew(sx, sy);
- this->postConcat(m);
+ Matrix m = {};
+ m.setSkew(sx, sy);
+ this->postConcat(m);
}
void Matrix::setConcat(const Matrix& first, const Matrix& second) {
- auto& matA = first.values;
- auto& matB = second.values;
- auto a = matB[SCALE_X] * matA[SCALE_X];
- auto b = 0.0;
- auto c = 0.0;
- auto d = matB[SCALE_Y] * matA[SCALE_Y];
- auto tx = matB[TRANS_X] * matA[SCALE_X] + matA[TRANS_X];
- auto ty = matB[TRANS_Y] * matA[SCALE_Y] + matA[TRANS_Y];
-
- if (matB[SKEW_Y] != 0.0 || matB[SKEW_X] != 0.0 || matA[SKEW_Y] != 0.0 || matA[SKEW_X] != 0.0) {
- a += matB[SKEW_Y] * matA[SKEW_X];
- d += matB[SKEW_X] * matA[SKEW_Y];
- b += matB[SCALE_X] * matA[SKEW_Y] + matB[SKEW_Y] * matA[SCALE_Y];
- c += matB[SKEW_X] * matA[SCALE_X] + matB[SCALE_Y] * matA[SKEW_X];
- tx += matB[TRANS_Y] * matA[SKEW_X];
- ty += matB[TRANS_X] * matA[SKEW_Y];
- }
-
- values[SCALE_X] = a;
- values[SKEW_Y] = b;
- values[SKEW_X] = c;
- values[SCALE_Y] = d;
- values[TRANS_X] = tx;
- values[TRANS_Y] = ty;
- values[PERSP_0] = 0;
- values[PERSP_1] = 0;
- values[PERSP_2] = 1;
+ auto& matA = first.values;
+ auto& matB = second.values;
+ auto a = matB[SCALE_X] * matA[SCALE_X];
+ auto b = 0.0;
+ auto c = 0.0;
+ auto d = matB[SCALE_Y] * matA[SCALE_Y];
+ auto tx = matB[TRANS_X] * matA[SCALE_X] + matA[TRANS_X];
+ auto ty = matB[TRANS_Y] * matA[SCALE_Y] + matA[TRANS_Y];
+
+ if (matB[SKEW_Y] != 0.0 || matB[SKEW_X] != 0.0 || matA[SKEW_Y] != 0.0 || matA[SKEW_X] != 0.0) {
+ a += matB[SKEW_Y] * matA[SKEW_X];
+ d += matB[SKEW_X] * matA[SKEW_Y];
+ b += matB[SCALE_X] * matA[SKEW_Y] + matB[SKEW_Y] * matA[SCALE_Y];
+ c += matB[SKEW_X] * matA[SCALE_X] + matB[SCALE_Y] * matA[SKEW_X];
+ tx += matB[TRANS_Y] * matA[SKEW_X];
+ ty += matB[TRANS_X] * matA[SKEW_Y];
+ }
+
+ values[SCALE_X] = a;
+ values[SKEW_Y] = b;
+ values[SKEW_X] = c;
+ values[SCALE_Y] = d;
+ values[TRANS_X] = tx;
+ values[TRANS_Y] = ty;
+ values[PERSP_0] = 0;
+ values[PERSP_1] = 0;
+ values[PERSP_2] = 1;
}
void Matrix::preConcat(const Matrix& mat) {
- // check for identity first, so we don't do a needless copy of ourselves
- // to ourselves inside setConcat()
- if (!mat.isIdentity()) {
- this->setConcat(*this, mat);
- }
+ // check for identity first, so we don't do a needless copy of ourselves
+ // to ourselves inside setConcat()
+ if (!mat.isIdentity()) {
+ this->setConcat(*this, mat);
+ }
}
void Matrix::postConcat(const Matrix& mat) {
- // check for identity first, so we don't do a needless copy of ourselves
- // to ourselves inside setConcat()
- if (!mat.isIdentity()) {
- this->setConcat(mat, *this);
- }
+ // check for identity first, so we don't do a needless copy of ourselves
+ // to ourselves inside setConcat()
+ if (!mat.isIdentity()) {
+ this->setConcat(mat, *this);
+ }
}
bool Matrix::invertible() const {
- float determinant = values[SCALE_X] * values[SCALE_Y] - values[SKEW_Y] * values[SKEW_X];
- return !(FloatNearlyZero(determinant, FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO));
+ float determinant = values[SCALE_X] * values[SCALE_Y] - values[SKEW_Y] * values[SKEW_X];
+ return !(FloatNearlyZero(determinant, FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO));
}
bool Matrix::invertNonIdentity(Matrix* inverse) const {
- auto a = values[SCALE_X];
- auto d = values[SCALE_Y];
- auto c = values[SKEW_X];
- auto b = values[SKEW_Y];
- auto tx = values[TRANS_X];
- auto ty = values[TRANS_Y];
-
- if (b == 0 && c == 0) {
- if (a == 0 || d == 0) {
- return false;
+ auto a = values[SCALE_X];
+ auto d = values[SCALE_Y];
+ auto c = values[SKEW_X];
+ auto b = values[SKEW_Y];
+ auto tx = values[TRANS_X];
+ auto ty = values[TRANS_Y];
+
+ if (b == 0 && c == 0) {
+ if (a == 0 || d == 0) {
+ return false;
+ }
+ a = 1 / a;
+ d = 1 / d;
+ tx = -a * tx;
+ ty = -d * ty;
+ inverse->setAffine(a, b, c, d, tx, ty);
+ return true;
}
- a = 1 / a;
- d = 1 / d;
- tx = -a * tx;
- ty = -d * ty;
+ float determinant = a * d - b * c;
+ if (FloatNearlyZero(determinant, FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO)) {
+ return false;
+ }
+ determinant = 1 / determinant;
+ a = d * determinant;
+ b = -b * determinant;
+ c = -c * determinant;
+ d = values[SCALE_X] * determinant;
+ tx = -(a * values[TRANS_X] + c * values[TRANS_Y]);
+ ty = -(b * values[TRANS_X] + d * values[TRANS_Y]);
inverse->setAffine(a, b, c, d, tx, ty);
return true;
- }
- float determinant = a * d - b * c;
- if (FloatNearlyZero(determinant, FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO)) {
- return false;
- }
- determinant = 1 / determinant;
- a = d * determinant;
- b = -b * determinant;
- c = -c * determinant;
- d = values[SCALE_X] * determinant;
- tx = -(a * values[TRANS_X] + c * values[TRANS_Y]);
- ty = -(b * values[TRANS_X] + d * values[TRANS_Y]);
- inverse->setAffine(a, b, c, d, tx, ty);
- return true;
}
void Matrix::mapPoints(Point dst[], const Point src[], int count) const {
- auto tx = values[TRANS_X];
- auto ty = values[TRANS_Y];
- auto sx = values[SCALE_X];
- auto sy = values[SCALE_Y];
- auto kx = values[SKEW_X];
- auto ky = values[SKEW_Y];
- for (int i = 0; i < count; i++) {
- auto x = src[i].x * sx + src[i].y * kx + tx;
- auto y = src[i].x * ky + src[i].y * sy + ty;
- dst[i].set(x, y);
- }
+ auto tx = values[TRANS_X];
+ auto ty = values[TRANS_Y];
+ auto sx = values[SCALE_X];
+ auto sy = values[SCALE_Y];
+ auto kx = values[SKEW_X];
+ auto ky = values[SKEW_Y];
+ for (int i = 0; i < count; i++) {
+ auto x = src[i].x * sx + src[i].y * kx + tx;
+ auto y = src[i].x * ky + src[i].y * sy + ty;
+ dst[i].set(x, y);
+ }
}
void Matrix::mapXY(float x, float y, Point* result) const {
- auto tx = values[TRANS_X];
- auto ty = values[TRANS_Y];
- auto sx = values[SCALE_X];
- auto sy = values[SCALE_Y];
- auto kx = values[SKEW_X];
- auto ky = values[SKEW_Y];
- result->set(x * sx + y * kx + tx, x * ky + y * sy + ty);
+ auto tx = values[TRANS_X];
+ auto ty = values[TRANS_Y];
+ auto sx = values[SCALE_X];
+ auto sy = values[SCALE_Y];
+ auto kx = values[SKEW_X];
+ auto ky = values[SKEW_Y];
+ result->set(x * sx + y * kx + tx, x * ky + y * sy + ty);
}
void Matrix::mapRect(Rect* dst, const Rect& src) const {
- Point quad[4];
- quad[0].set(src.left, src.top);
- quad[1].set(src.right, src.top);
- quad[2].set(src.right, src.bottom);
- quad[3].set(src.left, src.bottom);
- mapPoints(quad, quad, 4);
- dst->setBounds(quad, 4);
+ Point quad[4];
+ quad[0].set(src.left, src.top);
+ quad[1].set(src.right, src.top);
+ quad[2].set(src.right, src.bottom);
+ quad[3].set(src.left, src.bottom);
+ mapPoints(quad, quad, 4);
+ dst->setBounds(quad, 4);
}
float Matrix::getMinScale() const {
- float results[2];
- if (getMinMaxScaleFactors(results)) {
- return results[0];
- }
- return -1.0f;
+ float results[2];
+ if (getMinMaxScaleFactors(results)) {
+ return results[0];
+ }
+ return -1.0f;
}
float Matrix::getMaxScale() const {
- float results[2];
- if (getMinMaxScaleFactors(results)) {
- return results[1];
- }
- return -1.0f;
+ float results[2];
+ if (getMinMaxScaleFactors(results)) {
+ return results[1];
+ }
+ return -1.0f;
}
bool Matrix::getMinMaxScaleFactors(float* results) const {
- float a = sdot(values[SCALE_X], values[SCALE_X], values[SKEW_Y], values[SKEW_Y]);
- float b = sdot(values[SCALE_X], values[SKEW_X], values[SCALE_Y], values[SKEW_Y]);
- float c = sdot(values[SKEW_X], values[SKEW_X], values[SCALE_Y], values[SCALE_Y]);
- float bSqd = b * b;
- if (bSqd <= FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO) {
- results[0] = a;
- results[1] = c;
- if (results[0] > results[1]) {
- using std::swap;
- swap(results[0], results[1]);
+ float a = sdot(values[SCALE_X], values[SCALE_X], values[SKEW_Y], values[SKEW_Y]);
+ float b = sdot(values[SCALE_X], values[SKEW_X], values[SCALE_Y], values[SKEW_Y]);
+ float c = sdot(values[SKEW_X], values[SKEW_X], values[SCALE_Y], values[SCALE_Y]);
+ float bSqd = b * b;
+ if (bSqd <= FLOAT_NEARLY_ZERO * FLOAT_NEARLY_ZERO) {
+ results[0] = a;
+ results[1] = c;
+ if (results[0] > results[1]) {
+ using std::swap;
+ swap(results[0], results[1]);
+ }
+ } else {
+ float aminusc = a - c;
+ float apluscdiv2 = (a + c) * 0.5f;
+ float x = sqrtf(aminusc * aminusc + 4 * bSqd) * 0.5f;
+ results[0] = apluscdiv2 - x;
+ results[1] = apluscdiv2 + x;
+ }
+ auto isFinite = (results[0] * 0 == 0);
+ if (!isFinite) {
+ return false;
+ }
+ if (results[0] < 0) {
+ results[0] = 0;
}
- } else {
- float aminusc = a - c;
- float apluscdiv2 = (a + c) * 0.5f;
- float x = sqrtf(aminusc * aminusc + 4 * bSqd) * 0.5f;
- results[0] = apluscdiv2 - x;
- results[1] = apluscdiv2 + x;
- }
- auto isFinite = (results[0] * 0 == 0);
- if (!isFinite) {
- return false;
- }
- if (results[0] < 0) {
- results[0] = 0;
- }
- results[0] = sqrtf(results[0]);
- isFinite = (results[1] * 0 == 0);
- if (!isFinite) {
- return false;
- }
- if (results[1] < 0) {
- results[1] = 0;
- }
- results[1] = sqrtf(results[1]);
- return true;
+ results[0] = sqrtf(results[0]);
+ isFinite = (results[1] * 0 == 0);
+ if (!isFinite) {
+ return false;
+ }
+ if (results[1] < 0) {
+ results[1] = 0;
+ }
+ results[1] = sqrtf(results[1]);
+ return true;
}
bool Matrix::isFinite() const {
- return FloatsAreFinite(values, 9);
+ return FloatsAreFinite(values, 9);
}
const Matrix& Matrix::I() {
- static const Matrix identity = Matrix::MakeAll(1, 0, 0, 0, 1, 0, 0, 0, 1);
- return identity;
+ static const Matrix identity = Matrix::MakeAll(1, 0, 0, 0, 1, 0, 0, 0, 1);
+ return identity;
}
const Matrix& Matrix::Invalid() {
- static const Matrix invalid = Matrix::MakeAll(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
- FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX);
- return invalid;
+ static const Matrix invalid = Matrix::MakeAll(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX,
+ FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX);
+ return invalid;
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/PathData.cpp b/src/base/PathData.cpp
index deee7b7192..808611fcb3 100644
--- a/src/base/PathData.cpp
+++ b/src/base/PathData.cpp
@@ -23,147 +23,147 @@
namespace pag {
void PathData::moveTo(float x, float y) {
- verbs.push_back(PathDataVerb::MoveTo);
- points.push_back({x, y});
- lastMoveTo.x = x;
- lastMoveTo.y = y;
+ verbs.push_back(PathDataVerb::MoveTo);
+ points.push_back({x, y});
+ lastMoveTo.x = x;
+ lastMoveTo.y = y;
}
void PathData::lineTo(float x, float y) {
- if (verbs.empty()) {
- moveTo(0, 0);
- }
- verbs.push_back(PathDataVerb::LineTo);
- points.push_back({x, y});
+ if (verbs.empty()) {
+ moveTo(0, 0);
+ }
+ verbs.push_back(PathDataVerb::LineTo);
+ points.push_back({x, y});
}
void PathData::cubicTo(float controlX1, float controlY1, float controlX2, float controlY2, float x,
float y) {
- if (verbs.empty()) {
- moveTo(0, 0);
- }
- verbs.push_back(PathDataVerb::CurveTo);
- points.push_back({controlX1, controlY1});
- points.push_back({controlX2, controlY2});
- points.push_back({x, y});
+ if (verbs.empty()) {
+ moveTo(0, 0);
+ }
+ verbs.push_back(PathDataVerb::CurveTo);
+ points.push_back({controlX1, controlY1});
+ points.push_back({controlX2, controlY2});
+ points.push_back({x, y});
}
void PathData::close() {
- if (verbs.empty()) {
- return;
- }
- auto lastVerb = verbs.back();
- if (lastVerb == PathDataVerb::Close) {
- return;
- }
- auto lastPoint = points.back();
- if (lastPoint != lastMoveTo) {
- lineTo(lastMoveTo.x, lastMoveTo.y);
- }
- verbs.push_back(PathDataVerb::Close);
+ if (verbs.empty()) {
+ return;
+ }
+ auto lastVerb = verbs.back();
+ if (lastVerb == PathDataVerb::Close) {
+ return;
+ }
+ auto lastPoint = points.back();
+ if (lastPoint != lastMoveTo) {
+ lineTo(lastMoveTo.x, lastMoveTo.y);
+ }
+ verbs.push_back(PathDataVerb::Close);
}
bool PathData::isClosed() const {
- if (verbs.empty()) {
- return false;
- }
- return verbs.back() == PathDataVerb::Close;
+ if (verbs.empty()) {
+ return false;
+ }
+ return verbs.back() == PathDataVerb::Close;
}
void PathData::reverse() {
- if (verbs.empty()) {
- return;
- }
- std::reverse(points.begin(), points.end());
- std::vector list;
- auto size = verbs.size();
- list.reserve(size);
- verbs.swap(list);
- verbs.push_back(PathDataVerb::MoveTo);
- bool hasClose = false;
- for (auto i = size - 1; i > 0; i--) {
- auto verb = list[i];
- switch (verb) {
- case PathDataVerb::Close:
- if (hasClose) {
- verbs.push_back(PathDataVerb::Close);
- }
- hasClose = true;
- break;
- case PathDataVerb::MoveTo:
- if (hasClose) {
- hasClose = false;
- verbs.push_back(PathDataVerb::Close);
+ if (verbs.empty()) {
+ return;
+ }
+ std::reverse(points.begin(), points.end());
+ std::vector list;
+ auto size = verbs.size();
+ list.reserve(size);
+ verbs.swap(list);
+ verbs.push_back(PathDataVerb::MoveTo);
+ bool hasClose = false;
+ for (auto i = size - 1; i > 0; i--) {
+ auto verb = list[i];
+ switch (verb) {
+ case PathDataVerb::Close:
+ if (hasClose) {
+ verbs.push_back(PathDataVerb::Close);
+ }
+ hasClose = true;
+ break;
+ case PathDataVerb::MoveTo:
+ if (hasClose) {
+ hasClose = false;
+ verbs.push_back(PathDataVerb::Close);
+ }
+ verbs.push_back(PathDataVerb::MoveTo);
+ break;
+ default:
+ verbs.push_back(verb);
+ break;
}
- verbs.push_back(PathDataVerb::MoveTo);
- break;
- default:
- verbs.push_back(verb);
- break;
}
- }
- if (hasClose) {
- verbs.push_back(PathDataVerb::Close);
- }
+ if (hasClose) {
+ verbs.push_back(PathDataVerb::Close);
+ }
}
void PathData::clear() {
- verbs.clear();
- points.clear();
+ verbs.clear();
+ points.clear();
}
struct CurveData {
- Point control1;
- Point control2;
- Point end;
+ Point control1;
+ Point control2;
+ Point end;
};
inline CurveData GetCurveData(PathDataVerb verb, const std::vector& points, int& index) {
- CurveData data = {};
- if (verb == PathDataVerb::CurveTo) {
- data.control1 = points[index++];
- data.control2 = points[index++];
- data.end = points[index++];
- } else {
- data.control1 = points[index - 1];
- data.end = points[index++];
- data.control2 = data.end;
- }
- return data;
+ CurveData data = {};
+ if (verb == PathDataVerb::CurveTo) {
+ data.control1 = points[index++];
+ data.control2 = points[index++];
+ data.end = points[index++];
+ } else {
+ data.control1 = points[index - 1];
+ data.end = points[index++];
+ data.control2 = data.end;
+ }
+ return data;
}
void PathData::interpolate(const PathData& path, PathData* result, float t) {
- if (verbs.empty() || path.verbs.empty()) {
- return;
- }
- auto& pointsA = points;
- auto& verbsA = verbs;
- auto& pointsB = path.points;
- auto& verbsB = path.verbs;
- int indexA = 0;
- int indexB = 0;
- auto size = verbsA.size();
- for (size_t i = 0; i < size; i++) {
- auto verbA = verbsA[i];
- auto verbB = verbsB[i];
- if (verbA == verbB) {
- result->verbs.push_back(verbA);
- if (verbA == PathDataVerb::Close) {
- continue;
- }
- auto count = verbA == PathDataVerb::CurveTo ? 3 : 1;
- while (count-- > 0) {
- result->points.push_back(Interpolate(pointsA[indexA++], pointsB[indexB++], t));
- }
- } else {
- auto dataA = GetCurveData(verbA, pointsA, indexA);
- auto dataB = GetCurveData(verbB, pointsB, indexB);
- result->verbs.push_back(PathDataVerb::CurveTo);
- result->points.push_back(Interpolate(dataA.control1, dataB.control1, t));
- result->points.push_back(Interpolate(dataA.control2, dataB.control2, t));
- result->points.push_back(Interpolate(dataA.end, dataB.end, t));
+ if (verbs.empty() || path.verbs.empty()) {
+ return;
+ }
+ auto& pointsA = points;
+ auto& verbsA = verbs;
+ auto& pointsB = path.points;
+ auto& verbsB = path.verbs;
+ int indexA = 0;
+ int indexB = 0;
+ auto size = verbsA.size();
+ for (size_t i = 0; i < size; i++) {
+ auto verbA = verbsA[i];
+ auto verbB = verbsB[i];
+ if (verbA == verbB) {
+ result->verbs.push_back(verbA);
+ if (verbA == PathDataVerb::Close) {
+ continue;
+ }
+ auto count = verbA == PathDataVerb::CurveTo ? 3 : 1;
+ while (count-- > 0) {
+ result->points.push_back(Interpolate(pointsA[indexA++], pointsB[indexB++], t));
+ }
+ } else {
+ auto dataA = GetCurveData(verbA, pointsA, indexA);
+ auto dataB = GetCurveData(verbB, pointsB, indexB);
+ result->verbs.push_back(PathDataVerb::CurveTo);
+ result->points.push_back(Interpolate(dataA.control1, dataB.control1, t));
+ result->points.push_back(Interpolate(dataA.control2, dataB.control2, t));
+ result->points.push_back(Interpolate(dataA.end, dataB.end, t));
+ }
}
- }
}
} // namespace pag
diff --git a/src/base/PreComposeLayer.cpp b/src/base/PreComposeLayer.cpp
index 3d95460b11..8fd8b47808 100644
--- a/src/base/PreComposeLayer.cpp
+++ b/src/base/PreComposeLayer.cpp
@@ -21,72 +21,72 @@
namespace pag {
std::unique_ptr PreComposeLayer::Wrap(pag::Composition* composition) {
- auto layer = new PreComposeLayer();
- layer->duration = composition->duration;
- layer->transform = Transform2D::MakeDefault();
- layer->composition = composition;
- return std::unique_ptr(layer);
+ auto layer = new PreComposeLayer();
+ layer->duration = composition->duration;
+ layer->transform = Transform2D::MakeDefault();
+ layer->composition = composition;
+ return std::unique_ptr(layer);
}
void PreComposeLayer::excludeVaryingRanges(std::vector* timeRanges) {
- Layer::excludeVaryingRanges(timeRanges);
- if (timeRanges->empty()) {
- return;
- }
- auto ranges = getContentStaticTimeRanges();
- TimeRange startRange = {0, startTime - 1};
- if (startRange.start < startRange.end) {
- ranges.insert(ranges.begin(), startRange);
- }
- auto endTime = timeRanges->back().end;
- TimeRange endRange = {startTime + duration, endTime};
- if (endRange.start < endRange.end) {
- ranges.push_back(endRange);
- }
- MergeTimeRanges(timeRanges, &ranges);
+ Layer::excludeVaryingRanges(timeRanges);
+ if (timeRanges->empty()) {
+ return;
+ }
+ auto ranges = getContentStaticTimeRanges();
+ TimeRange startRange = {0, startTime - 1};
+ if (startRange.start < startRange.end) {
+ ranges.insert(ranges.begin(), startRange);
+ }
+ auto endTime = timeRanges->back().end;
+ TimeRange endRange = {startTime + duration, endTime};
+ if (endRange.start < endRange.end) {
+ ranges.push_back(endRange);
+ }
+ MergeTimeRanges(timeRanges, &ranges);
}
std::vector PreComposeLayer::getContentStaticTimeRanges() const {
- auto ranges = composition->staticTimeRanges;
- float timeScale = 1;
- if (containingComposition) {
- timeScale = containingComposition->frameRate / composition->frameRate;
- }
- for (auto i = static_cast(ranges.size() - 1); i >= 0; i--) {
- auto& range = ranges[i];
- range.start = static_cast(roundf(range.start * timeScale));
- range.end = static_cast(roundf(range.end * timeScale));
- range.start += compositionStartTime;
- range.end += compositionStartTime;
- if (range.end <= startTime || range.start >= startTime + duration - 1) {
- ranges.erase(ranges.begin() + i);
- } else {
- if (range.start < startTime) {
- range.start = startTime;
- }
- if (range.end > startTime + duration - 1) {
- range.end = startTime + duration - 1;
- }
- if (range.start == range.end) {
- ranges.erase(ranges.begin() + i);
- }
+ auto ranges = composition->staticTimeRanges;
+ float timeScale = 1;
+ if (containingComposition) {
+ timeScale = containingComposition->frameRate / composition->frameRate;
}
- }
- return ranges;
+ for (auto i = static_cast(ranges.size() - 1); i >= 0; i--) {
+ auto& range = ranges[i];
+ range.start = static_cast(roundf(range.start * timeScale));
+ range.end = static_cast(roundf(range.end * timeScale));
+ range.start += compositionStartTime;
+ range.end += compositionStartTime;
+ if (range.end <= startTime || range.start >= startTime + duration - 1) {
+ ranges.erase(ranges.begin() + i);
+ } else {
+ if (range.start < startTime) {
+ range.start = startTime;
+ }
+ if (range.end > startTime + duration - 1) {
+ range.end = startTime + duration - 1;
+ }
+ if (range.start == range.end) {
+ ranges.erase(ranges.begin() + i);
+ }
+ }
+ }
+ return ranges;
}
Frame PreComposeLayer::getCompositionFrame(Frame layerFrame) {
- auto timeScale =
- containingComposition ? (composition->frameRate / containingComposition->frameRate) : 1.0f;
- return static_cast(
- roundf(static_cast(layerFrame - compositionStartTime) * timeScale));
+ auto timeScale =
+ containingComposition ? (composition->frameRate / containingComposition->frameRate) : 1.0f;
+ return static_cast(
+ roundf(static_cast(layerFrame - compositionStartTime) * timeScale));
}
bool PreComposeLayer::verify() const {
- if (!Layer::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(composition != nullptr);
+ if (!Layer::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(composition != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/Rect.cpp b/src/base/Rect.cpp
index d85af84c6b..a96f170142 100644
--- a/src/base/Rect.cpp
+++ b/src/base/Rect.cpp
@@ -21,45 +21,45 @@
namespace pag {
void Rect::scale(float scaleX, float scaleY) {
- left *= scaleX;
- right *= scaleY;
- top *= scaleX;
- bottom *= scaleY;
+ left *= scaleX;
+ right *= scaleY;
+ top *= scaleX;
+ bottom *= scaleY;
}
bool Rect::setBounds(const Point pts[], int count) {
- if (count <= 0) {
- this->setEmpty();
- return true;
- }
- float minX, maxX;
- float minY, maxY;
- minX = maxX = pts[0].x;
- minY = maxY = pts[0].y;
-
- for (int i = 1; i < count; i++) {
- auto x = pts[i].x;
- auto y = pts[i].y;
- auto isFinite = ((x + y) * 0 == 0);
- if (!isFinite) {
- setEmpty();
- return false;
- }
- if (x < minX) {
- minX = x;
+ if (count <= 0) {
+ this->setEmpty();
+ return true;
}
- if (x > maxX) {
- maxX = x;
- }
- if (y < minY) {
- minY = y;
- }
- if (y > maxY) {
- maxY = y;
+ float minX, maxX;
+ float minY, maxY;
+ minX = maxX = pts[0].x;
+ minY = maxY = pts[0].y;
+
+ for (int i = 1; i < count; i++) {
+ auto x = pts[i].x;
+ auto y = pts[i].y;
+ auto isFinite = ((x + y) * 0 == 0);
+ if (!isFinite) {
+ setEmpty();
+ return false;
+ }
+ if (x < minX) {
+ minX = x;
+ }
+ if (x > maxX) {
+ maxX = x;
+ }
+ if (y < minY) {
+ minY = y;
+ }
+ if (y > maxY) {
+ maxY = y;
+ }
}
- }
- setLTRB(minX, minY, maxX, maxY);
- return true;
+ setLTRB(minX, minY, maxX, maxY);
+ return true;
}
#define CHECK_INTERSECT(al, at, ar, ab, bl, bt, br, bb) \
@@ -75,30 +75,30 @@ bool Rect::setBounds(const Point pts[], int count) {
// do the !(opposite) check so we return false if either arg is NaN
bool Rect::intersect(float l, float t, float r, float b) {
- CHECK_INTERSECT(l, t, r, b, left, top, right, bottom);
- this->setLTRB(L, T, R, B);
- return true;
+ CHECK_INTERSECT(l, t, r, b, left, top, right, bottom);
+ this->setLTRB(L, T, R, B);
+ return true;
}
bool Rect::intersect(const Rect& a, const Rect& b) {
- CHECK_INTERSECT(a.left, a.top, a.right, a.bottom, b.left, b.top, b.right, b.bottom);
- this->setLTRB(L, T, R, B);
- return true;
+ CHECK_INTERSECT(a.left, a.top, a.right, a.bottom, b.left, b.top, b.right, b.bottom);
+ this->setLTRB(L, T, R, B);
+ return true;
}
void Rect::join(float l, float t, float r, float b) {
- // do nothing if the params are empty
- if (l >= r || t >= b) {
- return;
- }
- // if we are empty, just assign
- if (left >= right || top >= bottom) {
- this->setLTRB(l, t, r, b);
- } else {
- left = left < l ? left : l;
- top = top < t ? top : t;
- right = right > r ? right : r;
- bottom = bottom > b ? bottom : b;
- }
+ // do nothing if the params are empty
+ if (l >= r || t >= b) {
+ return;
+ }
+ // if we are empty, just assign
+ if (left >= right || top >= bottom) {
+ this->setLTRB(l, t, r, b);
+ } else {
+ left = left < l ? left : l;
+ top = top < t ? top : t;
+ right = right > r ? right : r;
+ bottom = bottom > b ? bottom : b;
+ }
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/Sequence.cpp b/src/base/Sequence.cpp
index 60c335c2e5..946ea3cb0c 100644
--- a/src/base/Sequence.cpp
+++ b/src/base/Sequence.cpp
@@ -21,32 +21,32 @@
namespace pag {
Sequence* Sequence::Get(Composition* composition) {
- // Currently, we use the last one for best rendering quality, ignore all others.
- if (composition != nullptr) {
- switch (composition->type()) {
- case CompositionType::Video:
- return static_cast(composition)->sequences.back();
- case CompositionType::Bitmap:
- return static_cast(composition)->sequences.back();
- default:
- break;
+ // Currently, we use the last one for best rendering quality, ignore all others.
+ if (composition != nullptr) {
+ switch (composition->type()) {
+ case CompositionType::Video:
+ return static_cast(composition)->sequences.back();
+ case CompositionType::Bitmap:
+ return static_cast(composition)->sequences.back();
+ default:
+ break;
+ }
}
- }
- return nullptr;
+ return nullptr;
}
bool Sequence::verify() const {
- VerifyAndReturn(composition != nullptr && width > 0 && height > 0 && frameRate > 0);
+ VerifyAndReturn(composition != nullptr && width > 0 && height > 0 && frameRate > 0);
}
Frame Sequence::toSequenceFrame(Frame compositionFrame) {
- auto sequenceFrame =
- ConvertFrameByStaticTimeRanges(composition->staticTimeRanges, compositionFrame);
- double timeScale = frameRate / composition->frameRate;
- sequenceFrame = static_cast(round(sequenceFrame * timeScale));
- if (sequenceFrame >= duration()) {
- sequenceFrame = static_cast(duration()) - 1;
- }
- return sequenceFrame;
+ auto sequenceFrame =
+ ConvertFrameByStaticTimeRanges(composition->staticTimeRanges, compositionFrame);
+ double timeScale = frameRate / composition->frameRate;
+ sequenceFrame = static_cast(round(sequenceFrame * timeScale));
+ if (sequenceFrame >= duration()) {
+ sequenceFrame = static_cast(duration()) - 1;
+ }
+ return sequenceFrame;
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/ShapeLayer.cpp b/src/base/ShapeLayer.cpp
index 6d03697d91..245ee17359 100644
--- a/src/base/ShapeLayer.cpp
+++ b/src/base/ShapeLayer.cpp
@@ -22,30 +22,30 @@
namespace pag {
ShapeLayer::~ShapeLayer() {
- for (auto& element : contents) {
- delete element;
- }
+ for (auto& element : contents) {
+ delete element;
+ }
}
void ShapeLayer::excludeVaryingRanges(std::vector* timeRanges) {
- Layer::excludeVaryingRanges(timeRanges);
- for (auto& element : contents) {
- element->excludeVaryingRanges(timeRanges);
- }
+ Layer::excludeVaryingRanges(timeRanges);
+ for (auto& element : contents) {
+ element->excludeVaryingRanges(timeRanges);
+ }
}
bool ShapeLayer::verify() const {
- if (!Layer::verify()) {
- VerifyFailed();
- return false;
- }
- for (auto& element : contents) {
- if (element == nullptr || !element->verify()) {
- VerifyFailed();
- return false;
+ if (!Layer::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ for (auto& element : contents) {
+ if (element == nullptr || !element->verify()) {
+ VerifyFailed();
+ return false;
+ }
}
- }
- return true;
+ return true;
}
} // namespace pag
diff --git a/src/base/SolidLayer.cpp b/src/base/SolidLayer.cpp
index 33fa26d35f..692b836c69 100644
--- a/src/base/SolidLayer.cpp
+++ b/src/base/SolidLayer.cpp
@@ -21,10 +21,10 @@
namespace pag {
bool SolidLayer::verify() const {
- if (!Layer::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(width > 0 && height > 0);
+ if (!Layer::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(width > 0 && height > 0);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/TextLayer.cpp b/src/base/TextLayer.cpp
index 3af10d8ddf..ae5d6a38ad 100644
--- a/src/base/TextLayer.cpp
+++ b/src/base/TextLayer.cpp
@@ -22,59 +22,59 @@
namespace pag {
TextLayer::~TextLayer() {
- delete sourceText;
- delete pathOption;
- delete moreOption;
- for (auto& animator : animators) {
- delete animator;
- }
+ delete sourceText;
+ delete pathOption;
+ delete moreOption;
+ for (auto& animator : animators) {
+ delete animator;
+ }
}
TextDocumentHandle TextLayer::getTextDocument() {
- if (sourceText == nullptr) {
- return nullptr;
- }
- if (sourceText->animatable()) {
- auto keyframes =
- reinterpret_cast*>(sourceText)->keyframes;
- return keyframes[0]->startValue;
- }
- return sourceText->getValueAt(0);
+ if (sourceText == nullptr) {
+ return nullptr;
+ }
+ if (sourceText->animatable()) {
+ auto keyframes =
+ reinterpret_cast*>(sourceText)->keyframes;
+ return keyframes[0]->startValue;
+ }
+ return sourceText->getValueAt(0);
}
void TextLayer::excludeVaryingRanges(std::vector* timeRanges) {
- Layer::excludeVaryingRanges(timeRanges);
- sourceText->excludeVaryingRanges(timeRanges);
- if (pathOption) {
- pathOption->excludeVaryingRanges(timeRanges);
- }
- if (moreOption) {
- moreOption->excludeVaryingRanges(timeRanges);
- }
- for (auto& animator : animators) {
- animator->excludeVaryingRanges(timeRanges);
- }
+ Layer::excludeVaryingRanges(timeRanges);
+ sourceText->excludeVaryingRanges(timeRanges);
+ if (pathOption) {
+ pathOption->excludeVaryingRanges(timeRanges);
+ }
+ if (moreOption) {
+ moreOption->excludeVaryingRanges(timeRanges);
+ }
+ for (auto& animator : animators) {
+ animator->excludeVaryingRanges(timeRanges);
+ }
}
bool TextLayer::verify() const {
- if (!Layer::verify()) {
- VerifyFailed();
- return false;
- }
- if (sourceText == nullptr) {
- VerifyFailed();
- return false;
- }
- if (pathOption != nullptr && !pathOption->verify()) {
- VerifyFailed();
- return false;
- }
- for (auto& animator : animators) {
- if (animator == nullptr || !animator->verify()) {
- VerifyFailed();
- return false;
+ if (!Layer::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ if (sourceText == nullptr) {
+ VerifyFailed();
+ return false;
+ }
+ if (pathOption != nullptr && !pathOption->verify()) {
+ VerifyFailed();
+ return false;
+ }
+ for (auto& animator : animators) {
+ if (animator == nullptr || !animator->verify()) {
+ VerifyFailed();
+ return false;
+ }
}
- }
- VerifyAndReturn(moreOption == nullptr || moreOption->verify());
+ VerifyAndReturn(moreOption == nullptr || moreOption->verify());
}
} // namespace pag
diff --git a/src/base/TimeRange.cpp b/src/base/TimeRange.cpp
index c06bd7e9cf..f6afbeca03 100644
--- a/src/base/TimeRange.cpp
+++ b/src/base/TimeRange.cpp
@@ -22,150 +22,150 @@
namespace pag {
static void TargetInsideTimeRange(std::vector* timeRanges, int i, Frame startTime,
Frame endTime) {
- auto& timeRange = (*timeRanges)[i];
- TimeRange range = {endTime + 1, timeRange.end};
- timeRange.end = startTime - 1;
- if (range.end > range.start) {
- timeRanges->insert(timeRanges->begin() + i + 1, range);
- }
- if (timeRange.end <= timeRange.start) {
- timeRanges->erase(timeRanges->begin() + i);
- }
+ auto& timeRange = (*timeRanges)[i];
+ TimeRange range = {endTime + 1, timeRange.end};
+ timeRange.end = startTime - 1;
+ if (range.end > range.start) {
+ timeRanges->insert(timeRanges->begin() + i + 1, range);
+ }
+ if (timeRange.end <= timeRange.start) {
+ timeRanges->erase(timeRanges->begin() + i);
+ }
}
static void TargetIntersectTimeRange(std::vector* timeRanges, int i, Frame startTime,
Frame endTime) {
- auto& timeRange = (*timeRanges)[i];
- if (timeRange.start < startTime) {
- timeRange.end = startTime - 1;
- } else {
- timeRange.start = endTime + 1;
- }
- if (timeRange.end <= timeRange.start) {
- timeRanges->erase(timeRanges->begin() + i);
- }
+ auto& timeRange = (*timeRanges)[i];
+ if (timeRange.start < startTime) {
+ timeRange.end = startTime - 1;
+ } else {
+ timeRange.start = endTime + 1;
+ }
+ if (timeRange.end <= timeRange.start) {
+ timeRanges->erase(timeRanges->begin() + i);
+ }
}
void SubtractFromTimeRanges(std::vector* timeRanges, Frame startTime, Frame endTime) {
- if (endTime < startTime) {
- SplitTimeRangesAt(timeRanges, startTime);
- return;
- }
- auto size = static_cast(timeRanges->size());
- for (int i = size - 1; i >= 0; i--) {
- auto& timeRange = (*timeRanges)[i];
- if (timeRange.end < startTime || timeRange.start > endTime) {
- // target outside timeRange
- continue;
- }
- if (timeRange.start < startTime && timeRange.end > endTime) {
- // target inside timeRange
- TargetInsideTimeRange(timeRanges, i, startTime, endTime);
- break;
+ if (endTime < startTime) {
+ SplitTimeRangesAt(timeRanges, startTime);
+ return;
}
- if (timeRange.start >= startTime && timeRange.end <= endTime) {
- // target contain timeRange
- timeRanges->erase(timeRanges->begin() + i);
- } else {
- // target intersect timeRange
- TargetIntersectTimeRange(timeRanges, i, startTime, endTime);
+ auto size = static_cast(timeRanges->size());
+ for (int i = size - 1; i >= 0; i--) {
+ auto& timeRange = (*timeRanges)[i];
+ if (timeRange.end < startTime || timeRange.start > endTime) {
+ // target outside timeRange
+ continue;
+ }
+ if (timeRange.start < startTime && timeRange.end > endTime) {
+ // target inside timeRange
+ TargetInsideTimeRange(timeRanges, i, startTime, endTime);
+ break;
+ }
+ if (timeRange.start >= startTime && timeRange.end <= endTime) {
+ // target contain timeRange
+ timeRanges->erase(timeRanges->begin() + i);
+ } else {
+ // target intersect timeRange
+ TargetIntersectTimeRange(timeRanges, i, startTime, endTime);
+ }
}
- }
}
void SplitTimeRangesAt(std::vector* timeRanges, Frame startTime) {
- auto size = static_cast(timeRanges->size());
- for (int i = size - 1; i >= 0; i--) {
- auto timeRange = (*timeRanges)[i];
- if (timeRange.start == startTime || timeRange.end < startTime) {
- break;
- }
- if (timeRange.start < startTime && timeRange.end >= startTime) {
- TimeRange range = {startTime, timeRange.end};
- (*timeRanges)[i].end = timeRange.end = startTime - 1;
- if (range.end > range.start) {
- timeRanges->insert(timeRanges->begin() + i + 1, range);
- }
- if (timeRange.end <= timeRange.start) {
- timeRanges->erase(timeRanges->begin() + i);
- }
- break;
+ auto size = static_cast(timeRanges->size());
+ for (int i = size - 1; i >= 0; i--) {
+ auto timeRange = (*timeRanges)[i];
+ if (timeRange.start == startTime || timeRange.end < startTime) {
+ break;
+ }
+ if (timeRange.start < startTime && timeRange.end >= startTime) {
+ TimeRange range = {startTime, timeRange.end};
+ (*timeRanges)[i].end = timeRange.end = startTime - 1;
+ if (range.end > range.start) {
+ timeRanges->insert(timeRanges->begin() + i + 1, range);
+ }
+ if (timeRange.end <= timeRange.start) {
+ timeRanges->erase(timeRanges->begin() + i);
+ }
+ break;
+ }
}
- }
}
void MergeTimeRanges(std::vector* timeRanges,
const std::vector* otherRanges) {
- std::vector intersections;
- auto mergeFunc = [otherRanges, &intersections](TimeRange& timeRange) {
- for (auto& range : *otherRanges) {
- if (range.end < timeRange.start) {
- continue;
- }
- if (range.start > timeRange.end) {
- break;
- }
- if (range.start <= timeRange.start && range.end >= timeRange.end) {
- intersections.push_back(timeRange);
- break;
- }
- if (range.start >= timeRange.start && range.end <= timeRange.end) {
- intersections.push_back(range);
- continue;
- }
- if (range.start < timeRange.start) {
- TimeRange newRange = {timeRange.start, range.end};
- intersections.push_back(newRange);
- continue;
- }
- if (range.end > timeRange.end) {
- TimeRange newRange = {range.start, timeRange.end};
- intersections.push_back(newRange);
- }
- }
- };
- std::for_each(timeRanges->begin(), timeRanges->end(), mergeFunc);
- *timeRanges = intersections;
+ std::vector intersections;
+ auto mergeFunc = [otherRanges, &intersections](TimeRange& timeRange) {
+ for (auto& range : *otherRanges) {
+ if (range.end < timeRange.start) {
+ continue;
+ }
+ if (range.start > timeRange.end) {
+ break;
+ }
+ if (range.start <= timeRange.start && range.end >= timeRange.end) {
+ intersections.push_back(timeRange);
+ break;
+ }
+ if (range.start >= timeRange.start && range.end <= timeRange.end) {
+ intersections.push_back(range);
+ continue;
+ }
+ if (range.start < timeRange.start) {
+ TimeRange newRange = {timeRange.start, range.end};
+ intersections.push_back(newRange);
+ continue;
+ }
+ if (range.end > timeRange.end) {
+ TimeRange newRange = {range.start, timeRange.end};
+ intersections.push_back(newRange);
+ }
+ }
+ };
+ std::for_each(timeRanges->begin(), timeRanges->end(), mergeFunc);
+ *timeRanges = intersections;
}
std::vector OffsetTimeRanges(const std::vector& timeRanges,
Frame offsetTime) {
- std::vector newTimeRanges = {};
- for (auto timeRange : timeRanges) {
- timeRange.start += offsetTime;
- timeRange.end += offsetTime;
- newTimeRanges.push_back(timeRange);
- }
- return newTimeRanges;
+ std::vector newTimeRanges = {};
+ for (auto timeRange : timeRanges) {
+ timeRange.start += offsetTime;
+ timeRange.end += offsetTime;
+ newTimeRanges.push_back(timeRange);
+ }
+ return newTimeRanges;
}
bool HasVaryingTimeRange(const std::vector* staticTimeRanges, Frame startTime,
Frame duration) {
- if (staticTimeRanges->size() == 1) {
- auto& range = (*staticTimeRanges)[0];
- if (range.start == startTime && range.end == startTime + duration - 1) {
- return false;
+ if (staticTimeRanges->size() == 1) {
+ auto& range = (*staticTimeRanges)[0];
+ if (range.start == startTime && range.end == startTime + duration - 1) {
+ return false;
+ }
}
- }
- return true;
+ return true;
}
int FindTimeRangeAt(const std::vector& timeRanges, Frame position, int start, int end) {
- if (start > end) {
- return -1;
- }
- auto index = static_cast((start + end) * 0.5);
- auto& timeRange = timeRanges[index];
- if (timeRange.start > position) {
- return FindTimeRangeAt(timeRanges, position, start, index - 1);
- } else if (timeRange.end < position) {
- return FindTimeRangeAt(timeRanges, position, index + 1, end);
- } else {
- return index;
- }
+ if (start > end) {
+ return -1;
+ }
+ auto index = static_cast((start + end) * 0.5);
+ auto& timeRange = timeRanges[index];
+ if (timeRange.start > position) {
+ return FindTimeRangeAt(timeRanges, position, start, index - 1);
+ } else if (timeRange.end < position) {
+ return FindTimeRangeAt(timeRanges, position, index + 1, end);
+ } else {
+ return index;
+ }
}
Frame ConvertFrameByStaticTimeRanges(const std::vector& timeRanges, Frame frame) {
- auto index = FindTimeRangeAt(timeRanges, frame, 0, static_cast(timeRanges.size() - 1));
- return index != -1 ? timeRanges[index].start : frame;
+ auto index = FindTimeRangeAt(timeRanges, frame, 0, static_cast(timeRanges.size() - 1));
+ return index != -1 ? timeRanges[index].start : frame;
}
} // namespace pag
diff --git a/src/base/Transform2D.cpp b/src/base/Transform2D.cpp
index 646c14bf96..ee8360a272 100644
--- a/src/base/Transform2D.cpp
+++ b/src/base/Transform2D.cpp
@@ -21,45 +21,45 @@
namespace pag {
Transform2D* Transform2D::MakeDefault() {
- auto transform = new Transform2D();
- transform->anchorPoint = new Property();
- transform->anchorPoint->value = Point::Zero();
- transform->position = new Property();
- transform->position->value = Point::Zero();
- transform->scale = new Property();
- transform->scale->value = Point::Make(1, 1);
- transform->rotation = new Property();
- transform->rotation->value = 0.0f;
- transform->opacity = new Property();
- transform->opacity->value = Opaque;
- return transform;
+ auto transform = new Transform2D();
+ transform->anchorPoint = new Property();
+ transform->anchorPoint->value = Point::Zero();
+ transform->position = new Property();
+ transform->position->value = Point::Zero();
+ transform->scale = new Property();
+ transform->scale->value = Point::Make(1, 1);
+ transform->rotation = new Property();
+ transform->rotation->value = 0.0f;
+ transform->opacity = new Property();
+ transform->opacity->value = Opaque;
+ return transform;
}
Transform2D::~Transform2D() {
- delete anchorPoint;
- delete position;
- delete xPosition;
- delete yPosition;
- delete scale;
- delete rotation;
- delete opacity;
+ delete anchorPoint;
+ delete position;
+ delete xPosition;
+ delete yPosition;
+ delete scale;
+ delete rotation;
+ delete opacity;
}
void Transform2D::excludeVaryingRanges(std::vector* timeRanges) const {
- anchorPoint->excludeVaryingRanges(timeRanges);
- if (position != nullptr) {
- position->excludeVaryingRanges(timeRanges);
- } else {
- xPosition->excludeVaryingRanges(timeRanges);
- yPosition->excludeVaryingRanges(timeRanges);
- }
- scale->excludeVaryingRanges(timeRanges);
- rotation->excludeVaryingRanges(timeRanges);
- opacity->excludeVaryingRanges(timeRanges);
+ anchorPoint->excludeVaryingRanges(timeRanges);
+ if (position != nullptr) {
+ position->excludeVaryingRanges(timeRanges);
+ } else {
+ xPosition->excludeVaryingRanges(timeRanges);
+ yPosition->excludeVaryingRanges(timeRanges);
+ }
+ scale->excludeVaryingRanges(timeRanges);
+ rotation->excludeVaryingRanges(timeRanges);
+ opacity->excludeVaryingRanges(timeRanges);
}
bool Transform2D::verify() const {
- VerifyAndReturn(anchorPoint != nullptr &&
- (position != nullptr || (xPosition != nullptr && yPosition != nullptr)) &&
- scale != nullptr && rotation != nullptr && opacity != nullptr);
+ VerifyAndReturn(anchorPoint != nullptr &&
+ (position != nullptr || (xPosition != nullptr && yPosition != nullptr)) &&
+ scale != nullptr && rotation != nullptr && opacity != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/VectorComposition.cpp b/src/base/VectorComposition.cpp
index 0806a99d71..397d31ec57 100644
--- a/src/base/VectorComposition.cpp
+++ b/src/base/VectorComposition.cpp
@@ -22,67 +22,67 @@
namespace pag {
VectorComposition::~VectorComposition() {
- for (auto& layer : layers) {
- delete layer;
- }
+ for (auto& layer : layers) {
+ delete layer;
+ }
}
CompositionType VectorComposition::type() const {
- return CompositionType::Vector;
+ return CompositionType::Vector;
}
void VectorComposition::updateStaticTimeRanges() {
- staticTimeRanges = {};
- if (duration <= 1) {
- return;
- }
- TimeRange range = {0, duration - 1};
- staticTimeRanges.push_back(range);
- for (auto layer : layers) {
- if (staticTimeRanges.empty()) {
- break;
+ staticTimeRanges = {};
+ if (duration <= 1) {
+ return;
}
- if (layer->type() == LayerType::PreCompose) {
- auto composition = static_cast(layer)->composition;
- if (!composition->staticTimeRangeUpdated) {
- composition->updateStaticTimeRanges();
- composition->staticTimeRangeUpdated = true;
- }
+ TimeRange range = {0, duration - 1};
+ staticTimeRanges.push_back(range);
+ for (auto layer : layers) {
+ if (staticTimeRanges.empty()) {
+ break;
+ }
+ if (layer->type() == LayerType::PreCompose) {
+ auto composition = static_cast(layer)->composition;
+ if (!composition->staticTimeRangeUpdated) {
+ composition->updateStaticTimeRanges();
+ composition->staticTimeRangeUpdated = true;
+ }
+ }
+ layer->excludeVaryingRanges(&staticTimeRanges);
+ SplitTimeRangesAt(&staticTimeRanges, layer->startTime);
+ SplitTimeRangesAt(&staticTimeRanges, layer->startTime + layer->duration);
}
- layer->excludeVaryingRanges(&staticTimeRanges);
- SplitTimeRangesAt(&staticTimeRanges, layer->startTime);
- SplitTimeRangesAt(&staticTimeRanges, layer->startTime + layer->duration);
- }
}
bool VectorComposition::hasImageContent() const {
- for (auto& layer : layers) {
- switch (layer->type()) {
- case LayerType::PreCompose:
- if (static_cast(layer)->composition->hasImageContent()) {
- return true;
+ for (auto& layer : layers) {
+ switch (layer->type()) {
+ case LayerType::PreCompose:
+ if (static_cast(layer)->composition->hasImageContent()) {
+ return true;
+ }
+ break;
+ case LayerType::Image:
+ return true;
+ default:
+ break;
}
- break;
- case LayerType::Image:
- return true;
- default:
- break;
}
- }
- return false;
+ return false;
}
bool VectorComposition::verify() const {
- if (!Composition::verify()) {
- VerifyFailed();
- return false;
- }
- for (auto layer : layers) {
- if (layer == nullptr || !layer->verify()) {
- VerifyFailed();
- return false;
+ if (!Composition::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ for (auto layer : layers) {
+ if (layer == nullptr || !layer->verify()) {
+ VerifyFailed();
+ return false;
+ }
}
- }
- return true;
+ return true;
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/VideoComposition.cpp b/src/base/VideoComposition.cpp
index a2f30e3e8f..9d82b64fac 100644
--- a/src/base/VideoComposition.cpp
+++ b/src/base/VideoComposition.cpp
@@ -21,56 +21,56 @@
namespace pag {
VideoComposition::~VideoComposition() {
- for (auto sequence : sequences) {
- delete sequence;
- }
+ for (auto sequence : sequences) {
+ delete sequence;
+ }
}
CompositionType VideoComposition::type() const {
- return CompositionType::Video;
+ return CompositionType::Video;
}
void VideoComposition::updateStaticTimeRanges() {
- staticTimeRanges = {};
- if (duration <= 1) {
- return;
- }
- if (!sequences.empty()) {
- auto sequence = sequences[0];
- for (size_t i = 1; i < sequences.size(); i++) {
- auto item = sequences[i];
- if (item->frameRate > sequence->frameRate) {
- sequence = item;
- }
+ staticTimeRanges = {};
+ if (duration <= 1) {
+ return;
}
- float timeScale = frameRate / sequence->frameRate;
- for (auto timeRange : sequence->staticTimeRanges) {
- timeRange.start = static_cast(roundf(timeRange.start * timeScale));
- timeRange.end = static_cast(roundf(timeRange.end * timeScale));
- staticTimeRanges.push_back(timeRange);
+ if (!sequences.empty()) {
+ auto sequence = sequences[0];
+ for (size_t i = 1; i < sequences.size(); i++) {
+ auto item = sequences[i];
+ if (item->frameRate > sequence->frameRate) {
+ sequence = item;
+ }
+ }
+ float timeScale = frameRate / sequence->frameRate;
+ for (auto timeRange : sequence->staticTimeRanges) {
+ timeRange.start = static_cast(roundf(timeRange.start * timeScale));
+ timeRange.end = static_cast(roundf(timeRange.end * timeScale));
+ staticTimeRanges.push_back(timeRange);
+ }
+ } else {
+ TimeRange range = {0, duration - 1};
+ staticTimeRanges.push_back(range);
}
- } else {
- TimeRange range = {0, duration - 1};
- staticTimeRanges.push_back(range);
- }
}
bool VideoComposition::hasImageContent() const {
- return true;
+ return true;
}
bool VideoComposition::verify() const {
- if (!Composition::verify() || sequences.empty()) {
- VerifyFailed();
- return false;
- }
- auto sequenceValid = [](VideoSequence* sequence) {
- return sequence != nullptr && sequence->verify();
- };
- if (!std::all_of(sequences.begin(), sequences.end(), sequenceValid)) {
- VerifyFailed();
- return false;
- }
- return true;
+ if (!Composition::verify() || sequences.empty()) {
+ VerifyFailed();
+ return false;
+ }
+ auto sequenceValid = [](VideoSequence* sequence) {
+ return sequence != nullptr && sequence->verify();
+ };
+ if (!std::all_of(sequences.begin(), sequences.end(), sequenceValid)) {
+ VerifyFailed();
+ return false;
+ }
+ return true;
}
} // namespace pag
diff --git a/src/base/VideoSequence.cpp b/src/base/VideoSequence.cpp
index 7e5da162f4..1f99eee389 100644
--- a/src/base/VideoSequence.cpp
+++ b/src/base/VideoSequence.cpp
@@ -21,36 +21,38 @@
namespace pag {
VideoFrame::~VideoFrame() {
- delete fileBytes;
+ delete fileBytes;
}
VideoSequence::~VideoSequence() {
- for (auto frame : frames) {
- delete frame;
- }
+ for (auto frame : frames) {
+ delete frame;
+ }
- for (auto header : headers) {
- delete header;
- }
+ for (auto header : headers) {
+ delete header;
+ }
}
bool VideoSequence::verify() const {
- if (!Sequence::verify() || frames.empty()) {
- VerifyFailed();
- return false;
- }
- auto frameNotNull = [](VideoFrame* frame) {
- return frame != nullptr && frame->fileBytes != nullptr;
- };
- if (!std::all_of(frames.begin(), frames.end(), frameNotNull)) {
- VerifyFailed();
- return false;
- }
- auto headerNotNull = [](ByteData* header) { return header != nullptr; };
- if (!std::all_of(headers.begin(), headers.end(), headerNotNull)) {
- VerifyFailed();
- return false;
- }
- return true;
+ if (!Sequence::verify() || frames.empty()) {
+ VerifyFailed();
+ return false;
+ }
+ auto frameNotNull = [](VideoFrame* frame) {
+ return frame != nullptr && frame->fileBytes != nullptr;
+ };
+ if (!std::all_of(frames.begin(), frames.end(), frameNotNull)) {
+ VerifyFailed();
+ return false;
+ }
+ auto headerNotNull = [](ByteData* header) {
+ return header != nullptr;
+ };
+ if (!std::all_of(headers.begin(), headers.end(), headerNotNull)) {
+ VerifyFailed();
+ return false;
+ }
+ return true;
}
} // namespace pag
diff --git a/src/base/effects/BulgeEffect.cpp b/src/base/effects/BulgeEffect.cpp
index 1607cd21a1..4d70a2adc2 100644
--- a/src/base/effects/BulgeEffect.cpp
+++ b/src/base/effects/BulgeEffect.cpp
@@ -24,139 +24,139 @@
namespace pag {
static void ConvertEllipseToPath(Path* path, float centerX, float centerY, float radiusX,
float radiusY) {
- auto start = -M_PI_2_F;
- auto endAngle = M_PI_F + M_PI_2_F;
- auto end = 0;
- auto currentX = centerX + cosf(start) * radiusX;
- auto currentY = centerY + sinf(start) * radiusY;
- path->moveTo(currentX, currentY);
- auto u = cosf(start);
- auto v = sinf(start);
- for (int i = 0; i < 4; i++) {
- auto addAngle = end - start;
- auto a = 4 * tanf(addAngle * 0.25f) / 3;
- auto x1 = currentX - v * a * radiusX;
- auto y1 = currentY + u * a * radiusY;
- u = cosf(end);
- v = sinf(end);
- currentX = centerX + u * radiusX;
- currentY = centerY + v * radiusY;
- auto x2 = currentX + v * a * radiusX;
- auto y2 = currentY - u * a * radiusY;
- path->cubicTo(x1, y1, x2, y2, currentX, currentY);
- if (end == endAngle) {
- break;
+ auto start = -M_PI_2_F;
+ auto endAngle = M_PI_F + M_PI_2_F;
+ auto end = 0;
+ auto currentX = centerX + cosf(start) * radiusX;
+ auto currentY = centerY + sinf(start) * radiusY;
+ path->moveTo(currentX, currentY);
+ auto u = cosf(start);
+ auto v = sinf(start);
+ for (int i = 0; i < 4; i++) {
+ auto addAngle = end - start;
+ auto a = 4 * tanf(addAngle * 0.25f) / 3;
+ auto x1 = currentX - v * a * radiusX;
+ auto y1 = currentY + u * a * radiusY;
+ u = cosf(end);
+ v = sinf(end);
+ currentX = centerX + u * radiusX;
+ currentY = centerY + v * radiusY;
+ auto x2 = currentX + v * a * radiusX;
+ auto y2 = currentY - u * a * radiusY;
+ path->cubicTo(x1, y1, x2, y2, currentX, currentY);
+ if (end == endAngle) {
+ break;
+ }
+ start = end;
+ end = start + M_PI_2_F;
+ if (end > endAngle) {
+ end = endAngle;
+ }
}
- start = end;
- end = start + M_PI_2_F;
- if (end > endAngle) {
- end = endAngle;
- }
- }
- path->close();
+ path->close();
}
BulgeEffect::~BulgeEffect() {
- delete horizontalRadius;
- delete verticalRadius;
- delete bulgeCenter;
- delete bulgeHeight;
- delete taperRadius;
- delete pinning;
+ delete horizontalRadius;
+ delete verticalRadius;
+ delete bulgeCenter;
+ delete bulgeHeight;
+ delete taperRadius;
+ delete pinning;
}
bool BulgeEffect::visibleAt(Frame layerFrame) const {
- auto horizontalRadiusValue = horizontalRadius->getValueAt(layerFrame);
- auto verticalRadiusValue = verticalRadius->getValueAt(layerFrame);
- auto height = bulgeHeight->getValueAt(layerFrame);
- return height != 0.0f && horizontalRadiusValue != 0.0f && verticalRadiusValue != 0.0f;
+ auto horizontalRadiusValue = horizontalRadius->getValueAt(layerFrame);
+ auto verticalRadiusValue = verticalRadius->getValueAt(layerFrame);
+ auto height = bulgeHeight->getValueAt(layerFrame);
+ return height != 0.0f && horizontalRadiusValue != 0.0f && verticalRadiusValue != 0.0f;
}
void AdjustLeft(const Point& bulgeCenterValue, float horizontalRadiusValue, float* left) {
- auto leftDiffer =
- bulgeCenterValue.x > *left ? (*left - (bulgeCenterValue.x - horizontalRadiusValue)) : 0;
- if (leftDiffer > 0) {
- *left -= leftDiffer;
- }
+ auto leftDiffer =
+ bulgeCenterValue.x > *left ? (*left - (bulgeCenterValue.x - horizontalRadiusValue)) : 0;
+ if (leftDiffer > 0) {
+ *left -= leftDiffer;
+ }
}
void AdjustRight(const Point& bulgeCenterValue, float horizontalRadiusValue, float* right) {
- auto rightDiffer =
- bulgeCenterValue.y < *right ? ((bulgeCenterValue.x + horizontalRadiusValue) - *right) : 0;
- if (rightDiffer > 0) {
- *right += rightDiffer;
- }
+ auto rightDiffer =
+ bulgeCenterValue.y < *right ? ((bulgeCenterValue.x + horizontalRadiusValue) - *right) : 0;
+ if (rightDiffer > 0) {
+ *right += rightDiffer;
+ }
}
void AdjustTop(const Point& bulgeCenterValue, float verticalRadiusValue, float* top) {
- auto topDiffer =
- bulgeCenterValue.y > *top ? (*top - (bulgeCenterValue.y - verticalRadiusValue)) : 0;
- if (topDiffer > 0) {
- *top -= topDiffer;
- }
+ auto topDiffer =
+ bulgeCenterValue.y > *top ? (*top - (bulgeCenterValue.y - verticalRadiusValue)) : 0;
+ if (topDiffer > 0) {
+ *top -= topDiffer;
+ }
}
void AdjustBottom(const Point& bulgeCenterValue, float verticalRadiusValue, float* bottom) {
- auto bottomDiffer =
- (bulgeCenterValue.y < *bottom) ? ((bulgeCenterValue.y + verticalRadiusValue) - *bottom) : 0;
- if (bottomDiffer > 0) {
- *bottom += bottomDiffer;
- }
+ auto bottomDiffer =
+ (bulgeCenterValue.y < *bottom) ? ((bulgeCenterValue.y + verticalRadiusValue) - *bottom) : 0;
+ if (bottomDiffer > 0) {
+ *bottom += bottomDiffer;
+ }
}
void BulgeEffect::transformBounds(Rect* contentBounds, const Point&, Frame layerFrame) const {
- auto horizontalRadiusValue = horizontalRadius->getValueAt(layerFrame);
- auto verticalRadiusValue = verticalRadius->getValueAt(layerFrame);
- auto bulgeCenterValue = bulgeCenter->getValueAt(layerFrame);
- auto bulgeHeightValue = bulgeHeight->getValueAt(layerFrame);
- auto pinningValue = pinning->getValueAt(layerFrame);
- // 凸出特效固定开启的话,不改变尺寸。
- if (pinningValue || bulgeHeightValue == 0) {
- return;
- }
+ auto horizontalRadiusValue = horizontalRadius->getValueAt(layerFrame);
+ auto verticalRadiusValue = verticalRadius->getValueAt(layerFrame);
+ auto bulgeCenterValue = bulgeCenter->getValueAt(layerFrame);
+ auto bulgeHeightValue = bulgeHeight->getValueAt(layerFrame);
+ auto pinningValue = pinning->getValueAt(layerFrame);
+ // 凸出特效固定开启的话,不改变尺寸。
+ if (pinningValue || bulgeHeightValue == 0) {
+ return;
+ }
- auto left = contentBounds->left;
- auto top = contentBounds->top;
- auto right = contentBounds->right;
- auto bottom = contentBounds->bottom;
+ auto left = contentBounds->left;
+ auto top = contentBounds->top;
+ auto right = contentBounds->right;
+ auto bottom = contentBounds->bottom;
- Path ellipsePath = {};
- // radius 需要加 1,如果 2 者相交只有一个点时,intersectPath.isEmpty 为 true
- ConvertEllipseToPath(&ellipsePath, bulgeCenterValue.x, bulgeCenterValue.y,
- horizontalRadiusValue + 1, verticalRadiusValue + 1);
- Path boundsPath = {};
- boundsPath.addRect(left, top, right, bottom);
- auto intersectPath = ellipsePath;
- intersectPath.addPath(boundsPath, PathOp::Intersect);
- // 凸出效果的椭圆与内容 bounds 没有交集,不改变尺寸
- if (intersectPath.isEmpty() && !intersectPath.isInverseFillType()) {
- return;
- }
- // 计算凸出范围
- AdjustLeft(bulgeCenterValue, horizontalRadiusValue, &left);
- AdjustRight(bulgeCenterValue, horizontalRadiusValue, &right);
- AdjustTop(bulgeCenterValue, verticalRadiusValue, &top);
- AdjustBottom(bulgeCenterValue, verticalRadiusValue, &bottom);
- contentBounds->setLTRB(left, top, right, bottom);
+ Path ellipsePath = {};
+ // radius 需要加 1,如果 2 者相交只有一个点时,intersectPath.isEmpty 为 true
+ ConvertEllipseToPath(&ellipsePath, bulgeCenterValue.x, bulgeCenterValue.y,
+ horizontalRadiusValue + 1, verticalRadiusValue + 1);
+ Path boundsPath = {};
+ boundsPath.addRect(left, top, right, bottom);
+ auto intersectPath = ellipsePath;
+ intersectPath.addPath(boundsPath, PathOp::Intersect);
+ // 凸出效果的椭圆与内容 bounds 没有交集,不改变尺寸
+ if (intersectPath.isEmpty() && !intersectPath.isInverseFillType()) {
+ return;
+ }
+ // 计算凸出范围
+ AdjustLeft(bulgeCenterValue, horizontalRadiusValue, &left);
+ AdjustRight(bulgeCenterValue, horizontalRadiusValue, &right);
+ AdjustTop(bulgeCenterValue, verticalRadiusValue, &top);
+ AdjustBottom(bulgeCenterValue, verticalRadiusValue, &bottom);
+ contentBounds->setLTRB(left, top, right, bottom);
}
void BulgeEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- horizontalRadius->excludeVaryingRanges(timeRanges);
- verticalRadius->excludeVaryingRanges(timeRanges);
- bulgeCenter->excludeVaryingRanges(timeRanges);
- bulgeHeight->excludeVaryingRanges(timeRanges);
- taperRadius->excludeVaryingRanges(timeRanges);
- pinning->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ horizontalRadius->excludeVaryingRanges(timeRanges);
+ verticalRadius->excludeVaryingRanges(timeRanges);
+ bulgeCenter->excludeVaryingRanges(timeRanges);
+ bulgeHeight->excludeVaryingRanges(timeRanges);
+ taperRadius->excludeVaryingRanges(timeRanges);
+ pinning->excludeVaryingRanges(timeRanges);
}
bool BulgeEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(horizontalRadius != nullptr && verticalRadius != nullptr &&
- bulgeCenter != nullptr && bulgeHeight != nullptr && taperRadius != nullptr &&
- pinning != nullptr);
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(horizontalRadius != nullptr && verticalRadius != nullptr &&
+ bulgeCenter != nullptr && bulgeHeight != nullptr && taperRadius != nullptr &&
+ pinning != nullptr);
}
} // namespace pag
diff --git a/src/base/effects/CornerPinEffect.cpp b/src/base/effects/CornerPinEffect.cpp
index 775790f109..6b5e8fb15d 100644
--- a/src/base/effects/CornerPinEffect.cpp
+++ b/src/base/effects/CornerPinEffect.cpp
@@ -21,48 +21,48 @@
namespace pag {
CornerPinEffect::~CornerPinEffect() {
- delete upperLeft;
- delete upperRight;
- delete lowerLeft;
- delete lowerRight;
+ delete upperLeft;
+ delete upperRight;
+ delete lowerLeft;
+ delete lowerRight;
}
bool CornerPinEffect::visibleAt(Frame) const {
- return true;
+ return true;
}
void CornerPinEffect::transformBounds(Rect* contentBounds, const Point&, Frame layerFrame) const {
- auto upperLeftValue = upperLeft->getValueAt(layerFrame);
- auto upperRightValue = upperRight->getValueAt(layerFrame);
- auto lowerLeftValue = lowerLeft->getValueAt(layerFrame);
- auto lowerRightValue = lowerRight->getValueAt(layerFrame);
+ auto upperLeftValue = upperLeft->getValueAt(layerFrame);
+ auto upperRightValue = upperRight->getValueAt(layerFrame);
+ auto lowerLeftValue = lowerLeft->getValueAt(layerFrame);
+ auto lowerRightValue = lowerRight->getValueAt(layerFrame);
- auto left = std::min(std::min(upperLeftValue.x, lowerLeftValue.x),
- std::min(upperRightValue.x, lowerRightValue.x));
- auto top = std::min(std::min(upperLeftValue.y, lowerLeftValue.y),
- std::min(upperRightValue.y, lowerRightValue.y));
- auto right = std::max(std::max(upperLeftValue.x, lowerLeftValue.x),
- std::max(upperRightValue.x, lowerRightValue.x));
- auto bottom = std::max(std::max(upperLeftValue.y, lowerLeftValue.y),
- std::max(upperRightValue.y, lowerRightValue.y));
+ auto left = std::min(std::min(upperLeftValue.x, lowerLeftValue.x),
+ std::min(upperRightValue.x, lowerRightValue.x));
+ auto top = std::min(std::min(upperLeftValue.y, lowerLeftValue.y),
+ std::min(upperRightValue.y, lowerRightValue.y));
+ auto right = std::max(std::max(upperLeftValue.x, lowerLeftValue.x),
+ std::max(upperRightValue.x, lowerRightValue.x));
+ auto bottom = std::max(std::max(upperLeftValue.y, lowerLeftValue.y),
+ std::max(upperRightValue.y, lowerRightValue.y));
- contentBounds->setLTRB(left, top, right, bottom);
+ contentBounds->setLTRB(left, top, right, bottom);
}
void CornerPinEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- upperLeft->excludeVaryingRanges(timeRanges);
- upperRight->excludeVaryingRanges(timeRanges);
- lowerLeft->excludeVaryingRanges(timeRanges);
- lowerRight->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ upperLeft->excludeVaryingRanges(timeRanges);
+ upperRight->excludeVaryingRanges(timeRanges);
+ lowerLeft->excludeVaryingRanges(timeRanges);
+ lowerRight->excludeVaryingRanges(timeRanges);
}
bool CornerPinEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(upperLeft != nullptr && upperRight != nullptr && lowerLeft != nullptr &&
- lowerRight != nullptr);
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(upperLeft != nullptr && upperRight != nullptr && lowerLeft != nullptr &&
+ lowerRight != nullptr);
}
} // namespace pag
diff --git a/src/base/effects/DisplacementMapEffect.cpp b/src/base/effects/DisplacementMapEffect.cpp
index 44a8640d79..c24408495a 100644
--- a/src/base/effects/DisplacementMapEffect.cpp
+++ b/src/base/effects/DisplacementMapEffect.cpp
@@ -21,58 +21,58 @@
namespace pag {
DisplacementMapEffect::~DisplacementMapEffect() {
- delete useForHorizontalDisplacement;
- delete maxHorizontalDisplacement;
- delete useForVerticalDisplacement;
- delete maxVerticalDisplacement;
- delete displacementMapBehavior;
- delete edgeBehavior;
- delete expandOutput;
+ delete useForHorizontalDisplacement;
+ delete maxHorizontalDisplacement;
+ delete useForVerticalDisplacement;
+ delete maxVerticalDisplacement;
+ delete displacementMapBehavior;
+ delete edgeBehavior;
+ delete expandOutput;
}
bool DisplacementMapEffect::visibleAt(Frame layerFrame) const {
- if (displacementMapLayer == nullptr) {
- return false;
- }
- // DisplacementMap特效只支持视频序列帧或者图片序列帧。
- if (displacementMapLayer->type() == LayerType::PreCompose) {
- auto preComposeLayer = static_cast(displacementMapLayer);
- auto composition = preComposeLayer->composition;
- if (composition->type() == CompositionType::Video ||
- composition->type() == CompositionType::Bitmap) {
- auto mapContentFrame = layerFrame - displacementMapLayer->startTime;
- if (mapContentFrame < 0 || mapContentFrame >= displacementMapLayer->duration) {
+ if (displacementMapLayer == nullptr) {
return false;
- }
- return maxHorizontalDisplacement->getValueAt(layerFrame) != 0 ||
- maxVerticalDisplacement->getValueAt(layerFrame) != 0;
}
- }
- return false;
+ // DisplacementMap特效只支持视频序列帧或者图片序列帧。
+ if (displacementMapLayer->type() == LayerType::PreCompose) {
+ auto preComposeLayer = static_cast(displacementMapLayer);
+ auto composition = preComposeLayer->composition;
+ if (composition->type() == CompositionType::Video ||
+ composition->type() == CompositionType::Bitmap) {
+ auto mapContentFrame = layerFrame - displacementMapLayer->startTime;
+ if (mapContentFrame < 0 || mapContentFrame >= displacementMapLayer->duration) {
+ return false;
+ }
+ return maxHorizontalDisplacement->getValueAt(layerFrame) != 0 ||
+ maxVerticalDisplacement->getValueAt(layerFrame) != 0;
+ }
+ }
+ return false;
}
void DisplacementMapEffect::transformBounds(Rect*, const Point&, Frame) const {
}
void DisplacementMapEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- useForHorizontalDisplacement->excludeVaryingRanges(timeRanges);
- maxHorizontalDisplacement->excludeVaryingRanges(timeRanges);
- useForVerticalDisplacement->excludeVaryingRanges(timeRanges);
- maxVerticalDisplacement->excludeVaryingRanges(timeRanges);
- displacementMapBehavior->excludeVaryingRanges(timeRanges);
- edgeBehavior->excludeVaryingRanges(timeRanges);
- expandOutput->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ useForHorizontalDisplacement->excludeVaryingRanges(timeRanges);
+ maxHorizontalDisplacement->excludeVaryingRanges(timeRanges);
+ useForVerticalDisplacement->excludeVaryingRanges(timeRanges);
+ maxVerticalDisplacement->excludeVaryingRanges(timeRanges);
+ displacementMapBehavior->excludeVaryingRanges(timeRanges);
+ edgeBehavior->excludeVaryingRanges(timeRanges);
+ expandOutput->excludeVaryingRanges(timeRanges);
}
bool DisplacementMapEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(useForHorizontalDisplacement != nullptr && maxHorizontalDisplacement != nullptr &&
- useForVerticalDisplacement != nullptr && maxVerticalDisplacement != nullptr &&
- displacementMapBehavior != nullptr && edgeBehavior != nullptr &&
- expandOutput != nullptr);
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(useForHorizontalDisplacement != nullptr && maxHorizontalDisplacement != nullptr &&
+ useForVerticalDisplacement != nullptr && maxVerticalDisplacement != nullptr &&
+ displacementMapBehavior != nullptr && edgeBehavior != nullptr &&
+ expandOutput != nullptr);
}
} // namespace pag
diff --git a/src/base/effects/Effect.cpp b/src/base/effects/Effect.cpp
index 7f715a90a2..415d090ee2 100644
--- a/src/base/effects/Effect.cpp
+++ b/src/base/effects/Effect.cpp
@@ -25,22 +25,22 @@ Effect::Effect() : uniqueID(UniqueID::Next()) {
}
Effect::~Effect() {
- delete effectOpacity;
+ delete effectOpacity;
}
void Effect::excludeVaryingRanges(std::vector* timeRanges) const {
- if (effectOpacity != nullptr) {
- effectOpacity->excludeVaryingRanges(timeRanges);
- }
+ if (effectOpacity != nullptr) {
+ effectOpacity->excludeVaryingRanges(timeRanges);
+ }
}
bool Effect::verify() const {
- for (auto mask : maskReferences) {
- if (mask == nullptr) {
- VerifyFailed();
- return false;
+ for (auto mask : maskReferences) {
+ if (mask == nullptr) {
+ VerifyFailed();
+ return false;
+ }
}
- }
- return true;
+ return true;
}
} // namespace pag
diff --git a/src/base/effects/FastBlurEffect.cpp b/src/base/effects/FastBlurEffect.cpp
index 77cfc46e11..c0bfaf9d24 100644
--- a/src/base/effects/FastBlurEffect.cpp
+++ b/src/base/effects/FastBlurEffect.cpp
@@ -21,49 +21,49 @@
namespace pag {
FastBlurEffect::~FastBlurEffect() {
- delete blurriness;
- delete blurDimensions;
- delete repeatEdgePixels;
+ delete blurriness;
+ delete blurDimensions;
+ delete repeatEdgePixels;
}
bool FastBlurEffect::visibleAt(Frame layerFrame) const {
- return blurriness->getValueAt(layerFrame) != 0;
+ return blurriness->getValueAt(layerFrame) != 0;
}
void FastBlurEffect::transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const {
- auto repeatEdge = repeatEdgePixels->getValueAt(layerFrame);
- if (repeatEdge) {
- return;
- }
- auto direction = blurDimensions->getValueAt(layerFrame);
- auto intensity = blurriness->getValueAt(layerFrame);
- auto blurrinessX = intensity * filterScale.x;
- auto blurrinessY = intensity * filterScale.y;
- auto expandX = (direction == BlurDimensionsDirection::All ||
- direction == BlurDimensionsDirection::Horizontal)
- ? blurrinessX
- : 0.0;
- auto expandY =
- (direction == BlurDimensionsDirection::All || direction == BlurDimensionsDirection::Vertical)
- ? blurrinessY
- : 0.0;
- contentBounds->outset(expandX, expandY);
+ auto repeatEdge = repeatEdgePixels->getValueAt(layerFrame);
+ if (repeatEdge) {
+ return;
+ }
+ auto direction = blurDimensions->getValueAt(layerFrame);
+ auto intensity = blurriness->getValueAt(layerFrame);
+ auto blurrinessX = intensity * filterScale.x;
+ auto blurrinessY = intensity * filterScale.y;
+ auto expandX = (direction == BlurDimensionsDirection::All ||
+ direction == BlurDimensionsDirection::Horizontal)
+ ? blurrinessX
+ : 0.0;
+ auto expandY =
+ (direction == BlurDimensionsDirection::All || direction == BlurDimensionsDirection::Vertical)
+ ? blurrinessY
+ : 0.0;
+ contentBounds->outset(expandX, expandY);
}
void FastBlurEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- blurriness->excludeVaryingRanges(timeRanges);
- blurDimensions->excludeVaryingRanges(timeRanges);
- repeatEdgePixels->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ blurriness->excludeVaryingRanges(timeRanges);
+ blurDimensions->excludeVaryingRanges(timeRanges);
+ repeatEdgePixels->excludeVaryingRanges(timeRanges);
}
bool FastBlurEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(blurriness != nullptr && blurDimensions != nullptr &&
- repeatEdgePixels != nullptr);
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(blurriness != nullptr && blurDimensions != nullptr &&
+ repeatEdgePixels != nullptr);
}
} // namespace pag
diff --git a/src/base/effects/GlowEffect.cpp b/src/base/effects/GlowEffect.cpp
index 10450eb511..a35c9960bc 100644
--- a/src/base/effects/GlowEffect.cpp
+++ b/src/base/effects/GlowEffect.cpp
@@ -21,31 +21,31 @@
namespace pag {
GlowEffect::~GlowEffect() {
- delete glowThreshold;
- delete glowRadius;
- delete glowIntensity;
+ delete glowThreshold;
+ delete glowRadius;
+ delete glowIntensity;
}
bool GlowEffect::visibleAt(Frame layerFrame) const {
- auto threshold = glowThreshold->getValueAt(layerFrame);
- return threshold < 1.0f;
+ auto threshold = glowThreshold->getValueAt(layerFrame);
+ return threshold < 1.0f;
}
void GlowEffect::transformBounds(Rect*, const Point&, Frame) const {
}
void GlowEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- glowThreshold->excludeVaryingRanges(timeRanges);
- glowRadius->excludeVaryingRanges(timeRanges);
- glowIntensity->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ glowThreshold->excludeVaryingRanges(timeRanges);
+ glowRadius->excludeVaryingRanges(timeRanges);
+ glowIntensity->excludeVaryingRanges(timeRanges);
}
bool GlowEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(glowThreshold != nullptr && glowRadius != nullptr && glowIntensity != nullptr);
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(glowThreshold != nullptr && glowRadius != nullptr && glowIntensity != nullptr);
}
} // namespace pag
diff --git a/src/base/effects/LevelsIndividualEffect.cpp b/src/base/effects/LevelsIndividualEffect.cpp
index db2bda616f..f0b8586c8d 100644
--- a/src/base/effects/LevelsIndividualEffect.cpp
+++ b/src/base/effects/LevelsIndividualEffect.cpp
@@ -21,82 +21,82 @@
namespace pag {
LevelsIndividualEffect::~LevelsIndividualEffect() {
- // RGB
- delete inputBlack;
- delete inputWhite;
- delete gamma;
- delete outputBlack;
- delete outputWhite;
- // Red
- delete redInputBlack;
- delete redInputWhite;
- delete redGamma;
- delete redOutputBlack;
- delete redOutputWhite;
- // Green
- delete greenInputBlack;
- delete greenInputWhite;
- delete greenGamma;
- delete greenOutputBlack;
- delete greenOutputWhite;
- // Blue
- delete blueInputBlack;
- delete blueInputWhite;
- delete blueGamma;
- delete blueOutputBlack;
- delete blueOutputWhite;
+ // RGB
+ delete inputBlack;
+ delete inputWhite;
+ delete gamma;
+ delete outputBlack;
+ delete outputWhite;
+ // Red
+ delete redInputBlack;
+ delete redInputWhite;
+ delete redGamma;
+ delete redOutputBlack;
+ delete redOutputWhite;
+ // Green
+ delete greenInputBlack;
+ delete greenInputWhite;
+ delete greenGamma;
+ delete greenOutputBlack;
+ delete greenOutputWhite;
+ // Blue
+ delete blueInputBlack;
+ delete blueInputWhite;
+ delete blueGamma;
+ delete blueOutputBlack;
+ delete blueOutputWhite;
}
bool LevelsIndividualEffect::visibleAt(Frame) const {
- return true;
+ return true;
}
void LevelsIndividualEffect::transformBounds(Rect*, const Point&, Frame) const {
}
void LevelsIndividualEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- // RGB
- inputBlack->excludeVaryingRanges(timeRanges);
- inputWhite->excludeVaryingRanges(timeRanges);
- gamma->excludeVaryingRanges(timeRanges);
- outputBlack->excludeVaryingRanges(timeRanges);
- outputWhite->excludeVaryingRanges(timeRanges);
- // Red
- redInputBlack->excludeVaryingRanges(timeRanges);
- redInputWhite->excludeVaryingRanges(timeRanges);
- redGamma->excludeVaryingRanges(timeRanges);
- redOutputBlack->excludeVaryingRanges(timeRanges);
- redOutputWhite->excludeVaryingRanges(timeRanges);
- // Green
- greenInputBlack->excludeVaryingRanges(timeRanges);
- greenInputWhite->excludeVaryingRanges(timeRanges);
- greenGamma->excludeVaryingRanges(timeRanges);
- greenOutputBlack->excludeVaryingRanges(timeRanges);
- greenOutputWhite->excludeVaryingRanges(timeRanges);
- // Blue
- blueInputBlack->excludeVaryingRanges(timeRanges);
- blueInputWhite->excludeVaryingRanges(timeRanges);
- blueGamma->excludeVaryingRanges(timeRanges);
- blueOutputBlack->excludeVaryingRanges(timeRanges);
- blueOutputWhite->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ // RGB
+ inputBlack->excludeVaryingRanges(timeRanges);
+ inputWhite->excludeVaryingRanges(timeRanges);
+ gamma->excludeVaryingRanges(timeRanges);
+ outputBlack->excludeVaryingRanges(timeRanges);
+ outputWhite->excludeVaryingRanges(timeRanges);
+ // Red
+ redInputBlack->excludeVaryingRanges(timeRanges);
+ redInputWhite->excludeVaryingRanges(timeRanges);
+ redGamma->excludeVaryingRanges(timeRanges);
+ redOutputBlack->excludeVaryingRanges(timeRanges);
+ redOutputWhite->excludeVaryingRanges(timeRanges);
+ // Green
+ greenInputBlack->excludeVaryingRanges(timeRanges);
+ greenInputWhite->excludeVaryingRanges(timeRanges);
+ greenGamma->excludeVaryingRanges(timeRanges);
+ greenOutputBlack->excludeVaryingRanges(timeRanges);
+ greenOutputWhite->excludeVaryingRanges(timeRanges);
+ // Blue
+ blueInputBlack->excludeVaryingRanges(timeRanges);
+ blueInputWhite->excludeVaryingRanges(timeRanges);
+ blueGamma->excludeVaryingRanges(timeRanges);
+ blueOutputBlack->excludeVaryingRanges(timeRanges);
+ blueOutputWhite->excludeVaryingRanges(timeRanges);
}
static bool calculate5and(bool a, bool b, bool c, bool d, bool e) {
- return a && b && c && d && e;
+ return a && b && c && d && e;
}
bool LevelsIndividualEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- auto rgb = calculate5and(inputBlack, inputWhite, gamma, outputBlack, outputWhite);
- auto red = calculate5and(redInputBlack, redInputWhite, redGamma, redOutputBlack, redOutputWhite);
- auto green = calculate5and(greenInputBlack, greenInputWhite, greenGamma, greenOutputBlack,
- greenOutputWhite);
- auto blue =
- calculate5and(blueInputBlack, blueInputWhite, blueGamma, blueOutputBlack, blueOutputWhite);
- VerifyAndReturn(calculate5and(rgb, red, green, blue, 1));
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ auto rgb = calculate5and(inputBlack, inputWhite, gamma, outputBlack, outputWhite);
+ auto red = calculate5and(redInputBlack, redInputWhite, redGamma, redOutputBlack, redOutputWhite);
+ auto green = calculate5and(greenInputBlack, greenInputWhite, greenGamma, greenOutputBlack,
+ greenOutputWhite);
+ auto blue =
+ calculate5and(blueInputBlack, blueInputWhite, blueGamma, blueOutputBlack, blueOutputWhite);
+ VerifyAndReturn(calculate5and(rgb, red, green, blue, 1));
}
} // namespace pag
diff --git a/src/base/effects/MosaicEffect.cpp b/src/base/effects/MosaicEffect.cpp
index 233100aa2e..7abf4481c4 100644
--- a/src/base/effects/MosaicEffect.cpp
+++ b/src/base/effects/MosaicEffect.cpp
@@ -21,31 +21,31 @@
namespace pag {
MosaicEffect::~MosaicEffect() {
- delete horizontalBlocks;
- delete verticalBlocks;
- delete sharpColors;
+ delete horizontalBlocks;
+ delete verticalBlocks;
+ delete sharpColors;
}
bool MosaicEffect::visibleAt(Frame) const {
- return true;
+ return true;
}
void MosaicEffect::transformBounds(Rect*, const Point&, Frame) const {
}
void MosaicEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- horizontalBlocks->excludeVaryingRanges(timeRanges);
- verticalBlocks->excludeVaryingRanges(timeRanges);
- sharpColors->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ horizontalBlocks->excludeVaryingRanges(timeRanges);
+ verticalBlocks->excludeVaryingRanges(timeRanges);
+ sharpColors->excludeVaryingRanges(timeRanges);
}
bool MosaicEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(horizontalBlocks != nullptr && verticalBlocks != nullptr &&
- sharpColors != nullptr);
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(horizontalBlocks != nullptr && verticalBlocks != nullptr &&
+ sharpColors != nullptr);
}
} // namespace pag
diff --git a/src/base/effects/MotionTileEffect.cpp b/src/base/effects/MotionTileEffect.cpp
index 862e1cc61b..d56d8edbdd 100644
--- a/src/base/effects/MotionTileEffect.cpp
+++ b/src/base/effects/MotionTileEffect.cpp
@@ -22,49 +22,49 @@
namespace pag {
MotionTileEffect::~MotionTileEffect() {
- delete tileCenter;
- delete tileWidth;
- delete tileHeight;
- delete outputWidth;
- delete outputHeight;
- delete mirrorEdges;
- delete phase;
- delete horizontalPhaseShift;
+ delete tileCenter;
+ delete tileWidth;
+ delete tileHeight;
+ delete outputWidth;
+ delete outputHeight;
+ delete mirrorEdges;
+ delete phase;
+ delete horizontalPhaseShift;
}
bool MotionTileEffect::visibleAt(Frame) const {
- return true;
+ return true;
}
void MotionTileEffect::transformBounds(Rect* contentBounds, const Point&, Frame layerFrame) const {
- auto outputWidthValue = outputWidth->getValueAt(layerFrame);
- auto outputHeightValue = outputHeight->getValueAt(layerFrame);
- auto width = contentBounds->width() * outputWidthValue / 100.0f;
- auto height = contentBounds->height() * outputHeightValue / 100.0f;
- auto x = contentBounds->x() + (contentBounds->width() - width) * 0.5f;
- auto y = contentBounds->y() + (contentBounds->height() - height) * 0.5f;
- contentBounds->setXYWH(x, y, width, height);
+ auto outputWidthValue = outputWidth->getValueAt(layerFrame);
+ auto outputHeightValue = outputHeight->getValueAt(layerFrame);
+ auto width = contentBounds->width() * outputWidthValue / 100.0f;
+ auto height = contentBounds->height() * outputHeightValue / 100.0f;
+ auto x = contentBounds->x() + (contentBounds->width() - width) * 0.5f;
+ auto y = contentBounds->y() + (contentBounds->height() - height) * 0.5f;
+ contentBounds->setXYWH(x, y, width, height);
}
void MotionTileEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- tileCenter->excludeVaryingRanges(timeRanges);
- tileWidth->excludeVaryingRanges(timeRanges);
- tileHeight->excludeVaryingRanges(timeRanges);
- outputWidth->excludeVaryingRanges(timeRanges);
- outputHeight->excludeVaryingRanges(timeRanges);
- mirrorEdges->excludeVaryingRanges(timeRanges);
- phase->excludeVaryingRanges(timeRanges);
- horizontalPhaseShift->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ tileCenter->excludeVaryingRanges(timeRanges);
+ tileWidth->excludeVaryingRanges(timeRanges);
+ tileHeight->excludeVaryingRanges(timeRanges);
+ outputWidth->excludeVaryingRanges(timeRanges);
+ outputHeight->excludeVaryingRanges(timeRanges);
+ mirrorEdges->excludeVaryingRanges(timeRanges);
+ phase->excludeVaryingRanges(timeRanges);
+ horizontalPhaseShift->excludeVaryingRanges(timeRanges);
}
bool MotionTileEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(tileCenter != nullptr && tileWidth != nullptr && tileHeight != nullptr &&
- outputWidth != nullptr && outputHeight != nullptr && mirrorEdges != nullptr &&
- phase != nullptr && horizontalPhaseShift != nullptr);
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(tileCenter != nullptr && tileWidth != nullptr && tileHeight != nullptr &&
+ outputWidth != nullptr && outputHeight != nullptr && mirrorEdges != nullptr &&
+ phase != nullptr && horizontalPhaseShift != nullptr);
}
} // namespace pag
diff --git a/src/base/effects/RadialBlurEffect.cpp b/src/base/effects/RadialBlurEffect.cpp
index f6e456e772..8ce11de425 100644
--- a/src/base/effects/RadialBlurEffect.cpp
+++ b/src/base/effects/RadialBlurEffect.cpp
@@ -21,34 +21,34 @@
namespace pag {
RadialBlurEffect::~RadialBlurEffect() {
- delete amount;
- delete center;
- delete mode;
- delete antialias;
+ delete amount;
+ delete center;
+ delete mode;
+ delete antialias;
}
bool RadialBlurEffect::visibleAt(Frame layerFrame) const {
- auto amountValue = amount->getValueAt(layerFrame);
- return amountValue != 0;
+ auto amountValue = amount->getValueAt(layerFrame);
+ return amountValue != 0;
}
void RadialBlurEffect::transformBounds(Rect*, const Point&, Frame) const {
}
void RadialBlurEffect::excludeVaryingRanges(std::vector* timeRanges) const {
- Effect::excludeVaryingRanges(timeRanges);
- amount->excludeVaryingRanges(timeRanges);
- center->excludeVaryingRanges(timeRanges);
- mode->excludeVaryingRanges(timeRanges);
- antialias->excludeVaryingRanges(timeRanges);
+ Effect::excludeVaryingRanges(timeRanges);
+ amount->excludeVaryingRanges(timeRanges);
+ center->excludeVaryingRanges(timeRanges);
+ mode->excludeVaryingRanges(timeRanges);
+ antialias->excludeVaryingRanges(timeRanges);
}
bool RadialBlurEffect::verify() const {
- if (!Effect::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(amount != nullptr && center != nullptr && mode != nullptr &&
- antialias != nullptr);
+ if (!Effect::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(amount != nullptr && center != nullptr && mode != nullptr &&
+ antialias != nullptr);
}
} // namespace pag
diff --git a/src/base/keyframes/MultiDimensionPointKeyframe.cpp b/src/base/keyframes/MultiDimensionPointKeyframe.cpp
index 6420858409..f579c723a9 100644
--- a/src/base/keyframes/MultiDimensionPointKeyframe.cpp
+++ b/src/base/keyframes/MultiDimensionPointKeyframe.cpp
@@ -20,27 +20,27 @@
namespace pag {
MultiDimensionPointKeyframe::~MultiDimensionPointKeyframe() {
- delete xInterpolator;
- delete yInterpolator;
+ delete xInterpolator;
+ delete yInterpolator;
}
void MultiDimensionPointKeyframe::initialize() {
- if (interpolationType == KeyframeInterpolationType::Bezier) {
- xInterpolator = new BezierEasing(this->bezierOut[0], this->bezierIn[0]);
- yInterpolator = new BezierEasing(this->bezierOut[1], this->bezierIn[1]);
- } else {
- xInterpolator = new Interpolator();
- yInterpolator = new Interpolator();
- }
+ if (interpolationType == KeyframeInterpolationType::Bezier) {
+ xInterpolator = new BezierEasing(this->bezierOut[0], this->bezierIn[0]);
+ yInterpolator = new BezierEasing(this->bezierOut[1], this->bezierIn[1]);
+ } else {
+ xInterpolator = new Interpolator();
+ yInterpolator = new Interpolator();
+ }
}
Point MultiDimensionPointKeyframe::getValueAt(Frame time) {
- auto progress = static_cast(time - this->startTime) / (this->endTime - this->startTime);
- auto xProgress = xInterpolator->getInterpolation(progress);
- auto yProgress = yInterpolator->getInterpolation(progress);
- auto x = Interpolate(this->startValue.x, this->endValue.x, xProgress);
- auto y = Interpolate(this->startValue.y, this->endValue.y, yProgress);
- return {x, y};
+ auto progress = static_cast(time - this->startTime) / (this->endTime - this->startTime);
+ auto xProgress = xInterpolator->getInterpolation(progress);
+ auto yProgress = yInterpolator->getInterpolation(progress);
+ auto x = Interpolate(this->startValue.x, this->endValue.x, xProgress);
+ auto y = Interpolate(this->startValue.y, this->endValue.y, yProgress);
+ return {x, y};
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/keyframes/MultiDimensionPointKeyframe.h b/src/base/keyframes/MultiDimensionPointKeyframe.h
index d9a0c23cc4..fcf4011aa5 100644
--- a/src/base/keyframes/MultiDimensionPointKeyframe.h
+++ b/src/base/keyframes/MultiDimensionPointKeyframe.h
@@ -23,15 +23,15 @@
namespace pag {
class MultiDimensionPointKeyframe : public Keyframe {
- public:
- ~MultiDimensionPointKeyframe() override;
+public:
+ ~MultiDimensionPointKeyframe() override;
- void initialize() override;
+ void initialize() override;
- Point getValueAt(Frame time) override;
+ Point getValueAt(Frame time) override;
- private:
- Interpolator* xInterpolator = nullptr;
- Interpolator* yInterpolator = nullptr;
+private:
+ Interpolator* xInterpolator = nullptr;
+ Interpolator* yInterpolator = nullptr;
};
} // namespace pag
diff --git a/src/base/keyframes/SingleEaseKeyframe.h b/src/base/keyframes/SingleEaseKeyframe.h
index b83713fbb9..743ad85315 100644
--- a/src/base/keyframes/SingleEaseKeyframe.h
+++ b/src/base/keyframes/SingleEaseKeyframe.h
@@ -24,30 +24,30 @@
namespace pag {
template
class SingleEaseKeyframe : public Keyframe {
- public:
- ~SingleEaseKeyframe() override {
- delete interpolator;
- }
+public:
+ ~SingleEaseKeyframe() override {
+ delete interpolator;
+ }
- void initialize() override {
- if (this->interpolationType == KeyframeInterpolationType::Bezier) {
- interpolator = new BezierEasing(this->bezierOut[0], this->bezierIn[0]);
- } else {
- interpolator = new Interpolator();
+ void initialize() override {
+ if (this->interpolationType == KeyframeInterpolationType::Bezier) {
+ interpolator = new BezierEasing(this->bezierOut[0], this->bezierIn[0]);
+ } else {
+ interpolator = new Interpolator();
+ }
}
- }
- float getProgress(Frame time) {
- auto progress = static_cast(time - this->startTime) / (this->endTime - this->startTime);
- return interpolator->getInterpolation(progress);
- }
+ float getProgress(Frame time) {
+ auto progress = static_cast(time - this->startTime) / (this->endTime - this->startTime);
+ return interpolator->getInterpolation(progress);
+ }
- T getValueAt(Frame time) override {
- auto progress = getProgress(time);
- return Interpolate(this->startValue, this->endValue, progress);
- }
+ T getValueAt(Frame time) override {
+ auto progress = getProgress(time);
+ return Interpolate(this->startValue, this->endValue, progress);
+ }
- private:
- Interpolator* interpolator = nullptr;
+private:
+ Interpolator* interpolator = nullptr;
};
} // namespace pag
diff --git a/src/base/keyframes/SpatialPointKeyframe.cpp b/src/base/keyframes/SpatialPointKeyframe.cpp
index 4da0e974f2..4c141a0bf9 100644
--- a/src/base/keyframes/SpatialPointKeyframe.cpp
+++ b/src/base/keyframes/SpatialPointKeyframe.cpp
@@ -20,13 +20,13 @@
namespace pag {
void SpatialPointKeyframe::initialize() {
- SingleEaseKeyframe::initialize();
- spatialBezier =
- BezierPath::Build(startValue, startValue + spatialOut, endValue + spatialIn, endValue, 0.05f);
+ SingleEaseKeyframe::initialize();
+ spatialBezier =
+ BezierPath::Build(startValue, startValue + spatialOut, endValue + spatialIn, endValue, 0.05f);
}
Point SpatialPointKeyframe::getValueAt(Frame time) {
- auto progress = getProgress(time);
- return spatialBezier->getPosition(progress);
+ auto progress = getProgress(time);
+ return spatialBezier->getPosition(progress);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/keyframes/SpatialPointKeyframe.h b/src/base/keyframes/SpatialPointKeyframe.h
index 29af47af8f..fe4cde7d5b 100644
--- a/src/base/keyframes/SpatialPointKeyframe.h
+++ b/src/base/keyframes/SpatialPointKeyframe.h
@@ -22,11 +22,11 @@
namespace pag {
class SpatialPointKeyframe : public SingleEaseKeyframe {
- public:
- void initialize() override;
- Point getValueAt(Frame time) override;
+public:
+ void initialize() override;
+ Point getValueAt(Frame time) override;
- private:
- std::shared_ptr spatialBezier = nullptr;
+private:
+ std::shared_ptr spatialBezier = nullptr;
};
} // namespace pag
diff --git a/src/base/layerStyles/DropShadowStyle.cpp b/src/base/layerStyles/DropShadowStyle.cpp
index 6a87f8bade..1d11d0aab3 100644
--- a/src/base/layerStyles/DropShadowStyle.cpp
+++ b/src/base/layerStyles/DropShadowStyle.cpp
@@ -22,49 +22,49 @@
namespace pag {
DropShadowStyle::~DropShadowStyle() {
- delete blendMode;
- delete color;
- delete opacity;
- delete angle;
- delete distance;
- delete size;
- delete spread;
+ delete blendMode;
+ delete color;
+ delete opacity;
+ delete angle;
+ delete distance;
+ delete size;
+ delete spread;
}
bool DropShadowStyle::visibleAt(Frame layerFrame) const {
- auto distanceValue = distance->getValueAt(layerFrame);
- auto sizeValue = size->getValueAt(layerFrame);
- return distanceValue > 0 || sizeValue > 0;
+ auto distanceValue = distance->getValueAt(layerFrame);
+ auto sizeValue = size->getValueAt(layerFrame);
+ return distanceValue > 0 || sizeValue > 0;
}
void DropShadowStyle::transformBounds(Rect* contentBounds, const Point& filterScale,
Frame layerFrame) const {
- auto angleValue = angle->getValueAt(layerFrame);
- auto distanceValue = distance->getValueAt(layerFrame);
- auto sizeValue = size->getValueAt(layerFrame);
- auto radians = DegreesToRadians(angleValue - 180);
- float offsetX = cosf(radians) * distanceValue;
- float offsetY = -sinf(radians) * distanceValue;
- contentBounds->offset(offsetX * filterScale.x, offsetY * filterScale.y);
- contentBounds->outset(sizeValue * filterScale.x, sizeValue * filterScale.y);
+ auto angleValue = angle->getValueAt(layerFrame);
+ auto distanceValue = distance->getValueAt(layerFrame);
+ auto sizeValue = size->getValueAt(layerFrame);
+ auto radians = DegreesToRadians(angleValue - 180);
+ float offsetX = cosf(radians) * distanceValue;
+ float offsetY = -sinf(radians) * distanceValue;
+ contentBounds->offset(offsetX * filterScale.x, offsetY * filterScale.y);
+ contentBounds->outset(sizeValue * filterScale.x, sizeValue * filterScale.y);
}
void DropShadowStyle::excludeVaryingRanges(std::vector* timeRanges) const {
- blendMode->excludeVaryingRanges(timeRanges);
- color->excludeVaryingRanges(timeRanges);
- opacity->excludeVaryingRanges(timeRanges);
- angle->excludeVaryingRanges(timeRanges);
- distance->excludeVaryingRanges(timeRanges);
- size->excludeVaryingRanges(timeRanges);
- spread->excludeVaryingRanges(timeRanges);
+ blendMode->excludeVaryingRanges(timeRanges);
+ color->excludeVaryingRanges(timeRanges);
+ opacity->excludeVaryingRanges(timeRanges);
+ angle->excludeVaryingRanges(timeRanges);
+ distance->excludeVaryingRanges(timeRanges);
+ size->excludeVaryingRanges(timeRanges);
+ spread->excludeVaryingRanges(timeRanges);
}
bool DropShadowStyle::verify() const {
- if (!LayerStyle::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(blendMode != nullptr && color != nullptr && opacity != nullptr &&
- angle != nullptr && distance != nullptr && size != nullptr && spread != nullptr);
+ if (!LayerStyle::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(blendMode != nullptr && color != nullptr && opacity != nullptr &&
+ angle != nullptr && distance != nullptr && size != nullptr && spread != nullptr);
}
} // namespace pag
diff --git a/src/base/layerStyles/StrokeStyle.cpp b/src/base/layerStyles/StrokeStyle.cpp
index 61f45271d6..55904a06e5 100644
--- a/src/base/layerStyles/StrokeStyle.cpp
+++ b/src/base/layerStyles/StrokeStyle.cpp
@@ -21,34 +21,34 @@
namespace pag {
StrokeStyle::~StrokeStyle() {
- delete blendMode;
- delete color;
- delete size;
- delete opacity;
- delete position;
+ delete blendMode;
+ delete color;
+ delete size;
+ delete opacity;
+ delete position;
}
bool StrokeStyle::visibleAt(Frame) const {
- return false;
+ return false;
}
void StrokeStyle::transformBounds(Rect*, const Point&, Frame) const {
}
void StrokeStyle::excludeVaryingRanges(std::vector* timeRanges) const {
- blendMode->excludeVaryingRanges(timeRanges);
- color->excludeVaryingRanges(timeRanges);
- size->excludeVaryingRanges(timeRanges);
- opacity->excludeVaryingRanges(timeRanges);
- position->excludeVaryingRanges(timeRanges);
+ blendMode->excludeVaryingRanges(timeRanges);
+ color->excludeVaryingRanges(timeRanges);
+ size->excludeVaryingRanges(timeRanges);
+ opacity->excludeVaryingRanges(timeRanges);
+ position->excludeVaryingRanges(timeRanges);
}
bool StrokeStyle::verify() const {
- if (!LayerStyle::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(blendMode != nullptr && color != nullptr && size != nullptr &&
- opacity != nullptr && position != nullptr);
+ if (!LayerStyle::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(blendMode != nullptr && color != nullptr && size != nullptr &&
+ opacity != nullptr && position != nullptr);
}
} // namespace pag
diff --git a/src/base/shapes/EllipseElement.cpp b/src/base/shapes/EllipseElement.cpp
index c943404d4b..50a87a5288 100644
--- a/src/base/shapes/EllipseElement.cpp
+++ b/src/base/shapes/EllipseElement.cpp
@@ -21,20 +21,20 @@
namespace pag {
EllipseElement::~EllipseElement() {
- delete size;
- delete position;
+ delete size;
+ delete position;
}
void EllipseElement::excludeVaryingRanges(std::vector* timeRanges) const {
- position->excludeVaryingRanges(timeRanges);
- size->excludeVaryingRanges(timeRanges);
+ position->excludeVaryingRanges(timeRanges);
+ size->excludeVaryingRanges(timeRanges);
}
bool EllipseElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(position != nullptr && size != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(position != nullptr && size != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/FillElement.cpp b/src/base/shapes/FillElement.cpp
index d87fbe1697..e8fa081736 100644
--- a/src/base/shapes/FillElement.cpp
+++ b/src/base/shapes/FillElement.cpp
@@ -21,20 +21,20 @@
namespace pag {
FillElement::~FillElement() {
- delete color;
- delete opacity;
+ delete color;
+ delete opacity;
}
void FillElement::excludeVaryingRanges(std::vector* timeRanges) const {
- color->excludeVaryingRanges(timeRanges);
- opacity->excludeVaryingRanges(timeRanges);
+ color->excludeVaryingRanges(timeRanges);
+ opacity->excludeVaryingRanges(timeRanges);
}
bool FillElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(color != nullptr && opacity != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(color != nullptr && opacity != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/GradientFillElement.cpp b/src/base/shapes/GradientFillElement.cpp
index dcd51df1f4..7d73b4c8c1 100644
--- a/src/base/shapes/GradientFillElement.cpp
+++ b/src/base/shapes/GradientFillElement.cpp
@@ -21,25 +21,25 @@
namespace pag {
GradientFillElement::~GradientFillElement() {
- delete startPoint;
- delete endPoint;
- delete colors;
- delete opacity;
+ delete startPoint;
+ delete endPoint;
+ delete colors;
+ delete opacity;
}
void GradientFillElement::excludeVaryingRanges(std::vector* timeRanges) const {
- startPoint->excludeVaryingRanges(timeRanges);
- endPoint->excludeVaryingRanges(timeRanges);
- colors->excludeVaryingRanges(timeRanges);
- opacity->excludeVaryingRanges(timeRanges);
+ startPoint->excludeVaryingRanges(timeRanges);
+ endPoint->excludeVaryingRanges(timeRanges);
+ colors->excludeVaryingRanges(timeRanges);
+ opacity->excludeVaryingRanges(timeRanges);
}
bool GradientFillElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(startPoint != nullptr && endPoint != nullptr && colors != nullptr &&
- opacity != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(startPoint != nullptr && endPoint != nullptr && colors != nullptr &&
+ opacity != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/GradientStrokeElement.cpp b/src/base/shapes/GradientStrokeElement.cpp
index cdb4f593cc..6b01dd0ee2 100644
--- a/src/base/shapes/GradientStrokeElement.cpp
+++ b/src/base/shapes/GradientStrokeElement.cpp
@@ -21,45 +21,45 @@
namespace pag {
GradientStrokeElement::~GradientStrokeElement() {
- delete miterLimit;
- delete startPoint;
- delete endPoint;
- delete colors;
- delete opacity;
- delete strokeWidth;
- delete dashOffset;
- for (auto& dash : dashes) {
- delete dash;
- }
+ delete miterLimit;
+ delete startPoint;
+ delete endPoint;
+ delete colors;
+ delete opacity;
+ delete strokeWidth;
+ delete dashOffset;
+ for (auto& dash : dashes) {
+ delete dash;
+ }
}
void GradientStrokeElement::excludeVaryingRanges(std::vector* timeRanges) const {
- miterLimit->excludeVaryingRanges(timeRanges);
- startPoint->excludeVaryingRanges(timeRanges);
- endPoint->excludeVaryingRanges(timeRanges);
- colors->excludeVaryingRanges(timeRanges);
- opacity->excludeVaryingRanges(timeRanges);
- strokeWidth->excludeVaryingRanges(timeRanges);
- if (!dashes.empty()) {
- dashOffset->excludeVaryingRanges(timeRanges);
- for (auto& property : dashes) {
- property->excludeVaryingRanges(timeRanges);
+ miterLimit->excludeVaryingRanges(timeRanges);
+ startPoint->excludeVaryingRanges(timeRanges);
+ endPoint->excludeVaryingRanges(timeRanges);
+ colors->excludeVaryingRanges(timeRanges);
+ opacity->excludeVaryingRanges(timeRanges);
+ strokeWidth->excludeVaryingRanges(timeRanges);
+ if (!dashes.empty()) {
+ dashOffset->excludeVaryingRanges(timeRanges);
+ for (auto& property : dashes) {
+ property->excludeVaryingRanges(timeRanges);
+ }
}
- }
}
bool GradientStrokeElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- for (auto dash : dashes) {
- if (dash == nullptr) {
- VerifyFailed();
- return false;
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ for (auto dash : dashes) {
+ if (dash == nullptr) {
+ VerifyFailed();
+ return false;
+ }
}
- }
- VerifyAndReturn(miterLimit != nullptr && startPoint != nullptr && endPoint != nullptr &&
- colors != nullptr && opacity != nullptr && strokeWidth != nullptr);
+ VerifyAndReturn(miterLimit != nullptr && startPoint != nullptr && endPoint != nullptr &&
+ colors != nullptr && opacity != nullptr && strokeWidth != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/PolyStarElement.cpp b/src/base/shapes/PolyStarElement.cpp
index 7bace9602e..b1901ec42c 100644
--- a/src/base/shapes/PolyStarElement.cpp
+++ b/src/base/shapes/PolyStarElement.cpp
@@ -21,32 +21,32 @@
namespace pag {
PolyStarElement::~PolyStarElement() {
- delete points;
- delete position;
- delete rotation;
- delete innerRadius;
- delete outerRadius;
- delete innerRoundness;
- delete outerRoundness;
+ delete points;
+ delete position;
+ delete rotation;
+ delete innerRadius;
+ delete outerRadius;
+ delete innerRoundness;
+ delete outerRoundness;
}
void PolyStarElement::excludeVaryingRanges(std::vector* timeRanges) const {
- points->excludeVaryingRanges(timeRanges);
- position->excludeVaryingRanges(timeRanges);
- rotation->excludeVaryingRanges(timeRanges);
- innerRadius->excludeVaryingRanges(timeRanges);
- outerRadius->excludeVaryingRanges(timeRanges);
- innerRoundness->excludeVaryingRanges(timeRanges);
- outerRoundness->excludeVaryingRanges(timeRanges);
+ points->excludeVaryingRanges(timeRanges);
+ position->excludeVaryingRanges(timeRanges);
+ rotation->excludeVaryingRanges(timeRanges);
+ innerRadius->excludeVaryingRanges(timeRanges);
+ outerRadius->excludeVaryingRanges(timeRanges);
+ innerRoundness->excludeVaryingRanges(timeRanges);
+ outerRoundness->excludeVaryingRanges(timeRanges);
}
bool PolyStarElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(points != nullptr && position != nullptr && rotation != nullptr &&
- innerRadius != nullptr && outerRadius != nullptr && innerRoundness != nullptr &&
- outerRoundness != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(points != nullptr && position != nullptr && rotation != nullptr &&
+ innerRadius != nullptr && outerRadius != nullptr && innerRoundness != nullptr &&
+ outerRoundness != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/RectangleElement.cpp b/src/base/shapes/RectangleElement.cpp
index e9c7ccb7ad..0322041e1c 100644
--- a/src/base/shapes/RectangleElement.cpp
+++ b/src/base/shapes/RectangleElement.cpp
@@ -21,22 +21,22 @@
namespace pag {
RectangleElement::~RectangleElement() {
- delete size;
- delete position;
- delete roundness;
+ delete size;
+ delete position;
+ delete roundness;
}
void RectangleElement::excludeVaryingRanges(std::vector* timeRanges) const {
- position->excludeVaryingRanges(timeRanges);
- size->excludeVaryingRanges(timeRanges);
- roundness->excludeVaryingRanges(timeRanges);
+ position->excludeVaryingRanges(timeRanges);
+ size->excludeVaryingRanges(timeRanges);
+ roundness->excludeVaryingRanges(timeRanges);
}
bool RectangleElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(position != nullptr && size != nullptr && roundness != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(position != nullptr && size != nullptr && roundness != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/RepeaterElement.cpp b/src/base/shapes/RepeaterElement.cpp
index ff40fd0cb7..a4a63ec46a 100644
--- a/src/base/shapes/RepeaterElement.cpp
+++ b/src/base/shapes/RepeaterElement.cpp
@@ -21,22 +21,22 @@
namespace pag {
RepeaterElement::~RepeaterElement() {
- delete copies;
- delete offset;
- delete transform;
+ delete copies;
+ delete offset;
+ delete transform;
}
void RepeaterElement::excludeVaryingRanges(std::vector* timeRanges) const {
- copies->excludeVaryingRanges(timeRanges);
- offset->excludeVaryingRanges(timeRanges);
- transform->excludeVaryingRanges(timeRanges);
+ copies->excludeVaryingRanges(timeRanges);
+ offset->excludeVaryingRanges(timeRanges);
+ transform->excludeVaryingRanges(timeRanges);
}
bool RepeaterElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(copies != nullptr && offset != nullptr && transform != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(copies != nullptr && offset != nullptr && transform != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/RepeaterTransform.cpp b/src/base/shapes/RepeaterTransform.cpp
index 0d5c123d43..0c94170817 100644
--- a/src/base/shapes/RepeaterTransform.cpp
+++ b/src/base/shapes/RepeaterTransform.cpp
@@ -21,25 +21,25 @@
namespace pag {
RepeaterTransform::~RepeaterTransform() {
- delete anchorPoint;
- delete position;
- delete scale;
- delete rotation;
- delete startOpacity;
- delete endOpacity;
+ delete anchorPoint;
+ delete position;
+ delete scale;
+ delete rotation;
+ delete startOpacity;
+ delete endOpacity;
}
void RepeaterTransform::excludeVaryingRanges(std::vector* timeRanges) const {
- anchorPoint->excludeVaryingRanges(timeRanges);
- position->excludeVaryingRanges(timeRanges);
- scale->excludeVaryingRanges(timeRanges);
- rotation->excludeVaryingRanges(timeRanges);
- startOpacity->excludeVaryingRanges(timeRanges);
- endOpacity->excludeVaryingRanges(timeRanges);
+ anchorPoint->excludeVaryingRanges(timeRanges);
+ position->excludeVaryingRanges(timeRanges);
+ scale->excludeVaryingRanges(timeRanges);
+ rotation->excludeVaryingRanges(timeRanges);
+ startOpacity->excludeVaryingRanges(timeRanges);
+ endOpacity->excludeVaryingRanges(timeRanges);
}
bool RepeaterTransform::verify() const {
- VerifyAndReturn(anchorPoint != nullptr && position != nullptr && scale != nullptr &&
- rotation != nullptr && startOpacity != nullptr && endOpacity != nullptr);
+ VerifyAndReturn(anchorPoint != nullptr && position != nullptr && scale != nullptr &&
+ rotation != nullptr && startOpacity != nullptr && endOpacity != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/RoundCornersElement.cpp b/src/base/shapes/RoundCornersElement.cpp
index 83011e4eeb..ead728e5e1 100644
--- a/src/base/shapes/RoundCornersElement.cpp
+++ b/src/base/shapes/RoundCornersElement.cpp
@@ -21,18 +21,18 @@
namespace pag {
RoundCornersElement::~RoundCornersElement() {
- delete radius;
+ delete radius;
}
void RoundCornersElement::excludeVaryingRanges(std::vector* timeRanges) const {
- radius->excludeVaryingRanges(timeRanges);
+ radius->excludeVaryingRanges(timeRanges);
}
bool RoundCornersElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(radius != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(radius != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/ShapeGroupElement.cpp b/src/base/shapes/ShapeGroupElement.cpp
index 27359821bd..6d9277229d 100644
--- a/src/base/shapes/ShapeGroupElement.cpp
+++ b/src/base/shapes/ShapeGroupElement.cpp
@@ -21,34 +21,34 @@
namespace pag {
ShapeGroupElement::~ShapeGroupElement() {
- delete transform;
- for (auto& element : elements) {
- delete element;
- }
+ delete transform;
+ for (auto& element : elements) {
+ delete element;
+ }
}
void ShapeGroupElement::excludeVaryingRanges(std::vector* timeRanges) const {
- transform->excludeVaryingRanges(timeRanges);
- for (auto& element : elements) {
- element->excludeVaryingRanges(timeRanges);
- }
+ transform->excludeVaryingRanges(timeRanges);
+ for (auto& element : elements) {
+ element->excludeVaryingRanges(timeRanges);
+ }
}
bool ShapeGroupElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- if (transform == nullptr || !transform->verify()) {
- VerifyFailed();
- return false;
- }
- for (auto& element : elements) {
- if (element == nullptr || !element->verify()) {
- VerifyFailed();
- return false;
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ if (transform == nullptr || !transform->verify()) {
+ VerifyFailed();
+ return false;
+ }
+ for (auto& element : elements) {
+ if (element == nullptr || !element->verify()) {
+ VerifyFailed();
+ return false;
+ }
}
- }
- return true;
+ return true;
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/ShapePathElement.cpp b/src/base/shapes/ShapePathElement.cpp
index 5c457ae8e0..d32a3763fd 100644
--- a/src/base/shapes/ShapePathElement.cpp
+++ b/src/base/shapes/ShapePathElement.cpp
@@ -21,18 +21,18 @@
namespace pag {
ShapePathElement::~ShapePathElement() {
- delete shapePath;
+ delete shapePath;
}
void ShapePathElement::excludeVaryingRanges(std::vector* timeRanges) const {
- shapePath->excludeVaryingRanges(timeRanges);
+ shapePath->excludeVaryingRanges(timeRanges);
}
bool ShapePathElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(shapePath != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(shapePath != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/ShapeTransform.cpp b/src/base/shapes/ShapeTransform.cpp
index f6e638eaad..7e2db32462 100644
--- a/src/base/shapes/ShapeTransform.cpp
+++ b/src/base/shapes/ShapeTransform.cpp
@@ -21,28 +21,28 @@
namespace pag {
ShapeTransform::~ShapeTransform() {
- delete anchorPoint;
- delete position;
- delete scale;
- delete skew;
- delete skewAxis;
- delete rotation;
- delete opacity;
+ delete anchorPoint;
+ delete position;
+ delete scale;
+ delete skew;
+ delete skewAxis;
+ delete rotation;
+ delete opacity;
}
void ShapeTransform::excludeVaryingRanges(std::vector* timeRanges) const {
- anchorPoint->excludeVaryingRanges(timeRanges);
- position->excludeVaryingRanges(timeRanges);
- scale->excludeVaryingRanges(timeRanges);
- skew->excludeVaryingRanges(timeRanges);
- skewAxis->excludeVaryingRanges(timeRanges);
- rotation->excludeVaryingRanges(timeRanges);
- opacity->excludeVaryingRanges(timeRanges);
+ anchorPoint->excludeVaryingRanges(timeRanges);
+ position->excludeVaryingRanges(timeRanges);
+ scale->excludeVaryingRanges(timeRanges);
+ skew->excludeVaryingRanges(timeRanges);
+ skewAxis->excludeVaryingRanges(timeRanges);
+ rotation->excludeVaryingRanges(timeRanges);
+ opacity->excludeVaryingRanges(timeRanges);
}
bool ShapeTransform::verify() const {
- VerifyAndReturn(anchorPoint != nullptr && position != nullptr && scale != nullptr &&
- skew != nullptr && skewAxis != nullptr && rotation != nullptr &&
- opacity != nullptr);
+ VerifyAndReturn(anchorPoint != nullptr && position != nullptr && scale != nullptr &&
+ skew != nullptr && skewAxis != nullptr && rotation != nullptr &&
+ opacity != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/StrokeElement.cpp b/src/base/shapes/StrokeElement.cpp
index 3a1cdd4884..5b6cdf58e3 100644
--- a/src/base/shapes/StrokeElement.cpp
+++ b/src/base/shapes/StrokeElement.cpp
@@ -21,41 +21,41 @@
namespace pag {
StrokeElement::~StrokeElement() {
- delete miterLimit;
- delete color;
- delete opacity;
- delete strokeWidth;
- delete dashOffset;
- for (auto& dash : dashes) {
- delete dash;
- }
+ delete miterLimit;
+ delete color;
+ delete opacity;
+ delete strokeWidth;
+ delete dashOffset;
+ for (auto& dash : dashes) {
+ delete dash;
+ }
}
void StrokeElement::excludeVaryingRanges(std::vector* timeRanges) const {
- miterLimit->excludeVaryingRanges(timeRanges);
- color->excludeVaryingRanges(timeRanges);
- opacity->excludeVaryingRanges(timeRanges);
- strokeWidth->excludeVaryingRanges(timeRanges);
- if (!dashes.empty()) {
- dashOffset->excludeVaryingRanges(timeRanges);
- for (auto& property : dashes) {
- property->excludeVaryingRanges(timeRanges);
+ miterLimit->excludeVaryingRanges(timeRanges);
+ color->excludeVaryingRanges(timeRanges);
+ opacity->excludeVaryingRanges(timeRanges);
+ strokeWidth->excludeVaryingRanges(timeRanges);
+ if (!dashes.empty()) {
+ dashOffset->excludeVaryingRanges(timeRanges);
+ for (auto& property : dashes) {
+ property->excludeVaryingRanges(timeRanges);
+ }
}
- }
}
bool StrokeElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- for (auto dash : dashes) {
- if (dash == nullptr) {
- VerifyFailed();
- return false;
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ for (auto dash : dashes) {
+ if (dash == nullptr) {
+ VerifyFailed();
+ return false;
+ }
}
- }
- VerifyAndReturn(miterLimit != nullptr && color != nullptr && opacity != nullptr &&
- strokeWidth != nullptr);
+ VerifyAndReturn(miterLimit != nullptr && color != nullptr && opacity != nullptr &&
+ strokeWidth != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/shapes/TrimPathsElement.cpp b/src/base/shapes/TrimPathsElement.cpp
index 25c9cdd15e..a7b5a48f7e 100644
--- a/src/base/shapes/TrimPathsElement.cpp
+++ b/src/base/shapes/TrimPathsElement.cpp
@@ -21,22 +21,22 @@
namespace pag {
TrimPathsElement::~TrimPathsElement() {
- delete start;
- delete end;
- delete offset;
+ delete start;
+ delete end;
+ delete offset;
}
void TrimPathsElement::excludeVaryingRanges(std::vector* timeRanges) const {
- start->excludeVaryingRanges(timeRanges);
- end->excludeVaryingRanges(timeRanges);
- offset->excludeVaryingRanges(timeRanges);
+ start->excludeVaryingRanges(timeRanges);
+ end->excludeVaryingRanges(timeRanges);
+ offset->excludeVaryingRanges(timeRanges);
}
bool TrimPathsElement::verify() const {
- if (!ShapeElement::verify()) {
- VerifyFailed();
- return false;
- }
- VerifyAndReturn(start != nullptr && end != nullptr && offset != nullptr);
+ if (!ShapeElement::verify()) {
+ VerifyFailed();
+ return false;
+ }
+ VerifyAndReturn(start != nullptr && end != nullptr && offset != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/text/TextAnimator.cpp b/src/base/text/TextAnimator.cpp
index 4857cbdc71..08375524e8 100644
--- a/src/base/text/TextAnimator.cpp
+++ b/src/base/text/TextAnimator.cpp
@@ -21,40 +21,40 @@
namespace pag {
TextAnimator::~TextAnimator() {
- for (auto& selector : selectors) {
- delete selector;
- }
- delete colorProperties;
- delete typographyProperties;
+ for (auto& selector : selectors) {
+ delete selector;
+ }
+ delete colorProperties;
+ delete typographyProperties;
}
void TextAnimator::excludeVaryingRanges(std::vector* timeRanges) const {
- for (auto& selector : selectors) {
- selector->excludeVaryingRanges(timeRanges);
- }
- if (colorProperties != nullptr) {
- colorProperties->excludeVaryingRanges(timeRanges);
- }
- if (typographyProperties != nullptr) {
- typographyProperties->excludeVaryingRanges(timeRanges);
- }
+ for (auto& selector : selectors) {
+ selector->excludeVaryingRanges(timeRanges);
+ }
+ if (colorProperties != nullptr) {
+ colorProperties->excludeVaryingRanges(timeRanges);
+ }
+ if (typographyProperties != nullptr) {
+ typographyProperties->excludeVaryingRanges(timeRanges);
+ }
}
bool TextAnimator::verify() const {
- for (auto& selector : selectors) {
- if (selector == nullptr || !selector->verify()) {
- VerifyFailed();
- return false;
+ for (auto& selector : selectors) {
+ if (selector == nullptr || !selector->verify()) {
+ VerifyFailed();
+ return false;
+ }
+ }
+ if (colorProperties != nullptr && !colorProperties->verify()) {
+ VerifyFailed();
+ return false;
+ }
+ if (typographyProperties != nullptr && !typographyProperties->verify()) {
+ VerifyFailed();
+ return false;
}
- }
- if (colorProperties != nullptr && !colorProperties->verify()) {
- VerifyFailed();
- return false;
- }
- if (typographyProperties != nullptr && !typographyProperties->verify()) {
- VerifyFailed();
- return false;
- }
- return true;
+ return true;
}
} // namespace pag
diff --git a/src/base/text/TextAnimatorColorProperties.cpp b/src/base/text/TextAnimatorColorProperties.cpp
index 0e63527dae..2a83cb4019 100644
--- a/src/base/text/TextAnimatorColorProperties.cpp
+++ b/src/base/text/TextAnimatorColorProperties.cpp
@@ -21,20 +21,20 @@
namespace pag {
TextAnimatorColorProperties::~TextAnimatorColorProperties() {
- delete fillColor;
- delete strokeColor;
+ delete fillColor;
+ delete strokeColor;
}
void TextAnimatorColorProperties::excludeVaryingRanges(std::vector* timeRanges) const {
- if (fillColor != nullptr) {
- fillColor->excludeVaryingRanges(timeRanges);
- }
- if (strokeColor != nullptr) {
- strokeColor->excludeVaryingRanges(timeRanges);
- }
+ if (fillColor != nullptr) {
+ fillColor->excludeVaryingRanges(timeRanges);
+ }
+ if (strokeColor != nullptr) {
+ strokeColor->excludeVaryingRanges(timeRanges);
+ }
}
bool TextAnimatorColorProperties::verify() const {
- VerifyAndReturn(fillColor != nullptr || strokeColor != nullptr);
+ VerifyAndReturn(fillColor != nullptr || strokeColor != nullptr);
}
} // namespace pag
diff --git a/src/base/text/TextAnimatorTypographyProperties.cpp b/src/base/text/TextAnimatorTypographyProperties.cpp
index 6df58bfdf9..04d2f63099 100644
--- a/src/base/text/TextAnimatorTypographyProperties.cpp
+++ b/src/base/text/TextAnimatorTypographyProperties.cpp
@@ -21,39 +21,39 @@
namespace pag {
TextAnimatorTypographyProperties::~TextAnimatorTypographyProperties() {
- delete trackingType;
- delete trackingAmount;
- delete position;
- delete scale;
- delete rotation;
- delete opacity;
+ delete trackingType;
+ delete trackingAmount;
+ delete position;
+ delete scale;
+ delete rotation;
+ delete opacity;
}
void TextAnimatorTypographyProperties::excludeVaryingRanges(
std::vector* timeRanges) const {
- if (trackingType != nullptr) {
- trackingType->excludeVaryingRanges(timeRanges);
- }
- if (trackingAmount != nullptr) {
- trackingAmount->excludeVaryingRanges(timeRanges);
- }
- if (position != nullptr) {
- position->excludeVaryingRanges(timeRanges);
- }
- if (scale != nullptr) {
- scale->excludeVaryingRanges(timeRanges);
- }
- if (rotation != nullptr) {
- rotation->excludeVaryingRanges(timeRanges);
- }
- if (opacity != nullptr) {
- opacity->excludeVaryingRanges(timeRanges);
- }
+ if (trackingType != nullptr) {
+ trackingType->excludeVaryingRanges(timeRanges);
+ }
+ if (trackingAmount != nullptr) {
+ trackingAmount->excludeVaryingRanges(timeRanges);
+ }
+ if (position != nullptr) {
+ position->excludeVaryingRanges(timeRanges);
+ }
+ if (scale != nullptr) {
+ scale->excludeVaryingRanges(timeRanges);
+ }
+ if (rotation != nullptr) {
+ rotation->excludeVaryingRanges(timeRanges);
+ }
+ if (opacity != nullptr) {
+ opacity->excludeVaryingRanges(timeRanges);
+ }
}
bool TextAnimatorTypographyProperties::verify() const {
- // trackingAmount is required,but trackingType could be empty.
- VerifyAndReturn(trackingAmount != nullptr || position != nullptr || scale != nullptr ||
- rotation != nullptr || opacity != nullptr);
+ // trackingAmount is required,but trackingType could be empty.
+ VerifyAndReturn(trackingAmount != nullptr || position != nullptr || scale != nullptr ||
+ rotation != nullptr || opacity != nullptr);
}
} // namespace pag
diff --git a/src/base/text/TextMoreOptions.cpp b/src/base/text/TextMoreOptions.cpp
index 286fb9c74a..12516844c2 100644
--- a/src/base/text/TextMoreOptions.cpp
+++ b/src/base/text/TextMoreOptions.cpp
@@ -21,14 +21,14 @@
namespace pag {
TextMoreOptions::~TextMoreOptions() {
- delete groupingAlignment;
+ delete groupingAlignment;
}
void TextMoreOptions::excludeVaryingRanges(std::vector* timeRanges) const {
- groupingAlignment->excludeVaryingRanges(timeRanges);
+ groupingAlignment->excludeVaryingRanges(timeRanges);
}
bool TextMoreOptions::verify() const {
- VerifyAndReturn(groupingAlignment != nullptr);
+ VerifyAndReturn(groupingAlignment != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/text/TextPathOptions.cpp b/src/base/text/TextPathOptions.cpp
index 158517b789..506c8cf90f 100644
--- a/src/base/text/TextPathOptions.cpp
+++ b/src/base/text/TextPathOptions.cpp
@@ -21,23 +21,23 @@
namespace pag {
TextPathOptions::~TextPathOptions() {
- delete reversedPath;
- delete perpendicularToPath;
- delete forceAlignment;
- delete firstMargin;
- delete lastMargin;
+ delete reversedPath;
+ delete perpendicularToPath;
+ delete forceAlignment;
+ delete firstMargin;
+ delete lastMargin;
}
void TextPathOptions::excludeVaryingRanges(std::vector* timeRanges) const {
- reversedPath->excludeVaryingRanges(timeRanges);
- perpendicularToPath->excludeVaryingRanges(timeRanges);
- forceAlignment->excludeVaryingRanges(timeRanges);
- firstMargin->excludeVaryingRanges(timeRanges);
- lastMargin->excludeVaryingRanges(timeRanges);
+ reversedPath->excludeVaryingRanges(timeRanges);
+ perpendicularToPath->excludeVaryingRanges(timeRanges);
+ forceAlignment->excludeVaryingRanges(timeRanges);
+ firstMargin->excludeVaryingRanges(timeRanges);
+ lastMargin->excludeVaryingRanges(timeRanges);
}
bool TextPathOptions::verify() const {
- VerifyAndReturn(reversedPath != nullptr && perpendicularToPath != nullptr &&
- forceAlignment != nullptr && firstMargin != nullptr && lastMargin != nullptr);
+ VerifyAndReturn(reversedPath != nullptr && perpendicularToPath != nullptr &&
+ forceAlignment != nullptr && firstMargin != nullptr && lastMargin != nullptr);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/text/TextRangeSelector.cpp b/src/base/text/TextRangeSelector.cpp
index f8e5bc11b3..2a0a95dac4 100644
--- a/src/base/text/TextRangeSelector.cpp
+++ b/src/base/text/TextRangeSelector.cpp
@@ -21,34 +21,34 @@
namespace pag {
TextRangeSelector::~TextRangeSelector() {
- delete start;
- delete end;
- delete offset;
- delete mode;
- delete amount;
- delete smoothness;
- delete easeHigh;
- delete easeLow;
- delete randomSeed;
+ delete start;
+ delete end;
+ delete offset;
+ delete mode;
+ delete amount;
+ delete smoothness;
+ delete easeHigh;
+ delete easeLow;
+ delete randomSeed;
}
void TextRangeSelector::excludeVaryingRanges(std::vector* timeRanges) const {
- start->excludeVaryingRanges(timeRanges);
- end->excludeVaryingRanges(timeRanges);
- offset->excludeVaryingRanges(timeRanges);
- mode->excludeVaryingRanges(timeRanges);
- amount->excludeVaryingRanges(timeRanges);
- smoothness->excludeVaryingRanges(timeRanges);
- easeHigh->excludeVaryingRanges(timeRanges);
- easeLow->excludeVaryingRanges(timeRanges);
- if (randomizeOrder) {
- randomSeed->excludeVaryingRanges(timeRanges);
- }
+ start->excludeVaryingRanges(timeRanges);
+ end->excludeVaryingRanges(timeRanges);
+ offset->excludeVaryingRanges(timeRanges);
+ mode->excludeVaryingRanges(timeRanges);
+ amount->excludeVaryingRanges(timeRanges);
+ smoothness->excludeVaryingRanges(timeRanges);
+ easeHigh->excludeVaryingRanges(timeRanges);
+ easeLow->excludeVaryingRanges(timeRanges);
+ if (randomizeOrder) {
+ randomSeed->excludeVaryingRanges(timeRanges);
+ }
}
bool TextRangeSelector::verify() const {
- VerifyAndReturn(start != nullptr && end != nullptr && offset != nullptr && mode != nullptr &&
- amount != nullptr && smoothness != nullptr && easeHigh != nullptr &&
- easeLow != nullptr && randomSeed != nullptr);
+ VerifyAndReturn(start != nullptr && end != nullptr && offset != nullptr && mode != nullptr &&
+ amount != nullptr && smoothness != nullptr && easeHigh != nullptr &&
+ easeLow != nullptr && randomSeed != nullptr);
}
} // namespace pag
diff --git a/src/base/text/TextWigglySelector.cpp b/src/base/text/TextWigglySelector.cpp
index b9d737dd7d..bb878db95f 100644
--- a/src/base/text/TextWigglySelector.cpp
+++ b/src/base/text/TextWigglySelector.cpp
@@ -21,26 +21,26 @@
namespace pag {
TextWigglySelector::~TextWigglySelector() {
- delete mode;
- delete maxAmount;
- delete minAmount;
- delete wigglesPerSecond;
- delete correlation;
- delete temporalPhase;
- delete spatialPhase;
- delete lockDimensions;
- delete randomSeed;
+ delete mode;
+ delete maxAmount;
+ delete minAmount;
+ delete wigglesPerSecond;
+ delete correlation;
+ delete temporalPhase;
+ delete spatialPhase;
+ delete lockDimensions;
+ delete randomSeed;
}
void TextWigglySelector::excludeVaryingRanges(std::vector* timeRanges) const {
- // there are no static time ranges for TextWigglySelector
- timeRanges->erase(timeRanges->begin(), timeRanges->end());
+ // there are no static time ranges for TextWigglySelector
+ timeRanges->erase(timeRanges->begin(), timeRanges->end());
}
bool TextWigglySelector::verify() const {
- VerifyAndReturn(mode != nullptr && maxAmount != nullptr && minAmount != nullptr &&
- wigglesPerSecond != nullptr && correlation != nullptr &&
- temporalPhase != nullptr && spatialPhase != nullptr &&
- lockDimensions != nullptr && randomSeed != nullptr);
+ VerifyAndReturn(mode != nullptr && maxAmount != nullptr && minAmount != nullptr &&
+ wigglesPerSecond != nullptr && correlation != nullptr &&
+ temporalPhase != nullptr && spatialPhase != nullptr &&
+ lockDimensions != nullptr && randomSeed != nullptr);
}
} // namespace pag
diff --git a/src/base/utils/BezierEasing.cpp b/src/base/utils/BezierEasing.cpp
index 08b3724671..0eafff9146 100644
--- a/src/base/utils/BezierEasing.cpp
+++ b/src/base/utils/BezierEasing.cpp
@@ -20,16 +20,16 @@
namespace pag {
BezierEasing::BezierEasing(const Point& control1, const Point& control2) {
- bezierPath = BezierPath::Build(Point::Zero(), control1, control2, Point::Make(1, 1), 0.005f);
+ bezierPath = BezierPath::Build(Point::Zero(), control1, control2, Point::Make(1, 1), 0.005f);
}
float BezierEasing::getInterpolation(float input) {
- if (input <= 0) {
- return 0;
- }
- if (input >= 1) {
- return 1;
- }
- return bezierPath->getY(input);
+ if (input <= 0) {
+ return 0;
+ }
+ if (input >= 1) {
+ return 1;
+ }
+ return bezierPath->getY(input);
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/utils/BezierEasing.h b/src/base/utils/BezierEasing.h
index 44a9d5c114..9bb6579c85 100644
--- a/src/base/utils/BezierEasing.h
+++ b/src/base/utils/BezierEasing.h
@@ -23,21 +23,21 @@
namespace pag {
class BezierEasing : public Interpolator {
- public:
- BezierEasing(const Point& control1, const Point& control2);
+public:
+ BezierEasing(const Point& control1, const Point& control2);
- /**
- * Maps a value representing the elapsed fraction of an animation to a value that represents the
- * interpolated fraction. This interpolated value is then multiplied by the change in value of an
- * animation to derive the animated value at the current elapsed animation time.
- * @param input input A value between 0 and 1.0 indicating our current point in the animation
- * where 0 represents the start and 1.0 represents the end.
- * @return The interpolation value. This value can be more than 1.0 for interpolators which
- * overshoot their targets, or less than 0 for interpolators that undershoot their targets.
- */
- float getInterpolation(float input) override;
+ /**
+ * Maps a value representing the elapsed fraction of an animation to a value that represents the
+ * interpolated fraction. This interpolated value is then multiplied by the change in value of an
+ * animation to derive the animated value at the current elapsed animation time.
+ * @param input input A value between 0 and 1.0 indicating our current point in the animation
+ * where 0 represents the start and 1.0 represents the end.
+ * @return The interpolation value. This value can be more than 1.0 for interpolators which
+ * overshoot their targets, or less than 0 for interpolators that undershoot their targets.
+ */
+ float getInterpolation(float input) override;
- private:
- std::shared_ptr bezierPath = nullptr;
+private:
+ std::shared_ptr bezierPath = nullptr;
};
} // namespace pag
diff --git a/src/base/utils/BezierPath.cpp b/src/base/utils/BezierPath.cpp
index 334fe0a79b..4908a9ab51 100644
--- a/src/base/utils/BezierPath.cpp
+++ b/src/base/utils/BezierPath.cpp
@@ -25,38 +25,38 @@ namespace pag {
#define MaxBezierTValue 0x3FFFFFFF
bool TSpanBigEnough(int tSpan) {
- return (tSpan >> 10) != 0;
+ return (tSpan >> 10) != 0;
}
float ClampTo(float value, float min, float max) {
- if (value < min) {
- value = min;
- }
- if (value > max) {
- value = max;
- }
- return value;
+ if (value < min) {
+ value = min;
+ }
+ if (value > max) {
+ value = max;
+ }
+ return value;
}
float MaxFloat(float a, float b) {
- return a > b ? a : b;
+ return a > b ? a : b;
}
float MinFloat(float a, float b) {
- return a < b ? a : b;
+ return a < b ? a : b;
}
float Distance(const Point& a, const Point& b) {
- auto dx = a.x - b.x;
- auto dy = a.y - b.y;
- return sqrtf(dx * dx + dy * dy);
+ auto dx = a.x - b.x;
+ auto dy = a.y - b.y;
+ return sqrtf(dx * dx + dy * dy);
}
bool PointOnLine(const Point& point1, const Point& point2, const Point& point3,
const float& precision) {
- auto distance = point1.x * point2.y + point1.y * point3.x + point2.x * point3.y -
- point3.x * point2.y - point3.y * point1.x - point2.x * point1.y;
- return fabs(distance) < precision;
+ auto distance = point1.x * point2.y + point1.y * point3.x + point2.x * point3.y -
+ point3.x * point2.y - point3.y * point1.x - point2.x * point1.y;
+ return fabs(distance) < precision;
}
/**
@@ -64,213 +64,213 @@ bool PointOnLine(const Point& point1, const Point& point2, const Point& point3,
* two new cubics in result: result[0..3] and result[3..6]
*/
void SplitCubicCurveAt(const Point points[4], Point result[7], float t) {
- auto p1 = Interpolate(points[0], points[1], t);
- auto bc = Interpolate(points[1], points[2], t);
- auto p5 = Interpolate(points[2], points[3], t);
- auto p2 = Interpolate(p1, bc, t);
- auto p4 = Interpolate(bc, p5, t);
+ auto p1 = Interpolate(points[0], points[1], t);
+ auto bc = Interpolate(points[1], points[2], t);
+ auto p5 = Interpolate(points[2], points[3], t);
+ auto p2 = Interpolate(p1, bc, t);
+ auto p4 = Interpolate(bc, p5, t);
- result[0] = points[0];
- result[1] = p1;
- result[2] = p2;
- result[3] = Interpolate(p2, p4, t);
- result[4] = p4;
- result[5] = p5;
- result[6] = points[3];
+ result[0] = points[0];
+ result[1] = p1;
+ result[2] = p2;
+ result[3] = Interpolate(p2, p4, t);
+ result[4] = p4;
+ result[5] = p5;
+ result[6] = points[3];
}
bool DistanceExceedsLimit(const Point& pt1, const Point& pt2, const float& precision) {
- return MaxFloat(fabsf(pt2.x - pt1.x), fabsf(pt2.y - pt1.y)) > precision;
+ return MaxFloat(fabsf(pt2.x - pt1.x), fabsf(pt2.y - pt1.y)) > precision;
}
bool CubicTooCurvy(const Point pts[4], const float& precision) {
- static float oneOfThird = 1.0f / 3;
- static float twoOfThird = 2.0f / 3;
- auto pt1 = Interpolate(pts[0], pts[3], oneOfThird);
- auto pt2 = Interpolate(pts[0], pts[3], twoOfThird);
- return DistanceExceedsLimit(pts[1], pt1, precision) ||
- DistanceExceedsLimit(pts[2], pt2, precision);
+ static float oneOfThird = 1.0f / 3;
+ static float twoOfThird = 2.0f / 3;
+ auto pt1 = Interpolate(pts[0], pts[3], oneOfThird);
+ auto pt2 = Interpolate(pts[0], pts[3], twoOfThird);
+ return DistanceExceedsLimit(pts[1], pt1, precision) ||
+ DistanceExceedsLimit(pts[2], pt2, precision);
}
float BuildCubicSegments(const Point points[4], float distance, unsigned minT, unsigned maxT,
std::vector& segments, const float& precision) {
- if (TSpanBigEnough(maxT - minT) && CubicTooCurvy(points, precision)) {
- auto halfT = (minT + maxT) >> 1;
- Point result[7];
- SplitCubicCurveAt(points, result, 0.5f);
- distance = BuildCubicSegments(result, distance, minT, halfT, segments, precision);
- distance = BuildCubicSegments(&result[3], distance, halfT, maxT, segments, precision);
- } else {
- distance += Distance(points[0], points[3]);
- BezierSegment segment = {points[3], distance, maxT};
- segments.push_back(segment);
- }
- return distance;
+ if (TSpanBigEnough(maxT - minT) && CubicTooCurvy(points, precision)) {
+ auto halfT = (minT + maxT) >> 1;
+ Point result[7];
+ SplitCubicCurveAt(points, result, 0.5f);
+ distance = BuildCubicSegments(result, distance, minT, halfT, segments, precision);
+ distance = BuildCubicSegments(&result[3], distance, halfT, maxT, segments, precision);
+ } else {
+ distance += Distance(points[0], points[3]);
+ BezierSegment segment = {points[3], distance, maxT};
+ segments.push_back(segment);
+ }
+ return distance;
}
BezierKey BezierKey::Make(const Point points[4], float precision) {
- BezierKey bezierKey = {};
- auto values = reinterpret_cast(points);
- for (int i = 0; i < 8; i++) {
- bezierKey.values[i] = static_cast(roundf(values[i] / precision));
- }
- bezierKey.values[8] = static_cast(roundf(1 / precision));
- return bezierKey;
+ BezierKey bezierKey = {};
+ auto values = reinterpret_cast(points);
+ for (int i = 0; i < 8; i++) {
+ bezierKey.values[i] = static_cast(roundf(values[i] / precision));
+ }
+ bezierKey.values[8] = static_cast(roundf(1 / precision));
+ return bezierKey;
}
bool BezierKey::operator==(const pag::BezierKey& other) const {
- for (int i = 0; i < 9; i++) {
- if (values[i] != other.values[i]) {
- return false;
+ for (int i = 0; i < 9; i++) {
+ if (values[i] != other.values[i]) {
+ return false;
+ }
}
- }
- return true;
+ return true;
}
size_t BezierHasher::operator()(const pag::BezierKey& key) const {
- size_t hash = 0;
- auto& values = key.values;
- for (int i = 0; i < 9; i++) {
- hash ^= values[i] + 0x9e3779b9 + (hash << 6) + (hash >> 2);
- }
- return hash;
+ size_t hash = 0;
+ auto& values = key.values;
+ for (int i = 0; i < 9; i++) {
+ hash ^= values[i] + 0x9e3779b9 + (hash << 6) + (hash >> 2);
+ }
+ return hash;
}
static std::unordered_map, BezierHasher> BezierCacheMap =
- std::unordered_map, BezierHasher>{};
+ std::unordered_map, BezierHasher> {};
static std::mutex locker = {};
std::shared_ptr BezierPath::Build(const pag::Point& start, const pag::Point& control1,
- const pag::Point& control2, const pag::Point& end,
- float precision) {
- Point points[] = {start, control1, control2, end};
- auto bezierKey = BezierKey::Make(points, precision);
- {
- std::lock_guard autoLock(locker);
- auto result = BezierCacheMap.find(bezierKey);
- if (result != BezierCacheMap.end()) {
- auto& weak = result->second;
- auto data = weak.lock();
- if (data) {
- return data;
- }
- BezierCacheMap.erase(result);
+ const pag::Point& control2, const pag::Point& end,
+ float precision) {
+ Point points[] = {start, control1, control2, end};
+ auto bezierKey = BezierKey::Make(points, precision);
+ {
+ std::lock_guard autoLock(locker);
+ auto result = BezierCacheMap.find(bezierKey);
+ if (result != BezierCacheMap.end()) {
+ auto& weak = result->second;
+ auto data = weak.lock();
+ if (data) {
+ return data;
+ }
+ BezierCacheMap.erase(result);
+ }
}
- }
- auto bezierPath = std::shared_ptr(new BezierPath());
- BezierSegment segment = {points[0], 0, 0};
- bezierPath->segments.push_back(segment);
- if (PointOnLine(points[0], points[3], points[1], precision) &&
- PointOnLine(points[0], points[3], points[2], precision)) {
- bezierPath->length = Distance(points[0], points[3]);
- segment = {points[3], bezierPath->length, MaxBezierTValue};
+ auto bezierPath = std::shared_ptr(new BezierPath());
+ BezierSegment segment = {points[0], 0, 0};
bezierPath->segments.push_back(segment);
- } else {
- bezierPath->length =
- BuildCubicSegments(points, 0, 0, MaxBezierTValue, bezierPath->segments, precision);
- }
- {
- std::lock_guard autoLock(locker);
- std::weak_ptr weak = bezierPath;
- BezierCacheMap.insert(std::make_pair(bezierKey, std::move(weak)));
- }
- return bezierPath;
+ if (PointOnLine(points[0], points[3], points[1], precision) &&
+ PointOnLine(points[0], points[3], points[2], precision)) {
+ bezierPath->length = Distance(points[0], points[3]);
+ segment = {points[3], bezierPath->length, MaxBezierTValue};
+ bezierPath->segments.push_back(segment);
+ } else {
+ bezierPath->length =
+ BuildCubicSegments(points, 0, 0, MaxBezierTValue, bezierPath->segments, precision);
+ }
+ {
+ std::lock_guard autoLock(locker);
+ std::weak_ptr weak = bezierPath;
+ BezierCacheMap.insert(std::make_pair(bezierKey, std::move(weak)));
+ }
+ return bezierPath;
}
Point BezierPath::getPosition(float percent) const {
- if (percent <= 0) {
- return segments[0].position;
- }
- if (percent >= 1) {
- return segments.back().position;
- }
- int startIndex, endIndex;
- float fraction;
- findSegmentAtDistance(length * percent, startIndex, endIndex, fraction);
- return Interpolate(segments[startIndex].position, segments[endIndex].position, fraction);
+ if (percent <= 0) {
+ return segments[0].position;
+ }
+ if (percent >= 1) {
+ return segments.back().position;
+ }
+ int startIndex, endIndex;
+ float fraction;
+ findSegmentAtDistance(length * percent, startIndex, endIndex, fraction);
+ return Interpolate(segments[startIndex].position, segments[endIndex].position, fraction);
}
float BezierPath::getT(float percent) const {
- if (percent <= 0) {
- return 0;
- }
- if (percent >= 1) {
- return 1;
- }
- int startIndex, endIndex;
- float fraction;
- findSegmentAtDistance(length * percent, startIndex, endIndex, fraction);
- return Interpolate(segments[startIndex].tValue, segments[endIndex].tValue, fraction) /
- static_cast(MaxBezierTValue);
+ if (percent <= 0) {
+ return 0;
+ }
+ if (percent >= 1) {
+ return 1;
+ }
+ int startIndex, endIndex;
+ float fraction;
+ findSegmentAtDistance(length * percent, startIndex, endIndex, fraction);
+ return Interpolate(segments[startIndex].tValue, segments[endIndex].tValue, fraction) /
+ static_cast(MaxBezierTValue);
}
float BezierPath::getY(float x) const {
- int startIndex = 0;
- auto endIndex = static_cast(segments.size() - 1);
- while (endIndex - startIndex > 1) {
- auto middleIndex = (startIndex + endIndex) >> 1;
- if (x < segments[middleIndex].position.x) {
- endIndex = middleIndex;
- } else {
- startIndex = middleIndex;
+ int startIndex = 0;
+ auto endIndex = static_cast(segments.size() - 1);
+ while (endIndex - startIndex > 1) {
+ auto middleIndex = (startIndex + endIndex) >> 1;
+ if (x < segments[middleIndex].position.x) {
+ endIndex = middleIndex;
+ } else {
+ startIndex = middleIndex;
+ }
}
- }
- auto& start = segments[startIndex].position;
- auto& end = segments[endIndex].position;
- auto xRange = end.x - start.x;
- if (xRange == 0) {
- return start.y;
- }
- auto fraction = (x - start.x) / xRange;
- return Interpolate(start.y, end.y, fraction);
+ auto& start = segments[startIndex].position;
+ auto& end = segments[endIndex].position;
+ auto xRange = end.x - start.x;
+ if (xRange == 0) {
+ return start.y;
+ }
+ auto fraction = (x - start.x) / xRange;
+ return Interpolate(start.y, end.y, fraction);
}
float BezierPath::getX(float y) const {
- int startIndex = 0;
- auto endIndex = static_cast(segments.size() - 1);
- while (endIndex - startIndex > 1) {
- auto middleIndex = (startIndex + endIndex) >> 1;
- if (y < segments[middleIndex].position.y) {
- endIndex = middleIndex;
- } else {
- startIndex = middleIndex;
+ int startIndex = 0;
+ auto endIndex = static_cast(segments.size() - 1);
+ while (endIndex - startIndex > 1) {
+ auto middleIndex = (startIndex + endIndex) >> 1;
+ if (y < segments[middleIndex].position.y) {
+ endIndex = middleIndex;
+ } else {
+ startIndex = middleIndex;
+ }
}
- }
- auto& start = segments[startIndex].position;
- auto& end = segments[endIndex].position;
- auto yRange = end.y - start.y;
- if (yRange == 0) {
- return start.x;
- }
- auto fraction = (y - start.y) / yRange;
- return Interpolate(start.x, end.x, fraction);
+ auto& start = segments[startIndex].position;
+ auto& end = segments[endIndex].position;
+ auto yRange = end.y - start.y;
+ if (yRange == 0) {
+ return start.x;
+ }
+ auto fraction = (y - start.y) / yRange;
+ return Interpolate(start.x, end.x, fraction);
}
float BezierPath::getLength() const {
- return length;
+ return length;
}
void BezierPath::findSegmentAtDistance(float distance, int& startIndex, int& endIndex,
float& fraction) const {
- startIndex = 0;
- endIndex = static_cast(segments.size() - 1);
- while (endIndex - startIndex > 1) {
- auto middleIndex = (startIndex + endIndex) >> 1;
- if (distance < segments[middleIndex].distance) {
- endIndex = middleIndex;
+ startIndex = 0;
+ endIndex = static_cast(segments.size() - 1);
+ while (endIndex - startIndex > 1) {
+ auto middleIndex = (startIndex + endIndex) >> 1;
+ if (distance < segments[middleIndex].distance) {
+ endIndex = middleIndex;
+ } else {
+ startIndex = middleIndex;
+ }
+ }
+ auto& start = segments[startIndex];
+ auto& end = segments[endIndex];
+ auto distanceRange = end.distance - start.distance;
+ if (distanceRange == 0) {
+ fraction = 0;
} else {
- startIndex = middleIndex;
+ fraction = (distance - start.distance) / distanceRange;
}
- }
- auto& start = segments[startIndex];
- auto& end = segments[endIndex];
- auto distanceRange = end.distance - start.distance;
- if (distanceRange == 0) {
- fraction = 0;
- } else {
- fraction = (distance - start.distance) / distanceRange;
- }
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/utils/BezierPath.h b/src/base/utils/BezierPath.h
index cd245d03ab..287bd64728 100644
--- a/src/base/utils/BezierPath.h
+++ b/src/base/utils/BezierPath.h
@@ -24,70 +24,70 @@
namespace pag {
struct BezierKey {
- int32_t values[9];
+ int32_t values[9];
- static BezierKey Make(const Point points[4], float precision);
+ static BezierKey Make(const Point points[4], float precision);
- bool operator==(const BezierKey& other) const;
+ bool operator==(const BezierKey& other) const;
};
struct BezierHasher {
- size_t operator()(const BezierKey& key) const;
+ size_t operator()(const BezierKey& key) const;
};
struct BezierSegment {
- Point position;
- /**
- * Total distance up to this point
- */
- float distance;
- /**
- * Total t value up to this point
- */
- unsigned tValue;
+ Point position;
+ /**
+ * Total distance up to this point
+ */
+ float distance;
+ /**
+ * Total t value up to this point
+ */
+ unsigned tValue;
};
class BezierPath {
- public:
- /**
- * Creates a cubic bezier path.
- */
- static std::shared_ptr Build(const Point& start, const Point& control1,
- const Point& control2, const Point& end,
- float precision);
+public:
+ /**
+ * Creates a cubic bezier path.
+ */
+ static std::shared_ptr Build(const Point& start, const Point& control1,
+ const Point& control2, const Point& end,
+ float precision);
- /**
- * Calculates a point on the curve, for a given value between 0 and 1.0 indicating the percent of
- * the curve length where 0 represents the start and 1.0 represents the end.
- */
- Point getPosition(float percent) const;
+ /**
+ * Calculates a point on the curve, for a given value between 0 and 1.0 indicating the percent of
+ * the curve length where 0 represents the start and 1.0 represents the end.
+ */
+ Point getPosition(float percent) const;
- /**
- * Calculates a t value of the curve, for a given value between 0 and 1.0 indicating the percent
- * of the curve length where 0 represents the start and 1.0 represents the end.
- */
- float getT(float percent) const;
+ /**
+ * Calculates a t value of the curve, for a given value between 0 and 1.0 indicating the percent
+ * of the curve length where 0 represents the start and 1.0 represents the end.
+ */
+ float getT(float percent) const;
- /**
- * Calculates a y point value on the curve, for a given x point value.
- */
- float getY(float x) const;
+ /**
+ * Calculates a y point value on the curve, for a given x point value.
+ */
+ float getY(float x) const;
- /**
- * Calculates a x point value on the curve, for a given y point value.
- */
- float getX(float y) const;
+ /**
+ * Calculates a x point value on the curve, for a given y point value.
+ */
+ float getX(float y) const;
- /**
- * Returns the length of the bezier path in pixels.
- */
- float getLength() const;
+ /**
+ * Returns the length of the bezier path in pixels.
+ */
+ float getLength() const;
- private:
- float length = 0;
- std::vector segments;
+private:
+ float length = 0;
+ std::vector segments;
- BezierPath() = default;
- void findSegmentAtDistance(float distance, int& startIndex, int& endIndex, float& fraction) const;
+ BezierPath() = default;
+ void findSegmentAtDistance(float distance, int& startIndex, int& endIndex, float& fraction) const;
};
} // namespace pag
diff --git a/src/base/utils/BytesKey.cpp b/src/base/utils/BytesKey.cpp
index 4867f2f682..c32c547fa0 100644
--- a/src/base/utils/BytesKey.cpp
+++ b/src/base/utils/BytesKey.cpp
@@ -21,47 +21,47 @@
namespace pag {
union DataConverter {
- float floatValue;
- uint8_t bytes[4];
- uint32_t uintValue;
+ float floatValue;
+ uint8_t bytes[4];
+ uint32_t uintValue;
};
union PointerConverter {
- const void* pointer;
- uint32_t uintValues[2];
+ const void* pointer;
+ uint32_t uintValues[2];
};
void BytesKey::write(uint32_t value) {
- values.push_back(value);
+ values.push_back(value);
}
void BytesKey::write(const void* value) {
- PointerConverter converter = {};
- converter.pointer = value;
- values.push_back(converter.uintValues[0]);
- static size_t size = sizeof(intptr_t);
- if (size > 4) {
- values.push_back(converter.uintValues[1]);
- }
+ PointerConverter converter = {};
+ converter.pointer = value;
+ values.push_back(converter.uintValues[0]);
+ static size_t size = sizeof(intptr_t);
+ if (size > 4) {
+ values.push_back(converter.uintValues[1]);
+ }
}
void BytesKey::write(const uint8_t value[4]) {
- DataConverter converter = {};
- memcpy(converter.bytes, value, 4);
- values.push_back(converter.uintValue);
+ DataConverter converter = {};
+ memcpy(converter.bytes, value, 4);
+ values.push_back(converter.uintValue);
}
void BytesKey::write(float value) {
- DataConverter converter = {};
- converter.floatValue = value;
- values.push_back(converter.uintValue);
+ DataConverter converter = {};
+ converter.floatValue = value;
+ values.push_back(converter.uintValue);
}
size_t BytesHasher::operator()(const BytesKey& key) const {
- auto hash = key.values.size();
- for (auto& value : key.values) {
- hash ^= value + 0x9e3779b9 + (hash << 6u) + (hash >> 2u);
- }
- return hash;
+ auto hash = key.values.size();
+ for (auto& value : key.values) {
+ hash ^= value + 0x9e3779b9 + (hash << 6u) + (hash >> 2u);
+ }
+ return hash;
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/utils/BytesKey.h b/src/base/utils/BytesKey.h
index 48bd2fee55..d3f02e63b0 100644
--- a/src/base/utils/BytesKey.h
+++ b/src/base/utils/BytesKey.h
@@ -26,52 +26,52 @@ namespace pag {
* A key used for hashing a byte stream.
*/
class BytesKey {
- public:
- /**
- * Returns true if this key is invalid.
- */
- bool isValid() const {
- return !values.empty();
- }
+public:
+ /**
+ * Returns true if this key is invalid.
+ */
+ bool isValid() const {
+ return !values.empty();
+ }
- /**
- * Writes a uint32 value into the key.
- */
- void write(uint32_t value);
+ /**
+ * Writes a uint32 value into the key.
+ */
+ void write(uint32_t value);
- /**
- * Writes a pointer value into the key.
- */
- void write(const void* value);
+ /**
+ * Writes a pointer value into the key.
+ */
+ void write(const void* value);
- /**
- * Writes a uint32 value into the key.
- */
- void write(const uint8_t value[4]);
+ /**
+ * Writes a uint32 value into the key.
+ */
+ void write(const uint8_t value[4]);
- /**
- * Writes a float value into the key.
- */
- void write(float value);
+ /**
+ * Writes a float value into the key.
+ */
+ void write(float value);
- friend bool operator==(const BytesKey& a, const BytesKey& b) {
- return a.values == b.values;
- }
+ friend bool operator==(const BytesKey& a, const BytesKey& b) {
+ return a.values == b.values;
+ }
- bool operator<(const BytesKey& key) const {
- return values < key.values;
- }
+ bool operator<(const BytesKey& key) const {
+ return values < key.values;
+ }
- private:
- std::vector values = {};
+private:
+ std::vector values = {};
- friend struct BytesHasher;
+ friend struct BytesHasher;
};
/**
* The hasher for BytesKey.
*/
struct BytesHasher {
- size_t operator()(const BytesKey& key) const;
+ size_t operator()(const BytesKey& key) const;
};
} // namespace pag
diff --git a/src/base/utils/EnumClassHash.h b/src/base/utils/EnumClassHash.h
index 8b5842b473..558b264a15 100644
--- a/src/base/utils/EnumClassHash.h
+++ b/src/base/utils/EnumClassHash.h
@@ -19,9 +19,9 @@
#pragma once
namespace pag {
struct EnumClassHash {
- template
- size_t operator()(T t) const {
- return static_cast(t);
- }
+ template
+ size_t operator()(T t) const {
+ return static_cast(t);
+ }
};
} // namespace pag
diff --git a/src/base/utils/GetTimer.cpp b/src/base/utils/GetTimer.cpp
index 6191a4cd45..53371c848e 100644
--- a/src/base/utils/GetTimer.cpp
+++ b/src/base/utils/GetTimer.cpp
@@ -20,9 +20,9 @@
namespace pag {
int64_t GetTimer() {
- static auto START_TIME = std::chrono::high_resolution_clock::now();
- auto now = std::chrono::high_resolution_clock::now();
- auto ns = std::chrono::duration_cast(now - START_TIME);
- return static_cast(ns.count() * 1e-3);
+ static auto START_TIME = std::chrono::high_resolution_clock::now();
+ auto now = std::chrono::high_resolution_clock::now();
+ auto ns = std::chrono::duration_cast(now - START_TIME);
+ return static_cast(ns.count() * 1e-3);
}
} // namespace pag
diff --git a/src/base/utils/Interpolate.h b/src/base/utils/Interpolate.h
index 865d8983cc..39bc4540be 100644
--- a/src/base/utils/Interpolate.h
+++ b/src/base/utils/Interpolate.h
@@ -26,60 +26,60 @@ inline T Interpolate(const T& a, const T& b, const float& t);
template <>
inline float Interpolate(const float& a, const float& b, const float& t) {
- return a + (b - a) * t;
+ return a + (b - a) * t;
}
template <>
inline uint8_t Interpolate(const uint8_t& a, const uint8_t& b, const float& t) {
- auto ret = a + (b - a) * t;
- return static_cast(ret > 255 ? 255 : (ret < 0 ? 0 : ret));
+ auto ret = a + (b - a) * t;
+ return static_cast(ret > 255 ? 255 : (ret < 0 ? 0 : ret));
}
template <>
inline uint16_t Interpolate(const uint16_t& a, const uint16_t& b, const float& t) {
- auto ret = a + (b - a) * t;
- return static_cast(ret > 65535 ? 65535 : (ret < 0 ? 0 : ret));
+ auto ret = a + (b - a) * t;
+ return static_cast(ret > 65535 ? 65535 : (ret < 0 ? 0 : ret));
}
template <>
inline Point Interpolate(const Point& a, const Point& b, const float& t) {
- return {Interpolate(a.x, b.x, t), Interpolate(a.y, b.y, t)};
+ return {Interpolate(a.x, b.x, t), Interpolate(a.y, b.y, t)};
}
template <>
inline Color Interpolate(const Color& a, const Color& b, const float& t) {
- return {Interpolate(a.red, b.red, t), Interpolate(a.green, b.green, t),
- Interpolate(a.blue, b.blue, t)};
+ return {Interpolate(a.red, b.red, t), Interpolate(a.green, b.green, t),
+ Interpolate(a.blue, b.blue, t)};
}
template <>
inline int64_t Interpolate(const int64_t& a, const int64_t& b, const float& t) {
- return static_cast(a + (b - a) * t);
+ return static_cast(a + (b - a) * t);
}
template <>
inline uint32_t Interpolate(const uint32_t& a, const uint32_t& b, const float& t) {
- return static_cast(a + (b - a) * t);
+ return static_cast(a + (b - a) * t);
}
template <>
inline int32_t Interpolate(const int32_t& a, const int32_t& b, const float& t) {
- return static_cast(a + (b - a) * t);
+ return static_cast(a + (b - a) * t);
}
template <>
inline PathHandle Interpolate(const PathHandle& a, const PathHandle& b, const float& t) {
- auto path = new PathData();
- a->interpolate(*(b.get()), path, t);
- return PathHandle(path);
+ auto path = new PathData();
+ a->interpolate(*(b.get()), path, t);
+ return PathHandle(path);
}
template <>
inline GradientColorHandle Interpolate(const GradientColorHandle& a, const GradientColorHandle& b,
const float& t) {
- auto gradientColor = new GradientColor();
- a->interpolate(*(b.get()), gradientColor, t);
- return GradientColorHandle(gradientColor);
+ auto gradientColor = new GradientColor();
+ a->interpolate(*(b.get()), gradientColor, t);
+ return GradientColorHandle(gradientColor);
}
} // namespace pag
diff --git a/src/base/utils/Interpolator.h b/src/base/utils/Interpolator.h
index 87e760219d..5128b822cb 100644
--- a/src/base/utils/Interpolator.h
+++ b/src/base/utils/Interpolator.h
@@ -22,20 +22,20 @@
namespace pag {
class Interpolator {
- public:
- virtual ~Interpolator() = default;
+public:
+ virtual ~Interpolator() = default;
- /**
- * Maps a value representing the elapsed fraction of an animation to a value that represents the
- * interpolated fraction. This interpolated value is then multiplied by the change in value of an
- * animation to derive the animated value at the current elapsed animation time.
- * @param input input A value between 0 and 1.0 indicating our current point in the animation
- * where 0 represents the start and 1.0 represents the end.
- * @return The interpolation value. This value can be more than 1.0 for interpolators which
- * overshoot their targets, or less than 0 for interpolators that undershoot their targets.
- */
- virtual float getInterpolation(float input) {
- return input;
- }
+ /**
+ * Maps a value representing the elapsed fraction of an animation to a value that represents the
+ * interpolated fraction. This interpolated value is then multiplied by the change in value of an
+ * animation to derive the animated value at the current elapsed animation time.
+ * @param input input A value between 0 and 1.0 indicating our current point in the animation
+ * where 0 represents the start and 1.0 represents the end.
+ * @return The interpolation value. This value can be more than 1.0 for interpolators which
+ * overshoot their targets, or less than 0 for interpolators that undershoot their targets.
+ */
+ virtual float getInterpolation(float input) {
+ return input;
+ }
};
} // namespace pag
diff --git a/src/base/utils/MathExtra.h b/src/base/utils/MathExtra.h
index dab868342d..9cc34a9ce5 100644
--- a/src/base/utils/MathExtra.h
+++ b/src/base/utils/MathExtra.h
@@ -30,28 +30,28 @@ static constexpr float FLOAT_SQRT2 = 1.41421356f;
#define RadiansToDegrees(radians) ((radians) * (180.0f / M_PI_F))
static inline bool FloatNearlyZero(float x, float tolerance = FLOAT_NEARLY_ZERO) {
- return fabsf(x) <= tolerance;
+ return fabsf(x) <= tolerance;
}
static inline bool FloatNearlyEqual(float x, float y, float tolerance = FLOAT_NEARLY_ZERO) {
- return fabsf(x - y) <= tolerance;
+ return fabsf(x - y) <= tolerance;
}
static inline float SinSnapToZero(float radians) {
- float v = sinf(radians);
- return FloatNearlyZero(v) ? 0.0f : v;
+ float v = sinf(radians);
+ return FloatNearlyZero(v) ? 0.0f : v;
}
static inline float CosSnapToZero(float radians) {
- float v = cosf(radians);
- return FloatNearlyZero(v) ? 0.0f : v;
+ float v = cosf(radians);
+ return FloatNearlyZero(v) ? 0.0f : v;
}
static inline bool FloatsAreFinite(const float array[], int count) {
- float prod = 0;
- for (int i = 0; i < count; ++i) {
- prod *= array[i];
- }
- return prod == 0;
+ float prod = 0;
+ for (int i = 0; i < count; ++i) {
+ prod *= array[i];
+ }
+ return prod == 0;
}
} // namespace pag
diff --git a/src/base/utils/MatrixUtil.cpp b/src/base/utils/MatrixUtil.cpp
index 53a103ac35..cbb04fbdf8 100644
--- a/src/base/utils/MatrixUtil.cpp
+++ b/src/base/utils/MatrixUtil.cpp
@@ -20,47 +20,47 @@
namespace pag {
bool MapPointInverted(const Matrix& matrix, Point* point) {
- Matrix inverted = {};
- bool canInvert = matrix.invert(&inverted);
- if (canInvert) {
- inverted.mapPoints(point, 1);
- return true;
- }
- return false;
+ Matrix inverted = {};
+ bool canInvert = matrix.invert(&inverted);
+ if (canInvert) {
+ inverted.mapPoints(point, 1);
+ return true;
+ }
+ return false;
}
float GetMaxScaleFactor(const Matrix& matrix) {
- auto scale = GetScaleFactor(matrix);
- return std::max(fabsf(scale.x), fabsf(scale.y));
+ auto scale = GetScaleFactor(matrix);
+ return std::max(fabsf(scale.x), fabsf(scale.y));
}
Point GetScaleFactor(const Matrix& matrix, float contentScale, bool inverted) {
- Point scale = {};
- auto a = matrix.get(0);
- auto c = matrix.get(1);
- auto b = matrix.get(3);
- auto d = matrix.get(4);
- float determinant = a * d - b * c;
- if (a == 1 && b == 0) {
- scale.x = 1;
- } else {
- auto result = sqrtf(a * a + b * b);
- scale.x = determinant < 0 ? -result : result;
- }
- if (c == 0 && d == 1) {
- scale.y = 1;
- } else {
- auto result = sqrtf(c * c + d * d);
- scale.y = determinant < 0 ? -result : result;
- }
- scale.x *= contentScale;
- scale.y *= contentScale;
+ Point scale = {};
+ auto a = matrix.get(0);
+ auto c = matrix.get(1);
+ auto b = matrix.get(3);
+ auto d = matrix.get(4);
+ float determinant = a * d - b * c;
+ if (a == 1 && b == 0) {
+ scale.x = 1;
+ } else {
+ auto result = sqrtf(a * a + b * b);
+ scale.x = determinant < 0 ? -result : result;
+ }
+ if (c == 0 && d == 1) {
+ scale.y = 1;
+ } else {
+ auto result = sqrtf(c * c + d * d);
+ scale.y = determinant < 0 ? -result : result;
+ }
+ scale.x *= contentScale;
+ scale.y *= contentScale;
- if (inverted) {
- scale.x = scale.x == 0 ? 0 : 1 / scale.x;
- scale.y = scale.y == 0 ? 0 : 1 / scale.y;
- }
- return scale;
+ if (inverted) {
+ scale.x = scale.x == 0 ? 0 : 1 / scale.x;
+ scale.y = scale.y == 0 ? 0 : 1 / scale.y;
+ }
+ return scale;
}
} // namespace pag
\ No newline at end of file
diff --git a/src/base/utils/Task.cpp b/src/base/utils/Task.cpp
index 0c6fa9bb9a..0f721bf35c 100644
--- a/src/base/utils/Task.cpp
+++ b/src/base/utils/Task.cpp
@@ -30,146 +30,146 @@
namespace pag {
int GetCPUCores() {
- int cpuCores = 0;
+ int cpuCores = 0;
#ifdef __APPLE__
- size_t len = sizeof(cpuCores);
- // iOS 和 macOS 平台可以准确判断出 CPU 的物理核数。
- sysctlbyname("hw.physicalcpu", &cpuCores, &len, nullptr, 0);
+ size_t len = sizeof(cpuCores);
+ // iOS 和 macOS 平台可以准确判断出 CPU 的物理核数。
+ sysctlbyname("hw.physicalcpu", &cpuCores, &len, nullptr, 0);
#else
- cpuCores = static_cast(std::thread::hardware_concurrency());
+ cpuCores = static_cast(std::thread::hardware_concurrency());
#endif
- if (cpuCores <= 0) {
- cpuCores = 8;
- }
- return cpuCores;
+ if (cpuCores <= 0) {
+ cpuCores = 8;
+ }
+ return cpuCores;
}
std::shared_ptr Task::Make(std::unique_ptr executor) {
- return std::shared_ptr(new Task(std::move(executor)));
+ return std::shared_ptr(new Task(std::move(executor)));
}
Task::Task(std::unique_ptr executor) : executor(std::move(executor)) {
- taskGroup = TaskGroup::GetInstance();
+ taskGroup = TaskGroup::GetInstance();
}
Task::~Task() {
- cancel();
+ cancel();
}
void Task::run() {
- std::lock_guard autoLock(locker);
- if (running) {
- return;
- }
- running = true;
- taskGroup->pushTask(this);
+ std::lock_guard autoLock(locker);
+ if (running) {
+ return;
+ }
+ running = true;
+ taskGroup->pushTask(this);
}
bool Task::isRunning() {
- std::lock_guard autoLock(locker);
- return running;
+ std::lock_guard autoLock(locker);
+ return running;
}
Executor* Task::wait() {
- std::unique_lock autoLock(locker);
- if (!running) {
+ std::unique_lock autoLock(locker);
+ if (!running) {
+ return executor.get();
+ }
+ condition.wait(autoLock);
return executor.get();
- }
- condition.wait(autoLock);
- return executor.get();
}
void Task::cancel() {
- std::unique_lock autoLock(locker);
- if (!running) {
- return;
- }
- if (taskGroup->removeTask(this)) {
- running = false;
- return;
- }
- condition.wait(autoLock);
+ std::unique_lock autoLock(locker);
+ if (!running) {
+ return;
+ }
+ if (taskGroup->removeTask(this)) {
+ running = false;
+ return;
+ }
+ condition.wait(autoLock);
}
void Task::execute() {
- executor->execute();
- std::lock_guard auoLock(locker);
- running = false;
- condition.notify_all();
+ executor->execute();
+ std::lock_guard auoLock(locker);
+ running = false;
+ condition.notify_all();
}
TaskGroup* TaskGroup::GetInstance() {
- static TaskGroup taskGroup = {};
- return &taskGroup;
+ static TaskGroup taskGroup = {};
+ return &taskGroup;
}
void TaskGroup::RunLoop(TaskGroup* taskGroup) {
- while (true) {
- auto task = taskGroup->popTask();
- if (!task) {
- break;
+ while (true) {
+ auto task = taskGroup->popTask();
+ if (!task) {
+ break;
+ }
+ task->execute();
}
- task->execute();
- }
}
TaskGroup::TaskGroup() {
- static const int CPUCores = GetCPUCores();
- auto maxThreads = CPUCores > 16 ? 16 : CPUCores;
- activeThreads = maxThreads;
- for (int i = 0; i < maxThreads; i++) {
- threads.emplace_back(&TaskGroup::RunLoop, this);
- }
+ static const int CPUCores = GetCPUCores();
+ auto maxThreads = CPUCores > 16 ? 16 : CPUCores;
+ activeThreads = maxThreads;
+ for (int i = 0; i < maxThreads; i++) {
+ threads.emplace_back(&TaskGroup::RunLoop, this);
+ }
}
TaskGroup::~TaskGroup() {
- exit();
- for (auto& thread : threads) {
- if (thread.joinable()) {
- thread.join();
+ exit();
+ for (auto& thread : threads) {
+ if (thread.joinable()) {
+ thread.join();
+ }
}
- }
}
void TaskGroup::pushTask(Task* task) {
- std::lock_guard autoLock(locker);
- tasks.push_back(task);
- condition.notify_one();
+ std::lock_guard autoLock(locker);
+ tasks.push_back(task);
+ condition.notify_one();
}
Task* TaskGroup::popTask() {
- std::unique_lock autoLock(locker);
- activeThreads--;
- while (true) {
- if (tasks.empty()) {
- condition.wait(autoLock);
- if (exited) {
- return nullptr;
- }
- } else {
- auto task = tasks.front();
- tasks.pop_front();
- activeThreads++;
- // LOGI("TaskGroup.activeThreads : %d", activeThreads);
- return task;
+ std::unique_lock autoLock(locker);
+ activeThreads--;
+ while (true) {
+ if (tasks.empty()) {
+ condition.wait(autoLock);
+ if (exited) {
+ return nullptr;
+ }
+ } else {
+ auto task = tasks.front();
+ tasks.pop_front();
+ activeThreads++;
+ // LOGI("TaskGroup.activeThreads : %d", activeThreads);
+ return task;
+ }
}
- }
}
bool TaskGroup::removeTask(Task* task) {
- std::lock_guard autoLock(locker);
- auto position = std::find(tasks.begin(), tasks.end(), task);
- if (position == tasks.end()) {
- return false;
- }
- tasks.erase(position);
- return true;
+ std::lock_guard autoLock(locker);
+ auto position = std::find(tasks.begin(), tasks.end(), task);
+ if (position == tasks.end()) {
+ return false;
+ }
+ tasks.erase(position);
+ return true;
}
void TaskGroup::exit() {
- std::lock_guard autoLock(locker);
- exited = true;
- condition.notify_all();
+ std::lock_guard autoLock(locker);
+ exited = true;
+ condition.notify_all();
}
} // namespace pag
diff --git a/src/base/utils/Task.h b/src/base/utils/Task.h
index 29611f4d17..64cab8fd71 100644
--- a/src/base/utils/Task.h
+++ b/src/base/utils/Task.h
@@ -28,62 +28,62 @@
namespace pag {
class Executor {
- public:
- virtual ~Executor() = default;
+public:
+ virtual ~Executor() = default;
- private:
- virtual void execute() = 0;
+private:
+ virtual void execute() = 0;
- friend class Task;
+ friend class Task;
};
class TaskGroup;
class Task {
- public:
- static std::shared_ptr Make(std::unique_ptr executor);
- ~Task();
-
- void run();
- bool isRunning();
- Executor* wait();
- void cancel();
-
- private:
- std::mutex locker = {};
- std::condition_variable condition = {};
- bool running = false;
- TaskGroup* taskGroup = nullptr;
- std::unique_ptr executor = nullptr;
-
- explicit Task(std::unique_ptr