~ubuntu-branches/ubuntu/quantal/xscreensaver/quantal

« back to all changes in this revision

Viewing changes to OSX/jwxyz.m

  • Committer: Bazaar Package Importer
  • Author(s): Ted Gould
  • Date: 2008-08-28 16:15:25 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080828161525-mxga521aoezxjq8h
Tags: 5.07-0ubuntu1
* Upgrade upstream version
* debian/control: Remove suggest xdaliclock as it is no longer
  included
* Remove 10_jwz-screensaver-randr-patch-3.patch as it has been merged
  upstream.
* Add 24_hacks_xsublim_enable.patch as it seems that xsublim was dropped
  from the build files.  There is nothing in the Changelog about it
  so I believe it was accidental.
* Updating the .desktop files from the XML files using gnome-screensaver's
  utility to do so.  Lots of text updates.  Also:
    * Added: abstractile.desktop
    * Added: cwaves.desktop
    * Added: m6502.desktop
    * Added: skytentacles.desktop
    * Removed: xteevee.desktop
* xscreensaver-gl-extra.files: Added skytentacles
* xscreensaver-data-extra.files: Added abstractile, cwaves and m6502
* xscreensaver-data.files: Remove partial abstractile, m6502 and cwaves

Show diffs side-by-side

added added

removed removed

Lines of Context:
1479
1479
{
1480
1480
  CGRect wr = d->frame;
1481
1481
 
 
1482
  Assert ((w < 65535), "improbably large width");
 
1483
  Assert ((h < 65535), "improbably large height");
 
1484
  Assert ((src_x  < 65535 && src_x  > -65535), "improbably large src_x");
 
1485
  Assert ((src_y  < 65535 && src_y  > -65535), "improbably large src_y");
 
1486
  Assert ((dest_x < 65535 && dest_x > -65535), "improbably large dest_x");
 
1487
  Assert ((dest_y < 65535 && dest_y > -65535), "improbably large dest_y");
 
1488
 
1482
1489
  // Clip width and height to the bounds of the Drawable
1483
1490
  //
1484
1491
  if (dest_x + w > wr.size.width) {
1608
1615
  int depth, ibpp, ibpl;
1609
1616
  NSBitmapImageRep *bm = 0;
1610
1617
  
 
1618
  Assert ((width  < 65535), "improbably large width");
 
1619
  Assert ((height < 65535), "improbably large height");
 
1620
  Assert ((x < 65535 && x > -65535), "improbably large x");
 
1621
  Assert ((y < 65535 && y > -65535), "improbably large y");
 
1622
 
1611
1623
  if (d->type == PIXMAP) {
1612
1624
    depth = d->pixmap.depth;
1613
1625
    ibpp = CGBitmapContextGetBitsPerPixel (d->cgc);
1628
1640
    ibpl = [bm bytesPerRow];
1629
1641
    data = [bm bitmapData];
1630
1642
    Assert (data, "NSBitmapImageRep initWithFocusedViewRect failed");
1631
 
 
1632
 
    data += (y * ibpl) + (x * (ibpp/8));
1633
1643
  }
1634
1644
  
 
1645
  // data points at (x,y) with ibpl rowstride.  ignore x,y from now on.
 
1646
  data += (y * ibpl) + (x * (ibpp/8));
 
1647
  
1635
1648
  format = (depth == 1 ? XYPixmap : ZPixmap);
1636
1649
  XImage *image = XCreateImage (dpy, 0, depth, format, 0, 0, width, height,
1637
1650
                                0, 0);
1646
1659
  int xx, yy;
1647
1660
  if (depth == 1) {
1648
1661
    const unsigned char *iline = data;
1649
 
    for (yy = y; yy < y+height; yy++) {
 
1662
    for (yy = 0; yy < height; yy++) {
1650
1663
 
1651
1664
      const unsigned char *iline2 = iline;
1652
 
      for (xx = x; xx < x+width; xx++) {
 
1665
      for (xx = 0; xx < width; xx++) {
1653
1666
 
1654
1667
        iline2++;                     // ignore b or a
1655
1668
        iline2++;                     // ignore g or r
1664
1677
    Assert (ibpp == 24 || ibpp == 32, "weird obpp");
1665
1678
    const unsigned char *iline = data;
1666
1679
    unsigned char *oline = (unsigned char *) image->data;
1667
 
    oline += (y * obpl);
1668
 
    for (yy = y; yy < y+height; yy++) {
 
1680
    for (yy = 0; yy < height; yy++) {
1669
1681
 
1670
1682
      const unsigned char *iline2 = iline;
1671
1683
      unsigned char *oline2 = oline;
1672
 
      for (xx = x; xx < x+width; xx++) {
 
1684
      for (xx = 0; xx < width; xx++) {
1673
1685
 
1674
1686
        unsigned char a = (ibpp == 32 ? (*iline2++) : 0xFF);
1675
1687
        unsigned char r = *iline2++;
1681
1693
                               (b <<  0));
1682
1694
        *((unsigned int *) oline2) = pixel;
1683
1695
        oline2 += 4;
1684
 
     }
 
1696
      }
1685
1697
      oline += obpl;
1686
1698
      iline += ibpl;
1687
1699
    }
2014
2026
          char **name_ret)
2015
2027
{
2016
2028
  Assert (size > 0, "zero font size");
2017
 
  const char *prefix = (fixed ? "Monaco" : (serif ? "Times" : "Helvetica"));
2018
 
  const char *suffix = (bold && ital
2019
 
                        ? (serif ? "-BoldItalic" : "-BoldOblique")
2020
 
                        : (bold ? "-Bold" :
2021
 
                           ital ? (serif ? "-Italic" : "-Oblique") : ""));
2022
 
  char *name = (char *) malloc (strlen(prefix) + strlen(suffix) + 1);
2023
 
  strcpy (name, prefix);
2024
 
  strcat (name, suffix);
 
2029
  const char *name;
 
2030
 
 
2031
  if (fixed) {
 
2032
    // 
 
2033
    // "Monaco" only exists in plain.
 
2034
    // "LucidaSansTypewriterStd" gets an AGL bad value error.
 
2035
    // 
 
2036
    if (bold && ital) name = "Courier-BoldOblique";
 
2037
    else if (bold)    name = "Courier-Bold";
 
2038
    else if (ital)    name = "Courier-Oblique";
 
2039
    else              name = "Courier";
 
2040
 
 
2041
  } else if (serif) {
 
2042
    // 
 
2043
    // "Georgia" looks better than "Times".
 
2044
    // 
 
2045
    if (bold && ital) name = "Georgia-BoldItalic";
 
2046
    else if (bold)    name = "Georgia-Bold";
 
2047
    else if (ital)    name = "Georgia-Italic";
 
2048
    else              name = "Georgia";
 
2049
 
 
2050
  } else {
 
2051
    // 
 
2052
    // "Geneva" only exists in plain.
 
2053
    // "LucidaSansStd-BoldItalic" gets an AGL bad value error.
 
2054
    // "Verdana" renders smoother than "Helvetica" for some reason.
 
2055
    // 
 
2056
    if (bold && ital) name = "Verdana-BoldItalic";
 
2057
    else if (bold)    name = "Verdana-Bold";
 
2058
    else if (ital)    name = "Verdana-Italic";
 
2059
    else              name = "Verdana";
 
2060
  }
2025
2061
 
2026
2062
  NSString *nsname = [NSString stringWithCString:name
2027
2063
                                        encoding:NSUTF8StringEncoding];
2028
2064
  NSFont *f = [NSFont fontWithName:nsname size:size];
2029
 
  if (f) {
2030
 
    *name_ret = name;
2031
 
  } else {
2032
 
    free (name);
2033
 
  }
 
2065
  if (f)
 
2066
    *name_ret = strdup(name);
2034
2067
  return f;
2035
2068
}
2036
2069
 
2065
2098
static NSFont *
2066
2099
random_font (BOOL bold, BOOL ital, float size, char **name_ret)
2067
2100
{
2068
 
  NSFontTraitMask mask = ((bold ? NSUnboldFontMask   : NSBoldFontMask) |
2069
 
                          (ital ? NSUnitalicFontMask : NSItalicFontMask));
 
2101
  NSFontTraitMask mask = ((bold ? NSBoldFontMask   : NSUnboldFontMask) |
 
2102
                          (ital ? NSItalicFontMask : NSUnitalicFontMask));
2070
2103
  NSArray *fonts = [[NSFontManager sharedFontManager]
2071
2104
                     availableFontNamesWithTraits:mask];
2072
2105
  if (!fonts) return 0;