ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
TestPatternBinding Class Reference

Public Member Functions

 TestPatternBinding (int width, int height)
 ~TestPatternBinding ()
 TestPatternBinding (const TestPatternBinding &)=delete
TestPatternBinding & operator= (const TestPatternBinding &)=delete
bool valid () const
bool render (int width, int height, int index, double time, bool cadence, PatternPixels output)

Detailed Description

Definition at line 12 of file test_pattern.cpp.

Constructor & Destructor Documentation

◆ TestPatternBinding() [1/2]

TestPatternBinding::TestPatternBinding ( int width,
int height )
inline

Definition at line 14 of file test_pattern.cpp.

14 {
15 if (test_pattern_create(width, height, &pattern_) != ASCIICHAT_OK)
16 pattern_ = nullptr;
17 }
unsigned int height
Definition fft.c:23
unsigned int width
Definition fft.c:23
@ ASCIICHAT_OK
Definition error_codes.h:46
asciichat_error_t test_pattern_create(int width, int height, test_pattern_t **out)

References ASCIICHAT_OK, height, test_pattern_create(), and width.

Referenced by operator=(), and TestPatternBinding().

◆ ~TestPatternBinding()

TestPatternBinding::~TestPatternBinding ( )
inline

Definition at line 18 of file test_pattern.cpp.

18 {
19 if (pattern_)
20 test_pattern_destroy(pattern_);
21 }
void test_pattern_destroy(test_pattern_t *p)

References test_pattern_destroy().

◆ TestPatternBinding() [2/2]

TestPatternBinding::TestPatternBinding ( const TestPatternBinding & )
delete

References TestPatternBinding().

Member Function Documentation

◆ operator=()

TestPatternBinding & TestPatternBinding::operator= ( const TestPatternBinding & )
delete

References TestPatternBinding().

◆ render()

bool TestPatternBinding::render ( int width,
int height,
int index,
double time,
bool cadence,
PatternPixels output )
inline

Definition at line 27 of file test_pattern.cpp.

27 {
28 if (!pattern_) {
29 SET_ERRNO(ERROR_INVALID_STATE, "Test pattern is not initialized");
30 return false;
31 }
32 if (width <= 0 || height <= 0 ||
33 static_cast<uint64_t>(width) * static_cast<uint64_t>(height) * 4 != output["length"].as<size_t>()) {
34 SET_ERRNO(ERROR_INVALID_PARAM, "Invalid test pattern image: %dx%d", width, height);
35 return false;
36 }
37 if (test_pattern_resize(pattern_, width, height) != ASCIICHAT_OK ||
38 test_pattern_render(pattern_, index, time, cadence) != ASCIICHAT_OK)
39 return false;
40 const uint8_t *pixels = test_pattern_rgba(pattern_);
41 if (!pixels)
42 return false;
43 output.call<void>("set", emscripten::val(emscripten::typed_memory_view(output["length"].as<size_t>(), pixels)));
44 return true;
45 }
#define SET_ERRNO(code,...)
unsigned long long uint64_t
Definition common.h:63
unsigned char uint8_t
Definition common.h:60
@ ERROR_INVALID_STATE
@ ERROR_INVALID_PARAM
static bool size_t index
Definition queries.h:8
asciichat_error_t test_pattern_render(test_pattern_t *p, int index, double time_ms, bool cadence)
const uint8_t * test_pattern_rgba(test_pattern_t *p)
asciichat_error_t test_pattern_resize(test_pattern_t *p, int width, int height)

References ASCIICHAT_OK, ERROR_INVALID_PARAM, ERROR_INVALID_STATE, height, index, SET_ERRNO, test_pattern_render(), test_pattern_resize(), test_pattern_rgba(), and width.

Referenced by EMSCRIPTEN_BINDINGS().

◆ valid()

bool TestPatternBinding::valid ( ) const
inline

Definition at line 24 of file test_pattern.cpp.

24 {
25 return pattern_ != nullptr;
26 }

Referenced by EMSCRIPTEN_BINDINGS().


The documentation for this class was generated from the following file: