}
}
-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);
}
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;
}
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)) {
} 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;
}
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);
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) {
}
// Setup vertices
- BezierVertex* verts = reinterpret_cast<BezierVertex*>(vertices);
+ BezierVertex* bezVerts = reinterpret_cast<BezierVertex*>(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;
}
}
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);
}
}
}