Back to index

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

#include <nsCairoBlender.h>

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

List of all members.

Public Member Functions

 nsCairoBlender ()
 ~nsCairoBlender ()
NS_DECL_ISUPPORTS NS_IMETHOD Init (nsIDeviceContext *aContext)
 Initialize the Blender dc 11/4/98.
NS_IMETHOD Blend (PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight, nsIDrawingSurface *aSrc, nsIDrawingSurface *aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity, nsIDrawingSurface *aSecondSrc=nsnull, nscolor aSrcBackColor=NS_RGB(0, 0, 0), nscolor aSecondSrcBackColor=NS_RGB(0, 0, 0))
 NOTE: if we can make this static, that would be great.
NS_IMETHOD Blend (PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight, nsIRenderingContext *aSrc, nsIRenderingContext *aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity, nsIRenderingContext *aSecondSrc=nsnull, nscolor aSrcBackColor=NS_RGB(0, 0, 0), nscolor aSecondSrcBackColor=NS_RGB(0, 0, 0))
NS_IMETHOD GetAlphas (const nsRect &aRect, nsIDrawingSurface *aBlack, nsIDrawingSurface *aWhite, PRUint8 **aAlphas)
 GetAlphas computes an array of alpha values for a rectangle of pixels, using the drawn-onto-black and the drawn-onto-white images.

Private Attributes

nsCairoDeviceContextmCairoDC

Detailed Description

Definition at line 45 of file nsCairoBlender.h.


Constructor & Destructor Documentation

Definition at line 46 of file nsCairoBlender.cpp.

    : mCairoDC(nsnull)
{
}

Definition at line 51 of file nsCairoBlender.cpp.

{
}

Member Function Documentation

NS_IMETHODIMP nsCairoBlender::Blend ( PRInt32  aSX,
PRInt32  aSY,
PRInt32  aWidth,
PRInt32  aHeight,
nsIDrawingSurface aSrc,
nsIDrawingSurface aDest,
PRInt32  aDX,
PRInt32  aDY,
float  aSrcOpacity,
nsIDrawingSurface aSecondSrc = nsnull,
nscolor  aSrcBackColor = NS_RGB(0, 0, 0),
nscolor  aSecondSrcBackColor = NS_RGB(0, 0, 0) 
) [virtual]

NOTE: if we can make this static, that would be great.

I don't think we can. Blend source and destination nsDrawingSurfaces. Both drawing surfaces will have bitmaps associated with them.

Parameters:
aSXx offset into source drawing surface of blend area
aSYy offset into source drawing surface of blend area
aWidthwidth of blend area
aHeightwidth of blend area
aSrcsource for the blending
aDestdestination for blending
aDXx offset into destination drawing surface of blend area
aDYy offset into destination drawing surface of blend area
aSrcOpacity0.0f -> 1.0f opacity value of source area. 1.0f indicates complete opacity.
aSecondSrcan optional second source drawing surface which is used in conjunction with the background color parameters to determine which pixels to blend
aSrcBackColorcolor of pixels in aSrc that should be considered "background" color
aSecondSrcBackColorcolor of pixels in aSrc that should be considered "background" color

Implements nsIBlender.

Definition at line 63 of file nsCairoBlender.cpp.

{
    nsCairoDrawingSurface *cSrc = NS_STATIC_CAST(nsCairoDrawingSurface *, aSrc);
    nsCairoDrawingSurface *cDest = NS_STATIC_CAST(nsCairoDrawingSurface *, aDest);

    cairo_surface_t *src_surf = cSrc->GetCairoSurface();
    cairo_surface_t *dst_surf = cDest->GetCairoSurface();

    cairo_t *cairo = cairo_create();
    cairo_set_target_surface(cairo, dst_surf);

    cairo_rectangle (cairo, aDX, aDY, aWidth, aHeight);
    cairo_clip (cairo);

    PRUint32 srcWidth, srcHeight;
    aSrc->GetDimensions(&srcWidth, &srcHeight);

    cairo_translate (cairo, double(aDX - aSX), double(aDY - aSY));
    cairo_show_surface (cairo, src_surf, srcWidth, srcHeight);

    cairo_destroy (cairo);

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsCairoBlender::Blend ( PRInt32  aSX,
PRInt32  aSY,
PRInt32  aWidth,
PRInt32  aHeight,
nsIRenderingContext aSrc,
nsIRenderingContext aDest,
PRInt32  aDX,
PRInt32  aDY,
float  aSrcOpacity,
nsIRenderingContext aSecondSrc = nsnull,
nscolor  aSrcBackColor = NS_RGB(0, 0, 0),
nscolor  aSecondSrcBackColor = NS_RGB(0, 0, 0) 
) [virtual]

Implements nsIBlender.

Definition at line 94 of file nsCairoBlender.cpp.

{
    nsIDrawingSurface* srcSurface, *destSurface, *secondSrcSurface = nsnull;
    aSrc->GetDrawingSurface(&srcSurface);
    aDest->GetDrawingSurface(&destSurface);
    if (aSecondSrc != nsnull)
        aSecondSrc->GetDrawingSurface(&secondSrcSurface);
    return Blend(aSX, aSY, aWidth, aHeight, srcSurface, destSurface,
                 aDX, aDY, aSrcOpacity, secondSrcSurface, aSrcBackColor,
                 aSecondSrcBackColor);
}

Here is the call graph for this function:

NS_IMETHODIMP nsCairoBlender::GetAlphas ( const nsRect aRect,
nsIDrawingSurface aBlack,
nsIDrawingSurface aWhite,
PRUint8 **  aAlphas 
) [virtual]

GetAlphas computes an array of alpha values for a rectangle of pixels, using the drawn-onto-black and the drawn-onto-white images.

The pixels are returned in a new'ed array of aRect.width*aRect.height elements, in row-major order. This array must be freed by the caller.

Implements nsIBlender.

Definition at line 112 of file nsCairoBlender.cpp.

{
    *aAlphas = (PRUint8*) nsMemory::Alloc(aRect.width * aRect.height);
    NS_ENSURE_TRUE(*aAlphas, NS_ERROR_OUT_OF_MEMORY);

    memset(*aAlphas, 0, aRect.width * aRect.height);
    return NS_OK;
}

Here is the call graph for this function:

Initialize the Blender dc 11/4/98.

Parameters:
aContextis where the blender can get info about the device its blending on
Returns:
The result of the initialization, NS_OK if no errors

Implements nsIBlender.

Definition at line 56 of file nsCairoBlender.cpp.


Member Data Documentation

Definition at line 70 of file nsCairoBlender.h.


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