зеркало из https://github.com/mozilla/gecko-dev.git
b=429915, color mismatch with 1x1 images (SetColor API broken) ; r=stuart, a=damon
This commit is contained in:
Родитель
d8a2681e82
Коммит
fb8045c358
|
@ -379,7 +379,7 @@ nsThebesImage::LockImagePixels(PRBool aMaskPixels)
|
|||
gfxContext context(mImageSurface);
|
||||
context.SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
if (mSinglePixel)
|
||||
context.SetColor(mSinglePixelColor);
|
||||
context.SetDeviceColor(mSinglePixelColor);
|
||||
else
|
||||
context.SetSource(mOptSurface);
|
||||
context.Paint();
|
||||
|
@ -441,7 +441,7 @@ nsThebesImage::Draw(nsIRenderingContext &aContext,
|
|||
if (op == gfxContext::OPERATOR_OVER && mSinglePixelColor.a == 1.0)
|
||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
|
||||
ctx->SetColor(mSinglePixelColor);
|
||||
ctx->SetDeviceColor(mSinglePixelColor);
|
||||
ctx->NewPath();
|
||||
ctx->Rectangle(aDestRect, PR_TRUE);
|
||||
ctx->Fill();
|
||||
|
@ -610,7 +610,7 @@ nsThebesImage::Draw(nsIRenderingContext &aContext,
|
|||
ctx->Fill();
|
||||
|
||||
ctx->SetOperator(op);
|
||||
ctx->SetColor(gfxRGBA(0,0,0,0));
|
||||
ctx->SetDeviceColor(gfxRGBA(0,0,0,0));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
|
|||
gfxPoint tmpOffset = offset;
|
||||
|
||||
if (mSinglePixel && !hasPadding) {
|
||||
thebesContext->SetColor(mSinglePixelColor);
|
||||
thebesContext->SetDeviceColor(mSinglePixelColor);
|
||||
} else {
|
||||
nsRefPtr<gfxASurface> surface;
|
||||
PRInt32 width, height;
|
||||
|
@ -664,7 +664,7 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
|
|||
|
||||
gfxContext tmpContext(surface);
|
||||
if (mSinglePixel) {
|
||||
tmpContext.SetColor(mSinglePixelColor);
|
||||
tmpContext.SetDeviceColor(mSinglePixelColor);
|
||||
} else {
|
||||
tmpContext.SetSource(ThebesSurface());
|
||||
}
|
||||
|
@ -802,7 +802,7 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
|
|||
thebesContext->Fill();
|
||||
|
||||
thebesContext->SetOperator(op);
|
||||
thebesContext->SetColor(gfxRGBA(0,0,0,0));
|
||||
thebesContext->SetDeviceColor(gfxRGBA(0,0,0,0));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -348,6 +348,9 @@ NS_IMETHODIMP
|
|||
nsThebesRenderingContext::SetColor(nscolor aColor)
|
||||
{
|
||||
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::SetColor 0x%08x\n", this, aColor));
|
||||
/* This sets the color assuming the sRGB color space, since that's what all
|
||||
* CSS colors are defined to be in by the spec.
|
||||
*/
|
||||
mThebes->SetColor(gfxRGBA(aColor));
|
||||
|
||||
mColor = aColor;
|
||||
|
|
|
@ -314,16 +314,24 @@ public:
|
|||
**/
|
||||
|
||||
/**
|
||||
* Uses a solid color for drawing.
|
||||
* Set a solid color to use for drawing. This color is in the device color space
|
||||
* and is not transformed.
|
||||
*/
|
||||
void SetColor(const gfxRGBA& c);
|
||||
void SetDeviceColor(const gfxRGBA& c);
|
||||
|
||||
/**
|
||||
* Gets the current color.
|
||||
* Gets the current color. It's returned in the device color space.
|
||||
* returns PR_FALSE if there is something other than a color
|
||||
* set as the current source (pattern, surface, etc)
|
||||
*/
|
||||
PRBool GetColor(gfxRGBA& c);
|
||||
PRBool GetDeviceColor(gfxRGBA& c);
|
||||
|
||||
/**
|
||||
* Set a solid color in the sRGB color space to use for drawing.
|
||||
* If CMS is not enabled, the color is treated as a device-space color
|
||||
* and this call is identical to SetDeviceColor().
|
||||
*/
|
||||
void SetColor(const gfxRGBA& c);
|
||||
|
||||
/**
|
||||
* Uses a surface for drawing. This is a shorthand for creating a
|
||||
|
|
|
@ -645,8 +645,14 @@ gfxContext::SetColor(const gfxRGBA& c)
|
|||
cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::SetDeviceColor(const gfxRGBA& c)
|
||||
{
|
||||
cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
PRBool
|
||||
gfxContext::GetColor(gfxRGBA& c)
|
||||
gfxContext::GetDeviceColor(gfxRGBA& c)
|
||||
{
|
||||
return cairo_pattern_get_rgba(cairo_get_source(mCairo),
|
||||
&c.r,
|
||||
|
|
|
@ -1400,7 +1400,7 @@ HasSyntheticBold(gfxTextRun *aRun, PRUint32 aStart, PRUint32 aLength)
|
|||
static PRBool
|
||||
HasNonOpaqueColor(gfxContext *aContext, gfxRGBA& aCurrentColor)
|
||||
{
|
||||
if (aContext->GetColor(aCurrentColor)) {
|
||||
if (aContext->GetDeviceColor(aCurrentColor)) {
|
||||
if (aCurrentColor.a < 1.0 && aCurrentColor.a > 0.0) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ gfxFontMissingGlyphs::DrawMissingGlyph(gfxContext *aContext, const gfxRect& aRec
|
|||
aContext->Save();
|
||||
|
||||
gfxRGBA currentColor;
|
||||
if (!aContext->GetColor(currentColor)) {
|
||||
if (!aContext->GetDeviceColor(currentColor)) {
|
||||
// We're currently drawing with some kind of pattern... Just draw
|
||||
// the missing-glyph data in black.
|
||||
currentColor = gfxRGBA(0,0,0,1);
|
||||
|
@ -221,7 +221,7 @@ gfxFontMissingGlyphs::DrawMissingGlyph(gfxContext *aContext, const gfxRect& aRec
|
|||
aContext->SetLineJoin(gfxContext::LINE_JOIN_MITER);
|
||||
gfxRGBA color = currentColor;
|
||||
color.a *= BOX_BORDER_OPACITY;
|
||||
aContext->SetColor(color);
|
||||
aContext->SetDeviceColor(color);
|
||||
aContext->NewPath();
|
||||
aContext->Rectangle(borderStrokeRect);
|
||||
aContext->Stroke();
|
||||
|
@ -235,7 +235,7 @@ gfxFontMissingGlyphs::DrawMissingGlyph(gfxContext *aContext, const gfxRect& aRec
|
|||
if (aRect.Width() >= 2*MINIFONT_WIDTH + HEX_CHAR_GAP &&
|
||||
aRect.Height() >= 2*MINIFONT_HEIGHT + HEX_CHAR_GAP) {
|
||||
// Draw 4 digits for BMP
|
||||
aContext->SetColor(currentColor);
|
||||
aContext->SetDeviceColor(currentColor);
|
||||
gfxFloat left = -(MINIFONT_WIDTH + halfGap);
|
||||
DrawHexChar(aContext,
|
||||
center + gfxPoint(left, top), (aChar >> 12) & 0xF);
|
||||
|
@ -250,7 +250,7 @@ gfxFontMissingGlyphs::DrawMissingGlyph(gfxContext *aContext, const gfxRect& aRec
|
|||
if (aRect.Width() >= 3*MINIFONT_WIDTH + 2*HEX_CHAR_GAP &&
|
||||
aRect.Height() >= 2*MINIFONT_HEIGHT + HEX_CHAR_GAP) {
|
||||
// Draw 6 digits for non-BMP
|
||||
aContext->SetColor(currentColor);
|
||||
aContext->SetDeviceColor(currentColor);
|
||||
gfxFloat first = -(MINIFONT_WIDTH * 1.5 + HEX_CHAR_GAP);
|
||||
gfxFloat second = -(MINIFONT_WIDTH / 2.0);
|
||||
gfxFloat third = (MINIFONT_WIDTH / 2.0 + HEX_CHAR_GAP);
|
||||
|
|
Загрузка…
Ссылка в новой задаче