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_CONICGRADIENTEFFECTD2D1_H_
8 #define MOZILLA_GFX_CONICGRADIENTEFFECTD2D1_H_
11 #include <d2d1effectauthor.h>
12 #include <d2d1effecthelpers.h>
15 #include "mozilla/Attributes.h"
17 // {fa4e3246-be57-4052-8c8b-881cc3633287}
18 DEFINE_GUID(CLSID_ConicGradientEffect
, 0xfa4e3246, 0xbe57, 0x4052, 0x8c, 0x8b,
19 0x88, 0x1c, 0xc3, 0x63, 0x32, 0x87);
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 CONIC_PROP_STOP_COLLECTION
= 0,
40 CONIC_PROP_START_OFFSET
,
41 CONIC_PROP_END_OFFSET
,
45 class ConicGradientEffectD2D1 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 ConicGradientEffectD2D1();
89 RefPtr
<ID2D1GradientStopCollection
> mStopCollection
;
90 RefPtr
<ID2D1EffectContext
> mEffectContext
;
91 RefPtr
<ID2D1DrawInfo
> mDrawInfo
;
92 SIMPLE_PROP(D2D1_VECTOR_2F
, Center
);
93 SIMPLE_PROP(FLOAT
, Angle
);
94 SIMPLE_PROP(FLOAT
, StartOffset
);
95 SIMPLE_PROP(FLOAT
, EndOffset
);
96 SIMPLE_PROP(D2D_MATRIX_3X2_F
, Transform
);
100 } // namespace mozilla