no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / gfx / 2d / ExtendInputEffectD2D1.h
blob47a026b940f59af2959cbd7d3bb9c708fe9a2236
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_EXTENDINPUTEFFECTD2D1_H_
8 #define MOZILLA_GFX_EXTENDINPUTEFFECTD2D1_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_ExtendInputEffect, 0x5fb55c7c, 0xd795, 0x4ba3, 0xa9, 0x5c,
19 0x22, 0x82, 0x5d, 0x0c, 0x4d, 0xf7);
21 namespace mozilla {
22 namespace gfx {
24 enum { EXTENDINPUT_PROP_OUTPUT_RECT = 0 };
26 // An effect type that passes through its input unchanged but sets the effect's
27 // output rect to a specified rect. Unlike the built-in Crop effect, the
28 // ExtendInput effect can extend the input rect, and not just make it smaller.
29 // The added margins are filled with transparent black.
30 // Some effects have different output depending on their input effect's output
31 // rect, for example the Border effect (which repeats the edges of its input
32 // effect's output rect) or the component transfer and color matrix effects
33 // (which can transform transparent pixels into non-transparent ones, but only
34 // inside their input effect's output rect).
35 class ExtendInputEffectD2D1 final : public ID2D1EffectImpl,
36 public ID2D1DrawTransform {
37 public:
38 // ID2D1EffectImpl
39 IFACEMETHODIMP Initialize(ID2D1EffectContext* pContextInternal,
40 ID2D1TransformGraph* pTransformGraph);
41 IFACEMETHODIMP PrepareForRender(D2D1_CHANGE_TYPE changeType);
42 IFACEMETHODIMP SetGraph(ID2D1TransformGraph* pGraph);
44 // IUnknown
45 IFACEMETHODIMP_(ULONG) AddRef();
46 IFACEMETHODIMP_(ULONG) Release();
47 IFACEMETHODIMP QueryInterface(REFIID riid, void** ppOutput);
49 // ID2D1Transform
50 IFACEMETHODIMP MapInputRectsToOutputRect(
51 const D2D1_RECT_L* pInputRects, const D2D1_RECT_L* pInputOpaqueSubRects,
52 UINT32 inputRectCount, D2D1_RECT_L* pOutputRect,
53 D2D1_RECT_L* pOutputOpaqueSubRect);
54 IFACEMETHODIMP MapOutputRectToInputRects(const D2D1_RECT_L* pOutputRect,
55 D2D1_RECT_L* pInputRects,
56 UINT32 inputRectCount) const;
57 IFACEMETHODIMP MapInvalidRect(UINT32 inputIndex, D2D1_RECT_L invalidInputRect,
58 D2D1_RECT_L* pInvalidOutputRect) const;
60 // ID2D1TransformNode
61 IFACEMETHODIMP_(UINT32) GetInputCount() const { return 1; }
63 // ID2D1DrawTransform
64 IFACEMETHODIMP SetDrawInfo(ID2D1DrawInfo* pDrawInfo) { return S_OK; }
66 static HRESULT Register(ID2D1Factory1* aFactory);
67 static void Unregister(ID2D1Factory1* aFactory);
68 static HRESULT __stdcall CreateEffect(IUnknown** aEffectImpl);
70 HRESULT SetOutputRect(D2D1_VECTOR_4F aOutputRect) {
71 mOutputRect = aOutputRect;
72 return S_OK;
74 D2D1_VECTOR_4F GetOutputRect() const { return mOutputRect; }
76 private:
77 ExtendInputEffectD2D1();
79 uint32_t mRefCount;
80 D2D1_VECTOR_4F mOutputRect;
83 } // namespace gfx
84 } // namespace mozilla
85 #undef SIMPLE_PROP
87 #endif