Bug 1067093 - Get rid of gfxContext::AntialiasMode in favor of Moz2D AntialiasMode. r=Bas

This commit is contained in:
Jonathan Watt 2014-09-15 12:10:30 +01:00
parent efddb901b0
commit 7f41dd89c9
7 changed files with 19 additions and 36 deletions

View File

@ -586,20 +586,13 @@ gfxContext::PixelSnappedRectangleAndSetPattern(const gfxRect& rect,
void
gfxContext::SetAntialiasMode(AntialiasMode mode)
{
if (mode == MODE_ALIASED) {
CurrentState().aaMode = gfx::AntialiasMode::NONE;
} else if (mode == MODE_COVERAGE) {
CurrentState().aaMode = gfx::AntialiasMode::SUBPIXEL;
}
CurrentState().aaMode = mode;
}
gfxContext::AntialiasMode
AntialiasMode
gfxContext::CurrentAntialiasMode() const
{
if (CurrentState().aaMode == gfx::AntialiasMode::NONE) {
return MODE_ALIASED;
}
return MODE_COVERAGE;
return CurrentState().aaMode;
}
void

View File

@ -529,17 +529,8 @@ public:
void SetOperator(GraphicsOperator op);
GraphicsOperator CurrentOperator() const;
/**
* MODE_ALIASED means that only pixels whose centers are in the drawn area
* should be modified, and they should be modified to take the value drawn
* at the pixel center.
*/
enum AntialiasMode {
MODE_ALIASED,
MODE_COVERAGE
};
void SetAntialiasMode(AntialiasMode mode);
AntialiasMode CurrentAntialiasMode() const;
void SetAntialiasMode(mozilla::gfx::AntialiasMode mode);
mozilla::gfx::AntialiasMode CurrentAntialiasMode() const;
/**
** Clipping

View File

@ -93,12 +93,10 @@ gfxSurfaceDrawable::DrawInternal(gfxContext* aContext,
dt->ClearRect(fillRect);
dt->FillRect(fillRect, pattern);
} else {
CompositionOp op = CompositionOpForOp(aContext->CurrentOperator());
AntialiasMode aaMode =
aContext->CurrentAntialiasMode() == gfxContext::MODE_ALIASED ?
AntialiasMode::NONE :
AntialiasMode::SUBPIXEL;
dt->FillRect(fillRect, pattern, DrawOptions(aOpacity, op, aaMode));
dt->FillRect(fillRect, pattern,
DrawOptions(aOpacity,
CompositionOpForOp(aContext->CurrentOperator()),
aContext->CurrentAntialiasMode()));
}
}

View File

@ -9,6 +9,7 @@
#include <ctime>
#include "mozilla/DebugOnly.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/MathAlgorithms.h"
@ -3598,8 +3599,8 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
}
gfxContext *ctx = aContext.ThebesContext();
gfxContext::AntialiasMode oldMode = ctx->CurrentAntialiasMode();
ctx->SetAntialiasMode(gfxContext::MODE_ALIASED);
AntialiasMode oldMode = ctx->CurrentAntialiasMode();
ctx->SetAntialiasMode(AntialiasMode::NONE);
switch (aBorderStyle) {
case NS_STYLE_BORDER_STYLE_NONE:
@ -3932,12 +3933,12 @@ nsCSSRendering::PaintDecorationLine(nsIFrame* aFrame,
contextIsSaved = true;
aGfxContext->Clip(rect);
if (lineHeight > 2.0) {
aGfxContext->SetAntialiasMode(gfxContext::MODE_COVERAGE);
aGfxContext->SetAntialiasMode(AntialiasMode::SUBPIXEL);
} else {
// Don't use anti-aliasing here. Because looks like lighter color wavy
// line at this case. And probably, users don't think the
// non-anti-aliased wavy line is not pretty.
aGfxContext->SetAntialiasMode(gfxContext::MODE_ALIASED);
aGfxContext->SetAntialiasMode(AntialiasMode::NONE);
}
break;
default:

View File

@ -1494,7 +1494,7 @@ nsCSSBorderRenderer::DrawBorders()
gfxFloat dash = mBorderWidths[0];
mContext->SetDash(&dash, 1, 0.5);
mContext->SetAntialiasMode(gfxContext::MODE_ALIASED);
mContext->SetAntialiasMode(AntialiasMode::NONE);
gfxRect rect = mOuterRect;
rect.Deflate(mBorderWidths[0] / 2.0);
mContext->NewPath();

View File

@ -2888,10 +2888,10 @@ SVGTextDrawPathCallbacks::SetupContext()
// or make SetAntialiasMode set cairo text antialiasing too.
switch (mFrame->StyleSVG()->mTextRendering) {
case NS_STYLE_TEXT_RENDERING_OPTIMIZESPEED:
gfx->SetAntialiasMode(gfxContext::MODE_ALIASED);
gfx->SetAntialiasMode(AntialiasMode::NONE);
break;
default:
gfx->SetAntialiasMode(gfxContext::MODE_COVERAGE);
gfx->SetAntialiasMode(AntialiasMode::SUBPIXEL);
break;
}
}

View File

@ -620,10 +620,10 @@ nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext,
switch (StyleSVG()->mShapeRendering) {
case NS_STYLE_SHAPE_RENDERING_OPTIMIZESPEED:
case NS_STYLE_SHAPE_RENDERING_CRISPEDGES:
gfx->SetAntialiasMode(gfxContext::MODE_ALIASED);
gfx->SetAntialiasMode(AntialiasMode::NONE);
break;
default:
gfx->SetAntialiasMode(gfxContext::MODE_COVERAGE);
gfx->SetAntialiasMode(AntialiasMode::SUBPIXEL);
break;
}