本文整理汇总了C++中SkAAClip类的典型用法代码示例。如果您正苦于以下问题:C++ SkAAClip类的具体用法?C++ SkAAClip怎么用?C++ SkAAClip使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkAAClip类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: AUTO_RASTERCLIP_VALIDATE
bool SkRasterClip::op(const SkRegion& rgn, SkRegion::Op op) {
AUTO_RASTERCLIP_VALIDATE(*this);
if (fIsBW) {
return fBW.op(rgn, op);
} else {
SkAAClip tmp;
tmp.setRegion(rgn);
return fAA.op(tmp, op);
}
}
示例4: AUTO_RASTERCLIP_VALIDATE
bool SkRasterClip::op(const SkRegion& rgn, SkRegion::Op op) {
AUTO_RASTERCLIP_VALIDATE(*this);
if (fIsBW) {
(void)fBW.op(rgn, op);
} else {
SkAAClip tmp;
tmp.setRegion(rgn);
(void)fAA.op(tmp, op);
}
return this->updateCacheAndReturnNonEmpty();
}
示例5: test_regressions
static void test_regressions() {
// these should not assert in the debug build
// bug was introduced in rev. 3209
{
SkAAClip clip;
SkRect r;
r.fLeft = 129.892181f;
r.fTop = 10.3999996f;
r.fRight = 130.892181f;
r.fBottom = 20.3999996f;
clip.setRect(r, true);
}
}
示例6: 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);
}
}
}
示例7: 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
}
示例8: copyToMask
static bool operator==(const SkRegion& rgn, const SkAAClip& aaclip) {
SkMask mask0, mask1;
copyToMask(rgn, &mask0);
aaclip.copyToMask(&mask1);
bool eq = (mask0 == mask1);
SkMask::FreeImage(mask0.fImage);
SkMask::FreeImage(mask1.fImage);
return eq;
}
示例9: drawClip
static void drawClip(SkCanvas* canvas, const SkAAClip& clip) {
SkMask mask;
SkBitmap bm;
clip.copyToMask(&mask);
SkAutoMaskFreeImage amfi(mask.fImage);
bm.installMaskPixels(mask);
SkPaint paint;
canvas->drawBitmap(bm,
SK_Scalar1 * mask.fBounds.fLeft,
SK_Scalar1 * mask.fBounds.fTop,
&paint);
}
示例10: drawClip
static void drawClip(SkCanvas* canvas, const SkAAClip& clip) {
SkMask mask;
SkBitmap bm;
clip.copyToMask(&mask);
SkAutoMaskFreeImage amfi(mask.fImage);
bm.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(),
mask.fBounds.height(), mask.fRowBytes);
bm.setPixels(mask.fImage);
SkPaint paint;
canvas->drawBitmap(bm,
SK_Scalar1 * mask.fBounds.fLeft,
SK_Scalar1 * mask.fBounds.fTop,
&paint);
}
示例11: 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());
}
示例12: ClipView
ClipView() {
SkAAClip clip;
SkIRect r = { -2, -3, 842, 18 };
clip.setRect(r);
}
示例13: onDraw
virtual void onDraw(int loops, SkCanvas*) {
for (int i = 0; i < loops; ++i) {
SkAAClip clip;
clip.setRegion(fRegion);
}
}
示例14: equalsAAClip
static bool equalsAAClip(const SkRegion& rgn) {
SkAAClip aaclip;
aaclip.setRegion(rgn);
return rgn == aaclip;
}