OLD | NEW |
(Empty) | |
| 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 #include "SkCanvas.h" |
| 9 #include "SkSVGRenderContext.h" |
| 10 #include "SkSVGPoly.h" |
| 11 #include "SkSVGValue.h" |
| 12 |
| 13 SkSVGPoly::SkSVGPoly(SkSVGTag t) : INHERITED(t) {} |
| 14 |
| 15 void SkSVGPoly::setPoints(const SkSVGPointsType& pts) { |
| 16 fPath.reset(); |
| 17 fPath.addPoly(pts.value().begin(), |
| 18 pts.value().count(), |
| 19 this->tag() == SkSVGTag::kPolygon); // only polygons are auto-
closed |
| 20 } |
| 21 |
| 22 void SkSVGPoly::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { |
| 23 switch (attr) { |
| 24 case SkSVGAttribute::kPoints: |
| 25 if (const auto* pts = v.as<SkSVGPointsValue>()) { |
| 26 this->setPoints(*pts); |
| 27 } |
| 28 break; |
| 29 default: |
| 30 this->INHERITED::onSetAttribute(attr, v); |
| 31 } |
| 32 } |
| 33 |
| 34 void SkSVGPoly::onDraw(SkCanvas* canvas, const SkSVGLengthContext&, const SkPain
t& paint) const { |
| 35 canvas->drawPath(fPath, paint); |
| 36 } |
OLD | NEW |