FCT
载入中...
搜索中...
未找到
RenderGraph_TextureSize.h
浏览该文件的文档.
1#ifndef RENDERGRAPH_TEXTURESIZE_H
2#define RENDERGRAPH_TEXTURESIZE_H
3namespace FCT {
5 {
6 enum class Type {
9 Undefined // 等同于FullSize
10 };
11
13 uint32_t width;
14 uint32_t height;
15 //TextureSize = Target * RelativeScale
18
19 TextureSize(uint32_t w, uint32_t h) noexcept
21
22 TextureSize(const Fraction& relW, const Fraction& relH) noexcept
24
25 TextureSize(int32_t numW, int32_t denW, int32_t numH, int32_t denH) noexcept
26 : type(Type::Relative), width(0), height(0),
27 relativeWidth(numW, denW), relativeHeight(numH, denH) {}
28
29 TextureSize() noexcept
31
32 static TextureSize Absolute(uint32_t w, uint32_t h) {
33 return TextureSize(w, h);
34 }
35
36 static TextureSize Relative(const Fraction& w, const Fraction& h) {
37 return TextureSize(w, h);
38 }
39
40 static TextureSize Relative(int32_t numW, int32_t denW, int32_t numH, int32_t denH) {
41 return TextureSize(numW, denW, numH, denH);
42 }
43
45 return TextureSize(Fraction(1), Fraction(1));
46 }
47
49 return TextureSize(Fraction(1, 2), Fraction(1, 2));
50 }
51
53 return TextureSize(Fraction(1, 4), Fraction(1, 4));
54 }
55
56 // 添加一些常用的分数大小
58 return TextureSize(Fraction(1, 3), Fraction(1, 3));
59 }
60
62 return TextureSize(Fraction(2, 3), Fraction(2, 3));
63 }
64
66 return TextureSize(Fraction(3, 4), Fraction(3, 4));
67 }
68
69 // 检查是否为单位大小(1:1)
70 bool isFullSize() const noexcept {
71 return type == Type::Relative &&
72 relativeWidth.isUnit() && relativeHeight.isUnit();
73 }
74
75 // 获取相对大小的浮点值(用于兼容性)
76 float getRelativeWidthFloat() const noexcept {
77 return relativeWidth.toFloat();
78 }
79
80 float getRelativeHeightFloat() const noexcept {
81 return relativeHeight.toFloat();
82 }
83 };
84}
85#endif //RENDERGRAPH_TEXTURESIZE_H
static TextureSize FullSize()
static TextureSize Relative(int32_t numW, int32_t denW, int32_t numH, int32_t denH)
static TextureSize TwoThirdsSize()
static TextureSize ThirdSize()
bool isFullSize() const noexcept
static TextureSize Absolute(uint32_t w, uint32_t h)
TextureSize(const Fraction &relW, const Fraction &relH) noexcept
static TextureSize Relative(const Fraction &w, const Fraction &h)
TextureSize(uint32_t w, uint32_t h) noexcept
float getRelativeHeightFloat() const noexcept
static TextureSize QuarterSize()
static TextureSize ThreeQuartersSize()
TextureSize(int32_t numW, int32_t denW, int32_t numH, int32_t denH) noexcept
float getRelativeWidthFloat() const noexcept
static TextureSize HalfSize()