no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / gfx / 2d / RadialGradientEffectD2D1.h
bloba49671e6bdd3fc1c328d78d285372e6683d06ff3
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_
10 #include <d2d1_1.h>
11 #include <d2d1effectauthor.h>
12 #include <d2d1effecthelpers.h>
14 #include "2D.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) \
23 public: \
24 HRESULT Set##name(type a##name) { \
25 m##name = a##name; \
26 return S_OK; \
27 } \
28 type Get##name() const { return m##name; } \
30 private: \
31 type m##name;
33 namespace mozilla {
34 namespace gfx {
36 enum {
37 RADIAL_PROP_STOP_COLLECTION = 0,
38 RADIAL_PROP_CENTER_1,
39 RADIAL_PROP_CENTER_2,
40 RADIAL_PROP_RADIUS_1,
41 RADIAL_PROP_RADIUS_2,
42 RADIAL_PROP_TRANSFORM
45 class RadialGradientEffectD2D1 final : public ID2D1EffectImpl,
46 public ID2D1DrawTransform {
47 public:
48 // ID2D1EffectImpl
49 IFACEMETHODIMP Initialize(ID2D1EffectContext* pContextInternal,
50 ID2D1TransformGraph* pTransformGraph);
51 IFACEMETHODIMP PrepareForRender(D2D1_CHANGE_TYPE changeType);
52 IFACEMETHODIMP SetGraph(ID2D1TransformGraph* pGraph);
54 // IUnknown
55 IFACEMETHODIMP_(ULONG) AddRef();
56 IFACEMETHODIMP_(ULONG) Release();
57 IFACEMETHODIMP QueryInterface(REFIID riid, void** ppOutput);
59 // ID2D1Transform
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;
70 // ID2D1TransformNode
71 IFACEMETHODIMP_(UINT32) GetInputCount() const { return 1; }
73 // ID2D1DrawTransform
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; }
83 private:
84 already_AddRefed<ID2D1ResourceTexture> CreateGradientTexture();
86 RadialGradientEffectD2D1();
88 uint32_t mRefCount;
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);
99 } // namespace gfx
100 } // namespace mozilla
101 #undef SIMPLE_PROP
103 #endif