Bug 907011 - Implement antialias mode for the Cairo Azure backend. r=Bas

This commit is contained in:
Matt Woodrow 2013-08-21 11:56:27 +12:00
parent e790df95f3
commit 6775b7dfee
2 changed files with 29 additions and 0 deletions

View File

@ -433,6 +433,8 @@ DrawTargetCairo::DrawSurface(SourceSurface *aSurface,
cairo_pattern_set_filter(pat, GfxFilterToCairoFilter(aSurfOptions.mFilter));
cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD);
cairo_set_antialias(mContext, GfxAntialiasToCairoAntialias(aOptions.mAntialiasMode));
cairo_translate(mContext, aDest.X(), aDest.Y());
if (IsOperatorBoundByMask(aOptions.mCompositionOp)) {
@ -544,6 +546,8 @@ DrawTargetCairo::DrawPattern(const Pattern& aPattern,
cairo_pattern_t* pat = GfxPatternToCairoPattern(aPattern, aOptions.mAlpha);
cairo_set_source(mContext, pat);
cairo_set_antialias(mContext, GfxAntialiasToCairoAntialias(aOptions.mAntialiasMode));
if (NeedIntermediateSurface(aPattern, aOptions) ||
!IsOperatorBoundByMask(aOptions.mCompositionOp)) {
cairo_push_group_with_content(mContext, CAIRO_CONTENT_COLOR_ALPHA);
@ -612,6 +616,7 @@ DrawTargetCairo::CopySurface(SourceSurface *aSurface,
cairo_set_source_surface(mContext, surf, aDest.x - aSource.x, aDest.y - aSource.y);
cairo_set_operator(mContext, CAIRO_OPERATOR_SOURCE);
cairo_set_antialias(mContext, CAIRO_ANTIALIAS_NONE);
cairo_reset_clip(mContext);
cairo_new_path(mContext);
@ -624,6 +629,7 @@ DrawTargetCairo::ClearRect(const Rect& aRect)
{
AutoPrepareForDrawing prep(this, mContext);
cairo_set_antialias(mContext, CAIRO_ANTIALIAS_NONE);
cairo_new_path(mContext);
cairo_set_operator(mContext, CAIRO_OPERATOR_CLEAR);
cairo_rectangle(mContext, aRect.X(), aRect.Y(),
@ -711,6 +717,8 @@ DrawTargetCairo::FillGlyphs(ScaledFont *aFont,
cairo_set_source(mContext, pat);
cairo_pattern_destroy(pat);
cairo_set_antialias(mContext, GfxAntialiasToCairoAntialias(aOptions.mAntialiasMode));
// Convert our GlyphBuffer into an array of Cairo glyphs.
std::vector<cairo_glyph_t> glyphs(aBuffer.mNumGlyphs);
for (uint32_t i = 0; i < aBuffer.mNumGlyphs; ++i) {
@ -731,6 +739,8 @@ DrawTargetCairo::Mask(const Pattern &aSource,
AutoClearDeviceOffset clearSource(aSource);
AutoClearDeviceOffset clearMask(aMask);
cairo_set_antialias(mContext, GfxAntialiasToCairoAntialias(aOptions.mAntialiasMode));
cairo_pattern_t* source = GfxPatternToCairoPattern(aSource, aOptions.mAlpha);
cairo_set_source(mContext, source);
@ -755,6 +765,8 @@ DrawTargetCairo::MaskSurface(const Pattern &aSource,
return;
}
cairo_set_antialias(mContext, GfxAntialiasToCairoAntialias(aOptions.mAntialiasMode));
cairo_pattern_t* pat = GfxPatternToCairoPattern(aSource, aOptions.mAlpha);
cairo_set_source(mContext, pat);

View File

@ -77,6 +77,23 @@ GfxOpToCairoOp(CompositionOp op)
return CAIRO_OPERATOR_OVER;
}
static inline cairo_antialias_t
GfxAntialiasToCairoAntialias(AntialiasMode antialias)
{
switch (antialias)
{
case AA_NONE:
return CAIRO_ANTIALIAS_NONE;
case AA_GRAY:
return CAIRO_ANTIALIAS_GRAY;
case AA_SUBPIXEL:
return CAIRO_ANTIALIAS_SUBPIXEL;
case AA_DEFAULT:
return CAIRO_ANTIALIAS_DEFAULT;
}
return CAIRO_ANTIALIAS_DEFAULT;
}
static inline cairo_filter_t
GfxFilterToCairoFilter(Filter filter)
{