Fix cases of variable shadowing in src/pdf/.

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: Ide60535395eddae3392ff37339fa32bdde612da6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435878
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
This commit is contained in:
John Stiles 2021-08-02 15:49:20 -04:00 committed by SkCQ
parent eeff41a7b2
commit 0e15769355
3 changed files with 23 additions and 21 deletions

View File

@ -255,19 +255,21 @@ void serialize_image(const SkImage* img,
SkASSERT(doc);
SkASSERT(encodingQuality >= 0);
SkISize dimensions = img->dimensions();
sk_sp<SkData> data = img->refEncodedData();
if (data && do_jpeg(std::move(data), doc, dimensions, ref)) {
if (sk_sp<SkData> data = img->refEncodedData()) {
if (do_jpeg(std::move(data), doc, dimensions, ref)) {
return;
}
}
SkBitmap bm = to_pixels(img);
const SkPixmap& pm = bm.pixmap();
bool isOpaque = pm.isOpaque() || pm.computeIsOpaque();
if (encodingQuality <= 100 && isOpaque) {
sk_sp<SkData> data = img->encodeToData(SkEncodedImageFormat::kJPEG, encodingQuality);
if (data && do_jpeg(std::move(data), doc, dimensions, ref)) {
if (sk_sp<SkData> data = img->encodeToData(SkEncodedImageFormat::kJPEG, encodingQuality)) {
if (do_jpeg(std::move(data), doc, dimensions, ref)) {
return;
}
}
}
do_deflated_image(pm, doc, isOpaque, ref);
}

View File

@ -1577,15 +1577,15 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset,
SkPath perspectiveOutline = SkPath::Rect(imageBounds).makeTransform(transform);
// Retrieve the bounds of the new shape.
SkRect bounds = perspectiveOutline.getBounds();
if (!bounds.intersect(SkRect::Make(this->devClipBounds()))) {
SkRect outlineBounds = perspectiveOutline.getBounds();
if (!outlineBounds.intersect(SkRect::Make(this->devClipBounds()))) {
return;
}
// Transform the bitmap in the new space to the final space, to account for DPI
SkRect physicalBounds = fInitialTransform.mapRect(bounds);
SkScalar scaleX = physicalBounds.width() / bounds.width();
SkScalar scaleY = physicalBounds.height() / bounds.height();
SkRect physicalBounds = fInitialTransform.mapRect(outlineBounds);
SkScalar scaleX = physicalBounds.width() / outlineBounds.width();
SkScalar scaleY = physicalBounds.height() / outlineBounds.height();
// TODO(edisonn): A better approach would be to use a bitmap shader
// (in clamp mode) and draw a rect over the entire bounding box. Then
@ -1603,8 +1603,8 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset,
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorTRANSPARENT);
SkScalar deltaX = bounds.left();
SkScalar deltaY = bounds.top();
SkScalar deltaX = outlineBounds.left();
SkScalar deltaY = outlineBounds.top();
SkMatrix offsetMatrix = transform;
offsetMatrix.postTranslate(-deltaX, -deltaY);

View File

@ -256,10 +256,10 @@ static std::unique_ptr<SkPDFDict> gradientStitchCode(const SkShader::GradientInf
SkAutoSTMalloc<4, ColorTuple> colorDataAlloc(colorCount);
ColorTuple *colorData = colorDataAlloc.get();
for (int i = 0; i < colorCount; i++) {
colorData[i][0] = SkColorGetR(colors[i]);
colorData[i][1] = SkColorGetG(colors[i]);
colorData[i][2] = SkColorGetB(colors[i]);
for (int idx = 0; idx < colorCount; idx++) {
colorData[idx][0] = SkColorGetR(colors[idx]);
colorData[idx][1] = SkColorGetG(colors[idx]);
colorData[idx][2] = SkColorGetB(colors[idx]);
}
// no need for a stitch function if there are only 2 stops.
@ -273,15 +273,15 @@ static std::unique_ptr<SkPDFDict> gradientStitchCode(const SkShader::GradientInf
retval->insertObject("Domain", SkPDFMakeArray(0, 1));
retval->insertInt("FunctionType", 3);
for (int i = 1; i < colorCount; i++) {
if (i > 1) {
bounds->appendScalar(colorOffsets[i-1]);
for (int idx = 1; idx < colorCount; idx++) {
if (idx > 1) {
bounds->appendScalar(colorOffsets[idx-1]);
}
encode->appendScalar(0);
encode->appendScalar(1.0f);
functions->appendObject(createInterpolationFunction(colorData[i-1], colorData[i]));
functions->appendObject(createInterpolationFunction(colorData[idx-1], colorData[idx]));
}
retval->insertObject("Encode", std::move(encode));