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.

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

mercurial