mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00
Bug 1653193 - Hide complex template instance PrimitiveAttributes. r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D83751
This commit is contained in:
parent
82ca67dee0
commit
75e36d4ce3
@ -21,7 +21,7 @@
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/SVGObserverUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "FilterSupport.h"
|
||||
#include "FilterDescription.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "Layers.h"
|
||||
#include "nsICanvasRenderingContextInternal.h"
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/SVGElement.h"
|
||||
#include "FilterSupport.h"
|
||||
#include "FilterDescription.h"
|
||||
#include "nsImageLoadingContent.h"
|
||||
#include "SVGAnimatedLength.h"
|
||||
#include "SVGAnimatedNumber.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "FilterSupport.h"
|
||||
#include "ImageTypes.h"
|
||||
#include "RegionBuilder.h"
|
||||
#include "base/process_util.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#include "gfxFeature.h"
|
||||
#include "gfxFallback.h"
|
||||
@ -18,13 +17,11 @@
|
||||
#include "gfxRect.h"
|
||||
#include "gfxTelemetry.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/gfx/CrossProcessPaint.h"
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsRegion.h"
|
||||
#include "mozilla/Array.h"
|
||||
#include "mozilla/layers/VideoBridgeUtils.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/ipc/Shmem.h"
|
||||
|
||||
@ -1143,72 +1140,6 @@ struct ParamTraits<mozilla::gfx::CompositeAttributes> {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::gfx::FilterPrimitiveDescription> {
|
||||
typedef mozilla::gfx::FilterPrimitiveDescription paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
WriteParam(aMsg, aParam.PrimitiveSubregion());
|
||||
WriteParam(aMsg, aParam.FilterSpaceBounds());
|
||||
WriteParam(aMsg, aParam.IsTainted());
|
||||
WriteParam(aMsg, aParam.OutputColorSpace());
|
||||
WriteParam(aMsg, aParam.NumberOfInputs());
|
||||
for (size_t i = 0; i < aParam.NumberOfInputs(); i++) {
|
||||
WriteParam(aMsg, aParam.InputPrimitiveIndex(i));
|
||||
WriteParam(aMsg, aParam.InputColorSpace(i));
|
||||
}
|
||||
WriteParam(aMsg, aParam.Attributes());
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
||||
paramType* aResult) {
|
||||
mozilla::gfx::IntRect primitiveSubregion;
|
||||
mozilla::gfx::IntRect filterSpaceBounds;
|
||||
bool isTainted = false;
|
||||
mozilla::gfx::ColorSpace outputColorSpace;
|
||||
size_t numberOfInputs = 0;
|
||||
if (!ReadParam(aMsg, aIter, &primitiveSubregion) ||
|
||||
!ReadParam(aMsg, aIter, &filterSpaceBounds) ||
|
||||
!ReadParam(aMsg, aIter, &isTainted) ||
|
||||
!ReadParam(aMsg, aIter, &outputColorSpace) ||
|
||||
!ReadParam(aMsg, aIter, &numberOfInputs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aResult->SetPrimitiveSubregion(primitiveSubregion);
|
||||
aResult->SetFilterSpaceBounds(filterSpaceBounds);
|
||||
aResult->SetIsTainted(isTainted);
|
||||
aResult->SetOutputColorSpace(outputColorSpace);
|
||||
|
||||
for (size_t i = 0; i < numberOfInputs; i++) {
|
||||
int32_t inputPrimitiveIndex = 0;
|
||||
mozilla::gfx::ColorSpace inputColorSpace;
|
||||
if (!ReadParam(aMsg, aIter, &inputPrimitiveIndex) ||
|
||||
!ReadParam(aMsg, aIter, &inputColorSpace)) {
|
||||
return false;
|
||||
}
|
||||
aResult->SetInputPrimitive(i, inputPrimitiveIndex);
|
||||
aResult->SetInputColorSpace(i, inputColorSpace);
|
||||
}
|
||||
|
||||
return ReadParam(aMsg, aIter, &aResult->Attributes());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::gfx::FilterDescription> {
|
||||
typedef mozilla::gfx::FilterDescription paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
WriteParam(aMsg, aParam.mPrimitives);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
||||
paramType* aResult) {
|
||||
return (ReadParam(aMsg, aIter, &aResult->mPrimitives));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::gfx::Glyph> {
|
||||
typedef mozilla::gfx::Glyph paramType;
|
||||
|
144
gfx/src/FilterDescription.h
Normal file
144
gfx/src/FilterDescription.h
Normal file
@ -0,0 +1,144 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef __FilterDescription_h
|
||||
#define __FilterDescription_h
|
||||
|
||||
#include "FilterSupport.h"
|
||||
#include "mozilla/Variant.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla::gfx {
|
||||
class FilterPrimitiveDescription;
|
||||
}
|
||||
|
||||
MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR(
|
||||
mozilla::gfx::FilterPrimitiveDescription)
|
||||
|
||||
namespace mozilla::gfx {
|
||||
typedef Variant<
|
||||
EmptyAttributes, BlendAttributes, MorphologyAttributes,
|
||||
ColorMatrixAttributes, FloodAttributes, TileAttributes,
|
||||
ComponentTransferAttributes, OpacityAttributes, ConvolveMatrixAttributes,
|
||||
OffsetAttributes, DisplacementMapAttributes, TurbulenceAttributes,
|
||||
CompositeAttributes, MergeAttributes, ImageAttributes,
|
||||
GaussianBlurAttributes, DropShadowAttributes, DiffuseLightingAttributes,
|
||||
SpecularLightingAttributes, ToAlphaAttributes>
|
||||
PrimitiveAttributes;
|
||||
|
||||
/**
|
||||
* A data structure to carry attributes for a given primitive that's part of a
|
||||
* filter. Will be serializable via IPDL, so it must not contain complex
|
||||
* functionality.
|
||||
* Used as part of a FilterDescription.
|
||||
*/
|
||||
class FilterPrimitiveDescription final {
|
||||
public:
|
||||
enum {
|
||||
kPrimitiveIndexSourceGraphic = -1,
|
||||
kPrimitiveIndexSourceAlpha = -2,
|
||||
kPrimitiveIndexFillPaint = -3,
|
||||
kPrimitiveIndexStrokePaint = -4
|
||||
};
|
||||
|
||||
FilterPrimitiveDescription();
|
||||
explicit FilterPrimitiveDescription(PrimitiveAttributes&& aAttributes);
|
||||
FilterPrimitiveDescription(FilterPrimitiveDescription&& aOther) = default;
|
||||
FilterPrimitiveDescription& operator=(FilterPrimitiveDescription&& aOther) =
|
||||
default;
|
||||
FilterPrimitiveDescription(const FilterPrimitiveDescription& aOther)
|
||||
: mAttributes(aOther.mAttributes),
|
||||
mInputPrimitives(aOther.mInputPrimitives.Clone()),
|
||||
mFilterPrimitiveSubregion(aOther.mFilterPrimitiveSubregion),
|
||||
mFilterSpaceBounds(aOther.mFilterSpaceBounds),
|
||||
mInputColorSpaces(aOther.mInputColorSpaces.Clone()),
|
||||
mOutputColorSpace(aOther.mOutputColorSpace),
|
||||
mIsTainted(aOther.mIsTainted) {}
|
||||
|
||||
const PrimitiveAttributes& Attributes() const { return mAttributes; }
|
||||
PrimitiveAttributes& Attributes() { return mAttributes; }
|
||||
|
||||
IntRect PrimitiveSubregion() const { return mFilterPrimitiveSubregion; }
|
||||
IntRect FilterSpaceBounds() const { return mFilterSpaceBounds; }
|
||||
bool IsTainted() const { return mIsTainted; }
|
||||
|
||||
size_t NumberOfInputs() const { return mInputPrimitives.Length(); }
|
||||
int32_t InputPrimitiveIndex(size_t aInputIndex) const {
|
||||
return aInputIndex < mInputPrimitives.Length()
|
||||
? mInputPrimitives[aInputIndex]
|
||||
: 0;
|
||||
}
|
||||
|
||||
ColorSpace InputColorSpace(size_t aInputIndex) const {
|
||||
return aInputIndex < mInputColorSpaces.Length()
|
||||
? mInputColorSpaces[aInputIndex]
|
||||
: ColorSpace();
|
||||
}
|
||||
|
||||
ColorSpace OutputColorSpace() const { return mOutputColorSpace; }
|
||||
|
||||
void SetPrimitiveSubregion(const IntRect& aRect) {
|
||||
mFilterPrimitiveSubregion = aRect;
|
||||
}
|
||||
|
||||
void SetFilterSpaceBounds(const IntRect& aRect) {
|
||||
mFilterSpaceBounds = aRect;
|
||||
}
|
||||
|
||||
void SetIsTainted(bool aIsTainted) { mIsTainted = aIsTainted; }
|
||||
|
||||
void SetInputPrimitive(size_t aInputIndex, int32_t aInputPrimitiveIndex) {
|
||||
mInputPrimitives.EnsureLengthAtLeast(aInputIndex + 1);
|
||||
mInputPrimitives[aInputIndex] = aInputPrimitiveIndex;
|
||||
}
|
||||
|
||||
void SetInputColorSpace(size_t aInputIndex, ColorSpace aColorSpace) {
|
||||
mInputColorSpaces.EnsureLengthAtLeast(aInputIndex + 1);
|
||||
mInputColorSpaces[aInputIndex] = aColorSpace;
|
||||
}
|
||||
|
||||
void SetOutputColorSpace(const ColorSpace& aColorSpace) {
|
||||
mOutputColorSpace = aColorSpace;
|
||||
}
|
||||
|
||||
bool operator==(const FilterPrimitiveDescription& aOther) const;
|
||||
bool operator!=(const FilterPrimitiveDescription& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
|
||||
private:
|
||||
PrimitiveAttributes mAttributes;
|
||||
AutoTArray<int32_t, 2> mInputPrimitives;
|
||||
IntRect mFilterPrimitiveSubregion;
|
||||
IntRect mFilterSpaceBounds;
|
||||
AutoTArray<ColorSpace, 2> mInputColorSpaces;
|
||||
ColorSpace mOutputColorSpace;
|
||||
bool mIsTainted;
|
||||
};
|
||||
|
||||
/**
|
||||
* A data structure that contains one or more FilterPrimitiveDescriptions.
|
||||
* Designed to be serializable via IPDL, so it must not contain complex
|
||||
* functionality.
|
||||
*/
|
||||
struct FilterDescription final {
|
||||
FilterDescription() = default;
|
||||
explicit FilterDescription(
|
||||
nsTArray<FilterPrimitiveDescription>&& aPrimitives) {
|
||||
mPrimitives.SwapElements(aPrimitives);
|
||||
}
|
||||
|
||||
bool operator==(const FilterDescription& aOther) const;
|
||||
bool operator!=(const FilterDescription& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
|
||||
CopyableTArray<FilterPrimitiveDescription> mPrimitives;
|
||||
};
|
||||
} // namespace mozilla::gfx
|
||||
|
||||
#endif // __FilterSupport_h
|
@ -5,6 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "FilterSupport.h"
|
||||
#include "FilterDescription.h"
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Filters.h"
|
||||
|
@ -7,24 +7,18 @@
|
||||
#ifndef __FilterSupport_h
|
||||
#define __FilterSupport_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsRegion.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class FilterPrimitiveDescription;
|
||||
struct FilterDescription;
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR(
|
||||
mozilla::gfx::FilterPrimitiveDescription)
|
||||
|
||||
extern const float gsRGBToLinearRGBMap[256];
|
||||
|
||||
namespace mozilla {
|
||||
@ -357,16 +351,6 @@ struct DiffuseLightingAttributes {
|
||||
|
||||
struct SpecularLightingAttributes : public DiffuseLightingAttributes {};
|
||||
|
||||
typedef Variant<
|
||||
EmptyAttributes, BlendAttributes, MorphologyAttributes,
|
||||
ColorMatrixAttributes, FloodAttributes, TileAttributes,
|
||||
ComponentTransferAttributes, OpacityAttributes, ConvolveMatrixAttributes,
|
||||
OffsetAttributes, DisplacementMapAttributes, TurbulenceAttributes,
|
||||
CompositeAttributes, MergeAttributes, ImageAttributes,
|
||||
GaussianBlurAttributes, DropShadowAttributes, DiffuseLightingAttributes,
|
||||
SpecularLightingAttributes, ToAlphaAttributes>
|
||||
PrimitiveAttributes;
|
||||
|
||||
enum class ColorSpace { SRGB, LinearRGB, Max };
|
||||
|
||||
enum class AlphaModel { Unpremultiplied, Premultiplied };
|
||||
@ -396,116 +380,6 @@ class ColorModel {
|
||||
AlphaModel mAlphaModel;
|
||||
};
|
||||
|
||||
/**
|
||||
* A data structure to carry attributes for a given primitive that's part of a
|
||||
* filter. Will be serializable via IPDL, so it must not contain complex
|
||||
* functionality.
|
||||
* Used as part of a FilterDescription.
|
||||
*/
|
||||
class FilterPrimitiveDescription final {
|
||||
public:
|
||||
enum {
|
||||
kPrimitiveIndexSourceGraphic = -1,
|
||||
kPrimitiveIndexSourceAlpha = -2,
|
||||
kPrimitiveIndexFillPaint = -3,
|
||||
kPrimitiveIndexStrokePaint = -4
|
||||
};
|
||||
|
||||
FilterPrimitiveDescription();
|
||||
explicit FilterPrimitiveDescription(PrimitiveAttributes&& aAttributes);
|
||||
FilterPrimitiveDescription(FilterPrimitiveDescription&& aOther) = default;
|
||||
FilterPrimitiveDescription& operator=(FilterPrimitiveDescription&& aOther) =
|
||||
default;
|
||||
FilterPrimitiveDescription(const FilterPrimitiveDescription& aOther)
|
||||
: mAttributes(aOther.mAttributes),
|
||||
mInputPrimitives(aOther.mInputPrimitives.Clone()),
|
||||
mFilterPrimitiveSubregion(aOther.mFilterPrimitiveSubregion),
|
||||
mFilterSpaceBounds(aOther.mFilterSpaceBounds),
|
||||
mInputColorSpaces(aOther.mInputColorSpaces.Clone()),
|
||||
mOutputColorSpace(aOther.mOutputColorSpace),
|
||||
mIsTainted(aOther.mIsTainted) {}
|
||||
|
||||
const PrimitiveAttributes& Attributes() const { return mAttributes; }
|
||||
PrimitiveAttributes& Attributes() { return mAttributes; }
|
||||
|
||||
IntRect PrimitiveSubregion() const { return mFilterPrimitiveSubregion; }
|
||||
IntRect FilterSpaceBounds() const { return mFilterSpaceBounds; }
|
||||
bool IsTainted() const { return mIsTainted; }
|
||||
|
||||
size_t NumberOfInputs() const { return mInputPrimitives.Length(); }
|
||||
int32_t InputPrimitiveIndex(size_t aInputIndex) const {
|
||||
return aInputIndex < mInputPrimitives.Length()
|
||||
? mInputPrimitives[aInputIndex]
|
||||
: 0;
|
||||
}
|
||||
|
||||
ColorSpace InputColorSpace(size_t aInputIndex) const {
|
||||
return aInputIndex < mInputColorSpaces.Length()
|
||||
? mInputColorSpaces[aInputIndex]
|
||||
: ColorSpace();
|
||||
}
|
||||
|
||||
ColorSpace OutputColorSpace() const { return mOutputColorSpace; }
|
||||
|
||||
void SetPrimitiveSubregion(const IntRect& aRect) {
|
||||
mFilterPrimitiveSubregion = aRect;
|
||||
}
|
||||
|
||||
void SetFilterSpaceBounds(const IntRect& aRect) {
|
||||
mFilterSpaceBounds = aRect;
|
||||
}
|
||||
|
||||
void SetIsTainted(bool aIsTainted) { mIsTainted = aIsTainted; }
|
||||
|
||||
void SetInputPrimitive(size_t aInputIndex, int32_t aInputPrimitiveIndex) {
|
||||
mInputPrimitives.EnsureLengthAtLeast(aInputIndex + 1);
|
||||
mInputPrimitives[aInputIndex] = aInputPrimitiveIndex;
|
||||
}
|
||||
|
||||
void SetInputColorSpace(size_t aInputIndex, ColorSpace aColorSpace) {
|
||||
mInputColorSpaces.EnsureLengthAtLeast(aInputIndex + 1);
|
||||
mInputColorSpaces[aInputIndex] = aColorSpace;
|
||||
}
|
||||
|
||||
void SetOutputColorSpace(const ColorSpace& aColorSpace) {
|
||||
mOutputColorSpace = aColorSpace;
|
||||
}
|
||||
|
||||
bool operator==(const FilterPrimitiveDescription& aOther) const;
|
||||
bool operator!=(const FilterPrimitiveDescription& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
|
||||
private:
|
||||
PrimitiveAttributes mAttributes;
|
||||
AutoTArray<int32_t, 2> mInputPrimitives;
|
||||
IntRect mFilterPrimitiveSubregion;
|
||||
IntRect mFilterSpaceBounds;
|
||||
AutoTArray<ColorSpace, 2> mInputColorSpaces;
|
||||
ColorSpace mOutputColorSpace;
|
||||
bool mIsTainted;
|
||||
};
|
||||
|
||||
/**
|
||||
* A data structure that contains one or more FilterPrimitiveDescriptions.
|
||||
* Designed to be serializable via IPDL, so it must not contain complex
|
||||
* functionality.
|
||||
*/
|
||||
struct FilterDescription final {
|
||||
FilterDescription() = default;
|
||||
explicit FilterDescription(
|
||||
nsTArray<FilterPrimitiveDescription>&& aPrimitives) {
|
||||
mPrimitives.SwapElements(aPrimitives);
|
||||
}
|
||||
|
||||
bool operator==(const FilterDescription& aOther) const;
|
||||
bool operator!=(const FilterDescription& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
|
||||
CopyableTArray<FilterPrimitiveDescription> mPrimitives;
|
||||
};
|
||||
|
||||
already_AddRefed<FilterNode> FilterNodeGraphFromDescription(
|
||||
DrawTarget* aDT, const FilterDescription& aFilter,
|
||||
const Rect& aResultNeededRect, FilterNode* aSourceGraphic,
|
||||
|
@ -14,6 +14,7 @@ DEFINES['MOZ_APP_VERSION'] = '"%s"' % CONFIG['MOZ_APP_VERSION']
|
||||
|
||||
EXPORTS += [
|
||||
'DriverCrashGuard.h',
|
||||
'FilterDescription.h',
|
||||
'FilterSupport.h',
|
||||
'gfxCrashReporterUtils.h',
|
||||
'gfxTelemetry.h',
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "CSSFilterInstance.h"
|
||||
|
||||
// Keep others in (case-insensitive) order:
|
||||
#include "FilterDescription.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "nsIFrame.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "gfxPoint.h"
|
||||
#include "gfxRect.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "FilterSupport.h"
|
||||
#include "FilterDescription.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsRect.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user