gfx/2d/PathSkia.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.

     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_PATH_SKIA_H_
     7 #define MOZILLA_GFX_PATH_SKIA_H_
     9 #include "2D.h"
    10 #include "skia/SkPath.h"
    12 namespace mozilla {
    13 namespace gfx {
    15 class PathSkia;
    17 class PathBuilderSkia : public PathBuilder
    18 {
    19 public:
    20   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderSkia)
    21   PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath, FillRule aFillRule);
    22   PathBuilderSkia(FillRule aFillRule);
    24   virtual void MoveTo(const Point &aPoint);
    25   virtual void LineTo(const Point &aPoint);
    26   virtual void BezierTo(const Point &aCP1,
    27                         const Point &aCP2,
    28                         const Point &aCP3);
    29   virtual void QuadraticBezierTo(const Point &aCP1,
    30                                  const Point &aCP2);
    31   virtual void Close();
    32   virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle,
    33                    float aEndAngle, bool aAntiClockwise = false);
    34   virtual Point CurrentPoint() const;
    35   virtual TemporaryRef<Path> Finish();
    37   void AppendPath(const SkPath &aPath);
    39 private:
    41   void SetFillRule(FillRule aFillRule);
    43   SkPath mPath;
    44   FillRule mFillRule;
    45 };
    47 class PathSkia : public Path
    48 {
    49 public:
    50   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathSkia)
    51   PathSkia(SkPath& aPath, FillRule aFillRule)
    52     : mFillRule(aFillRule)
    53   {
    54     mPath.swap(aPath);
    55   }
    57   virtual BackendType GetBackendType() const { return BackendType::SKIA; }
    59   virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
    60   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
    61                                                              FillRule aFillRule = FillRule::FILL_WINDING) const;
    63   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
    65   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
    66                                    const Point &aPoint,
    67                                    const Matrix &aTransform) const;
    69   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
    71   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
    72                                 const Matrix &aTransform = Matrix()) const;
    74   virtual void StreamToSink(PathSink *aSink) const;
    76   virtual FillRule GetFillRule() const { return mFillRule; }
    78   const SkPath& GetPath() const { return mPath; }
    80 private:
    81   friend class DrawTargetSkia;
    83   SkPath mPath;
    84   FillRule mFillRule;
    85 };
    87 }
    88 }
    90 #endif /* MOZILLA_GFX_PATH_SKIA_H_ */

mercurial