SVGFEDisplacementMapElement.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_SVGFEDisplacementMapElement_h
  6. #define mozilla_dom_SVGFEDisplacementMapElement_h
  7. #include "nsSVGEnum.h"
  8. #include "nsSVGFilters.h"
  9. nsresult NS_NewSVGFEDisplacementMapElement(nsIContent **aResult,
  10. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
  11. namespace mozilla {
  12. namespace dom {
  13. typedef nsSVGFE SVGFEDisplacementMapElementBase;
  14. class SVGFEDisplacementMapElement : public SVGFEDisplacementMapElementBase
  15. {
  16. protected:
  17. friend nsresult (::NS_NewSVGFEDisplacementMapElement(nsIContent **aResult,
  18. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
  19. explicit SVGFEDisplacementMapElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
  20. : SVGFEDisplacementMapElementBase(aNodeInfo)
  21. {
  22. }
  23. virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  24. public:
  25. virtual FilterPrimitiveDescription
  26. GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
  27. const IntRect& aFilterSubregion,
  28. const nsTArray<bool>& aInputsAreTainted,
  29. nsTArray<RefPtr<SourceSurface>>& aInputImages) override;
  30. virtual bool AttributeAffectsRendering(
  31. int32_t aNameSpaceID, nsIAtom* aAttribute) const override;
  32. virtual nsSVGString& GetResultImageName() override { return mStringAttributes[RESULT]; }
  33. virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) override;
  34. virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
  35. // WebIDL
  36. already_AddRefed<SVGAnimatedString> In1();
  37. already_AddRefed<SVGAnimatedString> In2();
  38. already_AddRefed<SVGAnimatedNumber> Scale();
  39. already_AddRefed<SVGAnimatedEnumeration> XChannelSelector();
  40. already_AddRefed<SVGAnimatedEnumeration> YChannelSelector();
  41. protected:
  42. virtual bool OperatesOnSRGB(int32_t aInputIndex,
  43. bool aInputIsAlreadySRGB) override {
  44. switch (aInputIndex) {
  45. case 0:
  46. return aInputIsAlreadySRGB;
  47. case 1:
  48. return SVGFEDisplacementMapElementBase::OperatesOnSRGB(aInputIndex, aInputIsAlreadySRGB);
  49. default:
  50. NS_ERROR("Will not give correct color model");
  51. return false;
  52. }
  53. }
  54. virtual NumberAttributesInfo GetNumberInfo() override;
  55. virtual EnumAttributesInfo GetEnumInfo() override;
  56. virtual StringAttributesInfo GetStringInfo() override;
  57. enum { SCALE };
  58. nsSVGNumber2 mNumberAttributes[1];
  59. static NumberInfo sNumberInfo[1];
  60. enum { CHANNEL_X, CHANNEL_Y };
  61. nsSVGEnum mEnumAttributes[2];
  62. static nsSVGEnumMapping sChannelMap[];
  63. static EnumInfo sEnumInfo[2];
  64. enum { RESULT, IN1, IN2 };
  65. nsSVGString mStringAttributes[3];
  66. static StringInfo sStringInfo[3];
  67. };
  68. } // namespace dom
  69. } // namespace mozilla
  70. #endif // mozilla_dom_SVGFEDisplacementMapElement_h