Skip to content

Commit

Permalink
Bug 1410359 - Remove unused css filter codes. r=kats
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mephisto41 committed Oct 20, 2017
1 parent 1f86929 commit f482bf5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 112 deletions.
7 changes: 0 additions & 7 deletions gfx/layers/Layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2328,12 +2328,6 @@ class ContainerLayer : public Layer {
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) {}
Expand Down Expand Up @@ -2424,7 +2418,6 @@ class ContainerLayer : public Layer {
// the intermediate surface.
bool mChildrenChanged;
EventRegionsOverride mEventRegionsOverride;
nsTArray<CSSFilter> mFilterChain;
};

/**
Expand Down
43 changes: 0 additions & 43 deletions gfx/layers/LayersTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 0 additions & 21 deletions gfx/layers/LayersTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ namespace android {
class MOZ_EXPORT GraphicBuffer;
} // namespace android

struct nsStyleFilter;

namespace mozilla {
namespace layers {

Expand Down Expand Up @@ -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

Expand Down
28 changes: 10 additions & 18 deletions gfx/webrender_bindings/WebRenderTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
39 changes: 16 additions & 23 deletions layout/painting/nsDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f482bf5

Please sign in to comment.