本文整理汇总了C++中SkPath::incReserve方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::incReserve方法的具体用法?C++ SkPath::incReserve怎么用?C++ SkPath::incReserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::incReserve方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawConvexPolygon
void PlatformGraphicsContextSkia::drawConvexPolygon(size_t numPoints,
const FloatPoint* points,
bool shouldAntialias)
{
if (numPoints <= 1)
return;
SkPaint paint;
SkPath path;
path.incReserve(numPoints);
path.moveTo(SkFloatToScalar(points[0].x()), SkFloatToScalar(points[0].y()));
for (size_t i = 1; i < numPoints; i++)
path.lineTo(SkFloatToScalar(points[i].x()), SkFloatToScalar(points[i].y()));
if (mCanvas->quickReject(path, shouldAntialias ?
SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType)) {
return;
}
if (m_state->fillColor & 0xFF000000) {
setupPaintFill(&paint);
paint.setAntiAlias(shouldAntialias);
mCanvas->drawPath(path, paint);
}
if (m_state->strokeStyle != NoStroke) {
paint.reset();
setupPaintStroke(&paint, 0);
paint.setAntiAlias(shouldAntialias);
mCanvas->drawPath(path, paint);
}
}
示例2: drawConvexPolygon
void GraphicsContext::drawConvexPolygon(size_t numPoints,
const FloatPoint* points,
bool shouldAntialias)
{
if (paintingDisabled())
return;
if (numPoints <= 1)
return;
SkPath path;
path.incReserve(numPoints);
path.moveTo(WebCoreFloatToSkScalar(points[0].x()),
WebCoreFloatToSkScalar(points[0].y()));
for (size_t i = 1; i < numPoints; i++) {
path.lineTo(WebCoreFloatToSkScalar(points[i].x()),
WebCoreFloatToSkScalar(points[i].y()));
}
if (!isPathSkiaSafe(getCTM(), path))
return;
SkPaint paint;
platformContext()->setupPaintForFilling(&paint);
platformContext()->canvas()->drawPath(path, paint);
if (strokeStyle() != NoStroke) {
paint.reset();
platformContext()->setupPaintForStroking(&paint, 0, 0);
platformContext()->canvas()->drawPath(path, paint);
}
}
示例3: triangle
void WebTestThemeControlWin::triangle(int x0, int y0, int x1, int y1, int x2, int y2, SkColor color)
{
SkPath path;
SkPaint paint;
paint.setColor(color);
paint.setStyle(SkPaint::kFill_Style);
path.incReserve(4);
path.moveTo(SkIntToScalar(x0), SkIntToScalar(y0));
path.lineTo(SkIntToScalar(x1), SkIntToScalar(y1));
path.lineTo(SkIntToScalar(x2), SkIntToScalar(y2));
path.close();
m_canvas->drawPath(path, paint);
paint.setColor(m_edgeColor);
paint.setStyle(SkPaint::kStroke_Style);
m_canvas->drawPath(path, paint);
}
示例4: addCubic
SkPath ValueTraits<ShapeValue>::As<SkPath>(const ShapeValue& shape) {
SkPath path;
if (!shape.fVertices.empty()) {
// conservatively assume all cubics
path.incReserve(1 + SkToU32(shape.fVertices.size() * 3));
path.moveTo(shape.fVertices.front().fVertex);
}
const auto& addCubic = [&](size_t from, size_t to) {
const auto c0 = shape.fVertices[from].fVertex + shape.fVertices[from].fOutPoint,
c1 = shape.fVertices[to].fVertex + shape.fVertices[to].fInPoint;
if (c0 == shape.fVertices[from].fVertex &&
c1 == shape.fVertices[to].fVertex) {
// If the control points are coincident, we can power-reduce to a straight line.
// TODO: we could also do that when the controls are on the same line as the
// vertices, but it's unclear how common that case is.
path.lineTo(shape.fVertices[to].fVertex);
} else {
path.cubicTo(c0, c1, shape.fVertices[to].fVertex);
}
};
for (size_t i = 1; i < shape.fVertices.size(); ++i) {
addCubic(i - 1, i);
}
if (!shape.fVertices.empty() && shape.fClosed) {
addCubic(shape.fVertices.size() - 1, 0);
path.close();
}
path.setIsVolatile(shape.fVolatile);
path.shrinkToFit();
return path;
}