1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MOZILLA_GFX_RADIALGRADIENTEFFECTD2D1_H_
8 #define MOZILLA_GFX_RADIALGRADIENTEFFECTD2D1_H_
11 #include <d2d1effectauthor.h>
12 #include <d2d1effecthelpers.h>
15 #include "mozilla/Attributes.h"
17 // {97143DC6-CBC4-4DD4-A8BA-13342B0BA46D}
18 DEFINE_GUID(CLSID_RadialGradientEffect
, 0x97143dc6, 0xcbc4, 0x4dd4, 0xa8, 0xba,
19 0x13, 0x34, 0x2b, 0xb, 0xa4, 0x6d);
21 // Macro to keep our class nice and clean.
22 #define SIMPLE_PROP(type, name) \
24 HRESULT Set##name(type a##name) { \
28 type Get##name() const { return m##name; } \
37 RADIAL_PROP_STOP_COLLECTION
= 0,
45 class RadialGradientEffectD2D1 final
: public ID2D1EffectImpl
,
46 public ID2D1DrawTransform
{
49 IFACEMETHODIMP
Initialize(ID2D1EffectContext
* pContextInternal
,
50 ID2D1TransformGraph
* pTransformGraph
);
51 IFACEMETHODIMP
PrepareForRender(D2D1_CHANGE_TYPE changeType
);
52 IFACEMETHODIMP
SetGraph(ID2D1TransformGraph
* pGraph
);
55 IFACEMETHODIMP_(ULONG
) AddRef();
56 IFACEMETHODIMP_(ULONG
) Release();
57 IFACEMETHODIMP
QueryInterface(REFIID riid
, void** ppOutput
);
60 IFACEMETHODIMP
MapInputRectsToOutputRect(
61 const D2D1_RECT_L
* pInputRects
, const D2D1_RECT_L
* pInputOpaqueSubRects
,
62 UINT32 inputRectCount
, D2D1_RECT_L
* pOutputRect
,
63 D2D1_RECT_L
* pOutputOpaqueSubRect
);
64 IFACEMETHODIMP
MapOutputRectToInputRects(const D2D1_RECT_L
* pOutputRect
,
65 D2D1_RECT_L
* pInputRects
,
66 UINT32 inputRectCount
) const;
67 IFACEMETHODIMP
MapInvalidRect(UINT32 inputIndex
, D2D1_RECT_L invalidInputRect
,
68 D2D1_RECT_L
* pInvalidOutputRect
) const;
71 IFACEMETHODIMP_(UINT32
) GetInputCount() const { return 1; }
74 IFACEMETHODIMP
SetDrawInfo(ID2D1DrawInfo
* pDrawInfo
);
76 static HRESULT
Register(ID2D1Factory1
* aFactory
);
77 static void Unregister(ID2D1Factory1
* aFactory
);
78 static HRESULT __stdcall
CreateEffect(IUnknown
** aEffectImpl
);
80 HRESULT
SetStopCollection(IUnknown
* aStopCollection
);
81 IUnknown
* GetStopCollection() const { return mStopCollection
; }
84 already_AddRefed
<ID2D1ResourceTexture
> CreateGradientTexture();
86 RadialGradientEffectD2D1();
89 RefPtr
<ID2D1GradientStopCollection
> mStopCollection
;
90 RefPtr
<ID2D1EffectContext
> mEffectContext
;
91 RefPtr
<ID2D1DrawInfo
> mDrawInfo
;
92 SIMPLE_PROP(D2D1_VECTOR_2F
, Center1
);
93 SIMPLE_PROP(D2D1_VECTOR_2F
, Center2
);
94 SIMPLE_PROP(FLOAT
, Radius1
);
95 SIMPLE_PROP(FLOAT
, Radius2
);
96 SIMPLE_PROP(D2D_MATRIX_3X2_F
, Transform
);
100 } // namespace mozilla