1.10
types.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_TYPES_H
7#define EGT_TYPES_H
8
14#include <cairo.h>
15#include <egt/detail/enum.h>
16#include <egt/detail/meta.h>
17#include <iosfwd>
18#include <memory>
19
20namespace egt
21{
22inline namespace v1
23{
24
29 std::shared_ptr<cairo_surface_t>;
30
35 std::shared_ptr<cairo_t>;
36
41 std::shared_ptr<cairo_pattern_t>;
42
47 std::shared_ptr<cairo_scaled_font_t>;
48
49namespace detail
50{
52struct cairo_t_deleter
53{
54 void operator()(cairo_t* cr) { cairo_destroy(cr); }
55};
56
58struct cairo_surface_t_deleter
59{
60 void operator()(cairo_surface_t* surface) { cairo_surface_destroy(surface); }
61};
62
64struct cairo_pattern_t_deleter
65{
66 void operator()(cairo_pattern_t* pattern) { cairo_pattern_destroy(pattern); }
67};
68}
69
74 std::unique_ptr<cairo_t, detail::cairo_t_deleter>;
75
80 std::unique_ptr<cairo_surface_t, detail::cairo_surface_t_deleter>;
85 std::unique_ptr<cairo_pattern_t, detail::cairo_pattern_t_deleter>;
86
87
93enum class PixelFormat
94{
95 invalid,
96 rgb565,
97 argb8888,
98 xrgb8888,
99 yuyv,
101 nv21,
103 yuv420,
104 yvyu,
105 nv61,
106 yuy2,
107 uyvy,
108};
109
111template<>
112EGT_API const std::pair<PixelFormat, char const*> detail::EnumStrings<PixelFormat>::data[11];
113
115EGT_API std::ostream& operator<<(std::ostream& os, const PixelFormat& format);
116
123namespace detail
124{
125
130
135
140
145
150
160EGT_API std::string demangle(const char* name);
161
162}
163
164}
165}
166
167#endif
EGT_API std::string demangle(const char *name)
Demangle a C++ symbol into something human readable.
std::string format(T value, int precision=2)
Format a float/double to a fixed precision and return as a string.
Definition detail/string.h:65
PixelFormat egt_format(uint32_t format)
Convert a DRM format to a pixel format.
cairo_format_t cairo_format(PixelFormat format)
Convert a PixelFormat to a cairo format.
std::string gstreamer_format(PixelFormat format)
Convert a pixel format to a gstreamer format.
uint32_t drm_format(PixelFormat format)
Convert a pixel format to a DRM format.
std::shared_ptr< cairo_surface_t > shared_cairo_surface_t
Shared pointer for a cairo surface.
Definition types.h:29
std::shared_ptr< cairo_t > shared_cairo_t
Shared pointer for a cairo context.
Definition types.h:35
std::unique_ptr< cairo_t, detail::cairo_t_deleter > unique_cairo_t
Unique pointer for a cairo context.
Definition types.h:74
std::unique_ptr< cairo_pattern_t, detail::cairo_pattern_t_deleter > unique_cairo_pattern_t
Unique pointer for a cairo pattern.
Definition types.h:85
std::unique_ptr< cairo_surface_t, detail::cairo_surface_t_deleter > unique_cairo_surface_t
Unique pointer for a cairo surface.
Definition types.h:80
PixelFormat
Supported pixel formats.
Definition types.h:94
@ xrgb8888
32 bpp, 24-bit color
@ rgb565
16 bpp, 16-bit color
@ yuy2
Packed YUY 4:2:2.
@ argb8888
32 bpp, 24-bit color + 8-bit alpha
@ yuyv
Packed format with ½ horizontal chroma resolution, also known.
@ nv21
YUV 4:2:0 planar image, with 8 bit Y samples, followed by.
@ yuv420
Planar format.
@ uyvy
Reverse byte order of YUY2.
@ invalid
Invalid color format.
EGT_API std::ostream & operator<<(std::ostream &os, const Color &color)
Overloaded std::ostream insertion operator.
std::shared_ptr< cairo_scaled_font_t > shared_cairo_scaled_font_t
Shared pointer for a cairo font.
Definition types.h:47
std::shared_ptr< cairo_pattern_t > shared_cairo_pattern_t
Shared pointer for a cairo pattern.
Definition types.h:41
EGT framework namespace.
Definition animation.h:24
When using enum_to_string() and enum_from_string(), this type needs to be defined and specialized to ...
Definition enum.h:48