Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/licenses_golden/excluded_files
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
../../../flutter/display_list/effects/dl_image_filter_unittests.cc
../../../flutter/display_list/effects/dl_mask_filter_unittests.cc
../../../flutter/display_list/geometry/dl_geometry_types_unittests.cc
../../../flutter/display_list/geometry/dl_path_unittests.cc
../../../flutter/display_list/geometry/dl_region_unittests.cc
../../../flutter/display_list/geometry/dl_rtree_unittests.cc
../../../flutter/display_list/skia/dl_sk_conversions_unittests.cc
Expand Down
4 changes: 4 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -42345,6 +42345,8 @@ ORIGIN: ../../../flutter/display_list/effects/dl_mask_filter.h + ../../../flutte
ORIGIN: ../../../flutter/display_list/effects/dl_runtime_effect.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/effects/dl_runtime_effect.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/geometry/dl_geometry_types.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/geometry/dl_path.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/geometry/dl_path.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/geometry/dl_region.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/geometry/dl_region.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/display_list/geometry/dl_rtree.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -45240,6 +45242,8 @@ FILE: ../../../flutter/display_list/effects/dl_mask_filter.h
FILE: ../../../flutter/display_list/effects/dl_runtime_effect.cc
FILE: ../../../flutter/display_list/effects/dl_runtime_effect.h
FILE: ../../../flutter/display_list/geometry/dl_geometry_types.h
FILE: ../../../flutter/display_list/geometry/dl_path.cc
FILE: ../../../flutter/display_list/geometry/dl_path.h
FILE: ../../../flutter/display_list/geometry/dl_region.cc
FILE: ../../../flutter/display_list/geometry/dl_region.h
FILE: ../../../flutter/display_list/geometry/dl_rtree.cc
Expand Down
3 changes: 3 additions & 0 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ source_set("display_list") {
"effects/dl_runtime_effect.cc",
"effects/dl_runtime_effect.h",
"geometry/dl_geometry_types.h",
"geometry/dl_path.cc",
"geometry/dl_path.h",
"geometry/dl_region.cc",
"geometry/dl_region.h",
"geometry/dl_rtree.cc",
Expand Down Expand Up @@ -119,6 +121,7 @@ if (enable_unittests) {
"effects/dl_image_filter_unittests.cc",
"effects/dl_mask_filter_unittests.cc",
"geometry/dl_geometry_types_unittests.cc",
"geometry/dl_path_unittests.cc",
"geometry/dl_region_unittests.cc",
"geometry/dl_rtree_unittests.cc",
"skia/dl_sk_conversions_unittests.cc",
Expand Down
4 changes: 2 additions & 2 deletions display_list/benchmarking/dl_complexity_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void DisplayListGLComplexityCalculator::GLHelper::drawDRRect(
AccumulateComplexity(complexity);
}

void DisplayListGLComplexityCalculator::GLHelper::drawPath(const SkPath& path) {
void DisplayListGLComplexityCalculator::GLHelper::drawPath(const DlPath& path) {
if (IsComplex()) {
return;
}
Expand Down Expand Up @@ -655,7 +655,7 @@ void DisplayListGLComplexityCalculator::GLHelper::drawTextFrame(
DlScalar y) {}

void DisplayListGLComplexityCalculator::GLHelper::drawShadow(
const SkPath& path,
const DlPath& path,
const DlColor color,
const DlScalar elevation,
bool transparent_occluder,
Expand Down
4 changes: 2 additions & 2 deletions display_list/benchmarking/dl_complexity_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DisplayListGLComplexityCalculator
void drawCircle(const DlPoint& center, DlScalar radius) override;
void drawRRect(const SkRRect& rrect) override;
void drawDRRect(const SkRRect& outer, const SkRRect& inner) override;
void drawPath(const SkPath& path) override;
void drawPath(const DlPath& path) override;
void drawArc(const DlRect& oval_bounds,
DlScalar start_degrees,
DlScalar sweep_degrees,
Expand All @@ -76,7 +76,7 @@ class DisplayListGLComplexityCalculator
void drawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
DlScalar x,
DlScalar y) override;
void drawShadow(const SkPath& path,
void drawShadow(const DlPath& path,
const DlColor color,
const DlScalar elevation,
bool transparent_occluder,
Expand Down
3 changes: 2 additions & 1 deletion display_list/benchmarking/dl_complexity_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ class ComplexityCalculatorHelper
inline unsigned int Ceiling() { return ceiling_; }
inline unsigned int CurrentComplexityScore() { return complexity_score_; }

unsigned int CalculatePathComplexity(const SkPath& path,
unsigned int CalculatePathComplexity(const DlPath& dl_path,
unsigned int line_verb_cost,
unsigned int quad_verb_cost,
unsigned int conic_verb_cost,
unsigned int cubic_verb_cost) {
const SkPath& path = dl_path.GetSkPath();
int verb_count = path.countVerbs();
std::vector<uint8_t> verbs(verb_count);
path.getVerbs(verbs.data(), verbs.size());
Expand Down
4 changes: 2 additions & 2 deletions display_list/benchmarking/dl_complexity_metal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void DisplayListMetalComplexityCalculator::MetalHelper::drawDRRect(
}

void DisplayListMetalComplexityCalculator::MetalHelper::drawPath(
const SkPath& path) {
const DlPath& path) {
if (IsComplex()) {
return;
}
Expand Down Expand Up @@ -599,7 +599,7 @@ void DisplayListMetalComplexityCalculator::MetalHelper::drawTextFrame(
DlScalar y) {}

void DisplayListMetalComplexityCalculator::MetalHelper::drawShadow(
const SkPath& path,
const DlPath& path,
const DlColor color,
const DlScalar elevation,
bool transparent_occluder,
Expand Down
4 changes: 2 additions & 2 deletions display_list/benchmarking/dl_complexity_metal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DisplayListMetalComplexityCalculator
void drawCircle(const DlPoint& center, DlScalar radius) override;
void drawRRect(const SkRRect& rrect) override;
void drawDRRect(const SkRRect& outer, const SkRRect& inner) override;
void drawPath(const SkPath& path) override;
void drawPath(const DlPath& path) override;
void drawArc(const DlRect& oval_bounds,
DlScalar start_degrees,
DlScalar sweep_degrees,
Expand All @@ -76,7 +76,7 @@ class DisplayListMetalComplexityCalculator
void drawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
DlScalar x,
DlScalar y) override;
void drawShadow(const SkPath& path,
void drawShadow(const DlPath& path,
const DlColor color,
const DlScalar elevation,
bool transparent_occluder,
Expand Down
108 changes: 11 additions & 97 deletions display_list/display_list_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3618,98 +3618,6 @@ TEST_F(DisplayListTest, NopOperationsOmittedFromRecords) {
});
}

TEST_F(DisplayListTest, ImpellerPathPreferenceIsHonored) {
class Tester : public virtual DlOpReceiver,
public IgnoreClipDispatchHelper,
public IgnoreDrawDispatchHelper,
public IgnoreAttributeDispatchHelper,
public IgnoreTransformDispatchHelper {
public:
explicit Tester(bool prefer_impeller_paths)
: prefer_impeller_paths_(prefer_impeller_paths) {}

bool PrefersImpellerPaths() const override {
return prefer_impeller_paths_;
}

void drawPath(const SkPath& path) override { skia_draw_path_calls_++; }

void drawPath(const CacheablePath& cache) override {
impeller_draw_path_calls_++;
}

void clipPath(const SkPath& path, ClipOp op, bool is_aa) override {
skia_clip_path_calls_++;
}

void clipPath(const CacheablePath& cache, ClipOp op, bool is_aa) override {
impeller_clip_path_calls_++;
}

virtual void drawShadow(const SkPath& sk_path,
const DlColor color,
const SkScalar elevation,
bool transparent_occluder,
SkScalar dpr) override {
skia_draw_shadow_calls_++;
}

virtual void drawShadow(const CacheablePath& cache,
const DlColor color,
const SkScalar elevation,
bool transparent_occluder,
SkScalar dpr) override {
impeller_draw_shadow_calls_++;
}

int skia_draw_path_calls() const { return skia_draw_path_calls_; }
int skia_clip_path_calls() const { return skia_draw_path_calls_; }
int skia_draw_shadow_calls() const { return skia_draw_path_calls_; }
int impeller_draw_path_calls() const { return impeller_draw_path_calls_; }
int impeller_clip_path_calls() const { return impeller_draw_path_calls_; }
int impeller_draw_shadow_calls() const { return impeller_draw_path_calls_; }

private:
const bool prefer_impeller_paths_;
int skia_draw_path_calls_ = 0;
int skia_clip_path_calls_ = 0;
int skia_draw_shadow_calls_ = 0;
int impeller_draw_path_calls_ = 0;
int impeller_clip_path_calls_ = 0;
int impeller_draw_shadow_calls_ = 0;
};

DisplayListBuilder builder;
builder.DrawPath(SkPath::Rect(SkRect::MakeLTRB(0, 0, 100, 100)), DlPaint());
builder.ClipPath(SkPath::Rect(SkRect::MakeLTRB(0, 0, 100, 100)),
ClipOp::kIntersect, true);
builder.DrawShadow(SkPath::Rect(SkRect::MakeLTRB(20, 20, 80, 80)),
DlColor::kBlue(), 1.0f, true, 1.0f);
auto display_list = builder.Build();

{
Tester skia_tester(false);
display_list->Dispatch(skia_tester);
EXPECT_EQ(skia_tester.skia_draw_path_calls(), 1);
EXPECT_EQ(skia_tester.skia_clip_path_calls(), 1);
EXPECT_EQ(skia_tester.skia_draw_shadow_calls(), 1);
EXPECT_EQ(skia_tester.impeller_draw_path_calls(), 0);
EXPECT_EQ(skia_tester.impeller_clip_path_calls(), 0);
EXPECT_EQ(skia_tester.impeller_draw_shadow_calls(), 0);
}

{
Tester impeller_tester(true);
display_list->Dispatch(impeller_tester);
EXPECT_EQ(impeller_tester.skia_draw_path_calls(), 0);
EXPECT_EQ(impeller_tester.skia_clip_path_calls(), 0);
EXPECT_EQ(impeller_tester.skia_draw_shadow_calls(), 0);
EXPECT_EQ(impeller_tester.impeller_draw_path_calls(), 1);
EXPECT_EQ(impeller_tester.impeller_clip_path_calls(), 1);
EXPECT_EQ(impeller_tester.impeller_draw_shadow_calls(), 1);
}
}

class SaveLayerBoundsExpector : public virtual DlOpReceiver,
public IgnoreAttributeDispatchHelper,
public IgnoreClipDispatchHelper,
Expand Down Expand Up @@ -4616,7 +4524,7 @@ TEST_F(DisplayListTest, DrawDisplayListForwardsBackdropFlag) {
#define CLIP_EXPECTOR(name) ClipExpector name(__FILE__, __LINE__)

struct ClipExpectation {
std::variant<DlRect, SkRRect, SkPath> shape;
std::variant<DlRect, SkRRect, DlPath> shape;
bool is_oval;
ClipOp clip_op;
bool is_aa;
Expand All @@ -4628,7 +4536,7 @@ struct ClipExpectation {
case 1:
return "SkRRect";
case 2:
return "SkPath";
return "DlPath";
default:
return "Unknown";
}
Expand All @@ -4648,7 +4556,7 @@ ::std::ostream& operator<<(::std::ostream& os, const ClipExpectation& expect) {
os << std::get<SkRRect>(expect.shape);
break;
case 2:
os << std::get<SkPath>(expect.shape);
os << std::get<DlPath>(expect.shape).GetSkPath();
break;
case 3:
os << "Unknown";
Expand Down Expand Up @@ -4713,7 +4621,7 @@ class ClipExpector : public virtual DlOpReceiver,
return *this;
}

ClipExpector& addExpectation(const SkPath& path,
ClipExpector& addExpectation(const DlPath& path,
ClipOp clip_op = ClipOp::kIntersect,
bool is_aa = false) {
clip_expectations_.push_back({
Expand All @@ -4725,6 +4633,12 @@ class ClipExpector : public virtual DlOpReceiver,
return *this;
}

ClipExpector& addExpectation(const SkPath& path,
ClipOp clip_op = ClipOp::kIntersect,
bool is_aa = false) {
return addExpectation(DlPath(path), clip_op, is_aa);
}

void clipRect(const DlRect& rect,
DlCanvas::ClipOp clip_op,
bool is_aa) override {
Expand All @@ -4740,7 +4654,7 @@ class ClipExpector : public virtual DlOpReceiver,
bool is_aa) override {
check(rrect, clip_op, is_aa);
}
void clipPath(const SkPath& path,
void clipPath(const DlPath& path,
DlCanvas::ClipOp clip_op,
bool is_aa) override {
check(path, clip_op, is_aa);
Expand Down
34 changes: 20 additions & 14 deletions display_list/dl_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1044,30 +1044,30 @@ void DisplayListBuilder::ClipRRect(const SkRRect& rrect,
break;
}
}
void DisplayListBuilder::ClipPath(const SkPath& path,
void DisplayListBuilder::ClipPath(const DlPath& path,
ClipOp clip_op,
bool is_aa) {
if (current_info().is_nop) {
return;
}
if (!path.isInverseFillType()) {
if (!path.IsInverseFillType()) {
SkRect rect;
if (path.isRect(&rect)) {
if (path.IsSkRect(&rect)) {
ClipRect(rect, clip_op, is_aa);
return;
}
if (path.isOval(&rect)) {
if (path.IsSkOval(&rect)) {
ClipOval(rect, clip_op, is_aa);
return;
}
SkRRect rrect;
if (path.isRRect(&rrect)) {
if (path.IsSkRRect(&rrect)) {
ClipRRect(rrect, clip_op, is_aa);
return;
}
}
global_state().clipPath(path, clip_op, is_aa);
layer_local_state().clipPath(path, clip_op, is_aa);
global_state().clipPath(path.GetSkPath(), clip_op, is_aa);
layer_local_state().clipPath(path.GetSkPath(), clip_op, is_aa);
if (global_state().is_cull_rect_empty() ||
layer_local_state().is_cull_rect_empty()) {
current_info().is_nop = true;
Expand Down Expand Up @@ -1234,13 +1234,14 @@ void DisplayListBuilder::DrawDRRect(const SkRRect& outer,
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawDRRectFlags);
drawDRRect(outer, inner);
}
void DisplayListBuilder::drawPath(const SkPath& path) {
void DisplayListBuilder::drawPath(const DlPath& path) {
DisplayListAttributeFlags flags = kDrawPathFlags;
OpResult result = PaintResult(current_, flags);
if (result != OpResult::kNoEffect) {
bool is_visible = path.isInverseFillType()
? AccumulateUnbounded()
: AccumulateOpBounds(path.getBounds(), flags);
bool is_visible =
path.IsInverseFillType()
? AccumulateUnbounded()
: AccumulateOpBounds(ToSkRect(path.GetBounds()), flags);
if (is_visible) {
Push<DrawPathOp>(0, path);
CheckLayerOpacityHairlineCompatibility();
Expand All @@ -1249,6 +1250,11 @@ void DisplayListBuilder::drawPath(const SkPath& path) {
}
}
void DisplayListBuilder::DrawPath(const SkPath& path, const DlPaint& paint) {
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawPathFlags);
DlPath dl_path(path);
drawPath(dl_path);
}
void DisplayListBuilder::DrawPath(const DlPath& path, const DlPaint& paint) {
SetAttributesFromPaint(paint, DisplayListOpFlags::kDrawPathFlags);
drawPath(path);
}
Expand Down Expand Up @@ -1731,15 +1737,15 @@ void DisplayListBuilder::DrawTextFrame(
drawTextFrame(text_frame, x, y);
}

void DisplayListBuilder::DrawShadow(const SkPath& path,
void DisplayListBuilder::DrawShadow(const DlPath& path,
const DlColor color,
const DlScalar elevation,
bool transparent_occluder,
DlScalar dpr) {
OpResult result = PaintResult(DlPaint(color));
if (result != OpResult::kNoEffect) {
SkRect shadow_bounds =
DlCanvas::ComputeShadowBounds(path, elevation, dpr, GetTransform());
SkRect shadow_bounds = DlCanvas::ComputeShadowBounds(
path.GetSkPath(), elevation, dpr, GetTransform());
if (AccumulateOpBounds(shadow_bounds, kDrawShadowFlags)) {
transparent_occluder //
? Push<DrawShadowTransparentOccluderOp>(0, path, color, elevation,
Expand Down
Loading