~cyphermox/ubuntu/precise/xscreensaver/merge-5.15-2

« back to all changes in this revision

Viewing changes to OSX/jwxyz.m

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-06-29 09:30:05 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090629093005-kcpcwnmr3nw4dlpo
Tags: 5.08-0ubuntu1
* New upstream release (LP: #392374)
  - New hack, `photopile'.
  - Rewrote `sonar' and `jigsaw' as OpenGL programs.
  - Minor tweaks to `maze', `m6502', `hypnowheel', and `timetunnel'.
  - Savers that load images now obey EXIF rotation tags.
  - Arrgh, more RANDR noise!  Fixes this time for rotated screens, and for
    systems where RANDR lies and says the screen size is 0x0.
  - When the password dialog has timed out or been cancelled, don't pop it
    right back up a second time.
  - Password timeouts/cancels don't count as "failed logins".
  - Retired some of the older, less interesting savers:
    say goodbye to `bubbles', `critical', `flag', `forest',
    `glforestfire', `lmorph', `laser', `lightning', `lisa',
    `lissie', `rotor', `sphere', `spiral', `t3d', `vines',
    `whirlygig', and `worm'.
  - Merged `munch' and `mismunch'.
  - Updated `webcollage' to use twitpics.com as well.
* debian/patches/20_hacks_Makefile.patch:
  - Refreshed
* debian/patches/24_hacks_xsublim_enable.patch:
  - Refreshed
* debian/patches/25_xsublim_missing_man_page.patch
  - Put back removed man page
* debian/patches/53_XScreenSaver.ad.in.patch:
  - Refreshed
* debian/screensavers-desktop-files/*:
  debian/xscreensaver.files:
  debian/xscreensaver-data-extra.files:
  debian/xscreensaver-gl-extra.files:
  - Updated for new/removed/changed screensavers
* debian/control: Added Bzr link

Show diffs side-by-side

added added

removed removed

Lines of Context:
395
395
  int i;
396
396
  CGRect wr = d->frame;
397
397
 
 
398
  push_fg_gc (d, gc, YES);
 
399
 
398
400
# ifdef XDRAWPOINTS_IMAGES
399
401
 
400
402
  unsigned int argb = gc->gcv.foreground;
440
442
  CGRect *rects = (CGRect *) malloc (count * sizeof(CGRect));
441
443
  CGRect *r = rects;
442
444
  
443
 
  push_fg_gc (d, gc, YES);
444
445
  for (i = 0; i < count; i++) {
445
446
    r->size.width = r->size.height = 1;
446
447
    if (i > 0 && mode == CoordModePrevious) {
459
460
 
460
461
# endif /* ! XDRAWPOINTS_IMAGES */
461
462
 
 
463
  pop_gc (d, gc);
 
464
 
462
465
  return 0;
463
466
}
464
467
 
1704
1707
  return image;
1705
1708
}
1706
1709
 
 
1710
 
 
1711
/* Returns a transformation matrix to do rotation as per the provided
 
1712
   EXIF "Orientation" value.
 
1713
 */
 
1714
static CGAffineTransform
 
1715
exif_rotate (int rot, CGSize rect)
 
1716
{
 
1717
  CGAffineTransform trans = CGAffineTransformIdentity;
 
1718
  switch (rot) {
 
1719
  case 2:               // flip horizontal
 
1720
    trans = CGAffineTransformMakeTranslation (rect.width, 0);
 
1721
    trans = CGAffineTransformScale (trans, -1, 1);
 
1722
    break;
 
1723
 
 
1724
  case 3:               // rotate 180
 
1725
    trans = CGAffineTransformMakeTranslation (rect.width, rect.height);
 
1726
    trans = CGAffineTransformRotate (trans, M_PI);
 
1727
    break;
 
1728
 
 
1729
  case 4:               // flip vertical
 
1730
    trans = CGAffineTransformMakeTranslation (0, rect.height);
 
1731
    trans = CGAffineTransformScale (trans, 1, -1);
 
1732
    break;
 
1733
 
 
1734
  case 5:               // transpose (UL-to-LR axis)
 
1735
    trans = CGAffineTransformMakeTranslation (rect.height, rect.width);
 
1736
    trans = CGAffineTransformScale (trans, -1, 1);
 
1737
    trans = CGAffineTransformRotate (trans, 3 * M_PI / 2);
 
1738
    break;
 
1739
 
 
1740
  case 6:               // rotate 90
 
1741
    trans = CGAffineTransformMakeTranslation (0, rect.width);
 
1742
    trans = CGAffineTransformRotate (trans, 3 * M_PI / 2);
 
1743
    break;
 
1744
 
 
1745
  case 7:               // transverse (UR-to-LL axis)
 
1746
    trans = CGAffineTransformMakeScale (-1, 1);
 
1747
    trans = CGAffineTransformRotate (trans, M_PI / 2);
 
1748
    break;
 
1749
 
 
1750
  case 8:               // rotate 270
 
1751
    trans = CGAffineTransformMakeTranslation (rect.height, 0);
 
1752
    trans = CGAffineTransformRotate (trans, M_PI / 2);
 
1753
    break;
 
1754
 
 
1755
  default: 
 
1756
    break;
 
1757
  }
 
1758
 
 
1759
  return trans;
 
1760
}
 
1761
 
 
1762
 
1707
1763
void
1708
1764
jwxyz_draw_NSImage (Display *dpy, Drawable d, void *nsimg_arg,
1709
 
                    XRectangle *geom_ret)
 
1765
                    XRectangle *geom_ret, int exif_rotation)
1710
1766
{
1711
1767
  NSImage *nsimg = (NSImage *) nsimg_arg;
1712
1768
 
1721
1777
  CGImageRef cgi = CGImageSourceCreateImageAtIndex (cgsrc, 0, NULL);
1722
1778
 
1723
1779
  NSSize imgr = [nsimg size];
 
1780
  Bool rot_p = (exif_rotation >= 5);
 
1781
 
 
1782
  if (rot_p)
 
1783
    imgr = NSMakeSize (imgr.height, imgr.width);
 
1784
 
1724
1785
  CGRect winr = d->frame;
1725
1786
  float rw = winr.size.width  / imgr.width;
1726
1787
  float rh = winr.size.height / imgr.height;
1727
1788
  float r = (rw < rh ? rw : rh);
1728
1789
 
1729
 
  CGRect dst;
 
1790
  CGRect dst, dst2;
1730
1791
  dst.size.width  = imgr.width  * r;
1731
1792
  dst.size.height = imgr.height * r;
1732
1793
  dst.origin.x = (winr.size.width  - dst.size.width)  / 2;
1733
1794
  dst.origin.y = (winr.size.height - dst.size.height) / 2;
1734
1795
 
 
1796
  dst2.origin.x = dst2.origin.y = 0;
 
1797
  if (rot_p) {
 
1798
    dst2.size.width = dst.size.height; 
 
1799
    dst2.size.height = dst.size.width;
 
1800
  } else {
 
1801
    dst2.size = dst.size;
 
1802
  }
 
1803
 
1735
1804
  // Clear the part not covered by the image to background or black.
1736
1805
  //
1737
1806
  if (d->type == WINDOW)
1741
1810
    draw_rect (dpy, d, 0, 0, 0, winr.size.width, winr.size.height, NO, YES);
1742
1811
  }
1743
1812
 
 
1813
  CGAffineTransform trans = 
 
1814
    exif_rotate (exif_rotation, rot_p ? dst2.size : dst.size);
 
1815
 
 
1816
  CGContextSaveGState (d->cgc);
 
1817
  CGContextConcatCTM (d->cgc, 
 
1818
                      CGAffineTransformMakeTranslation (dst.origin.x,
 
1819
                                                        dst.origin.y));
 
1820
  CGContextConcatCTM (d->cgc, trans);
1744
1821
  //Assert (CGImageGetColorSpace (cgi) == dpy->colorspace, "bad colorspace");
1745
 
  CGContextDrawImage (d->cgc, dst, cgi);
 
1822
  CGContextDrawImage (d->cgc, dst2, cgi);
 
1823
  CGContextRestoreGState (d->cgc);
1746
1824
 
1747
1825
  CFRelease (cgsrc);
1748
1826
  CGImageRelease (cgi);