Bug 1410359 - Remove unused css filter codes. r=kats

Some css filter codes only used in layers-full mode. Since layers-full
already removed, we can also remove those unused codes.

MozReview-Commit-ID: 8YrfOfuXHNt

--HG--
extra : rebase_source : e9475d9100fbc2e5b301833f31fde1db458117aa
This commit is contained in:
Morris Tseng 2017-10-20 16:10:03 +08:00
parent 1f86929f6d
commit f482bf5f38
5 changed files with 26 additions and 112 deletions

View File

@ -2328,12 +2328,6 @@ public:
return mEventRegionsOverride;
}
void SetFilterChain(nsTArray<CSSFilter>&& aFilterChain) {
mFilterChain = aFilterChain;
}
nsTArray<CSSFilter>& GetFilterChain() { return mFilterChain; }
// If |aRect| is null, the entire layer should be considered invalid for
// compositing.
virtual void SetInvalidCompositeRect(const gfx::IntRect* aRect) {}
@ -2424,7 +2418,6 @@ protected:
// the intermediate surface.
bool mChildrenChanged;
EventRegionsOverride mEventRegionsOverride;
nsTArray<CSSFilter> mFilterChain;
};
/**

View File

@ -5,52 +5,9 @@
#include "LayersTypes.h"
#include "nsStyleStruct.h" // for nsStyleFilter
namespace mozilla {
namespace layers {
CSSFilter ToCSSFilter(const nsStyleFilter& filter)
{
switch (filter.GetType()) {
case NS_STYLE_FILTER_BRIGHTNESS: {
return {
CSSFilterType::BRIGHTNESS,
filter.GetFilterParameter().GetFactorOrPercentValue(),
};
}
case NS_STYLE_FILTER_CONTRAST: {
return {
CSSFilterType::CONTRAST,
filter.GetFilterParameter().GetFactorOrPercentValue(),
};
}
case NS_STYLE_FILTER_GRAYSCALE: {
return {
CSSFilterType::GRAYSCALE,
filter.GetFilterParameter().GetFactorOrPercentValue(),
};
}
case NS_STYLE_FILTER_INVERT: {
return {
CSSFilterType::INVERT,
filter.GetFilterParameter().GetFactorOrPercentValue(),
};
}
case NS_STYLE_FILTER_SEPIA: {
return {
CSSFilterType::SEPIA,
filter.GetFilterParameter().GetFactorOrPercentValue(),
};
}
// All other filter types should be prevented by the code which converts
// display items into layers.
default:
MOZ_ASSERT_UNREACHABLE("Tried to convert an unsupported filter");
return { CSSFilterType::CONTRAST, 0 };
}
}
EventRegions::EventRegions(const nsIntRegion& aHitRegion,
const nsIntRegion& aMaybeHitRegion,
const nsIntRegion& aDispatchToContentRegion,

View File

@ -38,8 +38,6 @@ namespace android {
class MOZ_EXPORT GraphicBuffer;
} // namespace android
struct nsStyleFilter;
namespace mozilla {
namespace layers {
@ -352,25 +350,6 @@ MOZ_DEFINE_ENUM_CLASS_WITH_BASE(ScrollDirection, uint32_t, (
HORIZONTAL
));
enum class CSSFilterType : int8_t {
BLUR,
BRIGHTNESS,
CONTRAST,
GRAYSCALE,
HUE_ROTATE,
INVERT,
OPACITY,
SATURATE,
SEPIA,
};
struct CSSFilter {
CSSFilterType type;
float argument;
};
CSSFilter ToCSSFilter(const nsStyleFilter& filter);
} // namespace layers
} // namespace mozilla

View File

@ -12,7 +12,6 @@
#include "mozilla/gfx/Matrix.h"
#include "mozilla/gfx/Types.h"
#include "mozilla/gfx/Tools.h"
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/PodOperations.h"
#include "mozilla/Range.h"
#include "mozilla/Variant.h"
@ -672,38 +671,31 @@ struct BuiltDisplayList {
wr::BuiltDisplayListDescriptor dl_desc;
};
static inline wr::WrFilterOpType ToWrFilterOpType(const layers::CSSFilterType type) {
static inline wr::WrFilterOpType ToWrFilterOpType(uint32_t type) {
switch (type) {
case layers::CSSFilterType::BLUR:
case NS_STYLE_FILTER_BLUR:
return wr::WrFilterOpType::Blur;
case layers::CSSFilterType::BRIGHTNESS:
case NS_STYLE_FILTER_BRIGHTNESS:
return wr::WrFilterOpType::Brightness;
case layers::CSSFilterType::CONTRAST:
case NS_STYLE_FILTER_CONTRAST:
return wr::WrFilterOpType::Contrast;
case layers::CSSFilterType::GRAYSCALE:
case NS_STYLE_FILTER_GRAYSCALE:
return wr::WrFilterOpType::Grayscale;
case layers::CSSFilterType::HUE_ROTATE:
case NS_STYLE_FILTER_HUE_ROTATE:
return wr::WrFilterOpType::HueRotate;
case layers::CSSFilterType::INVERT:
case NS_STYLE_FILTER_INVERT:
return wr::WrFilterOpType::Invert;
case layers::CSSFilterType::OPACITY:
case NS_STYLE_FILTER_OPACITY:
return wr::WrFilterOpType::Opacity;
case layers::CSSFilterType::SATURATE:
case NS_STYLE_FILTER_SATURATE:
return wr::WrFilterOpType::Saturate;
case layers::CSSFilterType::SEPIA:
case NS_STYLE_FILTER_SEPIA:
return wr::WrFilterOpType::Sepia;
}
MOZ_ASSERT_UNREACHABLE("Tried to convert unknown filter type.");
return wr::WrFilterOpType::Grayscale;
}
static inline wr::WrFilterOp ToWrFilterOp(const layers::CSSFilter& filter) {
return {
ToWrFilterOpType(filter.type),
filter.argument,
};
}
// Corresponds to an "internal" webrender clip id. That is, a
// ClipId::Clip(x,pipeline_id) maps to a WrClipId{x}. We use a struct wrapper
// instead of a typedef so that this is a distinct type from FrameMetrics::ViewID

View File

@ -9502,17 +9502,6 @@ nsDisplayFilter::BuildLayer(nsDisplayListBuilder* aBuilder,
RefPtr<ContainerLayer> container = aManager->GetLayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList,
newContainerParameters, nullptr);
LayerState state = this->GetLayerState(aBuilder, aManager, newContainerParameters);
if (container && state != LAYER_SVG_EFFECTS) {
const nsTArray<nsStyleFilter>& filters = mFrame->StyleEffects()->mFilters;
nsTArray<layers::CSSFilter> cssFilters = nsTArray<layers::CSSFilter>(filters.Length());
for (const nsStyleFilter& filter : filters) {
cssFilters.AppendElement(ToCSSFilter(filter));
}
container->SetFilterChain(Move(cssFilters));
}
return container.forget();
}
@ -9594,21 +9583,25 @@ nsDisplayFilter::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuild
// Due to differences in the way that WebRender filters operate
// only the brightness and contrast filters use that path. We
// can gradually enable more filters as WebRender bugs are fixed.
for (const nsStyleFilter& filter : mFrame->StyleEffects()->mFilters) {
if (filter.GetType() != NS_STYLE_FILTER_BRIGHTNESS &&
filter.GetType() != NS_STYLE_FILTER_CONTRAST &&
filter.GetType() != NS_STYLE_FILTER_GRAYSCALE &&
filter.GetType() != NS_STYLE_FILTER_INVERT &&
filter.GetType() != NS_STYLE_FILTER_SEPIA) {
return false;
}
}
nsTArray<mozilla::wr::WrFilterOp> wrFilters;
const nsTArray<nsStyleFilter>& filters = mFrame->StyleEffects()->mFilters;
nsTArray<layers::CSSFilter> cssFilters = nsTArray<layers::CSSFilter>(filters.Length());
for (const nsStyleFilter& filter : filters) {
wrFilters.AppendElement(wr::ToWrFilterOp(ToCSSFilter(filter)));
switch (filter.GetType()) {
case NS_STYLE_FILTER_BRIGHTNESS:
case NS_STYLE_FILTER_CONTRAST:
case NS_STYLE_FILTER_GRAYSCALE:
case NS_STYLE_FILTER_INVERT:
case NS_STYLE_FILTER_SEPIA: {
mozilla::wr::WrFilterOp filterOp = {
wr::ToWrFilterOpType(filter.GetType()),
filter.GetFilterParameter().GetFactorOrPercentValue(),
};
wrFilters.AppendElement(filterOp);
break;
}
default:
return false;
}
}
StackingContextHelper sc(aSc, aBuilder, wrFilters);