2019-05-10 16:58:44 +02:00
|
|
|
//
|
2020-01-01 02:23:48 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
2019-05-10 16:58:44 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/BackgroundType.h"
|
|
|
|
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(const BackgroundType &type, StorerT &storer) {
|
2019-12-22 19:01:51 +01:00
|
|
|
bool has_fill = type.fill.top_color != 0 || type.fill.bottom_color != 0;
|
2019-05-10 16:58:44 +02:00
|
|
|
bool has_intensity = type.intensity != 0;
|
2019-12-22 19:01:51 +01:00
|
|
|
bool is_gradient = !type.fill.is_solid();
|
2019-05-10 16:58:44 +02:00
|
|
|
BEGIN_STORE_FLAGS();
|
|
|
|
STORE_FLAG(type.is_blurred);
|
|
|
|
STORE_FLAG(type.is_moving);
|
2019-12-22 19:01:51 +01:00
|
|
|
STORE_FLAG(has_fill);
|
2019-05-10 16:58:44 +02:00
|
|
|
STORE_FLAG(has_intensity);
|
2019-12-22 19:01:51 +01:00
|
|
|
STORE_FLAG(is_gradient);
|
2019-05-10 16:58:44 +02:00
|
|
|
END_STORE_FLAGS();
|
|
|
|
store(type.type, storer);
|
2019-12-22 19:01:51 +01:00
|
|
|
if (has_fill) {
|
|
|
|
store(type.fill.top_color, storer);
|
|
|
|
if (is_gradient) {
|
|
|
|
store(type.fill.bottom_color, storer);
|
2019-12-22 20:32:01 +01:00
|
|
|
store(type.fill.rotation_angle, storer);
|
2019-12-22 19:01:51 +01:00
|
|
|
}
|
2019-05-10 16:58:44 +02:00
|
|
|
}
|
|
|
|
if (has_intensity) {
|
|
|
|
store(type.intensity, storer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(BackgroundType &type, ParserT &parser) {
|
2019-12-22 19:01:51 +01:00
|
|
|
bool has_fill;
|
2019-05-10 16:58:44 +02:00
|
|
|
bool has_intensity;
|
2019-12-22 19:01:51 +01:00
|
|
|
bool is_gradient;
|
2019-05-10 16:58:44 +02:00
|
|
|
BEGIN_PARSE_FLAGS();
|
|
|
|
PARSE_FLAG(type.is_blurred);
|
|
|
|
PARSE_FLAG(type.is_moving);
|
2019-12-22 19:01:51 +01:00
|
|
|
PARSE_FLAG(has_fill);
|
2019-05-10 16:58:44 +02:00
|
|
|
PARSE_FLAG(has_intensity);
|
2019-12-22 19:01:51 +01:00
|
|
|
PARSE_FLAG(is_gradient);
|
2019-05-10 16:58:44 +02:00
|
|
|
END_PARSE_FLAGS();
|
|
|
|
parse(type.type, parser);
|
2019-12-22 19:01:51 +01:00
|
|
|
if (has_fill) {
|
|
|
|
parse(type.fill.top_color, parser);
|
|
|
|
if (is_gradient) {
|
|
|
|
parse(type.fill.bottom_color, parser);
|
2019-12-22 20:32:01 +01:00
|
|
|
parse(type.fill.rotation_angle, parser);
|
2019-12-22 19:01:51 +01:00
|
|
|
} else {
|
|
|
|
type.fill.bottom_color = type.fill.top_color;
|
|
|
|
}
|
2019-05-10 16:58:44 +02:00
|
|
|
}
|
|
|
|
if (has_intensity) {
|
|
|
|
parse(type.intensity, parser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|