Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
nsAntiAliasedGlyph Class Reference

#include <nsAntiAliasedGlyph.h>

List of all members.

Public Member Functions

 nsAntiAliasedGlyph (PRUint32 aWidth, PRUint32 aHeight, PRUint32 aBorder)
 ~nsAntiAliasedGlyph ()
PRBool Init ()
PRBool Init (PRUint8 *aBuffer, PRUint32 aBufferLen)
PRUint32 GetBorder ()
PRUint8GetBuffer ()
PRUint32 GetBufferLen ()
PRUint32 GetBufferWidth ()
PRUint32 GetBufferHeight ()
PRInt32 GetAdvance ()
PRInt32 GetLBearing ()
PRInt32 GetRBearing ()
PRUint32 GetWidth ()
PRUint32 GetHeight ()
PRBool SetImage (XCharStruct *, _XImage *)
PRBool SetSize (GlyphMetrics *)

Protected Attributes

PRUint32 mBorder
PRInt32 mAscent
PRInt32 mDescent
PRInt32 mLBearing
PRInt32 mRBearing
PRInt32 mAdvance
PRUint32 mWidth
PRUint32 mHeight
PRUint32 mMaxWidth
PRUint32 mMaxHeight
PRUint32 mBufferWidth
PRUint32 mBufferHeight
PRBool mOwnBuffer
PRUint8mBuffer
PRUint32 mBufferLen

Detailed Description

Definition at line 38 of file nsAntiAliasedGlyph.h.


Constructor & Destructor Documentation

nsAntiAliasedGlyph::nsAntiAliasedGlyph ( PRUint32  aWidth,
PRUint32  aHeight,
PRUint32  aBorder 
)

Definition at line 49 of file nsAntiAliasedGlyph.cpp.

{
  mMaxWidth = aMaxWidth;
  mMaxHeight = aMaxHeight;
  mBorder = aBorder;
  mBufferWidth  = mBorder + mMaxWidth  + mBorder;
  mBufferHeight = mBorder + mMaxHeight + mBorder;

  mAscent    = 0;
  mDescent   = 0;
  mLBearing  = 0;
  mRBearing  = 0;
  mWidth     = 0;
  mHeight    = 0;
  mAdvance   = 0;
  mOwnBuffer = PR_FALSE;
  mBuffer    = nsnull;
  mBufferLen = 0;
}

Definition at line 70 of file nsAntiAliasedGlyph.cpp.

{
  if (mOwnBuffer)
    nsMemory::Free(mBuffer);
}

Member Function Documentation

Definition at line 56 of file nsAntiAliasedGlyph.h.

{ return mAdvance; };

Definition at line 50 of file nsAntiAliasedGlyph.h.

{ return mBorder; };

Here is the caller graph for this function:

Definition at line 51 of file nsAntiAliasedGlyph.h.

{ return mBuffer; };

Here is the caller graph for this function:

Definition at line 54 of file nsAntiAliasedGlyph.h.

{ return mBufferHeight; };

Here is the caller graph for this function:

Definition at line 52 of file nsAntiAliasedGlyph.h.

{ return mBufferLen; };

Definition at line 53 of file nsAntiAliasedGlyph.h.

{ return mBufferWidth; };

Here is the caller graph for this function:

Definition at line 60 of file nsAntiAliasedGlyph.h.

{ return mHeight; };

Here is the caller graph for this function:

Definition at line 57 of file nsAntiAliasedGlyph.h.

{ return mLBearing; };

Here is the caller graph for this function:

Definition at line 58 of file nsAntiAliasedGlyph.h.

{ return mRBearing; };

Definition at line 59 of file nsAntiAliasedGlyph.h.

{ return mWidth; };

Here is the caller graph for this function:

Definition at line 77 of file nsAntiAliasedGlyph.cpp.

{
  return Init(nsnull, 0);
}

Here is the caller graph for this function:

PRBool nsAntiAliasedGlyph::Init ( PRUint8 aBuffer,
PRUint32  aBufferLen 
)

Definition at line 83 of file nsAntiAliasedGlyph.cpp.

{
  mBufferLen = mBufferWidth * mBufferHeight;
  if (aBufferLen >= mBufferLen) {
    mBuffer = aBuffer;
    mOwnBuffer = PR_FALSE;
  }
  else {
    mBuffer = (PRUint8 *)nsMemory::Alloc(mBufferLen);
    if (!mBuffer) {
      mBufferLen = 0;
      return PR_FALSE;
    }
    mOwnBuffer = PR_TRUE;
  }
  memset(mBuffer, 0, mBufferLen);
  return PR_TRUE;
}

Here is the call graph for this function:

PRBool nsAntiAliasedGlyph::SetImage ( XCharStruct *  ,
_XImage *   
)

Definition at line 145 of file nsAntiAliasedGlyph.cpp.

{
  NS_ASSERTION(mBuffer, "null buffer (was Init called?)");
  if (!mBuffer)
    return PR_FALSE;
  PRUint32 src_width = GLYPH_RIGHT_EDGE(aCharStruct)
                       - GLYPH_LEFT_EDGE(aCharStruct);
  PRUint32 src_height = aXImage->height;
  if ((src_width > mMaxWidth) || (src_height > mMaxHeight)) {
    NS_ASSERTION(src_width<=mMaxWidth,"unexpected width");
    NS_ASSERTION(src_height<=mMaxHeight,"unexpected height");
    return PR_FALSE;
  }

  mAscent   = aCharStruct->ascent;
  mDescent  = aCharStruct->descent;
  mLBearing = aCharStruct->lbearing;
  mRBearing = aCharStruct->rbearing;
  mWidth    = src_width;
  mHeight   = src_height;
  mAdvance  = aCharStruct->width;

  NS_ASSERTION(aXImage->format==ZPixmap,"unexpected image format");
  if (aXImage->format != ZPixmap)
    return PR_FALSE;

  int bits_per_pixel = aXImage->bits_per_pixel;
  memset((char*)mBuffer, 0, mBufferLen);

  PRUint32 x, y;
  PRUint32 src_index = 0;
  PRUint32 dst_index =  mBorder + (mBorder*mBufferWidth);
  PRInt32 delta_dst_row = -src_width + mBufferWidth;
  PRUint8 *pSrcLineStart = (PRUint8 *)aXImage->data;
  if (bits_per_pixel == 16) {
    for (y=0; y<src_height; y++) {
      PRUint16 *src = (PRUint16*)pSrcLineStart;
      for (x=0; x<src_width; x++,src++,dst_index++) {
        if (*src & 0x1)
          mBuffer[dst_index] = 0xFF;
      }
      // move to the next row
      dst_index += delta_dst_row;
      pSrcLineStart += aXImage->bytes_per_line;
    }
    return PR_TRUE;
  }
  else if (bits_per_pixel == 24) {
    PRUint8 *src = (PRUint8*)aXImage->data;
    for (y=0; y<src_height; y++) {
      for (x=0; x<src_width; x++,src_index+=3,dst_index++) {
        if (src[src_index] & 0x1)
          mBuffer[dst_index] = 0xFF;
      }
      // move to the next row
      dst_index += delta_dst_row;
      src_index += -3*src_width + aXImage->bytes_per_line;
    }
    return PR_TRUE;
  }
  else if (bits_per_pixel == 32) {
    for (y=0; y<src_height; y++) {
      PRUint32 *src = (PRUint32*)pSrcLineStart;
      for (x=0; x<src_width; x++,src++,dst_index++) {
        if (*src & 0x100)
          mBuffer[dst_index] = 0xFF;
      }
      // move to the next row
      dst_index += delta_dst_row;
      pSrcLineStart += aXImage->bytes_per_line;
    }
    return PR_TRUE;
  }
  else {
    NS_ASSERTION(0, "do not support current bits_per_pixel");
    return PR_FALSE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 225 of file nsAntiAliasedGlyph.cpp.

{
  mAscent   = aGlyphMetrics->ascent;
  mDescent  = aGlyphMetrics->descent;
  mLBearing = aGlyphMetrics->lbearing;
  mRBearing = aGlyphMetrics->rbearing;
  mWidth    = aGlyphMetrics->width;
  mHeight   = aGlyphMetrics->height;
  mAdvance  = aGlyphMetrics->advance;
  return PR_TRUE;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 71 of file nsAntiAliasedGlyph.h.

Definition at line 67 of file nsAntiAliasedGlyph.h.

Definition at line 66 of file nsAntiAliasedGlyph.h.

Definition at line 79 of file nsAntiAliasedGlyph.h.

Definition at line 77 of file nsAntiAliasedGlyph.h.

Definition at line 80 of file nsAntiAliasedGlyph.h.

Definition at line 76 of file nsAntiAliasedGlyph.h.

Definition at line 68 of file nsAntiAliasedGlyph.h.

Definition at line 73 of file nsAntiAliasedGlyph.h.

Definition at line 69 of file nsAntiAliasedGlyph.h.

Definition at line 75 of file nsAntiAliasedGlyph.h.

Definition at line 74 of file nsAntiAliasedGlyph.h.

Definition at line 78 of file nsAntiAliasedGlyph.h.

Definition at line 70 of file nsAntiAliasedGlyph.h.

Definition at line 72 of file nsAntiAliasedGlyph.h.


The documentation for this class was generated from the following files: