1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/effects/Sk1DPathEffect.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,87 @@ 1.4 +/* 1.5 + * Copyright 2006 The Android Open Source Project 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef Sk1DPathEffect_DEFINED 1.12 +#define Sk1DPathEffect_DEFINED 1.13 + 1.14 +#include "SkPathEffect.h" 1.15 +#include "SkPath.h" 1.16 + 1.17 +class SkPathMeasure; 1.18 + 1.19 +// This class is not exported to java. 1.20 +class SK_API Sk1DPathEffect : public SkPathEffect { 1.21 +public: 1.22 + virtual bool filterPath(SkPath* dst, const SkPath& src, 1.23 + SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 1.24 + 1.25 +protected: 1.26 + /** Called at the start of each contour, returns the initial offset 1.27 + into that contour. 1.28 + */ 1.29 + virtual SkScalar begin(SkScalar contourLength) const = 0; 1.30 + /** Called with the current distance along the path, with the current matrix 1.31 + for the point/tangent at the specified distance. 1.32 + Return the distance to travel for the next call. If return <= 0, then that 1.33 + contour is done. 1.34 + */ 1.35 + virtual SkScalar next(SkPath* dst, SkScalar dist, SkPathMeasure&) const = 0; 1.36 + 1.37 +private: 1.38 + typedef SkPathEffect INHERITED; 1.39 +}; 1.40 + 1.41 +class SK_API SkPath1DPathEffect : public Sk1DPathEffect { 1.42 +public: 1.43 + enum Style { 1.44 + kTranslate_Style, // translate the shape to each position 1.45 + kRotate_Style, // rotate the shape about its center 1.46 + kMorph_Style, // transform each point, and turn lines into curves 1.47 + 1.48 + kStyleCount 1.49 + }; 1.50 + 1.51 + /** Dash by replicating the specified path. 1.52 + @param path The path to replicate (dash) 1.53 + @param advance The space between instances of path 1.54 + @param phase distance (mod advance) along path for its initial position 1.55 + @param style how to transform path at each point (based on the current 1.56 + position and tangent) 1.57 + */ 1.58 + static SkPath1DPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, 1.59 + Style style) { 1.60 + return SkNEW_ARGS(SkPath1DPathEffect, (path, advance, phase, style)); 1.61 + } 1.62 + 1.63 + virtual bool filterPath(SkPath*, const SkPath&, 1.64 + SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 1.65 + 1.66 + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect) 1.67 + 1.68 +protected: 1.69 + SkPath1DPathEffect(SkReadBuffer& buffer); 1.70 + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 1.71 + 1.72 + // overrides from Sk1DPathEffect 1.73 + virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE; 1.74 + virtual SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const SK_OVERRIDE; 1.75 + 1.76 +#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS 1.77 +public: 1.78 +#endif 1.79 + SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style); 1.80 + 1.81 +private: 1.82 + SkPath fPath; // copied from constructor 1.83 + SkScalar fAdvance; // copied from constructor 1.84 + SkScalar fInitialOffset; // computed from phase 1.85 + Style fStyle; // copied from constructor 1.86 + 1.87 + typedef Sk1DPathEffect INHERITED; 1.88 +}; 1.89 + 1.90 +#endif