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.
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_GFX_PATHCG_H_
7 #define MOZILLA_GFX_PATHCG_H_
9 #include <ApplicationServices/ApplicationServices.h>
10 #include "2D.h"
12 namespace mozilla {
13 namespace gfx {
15 class PathCG;
17 class PathBuilderCG : public PathBuilder
18 {
19 public:
20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderCG)
21 // absorbs a reference of aPath
22 PathBuilderCG(CGMutablePathRef aPath, FillRule aFillRule)
23 : mFillRule(aFillRule)
24 {
25 mCGPath = aPath;
26 }
28 PathBuilderCG(FillRule aFillRule)
29 : mFillRule(aFillRule)
30 {
31 mCGPath = CGPathCreateMutable();
32 }
34 virtual ~PathBuilderCG();
36 virtual void MoveTo(const Point &aPoint);
37 virtual void LineTo(const Point &aPoint);
38 virtual void BezierTo(const Point &aCP1,
39 const Point &aCP2,
40 const Point &aCP3);
41 virtual void QuadraticBezierTo(const Point &aCP1,
42 const Point &aCP2);
43 virtual void Close();
44 virtual void Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
45 Float aEndAngle, bool aAntiClockwise = false);
46 virtual Point CurrentPoint() const;
48 virtual TemporaryRef<Path> Finish();
50 private:
51 friend class PathCG;
52 friend class ScaledFontMac;
54 void EnsureActive(const Point &aPoint);
56 CGMutablePathRef mCGPath;
57 Point mCurrentPoint;
58 Point mBeginPoint;
59 FillRule mFillRule;
60 };
62 class PathCG : public Path
63 {
64 public:
65 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCG)
66 PathCG(CGMutablePathRef aPath, FillRule aFillRule)
67 : mPath(aPath)
68 , mFillRule(aFillRule)
69 {
70 CGPathRetain(mPath);
71 }
72 virtual ~PathCG() { CGPathRelease(mPath); }
74 // Paths will always return BackendType::COREGRAPHICS, but note that they
75 // are compatible with BackendType::COREGRAPHICS_ACCELERATED backend.
76 virtual BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
78 virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
79 virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
80 FillRule aFillRule = FillRule::FILL_WINDING) const;
82 virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
83 virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
84 const Point &aPoint,
85 const Matrix &aTransform) const;
86 virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
87 virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
88 const Matrix &aTransform = Matrix()) const;
90 virtual void StreamToSink(PathSink *aSink) const;
92 virtual FillRule GetFillRule() const { return mFillRule; }
94 CGMutablePathRef GetPath() const { return mPath; }
96 private:
97 friend class DrawTargetCG;
99 CGMutablePathRef mPath;
100 Point mEndPoint;
101 FillRule mFillRule;
102 };
104 }
105 }
107 #endif