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_PATHD2D_H_ |
michael@0 | 7 | #define MOZILLA_GFX_PATHD2D_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include <d2d1.h> |
michael@0 | 10 | |
michael@0 | 11 | #include "2D.h" |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace gfx { |
michael@0 | 15 | |
michael@0 | 16 | class PathD2D; |
michael@0 | 17 | |
michael@0 | 18 | class PathBuilderD2D : public PathBuilder |
michael@0 | 19 | { |
michael@0 | 20 | public: |
michael@0 | 21 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderD2D) |
michael@0 | 22 | PathBuilderD2D(ID2D1GeometrySink *aSink, ID2D1PathGeometry *aGeom, FillRule aFillRule) |
michael@0 | 23 | : mSink(aSink) |
michael@0 | 24 | , mGeometry(aGeom) |
michael@0 | 25 | , mFigureActive(false) |
michael@0 | 26 | , mFillRule(aFillRule) |
michael@0 | 27 | { |
michael@0 | 28 | } |
michael@0 | 29 | virtual ~PathBuilderD2D(); |
michael@0 | 30 | |
michael@0 | 31 | virtual void MoveTo(const Point &aPoint); |
michael@0 | 32 | virtual void LineTo(const Point &aPoint); |
michael@0 | 33 | virtual void BezierTo(const Point &aCP1, |
michael@0 | 34 | const Point &aCP2, |
michael@0 | 35 | const Point &aCP3); |
michael@0 | 36 | virtual void QuadraticBezierTo(const Point &aCP1, |
michael@0 | 37 | const Point &aCP2); |
michael@0 | 38 | virtual void Close(); |
michael@0 | 39 | virtual void Arc(const Point &aOrigin, Float aRadius, Float aStartAngle, |
michael@0 | 40 | Float aEndAngle, bool aAntiClockwise = false); |
michael@0 | 41 | virtual Point CurrentPoint() const; |
michael@0 | 42 | |
michael@0 | 43 | virtual TemporaryRef<Path> Finish(); |
michael@0 | 44 | |
michael@0 | 45 | ID2D1GeometrySink *GetSink() { return mSink; } |
michael@0 | 46 | |
michael@0 | 47 | private: |
michael@0 | 48 | friend class PathD2D; |
michael@0 | 49 | |
michael@0 | 50 | void EnsureActive(const Point &aPoint); |
michael@0 | 51 | |
michael@0 | 52 | RefPtr<ID2D1GeometrySink> mSink; |
michael@0 | 53 | RefPtr<ID2D1PathGeometry> mGeometry; |
michael@0 | 54 | |
michael@0 | 55 | bool mFigureActive; |
michael@0 | 56 | Point mCurrentPoint; |
michael@0 | 57 | Point mBeginPoint; |
michael@0 | 58 | FillRule mFillRule; |
michael@0 | 59 | }; |
michael@0 | 60 | |
michael@0 | 61 | class PathD2D : public Path |
michael@0 | 62 | { |
michael@0 | 63 | public: |
michael@0 | 64 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathD2D) |
michael@0 | 65 | PathD2D(ID2D1PathGeometry *aGeometry, bool aEndedActive, |
michael@0 | 66 | const Point &aEndPoint, FillRule aFillRule) |
michael@0 | 67 | : mGeometry(aGeometry) |
michael@0 | 68 | , mEndedActive(aEndedActive) |
michael@0 | 69 | , mEndPoint(aEndPoint) |
michael@0 | 70 | , mFillRule(aFillRule) |
michael@0 | 71 | {} |
michael@0 | 72 | |
michael@0 | 73 | virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; } |
michael@0 | 74 | |
michael@0 | 75 | virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const; |
michael@0 | 76 | virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform, |
michael@0 | 77 | FillRule aFillRule = FillRule::FILL_WINDING) const; |
michael@0 | 78 | |
michael@0 | 79 | virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const; |
michael@0 | 80 | |
michael@0 | 81 | virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions, |
michael@0 | 82 | const Point &aPoint, |
michael@0 | 83 | const Matrix &aTransform) const; |
michael@0 | 84 | |
michael@0 | 85 | virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const; |
michael@0 | 86 | |
michael@0 | 87 | virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions, |
michael@0 | 88 | const Matrix &aTransform = Matrix()) const; |
michael@0 | 89 | |
michael@0 | 90 | virtual void StreamToSink(PathSink *aSink) const; |
michael@0 | 91 | |
michael@0 | 92 | virtual FillRule GetFillRule() const { return mFillRule; } |
michael@0 | 93 | |
michael@0 | 94 | ID2D1Geometry *GetGeometry() { return mGeometry; } |
michael@0 | 95 | |
michael@0 | 96 | private: |
michael@0 | 97 | friend class DrawTargetD2D; |
michael@0 | 98 | friend class DrawTargetD2D1; |
michael@0 | 99 | |
michael@0 | 100 | mutable RefPtr<ID2D1PathGeometry> mGeometry; |
michael@0 | 101 | bool mEndedActive; |
michael@0 | 102 | Point mEndPoint; |
michael@0 | 103 | FillRule mFillRule; |
michael@0 | 104 | }; |
michael@0 | 105 | |
michael@0 | 106 | } |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | #endif /* MOZILLA_GFX_PATHD2D_H_ */ |