Bug 1207944 (part 4) - Use SetColor(const Color&) when setting from an nscolor. r=jwatt.

In various places SetColor() gets passed an nscolor. These are converted
(either implicitly or explicitly) to a gfxRBGA, and then to a gfx::Color.

This patch changes all these cases to avoid the middle step, by (a)
constructing a gfx::Color directly instead of an nscolor, or (b) by converting
an nscolor with Color::FromABGR().

--HG--
extra : rebase_source : ae423a422b37ada8ca0cb6f130350b4a71d58fc4
This commit is contained in:
Nicholas Nethercote 2015-09-23 23:41:30 -07:00
Родитель ef3e68e52b
Коммит a37228e1fe
12 изменённых файлов: 30 добавлений и 29 удалений

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

@ -2919,7 +2919,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
// If we might be using a background color, go ahead and set it now.
if (drawBackgroundColor && !isCanvasFrame)
ctx->SetColor(gfxRGBA(bgColor));
ctx->SetColor(Color::FromABGR(bgColor));
// NOTE: no Save() yet, we do that later by calling autoSR.EnsureSaved(ctx)
// in the cases we need it.
@ -3847,7 +3847,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
AntialiasMode oldMode = ctx->CurrentAntialiasMode();
ctx->SetAntialiasMode(AntialiasMode::NONE);
ctx->SetColor(aBorderColor);
ctx->SetColor(Color::FromABGR(aBorderColor));
switch (aBorderStyle) {
case NS_STYLE_BORDER_STYLE_NONE:
@ -3927,7 +3927,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
aBGColor->mBackgroundColor,
aBorderColor);
// XXXbz is this SetColor call still needed?
ctx->SetColor(bevelColor);
ctx->SetColor(Color::FromABGR(bevelColor));
nsRect rect(aBorder);
nscoord half;
if (horizontal) { // top, bottom
@ -3964,7 +3964,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
bevelColor = MakeBevelColor(ridgeGrooveSide, ridgeGroove,
aBGColor->mBackgroundColor, aBorderColor);
// XXXbz is this SetColor call still needed?
ctx->SetColor(bevelColor);
ctx->SetColor(Color::FromABGR(bevelColor));
if (horizontal) {
rect.y = rect.y + half;
rect.height = aBorder.height - half;

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

@ -5609,7 +5609,7 @@ nsLayoutUtils::PaintTextShadow(const nsIFrame* aFrame,
aDestCtx->Save();
aDestCtx->NewPath();
aDestCtx->SetColor(gfxRGBA(shadowColor));
aDestCtx->SetColor(Color::FromABGR(shadowColor));
// The callback will draw whatever we want to blur as a shadow.
aCallback(&renderingContext, shadowOffset, shadowColor, aCallbackData);

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

@ -4641,7 +4641,7 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
if (!rootFrame) {
// Nothing to paint, just fill the rect
aThebesContext->SetColor(gfxRGBA(aBackgroundColor));
aThebesContext->SetColor(Color::FromABGR(aBackgroundColor));
aThebesContext->Fill();
return NS_OK;
}
@ -10233,23 +10233,23 @@ void ReflowCountMgr::PaintCount(const char* aName,
fm->SetTextRunRTL(false);
width = fm->GetWidth(buf, len, aRenderingContext);;
uint32_t color;
uint32_t color2;
Color color;
Color color2;
if (aColor != 0) {
color = aColor;
color2 = NS_RGB(0,0,0);
color = Color::FromABGR(aColor);
color2 = Color(0.f, 0.f, 0.f);
} else {
uint8_t rc = 0, gc = 0, bc = 0;
gfx::Float rc = 0.f, gc = 0.f, bc = 0.f;
if (counter->mCount < 5) {
rc = 255;
gc = 255;
} else if ( counter->mCount < 11) {
gc = 255;
rc = 1.f;
gc = 1.f;
} else if (counter->mCount < 11) {
gc = 1.f;
} else {
rc = 255;
rc = 1.f;
}
color = NS_RGB(rc,gc,bc);
color2 = NS_RGB(rc/2,gc/2,bc/2);
color = Color(rc, gc, bc);
color2 = Color(rc/2, gc/2, bc/2);
}
nsRect rect(0,0, width+15, height+15);

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

@ -217,7 +217,7 @@ nsDisplayTextOverflowMarker::Paint(nsDisplayListBuilder* aBuilder,
nsLayoutUtils::PaintTextShadow(mFrame, aCtx, mRect, mVisibleRect,
foregroundColor, PaintTextShadowCallback,
(void*)this);
aCtx->ThebesContext()->SetColor(foregroundColor);
aCtx->ThebesContext()->SetColor(gfx::Color::FromABGR(foregroundColor));
PaintTextToContext(aCtx, nsPoint(0, 0));
}

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

@ -410,7 +410,7 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
default:
{
aRenderingContext.ThebesContext()->SetColor(
nsLayoutUtils::GetColor(this, eCSSProperty_color));
Color::FromABGR(nsLayoutUtils::GetColor(this, eCSSProperty_color)));
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
GetFontSizeInflation());

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

@ -1131,7 +1131,8 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
const nsRect& aRect)
{
// Set font and color
aRenderingContext.ThebesContext()->SetColor(StyleColor()->mColor);
aRenderingContext.ThebesContext()->
SetColor(Color::FromABGR(StyleColor()->mColor));
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(this));

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

@ -390,7 +390,7 @@ nsPageFrame::DrawHeaderFooter(nsRenderingContext& aRenderingContext,
gfx->Save();
gfx->Clip(NSRectToSnappedRect(aRect, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
aRenderingContext.ThebesContext()->SetColor(NS_RGB(0,0,0));
aRenderingContext.ThebesContext()->SetColor(Color(0.f, 0.f, 0.f));
nsLayoutUtils::DrawString(this, aFontMetrics, &aRenderingContext,
str.get(), str.Length(),
nsPoint(x, y + aAscent));
@ -624,7 +624,7 @@ nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext,
}
nsRect rect(aPt, mRect.Size());
aRenderingContext.ThebesContext()->SetColor(NS_RGB(0,0,0));
aRenderingContext.ThebesContext()->SetColor(Color(0.f, 0.f, 0.f));
gfxContextAutoDisableSubpixelAntialiasing disable(aRenderingContext.ThebesContext(), aDisableSubpixelAA);

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

@ -5691,7 +5691,7 @@ nsTextFrame::PaintOneShadow(uint32_t aOffset, uint32_t aLength,
aCtx->Save();
aCtx->NewPath();
aCtx->SetColor(gfxRGBA(shadowColor));
aCtx->SetColor(Color::FromABGR(shadowColor));
// Draw the text onto our alpha-only surface to capture the alpha values.
// Remember that the box blur context has a device offset on it, so we don't need to
@ -6337,7 +6337,7 @@ DrawTextRun(gfxTextRun* aTextRun,
aProvider, aAdvanceWidth, aContextPaint, aCallbacks);
aCallbacks->NotifyAfterText();
} else {
aCtx->SetColor(gfxRGBA(aTextColor));
aCtx->SetColor(Color::FromABGR(aTextColor));
aTextRun->Draw(aCtx, aTextBaselinePt, drawMode, aOffset, aLength,
aProvider, aAdvanceWidth, aContextPaint);
}

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

@ -2136,7 +2136,7 @@ nsMathMLChar::PaintForeground(nsPresContext* aPresContext,
fgColor = LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectForeground,
fgColor);
}
thebesContext->SetColor(fgColor);
thebesContext->SetColor(Color::FromABGR(fgColor));
thebesContext->Save();
nsRect r = mRect + aPt;
ApplyTransforms(thebesContext, aPresContext->AppUnitsPerDevPixel(), r);

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

@ -108,7 +108,7 @@ void nsDisplayMathMLError::Paint(nsDisplayListBuilder* aBuilder,
ColorPattern red(ToDeviceColor(Color(1.f, 0.f, 0.f, 1.f)));
drawTarget->FillRect(rect, red);
aCtx->ThebesContext()->SetColor(NS_RGB(255,255,255));
aCtx->ThebesContext()->SetColor(Color(1.f, 1.f, 1.f));
nscoord ascent = fm->MaxAscent();
NS_NAMED_LITERAL_STRING(errorMsg, "invalid-markup");
nsLayoutUtils::DrawUniDirString(errorMsg.get(), uint32_t(errorMsg.Length()),

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

@ -524,7 +524,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
nscolor c = aOverrideColor ? *aOverrideColor : StyleColor()->mColor;
ColorPattern color(ToDeviceColor(c));
aRenderingContext.ThebesContext()->SetColor(c);
aRenderingContext.ThebesContext()->SetColor(Color::FromABGR(c));
nsresult rv = NS_ERROR_FAILURE;

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

@ -3695,7 +3695,7 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex,
ctx->PushGroup(gfxContentType::COLOR_ALPHA);
}
ctx->SetColor(textContext->StyleColor()->mColor);
ctx->SetColor(Color::FromABGR(textContext->StyleColor()->mColor));
nsLayoutUtils::DrawString(this, *fontMet, &aRenderingContext, text.get(),
text.Length(),
textRect.TopLeft() + nsPoint(0, baseline),