2011-06-24 17:41:16 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 11:12:37 +00: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 17:41:16 +00:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_PATHD2D_H_
|
|
|
|
#define MOZILLA_GFX_PATHD2D_H_
|
|
|
|
|
2013-07-17 12:12:22 +00:00
|
|
|
#include <d2d1.h>
|
|
|
|
|
2011-06-24 17:41:16 +00:00
|
|
|
#include "2D.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class PathD2D;
|
|
|
|
|
|
|
|
class PathBuilderD2D : public PathBuilder
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 13:23:37 +00:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderD2D)
|
2015-01-08 00:10:48 +00:00
|
|
|
PathBuilderD2D(ID2D1GeometrySink *aSink, ID2D1PathGeometry *aGeom, FillRule aFillRule, BackendType aBackendType)
|
2011-06-24 17:41:16 +00:00
|
|
|
: mSink(aSink)
|
|
|
|
, mGeometry(aGeom)
|
|
|
|
, mFigureActive(false)
|
|
|
|
, mFillRule(aFillRule)
|
2015-01-08 00:10:48 +00:00
|
|
|
, mBackendType(aBackendType)
|
2011-06-24 17:41:16 +00: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 14:00:52 +00:00
|
|
|
virtual already_AddRefed<Path> Finish();
|
2011-06-24 17:41:16 +00:00
|
|
|
|
2015-01-08 00:10:48 +00:00
|
|
|
virtual BackendType GetBackendType() const { return mBackendType; }
|
2014-10-04 11:13:29 +00:00
|
|
|
|
2011-06-24 17:41:16 +00:00
|
|
|
ID2D1GeometrySink *GetSink() { return mSink; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class PathD2D;
|
|
|
|
|
|
|
|
void EnsureActive(const Point &aPoint);
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<ID2D1GeometrySink> mSink;
|
|
|
|
RefPtr<ID2D1PathGeometry> mGeometry;
|
2011-06-24 17:41:16 +00:00
|
|
|
|
|
|
|
bool mFigureActive;
|
|
|
|
Point mCurrentPoint;
|
|
|
|
Point mBeginPoint;
|
|
|
|
FillRule mFillRule;
|
2015-01-08 00:10:48 +00:00
|
|
|
BackendType mBackendType;
|
2011-06-24 17:41:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PathD2D : public Path
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 13:23:37 +00:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathD2D)
|
2011-06-24 17:41:16 +00:00
|
|
|
PathD2D(ID2D1PathGeometry *aGeometry, bool aEndedActive,
|
2015-01-08 00:10:48 +00:00
|
|
|
const Point &aEndPoint, FillRule aFillRule, BackendType aBackendType)
|
2011-06-24 17:41:16 +00:00
|
|
|
: mGeometry(aGeometry)
|
|
|
|
, mEndedActive(aEndedActive)
|
|
|
|
, mEndPoint(aEndPoint)
|
|
|
|
, mFillRule(aFillRule)
|
2015-01-08 00:10:48 +00:00
|
|
|
, mBackendType(aBackendType)
|
2011-06-24 17:41:16 +00:00
|
|
|
{}
|
|
|
|
|
2015-01-08 00:10:48 +00:00
|
|
|
virtual BackendType GetBackendType() const { return mBackendType; }
|
2011-06-24 17:41:16 +00:00
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
|
|
|
|
virtual already_AddRefed<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
|
2014-01-10 19:06:17 +00:00
|
|
|
FillRule aFillRule = FillRule::FILL_WINDING) const;
|
2011-06-24 17:41:16 +00:00
|
|
|
|
|
|
|
virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
|
|
|
|
|
2012-10-29 15:54:53 +00:00
|
|
|
virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
|
|
|
|
const Point &aPoint,
|
|
|
|
const Matrix &aTransform) const;
|
|
|
|
|
2011-07-13 00:34:40 +00:00
|
|
|
virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
|
|
|
|
|
|
|
|
virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
|
|
|
|
const Matrix &aTransform = Matrix()) const;
|
|
|
|
|
2013-11-07 09:10:53 +00:00
|
|
|
virtual void StreamToSink(PathSink *aSink) const;
|
2013-11-07 09:10:12 +00:00
|
|
|
|
2011-06-24 17:41:16 +00:00
|
|
|
virtual FillRule GetFillRule() const { return mFillRule; }
|
|
|
|
|
|
|
|
ID2D1Geometry *GetGeometry() { return mGeometry; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class DrawTargetD2D;
|
2013-07-17 12:12:22 +00:00
|
|
|
friend class DrawTargetD2D1;
|
2011-06-24 17:41:16 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
mutable RefPtr<ID2D1PathGeometry> mGeometry;
|
2011-06-24 17:41:16 +00:00
|
|
|
bool mEndedActive;
|
|
|
|
Point mEndPoint;
|
|
|
|
FillRule mFillRule;
|
2015-01-08 00:10:48 +00:00
|
|
|
BackendType mBackendType;
|
2011-06-24 17:41:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_PATHD2D_H_ */
|