mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support selecting Webm stickers.
This commit is contained in:
parent
044c7f3ce9
commit
2f9c39fe53
5 changed files with 26 additions and 5 deletions
|
@ -391,7 +391,10 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
|
||||||
auto request = ::Media::Streaming::FrameRequest();
|
auto request = ::Media::Streaming::FrameRequest();
|
||||||
request.outer = QSize(usew, painth) * cIntRetinaFactor();
|
request.outer = QSize(usew, painth) * cIntRetinaFactor();
|
||||||
request.resize = QSize(_thumbw, _thumbh) * cIntRetinaFactor();
|
request.resize = QSize(_thumbw, _thumbh) * cIntRetinaFactor();
|
||||||
request.keepAlpha = !isRound && unwrapped;
|
request.keepAlpha = (sticker != nullptr);
|
||||||
|
if (sticker && context.selected()) {
|
||||||
|
request.colored = context.st->msgStickerOverlay()->c;
|
||||||
|
}
|
||||||
request.corners = roundCorners;
|
request.corners = roundCorners;
|
||||||
request.radius = roundRadius;
|
request.radius = roundRadius;
|
||||||
if (!activeRoundPlaying && activeOwnPlaying->instance.playerLocked()) {
|
if (!activeRoundPlaying && activeOwnPlaying->instance.playerLocked()) {
|
||||||
|
@ -442,8 +445,13 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
|
||||||
ensureDataMediaCreated();
|
ensureDataMediaCreated();
|
||||||
const auto size = QSize(_thumbw, _thumbh);
|
const auto size = QSize(_thumbw, _thumbh);
|
||||||
const auto args = Images::PrepareArgs{
|
const auto args = Images::PrepareArgs{
|
||||||
.options = Images::RoundOptions(roundRadius, roundCorners),
|
.colored = ((sticker && context.selected())
|
||||||
.outer = QSize(usew, painth),
|
? &context.st->msgStickerOverlay()
|
||||||
|
: nullptr),
|
||||||
|
.options = (sticker
|
||||||
|
? Images::Option::TransparentBackground
|
||||||
|
: Images::RoundOptions(roundRadius, roundCorners)),
|
||||||
|
.outer = sticker ? QSize() : QSize(usew, painth),
|
||||||
};
|
};
|
||||||
if (const auto good = _dataMedia->goodThumbnail()) {
|
if (const auto good = _dataMedia->goodThumbnail()) {
|
||||||
p.drawPixmap(rthumb.topLeft(), good->pixSingle(size, args));
|
p.drawPixmap(rthumb.topLeft(), good->pixSingle(size, args));
|
||||||
|
|
|
@ -59,6 +59,7 @@ struct VideoInformation {
|
||||||
QSize size;
|
QSize size;
|
||||||
QImage cover;
|
QImage cover;
|
||||||
int rotation = 0;
|
int rotation = 0;
|
||||||
|
bool alpha = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AudioInformation {
|
struct AudioInformation {
|
||||||
|
@ -120,6 +121,7 @@ struct FrameRequest {
|
||||||
QSize outer;
|
QSize outer;
|
||||||
ImageRoundRadius radius = ImageRoundRadius();
|
ImageRoundRadius radius = ImageRoundRadius();
|
||||||
RectParts corners = RectPart::AllCorners;
|
RectParts corners = RectPart::AllCorners;
|
||||||
|
QColor colored = QColor(0, 0, 0, 0);
|
||||||
bool requireARGB32 = true;
|
bool requireARGB32 = true;
|
||||||
bool keepAlpha = false;
|
bool keepAlpha = false;
|
||||||
bool strict = true;
|
bool strict = true;
|
||||||
|
@ -139,6 +141,7 @@ struct FrameRequest {
|
||||||
&& (outer == other.outer)
|
&& (outer == other.outer)
|
||||||
&& (radius == other.radius)
|
&& (radius == other.radius)
|
||||||
&& (corners == other.corners)
|
&& (corners == other.corners)
|
||||||
|
&& (colored == other.colored)
|
||||||
&& (keepAlpha == other.keepAlpha)
|
&& (keepAlpha == other.keepAlpha)
|
||||||
&& (requireARGB32 == other.requireARGB32);
|
&& (requireARGB32 == other.requireARGB32);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +152,8 @@ struct FrameRequest {
|
||||||
[[nodiscard]] bool goodFor(const FrameRequest &other) const {
|
[[nodiscard]] bool goodFor(const FrameRequest &other) const {
|
||||||
return (requireARGB32 == other.requireARGB32)
|
return (requireARGB32 == other.requireARGB32)
|
||||||
&& (keepAlpha == other.keepAlpha)
|
&& (keepAlpha == other.keepAlpha)
|
||||||
&& ((*this == other) || (strict && !other.strict));
|
&& (colored == other.colored)
|
||||||
|
&& ((strict && !other.strict) || (*this == other));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,6 +181,7 @@ struct FrameWithInfo {
|
||||||
FrameYUV420 *yuv420 = nullptr;
|
FrameYUV420 *yuv420 = nullptr;
|
||||||
FrameFormat format = FrameFormat::None;
|
FrameFormat format = FrameFormat::None;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
bool alpha = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Streaming
|
} // namespace Streaming
|
||||||
|
|
|
@ -63,6 +63,7 @@ void SaveValidVideoInformation(
|
||||||
to.size = from.size;
|
to.size = from.size;
|
||||||
to.cover = std::move(from.cover);
|
to.cover = std::move(from.cover);
|
||||||
to.rotation = from.rotation;
|
to.rotation = from.rotation;
|
||||||
|
to.alpha = from.alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveValidStartInformation(Information &to, Information &&from) {
|
void SaveValidStartInformation(Information &to, Information &&from) {
|
||||||
|
|
|
@ -92,7 +92,9 @@ bool GoodForRequest(
|
||||||
bool hasAlpha,
|
bool hasAlpha,
|
||||||
int rotation,
|
int rotation,
|
||||||
const FrameRequest &request) {
|
const FrameRequest &request) {
|
||||||
if (image.isNull() || (hasAlpha && !request.keepAlpha)) {
|
if (image.isNull()
|
||||||
|
|| (hasAlpha && !request.keepAlpha)
|
||||||
|
|| request.colored.alpha() != 0) {
|
||||||
return false;
|
return false;
|
||||||
} else if (request.resize.isEmpty()) {
|
} else if (request.resize.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -321,6 +323,9 @@ QImage PrepareByRequest(
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
ApplyFrameRounding(storage, request);
|
ApplyFrameRounding(storage, request);
|
||||||
|
if (request.colored.alpha() != 0) {
|
||||||
|
storage = Images::Colored(std::move(storage), request.colored);
|
||||||
|
}
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -661,6 +661,7 @@ void VideoTrackObject::callReady() {
|
||||||
}
|
}
|
||||||
data.cover = frame->original;
|
data.cover = frame->original;
|
||||||
data.rotation = _stream.rotation;
|
data.rotation = _stream.rotation;
|
||||||
|
data.alpha = frame->alpha;
|
||||||
data.state.duration = _stream.duration;
|
data.state.duration = _stream.duration;
|
||||||
data.state.position = _syncTimePoint.trackTime;
|
data.state.position = _syncTimePoint.trackTime;
|
||||||
data.state.receivedTill = _readTillEnd
|
data.state.receivedTill = _readTillEnd
|
||||||
|
@ -1166,6 +1167,7 @@ FrameWithInfo VideoTrack::frameWithInfo(const Instance *instance) {
|
||||||
.yuv420 = &data.frame->yuv420,
|
.yuv420 = &data.frame->yuv420,
|
||||||
.format = data.frame->format,
|
.format = data.frame->format,
|
||||||
.index = data.index,
|
.index = data.index,
|
||||||
|
.alpha = data.frame->alpha,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue