michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef Sk2DPathEffect_DEFINED michael@0: #define Sk2DPathEffect_DEFINED michael@0: michael@0: #include "SkPath.h" michael@0: #include "SkPathEffect.h" michael@0: #include "SkMatrix.h" michael@0: michael@0: class SK_API Sk2DPathEffect : public SkPathEffect { michael@0: public: michael@0: static Sk2DPathEffect* Create(const SkMatrix& mat) { michael@0: return SkNEW_ARGS(Sk2DPathEffect, (mat)); michael@0: } michael@0: michael@0: virtual bool filterPath(SkPath*, const SkPath&, michael@0: SkStrokeRec*, const SkRect*) const SK_OVERRIDE; michael@0: michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect) michael@0: michael@0: protected: michael@0: /** New virtual, to be overridden by subclasses. michael@0: This is called once from filterPath, and provides the michael@0: uv parameter bounds for the path. Subsequent calls to michael@0: next() will receive u and v values within these bounds, michael@0: and then a call to end() will signal the end of processing. michael@0: */ michael@0: virtual void begin(const SkIRect& uvBounds, SkPath* dst) const; michael@0: virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const; michael@0: virtual void end(SkPath* dst) const; michael@0: michael@0: /** Low-level virtual called per span of locations in the u-direction. michael@0: The default implementation calls next() repeatedly with each michael@0: location. michael@0: */ michael@0: virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const; michael@0: michael@0: const SkMatrix& getMatrix() const { return fMatrix; } michael@0: michael@0: // protected so that subclasses can call this during unflattening michael@0: Sk2DPathEffect(SkReadBuffer&); michael@0: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; michael@0: michael@0: #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS michael@0: public: michael@0: #endif michael@0: Sk2DPathEffect(const SkMatrix& mat); michael@0: michael@0: private: michael@0: SkMatrix fMatrix, fInverse; michael@0: bool fMatrixIsInvertible; michael@0: michael@0: // illegal michael@0: Sk2DPathEffect(const Sk2DPathEffect&); michael@0: Sk2DPathEffect& operator=(const Sk2DPathEffect&); michael@0: michael@0: friend class Sk2DPathEffectBlitter; michael@0: typedef SkPathEffect INHERITED; michael@0: }; michael@0: michael@0: class SK_API SkLine2DPathEffect : public Sk2DPathEffect { michael@0: public: michael@0: static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) { michael@0: return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix)); michael@0: } michael@0: michael@0: virtual bool filterPath(SkPath* dst, const SkPath& src, michael@0: SkStrokeRec*, const SkRect*) const SK_OVERRIDE; michael@0: michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) michael@0: michael@0: protected: michael@0: virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; michael@0: michael@0: SkLine2DPathEffect(SkReadBuffer&); michael@0: michael@0: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; michael@0: michael@0: #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS michael@0: public: michael@0: #endif michael@0: SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) michael@0: : Sk2DPathEffect(matrix), fWidth(width) {} michael@0: michael@0: private: michael@0: SkScalar fWidth; michael@0: michael@0: typedef Sk2DPathEffect INHERITED; michael@0: }; michael@0: michael@0: class SK_API SkPath2DPathEffect : public Sk2DPathEffect { michael@0: public: michael@0: /** michael@0: * Stamp the specified path to fill the shape, using the matrix to define michael@0: * the latice. michael@0: */ michael@0: static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) { michael@0: return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path)); michael@0: } michael@0: michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) michael@0: michael@0: protected: michael@0: SkPath2DPathEffect(SkReadBuffer& buffer); michael@0: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; michael@0: michael@0: virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; michael@0: michael@0: #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS michael@0: public: michael@0: #endif michael@0: SkPath2DPathEffect(const SkMatrix&, const SkPath&); michael@0: michael@0: private: michael@0: SkPath fPath; michael@0: michael@0: typedef Sk2DPathEffect INHERITED; michael@0: }; michael@0: michael@0: #endif