gecko/gfx/2d/FilterNodeD2D1.h
Nathan Froyd e504437747 Bug 1207245 - part 3 - switch all uses of mozilla::RefPtr<T> to nsRefPtr<T>; r=ehsan
This commit was generated using the following script, executed at the
top level of a typical source code checkout.

 # Don't modify select files in mfbt/ because it's not worth trying to
 # tease out the dependencies currently.
 #
 # Don't modify anything in media/gmp-clearkey/0.1/ because those files
 # use their own RefPtr, defined in their own RefCounted.h.
find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    grep -v 'mfbt/RefPtr.h' | \
    grep -v 'mfbt/nsRefPtr.h' | \
    grep -v 'mfbt/RefCounted.h' | \
    grep -v 'media/gmp-clearkey/0.1/' | \
    xargs perl -p -i -e '
 s/mozilla::RefPtr/nsRefPtr/g; # handle declarations in headers
 s/\bRefPtr</nsRefPtr</g; # handle local variables in functions
 s#mozilla/RefPtr.h#mozilla/nsRefPtr.h#; # handle #includes
 s#mfbt/RefPtr.h#mfbt/nsRefPtr.h#;       # handle strange #includes
'

 # |using mozilla::RefPtr;| is OK; |using nsRefPtr;| is invalid syntax.
find . -name '*.cpp' -o -name '*.mm' | xargs sed -i -e '/using nsRefPtr/d'

 # RefPtr.h used |byRef| for dealing with COM-style outparams.
 # nsRefPtr.h uses |getter_AddRefs|.
 # Fixup that mismatch.
find . -name '*.cpp' -o -name '*.h'| \
    xargs perl -p -i -e 's/byRef/getter_AddRefs/g'
2015-10-18 00:40:10 -04:00

134 lines
4.6 KiB
C++

/* -*- 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"
#include <vector>
#include <d2d1_1.h>
#include <cguid.h>
namespace mozilla {
namespace gfx {
class FilterNodeD2D1 : public FilterNode
{
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeD2D1)
static already_AddRefed<FilterNode> Create(ID2D1DeviceContext *aDC, FilterType aType);
FilterNodeD2D1(ID2D1Effect *aEffect, FilterType aType)
: mEffect(aEffect)
, mType(aType)
{
InitUnmappedProperties();
}
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);
virtual void SetAttribute(uint32_t aIndex, const Matrix &aValue);
// 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);
virtual ID2D1Effect* MainEffect() { return mEffect.get(); }
virtual ID2D1Effect* InputEffect() { return mEffect.get(); }
virtual ID2D1Effect* OutputEffect() { return mEffect.get(); }
protected:
friend class DrawTargetD2D1;
friend class DrawTargetD2D;
friend class FilterNodeConvolveD2D1;
void InitUnmappedProperties();
nsRefPtr<ID2D1Effect> mEffect;
std::vector<nsRefPtr<FilterNodeD2D1>> mInputFilters;
std::vector<nsRefPtr<SourceSurface>> mInputSurfaces;
FilterType mType;
};
class FilterNodeConvolveD2D1 : public FilterNodeD2D1
{
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeConvolveD2D1)
FilterNodeConvolveD2D1(ID2D1DeviceContext *aDC);
virtual void SetInput(uint32_t aIndex, FilterNode *aFilter);
virtual void SetAttribute(uint32_t aIndex, uint32_t aValue);
virtual void SetAttribute(uint32_t aIndex, const IntSize &aValue);
virtual void SetAttribute(uint32_t aIndex, const IntPoint &aValue);
virtual void SetAttribute(uint32_t aIndex, const IntRect &aValue);
virtual ID2D1Effect* InputEffect() override;
private:
void UpdateChain();
void UpdateOffset();
void UpdateSourceRect();
nsRefPtr<ID2D1Effect> mExtendInputEffect;
nsRefPtr<ID2D1Effect> mBorderEffect;
ConvolveMatrixEdgeMode mEdgeMode;
IntPoint mTarget;
IntSize mKernelSize;
IntRect mSourceRect;
};
class FilterNodeExtendInputAdapterD2D1 : public FilterNodeD2D1
{
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeExtendInputAdapterD2D1)
FilterNodeExtendInputAdapterD2D1(ID2D1DeviceContext *aDC, FilterNodeD2D1 *aFilterNode, FilterType aType);
virtual ID2D1Effect* InputEffect() override { return mExtendInputEffect.get(); }
virtual ID2D1Effect* OutputEffect() override { return mWrappedFilterNode->OutputEffect(); }
private:
nsRefPtr<FilterNodeD2D1> mWrappedFilterNode;
nsRefPtr<ID2D1Effect> mExtendInputEffect;
};
class FilterNodePremultiplyAdapterD2D1 : public FilterNodeD2D1
{
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodePremultiplyAdapterD2D1)
FilterNodePremultiplyAdapterD2D1(ID2D1DeviceContext *aDC, FilterNodeD2D1 *aFilterNode, FilterType aType);
virtual ID2D1Effect* InputEffect() override { return mPrePremultiplyEffect.get(); }
virtual ID2D1Effect* OutputEffect() override { return mPostUnpremultiplyEffect.get(); }
private:
nsRefPtr<ID2D1Effect> mPrePremultiplyEffect;
nsRefPtr<ID2D1Effect> mPostUnpremultiplyEffect;
};
}
}
#endif