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


C++ SkRRect::setRectXY方法代码示例

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


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

示例1: draw

 SkRect draw(SkCanvas* canvas, const SkPaint& paint) override {
     SkRRect outerRRect;
     outerRRect.setRectXY(SkRect::MakeXYWH(0, 0, 50, 50), 5, 5);
     SkRRect innerRRect;
     innerRRect.setRectXY(SkRect::MakeXYWH(5, 8, 35, 30), 8, 3);
     canvas->drawDRRect(outerRRect, innerRRect, paint);
     return outerRRect.getBounds();
 }
开发者ID:jagannathanraman,项目名称:skia,代码行数:8,代码来源:dcshader.cpp

示例2: test_empty

// Test that all the SkRRect entry points correctly handle un-sorted and
// zero-sized input rects
static void test_empty(skiatest::Reporter* reporter) {
    static const SkRect oooRects[] = {  // out of order
        { 100, 0, 0, 100 },  // ooo horizontal
        { 0, 100, 100, 0 },  // ooo vertical
        { 100, 100, 0, 0 },  // ooo both
    };

    static const SkRect emptyRects[] = {
        { 100, 100, 100, 200 }, // empty horizontal
        { 100, 100, 200, 100 }, // empty vertical
        { 100, 100, 100, 100 }, // empty both
        { 0, 0, 0, 0 }          // setEmpty-empty
    };

    static const SkVector radii[4] = { { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 } };

    SkRRect r;

    for (size_t i = 0; i < SK_ARRAY_COUNT(oooRects); ++i) {
        r.setRect(oooRects[i]);
        REPORTER_ASSERT(reporter, !r.isEmpty());

        r.setOval(oooRects[i]);
        REPORTER_ASSERT(reporter, !r.isEmpty());

        r.setRectXY(oooRects[i], 1, 2);
        REPORTER_ASSERT(reporter, !r.isEmpty());

        r.setNinePatch(oooRects[i], 0, 1, 2, 3);
        REPORTER_ASSERT(reporter, !r.isEmpty());

        r.setRectRadii(oooRects[i], radii);
        REPORTER_ASSERT(reporter, !r.isEmpty());
    }

    for (size_t i = 0; i < SK_ARRAY_COUNT(emptyRects); ++i) {
        r.setRect(emptyRects[i]);
        REPORTER_ASSERT(reporter, r.isEmpty());

        r.setOval(emptyRects[i]);
        REPORTER_ASSERT(reporter, r.isEmpty());

        r.setRectXY(emptyRects[i], 1, 2);
        REPORTER_ASSERT(reporter, r.isEmpty());

        r.setNinePatch(emptyRects[i], 0, 1, 2, 3);
        REPORTER_ASSERT(reporter, r.isEmpty());

        r.setRectRadii(emptyRects[i], radii);
        REPORTER_ASSERT(reporter, r.isEmpty());
    }
}
开发者ID:03050903,项目名称:skia,代码行数:54,代码来源:RoundRectTest.cpp

示例3: while

std::unique_ptr<GrFragmentProcessor> EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
    SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
    SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
    SkVector r[4];
    r[SkRRect::kUpperLeft_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f);
    // ensure at least one corner really is elliptical
    do {
        r[SkRRect::kUpperLeft_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9.f);
    } while (r[SkRRect::kUpperLeft_Corner].fY == r[SkRRect::kUpperLeft_Corner].fX);

    SkRRect rrect;
    if (d->fRandom->nextBool()) {
        // half the time create a four-radii rrect.
        r[SkRRect::kLowerRight_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f);
        r[SkRRect::kLowerRight_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9.f);

        r[SkRRect::kUpperRight_Corner].fX = r[SkRRect::kLowerRight_Corner].fX;
        r[SkRRect::kUpperRight_Corner].fY = r[SkRRect::kUpperLeft_Corner].fY;

        r[SkRRect::kLowerLeft_Corner].fX = r[SkRRect::kUpperLeft_Corner].fX;
        r[SkRRect::kLowerLeft_Corner].fY = r[SkRRect::kLowerRight_Corner].fY;

        rrect.setRectRadii(SkRect::MakeWH(w, h), r);
    } else {
        rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
                                              r[SkRRect::kUpperLeft_Corner].fY);
    }
    std::unique_ptr<GrFragmentProcessor> fp;
    do {
        GrClipEdgeType et = (GrClipEdgeType)d->fRandom->nextULessThan(kGrClipEdgeTypeCnt);
        fp = GrRRectEffect::Make(et, rrect, *d->caps()->shaderCaps());
    } while (nullptr == fp);
    return fp;
}
开发者ID:android,项目名称:platform_external_skia,代码行数:34,代码来源:GrRRectEffect.cpp

示例4: emit_draw

static void emit_draw(SkCanvas* canvas, DrawOpType draw, SkTDArray<DrawType>* expected) {
    switch (draw) {
        case kNone_DrawOpType:
            break;
        case kClear_DrawOpType:
            canvas->clear(SK_ColorRED);
            *expected->append() = DRAW_CLEAR;
            break;
        case kOval_DrawOpType: {
            SkRect r = SkRect::MakeLTRB(10, 10, 90, 90);
            SkPaint p;
            canvas->drawOval(r, p);
            *expected->append() = DRAW_OVAL;
            break;
        }
        case kRect_DrawOpType: {
            SkRect r = SkRect::MakeLTRB(10, 10, 90, 90);
            SkPaint p;
            canvas->drawRect(r, p);
            *expected->append() = DRAW_RECT;
            break;
        }
        case kRRect_DrawOpType: {
            SkRect r = SkRect::MakeLTRB(10.0f, 10.0f, 90.0f, 90.0f);
            SkRRect rr;
            rr.setRectXY(r, 5.0f, 5.0f);
            SkPaint p;
            canvas->drawRRect(rr, p);
            *expected->append() = DRAW_RRECT;
            break;
        }
        default:
            SkASSERT(0);
    }
}
开发者ID:03050903,项目名称:skia,代码行数:35,代码来源:MatrixClipCollapseTest.cpp

示例5: onDraw

    void onDraw(SkCanvas* canvas) override {
        canvas->scale(1.5f, 1.5f);
        canvas->translate(50,50);

        const float blurRadii[] = { 1,5,10,20 };
        const int cornerRadii[] = { 1,5,10,20 };
        const SkRect r = SkRect::MakeWH(SkIntToScalar(25), SkIntToScalar(25));
        for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) {
            SkAutoCanvasRestore autoRestore(canvas, true);
            canvas->translate(0, (r.height() + SkIntToScalar(50)) * i);
            for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) {
                for (int k = 0; k <= 1; k++) {
                    SkMaskFilter* filter = SkBlurMaskFilter::Create(
                        kNormal_SkBlurStyle,
                        SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])),
                        SkBlurMaskFilter::kHighQuality_BlurFlag);
                    SkPaint paint;
                    paint.setColor(SK_ColorBLACK);
                    paint.setMaskFilter(filter)->unref();

                    bool useRadial = SkToBool(k);
                    if (useRadial) {
                        paint.setShader(MakeRadial());
                    }

                    SkRRect rrect;
                    rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]),
                                    SkIntToScalar(cornerRadii[j]));
                    canvas->drawRRect(rrect, paint);
                    canvas->translate(r.width() + SkIntToScalar(50), 0);
                }
            }
        }
    }
开发者ID:fluxxion82,项目名称:skia,代码行数:34,代码来源:blurroundrect.cpp

示例6: draw_rrect

static void draw_rrect(SkCanvas* canvas, const SkRect& r, const SkPaint& p) {
    SkScalar xRad = r.width() / 4.0f;
    SkScalar yRad = r.height() / 4.0f;

    SkRRect rr;
    rr.setRectXY(r, xRad, yRad);
    canvas->drawRRect(rr, p);
}
开发者ID:jagannathanraman,项目名称:skia,代码行数:8,代码来源:filterfastbounds.cpp

示例7: draw_drrect

static void draw_drrect(SkCanvas* canvas, const SkRect& r, const SkPaint& p) {
    SkScalar xRad = r.width() / 4.0f;
    SkScalar yRad = r.height() / 4.0f;

    SkRRect outer;
    outer.setRectXY(r, xRad, yRad);
    SkRRect inner = outer;
    inner.inset(xRad, yRad);
    canvas->drawDRRect(outer, inner, p);
}
开发者ID:jagannathanraman,项目名称:skia,代码行数:10,代码来源:filterfastbounds.cpp

示例8:

static void test_empty_crbug_458524(skiatest::Reporter* reporter) {
    SkRRect rr;
    const SkRect bounds = { 3709, 3709, 3709 + 7402, 3709 + 29825 };
    const SkScalar rad = 40;
    rr.setRectXY(bounds, rad, rad);

    SkRRect other;
    SkMatrix matrix;
    matrix.setScale(0, 1);
    rr.transform(matrix, &other);
    REPORTER_ASSERT(reporter, SkRRect::kEmpty_Type == other.getType());
}
开发者ID:Arternis,项目名称:skia,代码行数:12,代码来源:RoundRectTest.cpp

示例9: draw

void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setTextSize(16);
    SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 40, 30);
    canvas->drawRRect(rrect, paint);
    canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
    rrect.setRectXY(rrect.getBounds(), 35, 25);
    canvas->translate(128, 0);
    canvas->drawRRect(rrect, paint);
    canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
}
开发者ID:HalCanary,项目名称:skia-hc,代码行数:12,代码来源:RRect_isOval.cpp

示例10: rrect_clip

// Two pictures with a round rect clip on the second one
static void rrect_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
    canvas->drawPicture(pictures[0]);

    SkRect rect = pictures[0]->cullRect();
    rect.inset(kInset, kInset);

    SkRRect rrect;
    rrect.setRectXY(rect, kInset, kInset);

    canvas->clipRRect(rrect);

    canvas->drawPicture(pictures[1]);
}
开发者ID:aseprite,项目名称:skia,代码行数:14,代码来源:multipicturedraw.cpp

示例11:

static void test_empty_crbug_458524(skiatest::Reporter* reporter) {
    SkRRect rr;
    const SkRect bounds = { 3709, 3709, 3709 + 7402, 3709 + 29825 };
    const SkScalar rad = 40;
    rr.setRectXY(bounds, rad, rad);
    path_contains_rrect_check(reporter, rr);

    SkRRect other;
    SkMatrix matrix;
    matrix.setScale(0, 1);
    rr.transform(matrix, &other);
    path_contains_rrect_check(reporter, rr);
}
开发者ID:BertiKarsunke,项目名称:skia,代码行数:13,代码来源:RRectInPathTest.cpp

示例12: TestCreate

const GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
    SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
    SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
    SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f);
    SkRRect rrect;
    rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
    GrFragmentProcessor* fp;
    do {
        GrPrimitiveEdgeType et =
                (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt);
        fp = GrRRectEffect::Create(et, rrect);
    } while (nullptr == fp);
    return fp;
}
开发者ID:Nazi-Nigger,项目名称:gecko-dev,代码行数:14,代码来源:GrRRectEffect.cpp

示例13: makeRRect

 SkRRect makeRRect() {
     SkRRect rrect;
     RandomSetRRect rrectType = makeSetRRectType();
     if (fPrintName) {
         SkDebugf("%.*s%s\n", fPathDepth * 3, fTab, gRandomSetRRectNames[rrectType]);
     }
     switch (rrectType) {
     case kSetEmpty:
         rrect.setEmpty();
         break;
     case kSetRect: {
         SkRect rect = makeRect();
         rrect.setRect(rect);
     }
     break;
     case kSetOval: {
         SkRect oval = makeRect();
         rrect.setOval(oval);
     }
     break;
     case kSetRectXY: {
         SkRect rect = makeRect();
         SkScalar xRad = makeScalar();
         SkScalar yRad = makeScalar();
         rrect.setRectXY(rect, xRad, yRad);
     }
     break;
     case kSetNinePatch: {
         SkRect rect = makeRect();
         SkScalar leftRad = makeScalar();
         SkScalar topRad = makeScalar();
         SkScalar rightRad = makeScalar();
         SkScalar bottomRad = makeScalar();
         rrect.setNinePatch(rect, leftRad, topRad, rightRad, bottomRad);
         SkDebugf("");  // keep locals in scope
     }
     break;
     case kSetRectRadii: {
         SkRect rect = makeRect();
         SkVector radii[4];
         makeVectorArray(SK_ARRAY_COUNT(radii), radii);
         rrect.setRectRadii(rect, radii);
     }
     break;
     }
     return rrect;
 }
开发者ID:merckhung,项目名称:libui,代码行数:47,代码来源:SamplePathFuzz.cpp

示例14: TestCreate

GrFragmentProcessor* CircularRRectEffect::TestCreate(SkRandom* random,
                                                     GrContext*,
                                                     const GrDrawTargetCaps& caps,
                                                     GrTexture*[]) {
    SkScalar w = random->nextRangeScalar(20.f, 1000.f);
    SkScalar h = random->nextRangeScalar(20.f, 1000.f);
    SkScalar r = random->nextRangeF(kRadiusMin, 9.f);
    SkRRect rrect;
    rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
    GrFragmentProcessor* fp;
    do {
        GrPrimitiveEdgeType et =
                (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt);
        fp = GrRRectEffect::Create(et, rrect);
    } while (NULL == fp);
    return fp;
}
开发者ID:BenzoRoms,项目名称:external_skia,代码行数:17,代码来源:GrRRectEffect.cpp

示例15: drawshader_proc

static void drawshader_proc(SkCanvas* canvas, const SkBitmap& bm,
                            const SkPoint& pos) {
    SkRect r = {
        0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm.height())
    };
    r.offset(pos.fX, pos.fY);

    SkShader* s = SkShader::CreateBitmapShader(bm,
                                               SkShader::kClamp_TileMode,
                                               SkShader::kClamp_TileMode);
    SkPaint paint;
    paint.setShader(s)->unref();
    canvas->drawRect(r, paint);
    canvas->drawOval(r, paint);
    SkRRect rr;
    rr.setRectXY(r, 10, 10);
    canvas->drawRRect(rr, paint);
}
开发者ID:CriGio,项目名称:platform_external_skia,代码行数:18,代码来源:PictureTest.cpp


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