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>
This commit is contained in:
John Stiles 2021-08-02 13:26:38 -04:00 committed by SkCQ
parent 3533ff10c7
commit a212b95413
6 changed files with 10 additions and 14 deletions

View File

@ -158,8 +158,7 @@ DEF_SIMPLE_GM(parsedpaths, canvas, kParsePathTestDimension, kParsePathTestDimens
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));

View File

@ -66,8 +66,6 @@ protected:
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;

View File

@ -247,8 +247,7 @@ DEF_SIMPLE_GM(onebadarc, canvas, 100, 100) {
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) {

View File

@ -121,7 +121,7 @@ protected:
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 @@ protected:
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);
}

View File

@ -224,7 +224,7 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
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 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
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());

View File

@ -228,10 +228,10 @@ static void draw_batching(SkCanvas* canvas) {
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);