gfx/skia/trunk/include/core/SkPathMeasure.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 * 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 SkPathMeasure_DEFINED
michael@0 9 #define SkPathMeasure_DEFINED
michael@0 10
michael@0 11 #include "SkPath.h"
michael@0 12 #include "SkTDArray.h"
michael@0 13
michael@0 14 class SK_API SkPathMeasure : SkNoncopyable {
michael@0 15 public:
michael@0 16 SkPathMeasure();
michael@0 17 /** Initialize the pathmeasure with the specified path. The path must remain valid
michael@0 18 for the lifetime of the measure object, or until setPath() is called with
michael@0 19 a different path (or null), since the measure object keeps a pointer to the
michael@0 20 path object (does not copy its data).
michael@0 21 */
michael@0 22 SkPathMeasure(const SkPath& path, bool forceClosed);
michael@0 23 ~SkPathMeasure();
michael@0 24
michael@0 25 /** Reset the pathmeasure with the specified path. The path must remain valid
michael@0 26 for the lifetime of the measure object, or until setPath() is called with
michael@0 27 a different path (or null), since the measure object keeps a pointer to the
michael@0 28 path object (does not copy its data).
michael@0 29 */
michael@0 30 void setPath(const SkPath*, bool forceClosed);
michael@0 31
michael@0 32 /** Return the total length of the current contour, or 0 if no path
michael@0 33 is associated (e.g. resetPath(null))
michael@0 34 */
michael@0 35 SkScalar getLength();
michael@0 36
michael@0 37 /** Pins distance to 0 <= distance <= getLength(), and then computes
michael@0 38 the corresponding position and tangent.
michael@0 39 Returns false if there is no path, or a zero-length path was specified, in which case
michael@0 40 position and tangent are unchanged.
michael@0 41 */
michael@0 42 bool SK_WARN_UNUSED_RESULT getPosTan(SkScalar distance, SkPoint* position,
michael@0 43 SkVector* tangent);
michael@0 44
michael@0 45 enum MatrixFlags {
michael@0 46 kGetPosition_MatrixFlag = 0x01,
michael@0 47 kGetTangent_MatrixFlag = 0x02,
michael@0 48 kGetPosAndTan_MatrixFlag = kGetPosition_MatrixFlag | kGetTangent_MatrixFlag
michael@0 49 };
michael@0 50
michael@0 51 /** Pins distance to 0 <= distance <= getLength(), and then computes
michael@0 52 the corresponding matrix (by calling getPosTan).
michael@0 53 Returns false if there is no path, or a zero-length path was specified, in which case
michael@0 54 matrix is unchanged.
michael@0 55 */
michael@0 56 bool SK_WARN_UNUSED_RESULT getMatrix(SkScalar distance, SkMatrix* matrix,
michael@0 57 MatrixFlags flags = kGetPosAndTan_MatrixFlag);
michael@0 58
michael@0 59 /** Given a start and stop distance, return in dst the intervening segment(s).
michael@0 60 If the segment is zero-length, return false, else return true.
michael@0 61 startD and stopD are pinned to legal values (0..getLength()). If startD <= stopD
michael@0 62 then return false (and leave dst untouched).
michael@0 63 Begin the segment with a moveTo if startWithMoveTo is true
michael@0 64 */
michael@0 65 bool getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo);
michael@0 66
michael@0 67 /** Return true if the current contour is closed()
michael@0 68 */
michael@0 69 bool isClosed();
michael@0 70
michael@0 71 /** Move to the next contour in the path. Return true if one exists, or false if
michael@0 72 we're done with the path.
michael@0 73 */
michael@0 74 bool nextContour();
michael@0 75
michael@0 76 #ifdef SK_DEBUG
michael@0 77 void dump();
michael@0 78 #endif
michael@0 79
michael@0 80 private:
michael@0 81 SkPath::Iter fIter;
michael@0 82 const SkPath* fPath;
michael@0 83 SkScalar fLength; // relative to the current contour
michael@0 84 int fFirstPtIndex; // relative to the current contour
michael@0 85 bool fIsClosed; // relative to the current contour
michael@0 86 bool fForceClosed;
michael@0 87
michael@0 88 struct Segment {
michael@0 89 SkScalar fDistance; // total distance up to this point
michael@0 90 unsigned fPtIndex : 15; // index into the fPts array
michael@0 91 unsigned fTValue : 15;
michael@0 92 unsigned fType : 2;
michael@0 93
michael@0 94 SkScalar getScalarT() const;
michael@0 95 };
michael@0 96 SkTDArray<Segment> fSegments;
michael@0 97 SkTDArray<SkPoint> fPts; // Points used to define the segments
michael@0 98
michael@0 99 static const Segment* NextSegment(const Segment*);
michael@0 100
michael@0 101 void buildSegments();
michael@0 102 SkScalar compute_quad_segs(const SkPoint pts[3], SkScalar distance,
michael@0 103 int mint, int maxt, int ptIndex);
michael@0 104 SkScalar compute_cubic_segs(const SkPoint pts[3], SkScalar distance,
michael@0 105 int mint, int maxt, int ptIndex);
michael@0 106 const Segment* distanceToSegment(SkScalar distance, SkScalar* t);
michael@0 107 };
michael@0 108
michael@0 109 #endif

mercurial