Coverage Report

Created: 2025-08-28 06:26

/src/serenity/Userland/Libraries/LibGfx/FourCC.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/Types.h>
10
11
namespace Gfx {
12
13
struct [[gnu::packed]] FourCC {
14
    FourCC() = default;
15
16
    constexpr FourCC(char const name[4])
17
1.46M
    {
18
1.46M
        cc[0] = name[0];
19
1.46M
        cc[1] = name[1];
20
1.46M
        cc[2] = name[2];
21
1.46M
        cc[3] = name[3];
22
1.46M
    }
23
24
    static constexpr FourCC from_u32(u32 value)
25
0
    {
26
0
        FourCC result;
27
0
        result.cc[0] = static_cast<char>(value >> 24);
28
0
        result.cc[1] = static_cast<char>(value >> 16);
29
0
        result.cc[2] = static_cast<char>(value >> 8);
30
0
        result.cc[3] = static_cast<char>(value);
31
0
        return result;
32
0
    }
33
34
4.64M
    bool operator==(FourCC const&) const = default;
35
4.24k
    bool operator!=(FourCC const&) const = default;
36
37
    u32 to_u32() const
38
0
    {
39
0
        return (static_cast<u8>(cc[0]) << 24)
40
0
            | (static_cast<u8>(cc[1]) << 16)
41
0
            | (static_cast<u8>(cc[2]) << 8)
42
0
            | static_cast<u8>(cc[3]);
43
0
    }
44
45
    char cc[4];
46
};
47
48
}