gfx/skia/trunk/include/core/SkPathEffect.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkPathEffect_DEFINED
michael@0 11 #define SkPathEffect_DEFINED
michael@0 12
michael@0 13 #include "SkFlattenable.h"
michael@0 14 #include "SkPath.h"
michael@0 15 #include "SkPoint.h"
michael@0 16 #include "SkRect.h"
michael@0 17 #include "SkStrokeRec.h"
michael@0 18 #include "SkTDArray.h"
michael@0 19
michael@0 20 class SkPath;
michael@0 21
michael@0 22 /** \class SkPathEffect
michael@0 23
michael@0 24 SkPathEffect is the base class for objects in the SkPaint that affect
michael@0 25 the geometry of a drawing primitive before it is transformed by the
michael@0 26 canvas' matrix and drawn.
michael@0 27
michael@0 28 Dashing is implemented as a subclass of SkPathEffect.
michael@0 29 */
michael@0 30 class SK_API SkPathEffect : public SkFlattenable {
michael@0 31 public:
michael@0 32 SK_DECLARE_INST_COUNT(SkPathEffect)
michael@0 33
michael@0 34 /**
michael@0 35 * Given a src path (input) and a stroke-rec (input and output), apply
michael@0 36 * this effect to the src path, returning the new path in dst, and return
michael@0 37 * true. If this effect cannot be applied, return false and ignore dst
michael@0 38 * and stroke-rec.
michael@0 39 *
michael@0 40 * The stroke-rec specifies the initial request for stroking (if any).
michael@0 41 * The effect can treat this as input only, or it can choose to change
michael@0 42 * the rec as well. For example, the effect can decide to change the
michael@0 43 * stroke's width or join, or the effect can change the rec from stroke
michael@0 44 * to fill (or fill to stroke) in addition to returning a new (dst) path.
michael@0 45 *
michael@0 46 * If this method returns true, the caller will apply (as needed) the
michael@0 47 * resulting stroke-rec to dst and then draw.
michael@0 48 */
michael@0 49 virtual bool filterPath(SkPath* dst, const SkPath& src,
michael@0 50 SkStrokeRec*, const SkRect* cullR) const = 0;
michael@0 51
michael@0 52 /**
michael@0 53 * Compute a conservative bounds for its effect, given the src bounds.
michael@0 54 * The baseline implementation just assigns src to dst.
michael@0 55 */
michael@0 56 virtual void computeFastBounds(SkRect* dst, const SkRect& src) const;
michael@0 57
michael@0 58 /** \class PointData
michael@0 59
michael@0 60 PointData aggregates all the information needed to draw the point
michael@0 61 primitives returned by an 'asPoints' call.
michael@0 62 */
michael@0 63 class PointData {
michael@0 64 public:
michael@0 65 PointData()
michael@0 66 : fFlags(0)
michael@0 67 , fPoints(NULL)
michael@0 68 , fNumPoints(0) {
michael@0 69 fSize.set(SK_Scalar1, SK_Scalar1);
michael@0 70 // 'asPoints' needs to initialize/fill-in 'fClipRect' if it sets
michael@0 71 // the kUseClip flag
michael@0 72 };
michael@0 73 ~PointData() {
michael@0 74 delete [] fPoints;
michael@0 75 }
michael@0 76
michael@0 77 // TODO: consider using passed-in flags to limit the work asPoints does.
michael@0 78 // For example, a kNoPath flag could indicate don't bother generating
michael@0 79 // stamped solutions.
michael@0 80
michael@0 81 // Currently none of these flags are supported.
michael@0 82 enum PointFlags {
michael@0 83 kCircles_PointFlag = 0x01, // draw points as circles (instead of rects)
michael@0 84 kUsePath_PointFlag = 0x02, // draw points as stamps of the returned path
michael@0 85 kUseClip_PointFlag = 0x04, // apply 'fClipRect' before drawing the points
michael@0 86 };
michael@0 87
michael@0 88 uint32_t fFlags; // flags that impact the drawing of the points
michael@0 89 SkPoint* fPoints; // the center point of each generated point
michael@0 90 int fNumPoints; // number of points in fPoints
michael@0 91 SkVector fSize; // the size to draw the points
michael@0 92 SkRect fClipRect; // clip required to draw the points (if kUseClip is set)
michael@0 93 SkPath fPath; // 'stamp' to be used at each point (if kUsePath is set)
michael@0 94
michael@0 95 SkPath fFirst; // If not empty, contains geometry for first point
michael@0 96 SkPath fLast; // If not empty, contains geometry for last point
michael@0 97 };
michael@0 98
michael@0 99 /**
michael@0 100 * Does applying this path effect to 'src' yield a set of points? If so,
michael@0 101 * optionally return the points in 'results'.
michael@0 102 */
michael@0 103 virtual bool asPoints(PointData* results, const SkPath& src,
michael@0 104 const SkStrokeRec&, const SkMatrix&,
michael@0 105 const SkRect* cullR) const;
michael@0 106
michael@0 107 SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
michael@0 108
michael@0 109 protected:
michael@0 110 SkPathEffect() {}
michael@0 111 SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
michael@0 112
michael@0 113 private:
michael@0 114 // illegal
michael@0 115 SkPathEffect(const SkPathEffect&);
michael@0 116 SkPathEffect& operator=(const SkPathEffect&);
michael@0 117
michael@0 118 typedef SkFlattenable INHERITED;
michael@0 119 };
michael@0 120
michael@0 121 /** \class SkPairPathEffect
michael@0 122
michael@0 123 Common baseclass for Compose and Sum. This subclass manages two pathEffects,
michael@0 124 including flattening them. It does nothing in filterPath, and is only useful
michael@0 125 for managing the lifetimes of its two arguments.
michael@0 126 */
michael@0 127 class SkPairPathEffect : public SkPathEffect {
michael@0 128 public:
michael@0 129 virtual ~SkPairPathEffect();
michael@0 130
michael@0 131 protected:
michael@0 132 SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
michael@0 133 SkPairPathEffect(SkReadBuffer&);
michael@0 134 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
michael@0 135
michael@0 136 // these are visible to our subclasses
michael@0 137 SkPathEffect* fPE0, *fPE1;
michael@0 138
michael@0 139 private:
michael@0 140 typedef SkPathEffect INHERITED;
michael@0 141 };
michael@0 142
michael@0 143 /** \class SkComposePathEffect
michael@0 144
michael@0 145 This subclass of SkPathEffect composes its two arguments, to create
michael@0 146 a compound pathEffect.
michael@0 147 */
michael@0 148 class SkComposePathEffect : public SkPairPathEffect {
michael@0 149 public:
michael@0 150 /** Construct a pathEffect whose effect is to apply first the inner pathEffect
michael@0 151 and the the outer pathEffect (e.g. outer(inner(path)))
michael@0 152 The reference counts for outer and inner are both incremented in the constructor,
michael@0 153 and decremented in the destructor.
michael@0 154 */
michael@0 155 static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
michael@0 156 return SkNEW_ARGS(SkComposePathEffect, (outer, inner));
michael@0 157 }
michael@0 158
michael@0 159 virtual bool filterPath(SkPath* dst, const SkPath& src,
michael@0 160 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
michael@0 161
michael@0 162 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
michael@0 163
michael@0 164 protected:
michael@0 165 SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
michael@0 166
michael@0 167 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
michael@0 168 public:
michael@0 169 #endif
michael@0 170 SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
michael@0 171 : INHERITED(outer, inner) {}
michael@0 172
michael@0 173 private:
michael@0 174 // illegal
michael@0 175 SkComposePathEffect(const SkComposePathEffect&);
michael@0 176 SkComposePathEffect& operator=(const SkComposePathEffect&);
michael@0 177
michael@0 178 typedef SkPairPathEffect INHERITED;
michael@0 179 };
michael@0 180
michael@0 181 /** \class SkSumPathEffect
michael@0 182
michael@0 183 This subclass of SkPathEffect applies two pathEffects, one after the other.
michael@0 184 Its filterPath() returns true if either of the effects succeeded.
michael@0 185 */
michael@0 186 class SkSumPathEffect : public SkPairPathEffect {
michael@0 187 public:
michael@0 188 /** Construct a pathEffect whose effect is to apply two effects, in sequence.
michael@0 189 (e.g. first(path) + second(path))
michael@0 190 The reference counts for first and second are both incremented in the constructor,
michael@0 191 and decremented in the destructor.
michael@0 192 */
michael@0 193 static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
michael@0 194 return SkNEW_ARGS(SkSumPathEffect, (first, second));
michael@0 195 }
michael@0 196
michael@0 197 virtual bool filterPath(SkPath* dst, const SkPath& src,
michael@0 198 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
michael@0 199
michael@0 200 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
michael@0 201
michael@0 202 protected:
michael@0 203 SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
michael@0 204
michael@0 205 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
michael@0 206 public:
michael@0 207 #endif
michael@0 208 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
michael@0 209 : INHERITED(first, second) {}
michael@0 210
michael@0 211 private:
michael@0 212 // illegal
michael@0 213 SkSumPathEffect(const SkSumPathEffect&);
michael@0 214 SkSumPathEffect& operator=(const SkSumPathEffect&);
michael@0 215
michael@0 216 typedef SkPairPathEffect INHERITED;
michael@0 217 };
michael@0 218
michael@0 219 #endif

mercurial