[vte] sixel: Pass colour components to Context::prepare



commit 528d851085794003b4ca90bf336f1be1156e7a6e
Author: Christian Persch <chpe src gnome org>
Date:   Mon Oct 19 21:56:20 2020 +0200

    sixel: Pass colour components to Context::prepare
    
    The Context's colour storage format is internal, so pass the fg and
    bg colours components individually.

 src/sixel-context.cc | 13 +++++++++----
 src/sixel-context.hh |  8 ++++++--
 src/sixel-test.cc    | 28 +++++++++++++++++++++-------
 src/vteseq.cc        |  5 ++---
 4 files changed, 38 insertions(+), 16 deletions(-)
---
diff --git a/src/sixel-context.cc b/src/sixel-context.cc
index 580f7a6c..50853944 100644
--- a/src/sixel-context.cc
+++ b/src/sixel-context.cc
@@ -298,8 +298,12 @@ Context::reset_colors() noexcept
 
 void
 Context::prepare(uint32_t introducer,
-                 color_t fg,
-                 color_t bg,
+                 unsigned fg_red,
+                 unsigned fg_green,
+                 unsigned fg_blue,
+                 unsigned bg_red,
+                 unsigned bg_green,
+                 unsigned bg_blue,
                  bool private_color_registers,
                  double pixel_aspect) noexcept
 {
@@ -312,9 +316,10 @@ Context::prepare(uint32_t introducer,
                 reset_colors();
 
         /* FIXMEchpe: this all seems bogus. */
-        set_color(0, bg);
+        set_color(0, make_color(bg_red, bg_green, bg_blue));
         if (private_color_registers)
-                set_color(param_to_color_register(0), fg);
+                set_color(param_to_color_register(0),
+                          make_color(fg_red, fg_green, fg_blue));
 
         /*
          * DEC PPLV2 says that on entering DECSIXEL mode, the active colour
diff --git a/src/sixel-context.hh b/src/sixel-context.hh
index db9b2e36..b1c910c5 100644
--- a/src/sixel-context.hh
+++ b/src/sixel-context.hh
@@ -620,8 +620,12 @@ private:
 public:
 
         void prepare(uint32_t introducer,
-                     color_t fg,
-                     color_t bg,
+                     unsigned fg_red,
+                     unsigned fg_green,
+                     unsigned fg_blue,
+                     unsigned bg_red,
+                     unsigned bg_green,
+                     unsigned bg_blue,
                      bool private_color_registers,
                      double pixel_aspect = 1.0) noexcept;
 
diff --git a/src/sixel-test.cc b/src/sixel-test.cc
index d6d852d6..e91c2cd7 100644
--- a/src/sixel-test.cc
+++ b/src/sixel-test.cc
@@ -1013,13 +1013,20 @@ template<class C>
 static void
 parse_image(C& context,
             std::string_view const& str,
-            Context::color_t fg,
-            Context::color_t bg,
+            unsigned fg_red,
+            unsigned fg_green,
+            unsigned fg_blue,
+            unsigned bg_red,
+            unsigned bg_green,
+            unsigned bg_blue,
             bool private_color_registers = true,
             int line = __builtin_LINE())
 {
         context.reset();
-        context.prepare(0x50 /* C0 DCS */, fg, bg, private_color_registers);
+        context.prepare(0x50 /* C0 DCS */,
+                        fg_red, fg_green, fg_blue,
+                        bg_red, bg_green, bg_blue,
+                        private_color_registers);
 
         auto str_st = std::string{str};
         str_st.append(ST(StType::C0));
@@ -1031,12 +1038,19 @@ template<class C>
 static void
 parse_image(C& context,
             ItemList const& items,
-            Context::color_t fg,
-            Context::color_t bg,
+            unsigned fg_red,
+            unsigned fg_green,
+            unsigned fg_blue,
+            unsigned bg_red,
+            unsigned bg_green,
+            unsigned bg_blue,
             bool private_color_registers = true,
             int line = __builtin_LINE())
 {
-        parse_image(context, ItemStringifier(items).string(), fg, bg, private_color_registers, line);
+        parse_image(context, ItemStringifier(items).string(),
+                    fg_red, fg_green, fg_blue,
+                    bg_red, bg_green, bg_blue,
+                    private_color_registers, line);
 }
 
 template<class C>
@@ -1045,7 +1059,7 @@ parse_image(C& context,
             std::string_view const& str,
             int line = __builtin_LINE())
 {
-        parse_image(context, str, 0xffffffffu, 0xff000000u, true, line);
+        parse_image(context, str, 0xffu, 0xffu, 0xffu, 0xff8, 0xffu, 0xffu, true, line);
 }
 
 template<class C>
diff --git a/src/vteseq.cc b/src/vteseq.cc
index d96b6a47..1639bbe4 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -4440,11 +4440,10 @@ Terminal::DECSIXEL(vte::parser::Sequence const& seq)
 
                 auto const fg = get_color(VTE_DEFAULT_FG);
                 auto const bg = get_color(VTE_DEFAULT_BG);
-                auto nfg = uint32_t(fg->red >> 8) | ((fg->green >> 8) << 8) | ((fg->blue >> 8) << 16) | 0xff 
<< 24;
-                auto nbg = uint32_t(bg->red >> 8) | ((bg->green >> 8) << 8) | ((bg->blue >> 8) << 16) | 0xff 
<< 24;
 
                 m_sixel_context->prepare(seq.st(),
-                                         nfg, nbg,
+                                         fg->red >> 8, fg->green >> 8, fg->blue >> 8,
+                                         bg->red >> 8, bg->green >> 8, bg->blue >> 8,
                                          m_modes_private.XTERM_SIXEL_PRIVATE_COLOR_REGISTERS());
 
                 m_sixel_context->set_mode(mode);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]