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_PATH_CAIRO_H_ |
michael@0 | 7 | #define MOZILLA_GFX_PATH_CAIRO_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "2D.h" |
michael@0 | 10 | #include "cairo.h" |
michael@0 | 11 | #include <vector> |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace gfx { |
michael@0 | 15 | |
michael@0 | 16 | class DrawTargetCairo; |
michael@0 | 17 | class PathCairo; |
michael@0 | 18 | |
michael@0 | 19 | class PathBuilderCairo : public PathBuilder |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderCairo) |
michael@0 | 23 | PathBuilderCairo(FillRule aFillRule); |
michael@0 | 24 | |
michael@0 | 25 | virtual void MoveTo(const Point &aPoint); |
michael@0 | 26 | virtual void LineTo(const Point &aPoint); |
michael@0 | 27 | virtual void BezierTo(const Point &aCP1, |
michael@0 | 28 | const Point &aCP2, |
michael@0 | 29 | const Point &aCP3); |
michael@0 | 30 | virtual void QuadraticBezierTo(const Point &aCP1, |
michael@0 | 31 | const Point &aCP2); |
michael@0 | 32 | virtual void Close(); |
michael@0 | 33 | virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle, |
michael@0 | 34 | float aEndAngle, bool aAntiClockwise = false); |
michael@0 | 35 | virtual Point CurrentPoint() const; |
michael@0 | 36 | virtual TemporaryRef<Path> Finish(); |
michael@0 | 37 | |
michael@0 | 38 | private: // data |
michael@0 | 39 | friend class PathCairo; |
michael@0 | 40 | |
michael@0 | 41 | FillRule mFillRule; |
michael@0 | 42 | std::vector<cairo_path_data_t> mPathData; |
michael@0 | 43 | // It's easiest to track this here, parsing the path data to find the current |
michael@0 | 44 | // point is a little tricky. |
michael@0 | 45 | Point mCurrentPoint; |
michael@0 | 46 | Point mBeginPoint; |
michael@0 | 47 | }; |
michael@0 | 48 | |
michael@0 | 49 | class PathCairo : public Path |
michael@0 | 50 | { |
michael@0 | 51 | public: |
michael@0 | 52 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCairo) |
michael@0 | 53 | PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t> &aPathData, const Point &aCurrentPoint); |
michael@0 | 54 | PathCairo(cairo_t *aContext); |
michael@0 | 55 | ~PathCairo(); |
michael@0 | 56 | |
michael@0 | 57 | virtual BackendType GetBackendType() const { return BackendType::CAIRO; } |
michael@0 | 58 | |
michael@0 | 59 | virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const; |
michael@0 | 60 | virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform, |
michael@0 | 61 | FillRule aFillRule = FillRule::FILL_WINDING) const; |
michael@0 | 62 | |
michael@0 | 63 | virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const; |
michael@0 | 64 | |
michael@0 | 65 | virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions, |
michael@0 | 66 | const Point &aPoint, |
michael@0 | 67 | const Matrix &aTransform) const; |
michael@0 | 68 | |
michael@0 | 69 | virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const; |
michael@0 | 70 | |
michael@0 | 71 | virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions, |
michael@0 | 72 | const Matrix &aTransform = Matrix()) const; |
michael@0 | 73 | |
michael@0 | 74 | virtual void StreamToSink(PathSink *aSink) const; |
michael@0 | 75 | |
michael@0 | 76 | virtual FillRule GetFillRule() const { return mFillRule; } |
michael@0 | 77 | |
michael@0 | 78 | void SetPathOnContext(cairo_t *aContext) const; |
michael@0 | 79 | |
michael@0 | 80 | void AppendPathToBuilder(PathBuilderCairo *aBuilder, const Matrix *aTransform = nullptr) const; |
michael@0 | 81 | private: |
michael@0 | 82 | void EnsureContainingContext() const; |
michael@0 | 83 | |
michael@0 | 84 | FillRule mFillRule; |
michael@0 | 85 | std::vector<cairo_path_data_t> mPathData; |
michael@0 | 86 | mutable cairo_t *mContainingContext; |
michael@0 | 87 | Point mCurrentPoint; |
michael@0 | 88 | }; |
michael@0 | 89 | |
michael@0 | 90 | } |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | #endif /* MOZILLA_GFX_PATH_CAIRO_H_ */ |