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 @@ -140,6 +140,7 @@
../../../flutter/impeller/compiler/shader_bundle_unittests.cc
../../../flutter/impeller/compiler/switches_unittests.cc
../../../flutter/impeller/core/allocator_unittests.cc
../../../flutter/impeller/display_list/aiks_dl_path_unittests.cc
../../../flutter/impeller/display_list/dl_golden_unittests.cc
../../../flutter/impeller/display_list/dl_golden_unittests.h
../../../flutter/impeller/display_list/dl_unittests.cc
Expand Down
1 change: 1 addition & 0 deletions display_list/dl_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct DlColor {
static constexpr DlColor kDarkGrey() {return DlColor(0xFF3F3F3F);};
static constexpr DlColor kMidGrey() {return DlColor(0xFF808080);};
static constexpr DlColor kLightGrey() {return DlColor(0xFFC0C0C0);};
static constexpr DlColor kAliceBlue() {return DlColor(0xFFF0F8FF);};
// clang-format on

constexpr bool isOpaque() const { return getAlpha() == 0xFF; }
Expand Down
2 changes: 2 additions & 0 deletions impeller/aiks/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ impeller_component("aiks_playground") {
deps = [
":aiks",
"../playground:playground_test",
"//flutter/display_list",
"//flutter/impeller/display_list:display_list",
]
public_deps = [
"//flutter/impeller/typographer/backends/skia:typographer_skia_backend",
Expand Down
25 changes: 0 additions & 25 deletions impeller/aiks/aiks_path_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,6 @@
namespace impeller {
namespace testing {

TEST_P(AiksTest, RotateColorFilteredPath) {
Canvas canvas;
canvas.Concat(Matrix::MakeTranslation({300, 300}));
canvas.Concat(Matrix::MakeRotationZ(Radians(kPiOver2)));
auto arrow_stem =
PathBuilder{}.MoveTo({120, 190}).LineTo({120, 50}).TakePath();
auto arrow_head = PathBuilder{}
.MoveTo({50, 120})
.LineTo({120, 190})
.LineTo({190, 120})
.TakePath();
auto paint = Paint{
.stroke_width = 15.0,
.stroke_cap = Cap::kRound,
.stroke_join = Join::kRound,
.style = Paint::Style::kStroke,
.color_filter =
ColorFilter::MakeBlend(BlendMode::kSourceIn, Color::AliceBlue()),
};

canvas.DrawPath(arrow_stem, paint);
canvas.DrawPath(arrow_head, paint);
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanRenderStrokes) {
Canvas canvas;
Paint paint;
Expand Down
9 changes: 9 additions & 0 deletions impeller/aiks/aiks_playground.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <memory>

#include "impeller/aiks/aiks_context.h"
#include "impeller/display_list/dl_dispatcher.h"
#include "impeller/typographer/backends/skia/typographer_context_skia.h"
#include "impeller/typographer/typographer_context.h"

Expand Down Expand Up @@ -63,4 +64,12 @@ bool AiksPlayground::ImGuiBegin(const char* name,
return true;
}

bool AiksPlayground::OpenPlaygroundHere(
const sk_sp<flutter::DisplayList>& list) {
DlDispatcher dispatcher;
list->Dispatch(dispatcher);
Picture picture = dispatcher.EndRecordingAsPicture();
return OpenPlaygroundHere(std::move(picture));
}

} // namespace impeller
3 changes: 3 additions & 0 deletions impeller/aiks/aiks_playground.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef FLUTTER_IMPELLER_AIKS_AIKS_PLAYGROUND_H_
#define FLUTTER_IMPELLER_AIKS_AIKS_PLAYGROUND_H_

#include "flutter/display_list/display_list.h"
#include "impeller/aiks/aiks_context.h"
#include "impeller/aiks/aiks_playground_inspector.h"
#include "impeller/aiks/picture.h"
Expand Down Expand Up @@ -32,6 +33,8 @@ class AiksPlayground : public PlaygroundTest {

bool OpenPlaygroundHere(AiksPlaygroundCallback callback);

bool OpenPlaygroundHere(const sk_sp<flutter::DisplayList>& list);

static bool ImGuiBegin(const char* name,
bool* p_open,
ImGuiWindowFlags flags);
Expand Down
10 changes: 9 additions & 1 deletion impeller/display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impeller_component("display_list") {
template("display_list_unittests_component") {
target_name = invoker.target_name
predefined_sources = [
"aiks_dl_path_unittests.cc",
"dl_golden_unittests.cc",
"dl_playground.cc",
"dl_playground.h",
Expand All @@ -74,7 +75,12 @@ template("display_list_unittests_component") {
}

sources = predefined_sources + additional_sources
deps = [
if (defined(invoker.deps)) {
deps = invoker.deps
} else {
deps = []
}
deps += [
":display_list",
"../playground:playground_test",
"//flutter/impeller/scene",
Expand All @@ -88,9 +94,11 @@ template("display_list_unittests_component") {
}

display_list_unittests_component("display_list_unittests") {
deps = [ "//flutter/impeller/aiks:aiks_unittests" ]
}

display_list_unittests_component("display_list_unittests_golden") {
deps = [ "//flutter/impeller/aiks:aiks_unittests_golden" ]
defines = [
"IMPELLER_GOLDEN_TESTS",
"IMPELLER_ENABLE_VALIDATION=1",
Expand Down
46 changes: 46 additions & 0 deletions impeller/display_list/aiks_dl_path_unittests.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/impeller/aiks/aiks_unittests.h"

#include "flutter/display_list/dl_blend_mode.h"
#include "flutter/display_list/dl_builder.h"
#include "flutter/display_list/dl_color.h"
#include "flutter/display_list/dl_paint.h"
#include "flutter/display_list/effects/dl_color_filter.h"
#include "flutter/testing/testing.h"

namespace impeller {
namespace testing {

using namespace flutter;

TEST_P(AiksTest, RotateColorFilteredPath) {
DisplayListBuilder builder;
builder.Transform(SkMatrix::Translate(300, 300) * SkMatrix::RotateDeg(90));

SkPath arrow_stem;
SkPath arrow_head;

arrow_stem.moveTo({120, 190}).lineTo({120, 50});
arrow_head.moveTo({50, 120}).lineTo({120, 190}).lineTo({190, 120});

auto filter =
DlBlendColorFilter::Make(DlColor::kAliceBlue(), DlBlendMode::kSrcIn);

DlPaint paint;
paint.setStrokeWidth(15.0);
paint.setStrokeCap(DlStrokeCap::kRound);
paint.setStrokeJoin(DlStrokeJoin::kRound);
paint.setDrawStyle(DlDrawStyle::kStroke);
paint.setColorFilter(filter);
paint.setColor(DlColor::kBlack());

builder.DrawPath(arrow_stem, paint);
builder.DrawPath(arrow_head, paint);

ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
} // namespace testing
} // namespace impeller