Fix cases of variable shadowing in /gm/.
If we manage to fix all the existing cases of variable shadowing, we could enable -Wshadow. Change-Id: I905459bf0bbaa205da7dc59e1910e345bed2af51 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438538 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
ab005016f9
commit
acf7164587
@ -237,9 +237,8 @@ protected:
|
||||
// Align the next set with the middle of the previous in y, translated to the right in x.
|
||||
SkPoint corners[] = {{0, 0}, {0, kBottom}, {kWidth, kBottom}, {kWidth, 0}};
|
||||
matrices.back().mapPoints(corners, 4);
|
||||
SkScalar y = (corners[0].fY + corners[1].fY + corners[2].fY + corners[3].fY) / 4;
|
||||
SkScalar x = std::max({corners[0].fX, corners[1].fX, corners[2].fX, corners[3].fX});
|
||||
m.setTranslate(x, y);
|
||||
m.setTranslate(std::max({corners[0].fX, corners[1].fX, corners[2].fX, corners[3].fX}),
|
||||
(corners[0].fY + corners[1].fY + corners[2].fY + corners[3].fY) / 4);
|
||||
m.preScale(0.2f, 0.2f);
|
||||
matrices.push_back(m);
|
||||
|
||||
|
@ -373,11 +373,11 @@ private:
|
||||
// the single x-pass value from our precomputed row.
|
||||
float tdiff = numSubpixels * pad - (y * numSubpixels + ys + 0.5f);
|
||||
float bdiff = tdiff + h;
|
||||
auto w = def_integral_approx(tdiff, bdiff);
|
||||
auto integral = def_integral_approx(tdiff, bdiff);
|
||||
for (int x = 0; x < maskW; ++x) {
|
||||
for (int xs = 0; xs < numSubpixels; ++xs) {
|
||||
int rowIdx = x * numSubpixels + xs;
|
||||
accums[x] += w * row[rowIdx];
|
||||
accums[x] += integral * row[rowIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,9 +184,10 @@ protected:
|
||||
|
||||
const int kPadX = 30;
|
||||
const int kPadY = 40;
|
||||
SkPaint paint;
|
||||
paint.setAlphaf(0.125f);
|
||||
canvas->drawImageRect(fImage, SkRect::MakeIWH(gSize, gSize), SkSamplingOptions(), &paint);
|
||||
SkPaint alphaPaint;
|
||||
alphaPaint.setAlphaf(0.125f);
|
||||
canvas->drawImageRect(fImage, SkRect::MakeIWH(gSize, gSize), SkSamplingOptions(),
|
||||
&alphaPaint);
|
||||
canvas->translate(SK_Scalar1 * kPadX / 2,
|
||||
SK_Scalar1 * kPadY / 2);
|
||||
SkPaint blackPaint;
|
||||
@ -237,16 +238,16 @@ protected:
|
||||
// test the following code path:
|
||||
// SkGpuDevice::drawPath() -> SkGpuDevice::drawWithMaskFilter()
|
||||
SkIRect srcRect;
|
||||
SkPaint paint;
|
||||
SkPaint maskPaint;
|
||||
SkBitmap bm = make_chessbm(5, 5);
|
||||
|
||||
srcRect.setXYWH(1, 1, 3, 3);
|
||||
paint.setMaskFilter(SkMaskFilter::MakeBlur(
|
||||
maskPaint.setMaskFilter(SkMaskFilter::MakeBlur(
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5))));
|
||||
|
||||
fProc(canvas, bm.asImage().get(), bm, srcRect, dstRect,
|
||||
SkSamplingOptions(SkFilterMode::kLinear), &paint);
|
||||
SkSamplingOptions(SkFilterMode::kLinear), &maskPaint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ private:
|
||||
SkTextEncoding::kGlyphID, 0, 0, font, glyphPaint);
|
||||
|
||||
if (labelBounds) {
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
SkAutoCanvasRestore acr2(canvas, true);
|
||||
canvas->translate(glyphToDraw.location.fX, glyphToDraw.location.fY);
|
||||
canvas->rotate(glyphToDraw.rotation);
|
||||
SkString glyphStr;
|
||||
|
@ -601,8 +601,8 @@ private:
|
||||
void onOnceBeforeDraw() override {
|
||||
const SkPoint center = { 0, 0 };
|
||||
const SkScalar kRadius = 3000;
|
||||
const SkColor gColors[] = { 0xFFFFFFFF, 0xFF000000 };
|
||||
fShader = SkGradientShader::MakeRadial(center, kRadius, gColors, nullptr, 2,
|
||||
const SkColor kColors[] = { 0xFFFFFFFF, 0xFF000000 };
|
||||
fShader = SkGradientShader::MakeRadial(center, kRadius, kColors, nullptr, 2,
|
||||
SkTileMode::kClamp);
|
||||
}
|
||||
|
||||
|
@ -318,8 +318,6 @@ protected:
|
||||
virtual void installFilter(SkPaint* paint) = 0;
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkPaint paint;
|
||||
|
||||
canvas->translate(20, 40);
|
||||
|
||||
for (int doSaveLayer = 0; doSaveLayer <= 1; ++doSaveLayer) {
|
||||
|
10
gm/ovals.cpp
10
gm/ovals.cpp
@ -146,7 +146,7 @@ protected:
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkRandom rand(1);
|
||||
canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
|
||||
SkRect oval = SkRect::MakeLTRB(-20, -30, 20, 30);
|
||||
const SkRect kOval = SkRect::MakeLTRB(-20, -30, 20, 30);
|
||||
|
||||
const SkScalar kXStart = 60.0f;
|
||||
const SkScalar kYStart = 80.0f;
|
||||
@ -175,8 +175,8 @@ protected:
|
||||
SkColor color = genColor(&rand);
|
||||
fPaints[i].setColor(color);
|
||||
|
||||
canvas->drawRect(oval, rectPaint);
|
||||
canvas->drawOval(oval, fPaints[i]);
|
||||
canvas->drawRect(kOval, rectPaint);
|
||||
canvas->drawOval(kOval, fPaints[i]);
|
||||
|
||||
canvas->restore();
|
||||
|
||||
@ -268,8 +268,8 @@ protected:
|
||||
fPaints[i].setColor(color);
|
||||
fPaints[i].setShader(shader);
|
||||
|
||||
canvas->drawRect(oval, rectPaint);
|
||||
canvas->drawOval(oval, fPaints[i]);
|
||||
canvas->drawRect(kOval, rectPaint);
|
||||
canvas->drawOval(kOval, fPaints[i]);
|
||||
|
||||
fPaints[i].setShader(nullptr);
|
||||
|
||||
|
@ -507,10 +507,9 @@ protected:
|
||||
}
|
||||
}
|
||||
// Draw a single polygon with insets and potentially outsets
|
||||
void drawPolygon(SkCanvas* canvas, int index, SkPoint* offset) {
|
||||
void drawPolygon(SkCanvas* canvas, int index, SkPoint* position) {
|
||||
|
||||
SkPoint center;
|
||||
SkRect bounds;
|
||||
{
|
||||
std::unique_ptr<SkPoint[]> data(nullptr);
|
||||
int numPts;
|
||||
@ -519,16 +518,17 @@ protected:
|
||||
} else {
|
||||
GetSimplePolygon(index, SkPathDirection::kCW, &data, &numPts);
|
||||
}
|
||||
SkRect bounds;
|
||||
bounds.setBounds(data.get(), numPts);
|
||||
if (!fConvexOnly) {
|
||||
bounds.outset(kMaxOutset, kMaxOutset);
|
||||
}
|
||||
if (offset->fX + bounds.width() > kGMWidth) {
|
||||
offset->fX = 0;
|
||||
offset->fY += kMaxPathHeight;
|
||||
if (position->fX + bounds.width() > kGMWidth) {
|
||||
position->fX = 0;
|
||||
position->fY += kMaxPathHeight;
|
||||
}
|
||||
center = { offset->fX + SkScalarHalf(bounds.width()), offset->fY };
|
||||
offset->fX += bounds.width();
|
||||
center = { position->fX + SkScalarHalf(bounds.width()), position->fY };
|
||||
position->fX += bounds.width();
|
||||
}
|
||||
|
||||
const SkPathDirection dirs[2] = { SkPathDirection::kCW, SkPathDirection::kCCW };
|
||||
@ -581,8 +581,8 @@ protected:
|
||||
if (result) {
|
||||
SkPath path;
|
||||
path.moveTo(offsetPoly[0]);
|
||||
for (int i = 1; i < offsetPoly.count(); ++i) {
|
||||
path.lineTo(offsetPoly[i]);
|
||||
for (int j = 1; j < offsetPoly.count(); ++j) {
|
||||
path.lineTo(offsetPoly[j]);
|
||||
}
|
||||
path.close();
|
||||
|
||||
|
@ -83,11 +83,11 @@ static void draw_save_layer_draw_bitmap_restore_sequence(SkCanvas* canvas, SkCol
|
||||
bitmap.eraseColor(shapeColor);
|
||||
{
|
||||
// Make the bitmap non-uniform color, so that it can not be optimized as uniform drawRect.
|
||||
SkCanvas canvas(bitmap);
|
||||
SkCanvas bitmapCanvas(bitmap);
|
||||
SkPaint p;
|
||||
p.setColor(SK_ColorWHITE);
|
||||
SkASSERT(shapeColor != SK_ColorWHITE);
|
||||
canvas.drawRect(SkRect::MakeWH(SkIntToScalar(7), SkIntToScalar(7)), p);
|
||||
bitmapCanvas.drawRect(SkRect::MakeWH(SkIntToScalar(7), SkIntToScalar(7)), p);
|
||||
}
|
||||
|
||||
SkRect targetRect(SkRect::MakeWH(SkIntToScalar(kTestRectSize), SkIntToScalar(kTestRectSize)));
|
||||
@ -109,11 +109,11 @@ static void draw_svg_opacity_and_filter_layer_sequence(SkCanvas* canvas, SkColor
|
||||
sk_sp<SkPicture> shape;
|
||||
{
|
||||
SkPictureRecorder recorder;
|
||||
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kTestRectSize + 2),
|
||||
SkIntToScalar(kTestRectSize + 2));
|
||||
SkCanvas* recordCanvas = recorder.beginRecording(SkIntToScalar(kTestRectSize + 2),
|
||||
SkIntToScalar(kTestRectSize + 2));
|
||||
SkPaint shapePaint;
|
||||
shapePaint.setColor(shapeColor);
|
||||
canvas->drawRect(targetRect, shapePaint);
|
||||
recordCanvas->drawRect(targetRect, shapePaint);
|
||||
shape = recorder.finishRecordingAsPicture();
|
||||
}
|
||||
|
||||
|
@ -163,9 +163,9 @@ private:
|
||||
auto img = fGradImgs[i];
|
||||
int w = img->width();
|
||||
int h = img->height();
|
||||
for (auto s : kScales) {
|
||||
for (auto scale : kScales) {
|
||||
canvas->save();
|
||||
canvas->scale(s, s);
|
||||
canvas->scale(scale, scale);
|
||||
for (auto s : kSamplings) {
|
||||
// drawImage
|
||||
canvas->drawImage(img, 0, 0, s);
|
||||
@ -193,7 +193,7 @@ private:
|
||||
canvas->translate(.5f*w + kPad, 0);
|
||||
}
|
||||
canvas->restore();
|
||||
canvas->translate(0, kPad + 1.5f*h*s);
|
||||
canvas->translate(0, kPad + 1.5f*h*scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,9 +147,9 @@ protected:
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkRandom rand(1);
|
||||
canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
|
||||
const SkRect rect = SkRect::MakeLTRB(-20, -30, 20, 30);
|
||||
SkRRect circleRect;
|
||||
circleRect.setRectXY(rect, 5, 5);
|
||||
const SkRect kRect = SkRect::MakeLTRB(-20, -30, 20, 30);
|
||||
SkRRect circleRRect;
|
||||
circleRRect.setRectXY(kRect, 5, 5);
|
||||
|
||||
const SkScalar kXStart = 60.0f;
|
||||
const SkScalar kYStart = 80.0f;
|
||||
@ -178,8 +178,8 @@ protected:
|
||||
SkColor color = gen_color(&rand);
|
||||
fPaints[i].setColor(color);
|
||||
|
||||
canvas->drawRect(rect, rectPaint);
|
||||
canvas->drawRRect(circleRect, fPaints[i]);
|
||||
canvas->drawRect(kRect, rectPaint);
|
||||
canvas->drawRRect(circleRRect, fPaints[i]);
|
||||
|
||||
canvas->restore();
|
||||
|
||||
@ -283,8 +283,8 @@ protected:
|
||||
fPaints[i].setColor(color);
|
||||
fPaints[i].setShader(shader);
|
||||
|
||||
canvas->drawRect(rect, rectPaint);
|
||||
canvas->drawRRect(circleRect, fPaints[i]);
|
||||
canvas->drawRect(kRect, rectPaint);
|
||||
canvas->drawRRect(circleRRect, fPaints[i]);
|
||||
|
||||
fPaints[i].setShader(nullptr);
|
||||
|
||||
@ -306,7 +306,7 @@ protected:
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
SkRRect circleRect;
|
||||
circleRect.setRectXY(rect, radii[i][0], radii[i][1]);
|
||||
circleRect.setRectXY(kRect, radii[i][0], radii[i][1]);
|
||||
|
||||
canvas->save();
|
||||
// position the roundrect, and make it at off-integer coords.
|
||||
|
@ -91,9 +91,7 @@ void draw_paths(SkCanvas* canvas, ShadowMode mode) {
|
||||
SkScalar dy = 0;
|
||||
SkTDArray<SkMatrix> matrices;
|
||||
matrices.push()->reset();
|
||||
SkMatrix* m = matrices.push();
|
||||
m->setRotate(33.f, 25.f, 25.f);
|
||||
m->postScale(1.2f, 0.8f, 25.f, 25.f);
|
||||
matrices.push()->setRotate(33.f, 25.f, 25.f).postScale(1.2f, 0.8f, 25.f, 25.f);
|
||||
for (auto& m : matrices) {
|
||||
for (int flags : { kNone_ShadowFlag, kTransparentOccluder_ShadowFlag }) {
|
||||
int pathCounter = 0;
|
||||
|
@ -149,7 +149,7 @@ protected:
|
||||
|
||||
for (SkPoint jitter : kJitters) {
|
||||
{
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
SkAutoCanvasRestore acr2(canvas, true);
|
||||
canvas->translate(jitter.x(), jitter.y());
|
||||
canvas->drawPath(path, fFillPaint);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user