зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1277862, part 1 - Rename Moz2D's Filter to SamplingFilter in gfx/2d/. r=Bas
This commit is contained in:
Родитель
1dd7bdbf29
Коммит
0b33916487
13
gfx/2d/2D.h
13
gfx/2d/2D.h
|
@ -136,13 +136,13 @@ struct StrokeOptions {
|
|||
*/
|
||||
struct DrawSurfaceOptions {
|
||||
/// For constructor parameter description, see member data documentation.
|
||||
explicit DrawSurfaceOptions(Filter aFilter = Filter::LINEAR,
|
||||
explicit DrawSurfaceOptions(SamplingFilter aSamplingFilter = SamplingFilter::LINEAR,
|
||||
SamplingBounds aSamplingBounds = SamplingBounds::UNBOUNDED)
|
||||
: mFilter(aFilter)
|
||||
: mSamplingFilter(aSamplingFilter)
|
||||
, mSamplingBounds(aSamplingBounds)
|
||||
{ }
|
||||
|
||||
Filter mFilter; /**< Filter used when resampling source surface
|
||||
SamplingFilter mSamplingFilter; /**< SamplingFilter used when resampling source surface
|
||||
region to the destination region. */
|
||||
SamplingBounds mSamplingBounds; /**< This indicates whether the implementation is
|
||||
allowed to sample pixels outside the source
|
||||
|
@ -287,11 +287,12 @@ class SurfacePattern : public Pattern
|
|||
public:
|
||||
/// For constructor parameter description, see member data documentation.
|
||||
SurfacePattern(SourceSurface *aSourceSurface, ExtendMode aExtendMode,
|
||||
const Matrix &aMatrix = Matrix(), Filter aFilter = Filter::GOOD,
|
||||
const Matrix &aMatrix = Matrix(),
|
||||
SamplingFilter aSamplingFilter = SamplingFilter::GOOD,
|
||||
const IntRect &aSamplingRect = IntRect())
|
||||
: mSurface(aSourceSurface)
|
||||
, mExtendMode(aExtendMode)
|
||||
, mFilter(aFilter)
|
||||
, mSamplingFilter(aSamplingFilter)
|
||||
, mMatrix(aMatrix)
|
||||
, mSamplingRect(aSamplingRect)
|
||||
{}
|
||||
|
@ -304,7 +305,7 @@ public:
|
|||
RefPtr<SourceSurface> mSurface; //!< Surface to use for drawing
|
||||
ExtendMode mExtendMode; /**< This determines how the image is extended
|
||||
outside the bounds of the image */
|
||||
Filter mFilter; //!< Resampling filter for resampling the image.
|
||||
SamplingFilter mSamplingFilter; //!< Resampling filter for resampling the image.
|
||||
Matrix mMatrix; //!< Transforms the pattern into user space
|
||||
|
||||
IntRect mSamplingRect; /**< Rect that must not be sampled outside of,
|
||||
|
|
|
@ -132,15 +132,15 @@ CGBlendMode ToBlendMode(CompositionOp op)
|
|||
}
|
||||
|
||||
static CGInterpolationQuality
|
||||
InterpolationQualityFromFilter(Filter aFilter)
|
||||
InterpolationQualityFromSamplingFilter(SamplingFilter aSamplingFilter)
|
||||
{
|
||||
switch (aFilter) {
|
||||
switch (aSamplingFilter) {
|
||||
default:
|
||||
case Filter::LINEAR:
|
||||
case SamplingFilter::LINEAR:
|
||||
return kCGInterpolationLow;
|
||||
case Filter::POINT:
|
||||
case SamplingFilter::POINT:
|
||||
return kCGInterpolationNone;
|
||||
case Filter::GOOD:
|
||||
case SamplingFilter::GOOD:
|
||||
return kCGInterpolationLow;
|
||||
}
|
||||
}
|
||||
|
@ -362,11 +362,11 @@ DrawTargetCG::DrawSurface(SourceSurface *aSurface,
|
|||
CGContextSetAlpha(cg, aDrawOptions.mAlpha);
|
||||
CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
|
||||
|
||||
CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(aSurfOptions.mFilter));
|
||||
CGContextSetInterpolationQuality(cg, InterpolationQualityFromSamplingFilter(aSurfOptions.mSamplingFilter));
|
||||
|
||||
CGImageRef image = GetRetainedImageFromSourceSurface(aSurface);
|
||||
|
||||
if (aSurfOptions.mFilter == Filter::POINT) {
|
||||
if (aSurfOptions.mSamplingFilter == SamplingFilter::POINT) {
|
||||
CGImageRef subimage = CGImageCreateWithImageInRect(image, RectToCGRect(aSource));
|
||||
CGImageRelease(image);
|
||||
|
||||
|
@ -868,7 +868,7 @@ SetFillFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern &
|
|||
|
||||
CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
|
||||
const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
|
||||
CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(pat.mFilter));
|
||||
CGContextSetInterpolationQuality(cg, InterpolationQualityFromSamplingFilter(pat.mSamplingFilter));
|
||||
CGFloat alpha = 1.;
|
||||
CGContextSetFillPattern(cg, pattern, &alpha);
|
||||
CGPatternRelease(pattern);
|
||||
|
@ -893,7 +893,7 @@ SetStrokeFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern
|
|||
|
||||
CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
|
||||
const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
|
||||
CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(pat.mFilter));
|
||||
CGContextSetInterpolationQuality(cg, InterpolationQualityFromSamplingFilter(pat.mSamplingFilter));
|
||||
CGFloat alpha = 1.;
|
||||
CGContextSetStrokePattern(cg, pattern, &alpha);
|
||||
CGPatternRelease(pattern);
|
||||
|
@ -1006,7 +1006,7 @@ DrawTargetCG::FillRect(const Rect &aRect,
|
|||
|
||||
CGRect imageRect = CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image));
|
||||
|
||||
CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(pat.mFilter));
|
||||
CGContextSetInterpolationQuality(cg, InterpolationQualityFromSamplingFilter(pat.mSamplingFilter));
|
||||
|
||||
CGContextDrawImage(cg, imageRect, image);
|
||||
CGImageRelease(image);
|
||||
|
|
|
@ -516,7 +516,7 @@ GfxPatternToCairoPattern(const Pattern& aPattern,
|
|||
|
||||
matrix = &pattern.mMatrix;
|
||||
|
||||
cairo_pattern_set_filter(pat, GfxFilterToCairoFilter(pattern.mFilter));
|
||||
cairo_pattern_set_filter(pat, GfxSamplingFilterToCairoFilter(pattern.mSamplingFilter));
|
||||
cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(pattern.mExtendMode));
|
||||
|
||||
cairo_surface_destroy(surf);
|
||||
|
@ -853,7 +853,7 @@ DrawTargetCairo::DrawSurface(SourceSurface *aSurface,
|
|||
cairo_surface_destroy(surf);
|
||||
|
||||
cairo_pattern_set_matrix(pat, &src_mat);
|
||||
cairo_pattern_set_filter(pat, GfxFilterToCairoFilter(aSurfOptions.mFilter));
|
||||
cairo_pattern_set_filter(pat, GfxSamplingFilterToCairoFilter(aSurfOptions.mSamplingFilter));
|
||||
cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD);
|
||||
|
||||
cairo_set_antialias(mContext, GfxAntialiasToCairoAntialias(aOptions.mAntialiasMode));
|
||||
|
|
|
@ -170,7 +170,8 @@ DrawTargetD2D1::DrawSurface(SourceSurface *aSurface,
|
|||
}
|
||||
|
||||
if (bitmap && aSurfOptions.mSamplingBounds == SamplingBounds::UNBOUNDED) {
|
||||
mDC->DrawBitmap(bitmap, D2DRect(aDest), aOptions.mAlpha, D2DFilter(aSurfOptions.mFilter), D2DRect(aSource));
|
||||
mDC->DrawBitmap(bitmap, D2DRect(aDest), aOptions.mAlpha,
|
||||
D2DFilter(aSurfOptions.mSamplingFilter), D2DRect(aSource));
|
||||
} else {
|
||||
// This has issues ignoring the alpha channel on windows 7 with images marked opaque.
|
||||
MOZ_ASSERT(aSurface->GetFormat() != SurfaceFormat::B8G8R8X8);
|
||||
|
@ -178,7 +179,7 @@ DrawTargetD2D1::DrawSurface(SourceSurface *aSurface,
|
|||
D2D1::ImageBrushProperties(samplingBounds,
|
||||
D2D1_EXTEND_MODE_CLAMP,
|
||||
D2D1_EXTEND_MODE_CLAMP,
|
||||
D2DInterpolationMode(aSurfOptions.mFilter)),
|
||||
D2DInterpolationMode(aSurfOptions.mSamplingFilter)),
|
||||
D2D1::BrushProperties(aOptions.mAlpha, D2DMatrix(transform)),
|
||||
getter_AddRefs(brush));
|
||||
mDC->FillRectangle(D2DRect(aDest), brush);
|
||||
|
@ -1704,7 +1705,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
|
|||
|
||||
mDC->CreateBitmapBrush(bitmap,
|
||||
D2D1::BitmapBrushProperties(xRepeat, yRepeat,
|
||||
D2DFilter(pat->mFilter)),
|
||||
D2DFilter(pat->mSamplingFilter)),
|
||||
D2D1::BrushProperties(aAlpha, D2DMatrix(mat)),
|
||||
getter_AddRefs(bitmapBrush));
|
||||
if (!bitmapBrush) {
|
||||
|
@ -1735,7 +1736,7 @@ DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
|
|||
D2D1::ImageBrushProperties(samplingBounds,
|
||||
xRepeat,
|
||||
yRepeat,
|
||||
D2DInterpolationMode(pat->mFilter)),
|
||||
D2DInterpolationMode(pat->mSamplingFilter)),
|
||||
D2D1::BrushProperties(aAlpha, D2DMatrix(mat)),
|
||||
getter_AddRefs(imageBrush));
|
||||
|
||||
|
|
|
@ -61,9 +61,11 @@ public:
|
|||
const SourceSurfaceDual *ssDual =
|
||||
static_cast<const SourceSurfaceDual*>(surfPat->mSurface.get());
|
||||
mA = new (mSurfPatA.addr()) SurfacePattern(ssDual->mA, surfPat->mExtendMode,
|
||||
surfPat->mMatrix, surfPat->mFilter);
|
||||
surfPat->mMatrix,
|
||||
surfPat->mSamplingFilter);
|
||||
mB = new (mSurfPatB.addr()) SurfacePattern(ssDual->mB, surfPat->mExtendMode,
|
||||
surfPat->mMatrix, surfPat->mFilter);
|
||||
surfPat->mMatrix,
|
||||
surfPat->mSamplingFilter);
|
||||
mPatternsInitialized = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ struct AdjustedPattern
|
|||
mPattern =
|
||||
new (mSurfPat) SurfacePattern(GetSourceSurface(surfPat->mSurface),
|
||||
surfPat->mExtendMode, surfPat->mMatrix,
|
||||
surfPat->mFilter);
|
||||
surfPat->mSamplingFilter);
|
||||
return mPattern;
|
||||
}
|
||||
case PatternType::LINEAR_GRADIENT:
|
||||
|
|
|
@ -290,7 +290,7 @@ SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, Float aAlpha = 1.0)
|
|||
|
||||
sk_sp<SkShader> shader = SkShader::MakeBitmapShader(bitmap, xTileMode, yTileMode, &mat);
|
||||
aPaint.setShader(shader);
|
||||
if (pat.mFilter == Filter::POINT) {
|
||||
if (pat.mSamplingFilter == SamplingFilter::POINT) {
|
||||
aPaint.setFilterQuality(kNone_SkFilterQuality);
|
||||
}
|
||||
break;
|
||||
|
@ -405,7 +405,7 @@ DrawTargetSkia::DrawSurface(SourceSurface *aSurface,
|
|||
SkBitmap bitmap = GetBitmapForSurface(aSurface);
|
||||
|
||||
AutoPaintSetup paint(mCanvas.get(), aOptions, &aDest);
|
||||
if (aSurfOptions.mFilter == Filter::POINT) {
|
||||
if (aSurfOptions.mSamplingFilter == SamplingFilter::POINT) {
|
||||
paint.mPaint.setFilterQuality(kNone_SkFilterQuality);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,14 @@ D2D1_COLORMATRIX_ALPHA_MODE D2DAlphaMode(uint32_t aMode)
|
|||
return D2D1_COLORMATRIX_ALPHA_MODE_PREMULTIPLIED;
|
||||
}
|
||||
|
||||
D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE D2DAffineTransformInterpolationMode(Filter aFilter)
|
||||
D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE D2DAffineTransformInterpolationMode(SamplingFilter aSamplingFilter)
|
||||
{
|
||||
switch (aFilter) {
|
||||
case Filter::GOOD:
|
||||
switch (aSamplingFilter) {
|
||||
case SamplingFilter::GOOD:
|
||||
return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_LINEAR;
|
||||
case Filter::LINEAR:
|
||||
case SamplingFilter::LINEAR:
|
||||
return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_LINEAR;
|
||||
case Filter::POINT:
|
||||
case SamplingFilter::POINT:
|
||||
return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
|
||||
default:
|
||||
MOZ_CRASH("GFX: Unknown enum value D2DAffineTIM!");
|
||||
|
@ -172,7 +172,7 @@ uint32_t ConvertValue(FilterType aType, uint32_t aAttribute, uint32_t aValue)
|
|||
break;
|
||||
case FilterType::TRANSFORM:
|
||||
if (aAttribute == ATT_TRANSFORM_FILTER) {
|
||||
aValue = D2DAffineTransformInterpolationMode(Filter(aValue));
|
||||
aValue = D2DAffineTransformInterpolationMode(SamplingFilter(aValue));
|
||||
}
|
||||
break;
|
||||
case FilterType::BLEND:
|
||||
|
|
|
@ -1042,7 +1042,7 @@ FilterNodeBlendSoftware::GetOutputRectInRect(const IntRect& aRect)
|
|||
}
|
||||
|
||||
FilterNodeTransformSoftware::FilterNodeTransformSoftware()
|
||||
: mFilter(Filter::GOOD)
|
||||
: mSamplingFilter(SamplingFilter::GOOD)
|
||||
{}
|
||||
|
||||
int32_t
|
||||
|
@ -1058,7 +1058,7 @@ void
|
|||
FilterNodeTransformSoftware::SetAttribute(uint32_t aIndex, uint32_t aFilter)
|
||||
{
|
||||
MOZ_ASSERT(aIndex == ATT_TRANSFORM_FILTER);
|
||||
mFilter = static_cast<Filter>(aFilter);
|
||||
mSamplingFilter = static_cast<SamplingFilter>(aFilter);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ FilterNodeTransformSoftware::Render(const IntRect& aRect)
|
|||
|
||||
Rect r(0, 0, srcRect.width, srcRect.height);
|
||||
dt->SetTransform(transform);
|
||||
dt->DrawSurface(input, r, r, DrawSurfaceOptions(mFilter));
|
||||
dt->DrawSurface(input, r, r, DrawSurfaceOptions(mSamplingFilter));
|
||||
|
||||
dt->Flush();
|
||||
surf->Unmap();
|
||||
|
|
|
@ -234,7 +234,7 @@ protected:
|
|||
|
||||
private:
|
||||
Matrix mMatrix;
|
||||
Filter mFilter;
|
||||
SamplingFilter mSamplingFilter;
|
||||
};
|
||||
|
||||
class FilterNodeBlendSoftware : public FilterNodeSoftware
|
||||
|
|
|
@ -109,15 +109,15 @@ CairoAntialiasToGfxAntialias(cairo_antialias_t aAntialias)
|
|||
}
|
||||
|
||||
static inline cairo_filter_t
|
||||
GfxFilterToCairoFilter(Filter filter)
|
||||
GfxSamplingFilterToCairoFilter(SamplingFilter filter)
|
||||
{
|
||||
switch (filter)
|
||||
{
|
||||
case Filter::GOOD:
|
||||
case SamplingFilter::GOOD:
|
||||
return CAIRO_FILTER_GOOD;
|
||||
case Filter::LINEAR:
|
||||
case SamplingFilter::LINEAR:
|
||||
return CAIRO_FILTER_BILINEAR;
|
||||
case Filter::POINT:
|
||||
case SamplingFilter::POINT:
|
||||
return CAIRO_FILTER_NEAREST;
|
||||
default:
|
||||
MOZ_CRASH("GFX: bad Cairo filter");
|
||||
|
|
|
@ -75,20 +75,20 @@ static inline D2D1_EXTEND_MODE D2DExtend(ExtendMode aExtendMode, Axis aAxis)
|
|||
return extend;
|
||||
}
|
||||
|
||||
static inline D2D1_BITMAP_INTERPOLATION_MODE D2DFilter(const Filter &aFilter)
|
||||
static inline D2D1_BITMAP_INTERPOLATION_MODE D2DFilter(const SamplingFilter aSamplingFilter)
|
||||
{
|
||||
switch (aFilter) {
|
||||
case Filter::POINT:
|
||||
switch (aSamplingFilter) {
|
||||
case SamplingFilter::POINT:
|
||||
return D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
|
||||
default:
|
||||
return D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;
|
||||
}
|
||||
}
|
||||
|
||||
static inline D2D1_INTERPOLATION_MODE D2DInterpolationMode(const Filter &aFilter)
|
||||
static inline D2D1_INTERPOLATION_MODE D2DInterpolationMode(const SamplingFilter aSamplingFilter)
|
||||
{
|
||||
switch (aFilter) {
|
||||
case Filter::POINT:
|
||||
switch (aSamplingFilter) {
|
||||
case SamplingFilter::POINT:
|
||||
return D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
|
||||
default:
|
||||
return D2D1_INTERPOLATION_MODE_LINEAR;
|
||||
|
|
|
@ -97,11 +97,11 @@ public:
|
|||
SurfacePattern* InitSurfacePattern(SourceSurface *aSourceSurface,
|
||||
ExtendMode aExtendMode,
|
||||
const Matrix &aMatrix = Matrix(),
|
||||
Filter aFilter = Filter::GOOD,
|
||||
SamplingFilter aSamplingFilter = SamplingFilter::GOOD,
|
||||
const IntRect &aSamplingRect = IntRect()) {
|
||||
MOZ_ASSERT(!mPattern);
|
||||
mPattern = new (mSurfacePattern.addr())
|
||||
SurfacePattern(aSourceSurface, aExtendMode, aMatrix, aFilter, aSamplingRect);
|
||||
SurfacePattern(aSourceSurface, aExtendMode, aMatrix, aSamplingFilter, aSamplingRect);
|
||||
return mSurfacePattern.addr();
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ RecordedEvent::StorePattern(PatternStorage &aDestination, const Pattern &aSource
|
|||
const SurfacePattern *pat =
|
||||
static_cast<const SurfacePattern*>(&aSource);
|
||||
store->mExtend = pat->mExtendMode;
|
||||
store->mFilter = pat->mFilter;
|
||||
store->mSamplingFilter = pat->mSamplingFilter;
|
||||
store->mMatrix = pat->mMatrix;
|
||||
store->mSurface = pat->mSurface;
|
||||
return;
|
||||
|
@ -533,7 +533,8 @@ struct GenericPattern
|
|||
SurfacePatternStorage *storage = reinterpret_cast<SurfacePatternStorage*>(&mStorage->mStorage);
|
||||
mPattern =
|
||||
new (mSurfPat) SurfacePattern(mTranslator->LookupSourceSurface(storage->mSurface),
|
||||
storage->mExtend, storage->mMatrix, storage->mFilter);
|
||||
storage->mExtend, storage->mMatrix,
|
||||
storage->mSamplingFilter);
|
||||
return mPattern;
|
||||
}
|
||||
case PatternType::LINEAR_GRADIENT:
|
||||
|
|
|
@ -138,7 +138,7 @@ struct RadialGradientPatternStorage
|
|||
struct SurfacePatternStorage
|
||||
{
|
||||
ExtendMode mExtend;
|
||||
Filter mFilter;
|
||||
SamplingFilter mSamplingFilter;
|
||||
ReferencePtr mSurface;
|
||||
Matrix mMatrix;
|
||||
};
|
||||
|
|
|
@ -235,7 +235,8 @@ enum class AntialiasMode : int8_t {
|
|||
DEFAULT
|
||||
};
|
||||
|
||||
enum class Filter : int8_t {
|
||||
// See https://en.wikipedia.org/wiki/Texture_filtering
|
||||
enum class SamplingFilter : int8_t {
|
||||
GOOD,
|
||||
LINEAR,
|
||||
POINT,
|
||||
|
|
Загрузка…
Ссылка в новой задаче