Reverts "[Impeller] Migrate unit tests off of Skia geometry classes (#161855)" (#162046)

<!-- start_original_pr_link -->
Reverts: flutter/flutter#161855
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: harryterkelsen
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: causing test failures on `linux_unopt` shard


https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20Production%20Engine%20Drone/1044163/infra
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: flar
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {jonahwilliams}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
Handles the impeller unittests line in
https://github.com/flutter/flutter/issues/161456

This PR is focused on the unit tests in Impeller. There are still some
uses in other non-test areas which will be handled in a separate PR.
<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
This commit is contained in:
auto-submit[bot] 2025-01-23 00:04:48 +00:00 committed by GitHub
parent b2f515f45e
commit c75d799dc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 1085 additions and 1279 deletions

View File

@ -1793,7 +1793,7 @@ TEST_F(DisplayListTest, FlutterSvgIssue661BoundsWereEmpty) {
{32.3f, 14.615f}, //
{32.3f, 19.34f});
path_builder1.Close();
DlPath dl_path1 = DlPath(path_builder1, DlPathFillType::kNonZero);
DlPath dl_path1 = DlPath(path_builder1.TakePath(DlPathFillType::kNonZero));
DlPathBuilder path_builder2;
path_builder2.MoveTo({37.5f, 19.33f});
@ -1806,7 +1806,7 @@ TEST_F(DisplayListTest, FlutterSvgIssue661BoundsWereEmpty) {
{37.495f, 11.756f}, //
{37.5f, 19.33f});
path_builder2.Close();
DlPath dl_path2 = DlPath(path_builder2, DlPathFillType::kNonZero);
DlPath dl_path2 = DlPath(path_builder2.TakePath(DlPathFillType::kNonZero));
DisplayListBuilder builder;
DlPaint paint = DlPaint(DlColor::kWhite()).setAntiAlias(true);
@ -4878,7 +4878,7 @@ TEST_F(DisplayListTest, ClipPathNonCulling) {
path_builder.LineTo({1000.0f, 0.0f});
path_builder.LineTo({0.0f, 1000.0f});
path_builder.Close();
DlPath path = DlPath(path_builder);
DlPath path = DlPath(path_builder.TakePath());
// Double checking that the path does indeed contain the clip. But,
// sadly, the Builder will not check paths for coverage to this level

View File

@ -62,33 +62,6 @@ DlPath DlPath::MakeRoundRectXY(const DlRect& rect,
counter_clock_wise ? SkPathDirection::kCCW : SkPathDirection::kCW));
}
DlPath DlPath::MakeLine(const DlPoint& a, const DlPoint& b) {
return DlPath(SkPath::Line(ToSkPoint(a), ToSkPoint(b)));
}
DlPath DlPath::MakePoly(const DlPoint pts[],
int count,
bool close,
DlPathFillType fill_type) {
return DlPath(
SkPath::Polygon(ToSkPoints(pts), count, close, ToSkFillType(fill_type)));
}
DlPath DlPath::MakeArc(const DlRect& bounds,
DlDegrees start,
DlDegrees end,
bool use_center) {
SkPath path;
if (use_center) {
path.moveTo(ToSkPoint(bounds.GetCenter()));
}
path.arcTo(ToSkRect(bounds), start.degrees, end.degrees, !use_center);
if (use_center) {
path.close();
}
return DlPath(path);
}
const SkPath& DlPath::GetSkPath() const {
auto& sk_path = data_->sk_path;
auto& path = data_->path;
@ -234,24 +207,16 @@ bool DlPath::IsVolatile() const {
return GetSkPath().isVolatile();
}
bool DlPath::IsConvex() const {
if (data_->sk_path_original) {
auto& sk_path = data_->sk_path;
FML_DCHECK(sk_path.has_value());
return sk_path.has_value() && sk_path->isConvex();
} else {
auto& path = data_->path;
FML_DCHECK(path.has_value());
return path.has_value() && path->IsConvex();
}
}
DlPath DlPath::operator+(const DlPath& other) const {
SkPath path = GetSkPath();
path.addPath(other.GetSkPath());
return DlPath(path);
}
DlPath::Data::Data(const SkPath& path) : sk_path(path) {
FML_DCHECK(!SkPathFillType_IsInverse(path.getFillType()));
}
SkPath DlPath::ConvertToSkiaPath(const Path& path, const DlPoint& shift) {
SkPath sk_path;
sk_path.setFillType(ToSkFillType(path.GetFillType()));
@ -373,16 +338,26 @@ Path DlPath::ConvertToImpellerPath(const SkPath& path, const DlPoint& shift) {
}
} while (verb != SkPath::Verb::kDone_Verb);
DlRect bounds = ToDlRect(path.getBounds());
if (!shift.IsZero()) {
builder.Shift(shift);
bounds = bounds.Shift(shift);
FillType fill_type;
switch (path.getFillType()) {
case SkPathFillType::kWinding:
fill_type = FillType::kNonZero;
break;
case SkPathFillType::kEvenOdd:
fill_type = FillType::kOdd;
break;
case SkPathFillType::kInverseWinding:
case SkPathFillType::kInverseEvenOdd:
FML_UNREACHABLE();
}
builder.SetConvexity(path.isConvex() ? Convexity::kConvex
: Convexity::kUnknown);
builder.SetBounds(bounds);
return builder.TakePath(ToDlFillType(path.getFillType()));
if (!shift.IsZero()) {
builder.Shift(shift);
}
auto sk_bounds = path.getBounds().makeOutset(shift.x, shift.y);
builder.SetBounds(ToDlRect(sk_bounds));
return builder.TakePath(fill_type);
}
} // namespace flutter

View File

@ -43,24 +43,10 @@ class DlPath {
DlScalar y_radius,
bool counter_clock_wise = false);
static DlPath MakeLine(const DlPoint& a, const DlPoint& b);
static DlPath MakePoly(const DlPoint pts[],
int count,
bool close,
DlPathFillType fill_type = DlPathFillType::kNonZero);
static DlPath MakeArc(const DlRect& bounds,
DlDegrees start,
DlDegrees end,
bool use_center);
DlPath() : data_(std::make_shared<Data>(SkPath())) {}
explicit DlPath(const SkPath& path) : data_(std::make_shared<Data>(path)) {}
explicit DlPath(const impeller::Path& path)
: data_(std::make_shared<Data>(path)) {}
explicit DlPath(DlPathBuilder& builder,
DlPathFillType fill_type = DlPathFillType::kNonZero)
: data_(std::make_shared<Data>(builder.TakePath(fill_type))) {}
DlPath(const DlPath& path) = default;
DlPath(DlPath&& path) = default;
@ -98,22 +84,18 @@ class DlPath {
bool IsConverted() const;
bool IsVolatile() const;
bool IsConvex() const;
bool IsEvenOdd() const;
DlPath operator+(const DlPath& other) const;
private:
struct Data {
explicit Data(const SkPath& path) : sk_path(path), sk_path_original(true) {
FML_DCHECK(!SkPathFillType_IsInverse(path.getFillType()));
}
explicit Data(const impeller::Path& path)
: path(path), sk_path_original(false) {}
explicit Data(const SkPath& path);
explicit Data(const impeller::Path& path) : path(path) {}
std::optional<SkPath> sk_path;
std::optional<impeller::Path> path;
uint32_t render_count = 0u;
const bool sk_path_original;
};
inline constexpr static DlPathFillType ToDlFillType(SkPathFillType sk_type) {

View File

@ -26,7 +26,6 @@ TEST(DisplayListPath, DefaultConstruction) {
EXPECT_FALSE(path.IsRect(nullptr, &is_closed));
EXPECT_FALSE(is_closed);
EXPECT_FALSE(path.IsOval(nullptr));
EXPECT_FALSE(path.IsRoundRect(nullptr));
is_closed = false;
EXPECT_FALSE(path.IsSkRect(nullptr));
@ -56,7 +55,6 @@ TEST(DisplayListPath, ConstructFromEmptySkiaPath) {
EXPECT_FALSE(path.IsRect(nullptr, &is_closed));
EXPECT_FALSE(is_closed);
EXPECT_FALSE(path.IsOval(nullptr));
EXPECT_FALSE(path.IsRoundRect(nullptr));
is_closed = false;
EXPECT_FALSE(path.IsSkRect(nullptr));
@ -87,7 +85,6 @@ TEST(DisplayListPath, ConstructFromEmptyImpellerPath) {
EXPECT_FALSE(path.IsRect(nullptr, &is_closed));
EXPECT_FALSE(is_closed);
EXPECT_FALSE(path.IsOval(nullptr));
EXPECT_FALSE(path.IsRoundRect(nullptr));
is_closed = false;
EXPECT_FALSE(path.IsSkRect(nullptr));
@ -117,7 +114,6 @@ TEST(DisplayListPath, CopyConstruct) {
EXPECT_FALSE(path2.IsRect(nullptr, &is_closed));
EXPECT_FALSE(is_closed);
EXPECT_TRUE(path2.IsOval(nullptr));
EXPECT_FALSE(path2.IsRoundRect(nullptr));
is_closed = false;
EXPECT_FALSE(path2.IsSkRect(nullptr));
@ -148,7 +144,6 @@ TEST(DisplayListPath, ConstructFromVolatile) {
EXPECT_FALSE(path.IsRect(nullptr, &is_closed));
EXPECT_FALSE(is_closed);
EXPECT_FALSE(path.IsOval(nullptr));
EXPECT_FALSE(path.IsRoundRect(nullptr));
is_closed = false;
EXPECT_FALSE(path.IsSkRect(nullptr));
@ -253,7 +248,6 @@ TEST(DisplayListPath, EmbeddingSharedReference) {
EXPECT_FALSE(path_.IsRect(nullptr, &is_closed)) << label;
EXPECT_FALSE(is_closed) << label;
EXPECT_TRUE(path_.IsOval(nullptr)) << label;
EXPECT_FALSE(path_.IsRoundRect(nullptr));
is_closed = false;
EXPECT_FALSE(path_.IsSkRect(nullptr)) << label;
@ -302,48 +296,6 @@ TEST(DisplayListPath, ConstructFromRect) {
EXPECT_EQ(dl_rect, DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_TRUE(is_closed);
EXPECT_FALSE(path.IsOval(nullptr));
EXPECT_FALSE(path.IsRoundRect(nullptr));
is_closed = false;
EXPECT_TRUE(path.IsSkRect(nullptr));
SkRect sk_rect;
EXPECT_TRUE(path.IsSkRect(&sk_rect, &is_closed));
EXPECT_EQ(sk_rect, SkRect::MakeLTRB(10, 10, 20, 20));
EXPECT_TRUE(is_closed);
EXPECT_FALSE(path.IsSkOval(nullptr));
EXPECT_FALSE(path.IsSkRRect(nullptr));
EXPECT_EQ(path.GetBounds(), DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_EQ(path.GetSkBounds(), SkRect::MakeLTRB(10, 10, 20, 20));
}
TEST(DisplayListPath, ConstructFromDlPathBuilderRect) {
DlPathBuilder builder;
builder.AddRect(DlRect::MakeLTRB(10, 10, 20, 20));
DlPath path(builder);
EXPECT_FALSE(path.IsConverted());
// Paths constructed from PathBuilder don't match paths built from similar
// SkRect and SkPath and DlPath factory methods exactly, only paths built
// from similar PathBuilder calls match exactly for == comparison
{
DlPathBuilder builder2;
builder2.AddRect(DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_EQ(path, DlPath(builder2));
}
EXPECT_TRUE(path.IsConverted());
EXPECT_FALSE(path.GetSkPath().isEmpty());
EXPECT_FALSE(path.GetPath().IsEmpty());
bool is_closed = false;
EXPECT_TRUE(path.IsRect(nullptr));
DlRect dl_rect;
EXPECT_TRUE(path.IsRect(&dl_rect, &is_closed));
EXPECT_EQ(dl_rect, DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_TRUE(is_closed);
EXPECT_FALSE(path.IsOval(nullptr));
EXPECT_FALSE(path.IsRoundRect(nullptr));
is_closed = false;
EXPECT_TRUE(path.IsSkRect(nullptr));
@ -374,7 +326,6 @@ TEST(DisplayListPath, ConstructFromOval) {
DlRect dl_bounds;
EXPECT_TRUE(path.IsOval(&dl_bounds));
EXPECT_EQ(dl_bounds, DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_FALSE(path.IsRoundRect(nullptr));
EXPECT_FALSE(path.IsSkRect(nullptr));
EXPECT_TRUE(path.IsSkOval(nullptr));
@ -387,47 +338,6 @@ TEST(DisplayListPath, ConstructFromOval) {
EXPECT_EQ(path.GetSkBounds(), SkRect::MakeLTRB(10, 10, 20, 20));
}
TEST(DisplayListPath, ConstructFromDlPathBuilderOval) {
DlPathBuilder builder;
builder.AddOval(DlRect::MakeLTRB(10, 10, 20, 20));
DlPath path(builder);
EXPECT_FALSE(path.IsConverted());
// Paths constructed from PathBuilder don't match paths built from similar
// SkRect and SkPath and DlPath factory methods exactly, only paths built
// from similar PathBuilder calls match exactly for == comparison
{
DlPathBuilder builder2;
builder2.AddOval(DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_EQ(path, DlPath(builder2));
}
EXPECT_TRUE(path.IsConverted());
EXPECT_FALSE(path.GetSkPath().isEmpty());
EXPECT_FALSE(path.GetPath().IsEmpty());
// Skia path, used for these tests, doesn't recognize ovals created
// by PathBuilder
EXPECT_FALSE(path.IsRect(nullptr));
// EXPECT_TRUE(path.IsOval(nullptr));
// DlRect dl_bounds;
// EXPECT_TRUE(path.IsOval(&dl_bounds));
// EXPECT_EQ(dl_bounds, DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_FALSE(path.IsRoundRect(nullptr));
// Skia path, used for these tests, doesn't recognize ovals created
// by PathBuilder
EXPECT_FALSE(path.IsSkRect(nullptr));
// EXPECT_TRUE(path.IsSkOval(nullptr));
// SkRect sk_bounds;
// EXPECT_TRUE(path.IsSkOval(&sk_bounds));
// EXPECT_EQ(sk_bounds, SkRect::MakeLTRB(10, 10, 20, 20));
EXPECT_FALSE(path.IsSkRRect(nullptr));
EXPECT_EQ(path.GetBounds(), DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_EQ(path.GetSkBounds(), SkRect::MakeLTRB(10, 10, 20, 20));
}
TEST(DisplayListPath, ConstructFromRRect) {
SkPath sk_path = SkPath::RRect(SkRect::MakeLTRB(10, 10, 20, 20), 1, 2);
DlPath path(sk_path);
@ -438,16 +348,11 @@ TEST(DisplayListPath, ConstructFromRRect) {
SkPath::RRect(SkRect::MakeLTRB(10, 10, 20, 20), 1, 2));
EXPECT_FALSE(path.IsConverted());
EXPECT_FALSE(path.GetSkPath().isEmpty());
EXPECT_FALSE(path.GetPath().IsEmpty());
EXPECT_TRUE(path.IsConverted());
EXPECT_FALSE(path.IsRect(nullptr));
EXPECT_FALSE(path.IsOval(nullptr));
DlRoundRect roundrect;
EXPECT_TRUE(path.IsRoundRect(&roundrect));
EXPECT_EQ(roundrect,
DlRoundRect::MakeRectXY(DlRect::MakeLTRB(10, 10, 20, 20), 1, 2));
EXPECT_FALSE(path.IsSkRect(nullptr));
EXPECT_FALSE(path.IsSkOval(nullptr));
@ -461,50 +366,6 @@ TEST(DisplayListPath, ConstructFromRRect) {
EXPECT_EQ(path.GetSkBounds(), SkRect::MakeLTRB(10, 10, 20, 20));
}
TEST(DisplayListPath, ConstructFromDlPathBuilderRoundRect) {
DlPathBuilder builder;
builder.AddRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeLTRB(10, 10, 20, 20), 1, 2));
DlPath path(builder);
EXPECT_FALSE(path.IsConverted());
// Paths constructed from PathBuilder don't match paths built from similar
// SkRRect and SkPath and DlPath factory methods exactly, only built from
// similar PathBuilder calls match exactly for == comparison
{
DlPathBuilder builder2;
builder2.AddRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeLTRB(10, 10, 20, 20), 1, 2));
EXPECT_EQ(path, DlPath(builder2));
}
EXPECT_TRUE(path.IsConverted());
EXPECT_FALSE(path.GetSkPath().isEmpty());
EXPECT_FALSE(path.GetPath().IsEmpty());
// Skia path, used for these tests, doesn't recognize ovals created
// by PathBuilder
EXPECT_FALSE(path.IsRect(nullptr));
EXPECT_FALSE(path.IsOval(nullptr));
// DlRoundRect roundrect;
// EXPECT_TRUE(path.IsRoundRect(&roundrect));
// EXPECT_EQ(roundrect,
// DlRoundRect::MakeRectXY(DlRect::MakeLTRB(10, 10, 20, 20), 1, 2));
// Skia path, used for these tests, doesn't recognize round rects created
// by PathBuilder
EXPECT_FALSE(path.IsSkRect(nullptr));
EXPECT_FALSE(path.IsSkOval(nullptr));
// EXPECT_TRUE(path.IsSkRRect(nullptr));
// SkRRect rrect2;
// EXPECT_TRUE(path.IsSkRRect(&rrect2));
// EXPECT_EQ(rrect2,
// SkRRect::MakeRectXY(SkRect::MakeLTRB(10, 10, 20, 20), 1, 2));
EXPECT_EQ(path.GetBounds(), DlRect::MakeLTRB(10, 10, 20, 20));
EXPECT_EQ(path.GetSkBounds(), SkRect::MakeLTRB(10, 10, 20, 20));
}
TEST(DisplayListPath, ConstructFromPath) {
SkPath sk_path1;
sk_path1.moveTo(10, 10);
@ -550,7 +411,8 @@ TEST(DisplayListPath, ConstructFromImpellerEqualsConstructFromSkia) {
sk_path.lineTo(0, 0); // Shouldn't be needed, but PathBuilder draws this
sk_path.close();
EXPECT_EQ(DlPath(path_builder, DlPathFillType::kNonZero), DlPath(sk_path));
EXPECT_EQ(DlPath(path_builder.TakePath(DlPathFillType::kNonZero)),
DlPath(sk_path));
}
#ifndef NDEBUG

View File

@ -16,6 +16,7 @@
#include "impeller/entity/contents/content_context.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/scalar.h"
#include "include/core/SkRefCnt.h"
namespace impeller {
namespace testing {

View File

@ -23,6 +23,7 @@
#include "impeller/playground/playground.h"
#include "impeller/playground/playground_test.h"
#include "impeller/renderer/testing/mocks.h"
#include "include/core/SkMatrix.h"
////////////////////////////////////////////////////////////////////////////////
// This is for tests of Canvas that are interested the results of rendering
@ -61,19 +62,19 @@ static BlendModeSelection GetBlendModeSelection() {
TEST_P(AiksTest, CanRenderAdvancedBlendColorFilterWithSaveLayer) {
DisplayListBuilder builder;
DlRect layer_rect = DlRect::MakeXYWH(0, 0, 500, 500);
SkRect layer_rect = SkRect::MakeXYWH(0, 0, 500, 500);
builder.ClipRect(layer_rect);
DlPaint save_paint;
save_paint.setColorFilter(DlColorFilter::MakeBlend(
DlColor::RGBA(0, 1, 0, 0.5), DlBlendMode::kDifference));
builder.SaveLayer(layer_rect, &save_paint);
builder.SaveLayer(&layer_rect, &save_paint);
DlPaint paint;
paint.setColor(DlColor::kBlack());
builder.DrawPaint(paint);
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 300, 300), paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -90,13 +91,13 @@ TEST_P(AiksTest, BlendModeShouldCoverWholeScreen) {
builder.SaveLayer(nullptr, &paint);
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 400, 400), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 400, 400), paint);
paint.setBlendMode(DlBlendMode::kSrc);
builder.SaveLayer(nullptr, &paint);
paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(200, 200, 200, 200), paint);
builder.DrawRect(SkRect::MakeXYWH(200, 200, 200, 200), paint);
builder.Restore();
builder.Restore();
@ -131,7 +132,7 @@ TEST_P(AiksTest, DrawPaintWithAdvancedBlendOverFilter) {
paint.setColor(DlColor::kWhite());
builder.DrawPaint(paint);
paint.setColor(DlColor::kBlack());
builder.DrawCircle(DlPoint(300, 300), 200, paint);
builder.DrawCircle(SkPoint{300, 300}, 200, paint);
paint.setColor(DlColor::kGreen());
paint.setBlendMode(DlBlendMode::kScreen);
builder.DrawPaint(paint);
@ -146,7 +147,7 @@ TEST_P(AiksTest, DrawAdvancedBlendPartlyOffscreen) {
draw_paint.setColor(DlColor::kBlue());
builder.DrawPaint(draw_paint);
builder.Scale(2, 2);
builder.ClipRect(DlRect::MakeLTRB(0, 0, 200, 200));
builder.ClipRect(SkRect::MakeLTRB(0, 0, 200, 200));
std::vector<DlColor> colors = {DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0),
DlColor::RGBA(0.1294, 0.5882, 0.9529, 1.0)};
@ -165,7 +166,7 @@ TEST_P(AiksTest, DrawAdvancedBlendPartlyOffscreen) {
));
paint.setBlendMode(DlBlendMode::kLighten);
builder.DrawCircle(DlPoint(100, 100), 100, paint);
builder.DrawCircle(SkPoint{100, 100}, 100, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -175,21 +176,21 @@ TEST_P(AiksTest, PaintBlendModeIsRespected) {
// Default is kSourceOver.
paint.setColor(DlColor::RGBA(1, 0, 0, 0.5));
builder.DrawCircle(DlPoint(150, 200), 100, paint);
builder.DrawCircle(SkPoint{150, 200}, 100, paint);
paint.setColor(DlColor::RGBA(0, 1, 0, 0.5));
builder.DrawCircle(DlPoint(250, 200), 100, paint);
builder.DrawCircle(SkPoint{250, 200}, 100, paint);
paint.setBlendMode(DlBlendMode::kPlus);
paint.setColor(DlColor::kRed());
builder.DrawCircle(DlPoint(450, 250), 100, paint);
builder.DrawCircle(SkPoint{450, 250}, 100, paint);
paint.setColor(DlColor::kGreen());
builder.DrawCircle(DlPoint(550, 250), 100, paint);
builder.DrawCircle(SkPoint{550, 250}, 100, paint);
paint.setColor(DlColor::kBlue());
builder.DrawCircle(DlPoint(500, 150), 100, paint);
builder.DrawCircle(SkPoint{500, 150}, 100, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -224,7 +225,7 @@ TEST_P(AiksTest, ColorFilterBlend) {
builder.Scale(0.4, 0.4);
{
DlPaint dstPaint;
builder.DrawImage(dst_image, DlPoint(0, 0),
builder.DrawImage(dst_image, SkPoint{0, 0},
DlImageSampling::kMipmapLinear, &dstPaint);
}
{
@ -236,7 +237,7 @@ TEST_P(AiksTest, ColorFilterBlend) {
DlBlendMode::kSrcIn);
srcPaint.setColorFilter(color_filter);
}
builder.DrawImage(src_image, DlPoint(0, 0),
builder.DrawImage(src_image, SkPoint{0, 0},
DlImageSampling::kMipmapLinear, &srcPaint);
}
builder.Restore();
@ -281,7 +282,7 @@ TEST_P(AiksTest, ColorFilterAdvancedBlend) {
builder.Scale(0.4, 0.4);
{
DlPaint dstPaint;
builder.DrawImage(dst_image, DlPoint(0, 0),
builder.DrawImage(dst_image, SkPoint{0, 0},
DlImageSampling::kMipmapLinear, &dstPaint);
}
{
@ -293,7 +294,7 @@ TEST_P(AiksTest, ColorFilterAdvancedBlend) {
DlBlendMode::kSrcIn);
srcPaint.setColorFilter(color_filter);
}
builder.DrawImage(src_image, DlPoint(0, 0),
builder.DrawImage(src_image, SkPoint{0, 0},
DlImageSampling::kMipmapLinear, &srcPaint);
}
builder.Restore();
@ -373,7 +374,7 @@ TEST_P(AiksTest, ColorFilterAdvancedBlendNoFbFetch) {
builder.Scale(0.4, 0.4);
{
DlPaint dstPaint;
builder.DrawImage(dst_image, DlPoint(0, 0),
builder.DrawImage(dst_image, SkPoint{0, 0},
DlImageSampling::kMipmapLinear, &dstPaint);
}
{
@ -385,7 +386,7 @@ TEST_P(AiksTest, ColorFilterAdvancedBlendNoFbFetch) {
DlBlendMode::kMultiply);
srcPaint.setColorFilter(color_filter);
}
builder.DrawImage(src_image, DlPoint(0, 0),
builder.DrawImage(src_image, SkPoint{0, 0},
DlImageSampling::kMipmapLinear, &srcPaint);
}
builder.Restore();
@ -413,15 +414,16 @@ TEST_P(AiksTest, BlendModePlusAlphaWideGamut) {
paint.setBlendMode(DlBlendMode::kPlus);
paint.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 400, 400), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 400, 400), paint);
paint.setColor(DlColor::kWhite());
auto rect = Rect::MakeXYWH(100, 100, 400, 400).Expand(-100, -100);
builder.DrawImageRect(
DlImageImpeller::Make(texture),
DlRect::MakeWH(texture->GetSize().width, texture->GetSize().height),
DlRect::MakeLTRB(rect.GetLeft(), rect.GetTop(), //
rect.GetRight(), rect.GetBottom()),
SkRect::MakeSize(
SkSize::Make(texture->GetSize().width, texture->GetSize().height)),
SkRect::MakeLTRB(rect.GetLeft(), rect.GetTop(), rect.GetRight(),
rect.GetBottom()),
DlImageSampling::kMipmapLinear, &paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -447,16 +449,17 @@ TEST_P(AiksTest, BlendModePlusAlphaColorFilterWideGamut) {
builder.SaveLayer(nullptr, &save_paint);
paint.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 400, 400), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 400, 400), paint);
paint.setColor(DlColor::kWhite());
auto rect = Rect::MakeXYWH(100, 100, 400, 400).Expand(-100, -100);
builder.DrawImageRect(
DlImageImpeller::Make(texture),
DlRect::MakeWH(texture->GetSize().width, texture->GetSize().height),
DlRect::MakeLTRB(rect.GetLeft(), rect.GetTop(), //
rect.GetRight(), rect.GetBottom()),
SkRect::MakeSize(
SkSize::Make(texture->GetSize().width, texture->GetSize().height)),
SkRect::MakeLTRB(rect.GetLeft(), rect.GetTop(), rect.GetRight(),
rect.GetBottom()),
DlImageSampling::kMipmapLinear, &paint);
builder.Restore();
@ -476,7 +479,7 @@ TEST_P(AiksTest, ForegroundBlendSubpassCollapseOptimization) {
DlPaint paint;
paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 200, 200), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 200, 200), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -486,12 +489,12 @@ TEST_P(AiksTest, ClearBlend) {
DlPaint blue;
blue.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600.0, 600.0), blue);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600.0, 600.0), blue);
DlPaint clear;
clear.setBlendMode(DlBlendMode::kClear);
builder.DrawCircle(DlPoint(300.0, 300.0), 200.0, clear);
builder.DrawCircle(SkPoint{300.0, 300.0}, 200.0, clear);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -530,7 +533,7 @@ static sk_sp<DisplayList> BlendModeTest(Vector2 content_scale,
for (const auto& color : source_colors) {
builder.Save();
{
builder.ClipRect(DlRect::MakeXYWH(25, 25, 100, 100));
builder.ClipRect(SkRect::MakeXYWH(25, 25, 100, 100));
// Perform the blend in a SaveLayer so that the initial backdrop color is
// fully transparent black. SourceOver blend the result onto the parent
// pass.
@ -551,7 +554,7 @@ static sk_sp<DisplayList> BlendModeTest(Vector2 content_scale,
DlPaint paint;
paint.setColor(
DlColor::RGBA(color.red, color.green, color.blue, color.alpha));
builder.DrawRect(DlRect::MakeXYWH(25, 25, 100, 100), paint);
builder.DrawRect(SkRect::MakeXYWH(25, 25, 100, 100), paint);
}
builder.Restore();
}
@ -577,7 +580,7 @@ static sk_sp<DisplayList> BlendModeTest(Vector2 content_scale,
auto dest = destination_color.Blend(color, blend_mode);
paint.setColor(DlColor::RGBA(dest.red, dest.green, dest.blue, dest.alpha));
paint.setBlendMode(DlBlendMode::kSrcOver);
builder.DrawRect(DlRect::MakeXYWH(25, 25, 100, 100), paint);
builder.DrawRect(SkRect::MakeXYWH(25, 25, 100, 100), paint);
builder.Translate(100, 0);
}
builder.Restore();
@ -596,14 +599,14 @@ static sk_sp<DisplayList> BlendModeTest(Vector2 content_scale,
{
DlPaint paint;
paint.setColor(DlColor::RGBA(41 / 255.0, 41 / 255.0, 41 / 255.0, 1));
builder.DrawRect(DlRect::MakeLTRB(0, 0, 800, 400), paint);
builder.DrawRect(SkRect::MakeLTRB(0, 0, 800, 400), paint);
}
DlPaint square_paint;
square_paint.setColor(DlColor::RGBA(15 / 255.0, 15 / 255.0, 15 / 255.0, 1));
for (int y = 0; y < 400 / 8; y++) {
for (int x = 0; x < 800 / 16; x++) {
builder.DrawRect(DlRect::MakeXYWH(x * 16 + (y % 2) * 8, y * 8, 8, 8),
builder.DrawRect(SkRect::MakeXYWH(x * 16 + (y % 2) * 8, y * 8, 8, 8),
square_paint);
}
}
@ -614,12 +617,12 @@ static sk_sp<DisplayList> BlendModeTest(Vector2 content_scale,
builder.Save();
builder.SaveLayer(nullptr, &paint);
{
builder.DrawImage(dst_image, DlPoint(0, 0), DlImageSampling::kMipmapLinear,
builder.DrawImage(dst_image, SkPoint{0, 0}, DlImageSampling::kMipmapLinear,
&paint);
paint.setColor(DlColor::kWhite().withAlpha(src_alpha * 255));
paint.setBlendMode(static_cast<DlBlendMode>(blend_mode));
builder.DrawImage(src_image, DlPoint(0, 0), DlImageSampling::kMipmapLinear,
builder.DrawImage(src_image, SkPoint{0, 0}, DlImageSampling::kMipmapLinear,
&paint);
}
builder.Restore();
@ -631,7 +634,7 @@ static sk_sp<DisplayList> BlendModeTest(Vector2 content_scale,
DlPaint save_paint;
builder.SaveLayer(nullptr, &save_paint);
{
builder.DrawImage(dst_image, DlPoint(400, 0),
builder.DrawImage(dst_image, SkPoint{400, 0},
DlImageSampling::kMipmapLinear, nullptr);
DlPaint save_paint;
@ -639,7 +642,7 @@ static sk_sp<DisplayList> BlendModeTest(Vector2 content_scale,
save_paint.setBlendMode(static_cast<DlBlendMode>(blend_mode));
builder.SaveLayer(nullptr, &save_paint);
{
builder.DrawImage(src_image, DlPoint(400, 0),
builder.DrawImage(src_image, SkPoint{400, 0},
DlImageSampling::kMipmapLinear, nullptr);
}
builder.Restore();
@ -722,7 +725,7 @@ TEST_P(AiksTest, ForegroundPipelineBlendAppliesTransformCorrectly) {
DlColor::RGBA(255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f),
DlBlendMode::kSrcIn));
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(200, 200),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint{200, 200},
DlImageSampling::kMipmapLinear, &image_paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -740,7 +743,7 @@ TEST_P(AiksTest, ForegroundAdvancedBlendAppliesTransformCorrectly) {
DlColor::RGBA(255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f),
DlBlendMode::kColorDodge));
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(200, 200),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint{200, 200},
DlImageSampling::kMipmapLinear, &image_paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -763,7 +766,7 @@ TEST_P(AiksTest, FramebufferAdvancedBlendCoverage) {
DlPaint image_paint;
image_paint.setBlendMode(DlBlendMode::kMultiply);
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(20, 20),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint{20, 20},
DlImageSampling::kMipmapLinear, &image_paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -805,8 +808,8 @@ TEST_P(AiksTest, ColorWheel) {
auto color = color_wheel_sampler(r).WithAlpha(1.0f - normalized_distance);
paint.setColor(
DlColor::RGBA(color.red, color.green, color.blue, color.alpha));
DlPoint position = DlPoint(distance * std::sin(r.radians),
-distance * std::cos(r.radians));
SkPoint position = SkPoint::Make(distance * std::sin(r.radians),
-distance * std::cos(r.radians));
builder.DrawCircle(position, 9 + normalized_distance * 3, paint);
}
@ -872,11 +875,11 @@ TEST_P(AiksTest, ColorWheel) {
const Scalar x = std::sin(k2Pi / 3);
const Scalar y = -std::cos(k2Pi / 3);
paint.setColor(color0);
builder.DrawCircle(DlPoint(-x * 45, y * 45), 65, paint);
builder.DrawCircle(SkPoint::Make(-x * 45, y * 45), 65, paint);
paint.setColor(color1);
builder.DrawCircle(DlPoint(0, -45), 65, paint);
builder.DrawCircle(SkPoint::Make(0, -45), 65, paint);
paint.setColor(color2);
builder.DrawCircle(DlPoint(x * 45, y * 45), 65, paint);
builder.DrawCircle(SkPoint::Make(x * 45, y * 45), 65, paint);
}
builder.Restore();
@ -913,9 +916,9 @@ TEST_P(AiksTest, AdvancedBlendColorFilterWithDestinationOpacity) {
save_paint.setColorFilter(DlColorFilter::MakeBlend(DlColor::kTransparent(),
DlBlendMode::kSaturation));
builder.SaveLayer(nullptr, &save_paint);
builder.DrawRect(DlRect::MakeXYWH(100, 100, 300, 300),
builder.DrawRect(SkRect::MakeXYWH(100, 100, 300, 300),
DlPaint(DlColor::kMaroon()));
builder.DrawRect(DlRect::MakeXYWH(200, 200, 300, 300),
builder.DrawRect(SkRect::MakeXYWH(200, 200, 300, 300),
DlPaint(DlColor::kBlue()));
builder.Restore();

View File

@ -20,6 +20,8 @@
#include "impeller/display_list/dl_image_impeller.h"
#include "impeller/playground/widgets.h"
#include "impeller/renderer/testing/mocks.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "third_party/imgui/imgui.h"
////////////////////////////////////////////////////////////////////////////////
@ -49,9 +51,9 @@ TEST_P(AiksTest, SolidColorOvalsMaskBlurTinySigma) {
builder.Save();
builder.Translate(100 + (i * 100), 100);
DlRoundRect rrect =
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(0, 0, 60.0f, 160.0f), 50, 100);
builder.DrawRoundRect(rrect, paint);
SkRRect rrect =
SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 60.0f, 160.0f), 50, 100);
builder.DrawRRect(rrect, paint);
builder.Restore();
}
@ -86,13 +88,13 @@ sk_sp<flutter::DisplayList> DoGradientOvalStrokeMaskBlur(Vector2 content_Scale,
{
DlPaint line_paint;
line_paint.setColor(DlColor::kWhite());
builder.DrawLine(DlPoint(100, 0), DlPoint(100, 60), line_paint);
builder.DrawLine(DlPoint(0, 30), DlPoint(200, 30), line_paint);
builder.DrawLine(SkPoint{100, 0}, SkPoint{100, 60}, line_paint);
builder.DrawLine(SkPoint{0, 30}, SkPoint{200, 30}, line_paint);
}
DlRoundRect rrect =
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(0, 0, 200.0f, 60.0f), 50, 100);
builder.DrawRoundRect(rrect, paint);
SkRRect rrect =
SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 200.0f, 60.0f), 50, 100);
builder.DrawRRect(rrect, paint);
builder.Restore();
return builder.Build();
@ -139,9 +141,9 @@ TEST_P(AiksTest, SolidColorCircleMaskBlurTinySigma) {
builder.Save();
builder.Translate(100 + (i * 100), 100);
DlRoundRect rrect = DlRoundRect::MakeRectXY(
DlRect::MakeXYWH(0, 0, 100.0f, 100.0f), 100, 100);
builder.DrawRoundRect(rrect, paint);
SkRRect rrect =
SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 100.0f, 100.0f), 100, 100);
builder.DrawRRect(rrect, paint);
builder.Restore();
}
@ -154,7 +156,7 @@ TEST_P(AiksTest, CanRenderMaskBlurHugeSigma) {
DlPaint paint;
paint.setColor(DlColor::kGreen());
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 99999));
builder.DrawCircle(DlPoint(400, 400), 300, paint);
builder.DrawCircle(SkPoint{400, 400}, 300, paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -164,7 +166,7 @@ TEST_P(AiksTest, CanRenderForegroundBlendWithMaskBlur) {
// This case triggers the ForegroundPorterDuffBlend path. The color filter
// should apply to the color only, and respect the alpha mask.
DisplayListBuilder builder;
builder.ClipRect(DlRect::MakeXYWH(100, 150, 400, 400));
builder.ClipRect(SkRect::MakeXYWH(100, 150, 400, 400));
DlPaint paint;
paint.setColor(DlColor::kWhite());
@ -174,7 +176,7 @@ TEST_P(AiksTest, CanRenderForegroundBlendWithMaskBlur) {
DlBlurMaskFilter::Make(DlBlurStyle::kNormal, sigma.sigma));
paint.setColorFilter(
DlColorFilter::MakeBlend(DlColor::kGreen(), DlBlendMode::kSrc));
builder.DrawCircle(DlPoint(400, 400), 200, paint);
builder.DrawCircle(SkPoint{400, 400}, 200, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -183,7 +185,7 @@ TEST_P(AiksTest, CanRenderForegroundAdvancedBlendWithMaskBlur) {
// This case triggers the ForegroundAdvancedBlend path. The color filter
// should apply to the color only, and respect the alpha mask.
DisplayListBuilder builder;
builder.ClipRect(DlRect::MakeXYWH(100, 150, 400, 400));
builder.ClipRect(SkRect::MakeXYWH(100, 150, 400, 400));
DlPaint paint;
paint.setColor(
@ -194,7 +196,7 @@ TEST_P(AiksTest, CanRenderForegroundAdvancedBlendWithMaskBlur) {
DlBlurMaskFilter::Make(DlBlurStyle::kNormal, sigma.sigma));
paint.setColorFilter(
DlColorFilter::MakeBlend(DlColor::kGreen(), DlBlendMode::kColor));
builder.DrawCircle(DlPoint(400, 400), 200, paint);
builder.DrawCircle(SkPoint{400, 400}, 200, paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -209,20 +211,20 @@ TEST_P(AiksTest, CanRenderBackdropBlurInteractive) {
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::kCornflowerBlue());
builder.DrawCircle(DlPoint(100, 100), 50, paint);
builder.DrawCircle(SkPoint{100, 100}, 50, paint);
paint.setColor(DlColor::kGreenYellow());
builder.DrawCircle(DlPoint(300, 200), 100, paint);
builder.DrawCircle(SkPoint{300, 200}, 100, paint);
paint.setColor(DlColor::kDarkMagenta());
builder.DrawCircle(DlPoint(140, 170), 75, paint);
builder.DrawCircle(SkPoint{140, 170}, 75, paint);
paint.setColor(DlColor::kOrangeRed());
builder.DrawCircle(DlPoint(180, 120), 100, paint);
builder.DrawCircle(SkPoint{180, 120}, 100, paint);
DlRoundRect rrect =
DlRoundRect::MakeRectXY(DlRect::MakeLTRB(a.x, a.y, b.x, b.y), 20, 20);
builder.ClipRoundRect(rrect);
SkRRect rrect =
SkRRect::MakeRectXY(SkRect::MakeLTRB(a.x, a.y, b.x, b.y), 20, 20);
builder.ClipRRect(rrect);
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);
@ -242,20 +244,20 @@ TEST_P(AiksTest, CanRenderBackdropBlur) {
DlPaint paint;
paint.setColor(DlColor::kCornflowerBlue());
builder.DrawCircle(DlPoint(100, 100), 50, paint);
builder.DrawCircle(SkPoint{100, 100}, 50, paint);
paint.setColor(DlColor::kGreenYellow());
builder.DrawCircle(DlPoint(300, 200), 100, paint);
builder.DrawCircle(SkPoint{300, 200}, 100, paint);
paint.setColor(DlColor::kDarkMagenta());
builder.DrawCircle(DlPoint(140, 170), 75, paint);
builder.DrawCircle(SkPoint{140, 170}, 75, paint);
paint.setColor(DlColor::kOrangeRed());
builder.DrawCircle(DlPoint(180, 120), 100, paint);
builder.DrawCircle(SkPoint{180, 120}, 100, paint);
DlRoundRect rrect =
DlRoundRect::MakeRectXY(DlRect::MakeLTRB(75, 50, 375, 275), 20, 20);
builder.ClipRoundRect(rrect);
SkRRect rrect =
SkRRect::MakeRectXY(SkRect::MakeLTRB(75, 50, 375, 275), 20, 20);
builder.ClipRRect(rrect);
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);
@ -272,13 +274,13 @@ TEST_P(AiksTest, CanRenderBackdropBlurWithSingleBackdropId) {
DisplayListBuilder builder;
DlPaint paint;
builder.DrawImage(image, DlPoint(50.0, 50.0),
builder.DrawImage(image, SkPoint::Make(50.0, 50.0),
DlImageSampling::kNearestNeighbor, &paint);
DlRoundRect rrect =
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(50, 250, 100, 100), 20, 20);
SkRRect rrect =
SkRRect::MakeRectXY(SkRect::MakeXYWH(50, 250, 100, 100), 20, 20);
builder.Save();
builder.ClipRoundRect(rrect);
builder.ClipRRect(rrect);
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);
@ -297,14 +299,14 @@ TEST_P(AiksTest, CanRenderMultipleBackdropBlurWithSingleBackdropId) {
DisplayListBuilder builder;
DlPaint paint;
builder.DrawImage(image, DlPoint(50.0, 50.0),
builder.DrawImage(image, SkPoint::Make(50.0, 50.0),
DlImageSampling::kNearestNeighbor, &paint);
for (int i = 0; i < 6; i++) {
DlRoundRect rrect = DlRoundRect::MakeRectXY(
DlRect::MakeXYWH(50 + (i * 100), 250, 100, 100), 20, 20);
SkRRect rrect = SkRRect::MakeRectXY(
SkRect::MakeXYWH(50 + (i * 100), 250, 100, 100), 20, 20);
builder.Save();
builder.ClipRoundRect(rrect);
builder.ClipRRect(rrect);
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);
@ -325,14 +327,14 @@ TEST_P(AiksTest,
DisplayListBuilder builder;
DlPaint paint;
builder.DrawImage(image, DlPoint(50.0, 50.0),
builder.DrawImage(image, SkPoint::Make(50.0, 50.0),
DlImageSampling::kNearestNeighbor, &paint);
for (int i = 0; i < 6; i++) {
DlRoundRect rrect = DlRoundRect::MakeRectXY(
DlRect::MakeXYWH(50 + (i * 100), 250, 100, 100), 20, 20);
SkRRect rrect = SkRRect::MakeRectXY(
SkRect::MakeXYWH(50 + (i * 100), 250, 100, 100), 20, 20);
builder.Save();
builder.ClipRoundRect(rrect);
builder.ClipRRect(rrect);
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);
@ -352,7 +354,7 @@ TEST_P(AiksTest, CanRenderBackdropBlurHugeSigma) {
DlPaint paint;
paint.setColor(DlColor::kGreen());
builder.DrawCircle(DlPoint(400, 400), 300, paint);
builder.DrawCircle(SkPoint{400, 400}, 300, paint);
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);
@ -367,12 +369,12 @@ TEST_P(AiksTest, CanRenderBackdropBlurHugeSigma) {
TEST_P(AiksTest, CanRenderClippedBlur) {
DisplayListBuilder builder;
builder.ClipRect(DlRect::MakeXYWH(100, 150, 400, 400));
builder.ClipRect(SkRect::MakeXYWH(100, 150, 400, 400));
DlPaint paint;
paint.setColor(DlColor::kGreen());
paint.setImageFilter(DlImageFilter::MakeBlur(20, 20, DlTileMode::kDecal));
builder.DrawCircle(DlPoint(400, 400), 200, paint);
builder.DrawCircle(SkPoint{400, 400}, 200, paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -394,8 +396,8 @@ TEST_P(AiksTest, ClippedBlurFilterRendersCorrectlyInteractive) {
DlBlurMaskFilter::Make(DlBlurStyle::kNormal, sigma.sigma));
paint.setColor(DlColor::kRed());
DlPath path = DlPath::MakeRect(DlRect::MakeLTRB(0, 0, 800, 800));
path = path + DlPath::MakeCircle(DlPoint(0, 0), 0.5);
SkPath path = SkPath::Rect(SkRect::MakeLTRB(0, 0, 800, 800));
path.addCircle(0, 0, 0.5);
builder.DrawPath(path, paint);
return builder.Build();
};
@ -412,8 +414,8 @@ TEST_P(AiksTest, ClippedBlurFilterRendersCorrectly) {
DlBlurMaskFilter::Make(DlBlurStyle::kNormal, sigma.sigma));
paint.setColor(DlColor::kRed());
DlPath path = DlPath::MakeRect(DlRect::MakeLTRB(0, 0, 800, 800));
path = path + DlPath::MakeCircle(DlPoint(0, 0), 0.5);
SkPath path = SkPath::Rect(SkRect::MakeLTRB(0, 0, 800, 800));
path.addCircle(0, 0, 0.5);
builder.DrawPath(path, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -423,13 +425,13 @@ TEST_P(AiksTest, ClearBlendWithBlur) {
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600.0, 600.0), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600.0, 600.0), paint);
DlPaint clear;
clear.setBlendMode(DlBlendMode::kClear);
clear.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 20));
builder.DrawCircle(DlPoint(300.0, 300.0), 200.0, clear);
builder.DrawCircle(SkPoint{300.0, 300.0}, 200.0, clear);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -450,7 +452,7 @@ TEST_P(AiksTest, BlurHasNoEdge) {
paint.setColor(DlColor::kGreen());
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, sigma));
builder.DrawRect(DlRect::MakeXYWH(300, 300, 200, 200), paint);
builder.DrawRect(SkRect::MakeXYWH(300, 300, 200, 200), paint);
return builder.Build();
};
@ -464,8 +466,8 @@ TEST_P(AiksTest, MaskBlurWithZeroSigmaIsSkipped) {
paint.setColor(DlColor::kBlue());
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 0));
builder.DrawCircle(DlPoint(300, 300), 200, paint);
builder.DrawRect(DlRect::MakeLTRB(100, 300, 500, 600), paint);
builder.DrawCircle(SkPoint{300, 300}, 200, paint);
builder.DrawRect(SkRect::MakeLTRB(100, 300, 500, 600), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -507,53 +509,53 @@ static sk_sp<DisplayList> MaskBlurVariantTest(
Scalar y = 50;
paint.setColor(DlColor::kCrimson().withAlpha(alpha));
builder.DrawRect(DlRect::MakeXYWH(x + 25 - radius / 2, y + radius / 2, //
builder.DrawRect(SkRect::MakeXYWH(x + 25 - radius / 2, y + radius / 2, //
radius, 60.0f - radius),
paint);
y += y_spacing;
paint.setColor(DlColor::kBlue().withAlpha(alpha));
builder.DrawCircle(DlPoint{x + 25, y + 25}, radius, paint);
builder.DrawCircle(SkPoint{x + 25, y + 25}, radius, paint);
y += y_spacing;
paint.setColor(DlColor::kGreen().withAlpha(alpha));
builder.DrawOval(DlRect::MakeXYWH(x + 25 - radius / 2, y + radius / 2, //
builder.DrawOval(SkRect::MakeXYWH(x + 25 - radius / 2, y + radius / 2, //
radius, 60.0f - radius),
paint);
y += y_spacing;
paint.setColor(DlColor::kPurple().withAlpha(alpha));
DlRoundRect rrect = DlRoundRect::MakeRectXY(
DlRect::MakeXYWH(x, y, 60.0f, 60.0f), radius, radius);
builder.DrawRoundRect(rrect, paint);
SkRRect rrect =
SkRRect::MakeRectXY(SkRect::MakeXYWH(x, y, 60.0f, 60.0f), radius, radius);
builder.DrawRRect(rrect, paint);
y += y_spacing;
paint.setColor(DlColor::kOrange().withAlpha(alpha));
rrect = DlRoundRect::MakeRectXY(DlRect::MakeXYWH(x, y, 60.0f, 60.0f), //
radius, 5.0);
builder.DrawRoundRect(rrect, paint);
rrect =
SkRRect::MakeRectXY(SkRect::MakeXYWH(x, y, 60.0f, 60.0f), radius, 5.0);
builder.DrawRRect(rrect, paint);
y += y_spacing;
paint.setColor(DlColor::kMaroon().withAlpha(alpha));
{
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(x + 0, y + 60));
path_builder.LineTo(DlPoint(x + 30, y + 0));
path_builder.LineTo(DlPoint(x + 60, y + 60));
path_builder.Close();
SkPath path;
path.moveTo(x + 0, y + 60);
path.lineTo(x + 30, y + 0);
path.lineTo(x + 60, y + 60);
path.close();
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
}
y += y_spacing;
paint.setColor(DlColor::kMaroon().withAlpha(alpha));
{
DlPath path = DlPath::MakeArc(Rect::MakeXYWH(x + 5, y, 50, 50), //
Degrees(90), Degrees(180), false) +
DlPath::MakeArc(Rect::MakeXYWH(x + 25, y, 50, 50), //
Degrees(90), Degrees(180), false);
SkPath path;
path.addArc(SkRect::MakeXYWH(x + 5, y, 50, 50), 90, 180);
path.addArc(SkRect::MakeXYWH(x + 25, y, 50, 50), 90, 180);
path.close();
builder.DrawPath(path, paint);
}
@ -634,18 +636,18 @@ TEST_P(AiksTest, GaussianBlurStyleInner) {
paint.setColor(DlColor::kGreen());
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kInner, 30));
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(200, 200));
path_builder.LineTo(DlPoint(300, 400));
path_builder.LineTo(DlPoint(100, 400));
path_builder.Close();
SkPath path;
path.moveTo(200, 200);
path.lineTo(300, 400);
path.lineTo(100, 400);
path.close();
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
// Draw another thing to make sure the clip area is reset.
DlPaint red;
red.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), red);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), red);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -661,18 +663,18 @@ TEST_P(AiksTest, GaussianBlurStyleOuter) {
paint.setColor(DlColor::kGreen());
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kOuter, 30));
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(200, 200));
path_builder.LineTo(DlPoint(300, 400));
path_builder.LineTo(DlPoint(100, 400));
path_builder.Close();
SkPath path;
path.moveTo(200, 200);
path.lineTo(300, 400);
path.lineTo(100, 400);
path.close();
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
// Draw another thing to make sure the clip area is reset.
DlPaint red;
red.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), red);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), red);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -688,18 +690,18 @@ TEST_P(AiksTest, GaussianBlurStyleSolid) {
paint.setColor(DlColor::kGreen());
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kSolid, 30));
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(200, 200));
path_builder.LineTo(DlPoint(300, 400));
path_builder.LineTo(DlPoint(100, 400));
path_builder.Close();
SkPath path;
path.moveTo(200, 200);
path.lineTo(300, 400);
path.lineTo(100, 400);
path.close();
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
// Draw another thing to make sure the clip area is reset.
DlPaint red;
red.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), red);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), red);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -722,11 +724,11 @@ TEST_P(AiksTest, MaskBlurTexture) {
builder.DrawImage(
DlImageImpeller::Make(CreateTextureForFixture("boston.jpg")),
DlPoint(200, 200), DlImageSampling::kNearestNeighbor, &paint);
SkPoint{200, 200}, DlImageSampling::kNearestNeighbor, &paint);
DlPaint red;
red.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), red);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), red);
return builder.Build();
};
@ -751,15 +753,15 @@ TEST_P(AiksTest, MaskBlurDoesntStretchContents) {
std::shared_ptr<Texture> boston = CreateTextureForFixture("boston.jpg");
builder.Transform(Matrix::MakeTranslation({100, 100}) *
Matrix::MakeScale({0.5, 0.5, 1.0f}));
builder.Transform(SkMatrix::Translate(100, 100) *
SkMatrix::Scale(0.5, 0.5));
paint.setColorSource(DlColorSource::MakeImage(
DlImageImpeller::Make(boston), DlTileMode::kRepeat, DlTileMode::kRepeat,
DlImageSampling::kMipmapLinear));
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, sigma));
builder.DrawRect(DlRect::MakeXYWH(0, 0, boston->GetSize().width,
builder.DrawRect(SkRect::MakeXYWH(0, 0, boston->GetSize().width,
boston->GetSize().height),
paint);
@ -775,15 +777,15 @@ TEST_P(AiksTest, GaussianBlurAtPeripheryVertical) {
builder.Scale(GetContentScale().x, GetContentScale().y);
paint.setColor(DlColor::kLimeGreen());
DlRoundRect rrect = DlRoundRect::MakeRectXY(
DlRect::MakeLTRB(0, 0, GetWindowSize().width, 100), 10, 10);
builder.DrawRoundRect(rrect, paint);
SkRRect rrect = SkRRect::MakeRectXY(
SkRect::MakeLTRB(0, 0, GetWindowSize().width, 100), 10, 10);
builder.DrawRRect(rrect, paint);
paint.setColor(DlColor::kMagenta());
rrect = DlRoundRect::MakeRectXY(
DlRect::MakeLTRB(0, 110, GetWindowSize().width, 210), 10, 10);
builder.DrawRoundRect(rrect, paint);
builder.ClipRect(DlRect::MakeLTRB(100, 0, 200, GetWindowSize().height));
rrect = SkRRect::MakeRectXY(
SkRect::MakeLTRB(0, 110, GetWindowSize().width, 210), 10, 10);
builder.DrawRRect(rrect, paint);
builder.ClipRect(SkRect::MakeLTRB(100, 0, 200, GetWindowSize().height));
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);
@ -803,17 +805,17 @@ TEST_P(AiksTest, GaussianBlurAtPeripheryHorizontal) {
std::shared_ptr<Texture> boston = CreateTextureForFixture("boston.jpg");
builder.DrawImageRect(
DlImageImpeller::Make(boston),
DlRect::MakeXYWH(0, 0, boston->GetSize().width, boston->GetSize().height),
DlRect::MakeLTRB(0, 0, GetWindowSize().width, 100),
SkRect::MakeXYWH(0, 0, boston->GetSize().width, boston->GetSize().height),
SkRect::MakeLTRB(0, 0, GetWindowSize().width, 100),
DlImageSampling::kNearestNeighbor);
DlPaint paint;
paint.setColor(DlColor::kMagenta());
DlRoundRect rrect = DlRoundRect::MakeRectXY(
DlRect::MakeLTRB(0, 110, GetWindowSize().width, 210), 10, 10);
builder.DrawRoundRect(rrect, paint);
builder.ClipRect(DlRect::MakeLTRB(0, 50, GetWindowSize().width, 150));
SkRRect rrect = SkRRect::MakeRectXY(
SkRect::MakeLTRB(0, 110, GetWindowSize().width, 210), 10, 10);
builder.DrawRRect(rrect, paint);
builder.ClipRect(SkRect::MakeLTRB(0, 50, GetWindowSize().width, 150));
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);
@ -849,17 +851,18 @@ TEST_P(AiksTest, GaussianBlurAnimatedBackdrop) {
DisplayListBuilder builder;
builder.Scale(GetContentScale().x, GetContentScale().y);
Scalar y = amp * sin(freq * 2.0 * M_PI * count / 60);
builder.DrawImage(DlImageImpeller::Make(boston),
DlPoint(1024 / 2 - boston->GetSize().width / 2,
(768 / 2 - boston->GetSize().height / 2) + y),
DlImageSampling::kMipmapLinear);
builder.DrawImage(
DlImageImpeller::Make(boston),
SkPoint::Make(1024 / 2 - boston->GetSize().width / 2,
(768 / 2 - boston->GetSize().height / 2) + y),
DlImageSampling::kMipmapLinear);
static PlaygroundPoint point_a(Point(100, 100), 20, Color::Red());
static PlaygroundPoint point_b(Point(900, 700), 20, Color::Red());
auto [handle_a, handle_b] = DrawPlaygroundLine(point_a, point_b);
builder.ClipRect(
DlRect::MakeLTRB(handle_a.x, handle_a.y, handle_b.x, handle_b.y));
builder.ClipRect(DlRect::MakeLTRB(100, 100, 900, 700));
SkRect::MakeLTRB(handle_a.x, handle_a.y, handle_b.x, handle_b.y));
builder.ClipRect(SkRect::MakeLTRB(100, 100, 900, 700));
DlPaint paint;
paint.setBlendMode(DlBlendMode::kSrc);
@ -896,17 +899,17 @@ TEST_P(AiksTest, GaussianBlurStyleInnerGradient) {
/*tile_mode=*/DlTileMode::kMirror));
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kInner, 30));
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(200, 200));
path_builder.LineTo(DlPoint(300, 400));
path_builder.LineTo(DlPoint(100, 400));
path_builder.Close();
builder.DrawPath(DlPath(path_builder), paint);
SkPath path;
path.moveTo(200, 200);
path.lineTo(300, 400);
path.lineTo(100, 400);
path.close();
builder.DrawPath(path, paint);
// Draw another thing to make sure the clip area is reset.
DlPaint red;
red.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), red);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), red);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -933,17 +936,17 @@ TEST_P(AiksTest, GaussianBlurStyleSolidGradient) {
/*tile_mode=*/DlTileMode::kMirror));
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kSolid, 30));
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(200, 200));
path_builder.LineTo(DlPoint(300, 400));
path_builder.LineTo(DlPoint(100, 400));
path_builder.Close();
builder.DrawPath(DlPath(path_builder), paint);
SkPath path;
path.moveTo(200, 200);
path.lineTo(300, 400);
path.lineTo(100, 400);
path.close();
builder.DrawPath(path, paint);
// Draw another thing to make sure the clip area is reset.
DlPaint red;
red.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), red);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), red);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -969,17 +972,17 @@ TEST_P(AiksTest, GaussianBlurStyleOuterGradient) {
/*tile_mode=*/DlTileMode::kMirror));
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kOuter, 30));
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(200, 200));
path_builder.LineTo(DlPoint(300, 400));
path_builder.LineTo(DlPoint(100, 400));
path_builder.Close();
builder.DrawPath(DlPath(path_builder), paint);
SkPath path;
path.moveTo(200, 200);
path.lineTo(300, 400);
path.lineTo(100, 400);
path.close();
builder.DrawPath(path, paint);
// Draw another thing to make sure the clip area is reset.
DlPaint red;
red.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), red);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), red);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -999,15 +1002,15 @@ TEST_P(AiksTest, GaussianBlurScaledAndClipped) {
auto rect =
Rect::MakeLTRB(center.x, center.y, center.x, center.y).Expand(clip_size);
builder.ClipRect(DlRect::MakeLTRB(rect.GetLeft(), rect.GetTop(),
builder.ClipRect(SkRect::MakeLTRB(rect.GetLeft(), rect.GetTop(),
rect.GetRight(), rect.GetBottom()));
builder.Translate(center.x, center.y);
builder.Scale(0.6, 0.6);
DlRect sk_bounds = DlRect::MakeLTRB(bounds.GetLeft(), bounds.GetTop(),
SkRect sk_bounds = SkRect::MakeLTRB(bounds.GetLeft(), bounds.GetTop(),
bounds.GetRight(), bounds.GetBottom());
Rect dest = bounds.Shift(-image_center);
DlRect sk_dst = DlRect::MakeLTRB(dest.GetLeft(), dest.GetTop(),
SkRect sk_dst = SkRect::MakeLTRB(dest.GetLeft(), dest.GetTop(),
dest.GetRight(), dest.GetBottom());
builder.DrawImageRect(DlImageImpeller::Make(boston), /*src=*/sk_bounds,
/*dst=*/sk_dst, DlImageSampling::kNearestNeighbor,
@ -1052,15 +1055,15 @@ TEST_P(AiksTest, GaussianBlurRotatedAndClippedInteractive) {
builder.Scale(GetContentScale().x, GetContentScale().y);
builder.ClipRect(
DlRect::MakeLTRB(handle_a.x, handle_a.y, handle_b.x, handle_b.y));
SkRect::MakeLTRB(handle_a.x, handle_a.y, handle_b.x, handle_b.y));
builder.Translate(center.x, center.y);
builder.Scale(scale, scale);
builder.Rotate(rotation);
DlRect sk_bounds = DlRect::MakeLTRB(bounds.GetLeft(), bounds.GetTop(),
SkRect sk_bounds = SkRect::MakeLTRB(bounds.GetLeft(), bounds.GetTop(),
bounds.GetRight(), bounds.GetBottom());
Rect dest = bounds.Shift(-image_center);
DlRect sk_dst = DlRect::MakeLTRB(dest.GetLeft(), dest.GetTop(),
SkRect sk_dst = SkRect::MakeLTRB(dest.GetLeft(), dest.GetTop(),
dest.GetRight(), dest.GetBottom());
builder.DrawImageRect(DlImageImpeller::Make(boston), /*src=*/sk_bounds,
/*dst=*/sk_dst, DlImageSampling::kNearestNeighbor,
@ -1078,7 +1081,7 @@ TEST_P(AiksTest, GaussianBlurOneDimension) {
builder.Scale(0.5, 0.5);
std::shared_ptr<Texture> boston = CreateTextureForFixture("boston.jpg");
builder.DrawImage(DlImageImpeller::Make(boston), DlPoint(100, 100), {});
builder.DrawImage(DlImageImpeller::Make(boston), SkPoint{100, 100}, {});
DlPaint paint;
paint.setBlendMode(DlBlendMode::kSrc);
@ -1110,7 +1113,7 @@ TEST_P(AiksTest, GaussianBlurRotatedAndClipped) {
auto clip_bounds =
Rect::MakeLTRB(center.x, center.y, center.x, center.y).Expand(clip_size);
builder.ClipRect(DlRect::MakeLTRB(clip_bounds.GetLeft(), clip_bounds.GetTop(),
builder.ClipRect(SkRect::MakeLTRB(clip_bounds.GetLeft(), clip_bounds.GetTop(),
clip_bounds.GetRight(),
clip_bounds.GetBottom()));
builder.Translate(center.x, center.y);
@ -1120,10 +1123,10 @@ TEST_P(AiksTest, GaussianBlurRotatedAndClipped) {
auto dst_rect = bounds.Shift(-image_center);
builder.DrawImageRect(
DlImageImpeller::Make(boston), /*src=*/
DlRect::MakeLTRB(bounds.GetLeft(), bounds.GetTop(), bounds.GetRight(),
SkRect::MakeLTRB(bounds.GetLeft(), bounds.GetTop(), bounds.GetRight(),
bounds.GetBottom()),
/*dst=*/
DlRect::MakeLTRB(dst_rect.GetLeft(), dst_rect.GetTop(),
SkRect::MakeLTRB(dst_rect.GetLeft(), dst_rect.GetTop(),
dst_rect.GetRight(), dst_rect.GetBottom()),
DlImageSampling::kMipmapLinear, &paint);
@ -1162,9 +1165,9 @@ TEST_P(AiksTest, GaussianBlurRotatedNonUniform) {
builder.Scale(scale, scale);
builder.Rotate(rotation);
DlRoundRect rrect =
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(-100, -100, 200, 200), 10, 10);
builder.DrawRoundRect(rrect, paint);
SkRRect rrect =
SkRRect::MakeRectXY(SkRect::MakeXYWH(-100, -100, 200, 200), 10, 10);
builder.DrawRRect(rrect, paint);
return builder.Build();
};
@ -1176,23 +1179,27 @@ TEST_P(AiksTest, BlurredRectangleWithShader) {
builder.Scale(GetContentScale().x, GetContentScale().y);
auto paint_lines = [&builder](Scalar dx, Scalar dy, DlPaint paint) {
auto draw_line = [&builder, &paint](DlPoint a, DlPoint b) {
DlPath line = DlPath::MakeLine(a, b);
auto draw_line = [&builder, &paint](SkPoint a, SkPoint b) {
SkPath line = SkPath::Line(a, b);
builder.DrawPath(line, paint);
};
paint.setStrokeWidth(5);
paint.setDrawStyle(DlDrawStyle::kStroke);
draw_line(DlPoint(dx + 100, dy + 100), DlPoint(dx + 200, dy + 200));
draw_line(DlPoint(dx + 100, dy + 200), DlPoint(dx + 200, dy + 100));
draw_line(DlPoint(dx + 150, dy + 100), DlPoint(dx + 200, dy + 150));
draw_line(DlPoint(dx + 100, dy + 150), DlPoint(dx + 150, dy + 200));
draw_line(SkPoint::Make(dx + 100, dy + 100),
SkPoint::Make(dx + 200, dy + 200));
draw_line(SkPoint::Make(dx + 100, dy + 200),
SkPoint::Make(dx + 200, dy + 100));
draw_line(SkPoint::Make(dx + 150, dy + 100),
SkPoint::Make(dx + 200, dy + 150));
draw_line(SkPoint::Make(dx + 100, dy + 150),
SkPoint::Make(dx + 150, dy + 200));
};
AiksContext renderer(GetContext(), nullptr);
DisplayListBuilder recorder_builder;
for (int x = 0; x < 5; ++x) {
for (int y = 0; y < 5; ++y) {
DlRect rect = DlRect::MakeXYWH(x * 20, y * 20, 20, 20);
SkRect rect = SkRect::MakeXYWH(x * 20, y * 20, 20, 20);
DlPaint paint;
paint.setColor(((x + y) & 1) == 0 ? DlColor::kYellow()
: DlColor::kBlue());
@ -1209,18 +1216,18 @@ TEST_P(AiksTest, BlurredRectangleWithShader) {
DlPaint paint;
paint.setColor(DlColor::kDarkGreen());
builder.DrawRect(DlRect::MakeLTRB(0, 0, 300, 600), paint);
builder.DrawRect(SkRect::MakeLTRB(0, 0, 300, 600), paint);
paint.setColorSource(image_source);
builder.DrawRect(DlRect::MakeLTRB(100, 100, 200, 200), paint);
builder.DrawRect(SkRect::MakeLTRB(100, 100, 200, 200), paint);
paint.setColorSource(nullptr);
paint.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeLTRB(300, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeLTRB(300, 0, 600, 600), paint);
paint.setColorSource(image_source);
paint.setImageFilter(blur_filter);
builder.DrawRect(DlRect::MakeLTRB(400, 100, 500, 200), paint);
builder.DrawRect(SkRect::MakeLTRB(400, 100, 500, 200), paint);
paint.setImageFilter(nullptr);
paint_lines(0, 300, paint);
@ -1278,7 +1285,7 @@ TEST_P(AiksTest, GaussianBlurWithoutDecalSupport) {
auto blur_filter = DlImageFilter::MakeBlur(20, 20, DlTileMode::kDecal);
paint.setImageFilter(blur_filter);
builder.DrawImage(texture, DlPoint(200, 200), {}, &paint);
builder.DrawImage(texture, SkPoint::Make(200, 200), {}, &paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -1291,16 +1298,16 @@ TEST_P(AiksTest, GaussianBlurSolidColorTinyMipMap) {
for (int32_t i = 1; i < 5; ++i) {
DisplayListBuilder builder;
Scalar fi = i;
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(100, 100));
path_builder.LineTo(DlPoint(100 + fi, 100 + fi));
SkPath path;
path.moveTo(100, 100);
path.lineTo(100 + fi, 100 + fi);
DlPaint paint;
paint.setColor(DlColor::kChartreuse());
auto blur_filter = DlImageFilter::MakeBlur(0.1, 0.1, DlTileMode::kClamp);
paint.setImageFilter(blur_filter);
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
auto image = DisplayListToTexture(builder.Build(), {1024, 768}, renderer);
EXPECT_TRUE(image) << " length " << i;
@ -1318,14 +1325,14 @@ TEST_P(AiksTest, GaussianBlurBackdropTinyMipMap) {
ISize clip_size = ISize(i, i);
builder.Save();
builder.ClipRect(
DlRect::MakeXYWH(400, 400, clip_size.width, clip_size.height));
SkRect::MakeXYWH(400, 400, clip_size.width, clip_size.height));
DlPaint paint;
paint.setColor(DlColor::kGreen());
auto blur_filter = DlImageFilter::MakeBlur(0.1, 0.1, DlTileMode::kDecal);
paint.setImageFilter(blur_filter);
builder.DrawCircle(DlPoint(400, 400), 200, paint);
builder.DrawCircle(SkPoint{400, 400}, 200, paint);
builder.Restore();
auto image = DisplayListToTexture(builder.Build(), {1024, 768}, renderer);
@ -1340,7 +1347,7 @@ TEST_P(AiksTest,
DisplayListBuilder builder;
DlPaint paint;
builder.DrawImage(image, DlPoint(50.0, 50.0),
builder.DrawImage(image, SkPoint::Make(50.0, 50.0),
DlImageSampling::kNearestNeighbor, &paint);
for (int i = 0; i < 6; i++) {
@ -1349,10 +1356,10 @@ TEST_P(AiksTest,
paint.setColor(DlColor::kWhite().withAlphaF(0.95));
builder.SaveLayer(nullptr, &paint);
}
DlRoundRect rrect = DlRoundRect::MakeRectXY(
DlRect::MakeXYWH(50 + (i * 100), 250, 100, 100), 20, 20);
SkRRect rrect = SkRRect::MakeRectXY(
SkRect::MakeXYWH(50 + (i * 100), 250, 100, 100), 20, 20);
builder.Save();
builder.ClipRoundRect(rrect);
builder.ClipRRect(rrect);
DlPaint save_paint;
save_paint.setBlendMode(DlBlendMode::kSrc);

View File

@ -16,17 +16,25 @@ namespace testing {
using namespace flutter;
namespace {
SkPath CreateCircle(Scalar x, Scalar y, Scalar radius) {
SkPath path;
path.addCircle(x, y, radius);
return path;
}
} // namespace
TEST_P(AiksTest, CanRenderNestedClips) {
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::kFuchsia());
builder.Save();
builder.ClipPath(DlPath::MakeCircle(DlPoint(200, 400), 300));
builder.ClipPath(CreateCircle(200, 400, 300));
builder.Restore();
builder.ClipPath(DlPath::MakeCircle(DlPoint(600, 400), 300));
builder.ClipPath(DlPath::MakeCircle(DlPoint(400, 600), 300));
builder.DrawRect(DlRect::MakeXYWH(200, 200, 400, 400), paint);
builder.ClipPath(CreateCircle(600, 400, 300));
builder.ClipPath(CreateCircle(400, 600, 300));
builder.DrawRect(SkRect::MakeXYWH(200, 200, 400, 400), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -36,36 +44,33 @@ TEST_P(AiksTest, CanRenderDifferenceClips) {
builder.Translate(400, 400);
// Limit drawing to face circle with a clip.
builder.ClipPath(DlPath::MakeCircle(DlPoint(0, 0), 200));
builder.ClipPath(CreateCircle(0, 0, 200));
builder.Save();
// Cut away eyes/mouth using difference clips.
builder.ClipPath(DlPath::MakeCircle(DlPoint(-100, -50), 30),
DlCanvas::ClipOp::kDifference);
builder.ClipPath(DlPath::MakeCircle(DlPoint(100, -50), 30),
DlCanvas::ClipOp::kDifference);
builder.ClipPath(CreateCircle(-100, -50, 30), DlCanvas::ClipOp::kDifference);
builder.ClipPath(CreateCircle(100, -50, 30), DlCanvas::ClipOp::kDifference);
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(-100, 50));
path_builder.QuadraticCurveTo(DlPoint(0, 150), DlPoint(100, 50));
builder.ClipPath(DlPath(path_builder), DlCanvas::ClipOp::kDifference);
SkPath path;
path.moveTo(-100, 50);
path.quadTo(0, 150, 100, 50);
builder.ClipPath(path, DlCanvas::ClipOp::kDifference);
// Draw a huge yellow rectangle to prove the clipping works.
DlPaint paint;
paint.setColor(DlColor::kYellow());
builder.DrawRect(DlRect::MakeXYWH(-1000, -1000, 2000, 2000), paint);
builder.DrawRect(SkRect::MakeXYWH(-1000, -1000, 2000, 2000), paint);
// Remove the difference clips and draw hair that partially covers the eyes.
builder.Restore();
paint.setColor(DlColor::kMaroon());
DlPathBuilder path_builder_2;
path_builder_2.MoveTo(DlPoint(200, -200));
path_builder_2.LineTo(DlPoint(-200, -200));
path_builder_2.LineTo(DlPoint(-200, -40));
path_builder_2.CubicCurveTo(DlPoint(0, -40), DlPoint(0, -80),
DlPoint(200, -80));
SkPath path_2;
path_2.moveTo(200, -200);
path_2.lineTo(-200, -200);
path_2.lineTo(-200, -40);
path_2.cubicTo({0, -40}, {0, -80}, {200, -80});
builder.DrawPath(DlPath(path_builder_2), paint);
builder.DrawPath(path_2, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -81,8 +86,8 @@ TEST_P(AiksTest, CanRenderWithContiguousClipRestores) {
builder.Save();
// Append two clips, the second resulting in empty coverage.
builder.ClipRect(DlRect::MakeXYWH(100, 100, 100, 100));
builder.ClipRect(DlRect::MakeXYWH(300, 300, 100, 100));
builder.ClipRect(SkRect::MakeXYWH(100, 100, 100, 100));
builder.ClipRect(SkRect::MakeXYWH(300, 300, 100, 100));
// Restore to no clips.
builder.Restore();
@ -106,8 +111,8 @@ TEST_P(AiksTest, ClipsUseCurrentTransform) {
builder.Scale(0.8, 0.8);
paint.setColor(colors[i % colors.size()]);
builder.ClipPath(DlPath::MakeCircle(DlPoint(0, 0), 300));
builder.DrawRect(DlRect::MakeXYWH(-300, -300, 600, 600), paint);
builder.ClipPath(CreateCircle(0, 0, 300));
builder.DrawRect(SkRect::MakeXYWH(-300, -300, 600, 600), paint);
}
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -122,18 +127,17 @@ TEST_P(AiksTest, FramebufferBlendsRespectClips) {
paint.setColor(DlColor::kWhite());
builder.DrawPaint(paint);
builder.ClipPath(DlPath::MakeCircle(DlPoint(150, 150), 50),
DlCanvas::ClipOp::kIntersect);
builder.ClipPath(SkPath::Circle(150, 150, 50), DlCanvas::ClipOp::kIntersect);
// Draw a red rectangle that should not show through the circle clip.
paint.setColor(DlColor::kRed());
paint.setBlendMode(DlBlendMode::kMultiply);
builder.DrawRect(DlRect::MakeXYWH(100, 100, 100, 100), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 100, 100), paint);
// Draw a green circle that shows through the clip.
paint.setColor(DlColor::kGreen());
paint.setBlendMode(DlBlendMode::kSrcOver);
builder.DrawCircle(DlPoint(150, 150), 50, paint);
builder.DrawCircle(SkPoint::Make(150, 150), 50, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

View File

@ -15,6 +15,9 @@
#include "flutter/display_list/dl_paint.h"
#include "flutter/testing/testing.h"
#include "impeller/playground/widgets.h"
#include "include/core/SkPath.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
using namespace flutter;
////////////////////////////////////////////////////////////////////////////////
@ -45,10 +48,20 @@ void CanRenderLinearGradient(AiksTest* aiks_test, DlTileMode tile_mode) {
{0, 0}, {200, 200}, 2, colors.data(), stops.data(), tile_mode);
paint.setColorSource(gradient);
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
Matrix ToMatrix(const SkMatrix& m) {
return Matrix{
// clang-format off
m[0], m[3], 0, m[6],
m[1], m[4], 0, m[7],
0, 0, 1, 0,
m[2], m[5], 0, m[8],
// clang-format on
};
}
} // namespace
TEST_P(AiksTest, CanRenderLinearGradientClamp) {
@ -84,7 +97,7 @@ TEST_P(AiksTest, CanRenderLinearGradientDecalWithColorFilter) {
paint.setColorFilter(DlColorFilter::MakeBlend(DlColor::kGreen().withAlpha(64),
DlBlendMode::kSrcOver));
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -100,7 +113,7 @@ static void CanRenderLinearGradientWithDithering(AiksTest* aiks_test) {
paint.setColorSource(DlColorSource::MakeLinear(
{0, 0}, {800, 500}, 2, colors.data(), stops.data(), DlTileMode::kClamp));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 800, 500), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 800, 500), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
@ -120,7 +133,7 @@ static void CanRenderRadialGradientWithDithering(AiksTest* aiks_test) {
paint.setColorSource(DlColorSource::MakeRadial(
{600, 600}, 600, 2, colors.data(), stops.data(), DlTileMode::kClamp));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 1200, 1200), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 1200, 1200), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
@ -143,7 +156,7 @@ static void CanRenderSweepGradientWithDithering(AiksTest* aiks_test) {
{100, 100}, /*start=*/45, /*end=*/135, 2, colors.data(), stops.data(),
DlTileMode::kMirror));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
@ -166,7 +179,7 @@ static void CanRenderConicalGradientWithDithering(AiksTest* aiks_test) {
colors.data(), stops.data(),
DlTileMode::kMirror));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
@ -193,7 +206,7 @@ void CanRenderLinearGradientWithOverlappingStops(AiksTest* aiks_test,
stops.data(), tile_mode));
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 500, 500), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 500, 500), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
} // namespace
@ -296,7 +309,7 @@ void CanRenderGradientWithIncompleteStops(AiksTest* aiks_test,
FML_UNREACHABLE();
}
builder.DrawRect(DlRect::MakeXYWH(0, 0, test_size, test_size), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, test_size, test_size), paint);
builder.Restore();
}
@ -351,7 +364,7 @@ void CanRenderLinearGradientManyColors(AiksTest* aiks_test,
stops.data(), tile_mode));
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
builder.Restore();
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
@ -391,7 +404,7 @@ void CanRenderLinearGradientWayManyColors(AiksTest* aiks_test,
stops.size(), colors.data(),
stops.data(), tile_mode));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
} // namespace
@ -443,7 +456,7 @@ TEST_P(AiksTest, CanRenderLinearGradientManyColorsUnevenStops) {
stops.size(), colors.data(),
stops.data(), tile_mode));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
return builder.Build();
};
ASSERT_TRUE(OpenPlaygroundHere(callback));
@ -466,8 +479,8 @@ TEST_P(AiksTest, CanRenderLinearGradientMaskBlur) {
DlTileMode::kClamp));
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 20));
builder.DrawCircle(DlPoint(300, 300), 200, paint);
builder.DrawRect(DlRect::MakeLTRB(100, 300, 500, 600), paint);
builder.DrawCircle(SkPoint{300, 300}, 200, paint);
builder.DrawRect(SkRect::MakeLTRB(100, 300, 500, 600), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -506,7 +519,7 @@ TEST_P(AiksTest, CanRenderRadialGradient) {
paint.setColorSource(DlColorSource::MakeRadial(
{100, 100}, 100, 2, colors.data(), stops.data(), tile_mode));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
return builder.Build();
};
ASSERT_TRUE(OpenPlaygroundHere(callback));
@ -564,7 +577,7 @@ TEST_P(AiksTest, CanRenderRadialGradientManyColors) {
paint.setColorSource(DlColorSource::MakeRadial(
{100, 100}, 100, stops.size(), colors.data(), stops.data(), tile_mode));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
return builder.Build();
};
ASSERT_TRUE(OpenPlaygroundHere(callback));
@ -586,7 +599,7 @@ void CanRenderSweepGradient(AiksTest* aiks_test, DlTileMode tile_mode) {
{100, 100}, /*start=*/45, /*end=*/135, /*stop_count=*/2, colors.data(),
stops.data(), tile_mode));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
} // namespace
@ -633,7 +646,7 @@ void CanRenderSweepGradientManyColors(AiksTest* aiks_test,
stops.size(), colors.data(),
stops.data(), tile_mode));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
ASSERT_TRUE(aiks_test->OpenPlaygroundHere(builder.Build()));
}
} // namespace
@ -656,7 +669,7 @@ TEST_P(AiksTest, CanRenderConicalGradient) {
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, size * 3, size * 3), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, size * 3, size * 3), paint);
std::vector<DlColor> colors = {
DlColor(Color::MakeRGBA8(0xF4, 0x43, 0x36, 0xFF).ToARGB()),
DlColor(Color::MakeRGBA8(0xFF, 0xEB, 0x3B, 0xFF).ToARGB()),
@ -688,7 +701,7 @@ TEST_P(AiksTest, CanRenderConicalGradient) {
std::get<2>(array[i]), std::get<3>(array[i]), std::get<0>(array[i]),
std::get<1>(array[i]), stops.size(), colors.data(), stops.data(),
DlTileMode::kClamp));
builder.DrawRect(DlRect::MakeXYWH(0, 0, size, size), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, size, size), paint);
builder.Restore();
}
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -714,12 +727,12 @@ TEST_P(AiksTest, CanRenderGradientDecalWithBackground) {
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeLTRB(0, 0, 605, 205), paint);
builder.DrawRect(SkRect::MakeLTRB(0, 0, 605, 205), paint);
for (int i = 0; i < 3; i++) {
builder.Save();
builder.Translate(i * 200.0f, 0);
paint.setColorSource(color_sources[i]);
builder.DrawRect(DlRect::MakeLTRB(0, 0, 200, 200), paint);
builder.DrawRect(SkRect::MakeLTRB(0, 0, 200, 200), paint);
builder.Restore();
}
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -766,13 +779,12 @@ TEST_P(AiksTest, GradientStrokesRenderCorrectly) {
stops.size(), colors.data(),
stops.data(), tile_mode));
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(20, 20));
path_builder.QuadraticCurveTo(DlPoint(60, 20), DlPoint(60, 60));
path_builder.Close();
path_builder.MoveTo(DlPoint(60, 20));
path_builder.QuadraticCurveTo(DlPoint(60, 60), DlPoint(20, 60));
DlPath path(path_builder);
SkPath path;
path.moveTo(20, 20);
path.quadTo({60, 20}, {60, 60});
path.close();
path.moveTo(60, 20);
path.quadTo({60, 60}, {20, 60});
builder.Scale(scale, scale);
@ -784,17 +796,19 @@ TEST_P(AiksTest, GradientStrokesRenderCorrectly) {
auto [handle_a, handle_b] =
DrawPlaygroundLine(circle_clip_point_a, circle_clip_point_b);
Matrix ip_matrix = builder.GetMatrix();
if (!ip_matrix.IsInvertible()) {
SkMatrix screen_to_canvas;
if (!builder.GetTransform().invert(&screen_to_canvas)) {
return nullptr;
}
ip_matrix = ip_matrix.Invert();
Matrix ip_matrix = ToMatrix(screen_to_canvas);
Point point_a = ip_matrix * handle_a * GetContentScale();
Point point_b = ip_matrix * handle_b * GetContentScale();
Point middle = (point_a + point_b) / 2;
auto radius = point_a.GetDistance(middle);
builder.ClipPath(DlPath::MakeCircle(middle, radius));
SkPath circle;
circle.addCircle(middle.x, middle.y, radius);
builder.ClipPath(circle);
}
for (auto join :
@ -830,10 +844,10 @@ TEST_P(AiksTest, FastGradientTestHorizontal) {
DlTileMode::kClamp));
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 300, 300), paint);
builder.Translate(400, 0);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(0, 0, 300, 300), 4, 4), paint);
builder.DrawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 300, 300), 4, 4),
paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -853,10 +867,10 @@ TEST_P(AiksTest, FastGradientTestVertical) {
DlTileMode::kClamp));
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 300, 300), paint);
builder.Translate(400, 0);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(0, 0, 300, 300), 4, 4), paint);
builder.DrawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 300, 300), 4, 4),
paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -876,10 +890,10 @@ TEST_P(AiksTest, FastGradientTestHorizontalReversed) {
DlTileMode::kClamp));
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 300, 300), paint);
builder.Translate(400, 0);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(0, 0, 300, 300), 4, 4), paint);
builder.DrawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 300, 300), 4, 4),
paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -899,10 +913,10 @@ TEST_P(AiksTest, FastGradientTestVerticalReversed) {
DlTileMode::kClamp));
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 300, 300), paint);
builder.Translate(400, 0);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(0, 0, 300, 300), 4, 4), paint);
builder.DrawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 300, 300), 4, 4),
paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -923,10 +937,10 @@ TEST_P(AiksTest, VerifyNonOptimizedGradient) {
stops.data(), DlTileMode::kRepeat));
paint.setColor(DlColor::kWhite());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 300, 300), paint);
builder.Translate(400, 0);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(0, 0, 300, 300), 4, 4), paint);
builder.DrawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 300, 300), 4, 4),
paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

View File

@ -9,6 +9,7 @@
#include "flutter/display_list/dl_color.h"
#include "flutter/display_list/dl_paint.h"
#include "flutter/testing/testing.h"
#include "include/core/SkRect.h"
namespace impeller {
namespace testing {
@ -25,7 +26,7 @@ TEST_P(AiksTest, DrawOpacityPeephole) {
alpha.setColor(DlColor::kRed().modulateOpacity(0.5));
builder.SaveLayer(nullptr, &alpha);
builder.DrawRect(DlRect::MakeXYWH(0, 0, 100, 100), green);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 100, 100), green);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -45,9 +46,9 @@ TEST_P(AiksTest, CanRenderGroupOpacity) {
alpha.setColor(DlColor::kRed().modulateOpacity(0.5));
builder.SaveLayer(nullptr, &alpha);
builder.DrawRect(DlRect::MakeXYWH(0, 0, 100, 100), red);
builder.DrawRect(DlRect::MakeXYWH(200, 200, 100, 100), green);
builder.DrawRect(DlRect::MakeXYWH(400, 400, 100, 100), blue);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 100, 100), red);
builder.DrawRect(SkRect::MakeXYWH(200, 200, 100, 100), green);
builder.DrawRect(SkRect::MakeXYWH(400, 400, 100, 100), blue);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -64,11 +65,11 @@ TEST_P(AiksTest, CanRenderGroupOpacityToSavelayer) {
// Create a saveLayer that will forward its opacity to another
// saveLayer, to verify that we correctly distribute opacity.
DlRect bounds = DlRect::MakeLTRB(0, 0, 500, 500);
builder.SaveLayer(bounds, &alpha);
builder.SaveLayer(bounds, &alpha);
builder.DrawRect(DlRect::MakeXYWH(0, 0, 400, 400), red);
builder.DrawRect(DlRect::MakeXYWH(0, 0, 450, 450), red);
SkRect bounds = SkRect::MakeLTRB(0, 0, 500, 500);
builder.SaveLayer(&bounds, &alpha);
builder.SaveLayer(&bounds, &alpha);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 400, 400), red);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 450, 450), red);
builder.Restore();
builder.Restore();

View File

@ -17,6 +17,11 @@
#include "impeller/display_list/dl_image_impeller.h"
#include "impeller/playground/widgets.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkRRect.h"
namespace impeller {
namespace testing {
@ -24,16 +29,13 @@ using namespace flutter;
TEST_P(AiksTest, RotateColorFilteredPath) {
DisplayListBuilder builder;
builder.Transform(DlMatrix::MakeTranslation(DlPoint(300, 300)) *
DlMatrix::MakeRotationZ(DlDegrees(90)));
builder.Transform(SkMatrix::Translate(300, 300) * SkMatrix::RotateDeg(90));
DlPathBuilder arrow_stem;
DlPathBuilder arrow_head;
SkPath arrow_stem;
SkPath arrow_head;
arrow_stem.MoveTo(DlPoint(120, 190)).LineTo(DlPoint(120, 50));
arrow_head.MoveTo(DlPoint(50, 120))
.LineTo(DlPoint(120, 190))
.LineTo(DlPoint(190, 120));
arrow_stem.moveTo({120, 190}).lineTo({120, 50});
arrow_head.moveTo({50, 120}).lineTo({120, 190}).lineTo({190, 120});
auto filter =
DlColorFilter::MakeBlend(DlColor::kAliceBlue(), DlBlendMode::kSrcIn);
@ -46,8 +48,8 @@ TEST_P(AiksTest, RotateColorFilteredPath) {
paint.setColorFilter(filter);
paint.setColor(DlColor::kBlack());
builder.DrawPath(DlPath(arrow_stem), paint);
builder.DrawPath(DlPath(arrow_head), paint);
builder.DrawPath(arrow_stem, paint);
builder.DrawPath(arrow_head, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -59,8 +61,7 @@ TEST_P(AiksTest, CanRenderStrokes) {
paint.setStrokeWidth(20);
paint.setDrawStyle(DlDrawStyle::kStroke);
builder.DrawPath(DlPath::MakeLine(DlPoint(200, 100), DlPoint(800, 100)),
paint);
builder.DrawPath(SkPath::Line({200, 100}, {800, 100}), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -72,7 +73,7 @@ TEST_P(AiksTest, CanRenderCurvedStrokes) {
paint.setStrokeWidth(25);
paint.setDrawStyle(DlDrawStyle::kStroke);
builder.DrawPath(DlPath::MakeCircle(DlPoint(500, 500), 250), paint);
builder.DrawPath(SkPath::Circle(500, 500, 250), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -84,7 +85,7 @@ TEST_P(AiksTest, CanRenderThickCurvedStrokes) {
paint.setStrokeWidth(100);
paint.setDrawStyle(DlDrawStyle::kStroke);
builder.DrawPath(DlPath::MakeCircle(DlPoint(100, 100), 50), paint);
builder.DrawPath(SkPath::Circle(100, 100, 50), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -96,7 +97,7 @@ TEST_P(AiksTest, CanRenderThinCurvedStrokes) {
paint.setStrokeWidth(0.01);
paint.setDrawStyle(DlDrawStyle::kStroke);
builder.DrawPath(DlPath::MakeCircle(DlPoint(100, 100), 50), paint);
builder.DrawPath(SkPath::Circle(100, 100, 50), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -108,8 +109,8 @@ TEST_P(AiksTest, CanRenderStrokePathThatEndsAtSharpTurn) {
paint.setStrokeWidth(200);
paint.setDrawStyle(DlDrawStyle::kStroke);
DlPath path = DlPath::MakeArc(DlRect::MakeXYWH(100, 100, 200, 200), //
DlDegrees(0), DlDegrees(90), false);
SkPath path;
path.arcTo(SkRect::MakeXYWH(100, 100, 200, 200), 0, 90, false);
builder.DrawPath(path, paint);
@ -124,12 +125,11 @@ TEST_P(AiksTest, CanRenderStrokePathWithCubicLine) {
paint.setStrokeWidth(20);
paint.setDrawStyle(DlDrawStyle::kStroke);
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(0, 200));
path_builder.CubicCurveTo(DlPoint(50, 400), DlPoint(350, 0),
DlPoint(400, 200));
SkPath path;
path.moveTo(0, 200);
path.cubicTo(50, 400, 350, 0, 400, 200);
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -144,11 +144,11 @@ TEST_P(AiksTest, CanRenderQuadraticStrokeWithInstantTurn) {
// Should draw a diagonal pill shape. If flat on either end, the stroke is
// rendering wrong.
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(250, 250));
path_builder.QuadraticCurveTo(DlPoint(100, 100), DlPoint(250, 250));
SkPath path;
path.moveTo(250, 250);
path.quadTo(100, 100, 250, 250);
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -159,24 +159,17 @@ TEST_P(AiksTest, CanRenderDifferencePaths) {
DlPaint paint;
paint.setColor(DlColor::kRed());
RoundingRadii radii = {
.top_left = {50, 25},
.top_right = {25, 50},
.bottom_left = {25, 50},
.bottom_right = {50, 25},
};
PathBuilder path_builder;
DlRoundRect rrect =
DlRoundRect::MakeRectRadii(DlRect::MakeXYWH(100, 100, 200, 200), radii);
// We use the factory method to convert the rrect and circle to a path so
// that they use the legacy conics for legacy golden output.
path_builder.AddPath(DlPath::MakeRoundRect(rrect).GetPath());
path_builder.AddPath(DlPath::MakeCircle(DlPoint(200, 200), 50).GetPath());
DlPath path(path_builder, DlPathFillType::kOdd);
SkPoint radii[4] = {{50, 25}, {25, 50}, {50, 25}, {25, 50}};
SkPath path;
SkRRect rrect;
rrect.setRectRadii(SkRect::MakeXYWH(100, 100, 200, 200), radii);
path.addRRect(rrect);
path.addCircle(200, 200, 50);
path.setFillType(SkPathFillType::kEvenOdd);
builder.DrawImage(
DlImageImpeller::Make(CreateTextureForFixture("boston.jpg")),
DlPoint{10, 10}, {});
SkPoint{10, 10}, {});
builder.DrawPath(path, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -192,18 +185,18 @@ TEST_P(AiksTest, CanDrawAnOpenPath) {
// 1. (50, height)
// 2. (width, height)
// 3. (width, 50)
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(50, 50));
path_builder.LineTo(DlPoint(50, 100));
path_builder.LineTo(DlPoint(100, 100));
path_builder.LineTo(DlPoint(100, 50));
SkPath path;
path.moveTo(50, 50);
path.lineTo(50, 100);
path.lineTo(100, 100);
path.lineTo(100, 50);
DlPaint paint;
paint.setColor(DlColor::kRed());
paint.setDrawStyle(DlDrawStyle::kStroke);
paint.setStrokeWidth(10);
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -213,19 +206,20 @@ TEST_P(AiksTest, CanDrawAnOpenPathThatIsntARect) {
// Draw a stroked path that is explicitly closed to verify
// It doesn't become a rectangle.
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(50, 50));
path_builder.LineTo(DlPoint(520, 120));
path_builder.LineTo(DlPoint(300, 310));
path_builder.LineTo(DlPoint(100, 50));
path_builder.Close();
SkPath path;
// PathBuilder builder;
path.moveTo(50, 50);
path.lineTo(520, 120);
path.lineTo(300, 310);
path.lineTo(100, 50);
path.close();
DlPaint paint;
paint.setColor(DlColor::kRed());
paint.setDrawStyle(DlDrawStyle::kStroke);
paint.setStrokeWidth(10);
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -257,13 +251,12 @@ TEST_P(AiksTest, SolidStrokesRenderCorrectly) {
paint.setDrawStyle(DlDrawStyle::kStroke);
paint.setStrokeWidth(10);
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(20, 20));
path_builder.QuadraticCurveTo(DlPoint(60, 20), DlPoint(60, 60));
path_builder.Close();
path_builder.MoveTo(DlPoint(60, 20));
path_builder.QuadraticCurveTo(DlPoint(60, 60), DlPoint(20, 60));
DlPath path(path_builder);
SkPath path;
path.moveTo({20, 20});
path.quadTo({60, 20}, {60, 60});
path.close();
path.moveTo({60, 20});
path.quadTo({60, 60}, {20, 60});
builder.Scale(scale, scale);
@ -275,21 +268,22 @@ TEST_P(AiksTest, SolidStrokesRenderCorrectly) {
auto [handle_a, handle_b] =
DrawPlaygroundLine(circle_clip_point_a, circle_clip_point_b);
Matrix screen_to_canvas = builder.GetMatrix();
if (!screen_to_canvas.IsInvertible()) {
SkMatrix screen_to_canvas = SkMatrix::I();
if (!builder.GetTransform().invert(&screen_to_canvas)) {
return nullptr;
}
screen_to_canvas = screen_to_canvas.Invert();
Point point_a = screen_to_canvas * handle_a;
Point point_b = screen_to_canvas * handle_b;
SkPoint point_a =
screen_to_canvas.mapPoint(SkPoint::Make(handle_a.x, handle_a.y));
SkPoint point_b =
screen_to_canvas.mapPoint(SkPoint::Make(handle_b.x, handle_b.y));
Point middle = point_a + point_b;
middle *= GetContentScale().x / 2;
SkPoint middle = point_a + point_b;
middle.scale(GetContentScale().x / 2);
auto radius = point_a.GetDistance(middle);
auto radius = SkPoint::Distance(point_a, middle);
builder.ClipPath(DlPath::MakeCircle(middle, radius));
builder.ClipPath(SkPath::Circle(middle.x(), middle.y(), radius));
}
for (auto join :
@ -322,8 +316,8 @@ TEST_P(AiksTest, DrawLinesRenderCorrectly) {
for (auto cap :
{DlStrokeCap::kButt, DlStrokeCap::kSquare, DlStrokeCap::kRound}) {
paint.setStrokeCap(cap);
DlPoint origin = {100, 100};
builder.DrawLine(DlPoint(150, 100), DlPoint(250, 100), paint);
SkPoint origin = {100, 100};
builder.DrawLine(SkPoint{150, 100}, SkPoint{250, 100}, paint);
for (int d = 15; d < 90; d += 15) {
Matrix m = Matrix::MakeRotationZ(Degrees(d));
Point origin = {100, 100};
@ -332,12 +326,13 @@ TEST_P(AiksTest, DrawLinesRenderCorrectly) {
auto a = origin + m * p0;
auto b = origin + m * p1;
builder.DrawLine(a, b, paint);
builder.DrawLine(SkPoint::Make(a.x, a.y), SkPoint::Make(b.x, b.y),
paint);
}
builder.DrawLine(DlPoint(100, 150), DlPoint(100, 250), paint);
builder.DrawCircle(origin, 35, paint);
builder.DrawLine(SkPoint{100, 150}, SkPoint{100, 250}, paint);
builder.DrawCircle({origin}, 35, paint);
builder.DrawLine(DlPoint(250, 250), DlPoint(250, 250), paint);
builder.DrawLine(SkPoint{250, 250}, SkPoint{250, 250}, paint);
builder.Translate(250, 0);
}
@ -390,7 +385,7 @@ TEST_P(AiksTest, DrawRectStrokesRenderCorrectly) {
paint.setStrokeWidth(10);
builder.Translate(100, 100);
builder.DrawPath(DlPath::MakeRect(DlRect::MakeSize(DlSize(100, 100))), paint);
builder.DrawPath(SkPath::Rect(SkRect::MakeSize(SkSize{100, 100})), {paint});
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -404,30 +399,24 @@ TEST_P(AiksTest, DrawRectStrokesWithBevelJoinRenderCorrectly) {
paint.setStrokeJoin(DlStrokeJoin::kBevel);
builder.Translate(100, 100);
builder.DrawPath(DlPath::MakeRect(DlRect::MakeSize(DlSize(100, 100))), paint);
builder.DrawPath(SkPath::Rect(SkRect::MakeSize(SkSize{100, 100})), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, CanDrawMultiContourConvexPath) {
DlPathBuilder path_builder;
SkPath path;
for (auto i = 0; i < 10; i++) {
if (i % 2 == 0) {
// We use the factory method to convert the circle to a path so that it
// uses the legacy conics for legacy golden output.
DlPath circle =
DlPath::MakeCircle(DlPoint(100 + 50 * i, 100 + 50 * i), 100);
path_builder.AddPath(circle.GetPath());
path_builder.Close();
path.addCircle(100 + 50 * i, 100 + 50 * i, 100);
path.close();
} else {
path_builder.MoveTo(DlPoint(100.f + 50.f * i - 100, 100.f + 50.f * i));
path_builder.LineTo(DlPoint(100.f + 50.f * i, 100.f + 50.f * i - 100));
path_builder.LineTo(DlPoint(100.f + 50.f * i - 100, //
100.f + 50.f * i - 100));
path_builder.Close();
path.moveTo({100.f + 50.f * i - 100, 100.f + 50.f * i});
path.lineTo({100.f + 50.f * i, 100.f + 50.f * i - 100});
path.lineTo({100.f + 50.f * i - 100, 100.f + 50.f * i - 100});
path.close();
}
}
DlPath path(path_builder);
DisplayListBuilder builder;
DlPaint paint;
@ -453,10 +442,9 @@ TEST_P(AiksTest, ArcWithZeroSweepAndBlur) {
stops.data(), DlTileMode::kMirror));
paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 20));
DlPathBuilder path_builder;
path_builder.AddArc(DlRect::MakeXYWH(10, 10, 100, 100), //
DlDegrees(0), DlDegrees(0));
builder.DrawPath(DlPath(path_builder), paint);
SkPath path;
path.addArc(SkRect::MakeXYWH(10, 10, 100, 100), 0, 0);
builder.DrawPath(path, paint);
// Check that this empty picture can be created without crashing.
builder.Build();
@ -467,8 +455,8 @@ TEST_P(AiksTest, CanRenderClips) {
DlPaint paint;
paint.setColor(DlColor::kFuchsia());
builder.ClipPath(DlPath::MakeRect(DlRect::MakeXYWH(0, 0, 500, 500)));
builder.DrawPath(DlPath::MakeCircle(DlPoint(500, 500), 250), paint);
builder.ClipPath(SkPath::Rect(SkRect::MakeXYWH(0, 0, 500, 500)));
builder.DrawPath(SkPath::Circle(500, 500, 250), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -518,48 +506,41 @@ TEST_P(AiksTest, CanRenderOverlappingMultiContourPath) {
DlPaint paint;
paint.setColor(DlColor::kRed());
RoundingRadii radii = {
.top_left = DlSize(50, 50),
.top_right = DlSize(50, 50),
.bottom_left = DlSize(50, 50),
.bottom_right = DlSize(50, 50),
};
SkPoint radii[4] = {{50, 50}, {50, 50}, {50, 50}, {50, 50}};
const Scalar kTriangleHeight = 100;
DlRoundRect rrect = DlRoundRect::MakeRectRadii(
DlRect::MakeXYWH(-kTriangleHeight / 2.0f, -kTriangleHeight / 2.0f,
SkRRect rrect;
rrect.setRectRadii(
SkRect::MakeXYWH(-kTriangleHeight / 2.0f, -kTriangleHeight / 2.0f,
kTriangleHeight, kTriangleHeight),
radii //
);
// We use the factory method to convert the rrect to a path so that it
// uses the legacy conics for legacy golden output.
DlPath rrect_path = DlPath::MakeRoundRect(rrect);
builder.Translate(200, 200);
// Form a path similar to the Material drop slider value indicator. Both
// shapes should render identically side-by-side.
{
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(0, kTriangleHeight));
path_builder.LineTo(DlPoint(-kTriangleHeight / 2.0f, 0));
path_builder.LineTo(DlPoint(kTriangleHeight / 2.0f, 0));
path_builder.Close();
path_builder.AddPath(rrect_path.GetPath());
SkPath path;
path.moveTo(0, kTriangleHeight);
path.lineTo(-kTriangleHeight / 2.0f, 0);
path.lineTo(kTriangleHeight / 2.0f, 0);
path.close();
path.addRRect(rrect);
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
}
builder.Translate(100, 0);
{
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(0, kTriangleHeight));
path_builder.LineTo(DlPoint(-kTriangleHeight / 2.0f, 0));
path_builder.LineTo(DlPoint(0, -10));
path_builder.LineTo(DlPoint(kTriangleHeight / 2.0f, 0));
path_builder.Close();
path_builder.AddPath(rrect_path.GetPath());
SkPath path;
path.moveTo(0, kTriangleHeight);
path.lineTo(-kTriangleHeight / 2.0f, 0);
path.lineTo(0, -10);
path.lineTo(kTriangleHeight / 2.0f, 0);
path.close();
path.addRRect(rrect);
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(path, paint);
}
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));

View File

@ -11,6 +11,9 @@
#include "flutter/display_list/effects/dl_runtime_effect.h"
#include "flutter/impeller/display_list/aiks_unittests.h"
#include "include/core/SkPath.h"
#include "include/core/SkRRect.h"
namespace impeller {
namespace testing {
@ -51,10 +54,10 @@ TEST_P(AiksTest, CanRenderClippedRuntimeEffects) {
DisplayListBuilder builder;
builder.Save();
builder.ClipRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(0, 0, 400, 400), 10.0, 10.0),
builder.ClipRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 400, 400), 10.0, 10.0),
DlCanvas::ClipOp::kIntersect);
builder.DrawRect(DlRect::MakeXYWH(0, 0, 400, 400), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 400, 400), paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -103,7 +106,7 @@ TEST_P(AiksTest, CanRenderRuntimeEffectFilter) {
uniform_data));
DisplayListBuilder builder;
builder.DrawRect(DlRect::MakeXYWH(0, 0, 400, 400), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 400, 400), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

View File

@ -15,6 +15,8 @@
#include "flutter/testing/testing.h"
#include "impeller/geometry/matrix.h"
#include "impeller/typographer/backends/skia/text_frame_skia.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include "txt/platform.h"
@ -29,7 +31,7 @@ struct TextRenderOptions {
Scalar font_size = 50;
Scalar stroke_width = 1;
DlColor color = DlColor::kYellow();
DlPoint position = DlPoint(100, 200);
SkPoint position = SkPoint::Make(100, 200);
std::shared_ptr<DlMaskFilter> filter;
};
@ -41,9 +43,9 @@ bool RenderTextInCanvasSkia(const std::shared_ptr<Context>& context,
// Draw the baseline.
DlPaint paint;
paint.setColor(DlColor::kAqua().withAlpha(255 * 0.25));
canvas.DrawRect(
DlRect::MakeXYWH(options.position.x - 50, options.position.y, 900, 10),
paint);
canvas.DrawRect(SkRect::MakeXYWH(options.position.x() - 50,
options.position.y(), 900, 10),
paint);
// Mark the point at which the text is drawn.
paint.setColor(DlColor::kRed().withAlpha(255 * 0.25));
@ -71,7 +73,7 @@ bool RenderTextInCanvasSkia(const std::shared_ptr<Context>& context,
text_paint.setStrokeWidth(options.stroke_width);
text_paint.setDrawStyle(options.stroke ? DlDrawStyle::kStroke
: DlDrawStyle::kFill);
canvas.DrawTextFrame(frame, options.position.x, options.position.y,
canvas.DrawTextFrame(frame, options.position.x(), options.position.y(),
text_paint);
return true;
}
@ -190,7 +192,7 @@ TEST_P(AiksTest, TextFrameSubpixelAlignment) {
builder.Scale(GetContentScale().x, GetContentScale().y);
for (size_t i = 0; i < phase_offsets.size(); i++) {
DlPoint position = DlPoint(
SkPoint position = SkPoint::Make(
200 +
magnitude * std::sin((-phase_offsets[i] * k2Pi * phase_variation +
GetSecondsElapsed() * speed)), //
@ -314,17 +316,17 @@ TEST_P(AiksTest, CanRenderTextOutsideBoundaries) {
text_paint.setColor(DlColor::kBlue().withAlpha(255 * 0.8));
struct {
DlPoint position;
SkPoint position;
const char* text;
} text[] = {{DlPoint(0, 0), "0F0F0F0"},
{DlPoint(1, 2), "789"},
{DlPoint(1, 3), "456"},
{DlPoint(1, 4), "123"},
{DlPoint(0, 6), "0F0F0F0"}};
} text[] = {{SkPoint::Make(0, 0), "0F0F0F0"},
{SkPoint::Make(1, 2), "789"},
{SkPoint::Make(1, 3), "456"},
{SkPoint::Make(1, 4), "123"},
{SkPoint::Make(0, 6), "0F0F0F0"}};
for (auto& t : text) {
builder.Save();
builder.Translate(t.position.x * font_size * 2,
t.position.y * font_size * 1.1);
builder.Translate(t.position.x() * font_size * 2,
t.position.y() * font_size * 1.1);
{
auto blob = SkTextBlob::MakeFromString(t.text, sk_font);
ASSERT_NE(blob, nullptr);
@ -345,10 +347,11 @@ TEST_P(AiksTest, TextRotated) {
paint.setColor(DlColor::ARGB(0.1, 0.1, 0.1, 1.0));
builder.DrawPaint(paint);
builder.Transform(Matrix(0.25, -0.3, 0, -0.002, //
0, 0.5, 0, 0, //
0, 0, 0.3, 0, //
100, 100, 0, 1.3));
builder.Transform(SkM44::ColMajor(Matrix(0.25, -0.3, 0, -0.002, //
0, 0.5, 0, 0, //
0, 0, 0.3, 0, //
100, 100, 0, 1.3)
.m));
ASSERT_TRUE(RenderTextInCanvasSkia(
GetContext(), builder, "the quick brown fox jumped over the lazy dog!.?",
"Roboto-Regular.ttf"));
@ -365,7 +368,7 @@ TEST_P(AiksTest, DrawScaledTextWithPerspectiveNoSaveLayer) {
0.0, 0.0, 0.0, 1.0) * //
Matrix::MakeRotationY({Degrees{10}});
builder.Transform(matrix);
builder.Transform(SkM44::ColMajor(matrix.m));
ASSERT_TRUE(RenderTextInCanvasSkia(GetContext(), builder, "Hello world",
"Roboto-Regular.ttf"));
@ -382,11 +385,11 @@ TEST_P(AiksTest, DrawScaledTextWithPerspectiveSaveLayer) {
Matrix::MakeRotationY({Degrees{10}});
DlPaint save_paint;
DlRect window_bounds =
DlRect::MakeXYWH(0, 0, GetWindowSize().width, GetWindowSize().height);
SkRect window_bounds =
SkRect::MakeXYWH(0, 0, GetWindowSize().width, GetWindowSize().height);
// Note: bounds were not needed by the AIKS version, which may indicate a bug.
builder.SaveLayer(window_bounds, &save_paint);
builder.Transform(matrix);
builder.SaveLayer(&window_bounds, &save_paint);
builder.Transform(SkM44::ColMajor(matrix.m));
ASSERT_TRUE(RenderTextInCanvasSkia(GetContext(), builder, "Hello world",
"Roboto-Regular.ttf"));
@ -403,11 +406,12 @@ TEST_P(AiksTest, CanRenderTextWithLargePerspectiveTransform) {
DlPaint save_paint;
builder.SaveLayer(nullptr, &save_paint);
builder.Transform(Matrix(2000, 0, 0, 0, //
0, 2000, 0, 0, //
0, 0, -1, 9000, //
0, 0, -1, 7000 //
));
builder.Transform(SkM44::ColMajor(Matrix(2000, 0, 0, 0, //
0, 2000, 0, 0, //
0, 0, -1, 9000, //
0, 0, -1, 7000 //
)
.m));
ASSERT_TRUE(RenderTextInCanvasSkia(GetContext(), builder, "Hello world",
"Roboto-Regular.ttf"));
@ -428,10 +432,10 @@ TEST_P(AiksTest, CanRenderTextWithPerspectiveTransformInSublist) {
0.0, 0.002, 0.0, 1.0);
DlPaint save_paint;
DlRect window_bounds =
DlRect::MakeXYWH(0, 0, GetWindowSize().width, GetWindowSize().height);
builder.SaveLayer(window_bounds, &save_paint);
builder.Transform(matrix);
SkRect window_bounds =
SkRect::MakeXYWH(0, 0, GetWindowSize().width, GetWindowSize().height);
builder.SaveLayer(&window_bounds, &save_paint);
builder.Transform(SkM44::ColMajor(matrix.m));
builder.DrawDisplayList(text_display_list, 1.0f);
builder.Restore();
@ -529,20 +533,19 @@ TEST_P(AiksTest, DifferenceClipsMustRenderIdenticallyAcrossBackends) {
builder.Save();
builder.Transform(path_xform);
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(87.5, 349.5));
path_builder.LineTo(DlPoint(25.0, 29.5));
path_builder.LineTo(DlPoint(150.0, 118.0));
path_builder.LineTo(DlPoint(25.0, 118.0));
path_builder.LineTo(DlPoint(150.0, 29.5));
path_builder.Close();
DlPath path(path_builder);
SkPath path;
path.moveTo(87.5, 349.5);
path.lineTo(25.0, 29.5);
path.lineTo(150.0, 118.0);
path.lineTo(25.0, 118.0);
path.lineTo(150.0, 29.5);
path.close();
DlColor fill_color(1.0, 1.0, 0.0, 0.0, DlColorSpace::kSRGB);
DlColor stroke_color(1.0, 0.0, 0.0, 0.0, DlColorSpace::kSRGB);
paint.setColor(fill_color);
paint.setDrawStyle(DlDrawStyle::kFill);
builder.DrawPath(path, paint);
builder.DrawPath(DlPath(path), paint);
paint.setColor(stroke_color);
paint.setStrokeWidth(2.0);

View File

@ -23,12 +23,22 @@
#include "impeller/display_list/dl_dispatcher.h"
#include "impeller/display_list/dl_image_impeller.h"
#include "impeller/geometry/scalar.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPath.h"
#include "include/core/SkRefCnt.h"
namespace impeller {
namespace testing {
using namespace flutter;
namespace {
SkRect GetCullRect(ISize window_size) {
return SkRect::MakeSize(SkSize::Make(window_size.width, window_size.height));
}
} // namespace
TEST_P(AiksTest, CollapsedDrawPaintInSubpass) {
DisplayListBuilder builder;
@ -68,7 +78,7 @@ TEST_P(AiksTest, CollapsedDrawPaintInSubpassBackdropFilter) {
}
TEST_P(AiksTest, ColorMatrixFilterSubpassCollapseOptimization) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
const float matrix[20] = {
-1.0, 0, 0, 1.0, 0, //
@ -87,13 +97,13 @@ TEST_P(AiksTest, ColorMatrixFilterSubpassCollapseOptimization) {
DlPaint draw_paint;
draw_paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 200, 200), draw_paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 200, 200), draw_paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, LinearToSrgbFilterSubpassCollapseOptimization) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColorFilter(DlColorFilter::MakeLinearToSrgbGamma());
@ -104,13 +114,13 @@ TEST_P(AiksTest, LinearToSrgbFilterSubpassCollapseOptimization) {
DlPaint draw_paint;
draw_paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 200, 200), draw_paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 200, 200), draw_paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, SrgbToLinearFilterSubpassCollapseOptimization) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColorFilter(DlColorFilter::MakeLinearToSrgbGamma());
@ -121,45 +131,45 @@ TEST_P(AiksTest, SrgbToLinearFilterSubpassCollapseOptimization) {
DlPaint draw_paint;
draw_paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 200, 200), draw_paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 200, 200), draw_paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, TranslucentSaveLayerDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 300, 300), paint);
DlPaint save_paint;
save_paint.setColor(DlColor::kBlack().withAlpha(128));
builder.SaveLayer(nullptr, &save_paint);
builder.DrawRect(DlRect::MakeXYWH(100, 500, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 500, 300, 300), paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, TranslucentSaveLayerWithBlendColorFilterDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 300, 300), paint);
DlPaint save_paint;
paint.setColor(DlColor::kBlack().withAlpha(128));
paint.setColorFilter(
DlColorFilter::MakeBlend(DlColor::kRed(), DlBlendMode::kDstOver));
builder.Save();
builder.ClipRect(DlRect::MakeXYWH(100, 500, 300, 300));
builder.ClipRect(SkRect::MakeXYWH(100, 500, 300, 300));
builder.SaveLayer(nullptr, &paint);
DlPaint draw_paint;
draw_paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 500, 300, 300), draw_paint);
builder.DrawRect(SkRect::MakeXYWH(100, 500, 300, 300), draw_paint);
builder.Restore();
builder.Restore();
@ -167,11 +177,11 @@ TEST_P(AiksTest, TranslucentSaveLayerWithBlendColorFilterDrawsCorrectly) {
}
TEST_P(AiksTest, TranslucentSaveLayerWithBlendImageFilterDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 300, 300), paint);
DlPaint save_paint;
save_paint.setColor(DlColor::kBlack().withAlpha(128));
@ -182,30 +192,30 @@ TEST_P(AiksTest, TranslucentSaveLayerWithBlendImageFilterDrawsCorrectly) {
DlPaint draw_paint;
draw_paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 500, 300, 300), draw_paint);
builder.DrawRect(SkRect::MakeXYWH(100, 500, 300, 300), draw_paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, TranslucentSaveLayerWithColorAndImageFilterDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 100, 300, 300), paint);
builder.DrawRect(SkRect::MakeXYWH(100, 100, 300, 300), paint);
DlPaint save_paint;
save_paint.setColor(DlColor::kBlack().withAlpha(128));
save_paint.setColorFilter(
DlColorFilter::MakeBlend(DlColor::kRed(), DlBlendMode::kDstOver));
builder.Save();
builder.ClipRect(DlRect::MakeXYWH(100, 500, 300, 300));
builder.ClipRect(SkRect::MakeXYWH(100, 500, 300, 300));
builder.SaveLayer(nullptr, &save_paint);
DlPaint draw_paint;
draw_paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeXYWH(100, 500, 300, 300), draw_paint);
builder.DrawRect(SkRect::MakeXYWH(100, 500, 300, 300), draw_paint);
builder.Restore();
builder.Restore();
@ -213,7 +223,7 @@ TEST_P(AiksTest, TranslucentSaveLayerWithColorAndImageFilterDrawsCorrectly) {
}
TEST_P(AiksTest, ImageFilteredUnboundedSaveLayerWithUnboundedContents) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
builder.Scale(GetContentScale().x, GetContentScale().y);
DlPaint save_paint;
@ -230,7 +240,7 @@ TEST_P(AiksTest, ImageFilteredUnboundedSaveLayerWithUnboundedContents) {
// Contrasting rectangle to see interior blurring
DlPaint draw_rect;
draw_rect.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeLTRB(125, 125, 175, 175), draw_rect);
builder.DrawRect(SkRect::MakeLTRB(125, 125, 175, 175), draw_rect);
}
builder.Restore();
@ -238,25 +248,25 @@ TEST_P(AiksTest, ImageFilteredUnboundedSaveLayerWithUnboundedContents) {
}
TEST_P(AiksTest, TranslucentSaveLayerImageDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
auto image = DlImageImpeller::Make(CreateTextureForFixture("airplane.jpg"));
builder.DrawImage(image, DlPoint(100, 100), DlImageSampling::kMipmapLinear);
builder.DrawImage(image, SkPoint{100, 100}, DlImageSampling::kMipmapLinear);
DlPaint paint;
paint.setColor(DlColor::kBlack().withAlpha(128));
builder.SaveLayer(nullptr, &paint);
builder.DrawImage(image, DlPoint(100, 500), DlImageSampling::kMipmapLinear);
builder.DrawImage(image, SkPoint{100, 500}, DlImageSampling::kMipmapLinear);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, TranslucentSaveLayerWithColorMatrixColorFilterDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
auto image = DlImageImpeller::Make(CreateTextureForFixture("airplane.jpg"));
builder.DrawImage(image, DlPoint(100, 100), {});
builder.DrawImage(image, SkPoint{100, 100}, {});
const float matrix[20] = {
1, 0, 0, 0, 0, //
@ -268,17 +278,17 @@ TEST_P(AiksTest, TranslucentSaveLayerWithColorMatrixColorFilterDrawsCorrectly) {
paint.setColor(DlColor::kBlack().withAlpha(128));
paint.setColorFilter(DlColorFilter::MakeMatrix(matrix));
builder.SaveLayer(nullptr, &paint);
builder.DrawImage(image, DlPoint(100, 500), {});
builder.DrawImage(image, SkPoint{100, 500}, {});
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, TranslucentSaveLayerWithColorMatrixImageFilterDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
auto image = DlImageImpeller::Make(CreateTextureForFixture("airplane.jpg"));
builder.DrawImage(image, DlPoint(100, 100), {});
builder.DrawImage(image, SkPoint{100, 100}, {});
const float matrix[20] = {
1, 0, 0, 0, 0, //
@ -290,7 +300,7 @@ TEST_P(AiksTest, TranslucentSaveLayerWithColorMatrixImageFilterDrawsCorrectly) {
paint.setColor(DlColor::kBlack().withAlpha(128));
paint.setColorFilter(DlColorFilter::MakeMatrix(matrix));
builder.SaveLayer(nullptr, &paint);
builder.DrawImage(image, DlPoint(100, 500), {});
builder.DrawImage(image, SkPoint{100, 500}, {});
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -298,10 +308,10 @@ TEST_P(AiksTest, TranslucentSaveLayerWithColorMatrixImageFilterDrawsCorrectly) {
TEST_P(AiksTest,
TranslucentSaveLayerWithColorFilterAndImageFilterDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
auto image = DlImageImpeller::Make(CreateTextureForFixture("airplane.jpg"));
builder.DrawImage(image, DlPoint(100, 100), {});
builder.DrawImage(image, SkPoint{100, 100}, {});
const float matrix[20] = {
1, 0, 0, 0, 0, //
@ -316,18 +326,18 @@ TEST_P(AiksTest,
paint.setColorFilter(
DlColorFilter::MakeBlend(DlColor::kGreen(), DlBlendMode::kModulate));
builder.SaveLayer(nullptr, &paint);
builder.DrawImage(image, DlPoint(100, 500), {});
builder.DrawImage(image, SkPoint{100, 500}, {});
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, TranslucentSaveLayerWithAdvancedBlendModeDrawsCorrectly) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 400, 400), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 400, 400), paint);
DlPaint save_paint;
save_paint.setAlpha(128);
@ -336,7 +346,7 @@ TEST_P(AiksTest, TranslucentSaveLayerWithAdvancedBlendModeDrawsCorrectly) {
DlPaint draw_paint;
draw_paint.setColor(DlColor::kGreen());
builder.DrawCircle(DlPoint(200, 200), 100, draw_paint);
builder.DrawCircle(SkPoint{200, 200}, 100, draw_paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -346,7 +356,7 @@ TEST_P(AiksTest, TranslucentSaveLayerWithAdvancedBlendModeDrawsCorrectly) {
/// The entire screen is green if successful. If failing, no frames will render,
/// or the entire screen will be transparent black.
TEST_P(AiksTest, CanRenderTinyOverlappingSubpasses) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColor(DlColor::kRed());
@ -357,10 +367,10 @@ TEST_P(AiksTest, CanRenderTinyOverlappingSubpasses) {
DlPaint yellow_paint;
yellow_paint.setColor(DlColor::kYellow());
builder.DrawCircle(DlPoint(100, 100), 0.1, yellow_paint);
builder.DrawCircle(SkPoint{100, 100}, 0.1, yellow_paint);
builder.Restore();
builder.SaveLayer({});
builder.DrawCircle(DlPoint(100, 100), 0.1, yellow_paint);
builder.DrawCircle(SkPoint{100, 100}, 0.1, yellow_paint);
builder.Restore();
DlPaint draw_paint;
@ -371,7 +381,7 @@ TEST_P(AiksTest, CanRenderTinyOverlappingSubpasses) {
}
TEST_P(AiksTest, CanRenderDestructiveSaveLayer) {
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DlPaint paint;
paint.setColor(DlColor::kRed());
@ -386,14 +396,14 @@ TEST_P(AiksTest, CanRenderDestructiveSaveLayer) {
DlPaint draw_paint;
draw_paint.setColor(DlColor::kGreen());
builder.DrawCircle(DlPoint(300, 300), 100, draw_paint);
builder.DrawCircle(SkPoint{300, 300}, 100, draw_paint);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, CanDrawPoints) {
std::vector<DlPoint> points = {
std::vector<SkPoint> points = {
{0, 0}, //
{100, 100}, //
{100, 0}, //
@ -415,7 +425,7 @@ TEST_P(AiksTest, CanDrawPoints) {
DlPaint background;
background.setColor(DlColor::kBlack());
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
builder.DrawPaint(background);
builder.Translate(200, 200);
@ -433,7 +443,7 @@ TEST_P(AiksTest, CanDrawPointsWithTextureMap) {
CreateTextureForFixture("table_mountain_nx.png",
/*enable_mipmapping=*/true));
std::vector<DlPoint> points = {
std::vector<SkPoint> points = {
{0, 0}, //
{100, 100}, //
{100, 0}, //
@ -456,7 +466,7 @@ TEST_P(AiksTest, CanDrawPointsWithTextureMap) {
paint_square.setColorSource(image_src);
paint_square.setStrokeWidth(200);
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
builder.Translate(200, 200);
builder.DrawPoints(DlCanvas::PointMode::kPoints, points.size(), points.data(),
@ -516,23 +526,23 @@ TEST_P(AiksTest, MipmapGenerationWorksCorrectly) {
DisplayListBuilder builder;
builder.DrawImageRect(
image,
DlRect::MakeWH(texture->GetSize().width, texture->GetSize().height),
DlRect::MakeLTRB(0, 0, 100, 100), DlImageSampling::kMipmapLinear);
SkRect::MakeSize(
SkSize::Make(texture->GetSize().width, texture->GetSize().height)),
SkRect::MakeLTRB(0, 0, 100, 100), DlImageSampling::kMipmapLinear);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
// https://github.com/flutter/flutter/issues/146648
TEST_P(AiksTest, StrokedPathWithMoveToThenCloseDrawnCorrectly) {
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(0, 400))
.LineTo(DlPoint(0, 0))
.LineTo(DlPoint(400, 0))
SkPath path;
path.moveTo(0, 400)
.lineTo(0, 0)
.lineTo(400, 0)
// MoveTo implicitly adds a contour, ensure that close doesn't
// add another nearly-empty contour.
.MoveTo(DlPoint(0, 400))
.Close();
DlPath path(path_builder);
.moveTo(0, 400)
.close();
DisplayListBuilder builder;
builder.Translate(50, 50);
@ -575,7 +585,7 @@ TEST_P(AiksTest, SetContentsWithRegion) {
auto image = DlImageImpeller::Make(bridge);
DisplayListBuilder builder;
builder.DrawImage(image, DlPoint(0, 0), {});
builder.DrawImage(image, SkPoint{0, 0}, {});
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -598,7 +608,7 @@ TEST_P(AiksTest, ReleasesTextureOnTeardown) {
DlImageImpeller::Make(texture), DlTileMode::kClamp, DlTileMode::kClamp,
DlImageSampling::kLinear, nullptr));
builder.DrawRect(DlRect::MakeXYWH(0, 0, 600, 600), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 600, 600), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -638,7 +648,7 @@ TEST_P(AiksTest, MatrixImageFilterMagnify) {
DlPaint rect_paint;
rect_paint.setAlpha(0.5 * 255);
builder.DrawImage(image, DlPoint(0, 0), DlImageSampling::kLinear,
builder.DrawImage(image, SkPoint{0, 0}, DlImageSampling::kLinear,
&rect_paint);
builder.Restore();
@ -653,24 +663,24 @@ TEST_P(AiksTest, ImageFilteredSaveLayerWithUnboundedContents) {
builder.Scale(GetContentScale().x, GetContentScale().y);
auto test = [&builder](const std::shared_ptr<DlImageFilter>& filter) {
auto DrawLine = [&builder](const DlPoint& p0, const DlPoint& p1,
auto DrawLine = [&builder](const SkPoint& p0, const SkPoint& p1,
const DlPaint& p) {
DlPaint paint = p;
paint.setDrawStyle(DlDrawStyle::kStroke);
builder.DrawPath(DlPath::MakeLine(p0, p1), paint);
builder.DrawPath(SkPath::Line(p0, p1), paint);
};
// Registration marks for the edge of the SaveLayer
DlPaint paint;
paint.setColor(DlColor::kWhite());
DrawLine(DlPoint(75, 100), DlPoint(225, 100), paint);
DrawLine(DlPoint(75, 200), DlPoint(225, 200), paint);
DrawLine(DlPoint(100, 75), DlPoint(100, 225), paint);
DrawLine(DlPoint(200, 75), DlPoint(200, 225), paint);
DrawLine(SkPoint::Make(75, 100), SkPoint::Make(225, 100), paint);
DrawLine(SkPoint::Make(75, 200), SkPoint::Make(225, 200), paint);
DrawLine(SkPoint::Make(100, 75), SkPoint::Make(100, 225), paint);
DrawLine(SkPoint::Make(200, 75), SkPoint::Make(200, 225), paint);
DlPaint save_paint;
save_paint.setImageFilter(filter);
DlRect bounds = DlRect::MakeLTRB(100, 100, 200, 200);
builder.SaveLayer(bounds, &save_paint);
SkRect bounds = SkRect::MakeLTRB(100, 100, 200, 200);
builder.SaveLayer(&bounds, &save_paint);
{
// DrawPaint to verify correct behavior when the contents are unbounded.
@ -680,7 +690,7 @@ TEST_P(AiksTest, ImageFilteredSaveLayerWithUnboundedContents) {
// Contrasting rectangle to see interior blurring
paint.setColor(DlColor::kBlue());
builder.DrawRect(DlRect::MakeLTRB(125, 125, 175, 175), paint);
builder.DrawRect(SkRect::MakeLTRB(125, 125, 175, 175), paint);
}
builder.Restore();
};
@ -753,8 +763,8 @@ TEST_P(AiksTest, MatrixBackdropFilter) {
rect_paint.setColor(DlColor::kRed());
rect_paint.setStrokeWidth(4);
rect_paint.setDrawStyle(DlDrawStyle::kStroke);
builder.DrawRect(DlRect::MakeLTRB(0, 0, 300, 300), rect_paint);
builder.DrawCircle(DlPoint(200, 200), 100, paint);
builder.DrawRect(SkRect::MakeLTRB(0, 0, 300, 300), rect_paint);
builder.DrawCircle(SkPoint::Make(200, 200), 100, paint);
// Should render a second circle, centered on the bottom-right-most edge of
// the circle.
DlMatrix matrix = DlMatrix::MakeTranslation({(100 + 100 * k1OverSqrt2),
@ -781,7 +791,7 @@ TEST_P(AiksTest, MatrixSaveLayerFilter) {
{
paint.setColor(DlColor::kGreen().withAlpha(255 * 0.5));
paint.setBlendMode(DlBlendMode::kPlus);
builder.DrawCircle(DlPoint(200, 200), 100, paint);
builder.DrawCircle(SkPoint{200, 200}, 100, paint);
// Should render a second circle, centered on the bottom-right-most edge of
// the circle.
@ -798,7 +808,7 @@ TEST_P(AiksTest, MatrixSaveLayerFilter) {
DlPaint circle_paint;
circle_paint.setColor(DlColor::kGreen().withAlpha(255 * 0.5));
circle_paint.setBlendMode(DlBlendMode::kPlus);
builder.DrawCircle(DlPoint(200, 200), 100, circle_paint);
builder.DrawCircle(SkPoint{200, 200}, 100, circle_paint);
builder.Restore();
}
builder.Restore();
@ -808,7 +818,7 @@ TEST_P(AiksTest, MatrixSaveLayerFilter) {
// Regression test for flutter/flutter#152780
TEST_P(AiksTest, CanDrawScaledPointsSmallScaleLargeRadius) {
std::vector<DlPoint> point = {
std::vector<SkPoint> point = {
{0, 0}, //
};
@ -817,7 +827,7 @@ TEST_P(AiksTest, CanDrawScaledPointsSmallScaleLargeRadius) {
paint.setColor(DlColor::kRed());
paint.setStrokeWidth(100 * 1000000);
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
builder.Translate(200, 200);
builder.Scale(0.000001, 0.000001);
@ -829,7 +839,7 @@ TEST_P(AiksTest, CanDrawScaledPointsSmallScaleLargeRadius) {
// Regression test for flutter/flutter#152780
TEST_P(AiksTest, CanDrawScaledPointsLargeScaleSmallRadius) {
std::vector<DlPoint> point = {
std::vector<SkPoint> point = {
{0, 0}, //
};
@ -838,7 +848,7 @@ TEST_P(AiksTest, CanDrawScaledPointsLargeScaleSmallRadius) {
paint.setColor(DlColor::kRed());
paint.setStrokeWidth(100 * 0.000001);
DisplayListBuilder builder(DlRect::MakeSize(GetWindowSize()));
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
builder.Translate(200, 200);
builder.Scale(1000000, 1000000);
@ -851,7 +861,7 @@ TEST_P(AiksTest, TransparentShadowProducesCorrectColor) {
DisplayListBuilder builder;
builder.Save();
builder.Scale(1.618, 1.618);
DlPath path = DlPath::MakeRect(DlRect::MakeXYWH(0, 0, 200, 100));
SkPath path = SkPath{}.addRect(SkRect::MakeXYWH(0, 0, 200, 100));
builder.DrawShadow(path, flutter::DlColor::kTransparent(), 15, false, 1);
builder.Restore();
@ -862,7 +872,7 @@ TEST_P(AiksTest, TransparentShadowProducesCorrectColor) {
// Regression test for https://github.com/flutter/flutter/issues/130613
TEST_P(AiksTest, DispatcherDoesNotCullPerspectiveTransformedChildDisplayLists) {
flutter::DisplayListBuilder sub_builder(true);
sub_builder.DrawRect(DlRect::MakeXYWH(0, 0, 50, 50),
sub_builder.DrawRect(SkRect::MakeXYWH(0, 0, 50, 50),
flutter::DlPaint(flutter::DlColor::kRed()));
auto display_list = sub_builder.Build();
@ -896,18 +906,18 @@ TEST_P(AiksTest, BackdropRestoreUsesCorrectCoverageForFirstRestoredClip) {
DlPaint paint;
// Add a difference clip that cuts out the bottom right corner
builder.ClipRect(DlRect::MakeLTRB(50, 50, 100, 100),
builder.ClipRect(SkRect::MakeLTRB(50, 50, 100, 100),
DlCanvas::ClipOp::kDifference);
// Draw a red rectangle that's going to be completely covered by green later.
paint.setColor(DlColor::kRed());
builder.DrawRect(DlRect::MakeLTRB(0, 0, 100, 100), paint);
builder.DrawRect(SkRect::MakeLTRB(0, 0, 100, 100), paint);
// Add a clip restricting the backdrop filter to the top right corner.
auto count = builder.GetSaveCount();
builder.Save();
{
builder.ClipRect(DlRect::MakeLTRB(0, 0, 100, 100));
builder.ClipRect(SkRect::MakeLTRB(0, 0, 100, 100));
{
// Create a save layer with a backdrop blur filter.
auto backdrop_filter =
@ -919,7 +929,7 @@ TEST_P(AiksTest, BackdropRestoreUsesCorrectCoverageForFirstRestoredClip) {
// Finally, overwrite all the previous stuff with green.
paint.setColor(DlColor::kGreen());
builder.DrawRect(DlRect::MakeLTRB(0, 0, 100, 100), paint);
builder.DrawRect(SkRect::MakeLTRB(0, 0, 100, 100), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -928,9 +938,9 @@ TEST_P(AiksTest, CanPictureConvertToImage) {
DisplayListBuilder recorder_canvas;
DlPaint paint;
paint.setColor(DlColor::RGBA(0.9568, 0.2627, 0.2118, 1.0));
recorder_canvas.DrawRect(DlRect::MakeXYWH(100.0, 100.0, 600, 600), paint);
recorder_canvas.DrawRect(SkRect::MakeXYWH(100.0, 100.0, 600, 600), paint);
paint.setColor(DlColor::RGBA(0.1294, 0.5882, 0.9529, 1.0));
recorder_canvas.DrawRect(DlRect::MakeXYWH(200.0, 200.0, 600, 600), paint);
recorder_canvas.DrawRect(SkRect::MakeXYWH(200.0, 200.0, 600, 600), paint);
DisplayListBuilder canvas;
AiksContext renderer(GetContext(), nullptr);
@ -940,9 +950,9 @@ TEST_P(AiksTest, CanPictureConvertToImage) {
auto image =
DisplayListToTexture(recorder_canvas.Build(), {1000, 1000}, renderer);
if (image) {
canvas.DrawImage(DlImageImpeller::Make(image), DlPoint(), {});
canvas.DrawImage(DlImageImpeller::Make(image), SkPoint{}, {});
paint.setColor(DlColor::RGBA(0.1, 0.1, 0.1, 0.2));
canvas.DrawRect(DlRect::MakeWH(1000, 1000), paint);
canvas.DrawRect(SkRect::MakeSize({1000, 1000}), paint);
}
ASSERT_TRUE(OpenPlaygroundHere(canvas.Build()));
@ -964,11 +974,11 @@ TEST_P(AiksTest, CanEmptyPictureConvertToImage) {
auto result_image =
DisplayListToTexture(builder.Build(), ISize{1000, 1000}, renderer);
if (result_image) {
recorder_builder.DrawImage(DlImageImpeller::Make(result_image), DlPoint(),
recorder_builder.DrawImage(DlImageImpeller::Make(result_image), SkPoint{},
{});
paint.setColor(DlColor::RGBA(0.1, 0.1, 0.1, 0.2));
recorder_builder.DrawRect(DlRect::MakeWH(1000, 1000), paint);
recorder_builder.DrawRect(SkRect::MakeSize({1000, 1000}), paint);
}
ASSERT_TRUE(OpenPlaygroundHere(recorder_builder.Build()));
@ -979,7 +989,7 @@ TEST_P(AiksTest, DepthValuesForLineMode) {
// have the same depth values.
DisplayListBuilder builder;
DlPath path = DlPath::MakeCircle(DlPoint(100, 100), 100);
SkPath path = SkPath::Circle(100, 100, 100);
builder.DrawPath(path, DlPaint()
.setColor(DlColor::kRed())
@ -1008,7 +1018,7 @@ TEST_P(AiksTest, DepthValuesForPolygonMode) {
// have the same depth values.
DisplayListBuilder builder;
DlPath path = DlPath::MakeCircle(DlPoint(100, 100), 100);
SkPath path = SkPath::Circle(100, 100, 100);
builder.DrawPath(path, DlPaint()
.setColor(DlColor::kRed())

View File

@ -11,6 +11,7 @@
#include "impeller/entity/texture_fill.vert.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/point.h"
#include "third_party/skia/include/core/SkPoint.h"
namespace impeller {

View File

@ -21,7 +21,7 @@ using impeller::Font;
namespace {
struct TextRenderOptions {
bool stroke = false;
DlScalar font_size = 50;
SkScalar font_size = 50;
DlColor color = DlColor::kYellow();
std::shared_ptr<DlMaskFilter> mask_filter;
};
@ -29,7 +29,7 @@ struct TextRenderOptions {
bool RenderTextInCanvasSkia(DlCanvas* canvas,
const std::string& text,
const std::string_view& font_fixture,
DlPoint position,
SkPoint position,
const TextRenderOptions& options = {}) {
auto c_font_fixture = std::string(font_fixture);
auto mapping = flutter::testing::OpenFixtureAsSkData(c_font_fixture.c_str());
@ -52,7 +52,7 @@ bool RenderTextInCanvasSkia(DlCanvas* canvas,
// text_paint.stroke_width = 1;
// text_paint.style =
// options.stroke ? Paint::Style::kStroke : Paint::Style::kFill;
canvas->DrawTextFrame(frame, position.x, position.y, text_paint);
canvas->DrawTextFrame(frame, position.x(), position.y(), text_paint);
return true;
}
@ -70,13 +70,13 @@ TEST_P(DlGoldenTest, TextBlurMaskFilterRespectCTM) {
DlBlurMaskFilter::Make(DlBlurStyle::kNormal, /*sigma=*/10,
/*respect_ctm=*/true);
ASSERT_TRUE(RenderTextInCanvasSkia(canvas, "hello world",
"Roboto-Regular.ttf", //
DlPoint(101, 101), options));
"Roboto-Regular.ttf",
SkPoint::Make(101, 101), options));
options.mask_filter = nullptr;
options.color = DlColor::kRed();
ASSERT_TRUE(RenderTextInCanvasSkia(canvas, "hello world",
"Roboto-Regular.ttf", //
DlPoint(100, 100), options));
"Roboto-Regular.ttf",
SkPoint::Make(100, 100), options));
};
DisplayListBuilder builder;
@ -97,13 +97,13 @@ TEST_P(DlGoldenTest, TextBlurMaskFilterDisrespectCTM) {
DlBlurMaskFilter::Make(DlBlurStyle::kNormal, /*sigma=*/10,
/*respect_ctm=*/false);
ASSERT_TRUE(RenderTextInCanvasSkia(canvas, "hello world",
"Roboto-Regular.ttf", //
DlPoint(101, 101), options));
"Roboto-Regular.ttf",
SkPoint::Make(101, 101), options));
options.mask_filter = nullptr;
options.color = DlColor::kRed();
ASSERT_TRUE(RenderTextInCanvasSkia(canvas, "hello world",
"Roboto-Regular.ttf", //
DlPoint(100, 100), options));
"Roboto-Regular.ttf",
SkPoint::Make(100, 100), options));
};
DisplayListBuilder builder;
@ -161,13 +161,13 @@ TEST_P(DlGoldenTest, ShimmerTest) {
canvas->Scale(content_scale.x, content_scale.y);
DlPaint paint;
canvas->DrawImage(images[0], DlPoint(10.135, 10.36334),
canvas->DrawImage(images[0], SkPoint::Make(10.135, 10.36334),
DlImageSampling::kLinear, &paint);
DlRect save_layer_bounds = DlRect::MakeLTRB(0, 0, 1024, 768);
SkRect save_layer_bounds = SkRect::MakeLTRB(0, 0, 1024, 768);
auto blur = DlImageFilter::MakeBlur(sigma, sigma, DlTileMode::kDecal);
canvas->ClipRect(DlRect::MakeLTRB(11.125, 10.3737, 911.25, 755.3333));
canvas->SaveLayer(save_layer_bounds, /*paint=*/nullptr, blur.get());
canvas->ClipRect(SkRect::MakeLTRB(11.125, 10.3737, 911.25, 755.3333));
canvas->SaveLayer(&save_layer_bounds, /*paint=*/nullptr, blur.get());
canvas->Restore();
};

View File

@ -41,7 +41,7 @@ TEST_P(DlGoldenTest, CanRenderImage) {
FML_CHECK(images.size() >= 1);
DlPaint paint;
paint.setColor(DlColor::kRed());
canvas->DrawImage(images[0], DlPoint(100.0, 100.0),
canvas->DrawImage(images[0], SkPoint::Make(100.0, 100.0),
DlImageSampling::kLinear, &paint);
};
@ -62,29 +62,29 @@ TEST_P(DlGoldenTest, Bug147807) {
canvas->Scale(content_scale.x, content_scale.y);
DlPaint paint;
paint.setColor(DlColor(0xfffef7ff));
canvas->DrawRect(DlRect::MakeLTRB(0, 0, 375, 667), paint);
canvas->DrawRect(SkRect::MakeLTRB(0, 0, 375, 667), paint);
paint.setColor(DlColor(0xffff9800));
canvas->DrawRect(DlRect::MakeLTRB(0, 0, 187.5, 333.5), paint);
canvas->DrawRect(SkRect::MakeLTRB(0, 0, 187.5, 333.5), paint);
paint.setColor(DlColor(0xff9c27b0));
canvas->DrawRect(DlRect::MakeLTRB(187.5, 0, 375, 333.5), paint);
canvas->DrawRect(SkRect::MakeLTRB(187.5, 0, 375, 333.5), paint);
paint.setColor(DlColor(0xff4caf50));
canvas->DrawRect(DlRect::MakeLTRB(0, 333.5, 187.5, 667), paint);
canvas->DrawRect(SkRect::MakeLTRB(0, 333.5, 187.5, 667), paint);
paint.setColor(DlColor(0xfff44336));
canvas->DrawRect(DlRect::MakeLTRB(187.5, 333.5, 375, 667), paint);
canvas->DrawRect(SkRect::MakeLTRB(187.5, 333.5, 375, 667), paint);
canvas->Save();
{
canvas->ClipRoundRect(
DlRoundRect::MakeOval(DlRect::MakeLTRB(201.25, 10, 361.25, 170)),
canvas->ClipRRect(
SkRRect::MakeOval(SkRect::MakeLTRB(201.25, 10, 361.25, 170)),
DlCanvas::ClipOp::kIntersect, true);
DlRect save_layer_bounds = DlRect::MakeLTRB(201.25, 10, 361.25, 170);
SkRect save_layer_bounds = SkRect::MakeLTRB(201.25, 10, 361.25, 170);
auto backdrop =
DlImageFilter::MakeMatrix(DlMatrix::MakeRow(3, 0, 0.0, -280, //
0, 3, 0.0, -920, //
0, 0, 1.0, 0.0, //
0, 0, 0.0, 1.0),
DlImageSampling::kLinear);
canvas->SaveLayer(save_layer_bounds, /*paint=*/nullptr, backdrop.get());
canvas->SaveLayer(&save_layer_bounds, /*paint=*/nullptr, backdrop.get());
{
canvas->Translate(201.25, 10);
auto paint = DlPaint()
@ -92,7 +92,7 @@ TEST_P(DlGoldenTest, Bug147807) {
.setColor(DlColor(0xff2196f3))
.setStrokeWidth(5)
.setDrawStyle(DlDrawStyle::kStroke);
canvas->DrawCircle(DlPoint(80, 80), 80, paint);
canvas->DrawCircle(SkPoint::Make(80, 80), 80, paint);
}
canvas->Restore();
}
@ -119,16 +119,14 @@ void DrawBlurGrid(DlCanvas* canvas) {
auto blur_filter = std::make_shared<flutter::DlBlurMaskFilter>(
flutter::DlBlurStyle::kNormal, blur_radius);
paint.setMaskFilter(blur_filter);
SkRRect rrect;
Scalar yval = gap + i * (gap + height);
canvas->DrawRoundRect(
DlRoundRect::MakeNinePatch(DlRect::MakeXYWH(gap, yval, width, height),
10, 10, 10, 10),
paint);
canvas->DrawRoundRect(
DlRoundRect::MakeNinePatch(
DlRect::MakeXYWH(2.0 * gap + width, yval, width, height), //
9, 10, 10, 10),
paint);
rrect.setNinePatch(SkRect::MakeXYWH(gap, yval, width, height), 10, 10, 10,
10);
canvas->DrawRRect(rrect, paint);
rrect.setNinePatch(SkRect::MakeXYWH(2.0 * gap + width, yval, width, height),
9, 10, 10, 10);
canvas->DrawRRect(rrect, paint);
}
}
} // namespace
@ -199,64 +197,51 @@ TEST_P(DlGoldenTest, FastVsGeneralGaussianMaskBlur) {
DlColor::kMaroon(),
};
auto make_rrect_path = [](const DlRect& rect, DlScalar rx,
DlScalar ry) -> DlPath {
auto add_corner = [](DlPathBuilder& path_builder, DlPoint corner,
DlVector2 relative_from, DlVector2 relative_to,
bool first) {
auto make_rrect_path = [](const SkRect& rect, DlScalar rx,
DlScalar ry) -> SkPath {
auto add_corner = [](SkPath& path, SkPoint rCorner, SkPoint rEnd) {
static const auto magic = impeller::PathBuilder::kArcApproximationMagic;
if (first) {
path_builder.MoveTo(corner + relative_from);
} else {
path_builder.LineTo(corner + relative_from);
}
// These fractions should be (1 - magic) to make a proper rrect
// path, but historically these equations were as written here.
// On the plus side, they ensure that we will not optimize this
// path as "Hey, look, it's an RRect", but the DrawPath gaussians
// will otherwise not be identical to the versions drawn with
// DrawRoundRect
path_builder.CubicCurveTo(corner + relative_from * magic,
corner + relative_to * magic,
corner + relative_to);
path.rCubicTo(rCorner.fX * (1.0f - magic), rCorner.fY * (1.0f - magic),
rCorner.fX + rEnd.fX * magic, rCorner.fY + rEnd.fY * magic,
rCorner.fX + rEnd.fX, rCorner.fY + rEnd.fY);
};
DlPathBuilder path_builder;
add_corner(path_builder, rect.GetRightTop(), //
DlVector2(-rx, 0.0f), DlVector2(0.0f, ry), true);
add_corner(path_builder, rect.GetRightBottom(), //
DlVector2(0.0f, -ry), DlVector2(-rx, 0.0f), false);
add_corner(path_builder, rect.GetLeftBottom(), //
DlVector2(rx, 0.0f), DlVector2(0.0f, -ry), false);
add_corner(path_builder, rect.GetLeftTop(), //
DlVector2(0.0f, ry), DlVector2(rx, 0.0f), false);
return DlPath(path_builder);
SkPath path;
path.moveTo(rect.fRight - rx, rect.fTop);
add_corner(path, {rx, 0.0f}, {0.0f, ry});
path.lineTo(rect.fRight, rect.fBottom - ry);
add_corner(path, {0.0f, ry}, {-rx, 0.0f});
path.lineTo(rect.fLeft + rx, rect.fBottom);
add_corner(path, {-rx, 0.0f}, {0.0f, -ry});
path.lineTo(rect.fLeft, rect.fTop + ry);
add_corner(path, {0.0f, -ry}, {rx, 0.0f});
path.close();
return path;
};
for (size_t i = 0; i < blur_sigmas.size(); i++) {
auto rect = DlRect::MakeXYWH(i * 320.0f + 50.0f, 50.0f, 100.0f, 100.0f);
auto rect = SkRect::MakeXYWH(i * 320.0f + 50.0f, 50.0f, 100.0f, 100.0f);
DlPaint paint = DlPaint() //
.setColor(blur_colors[i])
.setMaskFilter(DlBlurMaskFilter::Make(
DlBlurStyle::kNormal, blur_sigmas[i]));
builder.DrawRoundRect(DlRoundRect::MakeRectXY(rect, 10.0f, 10.0f), paint);
rect = rect.Shift(150.0f, 0.0f);
builder.DrawRRect(SkRRect::MakeRectXY(rect, 10.0f, 10.0f), paint);
rect = rect.makeOffset(150.0f, 0.0f);
builder.DrawPath(make_rrect_path(rect, 10.0f, 10.0f), paint);
rect = rect.Shift(-150.0f, 0.0f);
rect = rect.makeOffset(-150.0f, 0.0f);
rect = rect.Shift(0.0f, 200.0f);
builder.DrawRoundRect(DlRoundRect::MakeRectXY(rect, 10.0f, 30.0f), paint);
rect = rect.Shift(150.0f, 0.0f);
rect = rect.makeOffset(0.0f, 200.0f);
builder.DrawRRect(SkRRect::MakeRectXY(rect, 10.0f, 30.0f), paint);
rect = rect.makeOffset(150.0f, 0.0f);
builder.DrawPath(make_rrect_path(rect, 10.0f, 20.0f), paint);
rect = rect.Shift(-150.0f, 0.0f);
rect = rect.makeOffset(-150.0f, 0.0f);
rect = rect.Shift(0.0f, 200.0f);
builder.DrawRoundRect(DlRoundRect::MakeRectXY(rect, 30.0f, 10.0f), paint);
rect = rect.Shift(150.0f, 0.0f);
rect = rect.makeOffset(0.0f, 200.0f);
builder.DrawRRect(SkRRect::MakeRectXY(rect, 30.0f, 10.0f), paint);
rect = rect.makeOffset(150.0f, 0.0f);
builder.DrawPath(make_rrect_path(rect, 20.0f, 10.0f), paint);
rect = rect.Shift(-150.0f, 0.0f);
rect = rect.makeOffset(-150.0f, 0.0f);
}
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -304,12 +289,12 @@ TEST_P(DlGoldenTest, DashedLinesTest) {
// Make sure the rendering op responds appropriately to clipping
canvas->Save();
DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(275.0f, 225.0f));
path_builder.LineTo(DlPoint(325.0f, 275.0f));
path_builder.LineTo(DlPoint(275.0f, 325.0f));
path_builder.LineTo(DlPoint(225.0f, 275.0f));
canvas->ClipPath(DlPath(path_builder));
SkPath clip_path = SkPath();
clip_path.moveTo(275.0f, 225.0f);
clip_path.lineTo(325.0f, 275.0f);
clip_path.lineTo(275.0f, 325.0f);
clip_path.lineTo(225.0f, 275.0f);
canvas->ClipPath(clip_path);
canvas->DrawColor(DlColor::kYellow());
draw_one(DlStrokeCap::kRound, 275.0f, 275.0f, 15.0f, 10.0f);
canvas->Restore();

View File

@ -30,6 +30,10 @@
#include "impeller/geometry/scalar.h"
#include "impeller/playground/widgets.h"
#include "third_party/imgui/imgui.h"
#include "third_party/skia/include/core/SkBlurTypes.h"
#include "third_party/skia/include/core/SkClipOp.h"
#include "third_party/skia/include/core/SkPathBuilder.h"
#include "third_party/skia/include/core/SkRRect.h"
namespace impeller {
namespace testing {
@ -44,7 +48,7 @@ INSTANTIATE_PLAYGROUND_SUITE(DisplayListTest);
TEST_P(DisplayListTest, CanDrawRect) {
flutter::DisplayListBuilder builder;
builder.DrawRect(DlRect::MakeXYWH(10, 10, 100, 100),
builder.DrawRect(SkRect::MakeXYWH(10, 10, 100, 100),
flutter::DlPaint(flutter::DlColor::kBlue()));
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -94,7 +98,7 @@ TEST_P(DisplayListTest, CanDrawTextWithSaveLayer) {
TEST_P(DisplayListTest, CanDrawImage) {
auto texture = CreateTextureForFixture("embarcadero.jpg");
flutter::DisplayListBuilder builder;
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor, nullptr);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -107,11 +111,8 @@ TEST_P(DisplayListTest, CanDrawCapsAndJoins) {
paint.setStrokeWidth(30);
paint.setColor(flutter::DlColor::kRed());
flutter::DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(-50, 0));
path_builder.LineTo(DlPoint(0, -50));
path_builder.LineTo(DlPoint(50, 0));
flutter::DlPath path(path_builder);
auto path =
SkPathBuilder{}.moveTo(-50, 0).lineTo(0, -50).lineTo(50, 0).snapshot();
builder.Translate(100, 100);
{
@ -196,7 +197,7 @@ TEST_P(DisplayListTest, CanDrawArc) {
paint.setStrokeCap(cap);
paint.setStrokeJoin(flutter::DlStrokeJoin::kMiter);
paint.setStrokeMiter(10);
auto rect = DlRect::MakeLTRB(p1.x, p1.y, p2.x, p2.y);
auto rect = SkRect::MakeLTRB(p1.x, p1.y, p2.x, p2.y);
paint.setColor(flutter::DlColor::kGreen());
paint.setStrokeWidth(2);
builder.DrawRect(rect, paint);
@ -270,30 +271,29 @@ TEST_P(DisplayListTest, StrokedPathsDrawCorrectly) {
// Rectangle
builder.Translate(100, 100);
builder.DrawRect(DlRect::MakeWH(100, 100), paint);
builder.DrawRect(SkRect::MakeSize({100, 100}), paint);
// Rounded rectangle
builder.Translate(150, 0);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeWH(100, 50), 10, 10), paint);
builder.DrawRRect(SkRRect::MakeRectXY(SkRect::MakeSize({100, 50}), 10, 10),
paint);
// Double rounded rectangle
builder.Translate(150, 0);
builder.DrawDiffRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeWH(100, 50), 10, 10),
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(10, 10, 80, 30), 10, 10),
paint);
builder.DrawDRRect(
SkRRect::MakeRectXY(SkRect::MakeSize({100, 50}), 10, 10),
SkRRect::MakeRectXY(SkRect::MakeXYWH(10, 10, 80, 30), 10, 10), paint);
// Contour with duplicate join points
{
builder.Translate(150, 0);
flutter::DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(0, 0));
path_builder.LineTo(DlPoint(0, 0));
path_builder.LineTo(DlPoint(100, 0));
path_builder.LineTo(DlPoint(100, 0));
path_builder.LineTo(DlPoint(100, 100));
builder.DrawPath(DlPath(path_builder), paint);
SkPath path;
path.moveTo(0, 0);
path.lineTo(0, 0);
path.lineTo({100, 0});
path.lineTo({100, 0});
path.lineTo({100, 100});
builder.DrawPath(path, paint);
}
// Contour with duplicate start and end points
@ -303,27 +303,26 @@ TEST_P(DisplayListTest, StrokedPathsDrawCorrectly) {
{
builder.Save();
flutter::DlPathBuilder line_path_builder;
line_path_builder.MoveTo(DlPoint(0, 0));
line_path_builder.MoveTo(DlPoint(0, 0));
line_path_builder.LineTo(DlPoint(0, 0));
line_path_builder.LineTo(DlPoint(0, 0));
line_path_builder.LineTo(DlPoint(50, 50));
line_path_builder.LineTo(DlPoint(50, 50));
line_path_builder.LineTo(DlPoint(100, 0));
line_path_builder.LineTo(DlPoint(100, 0));
DlPath line_path(line_path_builder);
SkPath line_path;
line_path.moveTo(0, 0);
line_path.moveTo(0, 0);
line_path.lineTo({0, 0});
line_path.lineTo({0, 0});
line_path.lineTo({50, 50});
line_path.lineTo({50, 50});
line_path.lineTo({100, 0});
line_path.lineTo({100, 0});
builder.DrawPath(line_path, paint);
builder.Translate(0, 100);
builder.DrawPath(line_path, paint);
builder.Translate(0, 100);
flutter::DlPathBuilder line_path_builder2;
line_path_builder2.MoveTo(DlPoint(0, 0));
line_path_builder2.LineTo(DlPoint(0, 0));
line_path_builder2.LineTo(DlPoint(0, 0));
builder.DrawPath(DlPath(line_path_builder2), paint);
SkPath line_path2;
line_path2.moveTo(0, 0);
line_path2.lineTo(0, 0);
line_path2.lineTo(0, 0);
builder.DrawPath(line_path2, paint);
builder.Restore();
}
@ -333,28 +332,22 @@ TEST_P(DisplayListTest, StrokedPathsDrawCorrectly) {
{
builder.Save();
flutter::DlPathBuilder cubic_path;
cubic_path.MoveTo(DlPoint(0, 0));
cubic_path.CubicCurveTo(DlPoint(0, 0), //
DlPoint(140.0, 100.0), //
DlPoint(140, 20));
builder.DrawPath(DlPath(cubic_path), paint);
SkPath cubic_path;
cubic_path.moveTo({0, 0});
cubic_path.cubicTo(0, 0, 140.0, 100.0, 140, 20);
builder.DrawPath(cubic_path, paint);
builder.Translate(0, 100);
flutter::DlPathBuilder cubic_path2;
cubic_path2.MoveTo(DlPoint(0, 0));
cubic_path2.CubicCurveTo(DlPoint(0, 0), //
DlPoint(0, 0), //
DlPoint(150, 150));
builder.DrawPath(DlPath(cubic_path2), paint);
SkPath cubic_path2;
cubic_path2.moveTo({0, 0});
cubic_path2.cubicTo(0, 0, 0, 0, 150, 150);
builder.DrawPath(cubic_path2, paint);
builder.Translate(0, 100);
flutter::DlPathBuilder cubic_path3;
cubic_path3.MoveTo(DlPoint(0, 0));
cubic_path3.CubicCurveTo(DlPoint(0, 0), //
DlPoint(0, 0), //
DlPoint(0, 0));
builder.DrawPath(DlPath(cubic_path3), paint);
SkPath cubic_path3;
cubic_path3.moveTo({0, 0});
cubic_path3.cubicTo(0, 0, 0, 0, 0, 0);
builder.DrawPath(cubic_path3, paint);
builder.Restore();
}
@ -364,24 +357,24 @@ TEST_P(DisplayListTest, StrokedPathsDrawCorrectly) {
{
builder.Save();
flutter::DlPathBuilder quad_path;
quad_path.MoveTo(DlPoint(0, 0));
quad_path.MoveTo(DlPoint(0, 0));
quad_path.QuadraticCurveTo(DlPoint(100, 40), DlPoint(50, 80));
builder.DrawPath(DlPath(quad_path), paint);
SkPath quad_path;
quad_path.moveTo(0, 0);
quad_path.moveTo(0, 0);
quad_path.quadTo({100, 40}, {50, 80});
builder.DrawPath(quad_path, paint);
builder.Translate(0, 150);
flutter::DlPathBuilder quad_path2;
quad_path2.MoveTo(DlPoint(0, 0));
quad_path2.MoveTo(DlPoint(0, 0));
quad_path2.QuadraticCurveTo(DlPoint(0, 0), DlPoint(100, 100));
builder.DrawPath(DlPath(quad_path2), paint);
SkPath quad_path2;
quad_path2.moveTo(0, 0);
quad_path2.moveTo(0, 0);
quad_path2.quadTo({0, 0}, {100, 100});
builder.DrawPath(quad_path2, paint);
builder.Translate(0, 100);
flutter::DlPathBuilder quad_path3;
quad_path3.MoveTo(DlPoint(0, 0));
quad_path3.QuadraticCurveTo(DlPoint(0, 0), DlPoint(0, 0));
builder.DrawPath(DlPath(quad_path3), paint);
SkPath quad_path3;
quad_path3.moveTo(0, 0);
quad_path3.quadTo({0, 0}, {0, 0});
builder.DrawPath(quad_path3, paint);
builder.Restore();
}
@ -398,10 +391,11 @@ TEST_P(DisplayListTest, CanDrawWithOddPathWinding) {
paint.setDrawStyle(flutter::DlDrawStyle::kFill);
builder.Translate(300, 300);
flutter::DlPathBuilder path_builder;
path_builder.AddCircle(DlPoint(0, 0), 100);
path_builder.AddCircle(DlPoint(0, 0), 50);
builder.DrawPath(DlPath(path_builder, flutter::DlPathFillType::kOdd), paint);
SkPath path;
path.setFillType(SkPathFillType::kEvenOdd);
path.addCircle(0, 0, 100);
path.addCircle(0, 0, 50);
builder.DrawPath(path, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -423,12 +417,12 @@ TEST_P(DisplayListTest, CanDrawAnOpenPath) {
// 1. (50, height)
// 2. (width, height)
// 3. (width, 50)
flutter::DlPathBuilder path_builder;
path_builder.MoveTo(DlPoint(50, 50));
path_builder.LineTo(DlPoint(50, 100));
path_builder.LineTo(DlPoint(100, 100));
path_builder.LineTo(DlPoint(100, 50));
builder.DrawPath(DlPath(path_builder), paint);
SkPath path;
path.moveTo(50, 50);
path.lineTo(50, 100);
path.lineTo(100, 100);
path.lineTo(100, 50);
builder.DrawPath(path, paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -443,7 +437,7 @@ TEST_P(DisplayListTest, CanDrawWithMaskBlur) {
auto filter =
flutter::DlBlurMaskFilter(flutter::DlBlurStyle::kNormal, 10.0f);
paint.setMaskFilter(&filter);
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor, &paint);
}
@ -453,7 +447,7 @@ TEST_P(DisplayListTest, CanDrawWithMaskBlur) {
auto filter =
flutter::DlBlurMaskFilter(flutter::DlBlurStyle::kOuter, 10.0f);
paint.setMaskFilter(&filter);
builder.DrawArc(DlRect::MakeXYWH(410, 110, 100, 100), 45, 270, true, paint);
builder.DrawArc(SkRect::MakeXYWH(410, 110, 100, 100), 45, 270, true, paint);
}
// Mask blurred text.
@ -494,7 +488,7 @@ TEST_P(DisplayListTest, StrokedTextNotOffsetFromNormalText) {
// Draw a blue filled rectangle so the text is easier to see.
paint.setDrawStyle(flutter::DlDrawStyle::kFill);
paint.setColor(mat_blue);
builder.DrawRect(DlRect::MakeXYWH(0, 0, 500, 500), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 500, 500), paint);
// Draw stacked text, with stroked text on top.
paint.setDrawStyle(flutter::DlDrawStyle::kFill);
@ -515,7 +509,7 @@ TEST_P(DisplayListTest, IgnoreMaskFilterWhenSavingLayer) {
flutter::DlPaint paint;
paint.setMaskFilter(&filter);
builder.SaveLayer(nullptr, &paint);
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor);
builder.Restore();
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -531,7 +525,7 @@ TEST_P(DisplayListTest, CanDrawWithBlendColorFilter) {
auto filter = flutter::DlColorFilter::MakeBlend(
flutter::DlColor::kYellow(), flutter::DlBlendMode::kModulate);
paint.setColorFilter(filter);
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor, &paint);
}
@ -540,7 +534,7 @@ TEST_P(DisplayListTest, CanDrawWithBlendColorFilter) {
auto filter = flutter::DlColorFilter::MakeBlend(
flutter::DlColor::kRed(), flutter::DlBlendMode::kScreen);
paint.setColorFilter(filter);
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(250, 250),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(250, 250),
flutter::DlImageSampling::kNearestNeighbor, &paint);
}
@ -562,12 +556,12 @@ TEST_P(DisplayListTest, CanDrawWithColorFilterImageFilter) {
auto image_filter = flutter::DlImageFilter::MakeColorFilter(color_filter);
paint.setImageFilter(image_filter);
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor, &paint);
builder.Translate(0, 700);
paint.setColorFilter(color_filter);
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor, &paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -588,7 +582,7 @@ TEST_P(DisplayListTest, CanDrawWithImageBlurFilter) {
auto filter = flutter::DlBlurImageFilter(sigma[0], sigma[1],
flutter::DlTileMode::kClamp);
paint.setImageFilter(&filter);
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(200, 200),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(200, 200),
flutter::DlImageSampling::kNearestNeighbor, &paint);
return builder.Build();
@ -608,11 +602,11 @@ TEST_P(DisplayListTest, CanDrawWithComposeImageFilter) {
auto close = std::make_shared<flutter::DlComposeImageFilter>(erode, dilate);
paint.setImageFilter(open.get());
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor, &paint);
builder.Translate(0, 700);
paint.setImageFilter(close.get());
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor, &paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -642,7 +636,7 @@ TEST_P(DisplayListTest, CanClampTheResultingColorOfColorMatrixFilter) {
flutter::DisplayListBuilder builder;
flutter::DlPaint paint;
paint.setImageFilter(compose.get());
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(100, 100),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
flutter::DlImageSampling::kNearestNeighbor, &paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -677,24 +671,25 @@ TEST_P(DisplayListTest, CanDrawBackdropFilter) {
auto filter = flutter::DlBlurImageFilter(sigma[0], sigma[1],
flutter::DlTileMode::kClamp);
std::optional<DlRect> bounds;
std::optional<SkRect> bounds;
if (use_bounds) {
static PlaygroundPoint point_a(Point(350, 150), 20, Color::White());
static PlaygroundPoint point_b(Point(800, 600), 20, Color::White());
auto [p1, p2] = DrawPlaygroundLine(point_a, point_b);
bounds = DlRect::MakeLTRB(p1.x, p1.y, p2.x, p2.y);
bounds = SkRect::MakeLTRB(p1.x, p1.y, p2.x, p2.y);
}
// Insert a clip to test that the backdrop filter handles stencil depths > 0
// correctly.
if (add_clip) {
builder.ClipRect(DlRect::MakeLTRB(0, 0, 99999, 99999),
builder.ClipRect(SkRect::MakeLTRB(0, 0, 99999, 99999),
flutter::DlCanvas::ClipOp::kIntersect, true);
}
builder.DrawImage(DlImageImpeller::Make(texture), DlPoint(200, 200),
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(200, 200),
flutter::DlImageSampling::kNearestNeighbor, nullptr);
builder.SaveLayer(bounds, nullptr, &filter);
builder.SaveLayer(bounds.has_value() ? &bounds.value() : nullptr, nullptr,
&filter);
if (draw_circle) {
static PlaygroundPoint center_point(Point(500, 400), 20, Color::Red());
@ -706,7 +701,7 @@ TEST_P(DisplayListTest, CanDrawBackdropFilter) {
paint.setStrokeJoin(flutter::DlStrokeJoin::kBevel);
paint.setStrokeWidth(10);
paint.setColor(flutter::DlColor::kRed().withAlpha(100));
builder.DrawCircle(DlPoint(circle_center.x, circle_center.y), 100, paint);
builder.DrawCircle(SkPoint{circle_center.x, circle_center.y}, 100, paint);
}
return builder.Build();
@ -722,9 +717,9 @@ TEST_P(DisplayListTest, CanDrawNinePatchImage) {
auto size = texture->GetSize();
builder.DrawImageNine(
DlImageImpeller::Make(texture),
DlIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
SkIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
size.height * 3 / 4),
DlRect::MakeLTRB(0, 0, size.width * 2, size.height * 2),
SkRect::MakeLTRB(0, 0, size.width * 2, size.height * 2),
flutter::DlFilterMode::kNearest, nullptr);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -738,9 +733,9 @@ TEST_P(DisplayListTest, CanDrawNinePatchImageCenterWidthBiggerThanDest) {
auto size = texture->GetSize();
builder.DrawImageNine(
DlImageImpeller::Make(texture),
DlIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
SkIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
size.height * 3 / 4),
DlRect::MakeLTRB(0, 0, size.width / 2, size.height),
SkRect::MakeLTRB(0, 0, size.width / 2, size.height),
flutter::DlFilterMode::kNearest, nullptr);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -754,9 +749,9 @@ TEST_P(DisplayListTest, CanDrawNinePatchImageCenterHeightBiggerThanDest) {
auto size = texture->GetSize();
builder.DrawImageNine(
DlImageImpeller::Make(texture),
DlIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
SkIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
size.height * 3 / 4),
DlRect::MakeLTRB(0, 0, size.width, size.height / 2),
SkRect::MakeLTRB(0, 0, size.width, size.height / 2),
flutter::DlFilterMode::kNearest, nullptr);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -769,9 +764,9 @@ TEST_P(DisplayListTest, CanDrawNinePatchImageCenterBiggerThanDest) {
auto size = texture->GetSize();
builder.DrawImageNine(
DlImageImpeller::Make(texture),
DlIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
SkIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
size.height * 3 / 4),
DlRect::MakeLTRB(0, 0, size.width / 2, size.height / 2),
SkRect::MakeLTRB(0, 0, size.width / 2, size.height / 2),
flutter::DlFilterMode::kNearest, nullptr);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -784,9 +779,9 @@ TEST_P(DisplayListTest, CanDrawNinePatchImageCornersScaledDown) {
auto size = texture->GetSize();
builder.DrawImageNine(
DlImageImpeller::Make(texture),
DlIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
SkIRect::MakeLTRB(size.width / 4, size.height / 4, size.width * 3 / 4,
size.height * 3 / 4),
DlRect::MakeLTRB(0, 0, size.width / 4, size.height / 4),
SkRect::MakeLTRB(0, 0, size.width / 4, size.height / 4),
flutter::DlFilterMode::kNearest, nullptr);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -797,15 +792,15 @@ TEST_P(DisplayListTest, NinePatchImagePrecision) {
auto texture = CreateTextureForFixture("nine_patch_corners.png");
flutter::DisplayListBuilder builder;
builder.DrawImageNine(DlImageImpeller::Make(texture),
DlIRect::MakeXYWH(10, 10, 1, 1),
DlRect::MakeXYWH(0, 0, 200, 100),
SkIRect::MakeXYWH(10, 10, 1, 1),
SkRect::MakeXYWH(0, 0, 200, 100),
flutter::DlFilterMode::kNearest, nullptr);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(DisplayListTest, CanDrawPoints) {
flutter::DisplayListBuilder builder;
DlPoint points[7] = {
SkPoint points[7] = {
{0, 0}, //
{100, 100}, //
{100, 0}, //
@ -852,10 +847,10 @@ TEST_P(DisplayListTest, CanDrawZeroLengthLine) {
.setDrawStyle(flutter::DlDrawStyle::kStroke) //
.setStrokeCap(flutter::DlStrokeCap::kButt) //
.setStrokeWidth(20);
DlPath path = DlPath::MakeLine({150, 50}, {150, 50});
SkPath path = SkPath().addPoly({{150, 50}, {150, 50}}, false);
for (auto cap : caps) {
paint.setStrokeCap(cap);
builder.DrawLine(DlPoint(50, 50), DlPoint(50, 50), paint);
builder.DrawLine(SkPoint{50, 50}, SkPoint{50, 50}, paint);
builder.DrawPath(path, paint);
builder.Translate(0, 150);
}
@ -870,26 +865,27 @@ TEST_P(DisplayListTest, CanDrawShadow) {
builder.Scale(content_scale.x, content_scale.y);
constexpr size_t star_spikes = 5;
constexpr DlScalar half_spike_rotation = kPi / star_spikes;
constexpr DlScalar radius = 40;
constexpr DlScalar spike_size = 10;
constexpr DlScalar outer_radius = radius + spike_size;
constexpr DlScalar inner_radius = radius - spike_size;
std::array<DlPoint, star_spikes * 2> star;
constexpr SkScalar half_spike_rotation = kPi / star_spikes;
constexpr SkScalar radius = 40;
constexpr SkScalar spike_size = 10;
constexpr SkScalar outer_radius = radius + spike_size;
constexpr SkScalar inner_radius = radius - spike_size;
std::array<SkPoint, star_spikes * 2> star;
for (size_t i = 0; i < star_spikes; i++) {
const DlScalar rotation = half_spike_rotation * i * 2;
star[i * 2] = DlPoint(50 + std::sin(rotation) * outer_radius,
50 - std::cos(rotation) * outer_radius);
star[i * 2 + 1] =
DlPoint(50 + std::sin(rotation + half_spike_rotation) * inner_radius,
50 - std::cos(rotation + half_spike_rotation) * inner_radius);
const SkScalar rotation = half_spike_rotation * i * 2;
star[i * 2] = SkPoint::Make(50 + std::sin(rotation) * outer_radius,
50 - std::cos(rotation) * outer_radius);
star[i * 2 + 1] = SkPoint::Make(
50 + std::sin(rotation + half_spike_rotation) * inner_radius,
50 - std::cos(rotation + half_spike_rotation) * inner_radius);
}
std::array<DlPath, 4> paths = {
DlPath::MakeRect(DlRect::MakeXYWH(0, 0, 200, 100)),
DlPath::MakeRoundRectXY(DlRect::MakeXYWH(20, 0, 200, 100), 30, 30),
DlPath::MakeCircle(DlPoint(100, 50), 50),
DlPath::MakePoly(star.data(), star.size(), true),
std::array<SkPath, 4> paths = {
SkPath{}.addRect(SkRect::MakeXYWH(0, 0, 200, 100)),
SkPath{}.addRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(20, 0, 200, 100), 30, 30)),
SkPath{}.addCircle(100, 50, 50),
SkPath{}.addPoly(star.data(), star.size(), true),
};
paint.setColor(flutter::DlColor::kWhite());
builder.DrawPaint(paint);
@ -928,17 +924,17 @@ TEST_P(DisplayListTest, CanDrawZeroWidthLine) {
.setDrawStyle(flutter::DlDrawStyle::kStroke) //
.setStrokeCap(flutter::DlStrokeCap::kSquare) //
.setStrokeWidth(1);
DlPath path = DlPath::MakeLine({150, 50}, {160, 50});
SkPath path = SkPath().addPoly({{150, 50}, {160, 50}}, false);
for (auto cap : caps) {
paint.setStrokeCap(cap);
builder.DrawLine(DlPoint(50, 50), DlPoint(60, 50), paint);
builder.DrawRect(DlRect::MakeLTRB(45, 45, 65, 55), outline_paint);
builder.DrawLine(DlPoint{100, 50}, DlPoint{100, 50}, paint);
builder.DrawLine(SkPoint{50, 50}, SkPoint{60, 50}, paint);
builder.DrawRect(SkRect{45, 45, 65, 55}, outline_paint);
builder.DrawLine(SkPoint{100, 50}, SkPoint{100, 50}, paint);
if (cap != flutter::DlStrokeCap::kButt) {
builder.DrawRect(DlRect::MakeLTRB(95, 45, 105, 55), outline_paint);
builder.DrawRect(SkRect{95, 45, 105, 55}, outline_paint);
}
builder.DrawPath(path, paint);
builder.DrawRect(path.GetBounds().Expand(5, 5), outline_paint);
builder.DrawRect(path.getBounds().makeOutset(5, 5), outline_paint);
builder.Translate(0, 150);
}
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -1002,11 +998,10 @@ TEST_P(DisplayListTest, CanDrawWithMatrixFilter) {
builder.Scale(content_scale.x, content_scale.y);
// Set the current transform
auto ctm_matrix = Matrix::MakeRow(
ctm_scale[0], ctm_skew[0], 0.0f, ctm_translation[0], //
ctm_skew[1], ctm_scale[1], 0.0f, ctm_translation[1], //
0, 0, 1, 0, //
0, 0, 0, 1);
auto ctm_matrix =
SkMatrix::MakeAll(ctm_scale[0], ctm_skew[0], ctm_translation[0], //
ctm_skew[1], ctm_scale[1], ctm_translation[1], //
0, 0, 1);
builder.Transform(ctm_matrix);
// Set the matrix filter
@ -1036,7 +1031,7 @@ TEST_P(DisplayListTest, CanDrawWithMatrixFilter) {
}
}
builder.DrawImage(DlImageImpeller::Make(boston), DlPoint(),
builder.DrawImage(DlImageImpeller::Make(boston), SkPoint{},
flutter::DlImageSampling::kLinear, &paint);
}
if (enable_savelayer) {
@ -1064,22 +1059,22 @@ TEST_P(DisplayListTest, CanDrawWithMatrixFilterWhenSavingLayer) {
builder.Scale(2.0, 2.0);
flutter::DlPaint paint;
paint.setColor(flutter::DlColor::kYellow());
builder.DrawRect(DlRect::MakeWH(300, 300), paint);
builder.DrawRect(SkRect::MakeWH(300, 300), paint);
paint.setStrokeWidth(1.0);
paint.setDrawStyle(flutter::DlDrawStyle::kStroke);
paint.setColor(flutter::DlColor::kBlack().withAlpha(0x80));
builder.DrawLine(DlPoint(150, 0), DlPoint(150, 300), paint);
builder.DrawLine(DlPoint(0, 150), DlPoint(300, 150), paint);
builder.DrawLine(SkPoint::Make(150, 0), SkPoint::Make(150, 300), paint);
builder.DrawLine(SkPoint::Make(0, 150), SkPoint::Make(300, 150), paint);
flutter::DlPaint save_paint;
DlRect bounds = DlRect::MakeXYWH(100, 100, 100, 100);
SkRect bounds = SkRect::MakeXYWH(100, 100, 100, 100);
Matrix translate_matrix =
Matrix::MakeTranslation({translation[0], translation[1]});
if (enable_save_layer) {
auto filter = flutter::DlMatrixImageFilter(
translate_matrix, flutter::DlImageSampling::kNearestNeighbor);
save_paint.setImageFilter(filter.shared());
builder.SaveLayer(bounds, &save_paint);
builder.SaveLayer(&bounds, &save_paint);
} else {
builder.Save();
builder.Transform(translate_matrix);
@ -1094,7 +1089,7 @@ TEST_P(DisplayListTest, CanDrawWithMatrixFilterWhenSavingLayer) {
save_paint.setImageFilter(filter.shared());
builder.SaveLayer(bounds, &save_paint);
builder.SaveLayer(&bounds, &save_paint);
flutter::DlPaint paint2;
paint2.setColor(flutter::DlColor::kBlue());
builder.DrawRect(bounds, paint2);
@ -1111,11 +1106,11 @@ TEST_P(DisplayListTest, CanDrawRectWithLinearToSrgbColorFilter) {
paint.setColor(flutter::DlColor(0xFF2196F3).withAlpha(128));
flutter::DisplayListBuilder builder;
paint.setColorFilter(flutter::DlColorFilter::MakeLinearToSrgbGamma());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), paint);
builder.Translate(0, 200);
paint.setColorFilter(flutter::DlColorFilter::MakeSrgbToLinearGamma());
builder.DrawRect(DlRect::MakeXYWH(0, 0, 200, 200), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 200, 200), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -1128,7 +1123,7 @@ TEST_P(DisplayListTest, CanDrawPaintWithColorSource) {
const float stops[2] = {0.0, 1.0};
flutter::DlPaint paint;
flutter::DisplayListBuilder builder;
auto clip_bounds = DlRect::MakeWH(300.0, 300.0);
auto clip_bounds = SkRect::MakeWH(300.0, 300.0);
builder.Save();
builder.Translate(100, 100);
builder.ClipRect(clip_bounds, flutter::DlCanvas::ClipOp::kIntersect, false);
@ -1180,10 +1175,10 @@ TEST_P(DisplayListTest, CanBlendDstOverAndDstCorrectly) {
builder.Translate(100, 100);
flutter::DlPaint paint;
paint.setColor(flutter::DlColor::kRed());
builder.DrawRect(DlRect::MakeWH(200, 200), paint);
builder.DrawRect(SkRect::MakeSize({200, 200}), paint);
paint.setColor(flutter::DlColor::kBlue().withAlpha(127));
paint.setBlendMode(flutter::DlBlendMode::kSrcOver);
builder.DrawRect(DlRect::MakeWH(200, 200), paint);
builder.DrawRect(SkRect::MakeSize({200, 200}), paint);
builder.Restore();
}
{
@ -1191,10 +1186,10 @@ TEST_P(DisplayListTest, CanBlendDstOverAndDstCorrectly) {
builder.Translate(300, 100);
flutter::DlPaint paint;
paint.setColor(flutter::DlColor::kBlue().withAlpha(127));
builder.DrawRect(DlRect::MakeWH(200, 200), paint);
builder.DrawRect(SkRect::MakeSize({200, 200}), paint);
paint.setColor(flutter::DlColor::kRed());
paint.setBlendMode(flutter::DlBlendMode::kDstOver);
builder.DrawRect(DlRect::MakeWH(200, 200), paint);
builder.DrawRect(SkRect::MakeSize({200, 200}), paint);
builder.Restore();
}
{
@ -1202,10 +1197,10 @@ TEST_P(DisplayListTest, CanBlendDstOverAndDstCorrectly) {
builder.Translate(100, 300);
flutter::DlPaint paint;
paint.setColor(flutter::DlColor::kRed());
builder.DrawRect(DlRect::MakeWH(200, 200), paint);
builder.DrawRect(SkRect::MakeSize({200, 200}), paint);
paint.setColor(flutter::DlColor::kBlue().withAlpha(127));
paint.setBlendMode(flutter::DlBlendMode::kSrc);
builder.DrawRect(DlRect::MakeWH(200, 200), paint);
builder.DrawRect(SkRect::MakeSize({200, 200}), paint);
builder.Restore();
}
{
@ -1213,10 +1208,10 @@ TEST_P(DisplayListTest, CanBlendDstOverAndDstCorrectly) {
builder.Translate(300, 300);
flutter::DlPaint paint;
paint.setColor(flutter::DlColor::kBlue().withAlpha(127));
builder.DrawRect(DlRect::MakeWH(200, 200), paint);
builder.DrawRect(SkRect::MakeSize({200, 200}), paint);
paint.setColor(flutter::DlColor::kRed());
paint.setBlendMode(flutter::DlBlendMode::kDst);
builder.DrawRect(DlRect::MakeWH(200, 200), paint);
builder.DrawRect(SkRect::MakeSize({200, 200}), paint);
builder.Restore();
}
@ -1248,7 +1243,7 @@ TEST_P(DisplayListTest, CanDrawCorrectlyWithColorFilterAndImageFilter) {
paint.setColor(flutter::DlColor::kRed());
paint.setColorFilter(green_color_filter);
paint.setImageFilter(blue_image_filter);
builder.DrawRect(DlRect::MakeLTRB(100, 100, 500, 500), paint);
builder.DrawRect(SkRect::MakeLTRB(100, 100, 500, 500), paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
@ -1283,14 +1278,14 @@ TEST_P(DisplayListTest, MaskBlursApplyCorrectlyToColorSources) {
builder.Save();
builder.Translate(100, 0);
paint.setDrawStyle(flutter::DlDrawStyle::kFill);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeWH(100, 50), 30, 30), paint);
builder.DrawRRect(SkRRect::MakeRectXY(SkRect::MakeWH(100, 50), 30, 30),
paint);
paint.setDrawStyle(flutter::DlDrawStyle::kStroke);
paint.setStrokeWidth(10);
builder.Translate(200, 0);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeWH(100, 50), 30, 30), paint);
builder.DrawRRect(SkRRect::MakeRectXY(SkRect::MakeWH(100, 50), 30, 30),
paint);
builder.Restore();
builder.Translate(0, 100);
@ -1317,23 +1312,22 @@ TEST_P(DisplayListTest, DrawShapes) {
.setColor(flutter::DlColor::kWhite()) //
.setDrawStyle(flutter::DlDrawStyle::kStroke) //
.setStrokeWidth(10);
DlPath path = DlPath::MakeLine({150, 50}, {160, 50});
SkPath path = SkPath().addPoly({{150, 50}, {160, 50}}, false);
builder.Translate(300, 50);
builder.Scale(0.8, 0.8);
for (auto join : joins) {
paint.setStrokeJoin(join);
stroke_paint.setStrokeJoin(join);
builder.DrawRect(DlRect::MakeXYWH(0, 0, 100, 100), paint);
builder.DrawRect(DlRect::MakeXYWH(0, 150, 100, 100), stroke_paint);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(150, 0, 100, 100), 30, 30),
paint);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(150, 150, 100, 100), 30, 30),
builder.DrawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint);
builder.DrawRect(SkRect::MakeXYWH(0, 150, 100, 100), stroke_paint);
builder.DrawRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(150, 0, 100, 100), 30, 30), paint);
builder.DrawRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(150, 150, 100, 100), 30, 30),
stroke_paint);
builder.DrawCircle(DlPoint(350, 50), 50, paint);
builder.DrawCircle(DlPoint(350, 200), 50, stroke_paint);
builder.DrawCircle(SkPoint{350, 50}, 50, paint);
builder.DrawCircle(SkPoint{350, 200}, 50, stroke_paint);
builder.Translate(0, 300);
}
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
@ -1353,18 +1347,18 @@ TEST_P(DisplayListTest, ClipDrawRRectWithNonCircularRadii) {
.setDrawStyle(flutter::DlDrawStyle::kStroke) //
.setStrokeWidth(10);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(500, 100, 300, 300), 120, 40),
builder.DrawRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(500, 100, 300, 300), 120, 40),
fill_paint);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(500, 100, 300, 300), 120, 40),
builder.DrawRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(500, 100, 300, 300), 120, 40),
stroke_paint);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(100, 500, 300, 300), 40, 120),
builder.DrawRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(100, 500, 300, 300), 40, 120),
fill_paint);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(100, 500, 300, 300), 40, 120),
builder.DrawRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(100, 500, 300, 300), 40, 120),
stroke_paint);
flutter::DlPaint reference_paint = //
@ -1373,11 +1367,11 @@ TEST_P(DisplayListTest, ClipDrawRRectWithNonCircularRadii) {
.setDrawStyle(flutter::DlDrawStyle::kFill) //
.setStrokeWidth(10);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(500, 500, 300, 300), 40, 40),
builder.DrawRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(500, 500, 300, 300), 40, 40),
reference_paint);
builder.DrawRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(100, 100, 300, 300), 120, 120),
builder.DrawRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(100, 100, 300, 300), 120, 120),
reference_paint);
flutter::DlPaint clip_fill_paint = //
@ -1387,14 +1381,14 @@ TEST_P(DisplayListTest, ClipDrawRRectWithNonCircularRadii) {
.setStrokeWidth(10);
builder.Save();
builder.ClipRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(900, 100, 300, 300), 120, 40));
builder.ClipRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(900, 100, 300, 300), 120, 40));
builder.DrawPaint(clip_fill_paint);
builder.Restore();
builder.Save();
builder.ClipRoundRect(
DlRoundRect::MakeRectXY(DlRect::MakeXYWH(100, 900, 300, 300), 40, 120));
builder.ClipRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(100, 900, 300, 300), 40, 120));
builder.DrawPaint(clip_fill_paint);
builder.Restore();
@ -1497,7 +1491,7 @@ TEST_P(DisplayListTest, DrawPaintIgnoresMaskFilter) {
builder.DrawPaint(flutter::DlPaint().setColor(flutter::DlColor::kWhite()));
auto filter = flutter::DlBlurMaskFilter(flutter::DlBlurStyle::kNormal, 10.0f);
builder.DrawCircle(DlPoint(300, 300), 200,
builder.DrawCircle(SkPoint{300, 300}, 200,
flutter::DlPaint().setMaskFilter(&filter));
std::vector<flutter::DlColor> colors = {flutter::DlColor::kGreen(),
@ -1533,7 +1527,7 @@ TEST_P(DisplayListTest, DrawMaskBlursThatMightUseSaveLayers) {
.setAlpha(0x7f);
for (int x = 1; x <= 4; x++) {
for (int y = 1; y <= 4; y++) {
builder.DrawRect(DlRect::MakeXYWH(x * 100, y * 100, 80, 80),
builder.DrawRect(SkRect::MakeXYWH(x * 100, y * 100, 80, 80),
solid_alpha_paint);
}
}
@ -1553,7 +1547,7 @@ TEST_P(DisplayListTest, DrawMaskBlursThatMightUseSaveLayers) {
.setAlpha(0x7f);
for (int x = 1; x <= 4; x++) {
for (int y = 1; y <= 4; y++) {
builder.DrawRect(DlRect::MakeXYWH(x * 100, y * 100, 80, 80),
builder.DrawRect(SkRect::MakeXYWH(x * 100, y * 100, 80, 80),
normal_if_paint);
}
}

View File

@ -8,6 +8,7 @@
#include "impeller/core/formats.h"
#include "impeller/display_list/skia_conversions.h"
#include "impeller/geometry/point.h"
#include "third_party/skia/include/core/SkPoint.h"
namespace impeller {

View File

@ -38,15 +38,6 @@ struct RoundRect {
return MakeRectRadii(rect, RoundingRadii::MakeRadii(corner_radii));
}
constexpr static RoundRect MakeNinePatch(const Rect& rect,
Scalar left,
Scalar top,
Scalar right,
Scalar bottom) {
return MakeRectRadii(
rect, RoundingRadii::MakeNinePatch(left, top, right, bottom));
}
static RoundRect MakeRectRadii(const Rect& rect, const RoundingRadii& radii);
constexpr const Rect& GetBounds() const { return bounds_; }

View File

@ -25,18 +25,6 @@ struct RoundingRadii {
return {radii, radii, radii, radii};
}
constexpr static RoundingRadii MakeNinePatch(Scalar left,
Scalar top,
Scalar right,
Scalar bottom) {
return {
.top_left = Size{left, top},
.top_right = Size{right, top},
.bottom_left = Size(left, bottom),
.bottom_right = Size(right, bottom),
};
}
constexpr bool IsFinite() const {
return top_left.IsFinite() && //
top_right.IsFinite() && //

View File

@ -18,6 +18,7 @@
#include "impeller/golden_tests/metal_screenshot.h"
#include "impeller/golden_tests/metal_screenshotter.h"
#include "impeller/golden_tests/working_directory.h"
#include "third_party/skia/include/core/SkPaint.h"
namespace impeller {
namespace testing {
@ -91,7 +92,7 @@ TEST_F(GoldenTests, ConicalGradient) {
/*tile_mode=*/flutter::DlTileMode::kClamp //
));
builder.DrawRect(DlRect::MakeXYWH(10, 10, 250, 250), paint);
builder.DrawRect(SkRect::MakeXYWH(10, 10, 250, 250), paint);
auto aiks_context =
AiksContext(Screenshotter().GetPlayground().GetContext(), nullptr);

View File

@ -264,7 +264,7 @@ TEST_P(BlitPassTest, CanResizeTexturesPlayground) {
DlPaint paint;
paint.setColor(DlColor::kRed());
auto image = DlImageImpeller::Make(dst);
builder.DrawImage(image, flutter::DlPoint(100.0, 100.0),
builder.DrawImage(image, SkPoint::Make(100.0, 100.0),
DlImageSampling::kNearestNeighbor, &paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

View File

@ -289,7 +289,7 @@ TEST(DlOpSpy, DrawPath) {
DlPathBuilder path_builder;
path_builder.MoveTo({0, 1});
path_builder.LineTo({1, 1});
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(DlPath(path_builder.TakePath()), paint);
sk_sp<DisplayList> dl = builder.Build();
DlOpSpy dl_op_spy;
dl->Dispatch(dl_op_spy);
@ -302,7 +302,7 @@ TEST(DlOpSpy, DrawPath) {
path_builder.MoveTo({0, 0});
path_builder.LineTo({1, 0});
path_builder.LineTo({0, 1});
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(DlPath(path_builder.TakePath()), paint);
sk_sp<DisplayList> dl = builder.Build();
DlOpSpy dl_op_spy;
dl->Dispatch(dl_op_spy);
@ -315,7 +315,7 @@ TEST(DlOpSpy, DrawPath) {
DlPathBuilder path_builder;
path_builder.MoveTo({0, 1});
path_builder.LineTo({1, 1});
builder.DrawPath(DlPath(path_builder), paint);
builder.DrawPath(DlPath(path_builder.TakePath()), paint);
sk_sp<DisplayList> dl = builder.Build();
DlOpSpy dl_op_spy;
dl->Dispatch(dl_op_spy);