… | |
… | |
30 | # include <X11/extensions/Xrender.h> |
30 | # include <X11/extensions/Xrender.h> |
31 | #endif |
31 | #endif |
32 | |
32 | |
33 | #ifndef FilterConvolution |
33 | #ifndef FilterConvolution |
34 | #define FilterConvolution "convolution" |
34 | #define FilterConvolution "convolution" |
35 | #endif |
|
|
36 | |
|
|
37 | #define DO_TIMING_TEST 0 |
|
|
38 | |
|
|
39 | #if DO_TIMING_TEST |
|
|
40 | # include <sys/time.h> |
|
|
41 | #define TIMING_TEST_START(id) \ |
|
|
42 | struct timeval timing_test_##id##_stv; \ |
|
|
43 | gettimeofday (&timing_test_##id##_stv, NULL); |
|
|
44 | |
|
|
45 | #define TIMING_TEST_PRINT_RESULT(id) \ |
|
|
46 | do { \ |
|
|
47 | struct timeval tv; \ |
|
|
48 | gettimeofday (&tv, NULL); \ |
|
|
49 | tv.tv_sec -= (timing_test_##id##_stv).tv_sec; \ |
|
|
50 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__, \ |
|
|
51 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec); \ |
|
|
52 | } while (0) |
|
|
53 | |
|
|
54 | #else |
|
|
55 | #define TIMING_TEST_START(id) do {} while (0) |
|
|
56 | #define TIMING_TEST_PRINT_RESULT(id) do {} while (0) |
|
|
57 | #endif |
35 | #endif |
58 | |
36 | |
59 | /* |
37 | /* |
60 | * Pixmap geometry string interpretation : |
38 | * Pixmap geometry string interpretation : |
61 | * Each geometry string contains zero or one scale/position |
39 | * Each geometry string contains zero or one scale/position |
… | |
… | |
101 | #ifdef ENABLE_TRANSPARENCY |
79 | #ifdef ENABLE_TRANSPARENCY |
102 | shade = 100; |
80 | shade = 100; |
103 | #endif |
81 | #endif |
104 | flags = 0; |
82 | flags = 0; |
105 | pixmap = None; |
83 | pixmap = None; |
106 | valid_since = invalid_since = 0; |
84 | valid_since = 0; |
107 | target = 0; |
85 | target = 0; |
108 | target_x = target_y = 0; |
86 | target_x = target_y = 0; |
109 | } |
87 | } |
110 | |
88 | |
111 | void |
89 | void |
… | |
… | |
418 | |
396 | |
419 | # ifdef ENABLE_TRANSPARENCY |
397 | # ifdef ENABLE_TRANSPARENCY |
420 | if (background_flags) |
398 | if (background_flags) |
421 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
399 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
422 | |
400 | |
423 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
401 | if (background_flags & tintNeeded) |
424 | { |
402 | { |
425 | ShadingInfo as_shade; |
403 | ShadingInfo as_shade; |
426 | as_shade.shading = shade; |
404 | as_shade.shading = shade; |
427 | |
405 | |
428 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
406 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
… | |
… | |
433 | as_shade.tintColor.blue = c.b; |
411 | as_shade.tintColor.blue = c.b; |
434 | |
412 | |
435 | background_tint = shading2tint32 (&as_shade); |
413 | background_tint = shading2tint32 (&as_shade); |
436 | } |
414 | } |
437 | |
415 | |
438 | if (!(background_flags & transpPmapBlurred) && (flags & blurNeeded) && background != NULL) |
416 | if ((background_flags & blurNeeded) && background != NULL) |
439 | { |
417 | { |
440 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
418 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
441 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
419 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
442 | 100, ASIMAGE_QUALITY_DEFAULT); |
420 | 100, ASIMAGE_QUALITY_DEFAULT); |
443 | if (tmp) |
421 | if (tmp) |
… | |
… | |
1046 | |
1024 | |
1047 | if (new_shade != shade) |
1025 | if (new_shade != shade) |
1048 | { |
1026 | { |
1049 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
1027 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
1050 | shade = new_shade; |
1028 | shade = new_shade; |
1051 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
1029 | flags = (flags & ~tintFlags) | new_flags; |
1052 | return true; |
1030 | return true; |
1053 | } |
1031 | } |
1054 | |
1032 | |
1055 | return false; |
1033 | return false; |
1056 | } |
1034 | } |
… | |
… | |
1352 | gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1330 | gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1353 | |
1331 | |
1354 | if (gc) |
1332 | if (gc) |
1355 | { |
1333 | { |
1356 | XFillRectangle (dpy, pixmap, gc, 0, 0, window_width, window_height); |
1334 | XFillRectangle (dpy, pixmap, gc, 0, 0, window_width, window_height); |
1357 | result |= transpPmapTiled; |
1335 | result |= isValid | (flags & effectsFlags); |
1358 | XFreeGC (dpy, gc); |
1336 | XFreeGC (dpy, gc); |
1359 | |
1337 | |
1360 | if (!(flags & CLIENT_RENDER)) |
1338 | if (!(flags & CLIENT_RENDER)) |
1361 | { |
1339 | { |
1362 | if ((flags & blurNeeded) |
1340 | if ((flags & blurNeeded) |
1363 | && (flags & HAS_RENDER_CONV)) |
1341 | && (flags & HAS_RENDER_CONV)) |
1364 | { |
1342 | { |
1365 | if (blur_pixmap (pixmap, target->visual, window_width, window_height)) |
1343 | if (blur_pixmap (pixmap, target->visual, window_width, window_height)) |
1366 | result |= transpPmapBlurred; |
1344 | result &= ~blurNeeded; |
1367 | } |
1345 | } |
1368 | if ((flags & tintNeeded) |
1346 | if ((flags & tintNeeded) |
1369 | && (flags & (tintWholesome | HAS_RENDER))) |
1347 | && (flags & (tintWholesome | HAS_RENDER))) |
1370 | { |
1348 | { |
1371 | if (tint_pixmap (pixmap, target->visual, window_width, window_height)) |
1349 | if (tint_pixmap (pixmap, target->visual, window_width, window_height)) |
1372 | result |= transpPmapTinted; |
1350 | result &= ~tintNeeded; |
1373 | } |
1351 | } |
1374 | } /* server side rendering completed */ |
1352 | } /* server side rendering completed */ |
1375 | } |
1353 | } |
1376 | |
1354 | |
1377 | if (recoded_root_pmap != root_pixmap) |
1355 | if (recoded_root_pmap != root_pixmap) |
… | |
… | |
1409 | { |
1387 | { |
1410 | /* we need to re-generate transparency pixmap in that case ! */ |
1388 | /* we need to re-generate transparency pixmap in that case ! */ |
1411 | background_flags = make_transparency_pixmap (); |
1389 | background_flags = make_transparency_pixmap (); |
1412 | if (background_flags == 0) |
1390 | if (background_flags == 0) |
1413 | return false; |
1391 | return false; |
1414 | else if ((background_flags & transpTransformations) == (flags & transpTransformations)) |
1392 | else if (!(background_flags & effectsFlags)) |
1415 | flags &= ~isInvalid; |
1393 | flags |= isValid; |
1416 | } |
1394 | } |
1417 | # endif |
1395 | # endif |
1418 | |
1396 | |
1419 | # ifdef BG_IMAGE_FROM_FILE |
1397 | # ifdef BG_IMAGE_FROM_FILE |
1420 | if (have_image |
1398 | if (have_image |
1421 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1399 | || (background_flags & effectsFlags)) |
1422 | { |
1400 | { |
1423 | if (render_image (background_flags)) |
1401 | if (render_image (background_flags)) |
1424 | flags &= ~isInvalid; |
1402 | flags |= isValid; |
1425 | } |
1403 | } |
1426 | # endif |
1404 | # endif |
1427 | |
1405 | |
1428 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1406 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1429 | XImage *result = NULL; |
1407 | XImage *result = NULL; |
1430 | |
1408 | |
1431 | if (background_flags && (flags & isInvalid)) |
1409 | if (background_flags && !(flags & isValid)) |
1432 | { |
1410 | { |
1433 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1411 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1434 | } |
1412 | } |
1435 | |
1413 | |
1436 | if (result) |
1414 | if (result) |
1437 | { |
1415 | { |
1438 | /* our own client-side tinting */ |
1416 | /* our own client-side tinting */ |
1439 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1417 | if (background_flags & tintNeeded) |
1440 | { |
1418 | { |
1441 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1419 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1442 | if (flags & tintSet) |
1420 | if (flags & tintSet) |
1443 | tint.get (c); |
1421 | tint.get (c); |
1444 | shade_ximage (DefaultVisual (target->dpy, target->display->screen), result, shade, c); |
1422 | shade_ximage (DefaultVisual (target->dpy, target->display->screen), result, shade, c); |
… | |
… | |
1449 | if (gc) |
1427 | if (gc) |
1450 | { |
1428 | { |
1451 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1429 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1452 | |
1430 | |
1453 | XFreeGC (target->dpy, gc); |
1431 | XFreeGC (target->dpy, gc); |
1454 | flags &= ~isInvalid; |
1432 | flags |= isValid; |
1455 | } |
1433 | } |
1456 | |
1434 | |
1457 | XDestroyImage (result); |
1435 | XDestroyImage (result); |
1458 | } |
1436 | } |
1459 | # endif |
1437 | # endif |
1460 | |
1438 | |
1461 | if (flags & isInvalid) |
1439 | if (!(flags & isValid)) |
1462 | { |
1440 | { |
1463 | if (pixmap != None) |
1441 | if (pixmap != None) |
1464 | { |
1442 | { |
1465 | XFreePixmap (target->dpy, pixmap); |
1443 | XFreePixmap (target->dpy, pixmap); |
1466 | pixmap = None; |
1444 | pixmap = None; |
1467 | } |
1445 | } |
1468 | } |
1446 | } |
1469 | |
1447 | |
1470 | apply (); |
1448 | target->scr_recolour (false); |
|
|
1449 | flags |= hasChanged; |
1471 | |
1450 | |
1472 | valid_since = ev::now (); |
1451 | valid_since = ev::now (); |
1473 | |
1452 | |
1474 | return true; |
1453 | return true; |
1475 | } |
1454 | } |
… | |
… | |
1492 | flags |= HAS_RENDER_CONV; |
1471 | flags |= HAS_RENDER_CONV; |
1493 | |
1472 | |
1494 | XFree (filters); |
1473 | XFree (filters); |
1495 | } |
1474 | } |
1496 | #endif |
1475 | #endif |
1497 | } |
|
|
1498 | |
|
|
1499 | void |
|
|
1500 | bgPixmap_t::apply () |
|
|
1501 | { |
|
|
1502 | if (target == NULL) |
|
|
1503 | return; |
|
|
1504 | |
|
|
1505 | if (pixmap != None) |
|
|
1506 | { |
|
|
1507 | /* set target's background to pixmap */ |
|
|
1508 | # ifdef ENABLE_TRANSPARENCY |
|
|
1509 | if (flags & isTransparent) |
|
|
1510 | { |
|
|
1511 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
|
|
1512 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
|
|
1513 | |
|
|
1514 | if (target->scrollBar.win) |
|
|
1515 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
|
|
1516 | } |
|
|
1517 | else |
|
|
1518 | # endif |
|
|
1519 | { |
|
|
1520 | /* force old pixmap dereference in case it was transparent before :*/ |
|
|
1521 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
|
|
1522 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
|
|
1523 | /* do we also need to set scrollbar's background here ? */ |
|
|
1524 | |
|
|
1525 | if (target->scrollBar.win) |
|
|
1526 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
|
|
1527 | } |
|
|
1528 | } |
|
|
1529 | else |
|
|
1530 | { |
|
|
1531 | /* set target background to a pixel */ |
|
|
1532 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
|
|
1533 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
|
|
1534 | /* do we also need to set scrollbar's background here ? */ |
|
|
1535 | if (target->scrollBar.win) |
|
|
1536 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
|
|
1537 | } |
|
|
1538 | |
|
|
1539 | /* don't want Expose on the parent or vt. It is better to use |
|
|
1540 | scr_touch or we get a great deal of flicker otherwise: */ |
|
|
1541 | XClearWindow (target->dpy, target->parent[0]); |
|
|
1542 | |
|
|
1543 | if (target->scrollBar.state && target->scrollBar.win) |
|
|
1544 | { |
|
|
1545 | target->scrollBar.state = STATE_IDLE; |
|
|
1546 | target->scrollBar.show (0); |
|
|
1547 | } |
|
|
1548 | |
|
|
1549 | target->want_refresh = 1; |
|
|
1550 | flags |= hasChanged; |
|
|
1551 | } |
1476 | } |
1552 | |
1477 | |
1553 | #endif /* HAVE_BG_PIXMAP */ |
1478 | #endif /* HAVE_BG_PIXMAP */ |
1554 | |
1479 | |
1555 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1480 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |