本文整理汇总了C++中SkRRect::radii方法的典型用法代码示例。如果您正苦于以下问题:C++ SkRRect::radii方法的具体用法?C++ SkRRect::radii怎么用?C++ SkRRect::radii使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkRRect
的用法示例。
在下文中一共展示了SkRRect::radii方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeRRect
Json::Value SkJSONCanvas::makeRRect(const SkRRect& rrect) {
Json::Value result(Json::arrayValue);
result.append(this->makeRect(rrect.rect()));
result.append(this->makePoint(rrect.radii(SkRRect::kUpperLeft_Corner)));
result.append(this->makePoint(rrect.radii(SkRRect::kUpperRight_Corner)));
result.append(this->makePoint(rrect.radii(SkRRect::kLowerRight_Corner)));
result.append(this->makePoint(rrect.radii(SkRRect::kLowerLeft_Corner)));
return result;
}
示例2: compute_tallest_occluder
// The tallest inset rect
SkRect compute_tallest_occluder(const SkRRect& rr) {
const SkRect& r = rr.getBounds();
const SkVector& ul = rr.radii(SkRRect::kUpperLeft_Corner);
const SkVector& ur = rr.radii(SkRRect::kUpperRight_Corner);
const SkVector& lr = rr.radii(SkRRect::kLowerRight_Corner);
const SkVector& ll = rr.radii(SkRRect::kLowerLeft_Corner);
SkScalar maxL = SkTMax(ul.fX, ll.fX);
SkScalar maxR = SkTMax(ur.fX, lr.fX);
return SkRect::MakeLTRB(r.fLeft + maxL, r.fTop, r.fRight - maxR, r.fBottom);
}
示例3: compute_widest_occluder
// The widest inset rect
SkRect compute_widest_occluder(const SkRRect& rr) {
const SkRect& r = rr.getBounds();
const SkVector& ul = rr.radii(SkRRect::kUpperLeft_Corner);
const SkVector& ur = rr.radii(SkRRect::kUpperRight_Corner);
const SkVector& lr = rr.radii(SkRRect::kLowerRight_Corner);
const SkVector& ll = rr.radii(SkRRect::kLowerLeft_Corner);
SkScalar maxT = SkTMax(ul.fY, ur.fY);
SkScalar maxB = SkTMax(ll.fY, lr.fY);
return SkRect::MakeLTRB(r.fLeft, r.fTop + maxT, r.fRight, r.fBottom - maxB);
}
示例4:
PassRefPtr<JSONObject> LoggingCanvas::objectForRadius(const SkRRect& rrect, SkRRect::Corner corner)
{
RefPtr<JSONObject> radiusItem = JSONObject::create();
SkVector radius = rrect.radii(corner);
radiusItem->setNumber("xRadius", radius.x());
radiusItem->setNumber("yRadius", radius.y());
return radiusItem.release();
}
示例5: SkASSERT
void InstancedRendering::Batch::appendRRectParams(const SkRRect& rrect) {
SkASSERT(!fIsTracked);
switch (rrect.getType()) {
case SkRRect::kSimple_Type: {
const SkVector& radii = rrect.getSimpleRadii();
this->appendParamsTexel(radii.x(), radii.y(), rrect.width(), rrect.height());
return;
}
case SkRRect::kNinePatch_Type: {
float twoOverW = 2 / rrect.width();
float twoOverH = 2 / rrect.height();
const SkVector& radiiTL = rrect.radii(SkRRect::kUpperLeft_Corner);
const SkVector& radiiBR = rrect.radii(SkRRect::kLowerRight_Corner);
this->appendParamsTexel(radiiTL.x() * twoOverW, radiiBR.x() * twoOverW,
radiiTL.y() * twoOverH, radiiBR.y() * twoOverH);
return;
}
case SkRRect::kComplex_Type: {
/**
* The x and y radii of each arc are stored in separate vectors,
* in the following order:
*
* __x1 _ _ _ x3__
* y1 | | y2
*
* | |
*
* y3 |__ _ _ _ __| y4
* x2 x4
*
*/
float twoOverW = 2 / rrect.width();
float twoOverH = 2 / rrect.height();
const SkVector& radiiTL = rrect.radii(SkRRect::kUpperLeft_Corner);
const SkVector& radiiTR = rrect.radii(SkRRect::kUpperRight_Corner);
const SkVector& radiiBR = rrect.radii(SkRRect::kLowerRight_Corner);
const SkVector& radiiBL = rrect.radii(SkRRect::kLowerLeft_Corner);
this->appendParamsTexel(radiiTL.x() * twoOverW, radiiBL.x() * twoOverW,
radiiTR.x() * twoOverW, radiiBR.x() * twoOverW);
this->appendParamsTexel(radiiTL.y() * twoOverH, radiiTR.y() * twoOverH,
radiiBL.y() * twoOverH, radiiBR.y() * twoOverH);
return;
}
default: return;
}
}
示例6: compute_central_occluder
// Use the intersection of the corners' diagonals with their ellipses to shrink
// the bounding rect
SkRect compute_central_occluder(const SkRRect& rr) {
const SkRect r = rr.getBounds();
SkScalar newL = r.fLeft, newT = r.fTop, newR = r.fRight, newB = r.fBottom;
SkVector radii = rr.radii(SkRRect::kUpperLeft_Corner);
if (!radii.isZero()) {
SkPoint p = intersection(radii.fX, radii.fY);
newL = SkTMax(newL, r.fLeft + radii.fX - p.fX);
newT = SkTMax(newT, r.fTop + radii.fY - p.fY);
}
radii = rr.radii(SkRRect::kUpperRight_Corner);
if (!radii.isZero()) {
SkPoint p = intersection(radii.fX, radii.fY);
newR = SkTMin(newR, r.fRight + p.fX - radii.fX);
newT = SkTMax(newT, r.fTop + radii.fY - p.fY);
}
radii = rr.radii(SkRRect::kLowerRight_Corner);
if (!radii.isZero()) {
SkPoint p = intersection(radii.fX, radii.fY);
newR = SkTMin(newR, r.fRight + p.fX - radii.fX);
newB = SkTMin(newB, r.fBottom - radii.fY + p.fY);
}
radii = rr.radii(SkRRect::kLowerLeft_Corner);
if (!radii.isZero()) {
SkPoint p = intersection(radii.fX, radii.fY);
newL = SkTMax(newL, r.fLeft + radii.fX - p.fX);
newB = SkTMin(newB, r.fBottom - radii.fY + p.fY);
}
return SkRect::MakeLTRB(newL, newT, newR, newB);
}
示例7: toString
static void toString(const SkRRect& rrect, SkString* str) {
SkRect r = rrect.getBounds();
str->appendf("[%g,%g %g:%g]",
SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop),
SkScalarToFloat(r.width()), SkScalarToFloat(r.height()));
if (rrect.isOval()) {
str->append("()");
} else if (rrect.isSimple()) {
const SkVector& rad = rrect.getSimpleRadii();
str->appendf("(%g,%g)", rad.x(), rad.y());
} else if (rrect.isComplex()) {
SkVector radii[4] = {
rrect.radii(SkRRect::kUpperLeft_Corner),
rrect.radii(SkRRect::kUpperRight_Corner),
rrect.radii(SkRRect::kLowerRight_Corner),
rrect.radii(SkRRect::kLowerLeft_Corner),
};
str->appendf("(%g,%g %g,%g %g,%g %g,%g)",
radii[0].x(), radii[0].y(),
radii[1].x(), radii[1].y(),
radii[2].x(), radii[2].y(),
radii[3].x(), radii[3].y());
}
}
示例8: SkScalarHalf
// Test out the case where an oval already off in space is translated/scaled
// further off into space - yielding numerical issues when the rect & radii
// are transformed separatly
// BUG=skia:2696
static void test_issue_2696(skiatest::Reporter* reporter) {
SkRRect rrect;
SkRect r = { 28443.8594f, 53.1428604f, 28446.7148f, 56.0000038f };
rrect.setOval(r);
SkMatrix xform;
xform.setAll(2.44f, 0.0f, 485411.7f,
0.0f, 2.44f, -438.7f,
0.0f, 0.0f, 1.0f);
SkRRect dst;
bool success = rrect.transform(xform, &dst);
REPORTER_ASSERT(reporter, success);
SkScalar halfWidth = SkScalarHalf(dst.width());
SkScalar halfHeight = SkScalarHalf(dst.height());
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter,
SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fX, halfWidth));
REPORTER_ASSERT(reporter,
SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fY, halfHeight));
}
}
示例9:
static void test_9patch_rrect(skiatest::Reporter* reporter,
const SkRect& rect,
SkScalar l, SkScalar t, SkScalar r, SkScalar b,
bool checkRadii) {
SkRRect rr;
rr.setNinePatch(rect, l, t, r, b);
REPORTER_ASSERT(reporter, SkRRect::kNinePatch_Type == rr.type());
REPORTER_ASSERT(reporter, rr.rect() == rect);
if (checkRadii) {
// This test doesn't hold if the radii will be rescaled by SkRRect
SkRect ninePatchRadii = { l, t, r, b };
SkPoint rquad[4];
ninePatchRadii.toQuad(rquad);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, rquad[i] == rr.radii((SkRRect::Corner) i));
}
}
SkRRect rr2; // construct the same RR using the most general set function
SkVector radii[4] = { { l, t }, { r, t }, { r, b }, { l, b } };
rr2.setRectRadii(rect, radii);
REPORTER_ASSERT(reporter, rr2 == rr && rr2.getType() == rr.getType());
}
示例10: test_tricky_radii
static void test_tricky_radii(skiatest::Reporter* reporter) {
{
// crbug.com/458522
SkRRect rr;
const SkRect bounds = { 3709, 3709, 3709 + 7402, 3709 + 29825 };
const SkScalar rad = 12814;
const SkVector vec[] = { { rad, rad }, { 0, rad }, { rad, rad }, { 0, rad } };
rr.setRectRadii(bounds, vec);
}
{
// crbug.com//463920
SkRect r = SkRect::MakeLTRB(0, 0, 1009, 33554432.0);
SkVector radii[4] = {
{ 13.0f, 8.0f }, { 170.0f, 2.0 }, { 256.0f, 33554432.0 }, { 110.0f, 5.0f }
};
SkRRect rr;
rr.setRectRadii(r, radii);
REPORTER_ASSERT(reporter, (double) rr.radii(SkRRect::kUpperRight_Corner).fY +
(double) rr.radii(SkRRect::kLowerRight_Corner).fY <=
rr.height());
}
}
示例11: test_round_rect_basic
// Test out the basic API entry points
static void test_round_rect_basic(skiatest::Reporter* reporter) {
// Test out initialization methods
SkPoint zeroPt = { 0, 0 };
SkRRect empty;
empty.setEmpty();
REPORTER_ASSERT(reporter, SkRRect::kEmpty_Type == empty.type());
REPORTER_ASSERT(reporter, empty.rect().isEmpty());
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, zeroPt == empty.radii((SkRRect::Corner) i));
}
//----
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
SkRRect rr1;
rr1.setRect(rect);
REPORTER_ASSERT(reporter, SkRRect::kRect_Type == rr1.type());
REPORTER_ASSERT(reporter, rr1.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, zeroPt == rr1.radii((SkRRect::Corner) i));
}
//----
SkPoint halfPoint = { SkScalarHalf(kWidth), SkScalarHalf(kHeight) };
SkRRect rr2;
rr2.setOval(rect);
REPORTER_ASSERT(reporter, SkRRect::kOval_Type == rr2.type());
REPORTER_ASSERT(reporter, rr2.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter,
rr2.radii((SkRRect::Corner) i).equalsWithinTolerance(halfPoint));
}
//----
SkPoint p = { 5, 5 };
SkRRect rr3;
rr3.setRectXY(rect, p.fX, p.fY);
REPORTER_ASSERT(reporter, SkRRect::kSimple_Type == rr3.type());
REPORTER_ASSERT(reporter, rr3.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, p == rr3.radii((SkRRect::Corner) i));
}
//----
SkPoint radii[4] = { { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 } };
SkRRect rr4;
rr4.setRectRadii(rect, radii);
REPORTER_ASSERT(reporter, SkRRect::kSimple_Type == rr4.type());
REPORTER_ASSERT(reporter, rr4.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, radii[i] == rr4.radii((SkRRect::Corner) i));
}
//----
SkPoint radii2[4] = { { 0, 0 }, { 0, 0 }, { 50, 50 }, { 20, 50 } };
SkRRect rr5;
rr5.setRectRadii(rect, radii2);
REPORTER_ASSERT(reporter, SkRRect::kComplex_Type == rr5.type());
REPORTER_ASSERT(reporter, rr5.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, radii2[i] == rr5.radii((SkRRect::Corner) i));
}
// Test out == & !=
REPORTER_ASSERT(reporter, empty != rr3);
REPORTER_ASSERT(reporter, rr3 == rr4);
REPORTER_ASSERT(reporter, rr4 != rr5);
}
示例12: Make
std::unique_ptr<GrFragmentProcessor> GrRRectEffect::Make(GrClipEdgeType edgeType,
const SkRRect& rrect,
const GrShaderCaps& caps) {
if (rrect.isRect()) {
return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
}
if (rrect.isOval()) {
return GrOvalEffect::Make(edgeType, rrect.getBounds(), caps);
}
if (rrect.isSimple()) {
if (SkRRectPriv::GetSimpleRadii(rrect).fX < kRadiusMin ||
SkRRectPriv::GetSimpleRadii(rrect).fY < kRadiusMin) {
// In this case the corners are extremely close to rectangular and we collapse the
// clip to a rectangular clip.
return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
}
if (SkRRectPriv::GetSimpleRadii(rrect).fX == SkRRectPriv::GetSimpleRadii(rrect).fY) {
return CircularRRectEffect::Make(edgeType, CircularRRectEffect::kAll_CornerFlags,
rrect);
} else {
return EllipticalRRectEffect::Make(edgeType, rrect);
}
}
if (rrect.isComplex() || rrect.isNinePatch()) {
// Check for the "tab" cases - two adjacent circular corners and two square corners.
SkScalar circularRadius = 0;
uint32_t cornerFlags = 0;
SkVector radii[4];
bool squashedRadii = false;
for (int c = 0; c < 4; ++c) {
radii[c] = rrect.radii((SkRRect::Corner)c);
SkASSERT((0 == radii[c].fX) == (0 == radii[c].fY));
if (0 == radii[c].fX) {
// The corner is square, so no need to squash or flag as circular.
continue;
}
if (radii[c].fX < kRadiusMin || radii[c].fY < kRadiusMin) {
radii[c].set(0, 0);
squashedRadii = true;
continue;
}
if (radii[c].fX != radii[c].fY) {
cornerFlags = ~0U;
break;
}
if (!cornerFlags) {
circularRadius = radii[c].fX;
cornerFlags = 1 << c;
} else {
if (radii[c].fX != circularRadius) {
cornerFlags = ~0U;
break;
}
cornerFlags |= 1 << c;
}
}
switch (cornerFlags) {
case CircularRRectEffect::kAll_CornerFlags:
// This rrect should have been caught in the simple case above. Though, it would
// be correctly handled in the fallthrough code.
SkASSERT(false);
case CircularRRectEffect::kTopLeft_CornerFlag:
case CircularRRectEffect::kTopRight_CornerFlag:
case CircularRRectEffect::kBottomRight_CornerFlag:
case CircularRRectEffect::kBottomLeft_CornerFlag:
case CircularRRectEffect::kLeft_CornerFlags:
case CircularRRectEffect::kTop_CornerFlags:
case CircularRRectEffect::kRight_CornerFlags:
case CircularRRectEffect::kBottom_CornerFlags: {
SkTCopyOnFirstWrite<SkRRect> rr(rrect);
if (squashedRadii) {
rr.writable()->setRectRadii(rrect.getBounds(), radii);
}
return CircularRRectEffect::Make(edgeType, cornerFlags, *rr);
}
case CircularRRectEffect::kNone_CornerFlags:
return GrConvexPolyEffect::Make(edgeType, rrect.getBounds());
default: {
if (squashedRadii) {
// If we got here then we squashed some but not all the radii to zero. (If all
// had been squashed cornerFlags would be 0.) The elliptical effect doesn't
// support some rounded and some square corners.
return nullptr;
}
if (rrect.isNinePatch()) {
return EllipticalRRectEffect::Make(edgeType, rrect);
}
return nullptr;
}
}
}
return nullptr;
}
示例13: test_transform_helper
// Called to test various transforms on a single SkRRect.
static void test_transform_helper(skiatest::Reporter* reporter, const SkRRect& orig) {
SkRRect dst;
dst.setEmpty();
// The identity matrix will duplicate the rrect.
bool success = orig.transform(SkMatrix::I(), &dst);
REPORTER_ASSERT(reporter, success);
REPORTER_ASSERT(reporter, orig == dst);
// Skew and Perspective make transform fail.
SkMatrix matrix;
matrix.reset();
matrix.setSkewX(SkIntToScalar(2));
assert_transform_failure(reporter, orig, matrix);
matrix.reset();
matrix.setSkewY(SkIntToScalar(3));
assert_transform_failure(reporter, orig, matrix);
matrix.reset();
matrix.setPerspX(4);
assert_transform_failure(reporter, orig, matrix);
matrix.reset();
matrix.setPerspY(5);
assert_transform_failure(reporter, orig, matrix);
// Rotation fails.
matrix.reset();
matrix.setRotate(SkIntToScalar(90));
assert_transform_failure(reporter, orig, matrix);
matrix.setRotate(SkIntToScalar(37));
assert_transform_failure(reporter, orig, matrix);
// Translate will keep the rect moved, but otherwise the same.
matrix.reset();
SkScalar translateX = SkIntToScalar(32);
SkScalar translateY = SkIntToScalar(15);
matrix.setTranslateX(translateX);
matrix.setTranslateY(translateY);
dst.setEmpty();
success = orig.transform(matrix, &dst);
REPORTER_ASSERT(reporter, success);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter,
orig.radii((SkRRect::Corner) i) == dst.radii((SkRRect::Corner) i));
}
REPORTER_ASSERT(reporter, orig.rect().width() == dst.rect().width());
REPORTER_ASSERT(reporter, orig.rect().height() == dst.rect().height());
REPORTER_ASSERT(reporter, dst.rect().left() == orig.rect().left() + translateX);
REPORTER_ASSERT(reporter, dst.rect().top() == orig.rect().top() + translateY);
// Keeping the translation, but adding skew will make transform fail.
matrix.setSkewY(SkIntToScalar(7));
assert_transform_failure(reporter, orig, matrix);
// Scaling in -x will flip the round rect horizontally.
matrix.reset();
matrix.setScaleX(SkIntToScalar(-1));
dst.setEmpty();
success = orig.transform(matrix, &dst);
REPORTER_ASSERT(reporter, success);
{
GET_RADII;
// Radii have swapped in x.
REPORTER_ASSERT(reporter, origUL == dstUR);
REPORTER_ASSERT(reporter, origUR == dstUL);
REPORTER_ASSERT(reporter, origLR == dstLL);
REPORTER_ASSERT(reporter, origLL == dstLR);
}
// Width and height remain the same.
REPORTER_ASSERT(reporter, orig.rect().width() == dst.rect().width());
REPORTER_ASSERT(reporter, orig.rect().height() == dst.rect().height());
// Right and left have swapped (sort of)
REPORTER_ASSERT(reporter, orig.rect().right() == -dst.rect().left());
// Top has stayed the same.
REPORTER_ASSERT(reporter, orig.rect().top() == dst.rect().top());
// Keeping the scale, but adding a persp will make transform fail.
matrix.setPerspX(7);
assert_transform_failure(reporter, orig, matrix);
// Scaling in -y will flip the round rect vertically.
matrix.reset();
matrix.setScaleY(SkIntToScalar(-1));
dst.setEmpty();
success = orig.transform(matrix, &dst);
REPORTER_ASSERT(reporter, success);
{
GET_RADII;
// Radii have swapped in y.
REPORTER_ASSERT(reporter, origUL == dstLL);
REPORTER_ASSERT(reporter, origUR == dstLR);
REPORTER_ASSERT(reporter, origLR == dstUR);
REPORTER_ASSERT(reporter, origLL == dstUL);
}
// Width and height remain the same.
REPORTER_ASSERT(reporter, orig.rect().width() == dst.rect().width());
REPORTER_ASSERT(reporter, orig.rect().height() == dst.rect().height());
//.........这里部分代码省略.........
示例14: test_round_rect_basic
// Test out the basic API entry points
static void test_round_rect_basic(skiatest::Reporter* reporter) {
// Test out initialization methods
SkPoint zeroPt = { 0, 0 };
SkRRect empty;
empty.setEmpty();
REPORTER_ASSERT(reporter, SkRRect::kEmpty_Type == empty.type());
REPORTER_ASSERT(reporter, empty.rect().isEmpty());
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, zeroPt == empty.radii((SkRRect::Corner) i));
}
//----
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
SkRRect rr1;
rr1.setRect(rect);
REPORTER_ASSERT(reporter, SkRRect::kRect_Type == rr1.type());
REPORTER_ASSERT(reporter, rr1.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, zeroPt == rr1.radii((SkRRect::Corner) i));
}
SkRRect rr1_2; // construct the same RR using the most general set function
SkVector rr1_2_radii[4] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
rr1_2.setRectRadii(rect, rr1_2_radii);
REPORTER_ASSERT(reporter, rr1_2 == rr1 && rr1_2.getType() == rr1.getType());
SkRRect rr1_3; // construct the same RR using the nine patch set function
rr1_3.setNinePatch(rect, 0, 0, 0, 0);
REPORTER_ASSERT(reporter, rr1_3 == rr1 && rr1_3.getType() == rr1.getType());
//----
SkPoint halfPoint = { SkScalarHalf(kWidth), SkScalarHalf(kHeight) };
SkRRect rr2;
rr2.setOval(rect);
REPORTER_ASSERT(reporter, SkRRect::kOval_Type == rr2.type());
REPORTER_ASSERT(reporter, rr2.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter,
rr2.radii((SkRRect::Corner) i).equalsWithinTolerance(halfPoint));
}
SkRRect rr2_2; // construct the same RR using the most general set function
SkVector rr2_2_radii[4] = { { halfPoint.fX, halfPoint.fY }, { halfPoint.fX, halfPoint.fY },
{ halfPoint.fX, halfPoint.fY }, { halfPoint.fX, halfPoint.fY } };
rr2_2.setRectRadii(rect, rr2_2_radii);
REPORTER_ASSERT(reporter, rr2_2 == rr2 && rr2_2.getType() == rr2.getType());
SkRRect rr2_3; // construct the same RR using the nine patch set function
rr2_3.setNinePatch(rect, halfPoint.fX, halfPoint.fY, halfPoint.fX, halfPoint.fY);
REPORTER_ASSERT(reporter, rr2_3 == rr2 && rr2_3.getType() == rr2.getType());
//----
SkPoint p = { 5, 5 };
SkRRect rr3;
rr3.setRectXY(rect, p.fX, p.fY);
REPORTER_ASSERT(reporter, SkRRect::kSimple_Type == rr3.type());
REPORTER_ASSERT(reporter, rr3.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, p == rr3.radii((SkRRect::Corner) i));
}
SkRRect rr3_2; // construct the same RR using the most general set function
SkVector rr3_2_radii[4] = { { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 } };
rr3_2.setRectRadii(rect, rr3_2_radii);
REPORTER_ASSERT(reporter, rr3_2 == rr3 && rr3_2.getType() == rr3.getType());
SkRRect rr3_3; // construct the same RR using the nine patch set function
rr3_3.setNinePatch(rect, 5, 5, 5, 5);
REPORTER_ASSERT(reporter, rr3_3 == rr3 && rr3_3.getType() == rr3.getType());
//----
test_9patch_rrect(reporter, rect, 10, 9, 8, 7, true);
{
// Test out the rrect from skia:3466
SkRect rect2 = SkRect::MakeLTRB(0.358211994f, 0.755430222f, 0.872866154f, 0.806214333f);
test_9patch_rrect(reporter,
rect2,
0.926942348f, 0.642850280f, 0.529063463f, 0.587844372f,
false);
}
//----
SkPoint radii2[4] = { { 0, 0 }, { 0, 0 }, { 50, 50 }, { 20, 50 } };
SkRRect rr5;
rr5.setRectRadii(rect, radii2);
REPORTER_ASSERT(reporter, SkRRect::kComplex_Type == rr5.type());
REPORTER_ASSERT(reporter, rr5.rect() == rect);
for (int i = 0; i < 4; ++i) {
REPORTER_ASSERT(reporter, radii2[i] == rr5.radii((SkRRect::Corner) i));
}
//.........这里部分代码省略.........