From 53a3d0038c1f4f790a4c38780950d33dbc00cab7 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Fri, 28 Jun 2019 17:32:21 +0200
Subject: [PATCH] Fix build for Xcode.

---
 Telegram/SourceFiles/base/bytes.h                   |  2 ++
 Telegram/SourceFiles/base/flat_map.h                | 12 ++++++------
 Telegram/SourceFiles/chat_helpers/stickers.cpp      |  2 +-
 Telegram/SourceFiles/lottie/lottie_cache.cpp        |  3 ++-
 Telegram/SourceFiles/lottie/lottie_cache.h          |  1 -
 Telegram/SourceFiles/lottie/lottie_multi_player.cpp |  2 +-
 Telegram/ThirdParty/crl                             |  2 +-
 7 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/Telegram/SourceFiles/base/bytes.h b/Telegram/SourceFiles/base/bytes.h
index 9b062f1ce..3810e1b4a 100644
--- a/Telegram/SourceFiles/base/bytes.h
+++ b/Telegram/SourceFiles/base/bytes.h
@@ -10,6 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 #include "base/basic_types.h"
 #include <gsl/gsl>
 #include <gsl/gsl_byte>
+#include <vector>
+#include <array>
 
 namespace bytes {
 
diff --git a/Telegram/SourceFiles/base/flat_map.h b/Telegram/SourceFiles/base/flat_map.h
index 18a9ede3d..9c8a9bcd7 100644
--- a/Telegram/SourceFiles/base/flat_map.h
+++ b/Telegram/SourceFiles/base/flat_map.h
@@ -481,7 +481,7 @@ public:
 		return compare()(key, where->first) ? impl().end() : where;
 	}
 
-	template <typename OtherKey, typename = typename Compare::is_transparent>
+	template <typename OtherKey>
 	iterator findFirst(const OtherKey &key) {
 		if (empty()
 			|| compare()(key, front().first)
@@ -492,7 +492,7 @@ public:
 		return compare()(key, where->first) ? impl().end() : where;
 	}
 
-	template <typename OtherKey, typename = typename Compare::is_transparent>
+	template <typename OtherKey>
 	const_iterator findFirst(const OtherKey &key) const {
 		if (empty()
 			|| compare()(key, front().first)
@@ -810,13 +810,13 @@ public:
 	const_iterator find(const Key &key) const {
 		return this->findFirst(key);
 	}
-	template <typename OtherKey, typename = typename Compare::is_transparent>
+	template <typename OtherKey>
 	iterator find(const OtherKey &key) {
-		return this->findFirst<OtherKey>(key);
+		return this->template findFirst<OtherKey>(key);
 	}
-	template <typename OtherKey, typename = typename Compare::is_transparent>
+	template <typename OtherKey>
 	const_iterator find(const OtherKey &key) const {
-		return this->findFirst<OtherKey>(key);
+		return this->template findFirst<OtherKey>(key);
 	}
 
 	Type &operator[](const Key &key) {
diff --git a/Telegram/SourceFiles/chat_helpers/stickers.cpp b/Telegram/SourceFiles/chat_helpers/stickers.cpp
index e8dc619a1..859658bf2 100644
--- a/Telegram/SourceFiles/chat_helpers/stickers.cpp
+++ b/Telegram/SourceFiles/chat_helpers/stickers.cpp
@@ -1101,7 +1101,7 @@ auto LottieFromDocument(
 		QSize box) {
 	const auto data = document->data();
 	const auto filepath = document->filepath();
-	if (box.width() & box.height() > kDontCacheLottieAfterArea) {
+	if (box.width() * box.height() > kDontCacheLottieAfterArea) {
 		// Don't use frame caching for large stickers.
 		return method(
 			Lottie::ReadContent(data, filepath),
diff --git a/Telegram/SourceFiles/lottie/lottie_cache.cpp b/Telegram/SourceFiles/lottie/lottie_cache.cpp
index 0167d01f9..2b1892d2f 100644
--- a/Telegram/SourceFiles/lottie/lottie_cache.cpp
+++ b/Telegram/SourceFiles/lottie/lottie_cache.cpp
@@ -483,6 +483,7 @@ bool Cache::readHeader(const FrameRequest &request) {
 		|| request.size(original) != size) {
 		return false;
 	}
+	_encoder = static_cast<Encoder>(encoder);
 	_size = size;
 	_original = original;
 	_frameRate = frameRate;
@@ -608,7 +609,7 @@ void Cache::writeHeader() {
 	QDataStream stream(&_data, QIODevice::WriteOnly);
 
 	stream
-		<< static_cast<qint32>(Encoder::YUV420A4_LZ4)
+		<< static_cast<qint32>(_encoder)
 		<< _size
 		<< _original
 		<< qint32(_frameRate)
diff --git a/Telegram/SourceFiles/lottie/lottie_cache.h b/Telegram/SourceFiles/lottie/lottie_cache.h
index 983a99fa5..c3a8eebeb 100644
--- a/Telegram/SourceFiles/lottie/lottie_cache.h
+++ b/Telegram/SourceFiles/lottie/lottie_cache.h
@@ -121,7 +121,6 @@ private:
 	int _offsetFrameIndex = 0;
 	Encoder _encoder = Encoder::YUV420A4_LZ4;
 	FnMut<void(QByteArray &&cached)> _put;
-	bool _changed = false;
 
 };
 
diff --git a/Telegram/SourceFiles/lottie/lottie_multi_player.cpp b/Telegram/SourceFiles/lottie/lottie_multi_player.cpp
index badb8c789..03fae88f2 100644
--- a/Telegram/SourceFiles/lottie/lottie_multi_player.cpp
+++ b/Telegram/SourceFiles/lottie/lottie_multi_player.cpp
@@ -172,7 +172,7 @@ void MultiPlayer::checkNextFrameRender() {
 void MultiPlayer::updateFrameRequest(
 		not_null<const Animation*> animation,
 		const FrameRequest &request) {
-	const auto i = _active.find(animation.get());
+	const auto i = _active.find(animation);
 	Assert(i != _active.end());
 
 	_renderer->updateFrameRequest(i->second, request);
diff --git a/Telegram/ThirdParty/crl b/Telegram/ThirdParty/crl
index 1f0d4470b..9ea870038 160000
--- a/Telegram/ThirdParty/crl
+++ b/Telegram/ThirdParty/crl
@@ -1 +1 @@
-Subproject commit 1f0d4470b1234e31c75a4186abd59759d8142414
+Subproject commit 9ea870038a2a667add7f621be6252db909068386