本文整理汇总了C++中SkPath::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::isEmpty方法的具体用法?C++ SkPath::isEmpty怎么用?C++ SkPath::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clipPathElement
void SkSVGDevice::AutoElement::addClipResources(const SkDraw& draw, Resources* resources) {
SkASSERT(!draw.fClipStack->isWideOpen());
SkPath clipPath;
(void) draw.fClipStack->asPath(&clipPath);
SkString clipID = fResourceBucket->addClip();
const char* clipRule = clipPath.getFillType() == SkPath::kEvenOdd_FillType ?
"evenodd" : "nonzero";
{
// clipPath is in device space, but since we're only pushing transform attributes
// to the leaf nodes, so are all our elements => SVG userSpaceOnUse == device space.
AutoElement clipPathElement("clipPath", fWriter);
clipPathElement.addAttribute("id", clipID);
SkRect clipRect = SkRect::MakeEmpty();
if (clipPath.isEmpty() || clipPath.isRect(&clipRect)) {
AutoElement rectElement("rect", fWriter);
rectElement.addRectAttributes(clipRect);
rectElement.addAttribute("clip-rule", clipRule);
} else {
AutoElement pathElement("path", fWriter);
pathElement.addPathAttributes(clipPath);
pathElement.addAttribute("clip-rule", clipRule);
}
}
resources->fClip.printf("url(#%s)", clipID.c_str());
}
示例2:
sk_sp<SkPathEffect> SkPath1DPathEffect::Make(const SkPath& path, SkScalar advance, SkScalar phase,
Style style) {
if (advance <= 0 || path.isEmpty()) {
return nullptr;
}
return sk_sp<SkPathEffect>(new SkPath1DPathEffect(path, advance, phase, style));
}
示例3: makePath
void makePath() {
if (fPath.isEmpty()) {
const SkScalar radius = SkIntToScalar(45);
fPath.addCircle(SkIntToScalar(50), SkIntToScalar(50), radius);
fPath.addCircle(SkIntToScalar(100), SkIntToScalar(100), radius);
}
}
示例4: INHERITED
GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path) : INHERITED(gpu, kIsWrapped) {
#ifndef SK_SCALAR_IS_FLOAT
GrCrash("Assumes scalar is float.");
#endif
SkASSERT(!path.isEmpty());
GL_CALL_RET(fPathID, GenPaths(1));
SkSTArray<16, GrGLubyte, true> pathCommands;
SkSTArray<16, SkPoint, true> pathPoints;
int verbCnt = path.countVerbs();
int pointCnt = path.countPoints();
pathCommands.resize_back(verbCnt);
pathPoints.resize_back(pointCnt);
// TODO: Direct access to path points since we could pass them on directly.
path.getPoints(&pathPoints[0], pointCnt);
path.getVerbs(&pathCommands[0], verbCnt);
GR_DEBUGCODE(int numPts = 0);
for (int i = 0; i < verbCnt; ++i) {
SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
pathCommands[i] = verb_to_gl_path_cmd(v);
GR_DEBUGCODE(numPts += num_pts(v));
}
GrAssert(pathPoints.count() == numPts);
GL_CALL(PathCommands(fPathID,
verbCnt, &pathCommands[0],
2 * pointCnt, GR_GL_FLOAT, &pathPoints[0]));
fBounds = path.getBounds();
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_skia_src,代码行数:33,代码来源:GrGLPath.cpp
示例5: onDrawPath
bool GrAAConvexPathRenderer::onDrawPath(GrDrawTarget* target,
GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& vm,
const SkPath& path,
const SkStrokeRec&,
bool antiAlias) {
if (path.isEmpty()) {
return true;
}
// We outset our vertices one pixel and add one more pixel for precision.
// TODO create tighter bounds when we start reordering.
SkRect devRect = path.getBounds();
vm.mapRect(&devRect);
devRect.outset(2, 2);
AAConvexPathBatch::Geometry geometry;
geometry.fColor = color;
geometry.fViewMatrix = vm;
geometry.fPath = path;
SkAutoTUnref<GrBatch> batch(AAConvexPathBatch::Create(geometry));
target->drawBatch(pipelineBuilder, batch, &devRect);
return true;
}
示例6: fPath
SkPath1DPathEffect::SkPath1DPathEffect(const SkPath& path, SkScalar advance,
SkScalar phase, Style style) : fPath(path)
{
SkASSERT(advance > 0 && !path.isEmpty());
// cleanup their phase parameter, inverting it so that it becomes an
// offset along the path (to match the interpretation in PostScript)
if (phase < 0) {
phase = -phase;
if (phase > advance) {
phase = SkScalarMod(phase, advance);
}
} else {
if (phase > advance) {
phase = SkScalarMod(phase, advance);
}
phase = advance - phase;
}
// now catch the edge case where phase == advance (within epsilon)
if (phase >= advance) {
phase = 0;
}
SkASSERT(phase >= 0);
fAdvance = advance;
fInitialOffset = phase;
if ((unsigned)style > kMorph_Style) {
SkDEBUGF(("SkPath1DPathEffect style enum out of range %d\n", style));
}
fStyle = style;
}
示例7: tmpStroke
GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& origSkPath, const GrStrokeInfo& origStroke)
: INHERITED(gpu, origSkPath, origStroke),
fPathID(gpu->glPathRendering()->genPaths(1)) {
if (origSkPath.isEmpty()) {
InitPathObjectEmptyPath(gpu, fPathID);
fShouldStroke = false;
fShouldFill = false;
} else {
const SkPath* skPath = &origSkPath;
SkTLazy<SkPath> tmpPath;
const GrStrokeInfo* stroke = &origStroke;
GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle);
if (stroke->isDashed()) {
// Skia stroking and NVPR stroking differ with respect to dashing
// pattern.
// Convert a dashing to either a stroke or a fill.
if (stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) {
skPath = tmpPath.get();
stroke = &tmpStroke;
}
}
bool didInit = false;
if (stroke->needToApply() && stroke->getCap() != SkPaint::kButt_Cap) {
// Skia stroking and NVPR stroking differ with respect to stroking
// end caps of empty subpaths.
// Convert stroke to fill if path contains empty subpaths.
didInit = InitPathObjectPathDataCheckingDegenerates(gpu, fPathID, *skPath);
if (!didInit) {
if (!tmpPath.isValid()) {
tmpPath.init();
}
SkAssertResult(stroke->applyToPath(tmpPath.get(), *skPath));
skPath = tmpPath.get();
tmpStroke.setFillStyle();
stroke = &tmpStroke;
}
}
if (!didInit) {
InitPathObjectPathData(gpu, fPathID, *skPath);
}
fShouldStroke = stroke->needToApply();
fShouldFill = stroke->isFillStyle() ||
stroke->getStyle() == SkStrokeRec::kStrokeAndFill_Style;
if (fShouldStroke) {
InitPathObjectStroke(gpu, fPathID, *stroke);
// FIXME: try to account for stroking, without rasterizing the stroke.
fBounds.outset(stroke->getWidth(), stroke->getWidth());
}
}
this->registerWithCache();
}
示例8: SkHitTestPath
bool SkHitTestPath(const SkPath& path, SkRect& target, bool hires) {
if (target.isEmpty()) {
return false;
}
bool isInverse = path.isInverseFillType();
if (path.isEmpty()) {
return isInverse;
}
SkRect bounds = path.getBounds();
bool sects = SkRect::Intersects(target, bounds);
if (isInverse) {
if (!sects) {
return true;
}
} else {
if (!sects) {
return false;
}
if (target.contains(bounds)) {
return true;
}
}
SkPath devPath;
const SkPath* pathPtr;
SkRect devTarget;
if (hires) {
const SkScalar coordLimit = SkIntToScalar(16384);
const SkRect limit = { 0, 0, coordLimit, coordLimit };
SkMatrix matrix;
matrix.setRectToRect(bounds, limit, SkMatrix::kFill_ScaleToFit);
path.transform(matrix, &devPath);
matrix.mapRect(&devTarget, target);
pathPtr = &devPath;
} else {
devTarget = target;
pathPtr = &path;
}
SkIRect iTarget;
devTarget.round(&iTarget);
if (iTarget.isEmpty()) {
iTarget.fLeft = SkScalarFloorToInt(devTarget.fLeft);
iTarget.fTop = SkScalarFloorToInt(devTarget.fTop);
iTarget.fRight = iTarget.fLeft + 1;
iTarget.fBottom = iTarget.fTop + 1;
}
SkRegion clip(iTarget);
SkRegion rgn;
return rgn.setPath(*pathPtr, clip) ^ isInverse;
}
示例9: PathOpsSimplifyFailTest
static void PathOpsSimplifyFailTest(skiatest::Reporter* reporter) {
for (int index = 0; index < (int) (13 * nonFinitePtsCount * finitePtsCount); ++index) {
SkPath path;
int i = (int) (index % nonFinitePtsCount);
int f = (int) (index % finitePtsCount);
int g = (int) ((f + 1) % finitePtsCount);
switch (index % 13) {
case 0: path.lineTo(nonFinitePts[i]); break;
case 1: path.quadTo(nonFinitePts[i], nonFinitePts[i]); break;
case 2: path.quadTo(nonFinitePts[i], finitePts[f]); break;
case 3: path.quadTo(finitePts[f], nonFinitePts[i]); break;
case 4: path.cubicTo(nonFinitePts[i], finitePts[f], finitePts[f]); break;
case 5: path.cubicTo(finitePts[f], nonFinitePts[i], finitePts[f]); break;
case 6: path.cubicTo(finitePts[f], finitePts[f], nonFinitePts[i]); break;
case 7: path.cubicTo(nonFinitePts[i], nonFinitePts[i], finitePts[f]); break;
case 8: path.cubicTo(nonFinitePts[i], finitePts[f], nonFinitePts[i]); break;
case 9: path.cubicTo(finitePts[f], nonFinitePts[i], nonFinitePts[i]); break;
case 10: path.cubicTo(nonFinitePts[i], nonFinitePts[i], nonFinitePts[i]); break;
case 11: path.cubicTo(nonFinitePts[i], finitePts[f], finitePts[g]); break;
case 12: path.moveTo(nonFinitePts[i]); break;
}
SkPath result;
result.setFillType(SkPath::kWinding_FillType);
bool success = Simplify(path, &result);
REPORTER_ASSERT(reporter, !success);
REPORTER_ASSERT(reporter, result.isEmpty());
REPORTER_ASSERT(reporter, result.getFillType() == SkPath::kWinding_FillType);
reporter->bumpTestCount();
}
if (sizeof(reporter) == 4) {
return;
}
for (int index = 0; index < (int) (11 * finitePtsCount); ++index) {
SkPath path;
int f = (int) (index % finitePtsCount);
int g = (int) ((f + 1) % finitePtsCount);
switch (index % 11) {
case 0: path.lineTo(finitePts[f]); break;
case 1: path.quadTo(finitePts[f], finitePts[f]); break;
case 2: path.quadTo(finitePts[f], finitePts[g]); break;
case 3: path.quadTo(finitePts[g], finitePts[f]); break;
case 4: path.cubicTo(finitePts[f], finitePts[f], finitePts[f]); break;
case 5: path.cubicTo(finitePts[f], finitePts[f], finitePts[g]); break;
case 6: path.cubicTo(finitePts[f], finitePts[g], finitePts[f]); break;
case 7: path.cubicTo(finitePts[f], finitePts[g], finitePts[g]); break;
case 8: path.cubicTo(finitePts[g], finitePts[f], finitePts[f]); break;
case 9: path.cubicTo(finitePts[g], finitePts[f], finitePts[g]); break;
case 10: path.moveTo(finitePts[f]); break;
}
SkPath result;
result.setFillType(SkPath::kWinding_FillType);
bool success = Simplify(path, &result);
REPORTER_ASSERT(reporter, success);
REPORTER_ASSERT(reporter, result.getFillType() != SkPath::kWinding_FillType);
reporter->bumpTestCount();
}
}
示例10: toString
static void toString(const SkPath& path, SkString* str) {
if (path.isEmpty()) {
str->append("path:empty");
} else {
toString(path.getBounds(), str);
#if 1
SkString s;
dumpVerbs(path, &s);
str->append(s.c_str());
#endif
str->append("]");
str->prepend("path:[");
}
}
示例11: dash
// http://crbug.com/165432
// Limit extreme dash path effects to avoid exhausting the system memory.
static void test_crbug_165432(skiatest::Reporter* reporter) {
SkPath path;
path.moveTo(0, 0);
path.lineTo(10000000, 0);
SkScalar intervals[] = { 0.5f, 0.5f };
SkDashPathEffect dash(intervals, 2, 0);
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setPathEffect(&dash);
SkPath filteredPath;
SkStrokeRec rec(paint);
REPORTER_ASSERT(reporter, !dash.filterPath(&filteredPath, path, &rec, NULL));
REPORTER_ASSERT(reporter, filteredPath.isEmpty());
}
示例12: SkHitTestPathEx
bool SkHitTestPathEx(const SkPath& path, SkScalar x, SkScalar y) {
bool isInverse = path.isInverseFillType();
if (path.isEmpty()) {
return isInverse;
}
const SkRect& bounds = path.getBounds();
if (!bounds.contains(x, y)) {
return isInverse;
}
SkPath::Iter iter(path, true);
bool done = false;
int w = 0;
do {
SkPoint pts[4];
switch (iter.next(pts, false)) {
case SkPath::kMove_Verb:
case SkPath::kClose_Verb:
break;
case SkPath::kLine_Verb:
w += winding_line(pts, x, y);
break;
case SkPath::kQuad_Verb:
w += winding_quad(pts, x, y);
break;
case SkPath::kCubic_Verb:
w += winding_cubic(pts, x, y);
break;
case SkPath::kDone_Verb:
done = true;
break;
}
} while (!done);
switch (path.getFillType()) {
case SkPath::kEvenOdd_FillType:
case SkPath::kInverseEvenOdd_FillType:
w &= 1;
break;
default:
break;
}
return SkToBool(w);
}
示例13: InitPathObjectPathData
void GrGLPath::InitPathObjectPathData(GrGLGpu* gpu,
GrGLuint pathID,
const SkPath& skPath) {
SkASSERT(!skPath.isEmpty());
#ifdef SK_SCALAR_IS_FLOAT
// This branch does type punning, converting SkPoint* to GrGLfloat*.
if ((skPath.getSegmentMasks() & SkPath::kConic_SegmentMask) == 0) {
int verbCnt = skPath.countVerbs();
int pointCnt = skPath.countPoints();
int coordCnt = pointCnt * 2;
SkSTArray<16, GrGLubyte, true> pathCommands(verbCnt);
SkSTArray<16, GrGLfloat, true> pathCoords(coordCnt);
static_assert(sizeof(SkPoint) == sizeof(GrGLfloat) * 2, "sk_point_not_two_floats");
pathCommands.resize_back(verbCnt);
pathCoords.resize_back(coordCnt);
skPath.getPoints(reinterpret_cast<SkPoint*>(&pathCoords[0]), pointCnt);
skPath.getVerbs(&pathCommands[0], verbCnt);
SkDEBUGCODE(int verbCoordCnt = 0);
for (int i = 0; i < verbCnt; ++i) {
SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
pathCommands[i] = verb_to_gl_path_cmd(v);
SkDEBUGCODE(verbCoordCnt += num_coords(v));
}
SkASSERT(verbCnt == pathCommands.count());
SkASSERT(verbCoordCnt == pathCoords.count());
SkDEBUGCODE(verify_floats(&pathCoords[0], pathCoords.count()));
GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, pathCommands.count(), &pathCommands[0],
pathCoords.count(), GR_GL_FLOAT,
&pathCoords[0]));
return;
}
#endif
SkAssertResult(init_path_object_for_general_path<false>(gpu, pathID, skPath));
}
示例14: onDrawPath
bool GrAALinearizingConvexPathRenderer::onDrawPath(GrDrawTarget* target,
GrPipelineBuilder* pipelineBuilder,
GrColor color,
const SkMatrix& vm,
const SkPath& path,
const GrStrokeInfo& stroke,
bool antiAlias) {
if (path.isEmpty()) {
return true;
}
AAFlatteningConvexPathBatch::Geometry geometry;
geometry.fColor = color;
geometry.fViewMatrix = vm;
geometry.fPath = path;
geometry.fStrokeWidth = stroke.isFillStyle() ? -1.0f : stroke.getWidth();
geometry.fJoin = stroke.isFillStyle() ? SkPaint::Join::kMiter_Join : stroke.getJoin();
geometry.fMiterLimit = stroke.getMiter();
SkAutoTUnref<GrBatch> batch(AAFlatteningConvexPathBatch::Create(geometry));
target->drawBatch(pipelineBuilder, batch);
return true;
}
示例15: comparePaths
DEF_TEST(PathOpsBuilder, reporter) {
SkOpBuilder builder;
SkPath result;
REPORTER_ASSERT(reporter, builder.resolve(&result));
REPORTER_ASSERT(reporter, result.isEmpty());
builder.add(result, kDifference_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
REPORTER_ASSERT(reporter, result.isEmpty());
builder.add(result, kUnion_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
REPORTER_ASSERT(reporter, result.isEmpty());
SkPath rectPath;
rectPath.setFillType(SkPath::kEvenOdd_FillType);
rectPath.addRect(0, 1, 2, 3, SkPath::kCW_Direction);
builder.add(rectPath, kUnion_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
bool closed;
SkPath::Direction dir;
REPORTER_ASSERT(reporter, result.isRect(nullptr, &closed, &dir));
REPORTER_ASSERT(reporter, closed);
REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction);
int pixelDiff = comparePaths(reporter, __FUNCTION__, rectPath, result);
REPORTER_ASSERT(reporter, pixelDiff == 0);
rectPath.reset();
rectPath.setFillType(SkPath::kEvenOdd_FillType);
rectPath.addRect(0, 1, 2, 3, SkPath::kCCW_Direction);
builder.add(rectPath, kUnion_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
REPORTER_ASSERT(reporter, result.isRect(nullptr, &closed, &dir));
REPORTER_ASSERT(reporter, closed);
REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction);
REPORTER_ASSERT(reporter, rectPath == result);
builder.add(rectPath, kDifference_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
REPORTER_ASSERT(reporter, result.isEmpty());
SkPath rect2, rect3;
rect2.addRect(2, 1, 4, 3, SkPath::kCW_Direction);
rect3.addRect(4, 1, 5, 3, SkPath::kCCW_Direction);
builder.add(rectPath, kUnion_SkPathOp);
builder.add(rect2, kUnion_SkPathOp);
builder.add(rect3, kUnion_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
REPORTER_ASSERT(reporter, result.isRect(nullptr, &closed, &dir));
REPORTER_ASSERT(reporter, closed);
SkRect expected;
expected.set(0, 1, 5, 3);
REPORTER_ASSERT(reporter, result.getBounds() == expected);
SkPath circle1, circle2, circle3;
circle1.addCircle(5, 6, 4, SkPath::kCW_Direction);
circle2.addCircle(7, 4, 8, SkPath::kCCW_Direction);
circle3.addCircle(6, 5, 6, SkPath::kCW_Direction);
SkPath opCompare;
Op(circle1, circle2, kUnion_SkPathOp, &opCompare);
Op(opCompare, circle3, kDifference_SkPathOp, &opCompare);
builder.add(circle1, kUnion_SkPathOp);
builder.add(circle2, kUnion_SkPathOp);
builder.add(circle3, kDifference_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
pixelDiff = comparePaths(reporter, __FUNCTION__, opCompare, result);
REPORTER_ASSERT(reporter, pixelDiff == 0);
}