Tue, 06 Jan 2015 21:39:09 +0100
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_FILTERNODED2D1_H_ |
michael@0 | 7 | #define MOZILLA_GFX_FILTERNODED2D1_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "2D.h" |
michael@0 | 10 | #include "Filters.h" |
michael@0 | 11 | #include <d2d1_1.h> |
michael@0 | 12 | #include <cguid.h> |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace gfx { |
michael@0 | 16 | |
michael@0 | 17 | class FilterNodeD2D1 : public FilterNode |
michael@0 | 18 | { |
michael@0 | 19 | public: |
michael@0 | 20 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeD2D1) |
michael@0 | 21 | static TemporaryRef<FilterNode> Create(DrawTarget* aDT, ID2D1DeviceContext *aDC, FilterType aType); |
michael@0 | 22 | |
michael@0 | 23 | FilterNodeD2D1(DrawTarget* aDT, ID2D1Effect *aEffect, FilterType aType) |
michael@0 | 24 | : mDT(aDT) |
michael@0 | 25 | , mEffect(aEffect) |
michael@0 | 26 | , mType(aType) |
michael@0 | 27 | { |
michael@0 | 28 | InitUnmappedProperties(); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | virtual FilterBackend GetBackendType() { return FILTER_BACKEND_DIRECT2D1_1; } |
michael@0 | 32 | |
michael@0 | 33 | virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface); |
michael@0 | 34 | virtual void SetInput(uint32_t aIndex, FilterNode *aFilter); |
michael@0 | 35 | |
michael@0 | 36 | virtual void SetAttribute(uint32_t aIndex, uint32_t aValue); |
michael@0 | 37 | virtual void SetAttribute(uint32_t aIndex, Float aValue); |
michael@0 | 38 | virtual void SetAttribute(uint32_t aIndex, const Point &aValue); |
michael@0 | 39 | virtual void SetAttribute(uint32_t aIndex, const Matrix5x4 &aValue); |
michael@0 | 40 | virtual void SetAttribute(uint32_t aIndex, const Point3D &aValue); |
michael@0 | 41 | virtual void SetAttribute(uint32_t aIndex, const Size &aValue); |
michael@0 | 42 | virtual void SetAttribute(uint32_t aIndex, const IntSize &aValue); |
michael@0 | 43 | virtual void SetAttribute(uint32_t aIndex, const Color &aValue); |
michael@0 | 44 | virtual void SetAttribute(uint32_t aIndex, const Rect &aValue); |
michael@0 | 45 | virtual void SetAttribute(uint32_t aIndex, const IntRect &aValue); |
michael@0 | 46 | virtual void SetAttribute(uint32_t aIndex, bool aValue); |
michael@0 | 47 | virtual void SetAttribute(uint32_t aIndex, const Float *aValues, uint32_t aSize); |
michael@0 | 48 | virtual void SetAttribute(uint32_t aIndex, const IntPoint &aValue); |
michael@0 | 49 | virtual void SetAttribute(uint32_t aIndex, const Matrix &aValue); |
michael@0 | 50 | |
michael@0 | 51 | protected: |
michael@0 | 52 | friend class DrawTargetD2D1; |
michael@0 | 53 | friend class DrawTargetD2D; |
michael@0 | 54 | friend class FilterNodeConvolveD2D1; |
michael@0 | 55 | |
michael@0 | 56 | virtual ID2D1Effect* InputEffect() { return mEffect.get(); } |
michael@0 | 57 | virtual ID2D1Effect* OutputEffect() { return mEffect.get(); } |
michael@0 | 58 | |
michael@0 | 59 | void InitUnmappedProperties(); |
michael@0 | 60 | |
michael@0 | 61 | RefPtr<DrawTarget> mDT; |
michael@0 | 62 | RefPtr<ID2D1Effect> mEffect; |
michael@0 | 63 | FilterType mType; |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | class FilterNodeConvolveD2D1 : public FilterNodeD2D1 |
michael@0 | 67 | { |
michael@0 | 68 | public: |
michael@0 | 69 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeConvolveD2D1) |
michael@0 | 70 | FilterNodeConvolveD2D1(DrawTarget *aDT, ID2D1DeviceContext *aDC); |
michael@0 | 71 | |
michael@0 | 72 | virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface); |
michael@0 | 73 | virtual void SetInput(uint32_t aIndex, FilterNode *aFilter); |
michael@0 | 74 | |
michael@0 | 75 | virtual void SetAttribute(uint32_t aIndex, uint32_t aValue); |
michael@0 | 76 | virtual void SetAttribute(uint32_t aIndex, const IntSize &aValue); |
michael@0 | 77 | virtual void SetAttribute(uint32_t aIndex, const IntPoint &aValue); |
michael@0 | 78 | virtual void SetAttribute(uint32_t aIndex, const IntRect &aValue); |
michael@0 | 79 | |
michael@0 | 80 | private: |
michael@0 | 81 | void UpdateChain(); |
michael@0 | 82 | void UpdateOffset(); |
michael@0 | 83 | void UpdateSourceRect(); |
michael@0 | 84 | |
michael@0 | 85 | RefPtr<ID2D1Image> mInput; |
michael@0 | 86 | RefPtr<ID2D1Effect> mInputEffect; |
michael@0 | 87 | RefPtr<ID2D1Effect> mFloodEffect; |
michael@0 | 88 | RefPtr<ID2D1Effect> mCompositeEffect; |
michael@0 | 89 | RefPtr<ID2D1Effect> mCropEffect; |
michael@0 | 90 | RefPtr<ID2D1Effect> mBorderEffect; |
michael@0 | 91 | ConvolveMatrixEdgeMode mEdgeMode; |
michael@0 | 92 | IntPoint mTarget; |
michael@0 | 93 | IntSize mKernelSize; |
michael@0 | 94 | IntRect mSourceRect; |
michael@0 | 95 | }; |
michael@0 | 96 | |
michael@0 | 97 | class FilterNodeComponentTransferD2D1 : public FilterNodeD2D1 |
michael@0 | 98 | { |
michael@0 | 99 | public: |
michael@0 | 100 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeComponentTransferD2D1) |
michael@0 | 101 | FilterNodeComponentTransferD2D1(DrawTarget *aDT, ID2D1DeviceContext *aDC, ID2D1Effect *aEffect, FilterType aType); |
michael@0 | 102 | |
michael@0 | 103 | protected: |
michael@0 | 104 | virtual ID2D1Effect* InputEffect() MOZ_OVERRIDE { return mPrePremultiplyEffect.get(); } |
michael@0 | 105 | virtual ID2D1Effect* OutputEffect() MOZ_OVERRIDE { return mPostUnpremultiplyEffect.get(); } |
michael@0 | 106 | |
michael@0 | 107 | private: |
michael@0 | 108 | RefPtr<ID2D1Effect> mPrePremultiplyEffect; |
michael@0 | 109 | RefPtr<ID2D1Effect> mPostUnpremultiplyEffect; |
michael@0 | 110 | }; |
michael@0 | 111 | |
michael@0 | 112 | } |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | #endif |