gfx/2d/PathD2D.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/2d/PathD2D.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef MOZILLA_GFX_PATHD2D_H_
    1.10 +#define MOZILLA_GFX_PATHD2D_H_
    1.11 +
    1.12 +#include <d2d1.h>
    1.13 +
    1.14 +#include "2D.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace gfx {
    1.18 +
    1.19 +class PathD2D;
    1.20 +
    1.21 +class PathBuilderD2D : public PathBuilder
    1.22 +{
    1.23 +public:
    1.24 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderD2D)
    1.25 +  PathBuilderD2D(ID2D1GeometrySink *aSink, ID2D1PathGeometry *aGeom, FillRule aFillRule)
    1.26 +    : mSink(aSink)
    1.27 +    , mGeometry(aGeom)
    1.28 +    , mFigureActive(false)
    1.29 +    , mFillRule(aFillRule)
    1.30 +  {
    1.31 +  }
    1.32 +  virtual ~PathBuilderD2D();
    1.33 +
    1.34 +  virtual void MoveTo(const Point &aPoint);
    1.35 +  virtual void LineTo(const Point &aPoint);
    1.36 +  virtual void BezierTo(const Point &aCP1,
    1.37 +                        const Point &aCP2,
    1.38 +                        const Point &aCP3);
    1.39 +  virtual void QuadraticBezierTo(const Point &aCP1,
    1.40 +                                 const Point &aCP2);
    1.41 +  virtual void Close();
    1.42 +  virtual void Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
    1.43 +                   Float aEndAngle, bool aAntiClockwise = false);
    1.44 +  virtual Point CurrentPoint() const;
    1.45 +
    1.46 +  virtual TemporaryRef<Path> Finish();
    1.47 +
    1.48 +  ID2D1GeometrySink *GetSink() { return mSink; }
    1.49 +
    1.50 +private:
    1.51 +  friend class PathD2D;
    1.52 +
    1.53 +  void EnsureActive(const Point &aPoint);
    1.54 +
    1.55 +  RefPtr<ID2D1GeometrySink> mSink;
    1.56 +  RefPtr<ID2D1PathGeometry> mGeometry;
    1.57 +
    1.58 +  bool mFigureActive;
    1.59 +  Point mCurrentPoint;
    1.60 +  Point mBeginPoint;
    1.61 +  FillRule mFillRule;
    1.62 +};
    1.63 +
    1.64 +class PathD2D : public Path
    1.65 +{
    1.66 +public:
    1.67 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathD2D)
    1.68 +  PathD2D(ID2D1PathGeometry *aGeometry, bool aEndedActive,
    1.69 +          const Point &aEndPoint, FillRule aFillRule)
    1.70 +    : mGeometry(aGeometry)
    1.71 +    , mEndedActive(aEndedActive)
    1.72 +    , mEndPoint(aEndPoint)
    1.73 +    , mFillRule(aFillRule)
    1.74 +  {}
    1.75 +  
    1.76 +  virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; }
    1.77 +
    1.78 +  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
    1.79 +  virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
    1.80 +                                                             FillRule aFillRule = FillRule::FILL_WINDING) const;
    1.81 +
    1.82 +  virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
    1.83 +
    1.84 +  virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
    1.85 +                                   const Point &aPoint,
    1.86 +                                   const Matrix &aTransform) const;
    1.87 +
    1.88 +  virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
    1.89 +
    1.90 +  virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
    1.91 +                                const Matrix &aTransform = Matrix()) const;
    1.92 +
    1.93 +  virtual void StreamToSink(PathSink *aSink) const;
    1.94 +
    1.95 +  virtual FillRule GetFillRule() const { return mFillRule; }
    1.96 +
    1.97 +  ID2D1Geometry *GetGeometry() { return mGeometry; }
    1.98 +
    1.99 +private:
   1.100 +  friend class DrawTargetD2D;
   1.101 +  friend class DrawTargetD2D1;
   1.102 +
   1.103 +  mutable RefPtr<ID2D1PathGeometry> mGeometry;
   1.104 +  bool mEndedActive;
   1.105 +  Point mEndPoint;
   1.106 +  FillRule mFillRule;
   1.107 +};
   1.108 +
   1.109 +}
   1.110 +}
   1.111 +
   1.112 +#endif /* MOZILLA_GFX_PATHD2D_H_ */

mercurial