mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-10 16:29:55 +00:00
lottie:convert remaining raw pointer to unique_ptr.
Change-Id: If85e7b8ffbbacd2cd305e6a3ef6d98ccd8ed7172
This commit is contained in:
parent
ded7532e57
commit
c12a9916a5
@ -231,13 +231,7 @@ VRle LOTLayerItem::maskRle(const VRect &clipRect)
|
|||||||
return rle;
|
return rle;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOTLayerItem::LOTLayerItem(LOTLayerData *layerData)
|
LOTLayerItem::LOTLayerItem(LOTLayerData *layerData): mLayerData(layerData)
|
||||||
: mLayerData(layerData),
|
|
||||||
mParentLayer(nullptr),
|
|
||||||
mPrecompLayer(nullptr),
|
|
||||||
mCombinedAlpha(0.0f),
|
|
||||||
mFrameNo(-1),
|
|
||||||
mDirtyFlag(DirtyFlagBit::All)
|
|
||||||
{
|
{
|
||||||
if (mLayerData->mHasMask) {
|
if (mLayerData->mHasMask) {
|
||||||
for (auto &i : mLayerData->mMasks) {
|
for (auto &i : mLayerData->mMasks) {
|
||||||
@ -457,63 +451,59 @@ void LOTNullLayerItem::updateContent() {}
|
|||||||
LOTShapeLayerItem::LOTShapeLayerItem(LOTLayerData *layerData)
|
LOTShapeLayerItem::LOTShapeLayerItem(LOTLayerData *layerData)
|
||||||
: LOTLayerItem(layerData)
|
: LOTLayerItem(layerData)
|
||||||
{
|
{
|
||||||
mRoot = new LOTContentGroupItem(nullptr);
|
mRoot = std::make_unique<LOTContentGroupItem>(nullptr);
|
||||||
mRoot->addChildren(layerData);
|
mRoot->addChildren(layerData);
|
||||||
mRoot->processPaintOperation();
|
mRoot->processPaintOperation();
|
||||||
if (layerData->hasPathOperator()) mRoot->processTrimOperation();
|
if (layerData->hasPathOperator()) mRoot->processTrimOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOTShapeLayerItem::~LOTShapeLayerItem()
|
std::unique_ptr<LOTContentItem>
|
||||||
{
|
LOTShapeLayerItem::createContentItem(LOTData *contentData)
|
||||||
delete mRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOTContentItem *LOTShapeLayerItem::createContentItem(LOTData *contentData)
|
|
||||||
{
|
{
|
||||||
switch (contentData->type()) {
|
switch (contentData->type()) {
|
||||||
case LOTData::Type::ShapeGroup: {
|
case LOTData::Type::ShapeGroup: {
|
||||||
return new LOTContentGroupItem(
|
return std::make_unique<LOTContentGroupItem>(
|
||||||
static_cast<LOTShapeGroupData *>(contentData));
|
static_cast<LOTShapeGroupData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::Rect: {
|
case LOTData::Type::Rect: {
|
||||||
return new LOTRectItem(static_cast<LOTRectData *>(contentData));
|
return std::make_unique<LOTRectItem>(static_cast<LOTRectData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::Ellipse: {
|
case LOTData::Type::Ellipse: {
|
||||||
return new LOTEllipseItem(static_cast<LOTEllipseData *>(contentData));
|
return std::make_unique<LOTEllipseItem>(static_cast<LOTEllipseData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::Shape: {
|
case LOTData::Type::Shape: {
|
||||||
return new LOTShapeItem(static_cast<LOTShapeData *>(contentData));
|
return std::make_unique<LOTShapeItem>(static_cast<LOTShapeData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::Polystar: {
|
case LOTData::Type::Polystar: {
|
||||||
return new LOTPolystarItem(static_cast<LOTPolystarData *>(contentData));
|
return std::make_unique<LOTPolystarItem>(static_cast<LOTPolystarData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::Fill: {
|
case LOTData::Type::Fill: {
|
||||||
return new LOTFillItem(static_cast<LOTFillData *>(contentData));
|
return std::make_unique<LOTFillItem>(static_cast<LOTFillData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::GFill: {
|
case LOTData::Type::GFill: {
|
||||||
return new LOTGFillItem(static_cast<LOTGFillData *>(contentData));
|
return std::make_unique<LOTGFillItem>(static_cast<LOTGFillData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::Stroke: {
|
case LOTData::Type::Stroke: {
|
||||||
return new LOTStrokeItem(static_cast<LOTStrokeData *>(contentData));
|
return std::make_unique<LOTStrokeItem>(static_cast<LOTStrokeData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::GStroke: {
|
case LOTData::Type::GStroke: {
|
||||||
return new LOTGStrokeItem(static_cast<LOTGStrokeData *>(contentData));
|
return std::make_unique<LOTGStrokeItem>(static_cast<LOTGStrokeData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::Repeater: {
|
case LOTData::Type::Repeater: {
|
||||||
return new LOTRepeaterItem(static_cast<LOTRepeaterData *>(contentData));
|
return std::make_unique<LOTRepeaterItem>(static_cast<LOTRepeaterData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOTData::Type::Trim: {
|
case LOTData::Type::Trim: {
|
||||||
return new LOTTrimItem(static_cast<LOTTrimData *>(contentData));
|
return std::make_unique<LOTTrimItem>(static_cast<LOTTrimData *>(contentData));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -542,17 +532,9 @@ void LOTContentGroupItem::addChildren(LOTGroupData *data)
|
|||||||
{
|
{
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
||||||
for (auto i : data->mChildren) {
|
for (auto &i : data->mChildren) {
|
||||||
LOTData * data = i.get();
|
auto content = LOTShapeLayerItem::createContentItem(i.get());
|
||||||
LOTContentItem *content = LOTShapeLayerItem::createContentItem(data);
|
if (content) mContents.push_back(std::move(content));
|
||||||
if (content) mContents.push_back(content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOTContentGroupItem::~LOTContentGroupItem()
|
|
||||||
{
|
|
||||||
for (auto i : mContents) {
|
|
||||||
delete i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +583,7 @@ void LOTContentGroupItem::paintOperationHelper(
|
|||||||
{
|
{
|
||||||
int curOpCount = list.size();
|
int curOpCount = list.size();
|
||||||
for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
|
for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
|
||||||
auto child = *i;
|
auto child = (*i).get();
|
||||||
if (auto pathNode = dynamic_cast<LOTPathDataItem *>(child)) {
|
if (auto pathNode = dynamic_cast<LOTPathDataItem *>(child)) {
|
||||||
// the node is a path data node add the paint operation list to it.
|
// the node is a path data node add the paint operation list to it.
|
||||||
pathNode->addPaintOperation(list, curOpCount);
|
pathNode->addPaintOperation(list, curOpCount);
|
||||||
@ -638,7 +620,7 @@ void LOTContentGroupItem::trimOperationHelper(std::vector<LOTTrimItem *> &list)
|
|||||||
{
|
{
|
||||||
int curOpCount = list.size();
|
int curOpCount = list.size();
|
||||||
for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
|
for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
|
||||||
auto child = *i;
|
auto child = (*i).get();
|
||||||
if (auto pathNode = dynamic_cast<LOTPathDataItem *>(child)) {
|
if (auto pathNode = dynamic_cast<LOTPathDataItem *>(child)) {
|
||||||
// the node is a path data node add the trim operation list to it.
|
// the node is a path data node add the trim operation list to it.
|
||||||
pathNode->addTrimOperation(list);
|
pathNode->addTrimOperation(list);
|
||||||
|
|||||||
@ -81,14 +81,13 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
std::vector<VDrawable *> mDrawableList;
|
std::vector<VDrawable *> mDrawableList;
|
||||||
std::vector<std::unique_ptr<LOTMaskItem>> mMasks;
|
std::vector<std::unique_ptr<LOTMaskItem>> mMasks;
|
||||||
LOTLayerData *mLayerData;
|
LOTLayerData *mLayerData{nullptr};
|
||||||
LOTLayerItem *mParentLayer;
|
LOTLayerItem *mParentLayer{nullptr};
|
||||||
LOTLayerItem *mPrecompLayer;
|
LOTLayerItem *mPrecompLayer{nullptr};
|
||||||
VMatrix mCombinedMatrix;
|
VMatrix mCombinedMatrix;
|
||||||
float mCombinedAlpha;
|
float mCombinedAlpha{0.0};
|
||||||
int mFrameNo;
|
int mFrameNo{-1};
|
||||||
DirtyFlag mDirtyFlag;
|
DirtyFlag mDirtyFlag{DirtyFlagBit::All};
|
||||||
bool mVisible;
|
|
||||||
bool mStatic;
|
bool mStatic;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,13 +121,12 @@ class LOTContentGroupItem;
|
|||||||
class LOTShapeLayerItem: public LOTLayerItem
|
class LOTShapeLayerItem: public LOTLayerItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~LOTShapeLayerItem();
|
|
||||||
LOTShapeLayerItem(LOTLayerData *layerData);
|
LOTShapeLayerItem(LOTLayerData *layerData);
|
||||||
static LOTContentItem * createContentItem(LOTData *contentData);
|
static std::unique_ptr<LOTContentItem> createContentItem(LOTData *contentData);
|
||||||
void renderList(std::vector<VDrawable *> &list)final;
|
void renderList(std::vector<VDrawable *> &list)final;
|
||||||
protected:
|
protected:
|
||||||
void updateContent() final;
|
void updateContent() final;
|
||||||
LOTContentGroupItem *mRoot;
|
std::unique_ptr<LOTContentGroupItem> mRoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LOTNullLayerItem: public LOTLayerItem
|
class LOTNullLayerItem: public LOTLayerItem
|
||||||
@ -189,7 +187,6 @@ public:
|
|||||||
class LOTContentGroupItem: public LOTContentItem
|
class LOTContentGroupItem: public LOTContentItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~LOTContentGroupItem();
|
|
||||||
LOTContentGroupItem(LOTShapeGroupData *data);
|
LOTContentGroupItem(LOTShapeGroupData *data);
|
||||||
void addChildren(LOTGroupData *data);
|
void addChildren(LOTGroupData *data);
|
||||||
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) final;
|
void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha, const DirtyFlag &flag) final;
|
||||||
@ -200,7 +197,7 @@ private:
|
|||||||
void paintOperationHelper(std::vector<LOTPaintDataItem *> &list);
|
void paintOperationHelper(std::vector<LOTPaintDataItem *> &list);
|
||||||
void trimOperationHelper(std::vector<LOTTrimItem *> &list);
|
void trimOperationHelper(std::vector<LOTTrimItem *> &list);
|
||||||
LOTShapeGroupData *mData;
|
LOTShapeGroupData *mData;
|
||||||
std::vector<LOTContentItem *> mContents;
|
std::vector<std::unique_ptr<LOTContentItem>> mContents;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LOTPathDataItem : public LOTContentItem
|
class LOTPathDataItem : public LOTContentItem
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user