Bug 1509182. Switch from using WrFilterOp to using FilterOp directly. r=nical

This avoids code duplication and simplifies push_stacking_context

Differential Revision: https://phabricator.services.mozilla.com/D16050

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Muizelaar 2019-01-10 18:40:56 +00:00
Родитель 1e14e832fa
Коммит ef9bb810f0
19 изменённых файлов: 452 добавлений и 171 удалений

Просмотреть файл

@ -403,7 +403,7 @@ void AsyncImagePipelineManager::ApplyAsyncImageForPipeline(
wr::ToRoundedLayoutRect(aPipeline->mScBounds), nullptr, nullptr, &opacity, wr::ToRoundedLayoutRect(aPipeline->mScBounds), nullptr, nullptr, &opacity,
aPipeline->mScTransform.IsIdentity() ? nullptr : &aPipeline->mScTransform, aPipeline->mScTransform.IsIdentity() ? nullptr : &aPipeline->mScTransform,
wr::TransformStyle::Flat, nullptr, aPipeline->mMixBlendMode, wr::TransformStyle::Flat, nullptr, aPipeline->mMixBlendMode,
nsTArray<wr::WrFilterOp>(), true, nsTArray<wr::FilterOp>(), true,
// This is fine to do unconditionally because we only push images here. // This is fine to do unconditionally because we only push images here.
wr::RasterSpace::Screen()); wr::RasterSpace::Screen());

Просмотреть файл

@ -24,7 +24,7 @@ StackingContextHelper::StackingContextHelper()
StackingContextHelper::StackingContextHelper( StackingContextHelper::StackingContextHelper(
const StackingContextHelper& aParentSC, const ActiveScrolledRoot* aAsr, const StackingContextHelper& aParentSC, const ActiveScrolledRoot* aAsr,
nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem, nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem,
wr::DisplayListBuilder& aBuilder, const nsTArray<wr::WrFilterOp>& aFilters, wr::DisplayListBuilder& aBuilder, const nsTArray<wr::FilterOp>& aFilters,
const LayoutDeviceRect& aBounds, const gfx::Matrix4x4* aBoundTransform, const LayoutDeviceRect& aBounds, const gfx::Matrix4x4* aBoundTransform,
const wr::WrAnimationProperty* aAnimation, const float* aOpacityPtr, const wr::WrAnimationProperty* aAnimation, const float* aOpacityPtr,
const gfx::Matrix4x4* aTransformPtr, const gfx::Matrix4x4* aPerspectivePtr, const gfx::Matrix4x4* aTransformPtr, const gfx::Matrix4x4* aPerspectivePtr,

Просмотреть файл

@ -31,7 +31,7 @@ class MOZ_RAII StackingContextHelper {
const StackingContextHelper& aParentSC, const ActiveScrolledRoot* aAsr, const StackingContextHelper& aParentSC, const ActiveScrolledRoot* aAsr,
nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem, nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem,
wr::DisplayListBuilder& aBuilder, wr::DisplayListBuilder& aBuilder,
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>(), const nsTArray<wr::FilterOp>& aFilters = nsTArray<wr::FilterOp>(),
const LayoutDeviceRect& aBounds = LayoutDeviceRect(), const LayoutDeviceRect& aBounds = LayoutDeviceRect(),
const gfx::Matrix4x4* aBoundTransform = nullptr, const gfx::Matrix4x4* aBoundTransform = nullptr,
const wr::WrAnimationProperty* aAnimation = nullptr, const wr::WrAnimationProperty* aAnimation = nullptr,

Просмотреть файл

@ -1432,7 +1432,7 @@ void WebRenderCommandBuilder::BuildWebRenderCommands(
wr::DisplayListBuilder& aBuilder, wr::DisplayListBuilder& aBuilder,
wr::IpcResourceUpdateQueue& aResourceUpdates, nsDisplayList* aDisplayList, wr::IpcResourceUpdateQueue& aResourceUpdates, nsDisplayList* aDisplayList,
nsDisplayListBuilder* aDisplayListBuilder, WebRenderScrollData& aScrollData, nsDisplayListBuilder* aDisplayListBuilder, WebRenderScrollData& aScrollData,
wr::LayoutSize& aContentSize, const nsTArray<wr::WrFilterOp>& aFilters) { wr::LayoutSize& aContentSize, const nsTArray<wr::FilterOp>& aFilters) {
StackingContextHelper sc; StackingContextHelper sc;
aScrollData = WebRenderScrollData(mManager); aScrollData = WebRenderScrollData(mManager);
MOZ_ASSERT(mLayerScrollData.empty()); MOZ_ASSERT(mLayerScrollData.empty());

Просмотреть файл

@ -57,7 +57,7 @@ class WebRenderCommandBuilder {
nsDisplayListBuilder* aDisplayListBuilder, nsDisplayListBuilder* aDisplayListBuilder,
WebRenderScrollData& aScrollData, WebRenderScrollData& aScrollData,
wr::LayoutSize& aContentSize, wr::LayoutSize& aContentSize,
const nsTArray<wr::WrFilterOp>& aFilters); const nsTArray<wr::FilterOp>& aFilters);
void PushOverrideForASR(const ActiveScrolledRoot* aASR, void PushOverrideForASR(const ActiveScrolledRoot* aASR,
const wr::WrSpatialId& aSpatialId); const wr::WrSpatialId& aSpatialId);

Просмотреть файл

@ -246,7 +246,7 @@ void WebRenderLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback,
void WebRenderLayerManager::EndTransactionWithoutLayer( void WebRenderLayerManager::EndTransactionWithoutLayer(
nsDisplayList* aDisplayList, nsDisplayListBuilder* aDisplayListBuilder, nsDisplayList* aDisplayList, nsDisplayListBuilder* aDisplayListBuilder,
const nsTArray<wr::WrFilterOp>& aFilters, const nsTArray<wr::FilterOp>& aFilters,
WebRenderBackgroundData* aBackground) { WebRenderBackgroundData* aBackground) {
AUTO_PROFILER_TRACING("Paint", "RenderLayers"); AUTO_PROFILER_TRACING("Paint", "RenderLayers");

Просмотреть файл

@ -79,7 +79,7 @@ class WebRenderLayerManager final : public LayerManager {
EndTransactionFlags aFlags = END_DEFAULT) override; EndTransactionFlags aFlags = END_DEFAULT) override;
void EndTransactionWithoutLayer( void EndTransactionWithoutLayer(
nsDisplayList* aDisplayList, nsDisplayListBuilder* aDisplayListBuilder, nsDisplayList* aDisplayList, nsDisplayListBuilder* aDisplayListBuilder,
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>(), const nsTArray<wr::FilterOp>& aFilters = nsTArray<wr::FilterOp>(),
WebRenderBackgroundData* aBackground = nullptr); WebRenderBackgroundData* aBackground = nullptr);
virtual void EndTransaction( virtual void EndTransaction(
DrawPaintedLayerCallback aCallback, void* aCallbackData, DrawPaintedLayerCallback aCallback, void* aCallbackData,

Просмотреть файл

@ -676,7 +676,7 @@ Maybe<wr::WrSpatialId> DisplayListBuilder::PushStackingContext(
const WrAnimationProperty* aAnimation, const float* aOpacity, const WrAnimationProperty* aAnimation, const float* aOpacity,
const gfx::Matrix4x4* aTransform, wr::TransformStyle aTransformStyle, const gfx::Matrix4x4* aTransform, wr::TransformStyle aTransformStyle,
const gfx::Matrix4x4* aPerspective, const wr::MixBlendMode& aMixBlendMode, const gfx::Matrix4x4* aPerspective, const wr::MixBlendMode& aMixBlendMode,
const nsTArray<wr::WrFilterOp>& aFilters, bool aIsBackfaceVisible, const nsTArray<wr::FilterOp>& aFilters, bool aIsBackfaceVisible,
const wr::RasterSpace& aRasterSpace) { const wr::RasterSpace& aRasterSpace) {
MOZ_ASSERT(mClipChainLeaf.isNothing(), MOZ_ASSERT(mClipChainLeaf.isNothing(),
"Non-empty leaf from clip chain given, but not used with SC!"); "Non-empty leaf from clip chain given, but not used with SC!");

Просмотреть файл

@ -335,7 +335,7 @@ class DisplayListBuilder {
const wr::WrAnimationProperty* aAnimation, const float* aOpacity, const wr::WrAnimationProperty* aAnimation, const float* aOpacity,
const gfx::Matrix4x4* aTransform, wr::TransformStyle aTransformStyle, const gfx::Matrix4x4* aTransform, wr::TransformStyle aTransformStyle,
const gfx::Matrix4x4* aPerspective, const wr::MixBlendMode& aMixBlendMode, const gfx::Matrix4x4* aPerspective, const wr::MixBlendMode& aMixBlendMode,
const nsTArray<wr::WrFilterOp>& aFilters, bool aIsBackfaceVisible, const nsTArray<wr::FilterOp>& aFilters, bool aIsBackfaceVisible,
const wr::RasterSpace& aRasterSpace); const wr::RasterSpace& aRasterSpace);
void PopStackingContext(bool aIsReferenceFrame); void PopStackingContext(bool aIsReferenceFrame);

Просмотреть файл

@ -771,34 +771,6 @@ struct BuiltDisplayList {
wr::BuiltDisplayListDescriptor dl_desc; wr::BuiltDisplayListDescriptor dl_desc;
}; };
static inline wr::WrFilterOpType ToWrFilterOpType(uint32_t type) {
switch (type) {
case NS_STYLE_FILTER_BLUR:
return wr::WrFilterOpType::Blur;
case NS_STYLE_FILTER_BRIGHTNESS:
return wr::WrFilterOpType::Brightness;
case NS_STYLE_FILTER_CONTRAST:
return wr::WrFilterOpType::Contrast;
case NS_STYLE_FILTER_GRAYSCALE:
return wr::WrFilterOpType::Grayscale;
case NS_STYLE_FILTER_HUE_ROTATE:
return wr::WrFilterOpType::HueRotate;
case NS_STYLE_FILTER_INVERT:
return wr::WrFilterOpType::Invert;
case NS_STYLE_FILTER_OPACITY:
return wr::WrFilterOpType::Opacity;
case NS_STYLE_FILTER_SATURATE:
return wr::WrFilterOpType::Saturate;
case NS_STYLE_FILTER_SEPIA:
return wr::WrFilterOpType::Sepia;
case NS_STYLE_FILTER_DROP_SHADOW:
return wr::WrFilterOpType::DropShadow;
}
MOZ_ASSERT_UNREACHABLE("Tried to convert unknown filter type.");
return wr::WrFilterOpType::Grayscale;
}
// Corresponds to a clip id for a clip chain in webrender. Similar to // Corresponds to a clip id for a clip chain in webrender. Similar to
// WrClipId but a separate struct so we don't get them mixed up in C++. // WrClipId but a separate struct so we don't get them mixed up in C++.
struct WrClipChainId { struct WrClipChainId {

Просмотреть файл

@ -477,34 +477,6 @@ pub struct WrAnimationProperty {
id: u64, id: u64,
} }
#[repr(u32)]
#[derive(Copy, Clone)]
pub enum WrFilterOpType {
Blur = 0,
Brightness = 1,
Contrast = 2,
Grayscale = 3,
HueRotate = 4,
Invert = 5,
Opacity = 6,
Saturate = 7,
Sepia = 8,
DropShadow = 9,
ColorMatrix = 10,
SrgbToLinear = 11,
LinearToSrgb = 12,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct WrFilterOp {
filter_type: WrFilterOpType,
argument: c_float, // holds radius for DropShadow; value for other filters
offset: LayoutVector2D, // only used for DropShadow
color: ColorF, // only used for DropShadow
matrix: [f32;20], // only used in ColorMatrix
}
/// cbindgen:derive-eq=false /// cbindgen:derive-eq=false
#[repr(C)] #[repr(C)]
#[derive(Debug)] #[derive(Debug)]
@ -1912,7 +1884,7 @@ pub extern "C" fn wr_dp_push_stacking_context(state: &mut WrState,
transform_style: TransformStyle, transform_style: TransformStyle,
perspective: *const LayoutTransform, perspective: *const LayoutTransform,
mix_blend_mode: MixBlendMode, mix_blend_mode: MixBlendMode,
filters: *const WrFilterOp, filters: *const FilterOp,
filter_count: usize, filter_count: usize,
is_backface_visible: bool, is_backface_visible: bool,
glyph_raster_space: RasterSpace, glyph_raster_space: RasterSpace,
@ -1921,23 +1893,7 @@ pub extern "C" fn wr_dp_push_stacking_context(state: &mut WrState,
let c_filters = make_slice(filters, filter_count); let c_filters = make_slice(filters, filter_count);
let mut filters : Vec<FilterOp> = c_filters.iter().map(|c_filter| { let mut filters : Vec<FilterOp> = c_filters.iter().map(|c_filter| {
match c_filter.filter_type { *c_filter
WrFilterOpType::Blur => FilterOp::Blur(c_filter.argument),
WrFilterOpType::Brightness => FilterOp::Brightness(c_filter.argument),
WrFilterOpType::Contrast => FilterOp::Contrast(c_filter.argument),
WrFilterOpType::Grayscale => FilterOp::Grayscale(c_filter.argument),
WrFilterOpType::HueRotate => FilterOp::HueRotate(c_filter.argument),
WrFilterOpType::Invert => FilterOp::Invert(c_filter.argument),
WrFilterOpType::Opacity => FilterOp::Opacity(PropertyBinding::Value(c_filter.argument), c_filter.argument),
WrFilterOpType::Saturate => FilterOp::Saturate(c_filter.argument),
WrFilterOpType::Sepia => FilterOp::Sepia(c_filter.argument),
WrFilterOpType::DropShadow => FilterOp::DropShadow(c_filter.offset,
c_filter.argument,
c_filter.color),
WrFilterOpType::ColorMatrix => FilterOp::ColorMatrix(c_filter.matrix),
WrFilterOpType::SrgbToLinear => FilterOp::SrgbToLinear,
WrFilterOpType::LinearToSrgb => FilterOp::LinearToSrgb,
}
}).collect(); }).collect();
let clip_node_id_ref = unsafe { clip_node_id.as_ref() }; let clip_node_id_ref = unsafe { clip_node_id.as_ref() };

Просмотреть файл

@ -244,24 +244,6 @@ enum class WrExternalImageType : uint32_t {
Sentinel /* this must be last for serialization purposes. */ Sentinel /* this must be last for serialization purposes. */
}; };
enum class WrFilterOpType : uint32_t {
Blur = 0,
Brightness = 1,
Contrast = 2,
Grayscale = 3,
HueRotate = 4,
Invert = 5,
Opacity = 6,
Saturate = 7,
Sepia = 8,
DropShadow = 9,
ColorMatrix = 10,
SrgbToLinear = 11,
LinearToSrgb = 12,
Sentinel /* this must be last for serialization purposes. */
};
enum class YuvColorSpace : uint32_t { enum class YuvColorSpace : uint32_t {
Rec601 = 0, Rec601 = 0,
Rec709 = 1, Rec709 = 1,
@ -917,12 +899,385 @@ struct TypedTransform3D {
using LayoutTransform = TypedTransform3D<float, LayoutPixel, LayoutPixel>; using LayoutTransform = TypedTransform3D<float, LayoutPixel, LayoutPixel>;
struct WrFilterOp { struct PropertyBindingId {
WrFilterOpType filter_type; IdNamespace namespace_;
float argument; uint32_t uid;
LayoutVector2D offset;
ColorF color; bool operator==(const PropertyBindingId& aOther) const {
float matrix[20]; return namespace_ == aOther.namespace_ &&
uid == aOther.uid;
}
};
/// A unique key that is used for connecting animated property
/// values to bindings in the display list.
template<typename T>
struct PropertyBindingKey {
PropertyBindingId id;
bool operator==(const PropertyBindingKey& aOther) const {
return id == aOther.id;
}
};
/// A binding property can either be a specific value
/// (the normal, non-animated case) or point to a binding location
/// to fetch the current value from.
/// Note that Binding has also a non-animated value, the value is
/// used for the case where the animation is still in-delay phase
/// (i.e. the animation doesn't produce any animation values).
template<typename T>
struct PropertyBinding {
enum class Tag {
Value,
Binding,
Sentinel /* this must be last for serialization purposes. */
};
struct Value_Body {
T _0;
bool operator==(const Value_Body& aOther) const {
return _0 == aOther._0;
}
};
struct Binding_Body {
PropertyBindingKey<T> _0;
T _1;
bool operator==(const Binding_Body& aOther) const {
return _0 == aOther._0 &&
_1 == aOther._1;
}
};
Tag tag;
union {
Value_Body value;
Binding_Body binding;
};
static PropertyBinding Value(const T &a0) {
PropertyBinding result;
result.value._0 = a0;
result.tag = Tag::Value;
return result;
}
static PropertyBinding Binding(const PropertyBindingKey<T> &a0,
const T &a1) {
PropertyBinding result;
result.binding._0 = a0;
result.binding._1 = a1;
result.tag = Tag::Binding;
return result;
}
bool IsValue() const {
return tag == Tag::Value;
}
bool IsBinding() const {
return tag == Tag::Binding;
}
bool operator==(const PropertyBinding& aOther) const {
if (tag != aOther.tag) {
return false;
}
switch (tag) {
case Tag::Value: return value == aOther.value;
case Tag::Binding: return binding == aOther.binding;
default: return true;
}
}
};
struct FilterOp {
enum class Tag {
/// Filter that does no transformation of the colors, needed for
/// debug purposes only.
Identity,
Blur,
Brightness,
Contrast,
Grayscale,
HueRotate,
Invert,
Opacity,
Saturate,
Sepia,
DropShadow,
ColorMatrix,
SrgbToLinear,
LinearToSrgb,
Sentinel /* this must be last for serialization purposes. */
};
struct Blur_Body {
float _0;
bool operator==(const Blur_Body& aOther) const {
return _0 == aOther._0;
}
};
struct Brightness_Body {
float _0;
bool operator==(const Brightness_Body& aOther) const {
return _0 == aOther._0;
}
};
struct Contrast_Body {
float _0;
bool operator==(const Contrast_Body& aOther) const {
return _0 == aOther._0;
}
};
struct Grayscale_Body {
float _0;
bool operator==(const Grayscale_Body& aOther) const {
return _0 == aOther._0;
}
};
struct HueRotate_Body {
float _0;
bool operator==(const HueRotate_Body& aOther) const {
return _0 == aOther._0;
}
};
struct Invert_Body {
float _0;
bool operator==(const Invert_Body& aOther) const {
return _0 == aOther._0;
}
};
struct Opacity_Body {
PropertyBinding<float> _0;
float _1;
bool operator==(const Opacity_Body& aOther) const {
return _0 == aOther._0 &&
_1 == aOther._1;
}
};
struct Saturate_Body {
float _0;
bool operator==(const Saturate_Body& aOther) const {
return _0 == aOther._0;
}
};
struct Sepia_Body {
float _0;
bool operator==(const Sepia_Body& aOther) const {
return _0 == aOther._0;
}
};
struct DropShadow_Body {
LayoutVector2D _0;
float _1;
ColorF _2;
bool operator==(const DropShadow_Body& aOther) const {
return _0 == aOther._0 &&
_1 == aOther._1 &&
_2 == aOther._2;
}
};
struct ColorMatrix_Body {
float _0[20];
};
Tag tag;
union {
Blur_Body blur;
Brightness_Body brightness;
Contrast_Body contrast;
Grayscale_Body grayscale;
HueRotate_Body hue_rotate;
Invert_Body invert;
Opacity_Body opacity;
Saturate_Body saturate;
Sepia_Body sepia;
DropShadow_Body drop_shadow;
ColorMatrix_Body color_matrix;
};
static FilterOp Identity() {
FilterOp result;
result.tag = Tag::Identity;
return result;
}
static FilterOp Blur(const float &a0) {
FilterOp result;
result.blur._0 = a0;
result.tag = Tag::Blur;
return result;
}
static FilterOp Brightness(const float &a0) {
FilterOp result;
result.brightness._0 = a0;
result.tag = Tag::Brightness;
return result;
}
static FilterOp Contrast(const float &a0) {
FilterOp result;
result.contrast._0 = a0;
result.tag = Tag::Contrast;
return result;
}
static FilterOp Grayscale(const float &a0) {
FilterOp result;
result.grayscale._0 = a0;
result.tag = Tag::Grayscale;
return result;
}
static FilterOp HueRotate(const float &a0) {
FilterOp result;
result.hue_rotate._0 = a0;
result.tag = Tag::HueRotate;
return result;
}
static FilterOp Invert(const float &a0) {
FilterOp result;
result.invert._0 = a0;
result.tag = Tag::Invert;
return result;
}
static FilterOp Opacity(const PropertyBinding<float> &a0,
const float &a1) {
FilterOp result;
result.opacity._0 = a0;
result.opacity._1 = a1;
result.tag = Tag::Opacity;
return result;
}
static FilterOp Saturate(const float &a0) {
FilterOp result;
result.saturate._0 = a0;
result.tag = Tag::Saturate;
return result;
}
static FilterOp Sepia(const float &a0) {
FilterOp result;
result.sepia._0 = a0;
result.tag = Tag::Sepia;
return result;
}
static FilterOp DropShadow(const LayoutVector2D &a0,
const float &a1,
const ColorF &a2) {
FilterOp result;
result.drop_shadow._0 = a0;
result.drop_shadow._1 = a1;
result.drop_shadow._2 = a2;
result.tag = Tag::DropShadow;
return result;
}
static FilterOp ColorMatrix(const float (&a0)[20]) {
FilterOp result;
for (int i = 0; i < 20; i++) {result.color_matrix._0[i] = a0[i];}
result.tag = Tag::ColorMatrix;
return result;
}
static FilterOp SrgbToLinear() {
FilterOp result;
result.tag = Tag::SrgbToLinear;
return result;
}
static FilterOp LinearToSrgb() {
FilterOp result;
result.tag = Tag::LinearToSrgb;
return result;
}
bool IsIdentity() const {
return tag == Tag::Identity;
}
bool IsBlur() const {
return tag == Tag::Blur;
}
bool IsBrightness() const {
return tag == Tag::Brightness;
}
bool IsContrast() const {
return tag == Tag::Contrast;
}
bool IsGrayscale() const {
return tag == Tag::Grayscale;
}
bool IsHueRotate() const {
return tag == Tag::HueRotate;
}
bool IsInvert() const {
return tag == Tag::Invert;
}
bool IsOpacity() const {
return tag == Tag::Opacity;
}
bool IsSaturate() const {
return tag == Tag::Saturate;
}
bool IsSepia() const {
return tag == Tag::Sepia;
}
bool IsDropShadow() const {
return tag == Tag::DropShadow;
}
bool IsColorMatrix() const {
return tag == Tag::ColorMatrix;
}
bool IsSrgbToLinear() const {
return tag == Tag::SrgbToLinear;
}
bool IsLinearToSrgb() const {
return tag == Tag::LinearToSrgb;
}
}; };
/// Configure whether the contents of a stacking context /// Configure whether the contents of a stacking context
@ -1589,7 +1944,7 @@ WrSpatialId wr_dp_push_stacking_context(WrState *aState,
TransformStyle aTransformStyle, TransformStyle aTransformStyle,
const LayoutTransform *aPerspective, const LayoutTransform *aPerspective,
MixBlendMode aMixBlendMode, MixBlendMode aMixBlendMode,
const WrFilterOp *aFilters, const FilterOp *aFilters,
uintptr_t aFilterCount, uintptr_t aFilterCount,
bool aIsBackfaceVisible, bool aIsBackfaceVisible,
RasterSpace aGlyphRasterSpace) RasterSpace aGlyphRasterSpace)

Просмотреть файл

@ -6045,7 +6045,7 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor); bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor);
WebRenderBackgroundData data(wr::ToLayoutRect(bounds), WebRenderBackgroundData data(wr::ToLayoutRect(bounds),
wr::ToColorF(ToDeviceColor(bgcolor))); wr::ToColorF(ToDeviceColor(bgcolor)));
nsTArray<wr::WrFilterOp> wrFilters; nsTArray<wr::FilterOp> wrFilters;
MaybeSetupTransactionIdAllocator(layerManager, presContext); MaybeSetupTransactionIdAllocator(layerManager, presContext);
layerManager->AsWebRenderLayerManager()->EndTransactionWithoutLayer( layerManager->AsWebRenderLayerManager()->EndTransactionWithoutLayer(

Просмотреть файл

@ -2616,14 +2616,12 @@ already_AddRefed<LayerManager> nsDisplayList::PaintRoot(
auto* wrManager = static_cast<WebRenderLayerManager*>(layerManager.get()); auto* wrManager = static_cast<WebRenderLayerManager*>(layerManager.get());
nsIDocShell* docShell = presContext->GetDocShell(); nsIDocShell* docShell = presContext->GetDocShell();
nsTArray<wr::WrFilterOp> wrFilters; nsTArray<wr::FilterOp> wrFilters;
gfx::Matrix5x4* colorMatrix = gfx::Matrix5x4* colorMatrix =
nsDocShell::Cast(docShell)->GetColorMatrix(); nsDocShell::Cast(docShell)->GetColorMatrix();
if (colorMatrix) { if (colorMatrix) {
wr::WrFilterOp gs = {wr::WrFilterOpType::ColorMatrix}; wrFilters.AppendElement(
MOZ_ASSERT(sizeof(gs.matrix) == sizeof(colorMatrix->components)); wr::FilterOp::ColorMatrix(colorMatrix->components));
memcpy(&(gs.matrix), colorMatrix->components, sizeof(gs.matrix));
wrFilters.AppendElement(gs);
} }
wrManager->EndTransactionWithoutLayer(this, aBuilder, wrFilters); wrManager->EndTransactionWithoutLayer(this, aBuilder, wrFilters);
@ -6070,7 +6068,7 @@ bool nsDisplayOpacity::CreateWebRenderCommands(
animationsId, animationsId,
}; };
nsTArray<mozilla::wr::WrFilterOp> filters; nsTArray<mozilla::wr::FilterOp> filters;
StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder, StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder,
filters, LayoutDeviceRect(), nullptr, filters, LayoutDeviceRect(), nullptr,
animationsId ? &prop : nullptr, opacityForSC); animationsId ? &prop : nullptr, opacityForSC);
@ -6109,7 +6107,7 @@ bool nsDisplayBlendMode::CreateWebRenderCommands(
const StackingContextHelper& aSc, const StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager, mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) { nsDisplayListBuilder* aDisplayListBuilder) {
nsTArray<mozilla::wr::WrFilterOp> filters; nsTArray<mozilla::wr::FilterOp> filters;
StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder, StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder,
filters, LayoutDeviceRect(), nullptr, nullptr, filters, LayoutDeviceRect(), nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
@ -6341,7 +6339,7 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands(
prop.effect_type = wr::WrAnimationType::Transform; prop.effect_type = wr::WrAnimationType::Transform;
StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder, StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder,
nsTArray<wr::WrFilterOp>(), LayoutDeviceRect(), nsTArray<wr::FilterOp>(), LayoutDeviceRect(),
nullptr, &prop); nullptr, &prop);
nsDisplayWrapList::CreateWebRenderCommands(aBuilder, aResources, sc, aManager, nsDisplayWrapList::CreateWebRenderCommands(aBuilder, aResources, sc, aManager,
@ -7858,7 +7856,7 @@ bool nsDisplayTransform::CreateWebRenderCommands(
animationsId, animationsId,
}; };
nsTArray<mozilla::wr::WrFilterOp> filters; nsTArray<mozilla::wr::FilterOp> filters;
Maybe<nsDisplayTransform*> deferredTransformItem; Maybe<nsDisplayTransform*> deferredTransformItem;
if (!mFrame->ChildrenHavePerspective()) { if (!mFrame->ChildrenHavePerspective()) {
// If it has perspective, we create a new scroll data via the // If it has perspective, we create a new scroll data via the
@ -8465,7 +8463,7 @@ bool nsDisplayPerspective::CreateWebRenderCommands(
nsIFrame* perspectiveFrame = nsIFrame* perspectiveFrame =
mFrame->GetContainingBlock(nsIFrame::SKIP_SCROLLED_FRAME); mFrame->GetContainingBlock(nsIFrame::SKIP_SCROLLED_FRAME);
nsTArray<mozilla::wr::WrFilterOp> filters; nsTArray<mozilla::wr::FilterOp> filters;
StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder, StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder,
filters, LayoutDeviceRect(), nullptr, nullptr, filters, LayoutDeviceRect(), nullptr, nullptr,
nullptr, &transformForSC, &perspectiveMatrix, nullptr, &transformForSC, &perspectiveMatrix,
@ -9062,7 +9060,7 @@ bool nsDisplayMasksAndClipPaths::CreateWebRenderCommands(
: Nothing(); : Nothing();
layer.emplace(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder, layer.emplace(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder,
/*aFilters: */ nsTArray<wr::WrFilterOp>(), /*aFilters: */ nsTArray<wr::FilterOp>(),
/*aBounds: */ bounds, /*aBounds: */ bounds,
/*aBoundTransform: */ nullptr, /*aBoundTransform: */ nullptr,
/*aAnimation: */ nullptr, /*aAnimation: */ nullptr,
@ -9241,44 +9239,54 @@ static float ClampStdDeviation(float aStdDeviation) {
} }
bool nsDisplayFilters::CreateWebRenderCSSFilters( bool nsDisplayFilters::CreateWebRenderCSSFilters(
nsTArray<mozilla::wr::WrFilterOp>& wrFilters) { nsTArray<mozilla::wr::FilterOp>& wrFilters) {
// All CSS filters are supported by WebRender. SVG filters are not fully // All CSS filters are supported by WebRender. SVG filters are not fully
// supported, those use NS_STYLE_FILTER_URL and are handled separately. // supported, those use NS_STYLE_FILTER_URL and are handled separately.
const nsTArray<nsStyleFilter>& filters = mFrame->StyleEffects()->mFilters; const nsTArray<nsStyleFilter>& filters = mFrame->StyleEffects()->mFilters;
for (const nsStyleFilter& filter : filters) { for (const nsStyleFilter& filter : filters) {
switch (filter.GetType()) { switch (filter.GetType()) {
case NS_STYLE_FILTER_BRIGHTNESS: case NS_STYLE_FILTER_BRIGHTNESS:
wrFilters.AppendElement(wr::FilterOp::Brightness(
filter.GetFilterParameter().GetFactorOrPercentValue()));
break;
case NS_STYLE_FILTER_CONTRAST: case NS_STYLE_FILTER_CONTRAST:
wrFilters.AppendElement(wr::FilterOp::Contrast(
filter.GetFilterParameter().GetFactorOrPercentValue()));
break;
case NS_STYLE_FILTER_GRAYSCALE: case NS_STYLE_FILTER_GRAYSCALE:
wrFilters.AppendElement(wr::FilterOp::Grayscale(
filter.GetFilterParameter().GetFactorOrPercentValue()));
break;
case NS_STYLE_FILTER_INVERT: case NS_STYLE_FILTER_INVERT:
case NS_STYLE_FILTER_OPACITY: wrFilters.AppendElement(wr::FilterOp::Invert(
filter.GetFilterParameter().GetFactorOrPercentValue()));
break;
case NS_STYLE_FILTER_OPACITY: {
float opacity = filter.GetFilterParameter().GetFactorOrPercentValue();
wrFilters.AppendElement(wr::FilterOp::Opacity(
wr::PropertyBinding<float>::Value(opacity), opacity));
break;
}
case NS_STYLE_FILTER_SATURATE: case NS_STYLE_FILTER_SATURATE:
wrFilters.AppendElement(wr::FilterOp::Saturate(
filter.GetFilterParameter().GetFactorOrPercentValue()));
break;
case NS_STYLE_FILTER_SEPIA: { case NS_STYLE_FILTER_SEPIA: {
mozilla::wr::WrFilterOp filterOp = { wrFilters.AppendElement(wr::FilterOp::Sepia(
wr::ToWrFilterOpType(filter.GetType()), filter.GetFilterParameter().GetFactorOrPercentValue()));
filter.GetFilterParameter().GetFactorOrPercentValue(),
};
wrFilters.AppendElement(filterOp);
break; break;
} }
case NS_STYLE_FILTER_HUE_ROTATE: { case NS_STYLE_FILTER_HUE_ROTATE: {
mozilla::wr::WrFilterOp filterOp = { wrFilters.AppendElement(wr::FilterOp::HueRotate(
wr::ToWrFilterOpType(filter.GetType()), (float)filter.GetFilterParameter().GetAngleValueInDegrees()));
(float)filter.GetFilterParameter().GetAngleValueInDegrees(),
};
wrFilters.AppendElement(filterOp);
break; break;
} }
case NS_STYLE_FILTER_BLUR: { case NS_STYLE_FILTER_BLUR: {
float appUnitsPerDevPixel = float appUnitsPerDevPixel =
mFrame->PresContext()->AppUnitsPerDevPixel(); mFrame->PresContext()->AppUnitsPerDevPixel();
mozilla::wr::WrFilterOp filterOp = { wrFilters.AppendElement(mozilla::wr::FilterOp::Blur(ClampStdDeviation(
wr::ToWrFilterOpType(filter.GetType()), NSAppUnitsToFloatPixels(filter.GetFilterParameter().GetCoordValue(),
ClampStdDeviation(NSAppUnitsToFloatPixels( appUnitsPerDevPixel))));
filter.GetFilterParameter().GetCoordValue(),
appUnitsPerDevPixel)),
};
wrFilters.AppendElement(filterOp);
break; break;
} }
case NS_STYLE_FILTER_DROP_SHADOW: { case NS_STYLE_FILTER_DROP_SHADOW: {
@ -9295,19 +9303,18 @@ bool nsDisplayFilters::CreateWebRenderCSSFilters(
nsCSSShadowItem* shadow = shadows->ShadowAt(0); nsCSSShadowItem* shadow = shadows->ShadowAt(0);
nscolor color = shadow->mColor.CalcColor(mFrame); nscolor color = shadow->mColor.CalcColor(mFrame);
mozilla::wr::WrFilterOp filterOp = { auto filterOp = wr::FilterOp::DropShadow(
wr::ToWrFilterOpType(filter.GetType()),
NSAppUnitsToFloatPixels(shadow->mRadius, appUnitsPerDevPixel),
{ {
NSAppUnitsToFloatPixels(shadow->mXOffset, appUnitsPerDevPixel), NSAppUnitsToFloatPixels(shadow->mXOffset, appUnitsPerDevPixel),
NSAppUnitsToFloatPixels(shadow->mYOffset, appUnitsPerDevPixel), NSAppUnitsToFloatPixels(shadow->mYOffset, appUnitsPerDevPixel),
}, },
NSAppUnitsToFloatPixels(shadow->mRadius, appUnitsPerDevPixel),
{ {
NS_GET_R(color) / 255.0f, NS_GET_R(color) / 255.0f,
NS_GET_G(color) / 255.0f, NS_GET_G(color) / 255.0f,
NS_GET_B(color) / 255.0f, NS_GET_B(color) / 255.0f,
NS_GET_A(color) / 255.0f, NS_GET_A(color) / 255.0f,
}}; });
wrFilters.AppendElement(filterOp); wrFilters.AppendElement(filterOp);
break; break;
@ -9334,7 +9341,7 @@ bool nsDisplayFilters::CreateWebRenderCommands(
auto preFilterBounds = LayoutDeviceIntRect::Round( auto preFilterBounds = LayoutDeviceIntRect::Round(
LayoutDeviceRect::FromAppUnits(mBounds, auPerDevPixel)); LayoutDeviceRect::FromAppUnits(mBounds, auPerDevPixel));
nsTArray<mozilla::wr::WrFilterOp> wrFilters; nsTArray<mozilla::wr::FilterOp> wrFilters;
if (!CreateWebRenderCSSFilters(wrFilters) && if (!CreateWebRenderCSSFilters(wrFilters) &&
!nsSVGIntegrationUtils::BuildWebRenderFilters( !nsSVGIntegrationUtils::BuildWebRenderFilters(
mFrame, preFilterBounds, wrFilters, postFilterBounds)) { mFrame, preFilterBounds, wrFilters, postFilterBounds)) {

Просмотреть файл

@ -6352,7 +6352,7 @@ class nsDisplayFilters : public nsDisplayEffectsBase {
mozilla::layers::RenderRootStateManager* aManager, mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) override; nsDisplayListBuilder* aDisplayListBuilder) override;
bool CreateWebRenderCSSFilters(nsTArray<mozilla::wr::WrFilterOp>& wrFilters); bool CreateWebRenderCSSFilters(nsTArray<mozilla::wr::FilterOp>& wrFilters);
private: private:
// relative to mFrame // relative to mFrame

Просмотреть файл

@ -95,7 +95,7 @@ void nsFilterInstance::PaintFilteredFrame(
bool nsFilterInstance::BuildWebRenderFilters( bool nsFilterInstance::BuildWebRenderFilters(
nsIFrame* aFilteredFrame, const LayoutDeviceIntRect& aPreFilterBounds, nsIFrame* aFilteredFrame, const LayoutDeviceIntRect& aPreFilterBounds,
nsTArray<wr::WrFilterOp>& aWrFilters, nsTArray<wr::FilterOp>& aWrFilters,
LayoutDeviceIntRect& aPostFilterBounds) { LayoutDeviceIntRect& aPostFilterBounds) {
aWrFilters.Clear(); aWrFilters.Clear();
@ -145,12 +145,10 @@ bool nsFilterInstance::BuildWebRenderFilters(
bool primIsSrgb = primitive.OutputColorSpace() == gfx::ColorSpace::SRGB; bool primIsSrgb = primitive.OutputColorSpace() == gfx::ColorSpace::SRGB;
if (srgb && !primIsSrgb) { if (srgb && !primIsSrgb) {
wr::WrFilterOp filterOp = {wr::WrFilterOpType::SrgbToLinear}; aWrFilters.AppendElement(wr::FilterOp::SrgbToLinear());
aWrFilters.AppendElement(filterOp);
srgb = false; srgb = false;
} else if (!srgb && primIsSrgb) { } else if (!srgb && primIsSrgb) {
wr::WrFilterOp filterOp = {wr::WrFilterOpType::LinearToSrgb}; aWrFilters.AppendElement(wr::FilterOp::LinearToSrgb());
aWrFilters.AppendElement(filterOp);
srgb = true; srgb = true;
} }
@ -180,8 +178,8 @@ bool nsFilterInstance::BuildWebRenderFilters(
if (attr.is<OpacityAttributes>()) { if (attr.is<OpacityAttributes>()) {
float opacity = attr.as<OpacityAttributes>().mOpacity; float opacity = attr.as<OpacityAttributes>().mOpacity;
wr::WrFilterOp filterOp = {wr::WrFilterOpType::Opacity, opacity}; aWrFilters.AppendElement(wr::FilterOp::Opacity(
aWrFilters.AppendElement(filterOp); wr::PropertyBinding<float>::Value(opacity), opacity));
} else if (attr.is<ColorMatrixAttributes>()) { } else if (attr.is<ColorMatrixAttributes>()) {
const ColorMatrixAttributes& attributes = const ColorMatrixAttributes& attributes =
attr.as<ColorMatrixAttributes>(); attr.as<ColorMatrixAttributes>();
@ -213,9 +211,7 @@ bool nsFilterInstance::BuildWebRenderFilters(
transposed[3], transposed[8], transposed[13], transposed[18], transposed[3], transposed[8], transposed[13], transposed[18],
transposed[4], transposed[9], transposed[14], transposed[19]}; transposed[4], transposed[9], transposed[14], transposed[19]};
wr::WrFilterOp filterOp = {wr::WrFilterOpType::ColorMatrix}; aWrFilters.AppendElement(wr::FilterOp::ColorMatrix(matrix));
PodCopy(filterOp.matrix, matrix, 20);
aWrFilters.AppendElement(filterOp);
} else if (attr.is<GaussianBlurAttributes>()) { } else if (attr.is<GaussianBlurAttributes>()) {
if (chainIsAffectedByPrimSubregion) { if (chainIsAffectedByPrimSubregion) {
// There's a clip that needs to apply before the blur filter, but // There's a clip that needs to apply before the blur filter, but
@ -234,8 +230,7 @@ bool nsFilterInstance::BuildWebRenderFilters(
float radius = stdDev.width; float radius = stdDev.width;
if (radius != 0.0) { if (radius != 0.0) {
wr::WrFilterOp filterOp = {wr::WrFilterOpType::Blur, radius}; aWrFilters.AppendElement(wr::FilterOp::Blur(radius));
aWrFilters.AppendElement(filterOp);
} else { } else {
filterIsNoop = true; filterIsNoop = true;
} }
@ -252,12 +247,11 @@ bool nsFilterInstance::BuildWebRenderFilters(
return false; return false;
} }
wr::LayoutVector2D offset = {(float)shadow.mOffset.x,
(float)shadow.mOffset.y};
float radius = stdDev.width; float radius = stdDev.width;
wr::WrFilterOp filterOp = { wr::FilterOp filterOp =
wr::WrFilterOpType::DropShadow, wr::FilterOp::DropShadow(offset, radius, wr::ToColorF(shadow.mColor));
radius,
{(float)shadow.mOffset.x, (float)shadow.mOffset.y},
wr::ToColorF(shadow.mColor)};
aWrFilters.AppendElement(filterOp); aWrFilters.AppendElement(filterOp);
} else { } else {
@ -265,10 +259,8 @@ bool nsFilterInstance::BuildWebRenderFilters(
} }
if (filterIsNoop && aWrFilters.Length() > 0 && if (filterIsNoop && aWrFilters.Length() > 0 &&
(aWrFilters.LastElement().filter_type == (aWrFilters.LastElement().tag == wr::FilterOp::Tag::SrgbToLinear ||
wr::WrFilterOpType::SrgbToLinear || aWrFilters.LastElement().tag == wr::FilterOp::Tag::LinearToSrgb)) {
aWrFilters.LastElement().filter_type ==
wr::WrFilterOpType::LinearToSrgb)) {
// We pushed a color space conversion filter in prevision of applying // We pushed a color space conversion filter in prevision of applying
// another filter which turned out to be a no-op, so the conversion is // another filter which turned out to be a no-op, so the conversion is
// unnecessary. Remove it from the filter list. // unnecessary. Remove it from the filter list.
@ -282,8 +274,7 @@ bool nsFilterInstance::BuildWebRenderFilters(
} }
if (!srgb) { if (!srgb) {
wr::WrFilterOp filterOp = {wr::WrFilterOpType::LinearToSrgb}; aWrFilters.AppendElement(wr::FilterOp::LinearToSrgb());
aWrFilters.AppendElement(filterOp);
} }
// Only adjust the post filter clip if we are able to render this without // Only adjust the post filter clip if we are able to render this without

Просмотреть файл

@ -125,7 +125,7 @@ class nsFilterInstance {
static bool BuildWebRenderFilters( static bool BuildWebRenderFilters(
nsIFrame* aFilteredFrame, nsIFrame* aFilteredFrame,
const mozilla::LayoutDeviceIntRect& aPreFilterBounds, const mozilla::LayoutDeviceIntRect& aPreFilterBounds,
nsTArray<mozilla::wr::WrFilterOp>& aWrFilters, nsTArray<mozilla::wr::FilterOp>& aWrFilters,
mozilla::LayoutDeviceIntRect& aPostFilterBounds); mozilla::LayoutDeviceIntRect& aPostFilterBounds);
private: private:

Просмотреть файл

@ -1096,7 +1096,7 @@ void nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) {
bool nsSVGIntegrationUtils::BuildWebRenderFilters( bool nsSVGIntegrationUtils::BuildWebRenderFilters(
nsIFrame* aFilteredFrame, nsIFrame* aFilteredFrame,
const mozilla::LayoutDeviceIntRect& aPreFilterBounds, const mozilla::LayoutDeviceIntRect& aPreFilterBounds,
nsTArray<mozilla::wr::WrFilterOp>& aWrFilters, nsTArray<mozilla::wr::FilterOp>& aWrFilters,
mozilla::LayoutDeviceIntRect& aPostFilterBounds) { mozilla::LayoutDeviceIntRect& aPostFilterBounds) {
return nsFilterInstance::BuildWebRenderFilters( return nsFilterInstance::BuildWebRenderFilters(
aFilteredFrame, aPreFilterBounds, aWrFilters, aPostFilterBounds); aFilteredFrame, aPreFilterBounds, aWrFilters, aPostFilterBounds);

Просмотреть файл

@ -198,7 +198,7 @@ class nsSVGIntegrationUtils final {
static bool BuildWebRenderFilters( static bool BuildWebRenderFilters(
nsIFrame* aFilteredFrame, nsIFrame* aFilteredFrame,
const mozilla::LayoutDeviceIntRect& aPreFilterBounds, const mozilla::LayoutDeviceIntRect& aPreFilterBounds,
nsTArray<mozilla::wr::WrFilterOp>& aWrFilters, nsTArray<mozilla::wr::FilterOp>& aWrFilters,
mozilla::LayoutDeviceIntRect& aPostFilterBounds); mozilla::LayoutDeviceIntRect& aPostFilterBounds);
/** /**