Use unique_id for tiles instead of PeerData*.

This commit is contained in:
John Preston 2021-05-29 22:58:11 +04:00
parent e1614a280f
commit 0771fc14db
3 changed files with 14 additions and 8 deletions

View file

@ -89,8 +89,6 @@ public:
[[nodiscard]] rpl::producer<VideoQualityRequest> qualityRequests() const;
[[nodiscard]] rpl::producer<bool> mouseInsideValue() const;
[[nodiscard]] uint32 defaultFramebufferObject() const;
[[nodiscard]] rpl::lifetime &lifetime();
private:
@ -136,8 +134,8 @@ private:
[[nodiscard]] Ui::GL::ChosenRenderer chooseRenderer(
Ui::GL::Capabilities capabilities);
bool _opengl = false;
PanelMode _mode = PanelMode();
bool _opengl = false;
bool _geometryStaleAfterModeChange = false;
const std::unique_ptr<Ui::RpWidgetWrap> _content;
std::vector<std::unique_ptr<VideoTile>> _tiles;

View file

@ -936,13 +936,15 @@ void Viewport::RendererGL::validateDatas() {
if (width > available) {
available = width;
}
const auto peer = tiles[i]->row()->peer();
const auto j = ranges::find(_tileData, peer, &TileData::peer);
const auto id = quintptr(tiles[i]->track().get());
const auto j = ranges::find(_tileData, id, &TileData::id);
if (j != end(_tileData)) {
j->stale = false;
const auto index = (j - begin(_tileData));
_tileDataIndices[i] = index;
if (peer->nameVersion != j->nameVersion
const auto peer = tiles[i]->row()->peer();
if (peer != j->peer
|| peer->nameVersion != j->nameVersion
|| width != j->nameRect.width()) {
const auto nameTop = index * nameHeight;
j->nameRect = QRect(0, nameTop, width, nameHeight);
@ -963,6 +965,7 @@ void Viewport::RendererGL::validateDatas() {
if (_tileDataIndices[i] >= 0) {
continue;
}
const auto id = quintptr(tiles[i]->track().get());
const auto peer = tiles[i]->row()->peer();
auto index = int(_tileData.size());
maybeStaleAfter = ranges::find(
@ -972,12 +975,16 @@ void Viewport::RendererGL::validateDatas() {
&TileData::stale);
if (maybeStaleAfter != maybeStaleEnd) {
index = (maybeStaleAfter - begin(_tileData));
maybeStaleAfter->id = id;
maybeStaleAfter->peer = peer;
maybeStaleAfter->stale = false;
request.updating = true;
} else {
// This invalidates maybeStale*, but they're already equal.
_tileData.push_back({ .peer = peer });
_tileData.push_back({
.id = id,
.peer = peer,
});
}
_tileData[index].nameVersion = peer->nameVersion;
_tileData[index].nameRect = QRect(

View file

@ -47,13 +47,14 @@ public:
private:
struct TileData {
not_null<PeerData*> peer;
quintptr id = 0;
Ui::GL::Textures<5> textures;
Ui::GL::Framebuffers<2> framebuffers;
mutable int textureIndex = 0;
mutable int trackIndex = -1;
Ui::Animations::Simple outlined;
QRect nameRect;
not_null<PeerData*> peer;
int nameVersion = 0;
bool stale = false;
bool outline = false;