-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame.cpp
More file actions
34 lines (29 loc) · 918 Bytes
/
Frame.cpp
File metadata and controls
34 lines (29 loc) · 918 Bytes
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
#include "Frame.h"
//-- struct FrameSize --//
FrameSize FrameSize::scaled(const FrameScale & scale) const
{
if(scale.num > 0 || scale.den > 0)
return {width * scale.num / scale.den,
height * scale.num / scale.den};
if(scale.width > 0 || scale.height > 0)
return {scale.width, scale.height};
return *this;
}
FrameSize FrameSize::aligned(unsigned align) const
{
align--;
align |= (align >> 1);
align |= (align >> 2);
align |= (align >> 4);
align |= (align >> 8);
align |= (align >> 16);
return {width & ~align, height & ~align};
}
FrameSize FrameSize::bounded(const FrameSize & minSize, const FrameSize & maxSize) const
{
if(width < minSize.width || height < minSize.height)
return minSize;
if(width > maxSize.width || height > maxSize.height)
return maxSize;
return *this;
}