Back to index

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

#include <nsDrawingSurfaceMac.h>

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

List of all members.

Public Member Functions

 nsDrawingSurfaceMac ()
 
See Documentation in nsIDrawingSurface.h 3/02/99 dwc
virtual ~nsDrawingSurfaceMac ()
 
See Documentation in nsIDrawingSurface.h 3/02/99 dwc
NS_DECL_ISUPPORTS NS_IMETHOD Lock (PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight, void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes, PRUint32 aFlags)
 
See Documentation in nsIDrawingSurface.h 3/02/99 dwc
NS_IMETHOD Unlock (void)
 
See Documentation in nsIDrawingSurface.h 3/02/99 dwc
NS_IMETHOD GetDimensions (PRUint32 *aWidth, PRUint32 *aHeight)
 
See Documentation in nsIDrawingSurface.h 3/02/99 dwc
NS_IMETHOD IsOffscreen (PRBool *aOffScreen)
 Get the offscreen status of the drawing surface.
NS_IMETHOD IsPixelAddressable (PRBool *aAddressable)
 
See Documentation in nsIDrawingSurface.h 3/02/99 dwc
NS_IMETHOD GetPixelFormat (nsPixelFormat *aFormat)
 
See Documentation in nsIDrawingSurface.h 3/02/99 dwc
NS_IMETHOD Init (nsIDrawingSurface *aDS)
 
See Documentation in nsIDrawingSurfaceMac.h 3/02/99 dwc
NS_IMETHOD Init (CGrafPtr aThePort)
 
See Documentation in nsIDrawingSurfaceMac.h 3/02/99 dwc
NS_IMETHOD Init (nsIWidget *aTheWidget)
 
See Documentation in nsIDrawingSurfaceMac.h 3/02/99 dwc
NS_IMETHOD Init (PRUint32 aDepth, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags)
 
See Documentation in nsIDrawingSurfaceMac.h 3/02/99 dwc
NS_IMETHOD GetGrafPtr (CGrafPtr *aTheGrafPtr)
 Get a Macintosh GrafPtr that represents the drawing surface.
 NS_IMETHOD_ (CGContextRef) StartQuartzDrawing()
 Quartz helper function.
 NS_IMETHOD_ (void) EndQuartzDrawing(CGContextRef aContext)
 Quartz helper function.
nsGraphicStateGetGS (void)

Private Attributes

CGrafPtr mPort
PRUint32 mWidth
PRUint32 mHeight
PRInt32 mLockOffset
PRInt32 mLockHeight
PRUint32 mLockFlags
PRBool mIsOffscreen
PRBool mIsLocked
nsGraphicStatemGS

Detailed Description

Definition at line 49 of file nsDrawingSurfaceMac.h.


Constructor & Destructor Documentation


See Documentation in nsIDrawingSurface.h 3/02/99 dwc

Returns:
error status

Definition at line 60 of file nsDrawingSurfaceMac.cpp.

{
  mPort = NULL;
  mGS = sGraphicStatePool.GetNewGS();     //new nsGraphicState();
  mWidth = mHeight = 0;
  mLockOffset = mLockHeight = 0;
  mLockFlags = 0;
  mIsOffscreen = PR_FALSE;
  mIsLocked = PR_FALSE;
#ifdef MOZ_WIDGET_COCOA
  mWidgetView = nsnull;
#endif
}

Here is the call graph for this function:


See Documentation in nsIDrawingSurface.h 3/02/99 dwc

Returns:
error status

Definition at line 79 of file nsDrawingSurfaceMac.cpp.

{
       if(mIsOffscreen && mPort){
       GWorldPtr offscreenGWorld = (GWorldPtr)mPort;
              ::UnlockPixels(::GetGWorldPixMap(offscreenGWorld));
              ::DisposeGWorld(offscreenGWorld);
              
              nsGraphicsUtils::SetPortToKnownGoodPort();
       }

       if (mGS){
              sGraphicStatePool.ReleaseGS(mGS); //delete mGS;
       }
}

Here is the call graph for this function:


Member Function Documentation

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


See Documentation in nsIDrawingSurface.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurface.

Definition at line 189 of file nsDrawingSurfaceMac.cpp.

{
  *aWidth = mWidth;
  *aHeight = mHeight;
  return NS_OK;
}
NS_IMETHOD nsDrawingSurfaceMac::GetGrafPtr ( CGrafPtr aPort) [inline, virtual]

Get a Macintosh GrafPtr that represents the drawing surface.

Parameters:
aPortout parameter for GrafPtr
Returns:
error status

Implements nsIDrawingSurfaceMac.

Definition at line 73 of file nsDrawingSurfaceMac.h.

{ *aTheGrafPtr = mPort; return NS_OK; }

Here is the caller graph for this function:

Definition at line 78 of file nsDrawingSurfaceMac.h.

{return mGS;}

Here is the caller graph for this function:


See Documentation in nsIDrawingSurface.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurface.

Definition at line 212 of file nsDrawingSurfaceMac.cpp.

{
  //*aFormat = mPixFormat;
  NS_ASSERTION(0, "Not implemented!");
  return NS_ERROR_NOT_IMPLEMENTED;
}


See Documentation in nsIDrawingSurfaceMac.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurfaceMac.

Definition at line 226 of file nsDrawingSurfaceMac.cpp.

{
       nsDrawingSurfaceMac* surface = static_cast<nsDrawingSurfaceMac*>(aDS);
       surface->GetGrafPtr(&mPort);
       mGS->Init(surface);
       
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


See Documentation in nsIDrawingSurfaceMac.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurfaceMac.

Definition at line 240 of file nsDrawingSurfaceMac.cpp.

{
       // set our grafPtr to the passed in port
  mPort = aPort;
       mGS->Init(aPort);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsDrawingSurfaceMac::Init ( nsIWidget aTheWidget) [virtual]


See Documentation in nsIDrawingSurfaceMac.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurfaceMac.

Definition at line 253 of file nsDrawingSurfaceMac.cpp.

{
       // get our native graphics port from the widget
       mPort = reinterpret_cast<CGrafPtr>(aTheWidget->GetNativeData(NS_NATIVE_GRAPHIC));
       mGS->Init(aTheWidget);
#ifdef MOZ_WIDGET_COCOA
  mWidgetView = aTheWidget->GetNativeData(NS_NATIVE_WIDGET);
#endif
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsDrawingSurfaceMac::Init ( PRUint32  aDepth,
PRUint32  aWidth,
PRUint32  aHeight,
PRUint32  aFlags 
) [virtual]


See Documentation in nsIDrawingSurfaceMac.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurfaceMac.

Definition at line 270 of file nsDrawingSurfaceMac.cpp.

{
  PRUint32    depth;
  Rect               macRect;
  GWorldPtr offscreenGWorld = nsnull;
  Boolean   tryTempMemFirst = ((aFlags & NS_CREATEDRAWINGSURFACE_SHORTLIVED) != 0);
  
  depth = aDepth;
  mWidth = aWidth;
  mHeight = aHeight;
  

       // calculate the rectangle
  if (aWidth != 0){
       ::SetRect(&macRect, 0, 0, aWidth, aHeight);
  }else{
       ::SetRect(&macRect, 0, 0, 2, 2);
       }

       // create offscreen, first with normal memory, if that fails use temp memory, if that fails, return

       // Quick and dirty check to make sure there is some memory available.
       // GWorld allocations in temp mem can still fail if the heap is totally
       // full, because some stuff is allocated in the heap
       const long kReserveHeapFreeSpace = (1024 * 1024);
       const long kReserveHeapContigSpace = (512 * 1024);

  long   totalSpace, contiguousSpace;
  
  if (tryTempMemFirst)
  {
         ::NewGWorld(&offscreenGWorld, depth, &macRect, nsnull, nsnull, useTempMem);
    if (!offscreenGWorld)
    {
      // only try the heap if there is enough space
       ::PurgeSpace(&totalSpace, &contiguousSpace);            // this does not purge memory, just measure it

       if (totalSpace > kReserveHeapFreeSpace && contiguousSpace > kReserveHeapContigSpace)
              ::NewGWorld(&offscreenGWorld, depth, &macRect, nsnull, nsnull, 0);
    }
  }
  else    // heap first
  {
      // only try the heap if there is enough space
       ::PurgeSpace(&totalSpace, &contiguousSpace);            // this does not purge memory, just measure it

       if (totalSpace > kReserveHeapFreeSpace && contiguousSpace > kReserveHeapContigSpace)
              ::NewGWorld(&offscreenGWorld, depth, &macRect, nsnull, nsnull, 0);
  
      if (!offscreenGWorld)
             ::NewGWorld(&offscreenGWorld, depth, &macRect, nsnull, nsnull, useTempMem);
  }
  
  if (!offscreenGWorld)
    return NS_ERROR_OUT_OF_MEMORY;  
  
       // keep the pixels locked... that's how it works on Windows and  we are forced to do
       // the same because the API doesn't give us any hook to do it at drawing time.
  ::LockPixels(::GetGWorldPixMap(offscreenGWorld));

       // erase the offscreen area
       {
         StGWorldPortSetter  setter(offscreenGWorld);
         ::EraseRect(&macRect);
  }

       Init(offscreenGWorld);
       mIsOffscreen = PR_TRUE;
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD nsDrawingSurfaceMac::IsOffscreen ( PRBool aOffScreen) [inline, virtual]

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 64 of file nsDrawingSurfaceMac.h.

{ *aOffScreen = mIsOffscreen; return NS_OK; }


See Documentation in nsIDrawingSurface.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurface.

Definition at line 201 of file nsDrawingSurfaceMac.cpp.

{
  NS_ASSERTION(0, "Not implemented!");
  return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDrawingSurfaceMac::Lock ( PRInt32  aX,
PRInt32  aY,
PRUint32  aWidth,
PRUint32  aHeight,
void **  aBits,
PRInt32 aStride,
PRInt32 aWidthBytes,
PRUint32  aFlags 
) [virtual]


See Documentation in nsIDrawingSurface.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurface.

Definition at line 141 of file nsDrawingSurfaceMac.cpp.

{

  if (!mIsLocked && mIsOffscreen && mPort)
  {
    // get the offscreen gworld for our use
    GWorldPtr     offscreenGWorld = (GWorldPtr)mPort;

    // calculate the pixel data size
    PixMapHandle  thePixMap = ::GetGWorldPixMap(offscreenGWorld);
    Ptr           baseaddr  = ::GetPixBaseAddr(thePixMap);
    PRInt32       cmpSize   = ((**thePixMap).pixelSize >> 3);
    PRInt32       rowBytes  = (**thePixMap).rowBytes & 0x3FFF;

    *aBits = baseaddr + (aX * cmpSize) + aY * rowBytes;
    *aStride = rowBytes;
    *aWidthBytes = aWidth * cmpSize;

    mIsLocked = PR_TRUE;
  }
  else
  {
    NS_ASSERTION(0, "nested lock attempt");
    return NS_ERROR_FAILURE;
  }

  return NS_OK;
}

Here is the caller graph for this function:

nsDrawingSurfaceMac::NS_IMETHOD_ ( CGContextRef  ) [virtual]

Quartz helper function.

Constructs a Quartz context from the drawing surface's QuickDraw port. Must be balanced with a call to EndQuartzDrawing().

Returns:
Quartz drawing context

Implements nsIDrawingSurfaceMac.

Quartz helper function.

Releases Quartz context and resets state of drawing surface for QuickDraw calls. Must be called when you are done drawing to the Quartz context.

Parameters:
Quartzdrawing context returned by StartQuartzDrawing()

Implements nsIDrawingSurfaceMac.


See Documentation in nsIDrawingSurface.h 3/02/99 dwc

Returns:
error status

Implements nsIDrawingSurface.

Definition at line 178 of file nsDrawingSurfaceMac.cpp.

{
       mIsLocked = PR_FALSE;
  return NS_OK;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 91 of file nsDrawingSurfaceMac.h.

Definition at line 84 of file nsDrawingSurfaceMac.h.

Definition at line 89 of file nsDrawingSurfaceMac.h.

Definition at line 88 of file nsDrawingSurfaceMac.h.

Definition at line 87 of file nsDrawingSurfaceMac.h.

Definition at line 86 of file nsDrawingSurfaceMac.h.

Definition at line 85 of file nsDrawingSurfaceMac.h.

Definition at line 81 of file nsDrawingSurfaceMac.h.

Definition at line 83 of file nsDrawingSurfaceMac.h.


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