From 44c3128bd892d32f797810d93ef1ed392e0b902d Mon Sep 17 00:00:00 2001 From: robertphillips Date: Thu, 3 Sep 2015 12:58:48 -0700 Subject: [PATCH] Clean up some lint complaints BUG=skia:4287 Review URL: https://codereview.chromium.org/1327943003 --- src/core/SkPictureShader.cpp | 12 ++++----- src/gpu/batches/GrAAConvexPathRenderer.cpp | 13 +++++----- src/gpu/batches/GrAAConvexTessellator.cpp | 8 +++--- src/gpu/batches/GrAAHairLinePathRenderer.cpp | 26 ++++++++++---------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index 81e8ab42ee..80d5974b05 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -155,12 +155,12 @@ void SkPictureShader::flatten(SkWriteBuffer& buffer) const { } } -SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatrix* localM, - const int maxTextureSize) const { +SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkMatrix* localM, + const int maxTextureSize) const { SkASSERT(fPicture && !fPicture->cullRect().isEmpty()); SkMatrix m; - m.setConcat(matrix, this->getLocalMatrix()); + m.setConcat(viewMatrix, this->getLocalMatrix()); if (localM) { m.preConcat(*localM); } @@ -215,12 +215,12 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri this->getLocalMatrix()); if (!SkResourceCache::Find(key, BitmapShaderRec::Visitor, &tileShader)) { - SkMatrix matrix; - matrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSize.height()), + SkMatrix tileMatrix; + tileMatrix.setRectToRect(fTile, SkRect::MakeIWH(tileSize.width(), tileSize.height()), SkMatrix::kFill_ScaleToFit); SkBitmap bm; if (!SkInstallDiscardablePixelRef( - SkImageGenerator::NewFromPicture(tileSize, fPicture, &matrix, nullptr), &bm)) { + SkImageGenerator::NewFromPicture(tileSize, fPicture, &tileMatrix, nullptr), &bm)) { return nullptr; } diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp index 6023f188df..613b416601 100644 --- a/src/gpu/batches/GrAAConvexPathRenderer.cpp +++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp @@ -81,15 +81,15 @@ static void center_of_mass(const SegmentArray& segments, SkPoint* c) { pj = segments[1].endPt() - p0; for (int i = 1; i < count - 1; ++i) { pi = pj; - const SkPoint pj = segments[i + 1].endPt() - p0; + pj = segments[i + 1].endPt() - p0; - SkScalar t = SkScalarMul(pi.fX, pj.fY) - SkScalarMul(pj.fX, pi.fY); + SkScalar t = SkPoint::CrossProduct(pi, pj); area += t; center.fX += (pi.fX + pj.fX) * t; center.fY += (pi.fY + pj.fY) * t; - } } + // If the poly has no area then we instead return the average of // its points. if (SkScalarNearlyZero(area)) { @@ -106,8 +106,7 @@ static void center_of_mass(const SegmentArray& segments, SkPoint* c) { } else { area *= 3; area = SkScalarInvert(area); - center.fX = SkScalarMul(center.fX, area); - center.fY = SkScalarMul(center.fY, area); + center.scale(area); // undo the translate of p0 to the origin. *c = center + p0; } @@ -916,8 +915,8 @@ private: GrVertices vertices; - for (int i = 0; i < draws.count(); ++i) { - const Draw& draw = draws[i]; + for (int j = 0; j < draws.count(); ++j) { + const Draw& draw = draws[j]; vertices.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex, firstIndex, draw.fVertexCnt, draw.fIndexCnt); target->draw(vertices); diff --git a/src/gpu/batches/GrAAConvexTessellator.cpp b/src/gpu/batches/GrAAConvexTessellator.cpp index c111b8b562..5ef9aefddd 100644 --- a/src/gpu/batches/GrAAConvexTessellator.cpp +++ b/src/gpu/batches/GrAAConvexTessellator.cpp @@ -721,11 +721,11 @@ bool GrAAConvexTessellator::createInsetRing(const Ring& lastRing, Ring* nextRing dst[i] = nextRing->index(dst[i]); } - for (int cur = 0; cur < lastRing.numPts(); ++cur) { - int next = (cur + 1) % lastRing.numPts(); + for (int i = 0; i < lastRing.numPts(); ++i) { + int next = (i + 1) % lastRing.numPts(); - this->addTri(lastRing.index(cur), lastRing.index(next), dst[next]); - this->addTri(lastRing.index(cur), dst[next], dst[cur]); + this->addTri(lastRing.index(i), lastRing.index(next), dst[next]); + this->addTri(lastRing.index(i), dst[next], dst[i]); } if (done && fStrokeWidth < 0.0f) { diff --git a/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/src/gpu/batches/GrAAHairLinePathRenderer.cpp index e102db27a0..c6bdd055bb 100644 --- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp @@ -908,28 +908,28 @@ void AAHairlineBatch::onPrepareDraws(Target* target) { } // Setup vertices - BezierVertex* verts = reinterpret_cast(vertices); + BezierVertex* bezVerts = reinterpret_cast(vertices); int unsubdivQuadCnt = quads.count() / 3; for (int i = 0; i < unsubdivQuadCnt; ++i) { SkASSERT(qSubdivs[i] >= 0); - add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts); + add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts); } // Start Conics for (int i = 0; i < conicCount; ++i) { - add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts); + add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &bezVerts); } if (quadCount > 0) { target->initDraw(quadGP, this->pipeline()); { - GrVertices verts; - verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer, - firstVertex, kQuadNumVertices, kIdxsPerQuad, quadCount, - kQuadsNumInIdxBuffer); - target->draw(verts); + GrVertices tempVerts; + tempVerts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer, + firstVertex, kQuadNumVertices, kIdxsPerQuad, quadCount, + kQuadsNumInIdxBuffer); + target->draw(tempVerts); firstVertex += quadCount * kQuadNumVertices; } } @@ -938,11 +938,11 @@ void AAHairlineBatch::onPrepareDraws(Target* target) { target->initDraw(conicGP, this->pipeline()); { - GrVertices verts; - verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer, - firstVertex, kQuadNumVertices, kIdxsPerQuad, conicCount, - kQuadsNumInIdxBuffer); - target->draw(verts); + GrVertices tempVerts; + tempVerts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer, + firstVertex, kQuadNumVertices, kIdxsPerQuad, conicCount, + kQuadsNumInIdxBuffer); + target->draw(tempVerts); } } }