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.572 by sf-exg, Thu Jun 30 12:50:36 2016 UTC vs.
Revision 1.579 by root, Thu Jun 30 17:03:45 2016 UTC

3360 r &= 0xff; 3360 r &= 0xff;
3361 g &= 0xff; 3361 g &= 0xff;
3362 b &= 0xff; 3362 b &= 0xff;
3363 3363
3364 unsigned int color = (r << 16) | (g << 8) | b; 3364 unsigned int color = (r << 16) | (g << 8) | b;
3365 unsigned int idx_r = r / (0xff / (Red_levels - 1)); 3365 unsigned int idx_r = r * (Red_levels - 1) / 0xff;
3366 unsigned int idx_g = g / (0xff / (Green_levels - 1)); 3366 unsigned int idx_g = g * (Green_levels - 1) / 0xff;
3367 unsigned int idx_b = b / (0xff / (Blue_levels - 1)); 3367 unsigned int idx_b = b * (Blue_levels - 1) / 0xff;
3368 unsigned int idx = colorcube_index (idx_r, idx_g, idx_b); 3368 unsigned int idx = colorcube_index (idx_r, idx_g, idx_b);
3369 3369
3370 /* we allow one of the 6 directly neighbouring colours */
3371 /* to replace the current color, if they not used recently */
3372 static const signed char dxyz[][3] = {
3373 0, 0, 0,
3374 0, 0, +1,
3375 0, 0, -1,
3376 0, +1, 0,
3377 0, -1, 0,
3378 +1, 0, 0,
3379 -1, 0, 0,
3380 };
3381
3382 for (int n = 0; n < ecb_array_length (dxyz); ++n)
3383 {
3384 int r = idx_r + dxyz[n][0];
3385 int g = idx_r + dxyz[n][1];
3386 int b = idx_r + dxyz[n][2];
3387
3388 if (!IN_RANGE_EXC (r, 0, Red_levels )) continue;
3389 if (!IN_RANGE_EXC (g, 0, Green_levels)) continue;
3390 if (!IN_RANGE_EXC (b, 0, Blue_levels )) continue;
3391
3392 unsigned int index = colorcube_index (r, g, b);
3393
3394 if (rgb24_color[index] == color)
3395 {
3396 rgb24_seqno[index] = ++rgb24_sequence;
3397 return index + minTermCOLOR24;
3398 }
3399
3370 // minor issue: could update idx 0 few more times 3400 // minor issue: could update index 0 few more times
3371 if (rgb24_seqno[idx] == 0 3401 if ((rgb24_seqno[index] | rgb24_color[index]) == 0)
3372 && rgb24_color[idx] == 0) 3402 {
3403 idx = index;
3373 goto update; 3404 goto update;
3374
3375 if (rgb24_color[idx] == color)
3376 return idx + minTermCOLOR24;
3377
3378 for (int i = idx_r - 1; i <= (signed) idx_r + 1; i++)
3379 {
3380 if (!IN_RANGE_EXC (i, 0, Red_levels))
3381 continue;
3382
3383 for (int j = idx_g - 1; j <= (signed) idx_g + 1; j++)
3384 { 3405 }
3385 if (!IN_RANGE_EXC (j, 0, Green_levels))
3386 continue;
3387 3406
3388 for (int k = idx_b - 1; k <= (signed) idx_b + 1; k++)
3389 {
3390 if (!IN_RANGE_EXC (k, 0, Blue_levels))
3391 continue;
3392
3393 unsigned int index = colorcube_index (i, j, k);
3394
3395 // minor issue: could update index 0 few more times
3396 if (rgb24_seqno[index] == 0
3397 && rgb24_color[index] == 0)
3398 {
3399 idx = index;
3400 goto update;
3401 }
3402
3403 if (rgb24_color[index] == color)
3404 return index + minTermCOLOR24;
3405
3406 // like (rgb24_seqno[idx] > rgb24_seqno[index]) 3407 // like (rgb24_seqno[idx] > rgb24_seqno[index])
3407 // but also handles wrap around values good enough 3408 // but also handles wrap around values good enough
3408 if ((uint16_t) (rgb24_seqno[idx] - rgb24_seqno[index]) < 0x7fff) 3409 if ((uint16_t)(rgb24_seqno[idx] - rgb24_seqno[index]) < 0x7fff)
3409 idx = index; 3410 idx = index;
3410 }
3411 }
3412 } 3411 }
3413 3412
3414update: 3413update:
3415 rgb24_color[idx] = color; 3414 rgb24_color[idx] = color;
3416 rgb24_seqno[idx] = ++rgb24_sequence; 3415 rgb24_seqno[idx] = ++rgb24_sequence;
3417 3416
3418 idx += minTermCOLOR24; 3417 idx += minTermCOLOR24;
3419 pix_colors_focused [idx].free (this); 3418 pix_colors_focused [idx].free (this);
3420 pix_colors_focused [idx].set (this, rgba (r * 0x0101, 3419 pix_colors_focused [idx].set (this, rgba (r * 0x0101, g * 0x0101, b * 0x0101));
3421 g * 0x0101,
3422 b * 0x0101));
3423 update_fade_color (idx, false); 3420 update_fade_color (idx, false);
3424 3421
3425 return idx; 3422 return idx;
3426} 3423}
3427 3424

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines