gfx/skia/trunk/include/core/SkStrokeRec.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 2012 Google Inc.
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 SkStrokeRec_DEFINED
michael@0 9 #define SkStrokeRec_DEFINED
michael@0 10
michael@0 11 #include "SkPaint.h"
michael@0 12
michael@0 13 class SkPath;
michael@0 14
michael@0 15 class SkStrokeRec {
michael@0 16 public:
michael@0 17 enum InitStyle {
michael@0 18 kHairline_InitStyle,
michael@0 19 kFill_InitStyle
michael@0 20 };
michael@0 21 SkStrokeRec(InitStyle style);
michael@0 22
michael@0 23 SkStrokeRec(const SkStrokeRec&);
michael@0 24 explicit SkStrokeRec(const SkPaint&);
michael@0 25
michael@0 26 enum Style {
michael@0 27 kHairline_Style,
michael@0 28 kFill_Style,
michael@0 29 kStroke_Style,
michael@0 30 kStrokeAndFill_Style
michael@0 31 };
michael@0 32
michael@0 33 Style getStyle() const;
michael@0 34 SkScalar getWidth() const { return fWidth; }
michael@0 35 SkScalar getMiter() const { return fMiterLimit; }
michael@0 36 SkPaint::Cap getCap() const { return fCap; }
michael@0 37 SkPaint::Join getJoin() const { return fJoin; }
michael@0 38
michael@0 39 bool isHairlineStyle() const {
michael@0 40 return kHairline_Style == this->getStyle();
michael@0 41 }
michael@0 42
michael@0 43 bool isFillStyle() const {
michael@0 44 return kFill_Style == this->getStyle();
michael@0 45 }
michael@0 46
michael@0 47 void setFillStyle();
michael@0 48 void setHairlineStyle();
michael@0 49 /**
michael@0 50 * Specify the strokewidth, and optionally if you want stroke + fill.
michael@0 51 * Note, if width==0, then this request is taken to mean:
michael@0 52 * strokeAndFill==true -> new style will be Fill
michael@0 53 * strokeAndFill==false -> new style will be Hairline
michael@0 54 */
michael@0 55 void setStrokeStyle(SkScalar width, bool strokeAndFill = false);
michael@0 56
michael@0 57 void setStrokeParams(SkPaint::Cap cap, SkPaint::Join join, SkScalar miterLimit) {
michael@0 58 fCap = cap;
michael@0 59 fJoin = join;
michael@0 60 fMiterLimit = miterLimit;
michael@0 61 }
michael@0 62
michael@0 63 /**
michael@0 64 * Returns true if this specifes any thick stroking, i.e. applyToPath()
michael@0 65 * will return true.
michael@0 66 */
michael@0 67 bool needToApply() const {
michael@0 68 Style style = this->getStyle();
michael@0 69 return (kStroke_Style == style) || (kStrokeAndFill_Style == style);
michael@0 70 }
michael@0 71
michael@0 72 /**
michael@0 73 * Apply these stroke parameters to the src path, returning the result
michael@0 74 * in dst.
michael@0 75 *
michael@0 76 * If there was no change (i.e. style == hairline or fill) this returns
michael@0 77 * false and dst is unchanged. Otherwise returns true and the result is
michael@0 78 * stored in dst.
michael@0 79 *
michael@0 80 * src and dst may be the same path.
michael@0 81 */
michael@0 82 bool applyToPath(SkPath* dst, const SkPath& src) const;
michael@0 83
michael@0 84 bool operator==(const SkStrokeRec& other) const {
michael@0 85 return fWidth == other.fWidth &&
michael@0 86 fMiterLimit == other.fMiterLimit &&
michael@0 87 fCap == other.fCap &&
michael@0 88 fJoin == other.fJoin &&
michael@0 89 fStrokeAndFill == other.fStrokeAndFill;
michael@0 90 }
michael@0 91
michael@0 92 private:
michael@0 93 SkScalar fWidth;
michael@0 94 SkScalar fMiterLimit;
michael@0 95 SkPaint::Cap fCap;
michael@0 96 SkPaint::Join fJoin;
michael@0 97 bool fStrokeAndFill;
michael@0 98 };
michael@0 99
michael@0 100 #endif

mercurial