Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsDrawingSurfaceBeOS Class Reference

#include <nsDrawingSurfaceBeOS.h>

Inheritance diagram for nsDrawingSurfaceBeOS:
Inheritance graph
[legend]
Collaboration diagram for nsDrawingSurfaceBeOS:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsDrawingSurfaceBeOS ()
virtual ~nsDrawingSurfaceBeOS ()
NS_DECL_ISUPPORTS NS_IMETHOD Lock (PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight, void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes, PRUint32 aFlags)
 Lock a rect of a drawing surface and return a pointer to the upper left hand corner of the bitmap.
NS_IMETHOD Unlock (void)
 Unlock a rect of a drawing surface.
NS_IMETHOD GetDimensions (PRUint32 *aWidth, PRUint32 *aHeight)
 Get the dimensions of a drawing surface.
NS_IMETHOD IsOffscreen (PRBool *aOffScreen)
 Get the offscreen status of the drawing surface.
NS_IMETHOD IsPixelAddressable (PRBool *aAddressable)
 Get the pixel addressability status of the drawing surface.
NS_IMETHOD GetPixelFormat (nsPixelFormat *aFormat)
 Get the pixel format of a drawing surface.
NS_IMETHOD Init (BView *aView)
 Initialize a drawing surface using a windows DC.
NS_IMETHOD Init (BView *aView, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags)
 Initialize an offscreen drawing surface using a windows DC.
NS_IMETHOD AcquireView (BView **aView)
NS_IMETHOD ReleaseView (void)
NS_IMETHOD AcquireBitmap (BBitmap **aBitmap)
NS_IMETHOD ReleaseBitmap (void)
void GetSize (PRUint32 *aWidth, PRUint32 *aHeight)
bool LockDrawable ()
void UnlockDrawable ()

Private Attributes

BView * mView
BBitmap * mBitmap
nsPixelFormat mPixFormat
PRUint32 mWidth
PRUint32 mHeight
PRUint32 mFlags
PRBool mIsOffscreen
PRUint32 mLockFlags
PRBool mLocked

Detailed Description

Definition at line 47 of file nsDrawingSurfaceBeOS.h.


Constructor & Destructor Documentation

Definition at line 47 of file nsDrawingSurfaceBeOS.cpp.

Definition at line 57 of file nsDrawingSurfaceBeOS.cpp.

{
  if(mBitmap)
  {
    // Deleting mBitmap will also remove and delete any child views
    mBitmap->Unlock();
    delete mBitmap;
    mView = nsnull;
    mBitmap = nsnull;
  }
}

Member Function Documentation

Definition at line 225 of file nsDrawingSurfaceBeOS.cpp.

{
  if (mBitmap && mView)
  {
    mView->Sync();
  }
  *aBitmap = mBitmap;

  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 219 of file nsDrawingSurfaceBeOS.cpp.

{
  *aView = mView;
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsDrawingSurfaceBeOS::GetDimensions ( PRUint32 aWidth,
PRUint32 aHeight 
) [virtual]

Get the dimensions of a drawing surface.

Parameters:
aWidthout parameter for width of drawing surface
aHeightout parameter for height of drawing surface
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 124 of file nsDrawingSurfaceBeOS.cpp.

{
  *aWidth = mWidth;
  *aHeight = mHeight;

  return NS_OK;
}

Get the pixel format of a drawing surface.

Parameters:
aOffscreenout parameter filled in with pixel format information.
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 144 of file nsDrawingSurfaceBeOS.cpp.

{
  *aFormat = mPixFormat;
  return NS_OK;
}
void nsDrawingSurfaceBeOS::GetSize ( PRUint32 aWidth,
PRUint32 aHeight 
) [inline]

Definition at line 82 of file nsDrawingSurfaceBeOS.h.

{ *aWidth = mWidth; *aHeight = mHeight; } 

Here is the caller graph for this function:

NS_IMETHODIMP nsDrawingSurfaceBeOS::Init ( BView *  aView) [virtual]

Initialize a drawing surface using a windows DC.

aDC is "owned" by the drawing surface until the drawing surface is destroyed.

Parameters:
aDCHDC to initialize drawing surface with
Returns:
error status

Implements nsIDrawingSurfaceBeOS.

Definition at line 150 of file nsDrawingSurfaceBeOS.cpp.

{
  if (aView->LockLooper()) 
  { 
    //remember dimensions 
    BRect r = aView->Bounds();
    mWidth = nscoord(r.IntegerWidth() + 1);
    mHeight = nscoord(r.IntegerHeight() + 1);
    
    mView = aView;
    aView->UnlockLooper(); 
  } 
 
  // onscreen View, attached to BWindow, acquired via GetNativeData() call in nsRendering
  mIsOffscreen = PR_FALSE; 
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsDrawingSurfaceBeOS::Init ( BView *  aView,
PRUint32  aWidth,
PRUint32  aHeight,
PRUint32  aFlags 
) [virtual]

Initialize an offscreen drawing surface using a windows DC.

aDC is not "owned" by this drawing surface, instead it is used to create a drawing surface compatible with aDC. if width or height are less than zero, aDC will be created with no offscreen bitmap installed.

Parameters:
aDCHDC to initialize drawing surface with
aWidthwidth of drawing surface
aHeightheight of drawing surface
aFlagsflags used to control type of drawing surface created
Returns:
error status

creating offscreen BBitmap

Implements nsIDrawingSurfaceBeOS.

Definition at line 168 of file nsDrawingSurfaceBeOS.cpp.

{
  NS_ASSERTION(!(aView == nsnull), "null BView");

  //remember dimensions
  mWidth=aWidth;
  mHeight=aHeight;
  mFlags = aFlags; 
  
  //creating offscreen  backbuffer surface
  mIsOffscreen = PR_TRUE; 
  //TODO: Maybe we should reuse BView by resizing it, 
  //and also reuse BBitmap if new size is = < of current size
  BRect r(0,0, mWidth-1, mHeight-1);
  //creating auxiliary BView to draw on offscreen BBitmap
  mView = new BView(r, "", 0, 0);
  if (!mView)
    return NS_ERROR_OUT_OF_MEMORY;

//if((aFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS) &&
//  (aWidth > 0) && (aHeight > 0))
  if (aWidth > 0 && aHeight > 0)
  {
    mBitmap = new BBitmap(r, B_RGBA32, true);
    if (!mBitmap)
      return NS_ERROR_OUT_OF_MEMORY;

    if (mBitmap->InitCheck()!=B_OK)
    {
      //for some reason, the bitmap isn't valid - delete the
      //bitmap object, then indicate failure
      delete mBitmap;
      mBitmap=NULL;
      return NS_ERROR_FAILURE;
    }
    
    //NB! Locking bitmap for lifetime to avoid unneccessary locking at each
    //drawing primitive call. Locking is quite time-expensive.
    //To avoid it, we call surface->LockDrawable() instead LockLooper()
    mBitmap->Lock();
    //Setting ViewColor transparent noticeably decreases AppServer load in DrawBitmp()
    //Applicable here, because Mozilla paints backgrounds explicitly, with images or filling areas.
    mView->SetViewColor(B_TRANSPARENT_32_BIT);
    mBitmap->AddChild(mView);
  }
  
  return NS_OK;
}

Get the offscreen status of the drawing surface.

Parameters:
aOffscreenout parameter for offscreen status of drawing surface. if PR_TRUE, then modifying the drawing surface does not immediately reflect the changes on the output device
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 132 of file nsDrawingSurfaceBeOS.cpp.

{
  *aOffScreen = mIsOffscreen;//mBitmap ? PR_TRUE : PR_FALSE;
  return NS_OK;
}

Here is the caller graph for this function:

Get the pixel addressability status of the drawing surface.

Parameters:
aAddressableout parameter for pixel addressability status of drawing surface. if PR_TRUE, then the drawing surface is optimized for pixel addressability (i.e. the Lock() method has very low overhead). All drawing surfaces support Lock()ing, but doing so on drawing surfaces that do not return PR_TRUE here may impose significant overhead.
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 138 of file nsDrawingSurfaceBeOS.cpp.

{
  *aAddressable = PR_FALSE; 
  return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS::Lock ( PRInt32  aX,
PRInt32  aY,
PRUint32  aWidth,
PRUint32  aHeight,
void **  aBits,
PRInt32 aStride,
PRInt32 aWidthBytes,
PRUint32  aFlags 
) [virtual]

Lock a rect of a drawing surface and return a pointer to the upper left hand corner of the bitmap.

Parameters:
aXx position of subrect of bitmap
aYy position of subrect of bitmap
aWidthwidth of subrect of bitmap
aHeightheight of subrect of bitmap
aBitsout parameter for upper left hand corner of bitmap
aStrideout parameter for number of bytes to add to aBits to go from scanline to scanline
aWidthBytesout parameter for number of bytes per line in aBits to process aWidth pixels
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 86 of file nsDrawingSurfaceBeOS.cpp.

{
  mLockFlags = aFlags;

  if (mBitmap && !mLocked)
  {
    if (mView)
      mView->Sync();
    if (mLockFlags & NS_LOCK_SURFACE_READ_ONLY)
      mBitmap->LockBits();
    *aStride = mBitmap->BytesPerRow();
    *aBits = (uint8 *)mBitmap->Bits() + aX*4 + *aStride * aY;
    *aWidthBytes = aWidth*4;
    mLocked = PR_TRUE; 
  }
  else
  {
    NS_ASSERTION(0, "nested lock attempt");
    return NS_ERROR_FAILURE;
  }
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 246 of file nsDrawingSurfaceBeOS.cpp.

{
  //TODO: try to avoid exta locking also for onscreen BView.
  //Perhaps it needs synchronization with widget through nsToolkit and lock counting.
  bool rv = false;
  if (!mBitmap)
  {
    // Non-bitmap (onscreen) view - unlock it as required if exists
    rv = mView && mView->LockLooper();
  }
  else
  {
    // Was locked in Init(), only test for locked state here
       rv = mBitmap->IsLocked();
  }
  return rv;
}

Here is the caller graph for this function:

Definition at line 241 of file nsDrawingSurfaceBeOS.cpp.

{
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 236 of file nsDrawingSurfaceBeOS.cpp.

{
  return NS_OK;
}

Here is the caller graph for this function:

Unlock a rect of a drawing surface.

must be preceded by a call to Lock(). Lock()/Unlock() pairs do not nest.

Returns:
error status

Implements nsIDrawingSurface.

Definition at line 112 of file nsDrawingSurfaceBeOS.cpp.

{
  if (mBitmap && mLocked)
  {
    if (mLockFlags & NS_LOCK_SURFACE_READ_ONLY)
      mBitmap->UnlockBits();
    mLocked = PR_FALSE; 
  }
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 264 of file nsDrawingSurfaceBeOS.cpp.

{
  // Do nothing, bitmap is locked for lifetime in our implementation
  if (mBitmap)
    return;
  // Non-bitmap (onscreen) view - unlock it as required.
  // mBitmap may be gone in destroy process, so additional check for Looper()
  if (mView  && mView->Looper())
    mView->UnlockLooper();
}

Here is the caller graph for this function:


Member Data Documentation

BBitmap* nsDrawingSurfaceBeOS::mBitmap [private]

Definition at line 88 of file nsDrawingSurfaceBeOS.h.

Definition at line 92 of file nsDrawingSurfaceBeOS.h.

Definition at line 91 of file nsDrawingSurfaceBeOS.h.

Definition at line 93 of file nsDrawingSurfaceBeOS.h.

Definition at line 97 of file nsDrawingSurfaceBeOS.h.

Definition at line 96 of file nsDrawingSurfaceBeOS.h.

Definition at line 89 of file nsDrawingSurfaceBeOS.h.

BView* nsDrawingSurfaceBeOS::mView [private]

Definition at line 87 of file nsDrawingSurfaceBeOS.h.

Definition at line 90 of file nsDrawingSurfaceBeOS.h.


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