michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_GFX_RADIALGRADIENTEFFECTD2D1_H_ michael@0: #define MOZILLA_GFX_RADIALGRADIENTEFFECTD2D1_H_ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "2D.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: // {97143DC6-CBC4-4DD4-A8BA-13342B0BA46D} michael@0: DEFINE_GUID(CLSID_RadialGradientEffect, michael@0: 0x97143dc6, 0xcbc4, 0x4dd4, 0xa8, 0xba, 0x13, 0x34, 0x2b, 0xb, 0xa4, 0x6d); michael@0: michael@0: // Macro to keep our class nice and clean. michael@0: #define SIMPLE_PROP(type, name) \ michael@0: public: \ michael@0: HRESULT Set##name(type a##name) \ michael@0: { m##name = a##name; return S_OK; } \ michael@0: type Get##name() const { return m##name; } \ michael@0: private: \ michael@0: type m##name; michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: enum { michael@0: RADIAL_PROP_STOP_COLLECTION = 0, michael@0: RADIAL_PROP_CENTER_1, michael@0: RADIAL_PROP_CENTER_2, michael@0: RADIAL_PROP_RADIUS_1, michael@0: RADIAL_PROP_RADIUS_2, michael@0: RADIAL_PROP_TRANSFORM michael@0: }; michael@0: michael@0: class RadialGradientEffectD2D1 MOZ_FINAL : public ID2D1EffectImpl michael@0: , public ID2D1DrawTransform michael@0: { michael@0: public: michael@0: // ID2D1EffectImpl michael@0: IFACEMETHODIMP Initialize(ID2D1EffectContext* pContextInternal, ID2D1TransformGraph* pTransformGraph); michael@0: IFACEMETHODIMP PrepareForRender(D2D1_CHANGE_TYPE changeType); michael@0: IFACEMETHODIMP SetGraph(ID2D1TransformGraph* pGraph); michael@0: michael@0: // IUnknown michael@0: IFACEMETHODIMP_(ULONG) AddRef(); michael@0: IFACEMETHODIMP_(ULONG) Release(); michael@0: IFACEMETHODIMP QueryInterface(REFIID riid, void** ppOutput); michael@0: michael@0: // ID2D1Transform michael@0: IFACEMETHODIMP MapInputRectsToOutputRect(const D2D1_RECT_L* pInputRects, michael@0: const D2D1_RECT_L* pInputOpaqueSubRects, michael@0: UINT32 inputRectCount, michael@0: D2D1_RECT_L* pOutputRect, michael@0: D2D1_RECT_L* pOutputOpaqueSubRect); michael@0: IFACEMETHODIMP MapOutputRectToInputRects(const D2D1_RECT_L* pOutputRect, michael@0: D2D1_RECT_L* pInputRects, michael@0: UINT32 inputRectCount) const; michael@0: IFACEMETHODIMP MapInvalidRect(UINT32 inputIndex, michael@0: D2D1_RECT_L invalidInputRect, michael@0: D2D1_RECT_L* pInvalidOutputRect) const; michael@0: michael@0: // ID2D1TransformNode michael@0: IFACEMETHODIMP_(UINT32) GetInputCount() const { return 1; } michael@0: michael@0: // ID2D1DrawTransform michael@0: IFACEMETHODIMP SetDrawInfo(ID2D1DrawInfo *pDrawInfo); michael@0: michael@0: static HRESULT Register(ID2D1Factory1* aFactory); michael@0: static HRESULT __stdcall CreateEffect(IUnknown** aEffectImpl); michael@0: michael@0: HRESULT SetStopCollection(IUnknown *aStopCollection); michael@0: IUnknown *GetStopCollection() const { return mStopCollection; } michael@0: michael@0: private: michael@0: TemporaryRef CreateGradientTexture(); michael@0: michael@0: RadialGradientEffectD2D1(); michael@0: michael@0: uint32_t mRefCount; michael@0: RefPtr mStopCollection; michael@0: RefPtr mEffectContext; michael@0: RefPtr mDrawInfo; michael@0: SIMPLE_PROP(D2D1_VECTOR_2F, Center1); michael@0: SIMPLE_PROP(D2D1_VECTOR_2F, Center2); michael@0: SIMPLE_PROP(FLOAT, Radius1); michael@0: SIMPLE_PROP(FLOAT, Radius2); michael@0: SIMPLE_PROP(D2D_MATRIX_3X2_F, Transform); michael@0: }; michael@0: michael@0: } michael@0: } michael@0: #undef SIMPLE_PROP michael@0: michael@0: #endif