Merge "Support drawing circles with drawArc in new pipeline" into nyc-dev
am: 1fd5f379d7
* commit '1fd5f379d724cc673a37d52b977e67d82451343a':
Support drawing circles with drawArc in new pipeline
This commit is contained in:
@@ -406,12 +406,16 @@ void RecordingCanvas::drawOval(float left, float top, float right, float bottom,
|
||||
|
||||
void RecordingCanvas::drawArc(float left, float top, float right, float bottom,
|
||||
float startAngle, float sweepAngle, bool useCenter, const SkPaint& paint) {
|
||||
addOp(alloc().create_trivial<ArcOp>(
|
||||
Rect(left, top, right, bottom),
|
||||
*(mState.currentSnapshot()->transform),
|
||||
getRecordedClip(),
|
||||
refPaint(&paint),
|
||||
startAngle, sweepAngle, useCenter));
|
||||
if (fabs(sweepAngle) >= 360.0f) {
|
||||
drawOval(left, top, right, bottom, paint);
|
||||
} else {
|
||||
addOp(alloc().create_trivial<ArcOp>(
|
||||
Rect(left, top, right, bottom),
|
||||
*(mState.currentSnapshot()->transform),
|
||||
getRecordedClip(),
|
||||
refPaint(&paint),
|
||||
startAngle, sweepAngle, useCenter));
|
||||
}
|
||||
}
|
||||
|
||||
void RecordingCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
|
||||
|
||||
@@ -57,6 +57,22 @@ TEST(RecordingCanvas, clipRect) {
|
||||
<< "Clip should be serialized once";
|
||||
}
|
||||
|
||||
TEST(RecordingCanvas, drawArc) {
|
||||
auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [](RecordingCanvas& canvas) {
|
||||
canvas.drawArc(0, 0, 200, 200, 0, 180, true, SkPaint());
|
||||
canvas.drawArc(0, 0, 100, 100, 0, 360, true, SkPaint());
|
||||
});
|
||||
|
||||
auto&& ops = dl->getOps();
|
||||
ASSERT_EQ(2u, ops.size()) << "Must be exactly two ops";
|
||||
EXPECT_EQ(RecordedOpId::ArcOp, ops[0]->opId);
|
||||
EXPECT_EQ(Rect(200, 200), ops[0]->unmappedBounds);
|
||||
|
||||
EXPECT_EQ(RecordedOpId::OvalOp, ops[1]->opId)
|
||||
<< "Circular arcs should be converted to ovals";
|
||||
EXPECT_EQ(Rect(100, 100), ops[1]->unmappedBounds);
|
||||
}
|
||||
|
||||
TEST(RecordingCanvas, drawLines) {
|
||||
auto dl = TestUtils::createDisplayList<RecordingCanvas>(100, 200, [](RecordingCanvas& canvas) {
|
||||
SkPaint paint;
|
||||
|
||||
Reference in New Issue
Block a user