From e6cc09cd5158afae9013ab737b3d9ce8686cd977 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 5 Oct 2015 17:12:46 -0700 Subject: [PATCH] Bug 1211324 (part 4) - Replace GraphicsFilter constants with gfx::Filter equivalents. r=mattwoodrow. The conversion is as follows: - GraphicsFilter::FILTER_NEAREST == gfx::Filter::POINT - GraphicsFilter::FILTER_GOOD == gfx::Filter::GOOD - GraphicsFilter::FILTER_BEST == gfx::Filter::LINEAR Also typedef GraphicsFilter to gfx::Filter; this will be removed in the next patch. These changes mean ToFilter() and ThebesFilter() are no longer needed. --- dom/canvas/CanvasRenderingContext2D.cpp | 3 +-- dom/svg/SVGFEImageElement.cpp | 2 +- gfx/2d/HelpersCairo.h | 2 ++ gfx/2d/Types.h | 3 ++- gfx/gl/GLTextureImage.cpp | 2 +- gfx/ipc/GfxMessageUtils.h | 9 +++---- gfx/layers/ImageLayers.cpp | 2 +- gfx/layers/Layers.cpp | 14 +++++----- gfx/layers/Layers.h | 2 +- gfx/layers/LayersLogging.cpp | 20 +++----------- gfx/layers/LayersLogging.h | 4 --- gfx/layers/basic/BasicCanvasLayer.cpp | 2 +- gfx/layers/basic/BasicImageLayer.cpp | 4 +-- gfx/layers/composite/CanvasLayerComposite.cpp | 4 +-- gfx/layers/composite/ImageLayerComposite.cpp | 2 +- gfx/layers/ipc/LayersMessages.ipdlh | 6 ++--- gfx/layers/opengl/CompositorOGL.cpp | 1 - gfx/layers/opengl/CompositorOGLVR.cpp | 1 - gfx/layers/protobuf/LayerScopePacket.pb.cc | 4 +-- gfx/layers/protobuf/LayerScopePacket.pb.h | 13 +++++---- gfx/thebes/GraphicsFilter.h | 9 +++---- gfx/thebes/gfx2DGlue.h | 27 ++----------------- gfx/thebes/gfxDrawable.cpp | 2 +- gfx/thebes/gfxDrawable.h | 2 +- gfx/thebes/gfxPattern.cpp | 6 ++--- gfx/thebes/gfxUtils.cpp | 10 +++---- gfx/thebes/gfxWindowsNativeDrawing.cpp | 2 +- image/ClippedImage.cpp | 2 +- image/DynamicImage.cpp | 3 +-- image/OrientedImage.cpp | 5 ++-- image/RasterImage.cpp | 9 +++---- image/VectorImage.cpp | 8 +++--- layout/base/nsLayoutUtils.cpp | 10 +++---- layout/generic/nsPluginFrame.cpp | 2 +- layout/xul/tree/nsTreeBodyFrame.cpp | 10 +++---- widget/cocoa/nsCocoaUtils.mm | 3 ++- widget/nsBaseDragService.cpp | 2 +- 37 files changed, 81 insertions(+), 131 deletions(-) diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 6ebb8c5f7f2..c9a21b171b3 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -4682,8 +4682,7 @@ CanvasRenderingContext2D::DrawDirectlyToCanvas( auto result = image.mImgContainer-> Draw(context, scaledImageSize, ImageRegion::Create(gfxRect(src.x, src.y, src.width, src.height)), - image.mWhichFrame, GraphicsFilter::FILTER_GOOD, - Some(svgContext), modifiedFlags); + image.mWhichFrame, Filter::GOOD, Some(svgContext), modifiedFlags); if (result != DrawResult::SUCCESS) { NS_WARNING("imgIContainer::Draw failed"); diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp index 1649b674084..dbd0a68b145 100644 --- a/dom/svg/SVGFEImageElement.cpp +++ b/dom/svg/SVGFEImageElement.cpp @@ -235,7 +235,7 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, Matrix TM = viewBoxTM; TM.PostTranslate(aFilterSubregion.x, aFilterSubregion.y); - Filter filter = ToFilter(nsLayoutUtils::GetGraphicsFilterForFrame(frame)); + Filter filter = nsLayoutUtils::GetGraphicsFilterForFrame(frame); FilterPrimitiveDescription descr(PrimitiveType::Image); descr.Attributes().Set(eImageFilter, (uint32_t)filter); diff --git a/gfx/2d/HelpersCairo.h b/gfx/2d/HelpersCairo.h index 84eef0648dd..7f753d01555 100644 --- a/gfx/2d/HelpersCairo.h +++ b/gfx/2d/HelpersCairo.h @@ -119,6 +119,8 @@ GfxFilterToCairoFilter(Filter filter) return CAIRO_FILTER_BILINEAR; case Filter::POINT: return CAIRO_FILTER_NEAREST; + default: + MOZ_CRASH("bad filter"); } return CAIRO_FILTER_BILINEAR; diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index ab3429e9e39..d41417a8c86 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -192,7 +192,8 @@ enum class AntialiasMode : int8_t { enum class Filter : int8_t { GOOD, LINEAR, - POINT + POINT, + SENTINEL // one past the last valid value }; enum class PatternType : int8_t { diff --git a/gfx/gl/GLTextureImage.cpp b/gfx/gl/GLTextureImage.cpp index 26ebbe36653..906a2815ebf 100644 --- a/gfx/gl/GLTextureImage.cpp +++ b/gfx/gl/GLTextureImage.cpp @@ -270,7 +270,7 @@ TextureImage::TextureImage(const gfx::IntSize& aSize, : mSize(aSize) , mWrapMode(aWrapMode) , mContentType(aContentType) - , mFilter(GraphicsFilter::FILTER_GOOD) + , mFilter(Filter::GOOD) , mFlags(aFlags) {} diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 52ea8c97372..c7b47c5b6f3 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -33,7 +33,6 @@ namespace mozilla { typedef gfxImageFormat PixelFormat; -typedef ::GraphicsFilter GraphicsFilterType; } // namespace mozilla @@ -206,11 +205,11 @@ struct ParamTraits {}; template <> -struct ParamTraits +struct ParamTraits : public ContiguousEnumSerializer< - mozilla::GraphicsFilterType, - GraphicsFilter::FILTER_GOOD, - GraphicsFilter::FILTER_SENTINEL> + mozilla::gfx::Filter, + mozilla::gfx::Filter::GOOD, + mozilla::gfx::Filter::SENTINEL> {}; template <> diff --git a/gfx/layers/ImageLayers.cpp b/gfx/layers/ImageLayers.cpp index d02ec48466f..dc9f36dcd0a 100644 --- a/gfx/layers/ImageLayers.cpp +++ b/gfx/layers/ImageLayers.cpp @@ -14,7 +14,7 @@ namespace mozilla { namespace layers { ImageLayer::ImageLayer(LayerManager* aManager, void* aImplData) -: Layer(aManager, aImplData), mFilter(GraphicsFilter::FILTER_GOOD) +: Layer(aManager, aImplData), mFilter(gfx::Filter::GOOD) , mScaleMode(ScaleMode::SCALE_NONE), mDisallowBigImage(false) {} diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index f9a249996ae..99343a8ce13 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -2136,7 +2136,7 @@ void CanvasLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix) { Layer::PrintInfo(aStream, aPrefix); - if (mFilter != GraphicsFilter::FILTER_GOOD) { + if (mFilter != Filter::GOOD) { AppendToString(aStream, mFilter, " [filter=", "]"); } } @@ -2148,14 +2148,14 @@ DumpFilter(layerscope::LayersPacket::Layer* aLayer, const GraphicsFilter& aFilte { using namespace layerscope; switch (aFilter) { - case GraphicsFilter::FILTER_GOOD: + case Filter::GOOD: aLayer->set_filter(LayersPacket::Layer::FILTER_GOOD); break; - case GraphicsFilter::FILTER_BEST: - aLayer->set_filter(LayersPacket::Layer::FILTER_BEST); + case Filter::LINEAR: + aLayer->set_filter(LayersPacket::Layer::FILTER_LINEAR); break; - case GraphicsFilter::FILTER_NEAREST: - aLayer->set_filter(LayersPacket::Layer::FILTER_NEAREST); + case Filter::POINT: + aLayer->set_filter(LayersPacket::Layer::FILTER_POINT); break; default: // ignore it @@ -2178,7 +2178,7 @@ void ImageLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix) { Layer::PrintInfo(aStream, aPrefix); - if (mFilter != GraphicsFilter::FILTER_GOOD) { + if (mFilter != Filter::GOOD) { AppendToString(aStream, mFilter, " [filter=", "]"); } } diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index a530cd124f5..e7d33dff570 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -2404,7 +2404,7 @@ protected: , mPreTransCallbackData(nullptr) , mPostTransCallback(nullptr) , mPostTransCallbackData(nullptr) - , mFilter(GraphicsFilter::FILTER_GOOD) + , mFilter(gfx::Filter::GOOD) , mDirty(false) {} diff --git a/gfx/layers/LayersLogging.cpp b/gfx/layers/LayersLogging.cpp index 852423bf8e7..c9862ebc218 100644 --- a/gfx/layers/LayersLogging.cpp +++ b/gfx/layers/LayersLogging.cpp @@ -28,22 +28,6 @@ AppendToString(std::stringstream& aStream, const void* p, aStream << sfx; } -void -AppendToString(std::stringstream& aStream, const GraphicsFilter& f, - const char* pfx, const char* sfx) -{ - aStream << pfx; - switch (f) { - case GraphicsFilter::FILTER_GOOD: aStream << "good"; break; - case GraphicsFilter::FILTER_BEST: aStream << "best"; break; - case GraphicsFilter::FILTER_NEAREST: aStream << "nearest"; break; - default: - NS_ERROR("unknown filter type"); - aStream << "???"; - } - aStream << sfx; -} - void AppendToString(std::stringstream& aStream, FrameMetrics::ViewID n, const char* pfx, const char* sfx) @@ -276,7 +260,6 @@ AppendToString(std::stringstream& aStream, const Matrix5x4& m, aStream << sfx; } - void AppendToString(std::stringstream& aStream, const Filter filter, const char* pfx, const char* sfx) @@ -287,6 +270,9 @@ AppendToString(std::stringstream& aStream, const Filter filter, case Filter::GOOD: aStream << "Filter::GOOD"; break; case Filter::LINEAR: aStream << "Filter::LINEAR"; break; case Filter::POINT: aStream << "Filter::POINT"; break; + default: + NS_ERROR("unknown filter type"); + aStream << "???"; } aStream << sfx; } diff --git a/gfx/layers/LayersLogging.h b/gfx/layers/LayersLogging.h index 25340405f1e..65f546470cd 100644 --- a/gfx/layers/LayersLogging.h +++ b/gfx/layers/LayersLogging.h @@ -30,10 +30,6 @@ void AppendToString(std::stringstream& aStream, const void* p, const char* pfx="", const char* sfx=""); -void -AppendToString(std::stringstream& aStream, const GraphicsFilter& f, - const char* pfx="", const char* sfx=""); - void AppendToString(std::stringstream& aStream, FrameMetrics::ViewID n, const char* pfx="", const char* sfx=""); diff --git a/gfx/layers/basic/BasicCanvasLayer.cpp b/gfx/layers/basic/BasicCanvasLayer.cpp index 080d4b79efa..6d4d977c34a 100644 --- a/gfx/layers/basic/BasicCanvasLayer.cpp +++ b/gfx/layers/basic/BasicCanvasLayer.cpp @@ -52,7 +52,7 @@ BasicCanvasLayer::Paint(DrawTarget* aDT, FillRectWithMask(aDT, aDeviceOffset, Rect(0, 0, mBounds.width, mBounds.height), - mSurface, ToFilter(mFilter), + mSurface, mFilter, DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)), aMaskLayer); diff --git a/gfx/layers/basic/BasicImageLayer.cpp b/gfx/layers/basic/BasicImageLayer.cpp index d4d3e46d78c..ade40a758e5 100644 --- a/gfx/layers/basic/BasicImageLayer.cpp +++ b/gfx/layers/basic/BasicImageLayer.cpp @@ -85,8 +85,8 @@ BasicImageLayer::Paint(DrawTarget* aDT, } gfx::IntSize size = mSize = surface->GetSize(); - FillRectWithMask(aDT, aDeviceOffset, Rect(0, 0, size.width, size.height), - surface, ToFilter(mFilter), + FillRectWithMask(aDT, aDeviceOffset, Rect(0, 0, size.width, size.height), + surface, mFilter, DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)), aMaskLayer); diff --git a/gfx/layers/composite/CanvasLayerComposite.cpp b/gfx/layers/composite/CanvasLayerComposite.cpp index 50e1e63f3b5..dffdf7dbcbf 100644 --- a/gfx/layers/composite/CanvasLayerComposite.cpp +++ b/gfx/layers/composite/CanvasLayerComposite.cpp @@ -137,10 +137,10 @@ CanvasLayerComposite::GetEffectFilter() Matrix matrix; bool is2D = GetEffectiveTransform().Is2D(&matrix); if (is2D && !ThebesMatrix(matrix).HasNonTranslationOrFlip()) { - filter = GraphicsFilter::FILTER_NEAREST; + filter = Filter::POINT; } #endif - return gfx::ToFilter(filter); + return filter; } void diff --git a/gfx/layers/composite/ImageLayerComposite.cpp b/gfx/layers/composite/ImageLayerComposite.cpp index 0a79a91d848..c54fb56ba76 100644 --- a/gfx/layers/composite/ImageLayerComposite.cpp +++ b/gfx/layers/composite/ImageLayerComposite.cpp @@ -166,7 +166,7 @@ ImageLayerComposite::CleanupResources() gfx::Filter ImageLayerComposite::GetEffectFilter() { - return gfx::ToFilter(mFilter); + return mFilter; } void diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index 6bc6c578472..14e9eeb5179 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -17,7 +17,7 @@ include "gfxipc/ShadowLayerUtils.h"; include "mozilla/GfxMessageUtils.h"; include "ImageLayers.h"; -using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h"; +using mozilla::gfx::Filter from "mozilla/gfx/2D.h"; using struct mozilla::gfx::Color from "mozilla/gfx/2D.h"; using struct mozilla::gfx::Point3D from "mozilla/gfx/Point.h"; using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h"; @@ -253,14 +253,14 @@ struct ContainerLayerAttributes { uint64_t hmdInfo; }; struct ColorLayerAttributes { LayerColor color; IntRect bounds; }; -struct CanvasLayerAttributes { GraphicsFilterType filter; IntRect bounds; }; +struct CanvasLayerAttributes { Filter filter; IntRect bounds; }; struct RefLayerAttributes { int64_t id; // TODO: Once bug 1132895 is fixed we shouldn't need to propagate the override // explicitly here. EventRegionsOverride eventRegionsOverride; }; -struct ImageLayerAttributes { GraphicsFilterType filter; IntSize scaleToSize; ScaleMode scaleMode; }; +struct ImageLayerAttributes { Filter filter; IntSize scaleToSize; ScaleMode scaleMode; }; union SpecificLayerAttributes { null_t; diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 6a39e49db5b..e03123842ad 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -12,7 +12,6 @@ #include "GLUploadHelpers.h" #include "Layers.h" // for WriteSnapshotToDumpFile #include "LayerScope.h" // for LayerScope -#include "gfx2DGlue.h" // for ThebesFilter #include "gfxCrashReporterUtils.h" // for ScopedGfxFeatureReporter #include "GraphicsFilter.h" // for GraphicsFilter #include "gfxPlatform.h" // for gfxPlatform diff --git a/gfx/layers/opengl/CompositorOGLVR.cpp b/gfx/layers/opengl/CompositorOGLVR.cpp index 5cf2923a2c7..ce13500fd88 100644 --- a/gfx/layers/opengl/CompositorOGLVR.cpp +++ b/gfx/layers/opengl/CompositorOGLVR.cpp @@ -18,7 +18,6 @@ #include "GLUploadHelpers.h" #include "Layers.h" // for WriteSnapshotToDumpFile #include "LayerScope.h" // for LayerScope -#include "gfx2DGlue.h" // for ThebesFilter #include "gfxCrashReporterUtils.h" // for ScopedGfxFeatureReporter #include "gfxMatrix.h" // for gfxMatrix #include "GraphicsFilter.h" // for GraphicsFilter diff --git a/gfx/layers/protobuf/LayerScopePacket.pb.cc b/gfx/layers/protobuf/LayerScopePacket.pb.cc index 7ab57d1bba2..6e7c1ab6304 100644 --- a/gfx/layers/protobuf/LayerScopePacket.pb.cc +++ b/gfx/layers/protobuf/LayerScopePacket.pb.cc @@ -1187,8 +1187,8 @@ bool LayersPacket_Layer_Filter_IsValid(int value) { #ifndef _MSC_VER const LayersPacket_Layer_Filter LayersPacket_Layer::FILTER_GOOD; -const LayersPacket_Layer_Filter LayersPacket_Layer::FILTER_BEST; -const LayersPacket_Layer_Filter LayersPacket_Layer::FILTER_NEAREST; +const LayersPacket_Layer_Filter LayersPacket_Layer::FILTER_LINEAR; +const LayersPacket_Layer_Filter LayersPacket_Layer::FILTER_POINT; const LayersPacket_Layer_Filter LayersPacket_Layer::FILTER_SENTINEL; #endif // _MSC_VER #ifndef _MSC_VER diff --git a/gfx/layers/protobuf/LayerScopePacket.pb.h b/gfx/layers/protobuf/LayerScopePacket.pb.h index ad64e183bb0..5774386b3c3 100644 --- a/gfx/layers/protobuf/LayerScopePacket.pb.h +++ b/gfx/layers/protobuf/LayerScopePacket.pb.h @@ -76,11 +76,10 @@ const LayersPacket_Layer_ScrollingDirect LayersPacket_Layer_ScrollingDirect_Scro const int LayersPacket_Layer_ScrollingDirect_ScrollingDirect_ARRAYSIZE = LayersPacket_Layer_ScrollingDirect_ScrollingDirect_MAX + 1; enum LayersPacket_Layer_Filter { - LayersPacket_Layer_Filter_FILTER_FAST = 0, - LayersPacket_Layer_Filter_FILTER_GOOD = 1, - LayersPacket_Layer_Filter_FILTER_BEST = 2, - LayersPacket_Layer_Filter_FILTER_NEAREST = 3, - LayersPacket_Layer_Filter_FILTER_SENTINEL = 6 + LayersPacket_Layer_Filter_FILTER_GOOD = 0, + LayersPacket_Layer_Filter_FILTER_LINEAR = 1, + LayersPacket_Layer_Filter_FILTER_POINT = 2, + LayersPacket_Layer_Filter_FILTER_SENTINEL = 3 }; bool LayersPacket_Layer_Filter_IsValid(int value); @@ -1155,8 +1154,8 @@ class LayersPacket_Layer : public ::google::protobuf::MessageLite { typedef LayersPacket_Layer_Filter Filter; static const Filter FILTER_GOOD = LayersPacket_Layer_Filter_FILTER_GOOD; - static const Filter FILTER_BEST = LayersPacket_Layer_Filter_FILTER_BEST; - static const Filter FILTER_NEAREST = LayersPacket_Layer_Filter_FILTER_NEAREST; + static const Filter FILTER_LINEAR = LayersPacket_Layer_Filter_FILTER_LINEAR; + static const Filter FILTER_POINT = LayersPacket_Layer_Filter_FILTER_POINT; static const Filter FILTER_SENTINEL = LayersPacket_Layer_Filter_FILTER_SENTINEL; static inline bool Filter_IsValid(int value) { return LayersPacket_Layer_Filter_IsValid(value); diff --git a/gfx/thebes/GraphicsFilter.h b/gfx/thebes/GraphicsFilter.h index 570f935ed51..8013493f07d 100644 --- a/gfx/thebes/GraphicsFilter.h +++ b/gfx/thebes/GraphicsFilter.h @@ -6,12 +6,9 @@ #ifndef GraphicsFilter_h #define GraphicsFilter_h -enum class GraphicsFilter : int { - FILTER_GOOD, - FILTER_BEST, - FILTER_NEAREST, - FILTER_SENTINEL -}; +#include "mozilla/gfx/Types.h" + +typedef mozilla::gfx::Filter GraphicsFilter; #endif diff --git a/gfx/thebes/gfx2DGlue.h b/gfx/thebes/gfx2DGlue.h index 2623120c029..5c79a951a3f 100644 --- a/gfx/thebes/gfx2DGlue.h +++ b/gfx/thebes/gfx2DGlue.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -5,7 +7,6 @@ #ifndef GFX_2D_GLUE_H #define GFX_2D_GLUE_H - #include "gfxPlatform.h" #include "gfxRect.h" #include "gfxMatrix.h" @@ -60,30 +61,6 @@ inline Size ToSize(const gfxSize &aSize) return Size(Float(aSize.width), Float(aSize.height)); } -inline Filter ToFilter(GraphicsFilter aFilter) -{ - switch (aFilter) { - case GraphicsFilter::FILTER_NEAREST: - return Filter::POINT; - case GraphicsFilter::FILTER_GOOD: - return Filter::GOOD; - default: - return Filter::LINEAR; - } -} - -inline GraphicsFilter ThebesFilter(Filter aFilter) -{ - switch (aFilter) { - case Filter::POINT: - return GraphicsFilter::FILTER_NEAREST; - case Filter::GOOD: - return GraphicsFilter::FILTER_GOOD; - default: - return GraphicsFilter::FILTER_BEST; - } -} - inline gfxPoint ThebesPoint(const Point &aPoint) { return gfxPoint(aPoint.x, aPoint.y); diff --git a/gfx/thebes/gfxDrawable.cpp b/gfx/thebes/gfxDrawable.cpp index c7ee4af2391..f69e6749305 100644 --- a/gfx/thebes/gfxDrawable.cpp +++ b/gfx/thebes/gfxDrawable.cpp @@ -91,7 +91,7 @@ gfxSurfaceDrawable::DrawInternal(gfxContext* aContext, patternTransform.Invert(); SurfacePattern pattern(mSourceSurface, extend, - patternTransform, ToFilter(aFilter), aSamplingRect); + patternTransform, aFilter, aSamplingRect); Rect fillRect = ToRect(aFillRect); DrawTarget* dt = aContext->GetDrawTarget(); diff --git a/gfx/thebes/gfxDrawable.h b/gfx/thebes/gfxDrawable.h index d0c1e75af32..f565771caf9 100644 --- a/gfx/thebes/gfxDrawable.h +++ b/gfx/thebes/gfxDrawable.h @@ -136,7 +136,7 @@ public: const gfxMatrix& aTransform = gfxMatrix()); protected: - already_AddRefed MakeSurfaceDrawable(const GraphicsFilter aFilter = GraphicsFilter::FILTER_BEST); + already_AddRefed MakeSurfaceDrawable(const GraphicsFilter aFilter = mozilla::gfx::Filter::LINEAR); nsRefPtr mCallback; nsRefPtr mSurfaceDrawable; diff --git a/gfx/thebes/gfxPattern.cpp b/gfx/thebes/gfxPattern.cpp index 0492c66f050..25603ba5bc2 100644 --- a/gfx/thebes/gfxPattern.cpp +++ b/gfx/thebes/gfxPattern.cpp @@ -188,16 +188,16 @@ gfxPattern::SetFilter(GraphicsFilter filter) return; } - static_cast(mGfxPattern.GetPattern())->mFilter = ToFilter(filter); + static_cast(mGfxPattern.GetPattern())->mFilter = filter; } GraphicsFilter gfxPattern::Filter() const { if (mGfxPattern.GetPattern()->GetType() != PatternType::SURFACE) { - return GraphicsFilter::FILTER_GOOD; + return Filter::GOOD; } - return ThebesFilter(static_cast(mGfxPattern.GetPattern())->mFilter); + return static_cast(mGfxPattern.GetPattern())->mFilter; } bool diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index 79a0bf5cb4b..b100258682b 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -453,8 +453,8 @@ CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable, nsRefPtr tmpCtx = new gfxContext(target); tmpCtx->SetOp(OptimalFillOp()); - aDrawable->Draw(tmpCtx, needed - needed.TopLeft(), true, - GraphicsFilter::FILTER_BEST, 1.0, gfxMatrix::Translation(needed.TopLeft())); + aDrawable->Draw(tmpCtx, needed - needed.TopLeft(), true, Filter::LINEAR, + 1.0, gfxMatrix::Translation(needed.TopLeft())); RefPtr surface = target->Snapshot(); nsRefPtr drawable = new gfxSurfaceDrawable(surface, size, gfxMatrix::Translation(-needed.TopLeft())); @@ -559,7 +559,7 @@ static GraphicsFilter ReduceResamplingFilter(GraphicsFilter aFilter, || aImgHeight <= kSmallImageSizeThreshold) { // Never resample small images. These are often used for borders and // rules (think 1x1 images used to make lines). - return GraphicsFilter::FILTER_NEAREST; + return Filter::POINT; } if (aImgHeight * kLargeStretch <= aSourceHeight || aImgWidth * kLargeStretch <= aSourceWidth) { @@ -570,7 +570,7 @@ static GraphicsFilter ReduceResamplingFilter(GraphicsFilter aFilter, // (which might be large) and then is stretching it to fill some part // of the page. if (fabs(aSourceWidth - aImgWidth)/aImgWidth < 0.5 || fabs(aSourceHeight - aImgHeight)/aImgHeight < 0.5) - return GraphicsFilter::FILTER_NEAREST; + return Filter::POINT; // The image is growing a lot and in more than one direction. Resampling // is slow and doesn't give us very much when growing a lot. @@ -695,7 +695,7 @@ PrescaleAndTileDrawable(gfxDrawable* aDrawable, aContext->CurrentAntialiasMode()); SurfacePattern scaledImagePattern(scaledImage, ExtendMode::REPEAT, - Matrix(), ToFilter(aFilter)); + Matrix(), aFilter); destDrawTarget->FillRect(scaledNeededRect, scaledImagePattern, drawOptions); } return true; diff --git a/gfx/thebes/gfxWindowsNativeDrawing.cpp b/gfx/thebes/gfxWindowsNativeDrawing.cpp index 559c38323d2..e6f7282f3bb 100644 --- a/gfx/thebes/gfxWindowsNativeDrawing.cpp +++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp @@ -288,7 +288,7 @@ gfxWindowsNativeDrawing::PaintToContext() pat->SetMatrix(m); if (mNativeDrawFlags & DO_NEAREST_NEIGHBOR_FILTERING) - pat->SetFilter(GraphicsFilter::FILTER_BEST); + pat->SetFilter(Filter::LINEAR); pat->SetExtend(ExtendMode::CLAMP); mContext->SetPattern(pat); diff --git a/image/ClippedImage.cpp b/image/ClippedImage.cpp index 1b95d3a64ac..7f7c5f2de3f 100644 --- a/image/ClippedImage.cpp +++ b/image/ClippedImage.cpp @@ -291,7 +291,7 @@ ClippedImage::GetFrameInternal(const nsIntSize& aSize, gfxUtils::DrawPixelSnapped(ctx, drawable, aSize, ImageRegion::Create(aSize), SurfaceFormat::B8G8R8A8, - GraphicsFilter::FILTER_BEST, + Filter::LINEAR, imgIContainer::FLAG_CLAMP); // Cache the resulting surface. diff --git a/image/DynamicImage.cpp b/image/DynamicImage.cpp index 6aa1bfdffdf..659fe70dddf 100644 --- a/image/DynamicImage.cpp +++ b/image/DynamicImage.cpp @@ -188,8 +188,7 @@ DynamicImage::GetFrameAtSize(const IntSize& aSize, nsRefPtr context = new gfxContext(dt); auto result = Draw(context, aSize, ImageRegion::Create(aSize), - aWhichFrame, GraphicsFilter::FILTER_NEAREST, - Nothing(), aFlags); + aWhichFrame, Filter::POINT, Nothing(), aFlags); return result == DrawResult::SUCCESS ? dt->Snapshot() : nullptr; } diff --git a/image/OrientedImage.cpp b/image/OrientedImage.cpp index 87893195a73..c4068719ac3 100644 --- a/image/OrientedImage.cpp +++ b/image/OrientedImage.cpp @@ -115,9 +115,8 @@ OrientedImage::GetFrame(uint32_t aWhichFrame, // Draw. nsRefPtr ctx = new gfxContext(target); ctx->Multiply(OrientationMatrix(size)); - gfxUtils::DrawPixelSnapped(ctx, drawable, size, - ImageRegion::Create(size), - surfaceFormat, GraphicsFilter::FILTER_BEST); + gfxUtils::DrawPixelSnapped(ctx, drawable, size, ImageRegion::Create(size), + surfaceFormat, Filter::LINEAR); return target->Snapshot(); } diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index 2e9483c1f39..4ec87d61ff3 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -1520,9 +1520,9 @@ RasterImage::Draw(gfxContext* aContext, mProgressTracker->OnUnlockedDraw(); } - // If we're not using GraphicsFilter::FILTER_GOOD, we shouldn't high-quality - // scale or downscale during decode. - uint32_t flags = aFilter == GraphicsFilter::FILTER_GOOD + // If we're not using Filter::GOOD, we shouldn't high-quality scale or + // downscale during decode. + uint32_t flags = aFilter == Filter::GOOD ? aFlags : aFlags & ~FLAG_HIGH_QUALITY_SCALING; @@ -1862,8 +1862,7 @@ RasterImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame, IntSize destSize(ceil(aDest.width), ceil(aDest.height)); - if (aFilter == GraphicsFilter::FILTER_GOOD && - CanDownscaleDuringDecode(destSize, aFlags)) { + if (aFilter == Filter::GOOD && CanDownscaleDuringDecode(destSize, aFlags)) { return destSize; } diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index 9e9fb00d3a2..7451f1125ed 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -735,10 +735,8 @@ VectorImage::GetFrameAtSize(const IntSize& aSize, nsRefPtr context = new gfxContext(dt); - auto result = Draw(context, aSize, - ImageRegion::Create(aSize), - aWhichFrame, GraphicsFilter::FILTER_NEAREST, - Nothing(), aFlags); + auto result = Draw(context, aSize, ImageRegion::Create(aSize), + aWhichFrame, Filter::POINT, Nothing(), aFlags); return result == DrawResult::SUCCESS ? dt->Snapshot() : nullptr; } @@ -918,7 +916,7 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams) nsresult rv = frame->InitWithDrawable(svgDrawable, aParams.size, SurfaceFormat::B8G8R8A8, - GraphicsFilter::FILTER_NEAREST, aParams.flags); + Filter::POINT, aParams.flags); // If we couldn't create the frame, it was probably because it would end // up way too big. Generally it also wouldn't fit in the cache, but the prefs diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 7eedfacc6f3..08dd84b0e81 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -5871,7 +5871,7 @@ nsLayoutUtils::GetClosestLayer(nsIFrame* aFrame) GraphicsFilter nsLayoutUtils::GetGraphicsFilterForFrame(nsIFrame* aForFrame) { - GraphicsFilter defaultFilter = GraphicsFilter::FILTER_GOOD; + GraphicsFilter defaultFilter = Filter::GOOD; nsStyleContext *sc; if (nsCSSRendering::IsCanvasFrame(aForFrame)) { nsCSSRendering::FindBackground(aForFrame, &sc); @@ -5881,11 +5881,11 @@ nsLayoutUtils::GetGraphicsFilterForFrame(nsIFrame* aForFrame) switch (sc->StyleSVG()->mImageRendering) { case NS_STYLE_IMAGE_RENDERING_OPTIMIZESPEED: - return GraphicsFilter::FILTER_BEST; + return Filter::POINT; case NS_STYLE_IMAGE_RENDERING_OPTIMIZEQUALITY: - return GraphicsFilter::FILTER_BEST; + return Filter::LINEAR; case NS_STYLE_IMAGE_RENDERING_CRISPEDGES: - return GraphicsFilter::FILTER_NEAREST; + return Filter::POINT; default: return defaultFilter; } @@ -6414,7 +6414,7 @@ nsLayoutUtils::DrawBackgroundImage(gfxContext& aContext, js::ProfileEntry::Category::GRAPHICS); if (UseBackgroundNearestFiltering()) { - aGraphicsFilter = GraphicsFilter::FILTER_NEAREST; + aGraphicsFilter = Filter::POINT; } SVGImageContext svgContext(aImageSize, Nothing()); diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp index 37bfbdfc2ac..d5751ef1bb5 100644 --- a/layout/generic/nsPluginFrame.cpp +++ b/layout/generic/nsPluginFrame.cpp @@ -1462,7 +1462,7 @@ nsPluginFrame::BuildLayer(nsDisplayListBuilder* aBuilder, #ifdef MOZ_GFX_OPTIMIZE_MOBILE if (!aManager->IsCompositingCheap()) { // Pixman just horrible with bilinear filter scaling - filter = GraphicsFilter::FILTER_NEAREST; + filter = Filter::POINT; } #endif imglayer->SetFilter(filter); diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 737c0074156..3b8b1cbc40d 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -3419,11 +3419,11 @@ nsTreeBodyFrame::PaintTwisty(int32_t aRowIndex, if (imageSize.height < twistyRect.height) { pt.y += (twistyRect.height - imageSize.height)/2; } - + // Paint the image. - nsLayoutUtils::DrawSingleUnscaledImage(*aRenderingContext.ThebesContext(), - aPresContext, image, - GraphicsFilter::FILTER_NEAREST, pt, &aDirtyRect, + nsLayoutUtils::DrawSingleUnscaledImage( + *aRenderingContext.ThebesContext(), aPresContext, image, + Filter::POINT, pt, &aDirtyRect, imgIContainer::FLAG_NONE, &imageSize); } } @@ -3767,7 +3767,7 @@ nsTreeBodyFrame::PaintCheckbox(int32_t aRowIndex, // Paint the image. nsLayoutUtils::DrawSingleUnscaledImage(*aRenderingContext.ThebesContext(), aPresContext, - image, GraphicsFilter::FILTER_NEAREST, pt, &aDirtyRect, + image, Filter::POINT, pt, &aDirtyRect, imgIContainer::FLAG_NONE, &imageSize); } } diff --git a/widget/cocoa/nsCocoaUtils.mm b/widget/cocoa/nsCocoaUtils.mm index ee95fb0b6e6..dab2ffdcb2b 100644 --- a/widget/cocoa/nsCocoaUtils.mm +++ b/widget/cocoa/nsCocoaUtils.mm @@ -35,6 +35,7 @@ using mozilla::gfx::BackendType; using mozilla::gfx::DataSourceSurface; using mozilla::gfx::DrawTarget; using mozilla::gfx::Factory; +using mozilla::gfx::Filter; using mozilla::gfx::IntPoint; using mozilla::gfx::IntRect; using mozilla::gfx::IntSize; @@ -491,7 +492,7 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer *aImage, ui } aImage->Draw(context, scaledSize, ImageRegion::Create(scaledSize), - aWhichFrame, GraphicsFilter::FILTER_NEAREST, Nothing(), + aWhichFrame, Filter::POINT, Nothing(), imgIContainer::FLAG_SYNC_DECODE); surface = drawTarget->Snapshot(); diff --git a/widget/nsBaseDragService.cpp b/widget/nsBaseDragService.cpp index 27f54660072..32c9d9bcf8b 100644 --- a/widget/nsBaseDragService.cpp +++ b/widget/nsBaseDragService.cpp @@ -670,7 +670,7 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext, imgContainer->Draw(ctx, destSize, ImageRegion::Create(destSize), imgIContainer::FRAME_CURRENT, - GraphicsFilter::FILTER_GOOD, Nothing(), + Filter::GOOD, Nothing(), imgIContainer::FLAG_SYNC_DECODE); *aSurface = dt->Snapshot(); } else {