gfx/2d/PathCG.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_PATHCG_H_
michael@0 7 #define MOZILLA_GFX_PATHCG_H_
michael@0 8
michael@0 9 #include <ApplicationServices/ApplicationServices.h>
michael@0 10 #include "2D.h"
michael@0 11
michael@0 12 namespace mozilla {
michael@0 13 namespace gfx {
michael@0 14
michael@0 15 class PathCG;
michael@0 16
michael@0 17 class PathBuilderCG : public PathBuilder
michael@0 18 {
michael@0 19 public:
michael@0 20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderCG)
michael@0 21 // absorbs a reference of aPath
michael@0 22 PathBuilderCG(CGMutablePathRef aPath, FillRule aFillRule)
michael@0 23 : mFillRule(aFillRule)
michael@0 24 {
michael@0 25 mCGPath = aPath;
michael@0 26 }
michael@0 27
michael@0 28 PathBuilderCG(FillRule aFillRule)
michael@0 29 : mFillRule(aFillRule)
michael@0 30 {
michael@0 31 mCGPath = CGPathCreateMutable();
michael@0 32 }
michael@0 33
michael@0 34 virtual ~PathBuilderCG();
michael@0 35
michael@0 36 virtual void MoveTo(const Point &aPoint);
michael@0 37 virtual void LineTo(const Point &aPoint);
michael@0 38 virtual void BezierTo(const Point &aCP1,
michael@0 39 const Point &aCP2,
michael@0 40 const Point &aCP3);
michael@0 41 virtual void QuadraticBezierTo(const Point &aCP1,
michael@0 42 const Point &aCP2);
michael@0 43 virtual void Close();
michael@0 44 virtual void Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
michael@0 45 Float aEndAngle, bool aAntiClockwise = false);
michael@0 46 virtual Point CurrentPoint() const;
michael@0 47
michael@0 48 virtual TemporaryRef<Path> Finish();
michael@0 49
michael@0 50 private:
michael@0 51 friend class PathCG;
michael@0 52 friend class ScaledFontMac;
michael@0 53
michael@0 54 void EnsureActive(const Point &aPoint);
michael@0 55
michael@0 56 CGMutablePathRef mCGPath;
michael@0 57 Point mCurrentPoint;
michael@0 58 Point mBeginPoint;
michael@0 59 FillRule mFillRule;
michael@0 60 };
michael@0 61
michael@0 62 class PathCG : public Path
michael@0 63 {
michael@0 64 public:
michael@0 65 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCG)
michael@0 66 PathCG(CGMutablePathRef aPath, FillRule aFillRule)
michael@0 67 : mPath(aPath)
michael@0 68 , mFillRule(aFillRule)
michael@0 69 {
michael@0 70 CGPathRetain(mPath);
michael@0 71 }
michael@0 72 virtual ~PathCG() { CGPathRelease(mPath); }
michael@0 73
michael@0 74 // Paths will always return BackendType::COREGRAPHICS, but note that they
michael@0 75 // are compatible with BackendType::COREGRAPHICS_ACCELERATED backend.
michael@0 76 virtual BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
michael@0 77
michael@0 78 virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
michael@0 79 virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
michael@0 80 FillRule aFillRule = FillRule::FILL_WINDING) const;
michael@0 81
michael@0 82 virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
michael@0 83 virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
michael@0 84 const Point &aPoint,
michael@0 85 const Matrix &aTransform) const;
michael@0 86 virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
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 CGMutablePathRef GetPath() const { return mPath; }
michael@0 95
michael@0 96 private:
michael@0 97 friend class DrawTargetCG;
michael@0 98
michael@0 99 CGMutablePathRef mPath;
michael@0 100 Point mEndPoint;
michael@0 101 FillRule mFillRule;
michael@0 102 };
michael@0 103
michael@0 104 }
michael@0 105 }
michael@0 106
michael@0 107 #endif

mercurial