Fix cases of variable shadowing in gm/.
These were reviewed last year at http://review.skia.org/312480 but never
landed. Splitting into small chunks to land individually.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.
Change-Id: Ie6a262328315a5726265ef4afede7e0e66337752
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435718
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/gm/arcto.cpp b/gm/arcto.cpp
index 20528c8..46964b6 100644
--- a/gm/arcto.cpp
+++ b/gm/arcto.cpp
@@ -158,8 +158,7 @@
uint32_t y = rand.nextRangeU(30, 70);
uint32_t x = rand.nextRangeU(30, 70);
spec.printf("M %d,%d\n", x, y);
- uint32_t count = rand.nextRangeU(0, 10);
- for (uint32_t i = 0; i < count; ++i) {
+ for (uint32_t i = rand.nextRangeU(0, 10); i--; ) {
spec.append(MakeRandomParsePathPiece(&rand));
}
SkAssertResult(SkParsePath::FromSVGString(spec.c_str(), &path));
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index b5065a6..19e8fab 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -66,8 +66,6 @@
SkISize onISize() override { return SkISize::Make(fWidth, fHeight); }
DrawResult onDraw(GrRecordingContext* rContext, SkCanvas* canvas, SkString* errorMsg) override {
- SkPaint paint;
-
auto sdc = SkCanvasPriv::TopDeviceSurfaceDrawContext(canvas);
if (!sdc) {
*errorMsg = kErrorMsg_DrawSkippedGpuOnly;
diff --git a/gm/circulararcs.cpp b/gm/circulararcs.cpp
index 764fdd1..448473e 100644
--- a/gm/circulararcs.cpp
+++ b/gm/circulararcs.cpp
@@ -247,8 +247,7 @@
canvas->translate(20, 0);
canvas->drawPath(path.detach(), p0);
- SkRect kRect = { 60, 0, 100, 40};
- canvas->drawArc(kRect, 45, 90, true, p0);
+ canvas->drawArc(SkRect{60, 0, 100, 40}, 45, 90, true, p0);
}
DEF_SIMPLE_GM(crbug_888453, canvas, 480, 150) {
diff --git a/gm/coloremoji_blendmodes.cpp b/gm/coloremoji_blendmodes.cpp
index b0de25d..a2da3c9 100644
--- a/gm/coloremoji_blendmodes.cpp
+++ b/gm/coloremoji_blendmodes.cpp
@@ -121,7 +121,7 @@
textP.setAntiAlias(true);
SkFont textFont(fColorType, 70);
- const int W = 5;
+ const int kWrap = 5;
SkScalar x0 = 0;
SkScalar y0 = 0;
@@ -156,7 +156,7 @@
labelFont, SkPaint(), SkTextUtils::kCenter_Align);
#endif
x += w + SkIntToScalar(10);
- if ((i % W) == W - 1) {
+ if ((i % kWrap) == kWrap - 1) {
x = x0;
y += h + SkIntToScalar(30);
}
diff --git a/gm/typeface.cpp b/gm/typeface.cpp
index 9b25e0f..9be01d4 100644
--- a/gm/typeface.cpp
+++ b/gm/typeface.cpp
@@ -224,7 +224,7 @@
for (const AliasType& alias : aliasTypes) {
font.setEdging(alias.edging);
- SkAutoCanvasRestore acr(canvas, false);
+ SkAutoCanvasRestore acr1(canvas, false);
if (alias.inLayer) {
canvas->saveLayer(nullptr, &paint);
}
@@ -239,7 +239,7 @@
font.setHinting(hinting);
for (const bool& rotateABit : rotateABitTypes) {
- SkAutoCanvasRestore acr(canvas, true);
+ SkAutoCanvasRestore acr2(canvas, true);
if (rotateABit) {
canvas->rotate(2, x + subpixel.offset.x(),
y + subpixel.offset.y());
diff --git a/gm/vertices.cpp b/gm/vertices.cpp
index a1ac94a..7d57f0b 100644
--- a/gm/vertices.cpp
+++ b/gm/vertices.cpp
@@ -228,10 +228,10 @@
SkTDArray<SkMatrix> matrices;
matrices.push()->reset();
matrices.push()->setTranslate(0, 40);
- SkMatrix* m = matrices.push();
- m->setRotate(45, kMeshSize / 2, kMeshSize / 2);
- m->postScale(1.2f, .8f, kMeshSize / 2, kMeshSize / 2);
- m->postTranslate(0, 80);
+ matrices.push()
+ ->setRotate(45, kMeshSize / 2, kMeshSize / 2)
+ .postScale(1.2f, .8f, kMeshSize / 2, kMeshSize / 2)
+ .postTranslate(0, 80);
auto shader = make_shader1(1);