Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsImageGTK.cpp File Reference
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "imgScaler.h"
#include "nsImageGTK.h"
#include "nsRenderingContextGTK.h"
#include "nspr.h"

Go to the source code of this file.

Defines

#define IsFlagSet(a, b)   ((a) & (b))
#define NS_GET_BIT(rowptr, x)   (rowptr[(x)>>3] & (1<<(7-(x)&0x7)))
#define NS_SET_BIT(rowptr, x)   (rowptr[(x)>>3] |= (1<<(7-(x)&0x7)))
#define NS_CLEAR_BIT(rowptr, x)   (rowptr[(x)>>3] &= ~(1<<(7-(x)&0x7)))
#define sign(x)   ((x)>0 ? 1:-1)

Functions

static void XlibStretchHorizontal (long x1, long x2, long y1, long y2, long ymin, long ymax, long startColumn, long endColumn, long offsetX, long offsetY, GdkPixmap *aSrcImage, GdkPixmap *aDstImage, GdkGC *gc)
void XlibRectStretch (PRInt32 srcWidth, PRInt32 srcHeight, PRInt32 dstWidth, PRInt32 dstHeight, PRInt32 dstOrigX, PRInt32 dstOrigY, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight, GdkPixmap *aSrcImage, GdkPixmap *aDstImage, GdkGC *gc, GdkGC *copygc, PRInt32 aDepth)
static unsigned findIndex32 (unsigned mask)
static unsigned findIndex24 (unsigned mask)

Variables

static GdkGC * s1bitGC = nsnull
static GdkGC * sXbitGC = nsnull
static PRBool sNeedSlowTile = PR_FALSE

Define Documentation

#define IsFlagSet (   a,
  b 
)    ((a) & (b))

Definition at line 50 of file nsImageGTK.cpp.

#define NS_CLEAR_BIT (   rowptr,
  x 
)    (rowptr[(x)>>3] &= ~(1<<(7-(x)&0x7)))

Definition at line 54 of file nsImageGTK.cpp.

#define NS_GET_BIT (   rowptr,
  x 
)    (rowptr[(x)>>3] & (1<<(7-(x)&0x7)))

Definition at line 52 of file nsImageGTK.cpp.

#define NS_SET_BIT (   rowptr,
  x 
)    (rowptr[(x)>>3] |= (1<<(7-(x)&0x7)))

Definition at line 53 of file nsImageGTK.cpp.

#define sign (   x)    ((x)>0 ? 1:-1)

Definition at line 489 of file nsImageGTK.cpp.


Function Documentation

static unsigned findIndex24 ( unsigned  mask) [static]

Definition at line 1010 of file nsImageGTK.cpp.

{
  switch (mask) {
  case 0xff:
    return 2;
  case 0xff00:
    return 1;
  case 0xff0000:
    return 0;
  default:
    return 0;
  }
}

Here is the caller graph for this function:

static unsigned findIndex32 ( unsigned  mask) [static]

Definition at line 993 of file nsImageGTK.cpp.

{
  switch (mask) {
  case 0xff:
    return 3;
  case 0xff00:
    return 2;
  case 0xff0000:
    return 1;
  case 0xff000000:
    return 0;
  default:
    return 0;
  }
}

Here is the caller graph for this function:

void XlibRectStretch ( PRInt32  srcWidth,
PRInt32  srcHeight,
PRInt32  dstWidth,
PRInt32  dstHeight,
PRInt32  dstOrigX,
PRInt32  dstOrigY,
PRInt32  aDX,
PRInt32  aDY,
PRInt32  aDWidth,
PRInt32  aDHeight,
GdkPixmap *  aSrcImage,
GdkPixmap *  aDstImage,
GdkGC *  gc,
GdkGC *  copygc,
PRInt32  aDepth 
)

Definition at line 511 of file nsImageGTK.cpp.

{
  long dx,dy,e,d,dx2;
  short sx,sy;
  GdkPixmap *aTmpImage = 0;
  PRBool skipHorizontal=PR_FALSE, skipVertical=PR_FALSE;
  long startColumn, startRow, endColumn, endRow;
  long xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

  xs1 = ys1 = xd1 = yd1 = 0;
  xs2 = srcWidth-1;
  ys2 = srcHeight-1;
  xd2 = dstWidth-1;
  yd2 = dstHeight-1;

//  fprintf(stderr, "XRS %p (%ld %ld)-(%ld %ld) (%ld %ld)-(%ld %ld)\n",
//          (void *)aDstImage, xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2);
  
  startColumn = aDX-dstOrigX;
  startRow    = aDY-dstOrigY;
  endColumn   = aDX+aDWidth-dstOrigX;
  endRow      = aDY+aDHeight-dstOrigY;

//  fprintf(stderr, "startXY = %d %d  endXY = %d %d   %d x %d\n",
//          startColumn, startRow, endColumn, endRow,
//          endColumn-startColumn, endRow-startRow);

  long scaleStartY, scaleEndY;
  scaleStartY = startRow * (ys2-ys1+1) / (yd2-yd1+1);
  scaleEndY   = 1 + endRow * (ys2-ys1+1) / (yd2-yd1+1);

  if (xd2-xd1 == xs2-xs1) {
//    fprintf(stderr, "skipping horizontal\n");
    skipHorizontal = PR_TRUE;
    aTmpImage = aSrcImage;
    scaleStartY = 0;
    scaleEndY = ys2;
  }

  if (yd2-yd1 == ys2-ys1) {
//    fprintf(stderr, "skipping vertical\n");
    skipVertical = PR_TRUE;
    aTmpImage = aDstImage;
  }

  if (skipVertical && skipHorizontal) {
    gdk_draw_pixmap(aDstImage, gc, aSrcImage,
                    0, 0, srcWidth, srcHeight,
                    dstOrigX, dstOrigY);
    return;
  }

//  fprintf(stderr, "scaleY Start/End = %d %d\n", scaleStartY, scaleEndY);

  if (!skipHorizontal && !skipVertical) {
    aTmpImage = gdk_pixmap_new(nsnull,
                               endColumn-startColumn,
                               scaleEndY-scaleStartY,
                               aDepth);
#ifdef MOZ_WIDGET_GTK2
    if (aDepth != 1)
      gdk_drawable_set_colormap(GDK_DRAWABLE(aTmpImage),
                                gdk_rgb_get_colormap());
#endif
  }
 
  dx = abs((int)(yd2-yd1));
  dy = abs((int)(ys2-ys1));
  sx = sign(yd2-yd1);
  sy = sign(ys2-ys1);
  e = dy-dx;
  dx2 = dx;
  dy += 1;
  if (!dx2) dx2=1;

  if (!skipHorizontal)
    XlibStretchHorizontal(xd1, xd2, xs1, xs2, scaleStartY, scaleEndY,
                          startColumn, endColumn,
                          skipVertical?dstOrigX:-startColumn, skipVertical?dstOrigY:-scaleStartY,
                          aSrcImage, aTmpImage, (skipVertical?gc:copygc));
  
  if (!skipVertical) {
    for (d=0; d<=dx; d++) {
      if ((yd1 >= startRow) && (yd1 <= endRow)) {
        gdk_draw_pixmap(aDstImage, gc, aTmpImage,
                        (skipHorizontal?startColumn:0), ys1-scaleStartY,
                        aDX, dstOrigY+yd1,
                        endColumn-startColumn, 1);
      }
      while (e>=0) {
             ys1 += sy;
             e -= dx2;
      }
      yd1 += sx;
      e += dy;
    }
  }

  if (!skipHorizontal && !skipVertical)
    gdk_pixmap_unref(aTmpImage);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void XlibStretchHorizontal ( long  x1,
long  x2,
long  y1,
long  y2,
long  ymin,
long  ymax,
long  startColumn,
long  endColumn,
long  offsetX,
long  offsetY,
GdkPixmap *  aSrcImage,
GdkPixmap *  aDstImage,
GdkGC *  gc 
) [static]

Definition at line 630 of file nsImageGTK.cpp.

{
  long dx,dy,e,d,dx2;
  short sx,sy;

  dx = abs((int)(x2-x1));
  dy = abs((int)(y2-y1));
  sx = sign(x2-x1);
  sy = sign(y2-y1);
  e = dy-dx;
  dx2 = dx;
  dy += 1;
  if (!dx2) dx2=1;
  for (d=0; d<=dx; d++) {
    if ((x1 >= startColumn) && (x1 <= endColumn)) {
      gdk_draw_pixmap(aDstImage, gc, aSrcImage,
                      y1, ymin, x1+offsetX, ymin+offsetY,
                      1, ymax-ymin);
    }
    while (e>=0) {
      y1 += sy;
      e -= dx2;
    }
    x1 += sx;
    e += dy;
  }
}

Here is the caller graph for this function:


Variable Documentation

GdkGC* s1bitGC = nsnull [static]

Definition at line 70 of file nsImageGTK.cpp.

Definition at line 75 of file nsImageGTK.cpp.

GdkGC* sXbitGC = nsnull [static]

Definition at line 71 of file nsImageGTK.cpp.