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

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.175 by sf-exg, Mon Dec 5 18:17:17 2011 UTC vs.
Revision 1.180 by sf-exg, Sat Dec 24 09:44:23 2011 UTC

201 x = y = 0; 201 x = y = 0;
202 geom_flags = WidthValue|HeightValue|XValue|YValue; 202 geom_flags = WidthValue|HeightValue|XValue|YValue;
203 } 203 }
204 else if (!strcasecmp (arr[i], "style=aspect-stretched")) 204 else if (!strcasecmp (arr[i], "style=aspect-stretched"))
205 { 205 {
206 new_flags = BG_PROP_SCALE; 206 new_flags = BG_KEEP_ASPECT;
207 w = h = windowScale; 207 w = h = windowScale;
208 x = y = centerAlign; 208 x = y = centerAlign;
209 geom_flags = WidthValue|HeightValue|XValue|YValue; 209 geom_flags = WidthValue|HeightValue|XValue|YValue;
210 } 210 }
211 else if (!strcasecmp (arr[i], "style=stretched")) 211 else if (!strcasecmp (arr[i], "style=stretched"))
227 w = h = noScale; 227 w = h = noScale;
228 geom_flags = WidthValue|HeightValue; 228 geom_flags = WidthValue|HeightValue;
229 } 229 }
230 else if (!strcasecmp (arr[i], "op=tile")) 230 else if (!strcasecmp (arr[i], "op=tile"))
231 new_flags |= BG_TILE; 231 new_flags |= BG_TILE;
232 else if (!strcasecmp (arr[i], "op=pscale")) 232 else if (!strcasecmp (arr[i], "op=keep-aspect"))
233 new_flags |= BG_PROP_SCALE; 233 new_flags |= BG_KEEP_ASPECT;
234 else if (!strcasecmp (arr[i], "op=root")) 234 else if (!strcasecmp (arr[i], "op=root-align"))
235 new_flags |= BG_ROOT_ALIGN; 235 new_flags |= BG_ROOT_ALIGN;
236 236
237 // deprecated 237 // deprecated
238 else if (!strcasecmp (arr[i], "tile")) 238 else if (!strcasecmp (arr[i], "tile"))
239 { 239 {
241 w = h = noScale; 241 w = h = noScale;
242 geom_flags |= WidthValue|HeightValue; 242 geom_flags |= WidthValue|HeightValue;
243 } 243 }
244 else if (!strcasecmp (arr[i], "propscale")) 244 else if (!strcasecmp (arr[i], "propscale"))
245 { 245 {
246 new_flags |= BG_PROP_SCALE; 246 new_flags |= BG_KEEP_ASPECT;
247 w = h = windowScale;
248 geom_flags |= WidthValue|HeightValue;
247 } 249 }
248 else if (!strcasecmp (arr[i], "hscale")) 250 else if (!strcasecmp (arr[i], "hscale"))
249 { 251 {
250 new_flags |= BG_TILE; 252 new_flags |= BG_TILE;
251 w = windowScale; 253 w = windowScale;
322 int target_height = szHint.height; 324 int target_height = szHint.height;
323 325
324 w = h_scale * target_width / 100; 326 w = h_scale * target_width / 100;
325 h = v_scale * target_height / 100; 327 h = v_scale * target_height / 100;
326 328
327 if (bg_flags & BG_PROP_SCALE) 329 if (bg_flags & BG_KEEP_ASPECT)
328 { 330 {
329 float scale = (float)w / image_width; 331 float scale = (float)w / image_width;
330 min_it (scale, (float)h / image_height); 332 min_it (scale, (float)h / image_height);
331 w = image_width * scale + 0.5; 333 w = image_width * scale + 0.5;
332 h = image_height * scale + 0.5; 334 h = image_height * scale + 0.5;
1275 bg_pmap_width = window_width; 1277 bg_pmap_width = window_width;
1276 bg_pmap_height = window_height; 1278 bg_pmap_height = window_height;
1277 } 1279 }
1278 1280
1279 /* straightforward pixmap copy */ 1281 /* straightforward pixmap copy */
1280 while (sx < 0) sx += root_width; 1282 while (sx < 0) sx += root_pmap_width;
1281 while (sy < 0) sy += root_height; 1283 while (sy < 0) sy += root_pmap_height;
1282 1284
1283 gcv.tile = recoded_root_pmap; 1285 gcv.tile = recoded_root_pmap;
1284 gcv.fill_style = FillTiled; 1286 gcv.fill_style = FillTiled;
1285 gcv.ts_x_origin = -sx; 1287 gcv.ts_x_origin = -sx;
1286 gcv.ts_y_origin = -sy; 1288 gcv.ts_y_origin = -sy;
1433#endif /* HAVE_BG_PIXMAP */ 1435#endif /* HAVE_BG_PIXMAP */
1434 1436
1435#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1437#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1436/* based on code from aterm-0.4.2 */ 1438/* based on code from aterm-0.4.2 */
1437 1439
1440static inline void
1441fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high)
1442{
1443 for (int i = 0; i <= mask >> sh; i++)
1444 {
1445 uint32_t tmp;
1446 tmp = i * high;
1447 tmp += (mask >> sh) * low;
1448 lookup[i] = (tmp / 0xffff) << sh;
1449 }
1450}
1451
1438static void 1452static void
1439shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) 1453shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c)
1440{ 1454{
1441 int sh_r, sh_g, sh_b; 1455 int sh_r, sh_g, sh_b;
1442 uint32_t mask_r, mask_g, mask_b; 1456 uint32_t mask_r, mask_g, mask_b;
1443 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1457 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1444 rgba low; 1458 unsigned short low;
1445 rgba high; 1459 rgba high;
1446 int i;
1447 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; 1460 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1448 1461
1449 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1462 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1450 1463
1451 /* for convenience */ 1464 /* for convenience */
1519 1532
1520 high.r = c.r * shade / 100; 1533 high.r = c.r * shade / 100;
1521 high.g = c.g * shade / 100; 1534 high.g = c.g * shade / 100;
1522 high.b = c.b * shade / 100; 1535 high.b = c.b * shade / 100;
1523 1536
1524 low.r = 65535 * (100 - shade) / 100; 1537 low = 0xffff * (100 - shade) / 100;
1525 low.g = 65535 * (100 - shade) / 100;
1526 low.b = 65535 * (100 - shade) / 100;
1527 } 1538 }
1528 else 1539 else
1529 { 1540 {
1530 high.r = c.r * shade / 100; 1541 high.r = c.r * shade / 100;
1531 high.g = c.g * shade / 100; 1542 high.g = c.g * shade / 100;
1532 high.b = c.b * shade / 100; 1543 high.b = c.b * shade / 100;
1533 1544
1534 low.r = low.g = low.b = 0; 1545 low = 0;
1535 } 1546 }
1536 1547
1537 /* fill our lookup tables */ 1548 /* fill our lookup tables */
1538 for (i = 0; i <= mask_r>>sh_r; i++) 1549 fill_lut (lookup_r, mask_r, sh_r, low, high.r);
1539 { 1550 fill_lut (lookup_g, mask_g, sh_g, low, high.g);
1540 uint32_t tmp; 1551 fill_lut (lookup_b, mask_b, sh_b, low, high.b);
1541 tmp = i * high.r;
1542 tmp += (mask_r>>sh_r) * low.r;
1543 lookup_r[i] = (tmp/65535)<<sh_r;
1544 }
1545 for (i = 0; i <= mask_g>>sh_g; i++)
1546 {
1547 uint32_t tmp;
1548 tmp = i * high.g;
1549 tmp += (mask_g>>sh_g) * low.g;
1550 lookup_g[i] = (tmp/65535)<<sh_g;
1551 }
1552 for (i = 0; i <= mask_b>>sh_b; i++)
1553 {
1554 uint32_t tmp;
1555 tmp = i * high.b;
1556 tmp += (mask_b>>sh_b) * low.b;
1557 lookup_b[i] = (tmp/65535)<<sh_b;
1558 }
1559 1552
1560 /* apply table to input image (replacing colors by newly calculated ones) */ 1553 /* apply table to input image (replacing colors by newly calculated ones) */
1561 if (ximage->bits_per_pixel == 32 1554 if (ximage->bits_per_pixel == 32
1562 && (ximage->depth == 24 || ximage->depth == 32) 1555 && (ximage->depth == 24 || ximage->depth == 32)
1563 && ximage->byte_order == host_byte_order) 1556 && ximage->byte_order == host_byte_order)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines