gfx/2d/RadialGradientEffectD2D1.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef MOZILLA_GFX_RADIALGRADIENTEFFECTD2D1_H_
michael@0 7 #define MOZILLA_GFX_RADIALGRADIENTEFFECTD2D1_H_
michael@0 8
michael@0 9 #include <d2d1_1.h>
michael@0 10 #include <d2d1effectauthor.h>
michael@0 11 #include <d2d1effecthelpers.h>
michael@0 12
michael@0 13 #include "2D.h"
michael@0 14 #include "mozilla/Attributes.h"
michael@0 15
michael@0 16 // {97143DC6-CBC4-4DD4-A8BA-13342B0BA46D}
michael@0 17 DEFINE_GUID(CLSID_RadialGradientEffect,
michael@0 18 0x97143dc6, 0xcbc4, 0x4dd4, 0xa8, 0xba, 0x13, 0x34, 0x2b, 0xb, 0xa4, 0x6d);
michael@0 19
michael@0 20 // Macro to keep our class nice and clean.
michael@0 21 #define SIMPLE_PROP(type, name) \
michael@0 22 public: \
michael@0 23 HRESULT Set##name(type a##name) \
michael@0 24 { m##name = a##name; return S_OK; } \
michael@0 25 type Get##name() const { return m##name; } \
michael@0 26 private: \
michael@0 27 type m##name;
michael@0 28
michael@0 29 namespace mozilla {
michael@0 30 namespace gfx {
michael@0 31
michael@0 32 enum {
michael@0 33 RADIAL_PROP_STOP_COLLECTION = 0,
michael@0 34 RADIAL_PROP_CENTER_1,
michael@0 35 RADIAL_PROP_CENTER_2,
michael@0 36 RADIAL_PROP_RADIUS_1,
michael@0 37 RADIAL_PROP_RADIUS_2,
michael@0 38 RADIAL_PROP_TRANSFORM
michael@0 39 };
michael@0 40
michael@0 41 class RadialGradientEffectD2D1 MOZ_FINAL : public ID2D1EffectImpl
michael@0 42 , public ID2D1DrawTransform
michael@0 43 {
michael@0 44 public:
michael@0 45 // ID2D1EffectImpl
michael@0 46 IFACEMETHODIMP Initialize(ID2D1EffectContext* pContextInternal, ID2D1TransformGraph* pTransformGraph);
michael@0 47 IFACEMETHODIMP PrepareForRender(D2D1_CHANGE_TYPE changeType);
michael@0 48 IFACEMETHODIMP SetGraph(ID2D1TransformGraph* pGraph);
michael@0 49
michael@0 50 // IUnknown
michael@0 51 IFACEMETHODIMP_(ULONG) AddRef();
michael@0 52 IFACEMETHODIMP_(ULONG) Release();
michael@0 53 IFACEMETHODIMP QueryInterface(REFIID riid, void** ppOutput);
michael@0 54
michael@0 55 // ID2D1Transform
michael@0 56 IFACEMETHODIMP MapInputRectsToOutputRect(const D2D1_RECT_L* pInputRects,
michael@0 57 const D2D1_RECT_L* pInputOpaqueSubRects,
michael@0 58 UINT32 inputRectCount,
michael@0 59 D2D1_RECT_L* pOutputRect,
michael@0 60 D2D1_RECT_L* pOutputOpaqueSubRect);
michael@0 61 IFACEMETHODIMP MapOutputRectToInputRects(const D2D1_RECT_L* pOutputRect,
michael@0 62 D2D1_RECT_L* pInputRects,
michael@0 63 UINT32 inputRectCount) const;
michael@0 64 IFACEMETHODIMP MapInvalidRect(UINT32 inputIndex,
michael@0 65 D2D1_RECT_L invalidInputRect,
michael@0 66 D2D1_RECT_L* pInvalidOutputRect) const;
michael@0 67
michael@0 68 // ID2D1TransformNode
michael@0 69 IFACEMETHODIMP_(UINT32) GetInputCount() const { return 1; }
michael@0 70
michael@0 71 // ID2D1DrawTransform
michael@0 72 IFACEMETHODIMP SetDrawInfo(ID2D1DrawInfo *pDrawInfo);
michael@0 73
michael@0 74 static HRESULT Register(ID2D1Factory1* aFactory);
michael@0 75 static HRESULT __stdcall CreateEffect(IUnknown** aEffectImpl);
michael@0 76
michael@0 77 HRESULT SetStopCollection(IUnknown *aStopCollection);
michael@0 78 IUnknown *GetStopCollection() const { return mStopCollection; }
michael@0 79
michael@0 80 private:
michael@0 81 TemporaryRef<ID2D1ResourceTexture> CreateGradientTexture();
michael@0 82
michael@0 83 RadialGradientEffectD2D1();
michael@0 84
michael@0 85 uint32_t mRefCount;
michael@0 86 RefPtr<ID2D1GradientStopCollection> mStopCollection;
michael@0 87 RefPtr<ID2D1EffectContext> mEffectContext;
michael@0 88 RefPtr<ID2D1DrawInfo> mDrawInfo;
michael@0 89 SIMPLE_PROP(D2D1_VECTOR_2F, Center1);
michael@0 90 SIMPLE_PROP(D2D1_VECTOR_2F, Center2);
michael@0 91 SIMPLE_PROP(FLOAT, Radius1);
michael@0 92 SIMPLE_PROP(FLOAT, Radius2);
michael@0 93 SIMPLE_PROP(D2D_MATRIX_3X2_F, Transform);
michael@0 94 };
michael@0 95
michael@0 96 }
michael@0 97 }
michael@0 98 #undef SIMPLE_PROP
michael@0 99
michael@0 100 #endif

mercurial