| 1 |
/* |
| 2 |
* Copyright 2016 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 |
*/ |
| 7 |
|
| 8 |
#ifndef SkSVGLine_DEFINED |
| 9 |
#define SkSVGLine_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkPath.h" |
| 12 |
#include "include/core/SkPathTypes.h" |
| 13 |
#include "include/core/SkRefCnt.h" |
| 14 |
#include "include/private/base/SkAPI.h" |
| 15 |
#include "modules/svg/include/SkSVGNode.h" |
| 16 |
#include "modules/svg/include/SkSVGShape.h" |
| 17 |
#include "modules/svg/include/SkSVGTypes.h" |
| 18 |
|
| 19 |
#include <tuple> |
| 20 |
|
| 21 |
class SkCanvas; |
| 22 |
class SkPaint; |
| 23 |
class SkSVGLengthContext; |
| 24 |
class SkSVGRenderContext; |
| 25 |
struct SkPoint; |
| 26 |
|
| 27 |
class SK_API SkSVGLine final : public SkSVGShape { |
| 28 |
public: |
| 29 |
static sk_sp<SkSVGLine> Make() { return sk_sp<SkSVGLine>(new SkSVGLine()); } |
| 30 |
|
| 31 |
SVG_ATTR(X1, SkSVGLength, SkSVGLength(0)) |
| 32 |
SVG_ATTR(Y1, SkSVGLength, SkSVGLength(0)) |
| 33 |
SVG_ATTR(X2, SkSVGLength, SkSVGLength(0)) |
| 34 |
SVG_ATTR(Y2, SkSVGLength, SkSVGLength(0)) |
| 35 |
|
| 36 |
protected: |
| 37 |
bool parseAndSetAttribute(const char*, const char*) override; |
| 38 |
|
| 39 |
void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, |
| 40 |
SkPathFillType) const override; |
| 41 |
|
| 42 |
SkPath onAsPath(const SkSVGRenderContext&) const override; |
| 43 |
|
| 44 |
private: |
| 45 |
SkSVGLine(); |
| 46 |
|
| 47 |
// resolve and return the two endpoints |
| 48 |
std::tuple<SkPoint, SkPoint> resolve(const SkSVGLengthContext&) const; |
| 49 |
|
| 50 |
using INHERITED = SkSVGShape; |
| 51 |
}; |
| 52 |
|
| 53 |
#endif // SkSVGLine_DEFINED |