Ocean
Loading...
Searching...
No Matches
TestFrameBlender.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TEST_TESTCV_TEST_FRAME_BLENDER_H
9#define META_OCEAN_TEST_TESTCV_TEST_FRAME_BLENDER_H
10
12
14
15namespace Ocean
16{
17
18namespace Test
19{
20
21namespace TestCV
22{
23
24/**
25 * This class implements a test for the frame blender class.
26 * @ingroup testcv
27 */
28class OCEAN_TEST_CV_EXPORT TestFrameBlender
29{
30 public:
31
32 /**
33 * Tests the frame blender functions.
34 * @param testDuration Test duration in seconds, with range (0, infinity)
35 * @param worker The worker object to distribute the computation
36 * @param selector Test selector for filtering sub-tests; default runs all tests
37 * @return True, if this test succeeded
38 */
39 static bool test(const double testDuration, Worker& worker, const TestSelector& selector = TestSelector());
40
41 /**
42 * Tests the blending two images with constant alpha value.
43 * @param testDuration Test duration in seconds, with range (0, infinity)
44 * @param worker The worker object to distribute the computation
45 * @return True, if this test succeeded
46 */
47 static bool testConstantAlpha(const double testDuration, Worker& worker);
48
49 /**
50 * Tests the blending two images with a separate alpha channel.
51 * @param testDuration Test duration in seconds, with range (0, infinity)
52 * @param worker The worker object to distribute the computation
53 * @return True, if this test succeeded
54 * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
55 */
56 template <bool tTransparentIs0xFF>
57 static bool testSeparateAlphaChannel(const double testDuration, Worker& worker);
58
59 /**
60 * Tests the blend function with alpha channel at the front or at the back.
61 * @param testDuration Test duration in seconds, with range (0, infinity)
62 * @param worker The worker object to distribute the computation
63 * @return True, if this test succeeded
64 * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
65 */
66 template <bool tTransparentIs0xFF>
67 static bool testBlend(const double testDuration, Worker& worker);
68
69 /**
70 * Tests the blend function with constant value.
71 * @param testDuration Test duration in seconds, with range (0, infinity)
72 * @param worker The worker object to distribute the computation
73 * @return True, if this test succeeded
74 * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
75 */
76 template <bool tTransparentIs0xFF>
77 static bool testBlendWithConstantValue(const double testDuration, Worker& worker);
78
79 protected:
80
81 /**
82 * Tests the blending two images with a separate alpha channel.
83 * @param testDuration Test duration in seconds, with range (0, infinity)
84 * @param worker The worker object to distribute the computation
85 * @return True, if this test succeeded
86 * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
87 */
88 template <bool tTransparentIs0xFF>
89 static bool testSeparateAlphaChannelSubFrame(const double testDuration, Worker& worker);
90
91 /**
92 * Tests the blending two images with a separate alpha channel.
93 * @param testDuration Test duration in seconds, with range (0, infinity)
94 * @param worker The worker object to distribute the computation
95 * @return True, if this test succeeded
96 * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
97 */
98 template <bool tTransparentIs0xFF>
99 static bool testSeparateAlphaChannelFullFrame(const double testDuration, Worker& worker);
100
101 /**
102 * Tests the sub-region transparent blend function.
103 * @param sourcePixelFormat Source pixel format
104 * @param targetPixelFormat Target pixel format
105 * @param targetWidth Width of the target test frame in pixel
106 * @param targetHeight Height of the target test frame in pixel
107 * @param testDuration Test duration in seconds, with range (0, infinity)
108 * @param worker The worker object to distribute the computation
109 * @return True, if this test succeeded
110 * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
111 */
112 template <bool tTransparentIs0xFF>
113 static bool testSubFrame(const FrameType::PixelFormat sourcePixelFormat, const FrameType::PixelFormat targetPixelFormat, const unsigned int targetWidth, const unsigned int targetHeight, const double testDuration, Worker& worker);
114
115 /**
116 * Tests the transparent blend function.
117 * @param sourcePixelFormat Source pixel format
118 * @param targetPixelFormat Target pixel format
119 * @param width The width of the test frame in pixel
120 * @param height The height of the test frame in pixel
121 * @param testDuration Test duration in seconds, with range (0, infinity)
122 * @param worker The worker object to distribute the computation
123 * @return True, if this test succeeded
124 * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
125 */
126 template <bool tTransparentIs0xFF>
127 static bool testFullFrame(const FrameType::PixelFormat sourcePixelFormat, const FrameType::PixelFormat targetPixelFormat, const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
128
129 /**
130 * Validates the blend function with alpha channel.
131 * @param sourceWithAlpha The source frame with alpha channel, must be valid
132 * @param target The target frame, must be valid
133 * @param blendResult The blend result, must be valid
134 * @param sourceLeft Horizontal start position inside the source frame, with range [0, sourceWithAlpha.width() - 1]
135 * @param sourceTop Vertical start position inside the source frame, with range [0, sourceWithAlpha.height() - 1]
136 * @param targetLeft Horizontal start position inside the target frame, with range [0, target.width() - 1]
137 * @param targetTop Vertical start position inside the target frame, with range [0, target.height() - 1]
138 * @param width The width of the blending sub-region in pixel, with range [1, min(sourceWithAlpha.width() - sourceLeft, target.width() - targetLeft)]
139 * @param height The height of the blending sub-region in pixel, with range [1, min(sourceWithAlpha.height() - sourceTop, target.height() - targetTop)]
140 * @return True, if succeeded
141 * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
142 */
143 template <bool tTransparentIs0xFF>
144 static bool validateBlendResult(const Frame& sourceWithAlpha, const Frame& target, const Frame& blendResult, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height);
145};
146
147}
148
149}
150
151}
152
153#endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_BLENDER_H
This class implements Ocean's image class.
Definition Frame.h:1879
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
This class implements a test for the frame blender class.
Definition TestFrameBlender.h:29
static bool test(const double testDuration, Worker &worker, const TestSelector &selector=TestSelector())
Tests the frame blender functions.
static bool testSeparateAlphaChannelSubFrame(const double testDuration, Worker &worker)
Tests the blending two images with a separate alpha channel.
static bool testConstantAlpha(const double testDuration, Worker &worker)
Tests the blending two images with constant alpha value.
static bool validateBlendResult(const Frame &sourceWithAlpha, const Frame &target, const Frame &blendResult, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height)
Validates the blend function with alpha channel.
static bool testSeparateAlphaChannel(const double testDuration, Worker &worker)
Tests the blending two images with a separate alpha channel.
static bool testFullFrame(const FrameType::PixelFormat sourcePixelFormat, const FrameType::PixelFormat targetPixelFormat, const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the transparent blend function.
static bool testBlend(const double testDuration, Worker &worker)
Tests the blend function with alpha channel at the front or at the back.
static bool testBlendWithConstantValue(const double testDuration, Worker &worker)
Tests the blend function with constant value.
static bool testSubFrame(const FrameType::PixelFormat sourcePixelFormat, const FrameType::PixelFormat targetPixelFormat, const unsigned int targetWidth, const unsigned int targetHeight, const double testDuration, Worker &worker)
Tests the sub-region transparent blend function.
static bool testSeparateAlphaChannelFullFrame(const double testDuration, Worker &worker)
Tests the blending two images with a separate alpha channel.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
The namespace covering the entire Ocean framework.
Definition Accessor.h:15