Switch over to SkPathBuilder
Bug: skia:9000
Change-Id: If7192dfb8df01db9acb83a3c331fbbde981e5e2e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307017
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/samplecode/SampleChart.cpp b/samplecode/SampleChart.cpp
index 6437d3e..46e4dec 100644
--- a/samplecode/SampleChart.cpp
+++ b/samplecode/SampleChart.cpp
@@ -7,7 +7,7 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
-#include "include/core/SkPath.h"
+#include "include/core/SkPathBuilder.h"
#include "include/utils/SkRandom.h"
#include "samplecode/Sample.h"
@@ -30,9 +30,7 @@
SkScalar yBase,
SkScalar xLeft, SkScalar xDelta,
int leftShift,
- SkPath* plot, SkPath* fill) {
- plot->rewind();
- fill->rewind();
+ SkPathBuilder* plot, SkPathBuilder* fill) {
plot->incReserve(topData.count());
if (nullptr == bottomData) {
fill->incReserve(topData.count() + 2);
@@ -121,9 +119,6 @@
}
}
- SkPath plotPath;
- SkPath fillPath;
-
static const SkScalar kStrokeWidth = SkIntToScalar(2);
SkPaint plotPaint;
SkPaint fillPaint;
@@ -135,7 +130,9 @@
fillPaint.setAntiAlias(true);
fillPaint.setStyle(SkPaint::kFill_Style);
+ SkPathBuilder plotPath, fillPath;
SkTDArray<SkScalar>* prevData = nullptr;
+
for (int i = 0; i < kNumGraphs; ++i) {
gen_paths(fData[i],
prevData,
@@ -148,10 +145,10 @@
// Make the fills partially transparent
fillPaint.setColor((gColors[i] & 0x00ffffff) | 0x80000000);
- canvas->drawPath(fillPath, fillPaint);
+ canvas->drawPath(fillPath.detach(), fillPaint);
plotPaint.setColor(gColors[i]);
- canvas->drawPath(plotPath, plotPaint);
+ canvas->drawPath(plotPath.detach(), plotPaint);
prevData = fData + i;
}