gfx/skia/trunk/include/effects/Sk1DPathEffect.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright 2006 The Android Open Source Project
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef Sk1DPathEffect_DEFINED
michael@0 9 #define Sk1DPathEffect_DEFINED
michael@0 10
michael@0 11 #include "SkPathEffect.h"
michael@0 12 #include "SkPath.h"
michael@0 13
michael@0 14 class SkPathMeasure;
michael@0 15
michael@0 16 // This class is not exported to java.
michael@0 17 class SK_API Sk1DPathEffect : public SkPathEffect {
michael@0 18 public:
michael@0 19 virtual bool filterPath(SkPath* dst, const SkPath& src,
michael@0 20 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
michael@0 21
michael@0 22 protected:
michael@0 23 /** Called at the start of each contour, returns the initial offset
michael@0 24 into that contour.
michael@0 25 */
michael@0 26 virtual SkScalar begin(SkScalar contourLength) const = 0;
michael@0 27 /** Called with the current distance along the path, with the current matrix
michael@0 28 for the point/tangent at the specified distance.
michael@0 29 Return the distance to travel for the next call. If return <= 0, then that
michael@0 30 contour is done.
michael@0 31 */
michael@0 32 virtual SkScalar next(SkPath* dst, SkScalar dist, SkPathMeasure&) const = 0;
michael@0 33
michael@0 34 private:
michael@0 35 typedef SkPathEffect INHERITED;
michael@0 36 };
michael@0 37
michael@0 38 class SK_API SkPath1DPathEffect : public Sk1DPathEffect {
michael@0 39 public:
michael@0 40 enum Style {
michael@0 41 kTranslate_Style, // translate the shape to each position
michael@0 42 kRotate_Style, // rotate the shape about its center
michael@0 43 kMorph_Style, // transform each point, and turn lines into curves
michael@0 44
michael@0 45 kStyleCount
michael@0 46 };
michael@0 47
michael@0 48 /** Dash by replicating the specified path.
michael@0 49 @param path The path to replicate (dash)
michael@0 50 @param advance The space between instances of path
michael@0 51 @param phase distance (mod advance) along path for its initial position
michael@0 52 @param style how to transform path at each point (based on the current
michael@0 53 position and tangent)
michael@0 54 */
michael@0 55 static SkPath1DPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase,
michael@0 56 Style style) {
michael@0 57 return SkNEW_ARGS(SkPath1DPathEffect, (path, advance, phase, style));
michael@0 58 }
michael@0 59
michael@0 60 virtual bool filterPath(SkPath*, const SkPath&,
michael@0 61 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
michael@0 62
michael@0 63 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
michael@0 64
michael@0 65 protected:
michael@0 66 SkPath1DPathEffect(SkReadBuffer& buffer);
michael@0 67 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
michael@0 68
michael@0 69 // overrides from Sk1DPathEffect
michael@0 70 virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE;
michael@0 71 virtual SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const SK_OVERRIDE;
michael@0 72
michael@0 73 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
michael@0 74 public:
michael@0 75 #endif
michael@0 76 SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
michael@0 77
michael@0 78 private:
michael@0 79 SkPath fPath; // copied from constructor
michael@0 80 SkScalar fAdvance; // copied from constructor
michael@0 81 SkScalar fInitialOffset; // computed from phase
michael@0 82 Style fStyle; // copied from constructor
michael@0 83
michael@0 84 typedef Sk1DPathEffect INHERITED;
michael@0 85 };
michael@0 86
michael@0 87 #endif

mercurial