SkStroke.h revision 8a1c16ff38322f0210116fa7293eb8817c7e477e
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Copyright (C) 2006 The Android Open Source Project
38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Licensed under the Apache License, Version 2.0 (the "License");
58a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * you may not use this file except in compliance with the License.
68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * You may obtain a copy of the License at
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *      http://www.apache.org/licenses/LICENSE-2.0
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Unless required by applicable law or agreed to in writing, software
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * distributed under the License is distributed on an "AS IS" BASIS,
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * See the License for the specific language governing permissions and
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * limitations under the License.
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkStroke_DEFINED
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkStroke_DEFINED
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPoint.h"
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPaint.h"
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkRect;
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPath;
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_DefaultStrokeWidth       SK_Scalar1
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SK_DefaultMiterLimit        SkIntToScalar(4)
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkStroke
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkStroke is the utility class that constructs paths by stroking
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    geometries (lines, rects, ovals, roundrects, paths). This is
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    invoked when a geometry or text is drawn in a canvas with the
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    kStroke_Mask bit set in the paint.
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkStroke {
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkStroke();
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkStroke(const SkPaint&);
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkStroke(const SkPaint&, SkScalar width);   // width overrides paint.getStrokeWidth()
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPaint::Cap    getCap() const { return (SkPaint::Cap)fCap; }
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void        setCap(SkPaint::Cap);
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPaint::Join   getJoin() const { return (SkPaint::Join)fJoin; }
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void        setJoin(SkPaint::Join);
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    setMiterLimit(SkScalar);
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    setWidth(SkScalar);
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    bool    getDoFill() const { return SkToBool(fDoFill); }
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    strokeLine(const SkPoint& start, const SkPoint& end, SkPath*) const;
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    strokeRect(const SkRect& rect, SkPath*) const;
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    strokeOval(const SkRect& oval, SkPath*) const;
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    strokeRRect(const SkRect& rect, SkScalar rx, SkScalar ry, SkPath*) const;
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    strokePath(const SkPath& path, SkPath*) const;
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ////////////////////////////////////////////////////////////////
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar    fWidth, fMiterLimit;
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint8_t     fCap, fJoin;
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBool8     fDoFill;
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkPaint;
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
72