2011-06-24 21:41:16 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-06-24 21:41:16 +04:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_PATHD2D_H_
|
|
|
|
#define MOZILLA_GFX_PATHD2D_H_
|
|
|
|
|
2013-07-17 16:12:22 +04:00
|
|
|
#include <d2d1.h>
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
#include "2D.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class PathD2D;
|
|
|
|
|
|
|
|
class PathBuilderD2D : public PathBuilder
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 17:23:37 +04:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderD2D)
|
2015-01-08 03:10:48 +03:00
|
|
|
PathBuilderD2D(ID2D1GeometrySink *aSink, ID2D1PathGeometry *aGeom, FillRule aFillRule, BackendType aBackendType)
|
2011-06-24 21:41:16 +04:00
|
|
|
: mSink(aSink)
|
|
|
|
, mGeometry(aGeom)
|
|
|
|
, mFigureActive(false)
|
|
|
|
, mFillRule(aFillRule)
|
2015-01-08 03:10:48 +03:00
|
|
|
, mBackendType(aBackendType)
|
2011-06-24 21:41:16 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual ~PathBuilderD2D();
|
|
|
|
|
|
|
|
virtual void MoveTo(const Point &aPoint);
|
|
|
|
virtual void LineTo(const Point &aPoint);
|
|
|
|
virtual void BezierTo(const Point &aCP1,
|
|
|
|
const Point &aCP2,
|
|
|
|
const Point &aCP3);
|
|
|
|
virtual void QuadraticBezierTo(const Point &aCP1,
|
|
|
|
const Point &aCP2);
|
|
|
|
virtual void Close();
|
|
|
|
virtual void Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
|
|
|
|
Float aEndAngle, bool aAntiClockwise = false);
|
|
|
|
virtual Point CurrentPoint() const;
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<Path> Finish();
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2015-01-08 03:10:48 +03:00
|
|
|
virtual BackendType GetBackendType() const { return mBackendType; }
|
2014-10-04 15:13:29 +04:00
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
ID2D1GeometrySink *GetSink() { return mSink; }
|
|
|
|
|
2016-05-17 19:47:22 +03:00
|
|
|
bool IsFigureActive() const { return mFigureActive; }
|
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
private:
|
|
|
|
friend class PathD2D;
|
|
|
|
|
|
|
|
void EnsureActive(const Point &aPoint);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ID2D1GeometrySink> mSink;
|
|
|
|
RefPtr<ID2D1PathGeometry> mGeometry;
|
2011-06-24 21:41:16 +04:00
|
|
|
|
|
|
|
bool mFigureActive;
|
|
|
|
Point mCurrentPoint;
|
|
|
|
Point mBeginPoint;
|
|
|
|
FillRule mFillRule;
|
2015-01-08 03:10:48 +03:00
|
|
|
BackendType mBackendType;
|
2011-06-24 21:41:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class PathD2D : public Path
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 17:23:37 +04:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathD2D)
|
2011-06-24 21:41:16 +04:00
|
|
|
PathD2D(ID2D1PathGeometry *aGeometry, bool aEndedActive,
|
2015-01-08 03:10:48 +03:00
|
|
|
const Point &aEndPoint, FillRule aFillRule, BackendType aBackendType)
|
2011-06-24 21:41:16 +04:00
|
|
|
: mGeometry(aGeometry)
|
|
|
|
, mEndedActive(aEndedActive)
|
|
|
|
, mEndPoint(aEndPoint)
|
|
|
|
, mFillRule(aFillRule)
|
2015-01-08 03:10:48 +03:00
|
|
|
, mBackendType(aBackendType)
|
2011-06-24 21:41:16 +04:00
|
|
|
{}
|
|
|
|
|
2015-01-08 03:10:48 +03:00
|
|
|
virtual BackendType GetBackendType() const { return mBackendType; }
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2016-02-08 05:15:54 +03:00
|
|
|
virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule) const;
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
|
2016-02-08 05:15:54 +03:00
|
|
|
FillRule aFillRule) const;
|
2011-06-24 21:41:16 +04:00
|
|
|
|
|
|
|
virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
|
|
|
|
|
2012-10-29 19:54:53 +04:00
|
|
|
virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
|
|
|
|
const Point &aPoint,
|
|
|
|
const Matrix &aTransform) const;
|
|
|
|
|
2011-07-13 04:34:40 +04:00
|
|
|
virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
|
|
|
|
|
|
|
|
virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
|
|
|
|
const Matrix &aTransform = Matrix()) const;
|
|
|
|
|
2013-11-07 13:10:53 +04:00
|
|
|
virtual void StreamToSink(PathSink *aSink) const;
|
2013-11-07 13:10:12 +04:00
|
|
|
|
2011-06-24 21:41:16 +04:00
|
|
|
virtual FillRule GetFillRule() const { return mFillRule; }
|
|
|
|
|
|
|
|
ID2D1Geometry *GetGeometry() { return mGeometry; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class DrawTargetD2D;
|
2013-07-17 16:12:22 +04:00
|
|
|
friend class DrawTargetD2D1;
|
2011-06-24 21:41:16 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
mutable RefPtr<ID2D1PathGeometry> mGeometry;
|
2011-06-24 21:41:16 +04:00
|
|
|
bool mEndedActive;
|
|
|
|
Point mEndPoint;
|
|
|
|
FillRule mFillRule;
|
2015-01-08 03:10:48 +03:00
|
|
|
BackendType mBackendType;
|
2011-06-24 21:41:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_PATHD2D_H_ */
|