michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_GFX_PATH_SKIA_H_ michael@0: #define MOZILLA_GFX_PATH_SKIA_H_ michael@0: michael@0: #include "2D.h" michael@0: #include "skia/SkPath.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: class PathSkia; michael@0: michael@0: class PathBuilderSkia : public PathBuilder michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderSkia) michael@0: PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath, FillRule aFillRule); michael@0: PathBuilderSkia(FillRule aFillRule); michael@0: michael@0: virtual void MoveTo(const Point &aPoint); michael@0: virtual void LineTo(const Point &aPoint); michael@0: virtual void BezierTo(const Point &aCP1, michael@0: const Point &aCP2, michael@0: const Point &aCP3); michael@0: virtual void QuadraticBezierTo(const Point &aCP1, michael@0: const Point &aCP2); michael@0: virtual void Close(); michael@0: virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle, michael@0: float aEndAngle, bool aAntiClockwise = false); michael@0: virtual Point CurrentPoint() const; michael@0: virtual TemporaryRef Finish(); michael@0: michael@0: void AppendPath(const SkPath &aPath); michael@0: michael@0: private: michael@0: michael@0: void SetFillRule(FillRule aFillRule); michael@0: michael@0: SkPath mPath; michael@0: FillRule mFillRule; michael@0: }; michael@0: michael@0: class PathSkia : public Path michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathSkia) michael@0: PathSkia(SkPath& aPath, FillRule aFillRule) michael@0: : mFillRule(aFillRule) michael@0: { michael@0: mPath.swap(aPath); michael@0: } michael@0: michael@0: virtual BackendType GetBackendType() const { return BackendType::SKIA; } michael@0: michael@0: virtual TemporaryRef CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const; michael@0: virtual TemporaryRef TransformedCopyToBuilder(const Matrix &aTransform, michael@0: FillRule aFillRule = FillRule::FILL_WINDING) const; michael@0: michael@0: virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const; michael@0: michael@0: virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions, michael@0: const Point &aPoint, michael@0: const Matrix &aTransform) const; michael@0: michael@0: virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const; michael@0: michael@0: virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions, michael@0: const Matrix &aTransform = Matrix()) const; michael@0: michael@0: virtual void StreamToSink(PathSink *aSink) const; michael@0: michael@0: virtual FillRule GetFillRule() const { return mFillRule; } michael@0: michael@0: const SkPath& GetPath() const { return mPath; } michael@0: michael@0: private: michael@0: friend class DrawTargetSkia; michael@0: michael@0: SkPath mPath; michael@0: FillRule mFillRule; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /* MOZILLA_GFX_PATH_SKIA_H_ */