Bug 897532. Add support for better filtering in Azure. r=bas

This fixes the quality regression on OS X.

--HG--
extra : rebase_source : f045caa95800d05098ea49e05fe90fc933f8849f
This commit is contained in:
Jeff Muizelaar 2013-07-31 14:46:25 -04:00
Родитель 14d0dced66
Коммит 8818ab3b07
7 изменённых файлов: 25 добавлений и 19 удалений

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

@ -292,7 +292,7 @@ public:
* aFilter Resampling filter used for resampling the image.
*/
SurfacePattern(SourceSurface *aSourceSurface, ExtendMode aExtendMode,
const Matrix &aMatrix = Matrix(), Filter aFilter = FILTER_LINEAR)
const Matrix &aMatrix = Matrix(), Filter aFilter = FILTER_GOOD)
: mSurface(aSourceSurface)
, mExtendMode(aExtendMode)
, mFilter(aFilter)

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

@ -123,6 +123,19 @@ CGBlendMode ToBlendMode(CompositionOp op)
return mode;
}
static CGInterpolationQuality
InterpolationQualityFromFilter(Filter aFilter)
{
switch (aFilter) {
default:
case FILTER_LINEAR:
return kCGInterpolationLow;
case FILTER_POINT:
return kCGInterpolationNone;
case FILTER_GOOD:
return kCGInterpolationDefault;
}
}
DrawTargetCG::DrawTargetCG() : mCg(nullptr), mSnapshot(nullptr)
@ -291,10 +304,7 @@ DrawTargetCG::DrawSurface(SourceSurface *aSurface,
CGRect flippedRect = CGRectMake(aDest.x, -(aDest.y + aDest.height),
aDest.width, aDest.height);
if (aSurfOptions.mFilter == FILTER_POINT)
CGContextSetInterpolationQuality(cg, kCGInterpolationNone);
else
CGContextSetInterpolationQuality(cg, kCGInterpolationLow);
CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(aSurfOptions.mFilter));
CGContextDrawImage(cg, flippedRect, image);
@ -653,10 +663,7 @@ SetFillFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern &
CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
if (pat.mFilter == FILTER_POINT)
CGContextSetInterpolationQuality(cg, kCGInterpolationNone);
else
CGContextSetInterpolationQuality(cg, kCGInterpolationLow);
CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(pat.mFilter));
CGFloat alpha = 1.;
CGContextSetFillPattern(cg, pattern, &alpha);
CGPatternRelease(pattern);
@ -681,10 +688,7 @@ SetStrokeFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern
CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
if (pat.mFilter == FILTER_POINT)
CGContextSetInterpolationQuality(cg, kCGInterpolationNone);
else
CGContextSetInterpolationQuality(cg, kCGInterpolationLow);
CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(pat.mFilter));
CGFloat alpha = 1.;
CGContextSetStrokePattern(cg, pattern, &alpha);
CGPatternRelease(pattern);
@ -770,10 +774,7 @@ DrawTargetCG::FillRect(const Rect &aRect,
CGRect imageRect = CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image));
if (pat.mFilter == FILTER_POINT)
CGContextSetInterpolationQuality(cg, kCGInterpolationNone);
else
CGContextSetInterpolationQuality(cg, kCGInterpolationLow);
CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(pat.mFilter));
CGContextDrawImage(cg, imageRect, image);
} else {

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

@ -285,7 +285,7 @@ DrawTargetSkia::DrawSurface(SourceSurface *aSurface,
const SkBitmap& bitmap = static_cast<SourceSurfaceSkia*>(aSurface)->GetBitmap();
AutoPaintSetup paint(mCanvas.get(), aOptions);
if (aSurfOptions.mFilter != FILTER_LINEAR) {
if (aSurfOptions.mFilter == FILTER_POINT) {
paint.mPaint.setFilterBitmap(false);
}

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

@ -82,6 +82,8 @@ GfxFilterToCairoFilter(Filter filter)
{
switch (filter)
{
case FILTER_GOOD:
return CAIRO_FILTER_GOOD;
case FILTER_LINEAR:
return CAIRO_FILTER_BILINEAR;
case FILTER_POINT:

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

@ -104,7 +104,7 @@ enum ExtendMode { EXTEND_CLAMP, EXTEND_REPEAT, EXTEND_REFLECT };
enum FillRule { FILL_WINDING, FILL_EVEN_ODD };
enum AntialiasMode { AA_NONE, AA_GRAY, AA_SUBPIXEL, AA_DEFAULT };
enum Snapping { SNAP_NONE, SNAP_ALIGNED };
enum Filter { FILTER_LINEAR, FILTER_POINT };
enum Filter { FILTER_GOOD, FILTER_LINEAR, FILTER_POINT };
enum PatternType { PATTERN_COLOR, PATTERN_SURFACE, PATTERN_LINEAR_GRADIENT, PATTERN_RADIAL_GRADIENT };
enum JoinStyle { JOIN_BEVEL, JOIN_ROUND, JOIN_MITER, JOIN_MITER_OR_BEVEL };
enum CapStyle { CAP_BUTT, CAP_ROUND, CAP_SQUARE };

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

@ -847,6 +847,7 @@ CompositorD3D11::SetSamplerForFilter(Filter aFilter)
{
ID3D11SamplerState *sampler;
switch (aFilter) {
default:
case FILTER_LINEAR:
sampler = mAttachments->mLinearSamplerState;
break;

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

@ -69,6 +69,8 @@ inline Filter ToFilter(gfxPattern::GraphicsFilter aFilter)
switch (aFilter) {
case gfxPattern::FILTER_NEAREST:
return FILTER_POINT;
case gfxPattern::FILTER_GOOD:
return FILTER_GOOD;
default:
return FILTER_LINEAR;
}