2013-11-27 15:25:16 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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 MOZILLA_GFX_FILTERNODED2D1_H_
|
|
|
|
#define MOZILLA_GFX_FILTERNODED2D1_H_
|
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
#include "Filters.h"
|
2014-09-25 23:18:29 +04:00
|
|
|
#include <vector>
|
2013-11-27 15:25:16 +04:00
|
|
|
#include <d2d1_1.h>
|
|
|
|
#include <cguid.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class FilterNodeD2D1 : public FilterNode
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 17:23:37 +04:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeD2D1)
|
2015-06-17 17:00:52 +03:00
|
|
|
static already_AddRefed<FilterNode> Create(ID2D1DeviceContext *aDC, FilterType aType);
|
2013-11-27 15:25:16 +04:00
|
|
|
|
2014-09-25 23:18:29 +04:00
|
|
|
FilterNodeD2D1(ID2D1Effect *aEffect, FilterType aType)
|
|
|
|
: mEffect(aEffect)
|
2013-11-27 15:25:16 +04:00
|
|
|
, mType(aType)
|
2013-11-27 15:25:27 +04:00
|
|
|
{
|
|
|
|
InitUnmappedProperties();
|
|
|
|
}
|
2013-11-27 15:25:16 +04:00
|
|
|
|
|
|
|
virtual FilterBackend GetBackendType() { return FILTER_BACKEND_DIRECT2D1_1; }
|
|
|
|
|
|
|
|
virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface);
|
|
|
|
virtual void SetInput(uint32_t aIndex, FilterNode *aFilter);
|
|
|
|
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, uint32_t aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, Float aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Point &aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Matrix5x4 &aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Point3D &aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Size &aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const IntSize &aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Color &aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Rect &aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const IntRect &aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, bool aValue);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Float *aValues, uint32_t aSize);
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const IntPoint &aValue);
|
2013-11-27 15:25:27 +04:00
|
|
|
virtual void SetAttribute(uint32_t aIndex, const Matrix &aValue);
|
2013-11-27 15:25:16 +04:00
|
|
|
|
2014-09-25 23:18:29 +04:00
|
|
|
// Called by DrawTarget before it draws our OutputEffect, and recursively
|
|
|
|
// by the filter nodes that have this filter as one of their inputs. This
|
|
|
|
// gives us a chance to convert any input surfaces to the target format for
|
|
|
|
// the DrawTarget that we will draw to.
|
|
|
|
virtual void WillDraw(DrawTarget *aDT);
|
|
|
|
|
2015-02-09 22:04:11 +03:00
|
|
|
virtual ID2D1Effect* MainEffect() { return mEffect.get(); }
|
|
|
|
virtual ID2D1Effect* InputEffect() { return mEffect.get(); }
|
|
|
|
virtual ID2D1Effect* OutputEffect() { return mEffect.get(); }
|
|
|
|
|
2013-11-27 15:25:16 +04:00
|
|
|
protected:
|
|
|
|
friend class DrawTargetD2D1;
|
|
|
|
friend class DrawTargetD2D;
|
|
|
|
friend class FilterNodeConvolveD2D1;
|
|
|
|
|
2013-11-27 15:25:27 +04:00
|
|
|
void InitUnmappedProperties();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ID2D1Effect> mEffect;
|
|
|
|
std::vector<RefPtr<FilterNodeD2D1>> mInputFilters;
|
|
|
|
std::vector<RefPtr<SourceSurface>> mInputSurfaces;
|
2013-11-27 15:25:16 +04:00
|
|
|
FilterType mType;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodeConvolveD2D1 : public FilterNodeD2D1
|
|
|
|
{
|
|
|
|
public:
|
2015-12-16 18:41:21 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeConvolveD2D1, override)
|
2016-12-16 10:54:32 +03:00
|
|
|
explicit FilterNodeConvolveD2D1(ID2D1DeviceContext *aDC);
|
2013-11-27 15:25:16 +04:00
|
|
|
|
2015-12-16 18:41:21 +03:00
|
|
|
virtual void SetInput(uint32_t aIndex, FilterNode *aFilter) override;
|
2013-11-27 15:25:16 +04:00
|
|
|
|
2015-12-16 18:41:21 +03:00
|
|
|
virtual void SetAttribute(uint32_t aIndex, uint32_t aValue) override;
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const IntSize &aValue) override;
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const IntPoint &aValue) override;
|
|
|
|
virtual void SetAttribute(uint32_t aIndex, const IntRect &aValue) override;
|
2013-11-27 15:25:16 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual ID2D1Effect* InputEffect() override;
|
2014-09-25 23:18:29 +04:00
|
|
|
|
2013-11-27 15:25:16 +04:00
|
|
|
private:
|
|
|
|
void UpdateChain();
|
|
|
|
void UpdateOffset();
|
|
|
|
void UpdateSourceRect();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ID2D1Effect> mExtendInputEffect;
|
|
|
|
RefPtr<ID2D1Effect> mBorderEffect;
|
2013-11-27 15:25:16 +04:00
|
|
|
ConvolveMatrixEdgeMode mEdgeMode;
|
|
|
|
IntPoint mTarget;
|
|
|
|
IntSize mKernelSize;
|
|
|
|
IntRect mSourceRect;
|
|
|
|
};
|
|
|
|
|
2015-02-09 22:04:11 +03:00
|
|
|
class FilterNodeExtendInputAdapterD2D1 : public FilterNodeD2D1
|
2013-11-27 15:25:16 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-12-16 18:41:21 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeExtendInputAdapterD2D1, override)
|
2015-02-09 22:04:11 +03:00
|
|
|
FilterNodeExtendInputAdapterD2D1(ID2D1DeviceContext *aDC, FilterNodeD2D1 *aFilterNode, FilterType aType);
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual ID2D1Effect* InputEffect() override { return mExtendInputEffect.get(); }
|
|
|
|
virtual ID2D1Effect* OutputEffect() override { return mWrappedFilterNode->OutputEffect(); }
|
2015-02-09 22:04:11 +03:00
|
|
|
|
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<FilterNodeD2D1> mWrappedFilterNode;
|
|
|
|
RefPtr<ID2D1Effect> mExtendInputEffect;
|
2015-02-09 22:04:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class FilterNodePremultiplyAdapterD2D1 : public FilterNodeD2D1
|
|
|
|
{
|
|
|
|
public:
|
2015-12-16 18:41:21 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodePremultiplyAdapterD2D1, override)
|
2015-02-09 22:04:11 +03:00
|
|
|
FilterNodePremultiplyAdapterD2D1(ID2D1DeviceContext *aDC, FilterNodeD2D1 *aFilterNode, FilterType aType);
|
2013-11-27 15:25:16 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual ID2D1Effect* InputEffect() override { return mPrePremultiplyEffect.get(); }
|
|
|
|
virtual ID2D1Effect* OutputEffect() override { return mPostUnpremultiplyEffect.get(); }
|
2013-11-27 15:25:16 +04:00
|
|
|
|
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ID2D1Effect> mPrePremultiplyEffect;
|
|
|
|
RefPtr<ID2D1Effect> mPostUnpremultiplyEffect;
|
2013-11-27 15:25:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|