本文整理汇总了C++中SkAAClip::setPath方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAAClip::setPath方法的具体用法?C++ SkAAClip::setPath怎么用?C++ SkAAClip::setPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAAClip
的用法示例。
在下文中一共展示了SkAAClip::setPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_path_bounds
static void test_path_bounds(skiatest::Reporter* reporter) {
SkPath path;
SkAAClip clip;
const int height = 40;
const SkScalar sheight = SkIntToScalar(height);
path.addOval(SkRect::MakeWH(sheight, sheight));
REPORTER_ASSERT(reporter, sheight == path.getBounds().height());
clip.setPath(path, nullptr, true);
REPORTER_ASSERT(reporter, height == clip.getBounds().height());
// this is the trimmed height of this cubic (with aa). The critical thing
// for this test is that it is less than height, which represents just
// the bounds of the path's control-points.
//
// This used to fail until we tracked the MinY in the BuilderBlitter.
//
const int teardrop_height = 12;
path.reset();
imoveTo(path, 0, 20);
icubicTo(path, 40, 40, 40, 0, 0, 20);
REPORTER_ASSERT(reporter, sheight == path.getBounds().height());
clip.setPath(path, nullptr, true);
REPORTER_ASSERT(reporter, teardrop_height == clip.getBounds().height());
}
示例2: test_path_with_hole
static void test_path_with_hole(skiatest::Reporter* reporter) {
static const uint8_t gExpectedImage[] = {
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
};
SkMask expected;
expected.fBounds.set(0, 0, 4, 6);
expected.fRowBytes = 4;
expected.fFormat = SkMask::kA8_Format;
expected.fImage = (uint8_t*)gExpectedImage;
SkPath path;
path.addRect(SkRect::MakeXYWH(0, 0,
SkIntToScalar(4), SkIntToScalar(2)));
path.addRect(SkRect::MakeXYWH(0, SkIntToScalar(4),
SkIntToScalar(4), SkIntToScalar(2)));
for (int i = 0; i < 2; ++i) {
SkAAClip clip;
clip.setPath(path, nullptr, 1 == i);
SkMask mask;
clip.copyToMask(&mask);
SkAutoMaskFreeImage freeM(mask.fImage);
REPORTER_ASSERT(reporter, expected == mask);
}
}
示例3: onDraw
virtual void onDraw(SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
for (int i = 0; i < N; ++i) {
SkAAClip clip;
if (fDoPath) {
clip.setPath(fPath, &fRegion, fDoAA);
} else {
clip.setRect(fRect, fDoAA);
}
}
}
示例4: onDrawContent
virtual void onDrawContent(SkCanvas* canvas) {
#if 1
SkAAClip aaclip;
SkPath path;
SkRect bounds;
bounds.set(0, 0, 20, 20);
bounds.inset(SK_ScalarHalf, SK_ScalarHalf);
// path.addRect(bounds);
// path.addOval(bounds);
path.addRoundRect(bounds, 4, 4);
aaclip.setPath(path);
canvas->translate(30, 30);
drawClip(canvas, aaclip);
SkAAClip aaclip2;
path.offset(10, 10);
aaclip2.setPath(path);
canvas->translate(30, 0);
drawClip(canvas, aaclip2);
SkAAClip aaclip3;
aaclip3.op(aaclip, aaclip2, SkRegion::kIntersect_Op);
canvas->translate(30, 0);
drawClip(canvas, aaclip3);
#endif
#if 0
SkRect r;
r.set(0, 0, this->width(), this->height());
r.inset(20, 20);
canvas->clipRect(r);
SkPath path;
path.addRect(r);
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(SK_ColorRED);
canvas->drawPath(path, paint);
#endif
}
示例5: test_really_a_rect
static void test_really_a_rect(skiatest::Reporter* reporter) {
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(100, 100), 5, 5);
SkPath path;
path.addRRect(rrect);
SkAAClip clip;
clip.setPath(path);
REPORTER_ASSERT(reporter, clip.getBounds() == SkIRect::MakeWH(100, 100));
REPORTER_ASSERT(reporter, !clip.isRect());
// This rect should intersect the clip, but slice-out all of the "soft" parts,
// leaving just a rect.
const SkIRect ir = SkIRect::MakeLTRB(10, -10, 50, 90);
clip.op(ir, SkRegion::kIntersect_Op);
REPORTER_ASSERT(reporter, clip.getBounds() == SkIRect::MakeLTRB(10, 0, 50, 90));
// the clip recognized that that it is just a rect!
REPORTER_ASSERT(reporter, clip.isRect());
}