2012-01-10 02:15:10 +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/. */
|
2012-01-10 02:15:10 +04:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_PATH_CAIRO_H_
|
|
|
|
#define MOZILLA_GFX_PATH_CAIRO_H_
|
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
#include "cairo.h"
|
2013-09-28 18:20:24 +04:00
|
|
|
#include <vector>
|
2012-01-10 02:15:10 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
class DrawTargetCairo;
|
2013-09-28 18:20:24 +04:00
|
|
|
class PathCairo;
|
2012-01-10 02:15:10 +04:00
|
|
|
|
|
|
|
class PathBuilderCairo : public PathBuilder
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 17:23:37 +04:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderCairo)
|
2014-08-08 05:17:30 +04:00
|
|
|
explicit PathBuilderCairo(FillRule aFillRule);
|
2012-01-10 02:15:10 +04:00
|
|
|
|
|
|
|
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;
|
|
|
|
virtual TemporaryRef<Path> Finish();
|
|
|
|
|
2014-10-04 15:13:29 +04:00
|
|
|
virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
|
|
|
|
|
2012-01-10 02:15:10 +04:00
|
|
|
private: // data
|
2013-09-28 18:20:24 +04:00
|
|
|
friend class PathCairo;
|
2012-09-04 01:48:04 +04:00
|
|
|
|
2012-01-10 02:15:10 +04:00
|
|
|
FillRule mFillRule;
|
2013-09-28 18:20:24 +04:00
|
|
|
std::vector<cairo_path_data_t> mPathData;
|
|
|
|
// It's easiest to track this here, parsing the path data to find the current
|
|
|
|
// point is a little tricky.
|
|
|
|
Point mCurrentPoint;
|
|
|
|
Point mBeginPoint;
|
2012-01-10 02:15:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class PathCairo : public Path
|
|
|
|
{
|
|
|
|
public:
|
2014-02-24 17:23:37 +04:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathCairo)
|
2013-09-28 18:20:24 +04:00
|
|
|
PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t> &aPathData, const Point &aCurrentPoint);
|
2014-08-08 05:17:30 +04:00
|
|
|
explicit PathCairo(cairo_t *aContext);
|
2013-09-28 18:20:24 +04:00
|
|
|
~PathCairo();
|
2012-01-10 02:15:10 +04:00
|
|
|
|
2014-01-10 23:06:16 +04:00
|
|
|
virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
|
2012-01-10 02:15:10 +04:00
|
|
|
|
2014-01-10 23:06:17 +04:00
|
|
|
virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
|
2012-01-10 02:15:10 +04:00
|
|
|
virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
|
2014-01-10 23:06:17 +04:00
|
|
|
FillRule aFillRule = FillRule::FILL_WINDING) const;
|
2012-01-10 02:15:10 +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;
|
|
|
|
|
2012-01-10 02:15:10 +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:11:26 +04:00
|
|
|
virtual void StreamToSink(PathSink *aSink) const;
|
2013-11-07 13:10:12 +04:00
|
|
|
|
2012-01-10 02:15:10 +04:00
|
|
|
virtual FillRule GetFillRule() const { return mFillRule; }
|
|
|
|
|
2013-09-28 18:20:24 +04:00
|
|
|
void SetPathOnContext(cairo_t *aContext) const;
|
2012-01-10 02:15:10 +04:00
|
|
|
|
2013-09-28 18:20:24 +04:00
|
|
|
void AppendPathToBuilder(PathBuilderCairo *aBuilder, const Matrix *aTransform = nullptr) const;
|
2012-01-10 02:15:10 +04:00
|
|
|
private:
|
2013-09-28 18:20:24 +04:00
|
|
|
void EnsureContainingContext() const;
|
|
|
|
|
2012-01-10 02:15:10 +04:00
|
|
|
FillRule mFillRule;
|
2013-09-28 18:20:24 +04:00
|
|
|
std::vector<cairo_path_data_t> mPathData;
|
|
|
|
mutable cairo_t *mContainingContext;
|
|
|
|
Point mCurrentPoint;
|
2012-01-10 02:15:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_PATH_CAIRO_H_ */
|