-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathChatBackgroundPattern.h
More file actions
74 lines (60 loc) · 2.38 KB
/
Copy pathChatBackgroundPattern.h
File metadata and controls
74 lines (60 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include "ChatBackgroundPattern.g.h"
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Foundation.Numerics.h>
#include <winrt/Windows.UI.Composition.h>
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::Foundation::Numerics;
using namespace winrt::Windows::UI::Composition;
namespace winrt::Telegram::Native::implementation
{
inline static float2 ComputeRenderSize(float width, float height, float rasterizationScale)
{
auto scale = (int)(rasterizationScale * 100);
auto dpi = 0.25f * rasterizationScale;
auto factor = 1.0f / rasterizationScale;
return float2(width * dpi * factor, height * dpi * factor);
}
inline static float2 ComputeRenderPhysicalSize(float width, float height, float rasterizationScale)
{
auto scale = (int)(rasterizationScale * 100);
auto dpi = 0.25f * rasterizationScale;
return float2(width * dpi, height * dpi);
}
struct ChatBackgroundPattern : ChatBackgroundPatternT<ChatBackgroundPattern>
{
ChatBackgroundPattern(ICompositionSurface surface)
: m_surface(surface)
, m_renderSize(0, 0)
, m_renderPhysicalSize(0, 0)
, m_naturalSize(0, 0)
, m_symbols(winrt::single_threaded_vector<ChatBackgroundSymbol>())
{
}
ChatBackgroundPattern(ICompositionSurface surface, float width, float height, float rasterizationScale, IVector<ChatBackgroundSymbol> patterns)
: m_surface(surface)
, m_renderSize(ComputeRenderSize(width, height, rasterizationScale))
, m_renderPhysicalSize(ComputeRenderPhysicalSize(width, height, rasterizationScale))
, m_naturalSize(width, height)
, m_symbols(patterns)
{
}
ICompositionSurface Surface();
float2 RenderSize();
float2 RenderPhysicalSize();
float2 NaturalSize();
IVector<ChatBackgroundSymbol> Symbols();
private:
ICompositionSurface m_surface;
float2 m_renderSize;
float2 m_renderPhysicalSize;
float2 m_naturalSize;
IVector<ChatBackgroundSymbol> m_symbols;
};
}
namespace winrt::Telegram::Native::factory_implementation
{
struct ChatBackgroundPattern : ChatBackgroundPatternT<ChatBackgroundPattern, implementation::ChatBackgroundPattern>
{
};
}