Optimize online dot painting.

This commit is contained in:
John Preston 2019-06-17 16:33:28 +02:00
parent 034bee8fc3
commit 61c66994a2
3 changed files with 34 additions and 34 deletions

View File

@ -34,9 +34,9 @@ dialogsPhotoSize: 46px;
dialogsPhotoPadding: 12px;
dialogsPadding: point(10px, 8px);
dialogsOnlineBadgeSizePadding: 4px;
dialogsOnlineBadgeSize: 8px;
dialogsOnlineBadgeRightSkip: 2px;
dialogsOnlineBadgeStroke: 2px;
dialogsOnlineBadgeSize: 10px;
dialogsOnlineBadgeSkip: point(10px, 12px);
dialogsImportantBarHeight: 37px;

View File

@ -181,21 +181,27 @@ InnerWidget::InnerWidget(
if (peerUpdate.peer->isSelf()) {
return;
}
const auto circleSize = st::dialogsOnlineBadgeSize
+ st::dialogsOnlineBadgeSizePadding;
const auto history = session().data().historyLoaded(peerUpdate.peer);
if (!history) {
return;
}
const auto size = st::dialogsOnlineBadgeSize;
const auto stroke = st::dialogsOnlineBadgeStroke;
const auto skip = st::dialogsOnlineBadgeSkip;
const auto edge = st::dialogsPadding.x() + st::dialogsPhotoSize;
const auto updateRect = QRect(
st::dialogsPadding.x()
+ st::dialogsPhotoSize
- st::dialogsOnlineBadgeRightSkip
- circleSize,
st::dialogsPadding.y()
+ st::dialogsPhotoSize
- circleSize,
circleSize,
circleSize);
edge - skip.x() - size,
edge - skip.y() - size,
size,
size
).marginsAdded(
{ stroke, stroke, stroke, stroke }
).translated(
st::dialogsPadding
);
updateDialogRow(
RowDescriptor(
session().data().history(peerUpdate.peer->id),
history,
FullMsgId()),
updateRect,
UpdateRowSection::Default | UpdateRowSection::Filtered);

View File

@ -260,37 +260,31 @@ void paintRow(
frame.setDevicePixelRatio(cRetinaFactor());
frame.fill(Qt::transparent);
{
const auto size = st::dialogsOnlineBadgeSize;
const auto paddingSize = st::dialogsOnlineBadgeSizePadding;
const auto circleSize = size + paddingSize;
const auto offset = size + paddingSize / 2;
const auto x = st::dialogsPadding.x() + st::dialogsPhotoSize - st::dialogsOnlineBadgeRightSkip - size;
const auto y = st::dialogsPadding.y() + st::dialogsPhotoSize - size;
Painter q(&frame);
PainterHighQualityEnabler hq(q);
from->paintUserpicLeft(
q,
0,
0,
fullWidth,
st::dialogsPhotoSize);
q.setPen(Qt::NoPen);
q.setBrush(Qt::transparent);
q.setCompositionMode(QPainter::CompositionMode_SourceOut);
q.drawEllipse(
x - circleSize,
y - circleSize,
circleSize,
circleSize);
PainterHighQualityEnabler hq(q);
q.setCompositionMode(QPainter::CompositionMode_Source);
const auto size = st::dialogsOnlineBadgeSize;
const auto stroke = st::dialogsOnlineBadgeStroke;
const auto skip = st::dialogsOnlineBadgeSkip;
const auto edge = st::dialogsPadding.x() + st::dialogsPhotoSize;
auto pen = QPen(Qt::transparent);
pen.setWidth(stroke);
q.setPen(pen);
q.setBrush(active
? st::dialogsOnlineBadgeFgActive
: st::dialogsOnlineBadgeFg);
q.setCompositionMode(QPainter::CompositionMode_Source);
q.drawEllipse(
x - offset,
y - offset,
edge - skip.x() - size,
edge - skip.y() - size,
size,
size);
}