|
17 | 17 |
|
18 | 18 | namespace Gfx { |
19 | 19 |
|
20 | | -typedef u32 ARGB32; |
| 20 | +// Named after in memory-order (little-endian) |
| 21 | +// e.g. 0xAARRGGBB |
| 22 | +using BGRA8888 = u32; |
21 | 23 |
|
22 | 24 | enum class AlphaType { |
23 | 25 | Premultiplied, |
@@ -139,14 +141,14 @@ class Color { |
139 | 141 |
|
140 | 142 | static constexpr Color branded_color(BrandedColor); |
141 | 143 |
|
142 | | - static constexpr Color from_rgb(unsigned rgb) { return Color(rgb | 0xff000000); } |
143 | | - static constexpr Color from_argb(unsigned argb) { return Color(argb); } |
144 | | - static constexpr Color from_abgr(unsigned abgr) |
| 144 | + static constexpr Color from_bgrx(unsigned bgrx) { return Color(bgrx | 0xff000000); } |
| 145 | + static constexpr Color from_bgra(unsigned bgra) { return Color(bgra); } |
| 146 | + static constexpr Color from_rgba(unsigned rgba) |
145 | 147 | { |
146 | | - unsigned argb = (abgr & 0xff00ff00) | ((abgr & 0xff0000) >> 16) | ((abgr & 0xff) << 16); |
147 | | - return Color::from_argb(argb); |
| 148 | + unsigned bgra = (rgba & 0xff00ff00) | ((rgba & 0xff0000) >> 16) | ((rgba & 0xff) << 16); |
| 149 | + return Color::from_bgra(bgra); |
148 | 150 | } |
149 | | - static constexpr Color from_bgr(unsigned bgr) { return Color::from_abgr(bgr | 0xff000000); } |
| 151 | + static constexpr Color from_rgbx(unsigned rgbx) { return Color::from_rgba(rgbx | 0xff000000); } |
150 | 152 |
|
151 | 153 | static constexpr Color from_yuv(YUV const& yuv) { return from_yuv(yuv.y, yuv.u, yuv.v); } |
152 | 154 | static constexpr Color from_yuv(float y, float u, float v) |
@@ -464,7 +466,7 @@ class Color { |
464 | 466 | return Color(((other.m_value ^ m_value) & 0x00ffffff) | (m_value & 0xff000000)); |
465 | 467 | } |
466 | 468 |
|
467 | | - constexpr ARGB32 value() const { return m_value; } |
| 469 | + constexpr BGRA8888 value() const { return m_value; } |
468 | 470 |
|
469 | 471 | constexpr bool operator==(Color other) const |
470 | 472 | { |
@@ -595,12 +597,12 @@ class Color { |
595 | 597 | } |
596 | 598 |
|
597 | 599 | private: |
598 | | - constexpr explicit Color(ARGB32 argb) |
| 600 | + constexpr explicit Color(BGRA8888 argb) |
599 | 601 | : m_value(argb) |
600 | 602 | { |
601 | 603 | } |
602 | 604 |
|
603 | | - ARGB32 m_value { 0 }; |
| 605 | + BGRA8888 m_value { 0 }; |
604 | 606 | }; |
605 | 607 |
|
606 | 608 | constexpr Color::Color(NamedColor named) |
@@ -695,41 +697,41 @@ constexpr Color Color::branded_color(BrandedColor color) |
695 | 697 | { |
696 | 698 | // clang-format off |
697 | 699 | switch (color) { |
698 | | - case BrandedColor::Indigo10: return from_rgb(0xa5'a6'f2); |
699 | | - case BrandedColor::Indigo20: return from_rgb(0x8a'88'eb); |
700 | | - case BrandedColor::Indigo30: return from_rgb(0x68'51'd6); |
701 | | - case BrandedColor::Indigo40: return from_rgb(0x55'3f'c4); |
702 | | - case BrandedColor::Indigo50: return from_rgb(0x4d'37'b8); |
703 | | - case BrandedColor::Indigo60: return from_rgb(0x3c'28'a1); |
704 | | - case BrandedColor::Indigo80: return from_rgb(0x30'1f'82); |
705 | | - case BrandedColor::Indigo100: return from_rgb(0x2a'13'73); |
706 | | - case BrandedColor::Indigo300: return from_rgb(0x26'0f'73); |
707 | | - case BrandedColor::Indigo500: return from_rgb(0x1d'0c'59); |
708 | | - case BrandedColor::Indigo900: return from_rgb(0x19'0c'4a); |
709 | | - |
710 | | - case BrandedColor::Violet10: return from_rgb(0xe0'd4'ff); |
711 | | - case BrandedColor::Violet20: return from_rgb(0xca'b5'ff); |
712 | | - case BrandedColor::Violet30: return from_rgb(0xc3'ab'ff); |
713 | | - case BrandedColor::Violet40: return from_rgb(0xb4'96'ff); |
714 | | - case BrandedColor::Violet50: return from_rgb(0xab'8e'f5); |
715 | | - case BrandedColor::Violet60: return from_rgb(0x9d'7c'f2); |
716 | | - case BrandedColor::Violet80: return from_rgb(0x93'6f'ed); |
717 | | - case BrandedColor::Violet100: return from_rgb(0x8a'64'e5); |
718 | | - case BrandedColor::Violet300: return from_rgb(0x82'57'e6); |
719 | | - case BrandedColor::Violet500: return from_rgb(0x7a'4c'e6); |
720 | | - case BrandedColor::Violet900: return from_rgb(0x6a'39'db); |
721 | | - |
722 | | - case BrandedColor::SlateBlue10: return from_rgb(0xcb'e0'f7); |
723 | | - case BrandedColor::SlateBlue20: return from_rgb(0xc1'd9'f5); |
724 | | - case BrandedColor::SlateBlue30: return from_rgb(0xb6'd2'f2); |
725 | | - case BrandedColor::SlateBlue40: return from_rgb(0xa8'c8'ed); |
726 | | - case BrandedColor::SlateBlue50: return from_rgb(0x97'bc'e6); |
727 | | - case BrandedColor::SlateBlue60: return from_rgb(0x86'ad'd9); |
728 | | - case BrandedColor::SlateBlue80: return from_rgb(0x77'a1'd1); |
729 | | - case BrandedColor::SlateBlue100: return from_rgb(0x6d'98'cc); |
730 | | - case BrandedColor::SlateBlue300: return from_rgb(0x5c'8e'cc); |
731 | | - case BrandedColor::SlateBlue500: return from_rgb(0x54'84'bf); |
732 | | - case BrandedColor::SlateBlue900: return from_rgb(0x48'72'a3); |
| 700 | + case BrandedColor::Indigo10: return from_bgrx(0xa5'a6'f2); |
| 701 | + case BrandedColor::Indigo20: return from_bgrx(0x8a'88'eb); |
| 702 | + case BrandedColor::Indigo30: return from_bgrx(0x68'51'd6); |
| 703 | + case BrandedColor::Indigo40: return from_bgrx(0x55'3f'c4); |
| 704 | + case BrandedColor::Indigo50: return from_bgrx(0x4d'37'b8); |
| 705 | + case BrandedColor::Indigo60: return from_bgrx(0x3c'28'a1); |
| 706 | + case BrandedColor::Indigo80: return from_bgrx(0x30'1f'82); |
| 707 | + case BrandedColor::Indigo100: return from_bgrx(0x2a'13'73); |
| 708 | + case BrandedColor::Indigo300: return from_bgrx(0x26'0f'73); |
| 709 | + case BrandedColor::Indigo500: return from_bgrx(0x1d'0c'59); |
| 710 | + case BrandedColor::Indigo900: return from_bgrx(0x19'0c'4a); |
| 711 | + |
| 712 | + case BrandedColor::Violet10: return from_bgrx(0xe0'd4'ff); |
| 713 | + case BrandedColor::Violet20: return from_bgrx(0xca'b5'ff); |
| 714 | + case BrandedColor::Violet30: return from_bgrx(0xc3'ab'ff); |
| 715 | + case BrandedColor::Violet40: return from_bgrx(0xb4'96'ff); |
| 716 | + case BrandedColor::Violet50: return from_bgrx(0xab'8e'f5); |
| 717 | + case BrandedColor::Violet60: return from_bgrx(0x9d'7c'f2); |
| 718 | + case BrandedColor::Violet80: return from_bgrx(0x93'6f'ed); |
| 719 | + case BrandedColor::Violet100: return from_bgrx(0x8a'64'e5); |
| 720 | + case BrandedColor::Violet300: return from_bgrx(0x82'57'e6); |
| 721 | + case BrandedColor::Violet500: return from_bgrx(0x7a'4c'e6); |
| 722 | + case BrandedColor::Violet900: return from_bgrx(0x6a'39'db); |
| 723 | + |
| 724 | + case BrandedColor::SlateBlue10: return from_bgrx(0xcb'e0'f7); |
| 725 | + case BrandedColor::SlateBlue20: return from_bgrx(0xc1'd9'f5); |
| 726 | + case BrandedColor::SlateBlue30: return from_bgrx(0xb6'd2'f2); |
| 727 | + case BrandedColor::SlateBlue40: return from_bgrx(0xa8'c8'ed); |
| 728 | + case BrandedColor::SlateBlue50: return from_bgrx(0x97'bc'e6); |
| 729 | + case BrandedColor::SlateBlue60: return from_bgrx(0x86'ad'd9); |
| 730 | + case BrandedColor::SlateBlue80: return from_bgrx(0x77'a1'd1); |
| 731 | + case BrandedColor::SlateBlue100: return from_bgrx(0x6d'98'cc); |
| 732 | + case BrandedColor::SlateBlue300: return from_bgrx(0x5c'8e'cc); |
| 733 | + case BrandedColor::SlateBlue500: return from_bgrx(0x54'84'bf); |
| 734 | + case BrandedColor::SlateBlue900: return from_bgrx(0x48'72'a3); |
733 | 735 | } |
734 | 736 | // clang-format on |
735 | 737 |
|
|
0 commit comments