Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 2eb705b

Browse files
committed
Bug 1277862, part 3 - Rename Moz2D's Filter to SamplingFilter in the rest of the tree. r=Bas
1 parent 0303602 commit 2eb705b

32 files changed

Lines changed: 161 additions & 149 deletions

dom/canvas/CanvasRenderingContext2D.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,16 @@ class CanvasGeneralPattern
275275
mode = ExtendMode::REPEAT;
276276
}
277277

278-
Filter filter;
278+
SamplingFilter samplingFilter;
279279
if (state.imageSmoothingEnabled) {
280-
filter = Filter::GOOD;
280+
samplingFilter = SamplingFilter::GOOD;
281281
} else {
282-
filter = Filter::POINT;
282+
samplingFilter = SamplingFilter::POINT;
283283
}
284284

285285
mPattern.InitSurfacePattern(state.patternStyles[aStyle]->mSurface, mode,
286-
state.patternStyles[aStyle]->mTransform, filter);
286+
state.patternStyles[aStyle]->mTransform,
287+
samplingFilter);
287288
}
288289

289290
return *mPattern.GetPattern();
@@ -4711,12 +4712,12 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
47114712
return;
47124713
}
47134714

4714-
Filter filter;
4715+
SamplingFilter samplingFilter;
47154716

47164717
if (CurrentState().imageSmoothingEnabled)
4717-
filter = gfx::Filter::LINEAR;
4718+
samplingFilter = gfx::SamplingFilter::LINEAR;
47184719
else
4719-
filter = gfx::Filter::POINT;
4720+
samplingFilter = gfx::SamplingFilter::POINT;
47204721

47214722
gfx::Rect bounds;
47224723

@@ -4739,7 +4740,7 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
47394740
DrawSurface(srcSurf,
47404741
gfx::Rect(aDx, aDy, aDw, aDh),
47414742
sourceRect,
4742-
DrawSurfaceOptions(filter),
4743+
DrawSurfaceOptions(samplingFilter),
47434744
DrawOptions(CurrentState().globalAlpha, UsedOperation()));
47444745
} else {
47454746
DrawDirectlyToCanvas(drawInfo, &bounds,
@@ -4806,7 +4807,7 @@ CanvasRenderingContext2D::DrawDirectlyToCanvas(
48064807
auto result = aImage.mImgContainer->
48074808
Draw(context, scaledImageSize,
48084809
ImageRegion::Create(gfxRect(aSrc.x, aSrc.y, aSrc.width, aSrc.height)),
4809-
aImage.mWhichFrame, Filter::GOOD, Some(svgContext), modifiedFlags);
4810+
aImage.mWhichFrame, SamplingFilter::GOOD, Some(svgContext), modifiedFlags);
48104811

48114812
if (result != DrawResult::SUCCESS) {
48124813
NS_WARNING("imgIContainer::Draw failed");
@@ -5041,7 +5042,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& aWindow, double aX,
50415042
gfx::Rect destRect(0, 0, aW, aH);
50425043
gfx::Rect sourceRect(0, 0, sw, sh);
50435044
mTarget->DrawSurface(source, destRect, sourceRect,
5044-
DrawSurfaceOptions(gfx::Filter::POINT),
5045+
DrawSurfaceOptions(gfx::SamplingFilter::POINT),
50455046
DrawOptions(GlobalAlpha(), UsedOperation(),
50465047
AntialiasMode::NONE));
50475048
mTarget->Flush();

dom/svg/SVGFEImageElement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
230230
Matrix TM = viewBoxTM;
231231
TM.PostTranslate(aFilterSubregion.x, aFilterSubregion.y);
232232

233-
Filter filter = nsLayoutUtils::GetGraphicsFilterForFrame(frame);
233+
SamplingFilter samplingFilter = nsLayoutUtils::GetSamplingFilterForFrame(frame);
234234

235235
FilterPrimitiveDescription descr(PrimitiveType::Image);
236-
descr.Attributes().Set(eImageFilter, (uint32_t)filter);
236+
descr.Attributes().Set(eImageFilter, (uint32_t)samplingFilter);
237237
descr.Attributes().Set(eImageTransform, TM);
238238

239239
// Append the image to aInputImages and store its index in the description.

image/ClippedImage.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class DrawSingleTileCallback : public gfxDrawingCallback
109109

110110
virtual bool operator()(gfxContext* aContext,
111111
const gfxRect& aFillRect,
112-
const Filter& aFilter,
112+
const SamplingFilter aSamplingFilter,
113113
const gfxMatrix& aTransform)
114114
{
115115
MOZ_ASSERT(aTransform.IsIdentity(),
@@ -120,7 +120,7 @@ class DrawSingleTileCallback : public gfxDrawingCallback
120120
// arguments that guarantee we never tile.
121121
mDrawResult =
122122
mImage->DrawSingleTile(aContext, mSize, ImageRegion::Create(aFillRect),
123-
mWhichFrame, aFilter, mSVGContext, mFlags);
123+
mWhichFrame, aSamplingFilter, mSVGContext, mFlags);
124124

125125
return true;
126126
}
@@ -308,7 +308,7 @@ ClippedImage::GetFrameInternal(const nsIntSize& aSize,
308308
gfxUtils::DrawPixelSnapped(ctx, drawable, aSize,
309309
ImageRegion::Create(aSize),
310310
SurfaceFormat::B8G8R8A8,
311-
Filter::LINEAR,
311+
SamplingFilter::LINEAR,
312312
imgIContainer::FLAG_CLAMP);
313313

314314
// Cache the resulting surface.
@@ -367,13 +367,13 @@ ClippedImage::Draw(gfxContext* aContext,
367367
const nsIntSize& aSize,
368368
const ImageRegion& aRegion,
369369
uint32_t aWhichFrame,
370-
Filter aFilter,
370+
SamplingFilter aSamplingFilter,
371371
const Maybe<SVGImageContext>& aSVGContext,
372372
uint32_t aFlags)
373373
{
374374
if (!ShouldClip()) {
375375
return InnerImage()->Draw(aContext, aSize, aRegion, aWhichFrame,
376-
aFilter, aSVGContext, aFlags);
376+
aSamplingFilter, aSVGContext, aFlags);
377377
}
378378

379379
// Check for tiling. If we need to tile then we need to create a
@@ -396,13 +396,13 @@ ClippedImage::Draw(gfxContext* aContext,
396396

397397
// Draw.
398398
gfxUtils::DrawPixelSnapped(aContext, drawable, aSize, aRegion,
399-
SurfaceFormat::B8G8R8A8, aFilter);
399+
SurfaceFormat::B8G8R8A8, aSamplingFilter);
400400

401401
return result;
402402
}
403403

404404
return DrawSingleTile(aContext, aSize, aRegion, aWhichFrame,
405-
aFilter, aSVGContext, aFlags);
405+
aSamplingFilter, aSVGContext, aFlags);
406406
}
407407

408408
static SVGImageContext
@@ -428,7 +428,7 @@ ClippedImage::DrawSingleTile(gfxContext* aContext,
428428
const nsIntSize& aSize,
429429
const ImageRegion& aRegion,
430430
uint32_t aWhichFrame,
431-
Filter aFilter,
431+
SamplingFilter aSamplingFilter,
432432
const Maybe<SVGImageContext>& aSVGContext,
433433
uint32_t aFlags)
434434
{
@@ -469,7 +469,7 @@ ClippedImage::DrawSingleTile(gfxContext* aContext,
469469
aContext->Multiply(gfxMatrix::Translation(-clip.x, -clip.y));
470470

471471
return InnerImage()->Draw(aContext, size, region,
472-
aWhichFrame, aFilter,
472+
aWhichFrame, aSamplingFilter,
473473
aSVGContext.map(UnclipViewport,
474474
make_pair(innerSize, mClip.Size())),
475475
aFlags);
@@ -495,11 +495,12 @@ ClippedImage::GetOrientation()
495495
nsIntSize
496496
ClippedImage::OptimalImageSizeForDest(const gfxSize& aDest,
497497
uint32_t aWhichFrame,
498-
Filter aFilter, uint32_t aFlags)
498+
SamplingFilter aSamplingFilter,
499+
uint32_t aFlags)
499500
{
500501
if (!ShouldClip()) {
501-
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter,
502-
aFlags);
502+
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame,
503+
aSamplingFilter, aFlags);
503504
}
504505

505506
int32_t imgWidth, imgHeight;
@@ -527,7 +528,7 @@ ClippedImage::OptimalImageSizeForDest(const gfxSize& aDest,
527528
gfxSize desiredSize(imgWidth * scale.width, imgHeight * scale.height);
528529
nsIntSize innerDesiredSize =
529530
InnerImage()->OptimalImageSizeForDest(desiredSize, aWhichFrame,
530-
aFilter, aFlags);
531+
aSamplingFilter, aFlags);
531532

532533
// To get our final result, we take the inner image's desired size and
533534
// determine how large the clipped region would be at that scale. (Again, we
@@ -539,8 +540,8 @@ ClippedImage::OptimalImageSizeForDest(const gfxSize& aDest,
539540

540541
MOZ_ASSERT(false,
541542
"If ShouldClip() led us to draw then we should never get here");
542-
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter,
543-
aFlags);
543+
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame,
544+
aSamplingFilter, aFlags);
544545
}
545546

546547
NS_IMETHODIMP_(nsIntRect)

image/ClippedImage.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ClippedImage : public ImageWrapper
5151
const nsIntSize& aSize,
5252
const ImageRegion& aRegion,
5353
uint32_t aWhichFrame,
54-
gfx::Filter aFilter,
54+
gfx::SamplingFilter aSamplingFilter,
5555
const Maybe<SVGImageContext>& aSVGContext,
5656
uint32_t aFlags) override;
5757
NS_IMETHOD RequestDiscard() override;
@@ -60,7 +60,7 @@ class ClippedImage : public ImageWrapper
6060
override;
6161
nsIntSize OptimalImageSizeForDest(const gfxSize& aDest,
6262
uint32_t aWhichFrame,
63-
gfx::Filter aFilter,
63+
gfx::SamplingFilter aSamplingFilter,
6464
uint32_t aFlags) override;
6565

6666
protected:
@@ -80,7 +80,7 @@ class ClippedImage : public ImageWrapper
8080
const nsIntSize& aSize,
8181
const ImageRegion& aRegion,
8282
uint32_t aWhichFrame,
83-
gfx::Filter aFilter,
83+
gfx::SamplingFilter aSamplingFilter,
8484
const Maybe<SVGImageContext>& aSVGContext,
8585
uint32_t aFlags);
8686

image/DynamicImage.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ DynamicImage::GetFrameAtSize(const IntSize& aSize,
189189
MOZ_ASSERT(context); // already checked the draw target above
190190

191191
auto result = Draw(context, aSize, ImageRegion::Create(aSize),
192-
aWhichFrame, Filter::POINT, Nothing(), aFlags);
192+
aWhichFrame, SamplingFilter::POINT, Nothing(), aFlags);
193193

194194
return result == DrawResult::SUCCESS ? dt->Snapshot() : nullptr;
195195
}
@@ -219,7 +219,7 @@ DynamicImage::Draw(gfxContext* aContext,
219219
const nsIntSize& aSize,
220220
const ImageRegion& aRegion,
221221
uint32_t aWhichFrame,
222-
Filter aFilter,
222+
SamplingFilter aSamplingFilter,
223223
const Maybe<SVGImageContext>& aSVGContext,
224224
uint32_t aFlags)
225225
{
@@ -229,7 +229,7 @@ DynamicImage::Draw(gfxContext* aContext,
229229

230230
if (aSize == drawableSize) {
231231
gfxUtils::DrawPixelSnapped(aContext, mDrawable, drawableSize, aRegion,
232-
SurfaceFormat::B8G8R8A8, aFilter);
232+
SurfaceFormat::B8G8R8A8, aSamplingFilter);
233233
return DrawResult::SUCCESS;
234234
}
235235

@@ -243,7 +243,7 @@ DynamicImage::Draw(gfxContext* aContext,
243243
aContext->Multiply(gfxMatrix::Scaling(scale.width, scale.height));
244244

245245
gfxUtils::DrawPixelSnapped(aContext, mDrawable, drawableSize, region,
246-
SurfaceFormat::B8G8R8A8, aFilter);
246+
SurfaceFormat::B8G8R8A8, aSamplingFilter);
247247
return DrawResult::SUCCESS;
248248
}
249249

@@ -319,7 +319,8 @@ DynamicImage::SetAnimationStartTime(const mozilla::TimeStamp& aTime)
319319
nsIntSize
320320
DynamicImage::OptimalImageSizeForDest(const gfxSize& aDest,
321321
uint32_t aWhichFrame,
322-
Filter aFilter, uint32_t aFlags)
322+
SamplingFilter aSamplingFilter,
323+
uint32_t aFlags)
323324
{
324325
IntSize size(mDrawable->Size());
325326
return nsIntSize(size.width, size.height);

image/FrozenImage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ FrozenImage::Draw(gfxContext* aContext,
7474
const nsIntSize& aSize,
7575
const ImageRegion& aRegion,
7676
uint32_t /* aWhichFrame - ignored */,
77-
Filter aFilter,
77+
SamplingFilter aSamplingFilter,
7878
const Maybe<SVGImageContext>& aSVGContext,
7979
uint32_t aFlags)
8080
{
8181
return InnerImage()->Draw(aContext, aSize, aRegion, FRAME_FIRST,
82-
aFilter, aSVGContext, aFlags);
82+
aSamplingFilter, aSVGContext, aFlags);
8383
}
8484

8585
NS_IMETHODIMP_(void)

image/FrozenImage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class FrozenImage : public ImageWrapper
5050
const nsIntSize& aSize,
5151
const ImageRegion& aRegion,
5252
uint32_t aWhichFrame,
53-
gfx::Filter aFilter,
53+
gfx::SamplingFilter aSamplingFilter,
5454
const Maybe<SVGImageContext>& aSVGContext,
5555
uint32_t aFlags) override;
5656
NS_IMETHOD_(void) RequestRefresh(const TimeStamp& aTime) override;

image/ImageWrapper.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace mozilla {
1414

1515
using gfx::DataSourceSurface;
16-
using gfx::Filter;
16+
using gfx::SamplingFilter;
1717
using gfx::SourceSurface;
1818
using layers::LayerManager;
1919
using layers::ImageContainer;
@@ -206,12 +206,12 @@ ImageWrapper::Draw(gfxContext* aContext,
206206
const nsIntSize& aSize,
207207
const ImageRegion& aRegion,
208208
uint32_t aWhichFrame,
209-
Filter aFilter,
209+
SamplingFilter aSamplingFilter,
210210
const Maybe<SVGImageContext>& aSVGContext,
211211
uint32_t aFlags)
212212
{
213213
return mInnerImage->Draw(aContext, aSize, aRegion, aWhichFrame,
214-
aFilter, aSVGContext, aFlags);
214+
aSamplingFilter, aSVGContext, aFlags);
215215
}
216216

217217
NS_IMETHODIMP
@@ -299,10 +299,11 @@ ImageWrapper::PropagateUseCounters(nsIDocument* aParentDocument)
299299
nsIntSize
300300
ImageWrapper::OptimalImageSizeForDest(const gfxSize& aDest,
301301
uint32_t aWhichFrame,
302-
Filter aFilter, uint32_t aFlags)
302+
SamplingFilter aSamplingFilter,
303+
uint32_t aFlags)
303304
{
304-
return mInnerImage->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter,
305-
aFlags);
305+
return mInnerImage->OptimalImageSizeForDest(aDest, aWhichFrame,
306+
aSamplingFilter, aFlags);
306307
}
307308

308309
NS_IMETHODIMP_(nsIntRect)

image/OrientedImage.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
117117
MOZ_ASSERT(ctx); // already checked the draw target above
118118
ctx->Multiply(OrientationMatrix(size));
119119
gfxUtils::DrawPixelSnapped(ctx, drawable, size, ImageRegion::Create(size),
120-
surfaceFormat, Filter::LINEAR);
120+
surfaceFormat, SamplingFilter::LINEAR);
121121

122122
return target->Snapshot();
123123
}
@@ -273,13 +273,14 @@ OrientedImage::Draw(gfxContext* aContext,
273273
const nsIntSize& aSize,
274274
const ImageRegion& aRegion,
275275
uint32_t aWhichFrame,
276-
Filter aFilter,
276+
SamplingFilter aSamplingFilter,
277277
const Maybe<SVGImageContext>& aSVGContext,
278278
uint32_t aFlags)
279279
{
280280
if (mOrientation.IsIdentity()) {
281281
return InnerImage()->Draw(aContext, aSize, aRegion,
282-
aWhichFrame, aFilter, aSVGContext, aFlags);
282+
aWhichFrame, aSamplingFilter,
283+
aSVGContext, aFlags);
283284
}
284285

285286
// Update the image size to match the image's coordinate system. (This could
@@ -302,26 +303,27 @@ OrientedImage::Draw(gfxContext* aContext,
302303
ImageRegion region(aRegion);
303304
region.TransformBoundsBy(inverseMatrix);
304305

305-
return InnerImage()->Draw(aContext, size, region, aWhichFrame, aFilter,
306+
return InnerImage()->Draw(aContext, size, region, aWhichFrame, aSamplingFilter,
306307
aSVGContext.map(OrientViewport, mOrientation),
307308
aFlags);
308309
}
309310

310311
nsIntSize
311312
OrientedImage::OptimalImageSizeForDest(const gfxSize& aDest,
312313
uint32_t aWhichFrame,
313-
Filter aFilter, uint32_t aFlags)
314+
SamplingFilter aSamplingFilter,
315+
uint32_t aFlags)
314316
{
315317
if (!mOrientation.SwapsWidthAndHeight()) {
316-
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter,
317-
aFlags);
318+
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame,
319+
aSamplingFilter, aFlags);
318320
}
319321

320322
// Swap the size for the calculation, then swap it back for the caller.
321323
gfxSize destSize(aDest.height, aDest.width);
322324
nsIntSize innerImageSize(InnerImage()->OptimalImageSizeForDest(destSize,
323325
aWhichFrame,
324-
aFilter,
326+
aSamplingFilter,
325327
aFlags));
326328
return nsIntSize(innerImageSize.height, innerImageSize.width);
327329
}

0 commit comments

Comments
 (0)