]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - libkms++/pixelformats.h
Fb: collect fbs and destroy them in card's destructor
[android/external-libkmsxx.git] / libkms++ / pixelformats.h
1 #pragma once
3 namespace kms
4 {
5 constexpr uint32_t MakeFourCC(const char *fourcc)
6 {
7         return fourcc[0] | (fourcc[1] << 8) | (fourcc[2] << 16) | (fourcc[3] << 24);
8 }
10 enum class PixelFormat : uint32_t
11 {
12         Undefined = 0,
14         NV12 = MakeFourCC("NV12"),
15         NV21 = MakeFourCC("NV21"),
17         UYVY = MakeFourCC("UYVY"),
18         YUYV = MakeFourCC("YUYV"),
19         YVYU = MakeFourCC("YVYU"),
20         VYUY = MakeFourCC("VYUY"),
22         XRGB8888 = MakeFourCC("XR24"),
23         XBGR8888 = MakeFourCC("XB24"),
24         ARGB8888 = MakeFourCC("AR24"),
25         ABGR8888 = MakeFourCC("AB24"),
27         RGB565 = MakeFourCC("RG16"),
28 };
30 static inline PixelFormat FourCCToPixelFormat(const std::string& fourcc)
31 {
32         return (PixelFormat)MakeFourCC(fourcc.c_str());
33 }
35 static inline std::string PixelFormatToFourCC(PixelFormat f)
36 {
37         char buf[5] = { (char)(((int)f >> 0) & 0xff),
38                         (char)(((int)f >> 8) & 0xff),
39                         (char)(((int)f >> 16) & 0xff),
40                         (char)(((int)f >> 24) & 0xff),
41                         0 };
42         return std::string(buf);
43 }
45 }