Bug 374280 - Opacity of elements referencing a pattern isn't respected. r=jwatt,sr=tor

This commit is contained in:
longsonr%gmail.com 2007-04-24 08:11:22 +00:00
Родитель bdee91ae37
Коммит 39cf1b1d22
4 изменённых файлов: 41 добавлений и 21 удалений

Просмотреть файл

@ -196,11 +196,13 @@ nsSVGGradientFrame::GetStopCount()
void
nsSVGGradientFrame::GetStopInformation(PRInt32 aIndex,
float *aOffset, nscolor *aColor, float *aOpacity)
float *aOffset,
nscolor *aStopColor,
float *aStopOpacity)
{
*aOffset = 0.0f;
*aColor = 0;
*aOpacity = 1.0f;
*aStopColor = NS_RGBA(0, 0, 0, 0);
*aStopOpacity = 1.0f;
nsIFrame *stopFrame = nsnull;
GetStopFrame(aIndex, &stopFrame);
@ -219,8 +221,8 @@ nsSVGGradientFrame::GetStopInformation(PRInt32 aIndex,
}
if (stopFrame) {
*aColor = stopFrame->GetStyleSVGReset()->mStopColor;
*aOpacity = stopFrame->GetStyleSVGReset()->mStopOpacity;
*aStopColor = stopFrame->GetStyleSVGReset()->mStopColor;
*aStopOpacity = stopFrame->GetStyleSVGReset()->mStopOpacity;
}
#ifdef DEBUG
// One way or another we have an implementation problem if we get here
@ -331,7 +333,7 @@ nsSVGGradientFrame::GetSpreadMethod()
PRBool
nsSVGGradientFrame::SetupPaintServer(gfxContext *aContext,
nsSVGGeometryFrame *aSource,
float aOpacity,
float aGraphicOpacity,
void **aClosure)
{
*aClosure = nsnull;
@ -371,10 +373,10 @@ nsSVGGradientFrame::SetupPaintServer(gfxContext *aContext,
float lastOffset = 0.0f;
for (PRUint32 i = 0; i < nStops; i++) {
float offset, opacity;
nscolor rgba;
float offset, stopOpacity;
nscolor stopColor;
GetStopInformation(i, &offset, &rgba, &opacity);
GetStopInformation(i, &offset, &stopColor, &stopOpacity);
if (offset < lastOffset)
offset = lastOffset;
@ -382,11 +384,11 @@ nsSVGGradientFrame::SetupPaintServer(gfxContext *aContext,
lastOffset = offset;
cairo_pattern_add_color_stop_rgba(gradient, offset,
NS_GET_R(rgba)/255.0,
NS_GET_G(rgba)/255.0,
NS_GET_B(rgba)/255.0,
NS_GET_A(rgba)/255.0 *
opacity * aOpacity);
NS_GET_R(stopColor)/255.0,
NS_GET_G(stopColor)/255.0,
NS_GET_B(stopColor)/255.0,
NS_GET_A(stopColor)/255.0 *
stopOpacity * aGraphicOpacity);
}
cairo_set_source(aContext->GetCairo(), gradient);

Просмотреть файл

@ -57,7 +57,7 @@ public:
// nsSVGPaintServerFrame methods:
virtual PRBool SetupPaintServer(gfxContext *aContext,
nsSVGGeometryFrame *aSource,
float aOpacity,
float aGraphicOpacity,
void **aClosure);
virtual void CleanupPaintServer(gfxContext *aContext, void *aClosure);
@ -125,7 +125,7 @@ private:
PRUint16 GetSpreadMethod();
PRUint32 GetStopCount();
void GetStopInformation(PRInt32 aIndex,
float *aOffset, nscolor *aColor, float *aOpacity);
float *aOffset, nscolor *aColor, float *aStopOpacity);
nsresult GetGradientTransform(nsIDOMSVGMatrix **retval,
nsSVGGeometryFrame *aSource);

Просмотреть файл

@ -204,7 +204,8 @@ nsSVGPatternFrame::GetCanvasTM() {
nsresult
nsSVGPatternFrame::PaintPattern(cairo_surface_t** surface,
nsIDOMSVGMatrix** patternMatrix,
nsSVGGeometryFrame *aSource)
nsSVGGeometryFrame *aSource,
float aGraphicOpacity)
{
/*
@ -298,6 +299,11 @@ nsSVGPatternFrame::PaintPattern(cairo_surface_t** surface,
gfxContext tmpContext(tmpSurface);
nsSVGRenderState tmpState(&tmpContext);
if (aGraphicOpacity != 1.0f) {
tmpContext.Save();
tmpContext.PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
}
// OK, now render -- note that we use "firstKid", which
// we got at the beginning because it takes care of the
// referenced pattern situation for us
@ -311,6 +317,12 @@ nsSVGPatternFrame::PaintPattern(cairo_surface_t** surface,
}
mSource = nsnull;
if (aGraphicOpacity != 1.0f) {
tmpContext.PopGroupToSource();
tmpContext.Paint(aGraphicOpacity);
tmpContext.Restore();
}
// caller now owns the cairo surface
cairo_surface_reference(tmpSurface->CairoSurface());
*surface = tmpSurface->CairoSurface();
@ -796,10 +808,14 @@ nsSVGPatternFrame::GetCallerGeometry(nsIDOMSVGMatrix **aCTM,
PRBool
nsSVGPatternFrame::SetupPaintServer(gfxContext *aContext,
nsSVGGeometryFrame *aSource,
float aOpacity,
float aGraphicOpacity,
void **aClosure)
{
*aClosure = nsnull;
if (aGraphicOpacity == 0.0f)
return PR_FALSE;
cairo_t *ctx = aContext->GetCairo();
cairo_matrix_t matrix;
@ -809,7 +825,8 @@ nsSVGPatternFrame::SetupPaintServer(gfxContext *aContext,
cairo_surface_t *surface;
nsCOMPtr<nsIDOMSVGMatrix> pMatrix;
cairo_identity_matrix(ctx);
nsresult rv = PaintPattern(&surface, getter_AddRefs(pMatrix), aSource);
nsresult rv = PaintPattern(&surface, getter_AddRefs(pMatrix),
aSource, aGraphicOpacity);
cairo_set_matrix(ctx, &matrix);
if (NS_FAILED(rv)) {
cairo_surface_destroy(surface);

Просмотреть файл

@ -65,12 +65,13 @@ public:
nsresult PaintPattern(cairo_surface_t **surface,
nsIDOMSVGMatrix **patternMatrix,
nsSVGGeometryFrame *aSource);
nsSVGGeometryFrame *aSource,
float aGraphicOpacity);
// nsSVGPaintServerFrame methods:
virtual PRBool SetupPaintServer(gfxContext *aContext,
nsSVGGeometryFrame *aSource,
float aOpacity,
float aGraphicOpacity,
void **aClosure);
virtual void CleanupPaintServer(gfxContext *aContext, void *aClosure);