1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/2d/PathSkia.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 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_PATH_SKIA_H_ 1.10 +#define MOZILLA_GFX_PATH_SKIA_H_ 1.11 + 1.12 +#include "2D.h" 1.13 +#include "skia/SkPath.h" 1.14 + 1.15 +namespace mozilla { 1.16 +namespace gfx { 1.17 + 1.18 +class PathSkia; 1.19 + 1.20 +class PathBuilderSkia : public PathBuilder 1.21 +{ 1.22 +public: 1.23 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderSkia) 1.24 + PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath, FillRule aFillRule); 1.25 + PathBuilderSkia(FillRule aFillRule); 1.26 + 1.27 + virtual void MoveTo(const Point &aPoint); 1.28 + virtual void LineTo(const Point &aPoint); 1.29 + virtual void BezierTo(const Point &aCP1, 1.30 + const Point &aCP2, 1.31 + const Point &aCP3); 1.32 + virtual void QuadraticBezierTo(const Point &aCP1, 1.33 + const Point &aCP2); 1.34 + virtual void Close(); 1.35 + virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle, 1.36 + float aEndAngle, bool aAntiClockwise = false); 1.37 + virtual Point CurrentPoint() const; 1.38 + virtual TemporaryRef<Path> Finish(); 1.39 + 1.40 + void AppendPath(const SkPath &aPath); 1.41 + 1.42 +private: 1.43 + 1.44 + void SetFillRule(FillRule aFillRule); 1.45 + 1.46 + SkPath mPath; 1.47 + FillRule mFillRule; 1.48 +}; 1.49 + 1.50 +class PathSkia : public Path 1.51 +{ 1.52 +public: 1.53 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathSkia) 1.54 + PathSkia(SkPath& aPath, FillRule aFillRule) 1.55 + : mFillRule(aFillRule) 1.56 + { 1.57 + mPath.swap(aPath); 1.58 + } 1.59 + 1.60 + virtual BackendType GetBackendType() const { return BackendType::SKIA; } 1.61 + 1.62 + virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const; 1.63 + virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform, 1.64 + FillRule aFillRule = FillRule::FILL_WINDING) const; 1.65 + 1.66 + virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const; 1.67 + 1.68 + virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions, 1.69 + const Point &aPoint, 1.70 + const Matrix &aTransform) const; 1.71 + 1.72 + virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const; 1.73 + 1.74 + virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions, 1.75 + const Matrix &aTransform = Matrix()) const; 1.76 + 1.77 + virtual void StreamToSink(PathSink *aSink) const; 1.78 + 1.79 + virtual FillRule GetFillRule() const { return mFillRule; } 1.80 + 1.81 + const SkPath& GetPath() const { return mPath; } 1.82 + 1.83 +private: 1.84 + friend class DrawTargetSkia; 1.85 + 1.86 + SkPath mPath; 1.87 + FillRule mFillRule; 1.88 +}; 1.89 + 1.90 +} 1.91 +} 1.92 + 1.93 +#endif /* MOZILLA_GFX_PATH_SKIA_H_ */