当前位置: 首页>>代码示例>>C++>>正文


C++ SkPath::setFillType方法代码示例

本文整理汇总了C++中SkPath::setFillType方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::setFillType方法的具体用法?C++ SkPath::setFillType怎么用?C++ SkPath::setFillType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkPath的用法示例。


在下文中一共展示了SkPath::setFillType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onDraw

    void onDraw(SkCanvas* canvas) override {
        SkPath path;
        SkRandom rand;

        int scale = 300;
        for (int i = 0; i < 4; ++i) {
            // get the random values deterministically
            SkScalar randoms[12];
            for (int index = 0; index < (int) SK_ARRAY_COUNT(randoms); ++index) {
                randoms[index] = rand.nextUScalar1();
            }
            path.lineTo(randoms[0] * scale, randoms[1] * scale);
            path.quadTo(randoms[2] * scale, randoms[3] * scale,
                        randoms[4] * scale, randoms[5] * scale);
            path.cubicTo(randoms[6] * scale, randoms[7] * scale,
                         randoms[8] * scale, randoms[9] * scale,
                         randoms[10] * scale, randoms[11] * scale);
        }

        path.setFillType(SkPath::kEvenOdd_FillType);
        path.offset(SkIntToScalar(20), SkIntToScalar(20));

        test_hittest(canvas, path);

        canvas->translate(SkIntToScalar(scale), 0);
        path.setFillType(SkPath::kWinding_FillType);

        test_hittest(canvas, path);
    }
开发者ID:guolianzhu,项目名称:skia,代码行数:29,代码来源:hittestpath.cpp

示例2: onDrawContent

    void onDrawContent(SkCanvas* canvas) override {
        test_huge_stroke(canvas); return;
        canvas->translate(SkIntToScalar(10), SkIntToScalar(10));

        SkPaint paint;
        paint.setAntiAlias(true);

        if (true) {
            canvas->drawColor(SK_ColorBLACK);

            paint.setTextSize(24);
            paint.setColor(SK_ColorWHITE);
            canvas->translate(10, 30);

            static const SkBlurStyle gStyle[] = {
                kNormal_SkBlurStyle,
                kInner_SkBlurStyle,
                kOuter_SkBlurStyle,
                kSolid_SkBlurStyle,
            };
            for (int x = 0; x < 5; x++) {
                SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4));
                for (int y = 0; y < 10; y++) {
                    if (x) {
                        paint.setMaskFilter(SkBlurMaskFilter::Make(gStyle[x - 1], sigma));
                    }
                    canvas->drawString("Title Bar", x*SkIntToScalar(100), y*SkIntToScalar(30), paint);
                    sigma *= 0.75f;
                }

            }
            return;
        }

        paint.setColor(SK_ColorBLUE);

#if 1
        SkPath p;
        float r = rand.nextUScalar1() + 0.5f;
        SkScalar x = 0, y = 0;
        p.moveTo(x, y);
#if 0
        p.cubicTo(x-75*r, y+75*r, x-40*r, y+125*r, x, y+85*r);
        p.cubicTo(x+40*r, y+125*r, x+75*r, y+75*r, x, y);
#else
        p.cubicTo(x+75*r, y+75*r, x+40*r, y+125*r, x, y+85*r);
        p.cubicTo(x-40*r, y+125*r, x-75*r, y+75*r, x, y);
#endif
        p.close();
        fPath = p;
        fPath.offset(100, 0);
#endif

        fPath.setFillType(SkPath::kWinding_FillType);
        drawSet(canvas, &paint);

        canvas->translate(0, fPath.getBounds().height() * 5 / 4);
        fPath.setFillType(SkPath::kEvenOdd_FillType);
        drawSet(canvas, &paint);
    }
开发者ID:android,项目名称:platform_external_skia,代码行数:60,代码来源:SampleStrokePath.cpp

示例3: 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();
    }
}
开发者ID:Frankie-666,项目名称:color-emoji.skia,代码行数:57,代码来源:PathOpsSimplifyFailTest.cpp

示例4:

static inline SkPath
path_to_sk (cairo_path_fixed_t *path,
	    cairo_fill_rule_t fill_rule,
	    cairo_matrix_t *mat = NULL)
{
    SkPath skPath = path_to_sk (path, mat);

    if (fill_rule == CAIRO_FILL_RULE_EVEN_ODD)
	skPath.setFillType (SkPath::kEvenOdd_FillType);
    else
	skPath.setFillType (SkPath::kWinding_FillType);

    return skPath;
}
开发者ID:AZed,项目名称:cairo,代码行数:14,代码来源:cairo-skia-surface.cpp

示例5: drawMask

    void drawMask(SkCanvas* canvas, const SkRect& r) {
        SkPaint paint;
        paint.setAntiAlias(true);

        if (true) {
            SkBitmap mask;
            int w = SkScalarRoundToInt(r.width());
            int h = SkScalarRoundToInt(r.height());
            mask.allocN32Pixels(w, h);
            mask.eraseColor(SK_ColorTRANSPARENT);
            SkCanvas c(mask);
            SkRect bounds = r;
            bounds.offset(-bounds.fLeft, -bounds.fTop);
            c.drawOval(bounds, paint);

            paint.setBlendMode(SkBlendMode::kDstIn);
            canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint);
        } else {
            SkPath p;
            p.addOval(r);
            p.setFillType(SkPath::kInverseWinding_FillType);
            paint.setBlendMode(SkBlendMode::kDstOut);
            canvas->drawPath(p, paint);
        }
    }
开发者ID:aseprite,项目名称:skia,代码行数:25,代码来源:SampleLayerMask.cpp

示例6: clipPath

bool PlatformGraphicsContextSkia::clipPath(const Path& pathToClip, WindRule clipRule)
{
    SkPath path = *pathToClip.platformPath();
    path.setFillType(clipRule == RULE_EVENODD
            ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
    return mCanvas->clipPath(path);
}
开发者ID:besk,项目名称:MT6589_kernel_source,代码行数:7,代码来源:PlatformGraphicsContextSkia.cpp

示例7: drawMask

    void drawMask(SkCanvas* canvas, const SkRect& r) {
        SkPaint paint;
        paint.setAntiAlias(true);

        if (true) {
            SkBitmap mask;
            int w = SkScalarRound(r.width());
            int h = SkScalarRound(r.height());
            mask.setConfig(SkBitmap::kARGB_8888_Config, w, h);
            mask.allocPixels();
            mask.eraseColor(0);
            SkCanvas c(mask);
            SkRect bounds = r;
            bounds.offset(-bounds.fLeft, -bounds.fTop);
            c.drawOval(bounds, paint);
            
            paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
            canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint);
        } else {
            SkPath p;
            p.addOval(r);
            p.setFillType(SkPath::kInverseWinding_FillType);
            paint.setXfermodeMode(SkXfermode::kDstOut_Mode);
            canvas->drawPath(p, paint);
        }
    }
开发者ID:ghub,项目名称:NVprSDK,代码行数:26,代码来源:SampleLayerMask.cpp

示例8: getSubsetPath

SkPath SubsetVerbs::getSubsetPath() const {
    SkPath result;
    result.setFillType(fPath.getFillType());
    if (!fSelected.count()) {
        return result;
    }
    SkPath::RawIter iter(fPath);
    uint8_t verb;
    SkPoint pts[4];
    int verbIndex = 0;
    bool addMoveTo = true;
    bool addLineTo = false;
    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
        bool enabled = SkPath::kLine_Verb <= verb && verb <= SkPath::kCubic_Verb
            ? fSelected[verbIndex++] : false;
        if (enabled) {
            if (addMoveTo) {
                result.moveTo(pts[0]);
                addMoveTo = false;
            } else if (addLineTo) {
                result.lineTo(pts[0]);
                addLineTo = false;
            }
        }
        switch (verb) {
            case SkPath::kMove_Verb:
                break;
            case SkPath::kLine_Verb:
                if (enabled) {
                    result.lineTo(pts[1]);
                }
                break;
            case SkPath::kQuad_Verb:
                if (enabled) {
                    result.quadTo(pts[1], pts[2]);
                }
                break;
            case SkPath::kConic_Verb:
                if (enabled) {
                    result.conicTo(pts[1], pts[2], iter.conicWeight());
                }
                break;
            case SkPath::kCubic_Verb:
                 if (enabled) {
                    result.cubicTo(pts[1], pts[2], pts[3]);
                }
                break;
            case SkPath::kClose_Verb:
                result.close();
                addMoveTo = true;
                addLineTo = false;
                continue;
            default:
                SkDEBUGFAIL("bad verb");
                return result;
        }
        addLineTo = !enabled;
    }
    return result;
}
开发者ID:03050903,项目名称:skia,代码行数:60,代码来源:SubsetPath.cpp

示例9: testSimplify

bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& state,
                  const char* pathStr) {
    SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType;
    path.setFillType(fillType);
    state.fReporter->bumpTestCount();
    if (!Simplify(path, &out)) {
        SkDebugf("%s did not expect failure\n", __FUNCTION__);
        REPORTER_ASSERT(state.fReporter, 0);
        return false;
    }
    if (!state.fReporter->verbose()) {
        return true;
    }
    int result = comparePaths(state.fReporter, nullptr, path, out, *state.fBitmap);
    if (result) {
        SkAutoMutexAcquire autoM(simplifyDebugOut);
        char temp[8192];
        sk_bzero(temp, sizeof(temp));
        SkMemoryWStream stream(temp, sizeof(temp));
        const char* pathPrefix = nullptr;
        const char* nameSuffix = nullptr;
        if (fillType == SkPath::kEvenOdd_FillType) {
            pathPrefix = "    path.setFillType(SkPath::kEvenOdd_FillType);\n";
            nameSuffix = "x";
        }
        const char testFunction[] = "testSimplify(reporter, path);";
        outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, stream);
        SkDebugf("%s", temp);
        REPORTER_ASSERT(state.fReporter, 0);
    }
    state.fReporter->bumpTestCount();
    return result == 0;
}
开发者ID:ericrk,项目名称:skia,代码行数:33,代码来源:PathOpsExtendedTest.cpp

示例10: operate

void operate(const SkPath& one, const SkPath& two, ShapeOp op, SkPath& result) {
    result.reset();
    result.setFillType(SkPath::kEvenOdd_FillType);
    // turn path into list of segments
    SkTArray<Op::Contour> contours;
    // FIXME: add self-intersecting cubics' T values to segment
    Op::EdgeBuilder builder(one, contours);
    const int aXorMask = builder.xorMask();
    builder.addOperand(two);
    const int bXorMask = builder.xorMask();
    builder.finish();
    SkTDArray<Op::Contour*> contourList;
    makeContourList(contours, contourList);
    Op::Contour** currentPtr = contourList.begin();
    if (!currentPtr) {
        return;
    }
    Op::Contour** listEnd = contourList.end();
    // find all intersections between segments
    do {
        Op::Contour** nextPtr = currentPtr;
        Op::Contour* current = *currentPtr++;
        Op::Contour* next;
        do {
            next = *nextPtr++;
        } while (addIntersectTs(current, next) && nextPtr != listEnd);
    } while (currentPtr != listEnd);
    // eat through coincident edges
    coincidenceCheck(contourList);
    fixOtherTIndex(contourList);
    // construct closed contours
    Op::PathWrapper wrapper(result);
    bridgeOp(contourList, op, aXorMask, bXorMask, wrapper);
}
开发者ID:bunhere,项目名称:skia,代码行数:34,代码来源:ShapeOps.cpp

示例11: testSimplifyx

bool testSimplifyx(SkPath& path, bool useXor, SkPath& out, State4& state,
        const char* pathStr) {
    SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType;
    path.setFillType(fillType);
    if (gShowPath) {
        showPath(path);
    }
    simplifyx(path, out);
    if (!gComparePaths) {
        return true;
    }
    int result = comparePaths(path, out, state.bitmap);
    if (result && gPathStrAssert) {
        SkDebugf("addTest %s\n", state.filename);
        char temp[8192];
        bzero(temp, sizeof(temp));
        SkMemoryWStream stream(temp, sizeof(temp));
        const char* pathPrefix = NULL;
        const char* nameSuffix = NULL;
        if (fillType == SkPath::kEvenOdd_FillType) {
            pathPrefix = "    path.setFillType(SkPath::kEvenOdd_FillType);\n";
            nameSuffix = "x";
        }
        const char testFunction[] = "testSimplifyx(path);";
        outputToStream(state, pathStr, pathPrefix, nameSuffix, testFunction, stream);
        SkDebugf(temp);
        SkASSERT(0);
    }
    return result == 0;
}
开发者ID:Cue,项目名称:skia,代码行数:30,代码来源:EdgeWalker_TestUtility.cpp

示例12: test_emptydrawing

/*  Two invariants are tested: How does an empty/degenerate path draw?
 *  - if the path is drawn inverse, it should draw everywhere
 *  - if the path is drawn non-inverse, it should draw nowhere
 *
 *  Things to iterate on:
 *  - path (empty, degenerate line/quad/cubic w/ and w/o close
 *  - paint style
 *  - path filltype
 *  - path stroke variants (e.g. caps, joins, width)
 */
static void test_emptydrawing(skiatest::Reporter* reporter) {
    static void (*gMakeProc[])(SkPath*) = {
        make_empty, make_M, make_MM, make_MZM, make_L, make_Q, make_C
    };
    static SkPath::FillType gFills[] = {
        SkPath::kWinding_FillType,
        SkPath::kEvenOdd_FillType,
        SkPath::kInverseWinding_FillType,
        SkPath::kInverseEvenOdd_FillType
    };
    for (int doClose = 0; doClose < 2; ++doClose) {
        for  (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProc); ++i) {
            SkPath path;
            gMakeProc[i](&path);
            if (doClose) {
                path.close();
            }
            for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) {
                path.setFillType(gFills[fill]);
                bool shouldDraw = path.isInverseFillType();
                iter_paint(reporter, path, shouldDraw);
            }
        }
    }
}
开发者ID:Adenilson,项目名称:skia,代码行数:35,代码来源:EmptyPathTest.cpp

示例13: draw_fill

 void draw_fill(SkCanvas* canvas, const SkRect& rect, SkScalar width) {
     if (rect.isEmpty()) {
         return;
     }
     SkPaint paint;
     paint.setColor(0x1f1f0f0f);
     paint.setStyle(SkPaint::kStroke_Style);
     paint.setStrokeWidth(width);
     SkPath path;
     SkScalar maxSide = SkTMax(rect.width(), rect.height()) / 2;
     SkPoint center = { rect.fLeft + maxSide, rect.fTop + maxSide };
     path.addCircle(center.fX, center.fY, maxSide);
     canvas->drawPath(path, paint);
     paint.setStyle(SkPaint::kFill_Style);
     path.reset();
     path.addCircle(center.fX, center.fY, maxSide - width / 2);
     paint.setColor(0x3f0f1f3f);
     canvas->drawPath(path, paint);
     path.reset();
     path.setFillType(SkPath::kEvenOdd_FillType);
     path.addCircle(center.fX, center.fY, maxSide + width / 2);
     SkRect outside = SkRect::MakeXYWH(center.fX - maxSide - width, center.fY - maxSide - width, 
             (maxSide + width) * 2, (maxSide + width) * 2);
     path.addRect(outside);
     canvas->drawPath(path, paint);
 }
开发者ID:Arternis,项目名称:skia,代码行数:26,代码来源:SampleQuadStroker.cpp

示例14: draw

/**
 * Draw a single path element of the clip stack into the accumulation bitmap
 */
void GrSWMaskHelper::draw(const SkPath& clientPath, SkRegion::Op op,
                          GrPathFill fill, bool antiAlias) {

    SkPaint paint;
    SkPath tmpPath;
    const SkPath* pathToDraw = &clientPath;
    if (kHairLine_PathFill == fill) {
        paint.setStyle(SkPaint::kStroke_Style);
        paint.setStrokeWidth(SK_Scalar1);
    } else {
        paint.setStyle(SkPaint::kFill_Style);
        SkPath::FillType skfill = gr_fill_to_sk_fill(fill);
        if (skfill != pathToDraw->getFillType()) {
            tmpPath = *pathToDraw;
            tmpPath.setFillType(skfill);
            pathToDraw = &tmpPath;
        }
    }
    SkXfermode* mode = SkXfermode::Create(op_to_mode(op));

    paint.setXfermode(mode);
    paint.setAntiAlias(antiAlias);
    paint.setColor(SK_ColorWHITE);

    fDraw.drawPath(*pathToDraw, paint);

    SkSafeUnref(mode);
}
开发者ID:Beifeng,项目名称:WTL-DUI,代码行数:31,代码来源:GrSoftwarePathRenderer.cpp

示例15: draw

 SkRect draw(SkCanvas* canvas, const SkPaint& paint) override {
     SkPath path;
     path.addCircle(15, 15, 10);
     path.addOval(SkRect::MakeXYWH(2, 2, 22, 37));
     path.setFillType(SkPath::kEvenOdd_FillType);
     canvas->drawPath(path, paint);
     return path.getBounds();
 }
开发者ID:jagannathanraman,项目名称:skia,代码行数:8,代码来源:dcshader.cpp


注:本文中的SkPath::setFillType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。