Fix cases of variable shadowing in /samplecode/.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.
Change-Id: I4c476668a83a0054fe8624d5ffa650db202ba810
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438376
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
diff --git a/samplecode/SampleClip.cpp b/samplecode/SampleClip.cpp
index 49da848..358e3f8 100644
--- a/samplecode/SampleClip.cpp
+++ b/samplecode/SampleClip.cpp
@@ -338,16 +338,16 @@
draw_halfplane(canvas, pts[0], pts[1], c);
}
-static void compute_half_planes(const SkMatrix& mx, SkScalar W, SkScalar H,
+static void compute_half_planes(const SkMatrix& mx, SkScalar width, SkScalar height,
SkHalfPlane planes[4]) {
SkScalar a = mx[0], b = mx[1], c = mx[2],
d = mx[3], e = mx[4], f = mx[5],
g = mx[6], h = mx[7], i = mx[8];
- planes[0] = { 2*g - 2*a/W, 2*h - 2*b/W, 2*i - 2*c/W };
- planes[1] = { 2*a/W, 2*b/W, 2*c/W };
- planes[2] = { 2*g - 2*d/H, 2*h - 2*e/H, 2*i - 2*f/H };
- planes[3] = { 2*d/H, 2*e/H, 2*f/H };
+ planes[0] = { 2*g - 2*a/width, 2*h - 2*b/width, 2*i - 2*c/width };
+ planes[1] = { 2*a/width, 2*b/width, 2*c/width };
+ planes[2] = { 2*g - 2*d/height, 2*h - 2*e/height, 2*i - 2*f/height };
+ planes[3] = { 2*d/height, 2*e/height, 2*f/height };
}
class HalfPlaneView2 : public Sample {
diff --git a/samplecode/SamplePolyToPoly.cpp b/samplecode/SamplePolyToPoly.cpp
index 04b2b71..41af4a0 100644
--- a/samplecode/SamplePolyToPoly.cpp
+++ b/samplecode/SamplePolyToPoly.cpp
@@ -50,21 +50,19 @@
(void) m2.setPolyToPoly((const SkPoint*)src1, (SkPoint*)dst1, 4);
- {
- const SkPoint src[] = {
- { SkIntToScalar(1), SkIntToScalar(0) },
- { SkIntToScalar(4), SkIntToScalar(7) },
- { SkIntToScalar(10), SkIntToScalar(2) }
- };
- const SkPoint dst[] = {
- { SkIntToScalar(4), SkIntToScalar(2) },
- { SkIntToScalar(45), SkIntToScalar(26) },
- { SkIntToScalar(32), SkIntToScalar(17) }
- };
+ const SkPoint src2[] = {
+ { SkIntToScalar(1), SkIntToScalar(0) },
+ { SkIntToScalar(4), SkIntToScalar(7) },
+ { SkIntToScalar(10), SkIntToScalar(2) }
+ };
+ const SkPoint dst2[] = {
+ { SkIntToScalar(4), SkIntToScalar(2) },
+ { SkIntToScalar(45), SkIntToScalar(26) },
+ { SkIntToScalar(32), SkIntToScalar(17) }
+ };
- SkMatrix m0;
- m0.setPolyToPoly(src, dst, 3);
- }
+ SkMatrix m0;
+ m0.setPolyToPoly(src2, dst2, 3);
}
}
diff --git a/samplecode/SampleShadowUtils.cpp b/samplecode/SampleShadowUtils.cpp
index 15199e2..e313875 100644
--- a/samplecode/SampleShadowUtils.cpp
+++ b/samplecode/SampleShadowUtils.cpp
@@ -172,9 +172,9 @@
SkTDArray<SkMatrix> matrices;
matrices.push()->reset();
matrices.push()->setRotate(33.f, 25.f, 25.f).postScale(1.2f, 0.8f, 25.f, 25.f);
- SkPaint paint;
- paint.setColor(SK_ColorGREEN);
- paint.setAntiAlias(true);
+ SkPaint greenPaint;
+ greenPaint.setColor(SK_ColorGREEN);
+ greenPaint.setAntiAlias(true);
SkPoint3 zPlaneParams = SkPoint3::Make(0, 0, std::max(1.0f, kHeight + fZDelta));
// convex paths
@@ -195,7 +195,7 @@
canvas->save();
canvas->concat(m);
- this->drawShadowedPath(canvas, path, zPlaneParams, paint, kAmbientAlpha,
+ this->drawShadowedPath(canvas, path, zPlaneParams, greenPaint, kAmbientAlpha,
lightPos, kLightR, kSpotAlpha, flags);
canvas->restore();
@@ -221,8 +221,8 @@
canvas->save();
canvas->concat(m);
- this->drawShadowedPath(canvas, path, zPlaneParams, paint, kAmbientAlpha, lightPos,
- kLightR, kSpotAlpha, kNone_ShadowFlag);
+ this->drawShadowedPath(canvas, path, zPlaneParams, greenPaint, kAmbientAlpha,
+ lightPos, kLightR, kSpotAlpha, kNone_ShadowFlag);
canvas->restore();
canvas->translate(dx, 0);
@@ -236,10 +236,10 @@
if (invCanvasM.invert(&invCanvasM)) {
canvas->save();
canvas->concat(invCanvasM);
- SkPaint paint;
- paint.setColor(SK_ColorBLACK);
- paint.setAntiAlias(true);
- canvas->drawCircle(lightPos.fX, lightPos.fY, kLightR / 10.f, paint);
+ SkPaint blackPaint;
+ blackPaint.setColor(SK_ColorBLACK);
+ blackPaint.setAntiAlias(true);
+ canvas->drawCircle(lightPos.fX, lightPos.fY, kLightR / 10.f, blackPaint);
canvas->restore();
}
}
diff --git a/samplecode/SampleVariableWidthStroker.cpp b/samplecode/SampleVariableWidthStroker.cpp
index ab2117a..7d9a352 100644
--- a/samplecode/SampleVariableWidthStroker.cpp
+++ b/samplecode/SampleVariableWidthStroker.cpp
@@ -463,7 +463,7 @@
* TODO: no reason this needs to return a vector of quads, can just append to the path
*/
std::vector<PathSegment> strokeSegment(const PathSegment& seg,
- const ScalarBezCurve& distFnc) const;
+ const ScalarBezCurve& distanceFunc) const;
/** Adds an endcap to fOuter */
enum class CapLocation { Start, End };
@@ -636,7 +636,7 @@
}
std::vector<SkVarWidthStroker::PathSegment> SkVarWidthStroker::strokeSegment(
- const PathSegment& seg, const ScalarBezCurve& distFnc) const {
+ const PathSegment& seg, const ScalarBezCurve& distanceFunc) const {
// Work item for the recursive splitting stack.
struct Item {
PathSegment fSeg;
@@ -659,7 +659,7 @@
// Push the initial segment and distance function
std::stack<Item> stack;
- stack.push(Item(seg, distFnc, ScalarBezCurve::Mul(distFnc, distFnc)));
+ stack.push(Item(seg, distanceFunc, ScalarBezCurve::Mul(distanceFunc, distanceFunc)));
std::vector<PathSegment> result;
constexpr int kMaxIters = 5000; /** TODO: this is completely arbitrary */