本文整理汇总了C++中SkPath::reverseAddPath方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::reverseAddPath方法的具体用法?C++ SkPath::reverseAddPath怎么用?C++ SkPath::reverseAddPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::reverseAddPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FixWinding
void FixWinding(SkPath* path) {
SkPath::FillType fillType = path->getFillType();
if (fillType == SkPath::kInverseEvenOdd_FillType) {
fillType = SkPath::kInverseWinding_FillType;
} else if (fillType == SkPath::kEvenOdd_FillType) {
fillType = SkPath::kWinding_FillType;
}
SkPathPriv::FirstDirection dir;
if (one_contour(*path) && SkPathPriv::CheapComputeFirstDirection(*path, &dir)) {
if (dir != SkPathPriv::kCCW_FirstDirection) {
SkPath temp;
temp.reverseAddPath(*path);
*path = temp;
}
path->setFillType(fillType);
return;
}
SkChunkAlloc allocator(4096);
SkOpContourHead contourHead;
SkOpGlobalState globalState(nullptr, &contourHead SkDEBUGPARAMS(nullptr));
SkOpEdgeBuilder builder(*path, &contourHead, &allocator, &globalState);
builder.finish(&allocator);
SkASSERT(contourHead.next());
contourHead.resetReverse();
bool writePath = false;
SkOpSpan* topSpan;
globalState.setPhase(SkOpGlobalState::kFixWinding);
while ((topSpan = FindSortableTop(&contourHead))) {
SkOpSegment* topSegment = topSpan->segment();
SkOpContour* topContour = topSegment->contour();
SkASSERT(topContour->isCcw() >= 0);
#if DEBUG_WINDING
SkDebugf("%s id=%d nested=%d ccw=%d\n", __FUNCTION__,
topSegment->debugID(), globalState.nested(), topContour->isCcw());
#endif
if ((globalState.nested() & 1) != SkToBool(topContour->isCcw())) {
topContour->setReverse();
writePath = true;
}
topContour->markDone();
globalState.clearNested();
}
if (!writePath) {
path->setFillType(fillType);
return;
}
SkPath empty;
SkPathWriter woundPath(empty);
SkOpContour* test = &contourHead;
do {
if (test->reversed()) {
test->toReversePath(&woundPath);
} else {
test->toPath(&woundPath);
}
} while ((test = test->next()));
*path = *woundPath.nativePath();
path->setFillType(fillType);
}
示例2: test_rev
static void test_rev(SkCanvas* canvas, const SkPath& path) {
test_path(canvas, path);
SkPath rev;
rev.reverseAddPath(path);
canvas->save();
canvas->translate(150, 0);
test_path(canvas, rev);
canvas->restore();
}
示例3: makePath
SkPath makePath() {
SkPath path;
for (uint32_t cIndex = 0; cIndex < fPathContourCount; ++cIndex) {
uint32_t segments = makeSegmentCount();
for (uint32_t sIndex = 0; sIndex < segments; ++sIndex) {
RandomAddPath addPathType = makeAddPathType();
++fAddCount;
if (fPrintName) {
SkDebugf("%.*s%s\n", fPathDepth * 3, fTab,
gRandomAddPathNames[addPathType]);
}
switch (addPathType) {
case kAddArc: {
SkRect oval = makeRect();
SkScalar startAngle = makeAngle();
SkScalar sweepAngle = makeAngle();
path.addArc(oval, startAngle, sweepAngle);
validate(path);
} break;
case kAddRoundRect1: {
SkRect rect = makeRect();
SkScalar rx = makeScalar(), ry = makeScalar();
SkPath::Direction dir = makeDirection();
path.addRoundRect(rect, rx, ry, dir);
validate(path);
} break;
case kAddRoundRect2: {
SkRect rect = makeRect();
SkScalar radii[8];
makeScalarArray(SK_ARRAY_COUNT(radii), radii);
SkPath::Direction dir = makeDirection();
path.addRoundRect(rect, radii, dir);
validate(path);
} break;
case kAddRRect: {
SkRRect rrect = makeRRect();
SkPath::Direction dir = makeDirection();
path.addRRect(rrect, dir);
validate(path);
} break;
case kAddPoly: {
SkTDArray<SkPoint> points;
makePointArray(&points);
bool close = makeBool();
path.addPoly(&points[0], points.count(), close);
validate(path);
} break;
case kAddPath1:
if (fPathDepth < fPathDepthLimit) {
++fPathDepth;
SkPath src = makePath();
validate(src);
SkScalar dx = makeScalar();
SkScalar dy = makeScalar();
SkPath::AddPathMode mode = makeAddPathMode();
path.addPath(src, dx, dy, mode);
--fPathDepth;
validate(path);
}
break;
case kAddPath2:
if (fPathDepth < fPathDepthLimit) {
++fPathDepth;
SkPath src = makePath();
validate(src);
SkPath::AddPathMode mode = makeAddPathMode();
path.addPath(src, mode);
--fPathDepth;
validate(path);
}
break;
case kAddPath3:
if (fPathDepth < fPathDepthLimit) {
++fPathDepth;
SkPath src = makePath();
validate(src);
SkMatrix matrix = makeMatrix();
SkPath::AddPathMode mode = makeAddPathMode();
path.addPath(src, matrix, mode);
--fPathDepth;
validate(path);
}
break;
case kReverseAddPath:
if (fPathDepth < fPathDepthLimit) {
++fPathDepth;
SkPath src = makePath();
validate(src);
path.reverseAddPath(src);
--fPathDepth;
validate(path);
}
break;
case kMoveToPath: {
SkScalar x = makeScalar();
SkScalar y = makeScalar();
path.moveTo(x, y);
validate(path);
} break;
case kRMoveToPath: {
//.........这里部分代码省略.........
示例4: resolve
/* OPTIMIZATION: Union doesn't need to be all-or-nothing. A run of three or more convex
paths with union ops could be locally resolved and still improve over doing the
ops one at a time. */
bool SkOpBuilder::resolve(SkPath* result) {
SkPath original = *result;
int count = fOps.count();
bool allUnion = true;
SkPathPriv::FirstDirection firstDir = SkPathPriv::kUnknown_FirstDirection;
for (int index = 0; index < count; ++index) {
SkPath* test = &fPathRefs[index];
if (kUnion_SkPathOp != fOps[index] || test->isInverseFillType()) {
allUnion = false;
break;
}
// If all paths are convex, track direction, reversing as needed.
if (test->isConvex()) {
SkPathPriv::FirstDirection dir;
if (!SkPathPriv::CheapComputeFirstDirection(*test, &dir)) {
allUnion = false;
break;
}
if (firstDir == SkPathPriv::kUnknown_FirstDirection) {
firstDir = dir;
} else if (firstDir != dir) {
SkPath temp;
temp.reverseAddPath(*test);
*test = temp;
}
continue;
}
// If the path is not convex but its bounds do not intersect the others, simplify is enough.
const SkRect& testBounds = test->getBounds();
for (int inner = 0; inner < index; ++inner) {
// OPTIMIZE: check to see if the contour bounds do not intersect other contour bounds?
if (SkRect::Intersects(fPathRefs[inner].getBounds(), testBounds)) {
allUnion = false;
break;
}
}
}
if (!allUnion) {
*result = fPathRefs[0];
for (int index = 1; index < count; ++index) {
if (!Op(*result, fPathRefs[index], fOps[index], result)) {
reset();
*result = original;
return false;
}
}
reset();
return true;
}
SkPath sum;
for (int index = 0; index < count; ++index) {
if (!Simplify(fPathRefs[index], &fPathRefs[index])) {
reset();
*result = original;
return false;
}
if (!fPathRefs[index].isEmpty()) {
// convert the even odd result back to winding form before accumulating it
if (!FixWinding(&fPathRefs[index])) {
*result = original;
return false;
}
sum.addPath(fPathRefs[index]);
}
}
reset();
bool success = Simplify(sum, result);
if (!success) {
*result = original;
}
return success;
}