Merge "minui: add ARGB_8888 format"

This commit is contained in:
Treehugger Robot
2019-12-13 23:44:50 +00:00
committed by Gerrit Code Review
4 changed files with 11 additions and 4 deletions
+3 -1
View File
@@ -209,7 +209,7 @@ void gr_texticon(int x, int y, const GRSurface* icon) {
void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
uint32_t r32 = r, g32 = g, b32 = b, a32 = a; uint32_t r32 = r, g32 = g, b32 = b, a32 = a;
if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) { if (pixel_format == PixelFormat::ARGB || pixel_format == PixelFormat::BGRA) {
gr_current = (a32 << 24) | (r32 << 16) | (g32 << 8) | b32; gr_current = (a32 << 24) | (r32 << 16) | (g32 << 8) | b32;
} else { } else {
gr_current = (a32 << 24) | (b32 << 16) | (g32 << 8) | r32; gr_current = (a32 << 24) | (b32 << 16) | (g32 << 8) | r32;
@@ -348,6 +348,8 @@ int gr_init() {
pixel_format = PixelFormat::ABGR; pixel_format = PixelFormat::ABGR;
} else if (format == "RGBX_8888") { } else if (format == "RGBX_8888") {
pixel_format = PixelFormat::RGBX; pixel_format = PixelFormat::RGBX;
} else if (format == "ARGB_8888") {
pixel_format = PixelFormat::ARGB;
} else if (format == "BGRA_8888") { } else if (format == "BGRA_8888") {
pixel_format = PixelFormat::BGRA; pixel_format = PixelFormat::BGRA;
} else { } else {
+4
View File
@@ -62,6 +62,8 @@ static int drm_format_to_bpp(uint32_t format) {
case DRM_FORMAT_ABGR8888: case DRM_FORMAT_ABGR8888:
case DRM_FORMAT_BGRA8888: case DRM_FORMAT_BGRA8888:
case DRM_FORMAT_RGBX8888: case DRM_FORMAT_RGBX8888:
case DRM_FORMAT_RGBA8888:
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_BGRX8888: case DRM_FORMAT_BGRX8888:
case DRM_FORMAT_XBGR8888: case DRM_FORMAT_XBGR8888:
case DRM_FORMAT_XRGB8888: case DRM_FORMAT_XRGB8888:
@@ -87,6 +89,8 @@ std::unique_ptr<GRSurfaceDrm> GRSurfaceDrm::Create(int drm_fd, int width, int he
format = DRM_FORMAT_ARGB8888; format = DRM_FORMAT_ARGB8888;
} else if (pixel_format == PixelFormat::RGBX) { } else if (pixel_format == PixelFormat::RGBX) {
format = DRM_FORMAT_XBGR8888; format = DRM_FORMAT_XBGR8888;
} else if (pixel_format == PixelFormat::ARGB) {
format = DRM_FORMAT_BGRA8888;
} else { } else {
format = DRM_FORMAT_RGB565; format = DRM_FORMAT_RGB565;
} }
+1
View File
@@ -101,6 +101,7 @@ enum class PixelFormat : int {
ABGR = 1, ABGR = 1,
RGBX = 2, RGBX = 2,
BGRA = 3, BGRA = 3,
ARGB = 4,
}; };
// Initializes the graphics backend and loads font file. Returns 0 on success, or -1 on error. Note // Initializes the graphics backend and loads font file. Returns 0 on success, or -1 on error. Note
+3 -3
View File
@@ -199,7 +199,7 @@ int res_create_display_surface(const char* name, GRSurface** pSurface) {
} }
PixelFormat pixel_format = gr_pixel_format(); PixelFormat pixel_format = gr_pixel_format();
if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) { if (pixel_format == PixelFormat::ARGB || pixel_format == PixelFormat::BGRA) {
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
} }
@@ -271,7 +271,7 @@ int res_create_multi_display_surface(const char* name, int* frames, int* fps,
surface[i] = created_surface.release(); surface[i] = created_surface.release();
} }
if (gr_pixel_format() == PixelFormat::ABGR || gr_pixel_format() == PixelFormat::BGRA) { if (gr_pixel_format() == PixelFormat::ARGB || gr_pixel_format() == PixelFormat::BGRA) {
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
} }
@@ -317,7 +317,7 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
} }
PixelFormat pixel_format = gr_pixel_format(); PixelFormat pixel_format = gr_pixel_format();
if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) { if (pixel_format == PixelFormat::ARGB || pixel_format == PixelFormat::BGRA) {
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
} }