On Thu, Jun 30, 2016 at 02:34:41PM +0300, Emanuele Giaquinta wrote:
> On Thu, Jun 23, 2016 at 08:28:46PM +0800, Fengguang Wu wrote:
> > When the color cube slot is found to be already occupied by a similar
> > 24-bit color, search through the -1, 0, +1 R/G/B indices trying to find
> > an empty slot, or the oldest used one (which hopefully is no longer in
> > active use).
> > 
> > This effectively reduces random collisions, hence make it pretty hard to
> > hit a vim GUI color scheme that cannot be correctly showed in urxvt.
> 
> Applied without hashing and with some cleanups. Thanks again.

Thank you! I tried run it with the debug patch and it looks alright.

The below 6xxx sequence numbers are close enough to each other, 
which is a strong indication the update logic is working fine.

Thanks,
Fengguang
---

Debug output when cycling through lots of vim color schemes.

These collisions do not mean incorrect colors for the _current_
in use vim color scheme.

urxvt: 24-bit color collision 6437: [000] [ 36] #0d0d0d => #050505
[R0]
[G0]     [B0] 6380 002200    [B1] 6418 1f001f
[G1]     [B0] 6354 110022    [B1] 6327 202020

[R1]
[G0]     [B0] 6429 000000    [B1] 6326 0d0d0d
[G1]     [B0] 6397 0a150d    [B1] 6422 061a3e

urxvt: 24-bit color collision 6438: [221] [117] #555753 => #696969
[R1]
[G1]     [B0] 6397 0a150d    [B1] 6422 061a3e    [B2] 6285 00008b
[G2]     [B0] 6317 313633    [B1] 6387 003255    [B2] 6251 204070
[G3]     [B0] 6320 777777    [B1] 6268 61614a    [B2] 6365 00884c

[R2]
[G1]     [B0] 6264 32322e    [B1] 6298 4e4e4e    [B2] 6359 404040
[G2]     [B0] 6259 2d2d2d    [B1] 6408 303030    [B2] 6356 334444
[G3]     [B0] 6358 336600    [B1] 6306 9fafaf    [B2] 6249 668866

[R3]
[G1]     [B0] 6338 600000    [B1] 6252 666666    [B2] 6375 80624d
[G2]     [B0] 6366 544060    [B1] 6384 aa7733    [B2] 6232 555753
[G3]     [B0] 6399 676767    [B1] 6383 aa5544    [B2] 6269 d1d1ba

urxvt: 24-bit color collision 6439: [042] [ 27] #3cb371 => #00aaaa
[R0]
[G3]     [B1] 6430 005c70    [B2] 6402 3b6ac8    [B3] 6195 06989a
[G4]     [B1] 6286 4a81b4    [B2] 6208 0384f6    [B3] 6280 4682b4
[G5]     [B1] 6371 44aa44    [B2] 6011 3cb371    [B3] 6112 40ff80

[R1]
[G3]     [B1] 6268 61614a    [B2] 6365 00884c    [B3] 6393 307aca
[G4]     [B1] 6277 778899    [B2] 6404 1094a0    [B3] 6206 0e8ed3
[G5]     [B1] 6178 62c600    [B2] 6186 00c5e7    [B3] 6431 60a8bc

urxvt: 24-bit color collision 6440: [111] [ 70] #2e3436 => #2f4f4f
[R0]
[G0]     [B0] 6380 002200    [B1] 6418 1f001f    [B2] 6315 434443
[G1]     [B0] 6354 110022    [B1] 6327 202020    [B2] 6328 00003f
[G2]     [B0] 6305 3f3f3f    [B1] 6382 007700    [B2] 6428 004443

[R1]
[G0]     [B0] 6429 000000    [B1] 6438 050505    [B2] 6352 191970
[G1]     [B0] 6397 0a150d    [B1] 6422 061a3e    [B2] 6285 00008b
[G2]     [B0] 6317 313633    [B1] 6387 003255    [B2] 6251 204070

[R2]
[G0]     [B0] 6233 2e3436    [B1] 6401 323232    [B2] 6260 444444
[G1]     [B0] 6264 32322e    [B1] 6298 4e4e4e    [B2] 6359 404040
[G2]     [B0] 6259 2d2d2d    [B1] 6408 303030    [B2] 6356 334444

urxvt: 24-bit color collision 6441: [332] [ 92] #888a85 => #839496
[R2]
[G2]     [B1] 6408 303030    [B2] 6356 334444    [B3] 6322 888888
[G3]     [B1] 6306 9fafaf    [B2] 6249 668866    [B3] 6349 87cefa
[G4]     [B1] 6245 339999    [B2] 6234 888a85    [B3] 6293 87afdf

[R3]
[G2]     [B1] 6384 aa7733    [B2] 6439 696969    [B3] 6344 969696
[G3]     [B1] 6383 aa5544    [B2] 6269 d1d1ba    [B3] 6420 bebebe
[G4]     [B1] 6347 c2bfa5    [B2] 6323 c7ca87    [B3] 6303 a9a9a9

[R4]
[G2]     [B1] 6294 808080    [B2] 6378 999999    [B3] 6309 7f9f7f
[G3]     [B1] 6412 b85d00    [B2] 6316 c3bf9f    [B3] 6437 bbbbbb
[G4]     [B1] 6376 ddd9b8    [B2] 6284 cdcecd    [B3] 6274 f8f8ff

urxvt: 24-bit color collision 6442: [010] [ 10] #3f3f3f => #002b36
[R0]
[G0]     [B0] 6380 002200    [B1] 6418 1f001f
[G1]     [B0] 6354 110022    [B1] 6327 202020
[G2]     [B0] 6305 3f3f3f    [B1] 6382 007700

[R1]
[G0]     [B0] 6429 000000    [B1] 6438 050505
[G1]     [B0] 6397 0a150d    [B1] 6422 061a3e
[G2]     [B0] 6317 313633    [B1] 6387 003255

urxvt: 24-bit color collision 6443: [221] [ 87] #668866 => #586e75
[R1]
[G1]     [B0] 6397 0a150d    [B1] 6422 061a3e    [B2] 6285 00008b
[G2]     [B0] 6317 313633    [B1] 6387 003255    [B2] 6251 204070
[G3]     [B0] 6320 777777    [B1] 6268 61614a    [B2] 6365 00884c

[R2]
[G1]     [B0] 6264 32322e    [B1] 6298 4e4e4e    [B2] 6359 404040
[G2]     [B0] 6259 2d2d2d    [B1] 6408 303030    [B2] 6356 334444
[G3]     [B0] 6358 336600    [B1] 6306 9fafaf    [B2] 6249 668866

[R3]
[G1]     [B0] 6338 600000    [B1] 6252 666666    [B2] 6375 80624d
[G2]     [B0] 6366 544060    [B1] 6384 aa7733    [B2] 6439 696969
[G3]     [B0] 6399 676767    [B1] 6383 aa5544    [B2] 6269 d1d1ba

urxvt: 24-bit color collision 6444: [011] [ 47] #204070 => #073642
[R0]
[G0]     [B0] 6380 002200    [B1] 6418 1f001f    [B2] 6315 434443
[G1]     [B0] 6354 110022    [B1] 6327 202020    [B2] 6328 00003f
[G2]     [B0] 6443 002b36    [B1] 6382 007700    [B2] 6428 004443

[R1]
[G0]     [B0] 6429 000000    [B1] 6438 050505    [B2] 6352 191970
[G1]     [B0] 6397 0a150d    [B1] 6422 061a3e    [B2] 6285 00008b
[G2]     [B0] 6317 313633    [B1] 6387 003255    [B2] 6251 204070

urxvt: 24-bit color collision 6445: [330] [ 91] #339999 => #859900
[R2]
[G2]     [B0] 6259 2d2d2d    [B1] 6408 303030
[G3]     [B0] 6358 336600    [B1] 6306 9fafaf
[G4]     [B0] 6391 8b8b00    [B1] 6245 339999

[R3]
[G2]     [B0] 6366 544060    [B1] 6384 aa7733
[G3]     [B0] 6399 676767    [B1] 6383 aa5544
[G4]     [B0] 6266 81816a    [B1] 6347 c2bfa5

[R4]
[G2]     [B0] 6254 857b6f    [B1] 6294 808080
[G3]     [B0] 6321 a56a30    [B1] 6412 b85d00
[G4]     [B0] 6362 80a030    [B1] 6376 ddd9b8

urxvt: 24-bit color collision 6446: [430] [150] #857b6f => #b58900
[R3]
[G2]     [B0] 6366 544060    [B1] 6384 aa7733
[G3]     [B0] 6399 676767    [B1] 6383 aa5544
[G4]     [B0] 6266 81816a    [B1] 6347 c2bfa5

[R4]
[G2]     [B0] 6254 857b6f    [B1] 6294 808080
[G3]     [B0] 6321 a56a30    [B1] 6412 b85d00
[G4]     [B0] 6362 80a030    [B1] 6376 ddd9b8

[R5]
[G2]     [B0] 6337 ffa500    [B1] 6373 bb9900
[G3]     [B0] 6324 face43    [B1] 6267 ccccaa
[G4]     [B0] 6406 ffd073    [B1] 6372 ccaaaa

urxvt: 24-bit color collision 6447: [132] [ 18] #06989a => #2aa198
[R0]
[G2]     [B1] 6382 007700    [B2] 6428 004443    [B3] 6238 004488
[G3]     [B1] 6430 005c70    [B2] 6402 3b6ac8    [B3] 6195 06989a
[G4]     [B1] 6286 4a81b4    [B2] 6208 0384f6    [B3] 6280 4682b4

[R1]
[G2]     [B1] 6387 003255    [B2] 6445 073642    [B3] 6421 008b8b
[G3]     [B1] 6268 61614a    [B2] 6365 00884c    [B3] 6393 307aca
[G4]     [B1] 6277 778899    [B2] 6404 1094a0    [B3] 6206 0e8ed3

[R2]
[G2]     [B1] 6408 303030    [B2] 6356 334444    [B3] 6322 888888
[G3]     [B1] 6306 9fafaf    [B2] 6444 586e75    [B3] 6349 87cefa
[G4]     [B1] 6446 859900    [B2] 6442 839496    [B3] 6293 87afdf

urxvt: 24-bit color collision 6448: [520] [221] #fa8072 => #d86020
[R4]
[G1]     [B0] 6374 bb6666    [B1] 6300 904838
[G2]     [B0] 6447 b58900    [B1] 6294 808080
[G3]     [B0] 6321 a56a30    [B1] 6412 b85d00

[R5]
[G1]     [B0] 6235 ce5c00    [B1] 6236 c17d11
[G2]     [B0] 6337 ffa500    [B1] 6373 bb9900
[G3]     [B0] 6324 face43    [B1] 6267 ccccaa

[R6]
[G1]     [B0] 6390 da302a    [B1] 6092 ff0007
[G2]     [B0] 6243 ff6600    [B1] 6086 fa8072
[G3]     [B0] 6325 ffce43    [B1] 6424 dabea2

urxvt: 24-bit color collision 6449: [510] [210] #da4939 => #dc322f
[R4]
[G0]     [B0] 6396 a50a4a    [B1] 6369 a52a2a
[G1]     [B0] 6374 bb6666    [B1] 6300 904838
[G2]     [B0] 6447 b58900    [B1] 6294 808080

[R5]
[G0]     [B0] 6415 cd3333    [B1] 6107 ff0000
[G1]     [B0] 6235 ce5c00    [B1] 6236 c17d11
[G2]     [B0] 6337 ffa500    [B1] 6373 bb9900

[R6]
[G0]     [B0] 6059 da4939    [B1] 6081 e50808
[G1]     [B0] 6390 da302a    [B1] 6092 ff0007
[G2]     [B0] 6243 ff6600    [B1] 6449 d86020

---
 command.C |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

--- src.orig/command.C  2016-06-30 21:08:25.075840281 +0800
+++ src/command.C       2016-06-30 21:30:11.272203734 +0800
@@ -3367,6 +3367,9 @@ rxvt_term::map_rgb24_color (unsigned int
   unsigned int idx_b = b / (0xff / (Blue_levels - 1));
   unsigned int idx = colorcube_index (idx_r, idx_g, idx_b);
 
+  char buf[4096];
+  char *p = buf;
+
   // minor issue: could update idx 0 few more times
   if (rgb24_seqno[idx] == 0
       && rgb24_color[idx] == 0)
@@ -3380,11 +3383,15 @@ rxvt_term::map_rgb24_color (unsigned int
       if (!IN_RANGE_EXC (i, 0, Red_levels))
         continue;
 
+      p += snprintf (p, buf + sizeof(buf) - p, "[R%d]\n", i);
+
       for (int j = idx_g - 1; j <= (signed) idx_g + 1; j++)
         {
           if (!IN_RANGE_EXC (j, 0, Green_levels))
             continue;
 
+          p += snprintf (p, buf + sizeof(buf) - p, "[G%d] ", j);
+
           for (int k = idx_b - 1; k <= (signed) idx_b + 1; k++)
             {
               if (!IN_RANGE_EXC (k, 0, Blue_levels))
@@ -3407,10 +3414,24 @@ rxvt_term::map_rgb24_color (unsigned int
               // but also handles wrap around values good enough
               if ((uint16_t) (rgb24_seqno[idx] - rgb24_seqno[index]) < 0x7fff)
                 idx = index;
-            }
-        }
+
+              p += snprintf (p, buf + sizeof(buf) - p, "    [B%d] %4hu %06x",
+                             k, rgb24_seqno[index], rgb24_color[index]);
+           }
+          p += snprintf (p, buf + sizeof(buf) - p, "\n");
+       }
+        p += snprintf (p, buf + sizeof(buf) - p, "\n");
     }
 
+#define DEBUG_RGB24
+#if defined(DEBUG_RGB24)
+    rxvt_warn ("24-bit color collision %hu: [%d%d%d] [%3u] #%06x => #%06x\n",
+               rgb24_sequence,
+               idx_r, idx_g, idx_b,
+               idx, rgb24_color[idx], color);
+    fprintf (stderr, buf);
+#endif
+
 update:
   rgb24_color[idx] = color;
   rgb24_seqno[idx] = ++rgb24_sequence;

_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/rxvt-unicode

Reply via email to