mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
lottie/vector: Added reset api to VBitmap class
This commit is contained in:
parent
4bc1a193af
commit
5f6e550111
@ -40,6 +40,13 @@ struct VBitmap::Impl {
|
|||||||
mOwnData(true),
|
mOwnData(true),
|
||||||
mRoData(false)
|
mRoData(false)
|
||||||
{
|
{
|
||||||
|
reset(width, height, format);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(uint width, uint height, VBitmap::Format format)
|
||||||
|
{
|
||||||
|
if (mOwnData && mData) delete(mData);
|
||||||
|
|
||||||
mDepth = depth(format);
|
mDepth = depth(format);
|
||||||
uint stride = ((width * mDepth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 4)
|
uint stride = ((width * mDepth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 4)
|
||||||
|
|
||||||
@ -49,11 +56,6 @@ struct VBitmap::Impl {
|
|||||||
mStride = stride;
|
mStride = stride;
|
||||||
mBytes = mStride * mHeight;
|
mBytes = mStride * mHeight;
|
||||||
mData = reinterpret_cast<uchar *>(::operator new(mBytes));
|
mData = reinterpret_cast<uchar *>(::operator new(mBytes));
|
||||||
|
|
||||||
if (!mData) {
|
|
||||||
// handle malloc failure
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Impl(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format):
|
Impl(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format):
|
||||||
@ -150,6 +152,20 @@ VBitmap::VBitmap(uchar *data, uint width, uint height, uint bytesPerLine,
|
|||||||
mImpl = std::make_shared<Impl>(data, width, height, bytesPerLine, format);
|
mImpl = std::make_shared<Impl>(data, width, height, bytesPerLine, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VBitmap::reset(uint w, uint h, VBitmap::Format format)
|
||||||
|
{
|
||||||
|
if (mImpl) {
|
||||||
|
if (w == mImpl->width() &&
|
||||||
|
h == mImpl->height() &&
|
||||||
|
format == mImpl->format()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mImpl->reset(w, h, format);
|
||||||
|
} else {
|
||||||
|
mImpl = std::make_shared<Impl>(w, h, format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint VBitmap::stride() const
|
uint VBitmap::stride() const
|
||||||
{
|
{
|
||||||
return mImpl ? mImpl->stride() : 0;
|
return mImpl ? mImpl->stride() : 0;
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
VBitmap(uint w, uint h, VBitmap::Format format);
|
VBitmap(uint w, uint h, VBitmap::Format format);
|
||||||
VBitmap(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format);
|
VBitmap(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format);
|
||||||
|
|
||||||
|
void reset(uint w, uint h, VBitmap::Format format=Format::ARGB32_Premultiplied);
|
||||||
uint stride() const;
|
uint stride() const;
|
||||||
uint width() const;
|
uint width() const;
|
||||||
uint height() const;
|
uint height() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user