ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.589 by sf-exg, Sun May 9 15:48:26 2021 UTC vs.
Revision 1.590 by sf-exg, Tue May 11 18:46:50 2021 UTC

3332 b &= 0xff; 3332 b &= 0xff;
3333 a &= 0xff; 3333 a &= 0xff;
3334 3334
3335 uint32_t color = (a << 24) | (r << 16) | (g << 8) | b; 3335 uint32_t color = (a << 24) | (r << 16) | (g << 8) | b;
3336 3336
3337 unsigned int idx_r = r * (Red_levels - 1) / 0xff;
3338 unsigned int idx_g = g * (Green_levels - 1) / 0xff;
3339 unsigned int idx_b = b * (Blue_levels - 1) / 0xff;
3340 unsigned int idx = colorcube_index (idx_r, idx_g, idx_b);
3341
3342 /* we allow one of the 6 directly neighbouring colours */ 3337 /* we allow one of the 6 closest neighbouring colours */
3343 /* to replace the current color, if they not used recently */ 3338 /* to replace the current color, if they not used recently */
3344 static const signed char dxyz[][3] = { 3339 static const signed char dxyz[][3] = {
3345 0, 0, 0, 3340 0, 0, 0,
3346 0, 0, +1, 3341 0, 0, 4,
3347 0, 0, -1,
3348 0, +1, 0, 3342 0, 4, 0,
3349 0, -1, 0,
3350 +1, 0, 0, 3343 4, 0, 0,
3351 -1, 0, 0, 3344 0, 4, 4,
3345 4, 4, 0,
3346 4, 0, 4,
3352 }; 3347 };
3353 3348
3349 static const unsigned char color_level[8][32] = {
3350 // neighbour index
3351 {0, 0, 1, 0, 0, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3},
3352 {0, 1, 0, 1, 1, 2, 1, 1, 2, 2, 3, 3, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4},
3353 {0, 0, 1, 2, 1, 1, 2, 3, 3, 2, 2, 3, 3, 4, 4, 3, 3, 3, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 5, 5, 5, 5},
3354 {0, 0, 2, 1, 2, 3, 2, 2, 3, 4, 4, 3, 3, 4, 4, 5, 5, 4, 4, 5, 5, 5, 6, 6, 5, 5, 5, 6, 6, 6, 6, 6},
3355 // Red_levels/Green_levels/Blue_levels index
3356 {0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
3357 {0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
3358 {0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5},
3359 {0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6},
3360 };
3361
3362 unsigned int idx;
3363
3354 for (int n = 0; n < ecb_array_length (dxyz); ++n) 3364 for (int n = 0; n < ecb_array_length (dxyz); ++n)
3355 { 3365 {
3356 int r = idx_r + dxyz[n][0]; 3366 unsigned int idx_r = color_level[ Red_levels - dxyz[n][0]][r / 8];
3357 int g = idx_g + dxyz[n][1]; 3367 unsigned int idx_g = color_level[Green_levels - dxyz[n][1]][g / 8];
3358 int b = idx_b + dxyz[n][2]; 3368 unsigned int idx_b = color_level[ Blue_levels - dxyz[n][2]][b / 8];
3359
3360 if (!IN_RANGE_EXC (r, 0, Red_levels )) continue;
3361 if (!IN_RANGE_EXC (g, 0, Green_levels)) continue;
3362 if (!IN_RANGE_EXC (b, 0, Blue_levels )) continue;
3363
3364 unsigned int index = colorcube_index (r, g, b); 3369 unsigned int index = colorcube_index (idx_r, idx_g, idx_b);
3370
3371 if (n == 0)
3372 idx = index;
3365 3373
3366 if (rgb24_color[index] == color) 3374 if (rgb24_color[index] == color)
3367 { 3375 {
3368 rgb24_seqno[index] = ++rgb24_sequence; 3376 rgb24_seqno[index] = ++rgb24_sequence;
3369 return index + minTermCOLOR24; 3377 return index + minTermCOLOR24;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines