[Impeller] move more aiks tests to DL. (flutter/engine#54260)
Part of https://github.com/flutter/flutter/issues/142054
This commit is contained in:
@@ -148,6 +148,7 @@
|
||||
../../../flutter/impeller/display_list/aiks_dl_gradient_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_opacity_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_path_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_runtime_effect_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_vertices_unittests.cc
|
||||
../../../flutter/impeller/display_list/dl_golden_blur_unittests.cc
|
||||
|
||||
@@ -1228,69 +1228,6 @@ TEST_P(AiksTest, OpaqueEntitiesGetCoercedToSource) {
|
||||
ASSERT_EQ(entity[0].GetBlendMode(), BlendMode::kSource);
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/126701 .
|
||||
TEST_P(AiksTest, CanRenderClippedRuntimeEffects) {
|
||||
auto runtime_stages =
|
||||
OpenAssetAsRuntimeStage("runtime_stage_example.frag.iplr");
|
||||
|
||||
auto runtime_stage =
|
||||
runtime_stages[PlaygroundBackendToRuntimeStageBackend(GetBackend())];
|
||||
ASSERT_TRUE(runtime_stage);
|
||||
ASSERT_TRUE(runtime_stage->IsDirty());
|
||||
|
||||
struct FragUniforms {
|
||||
Vector2 iResolution;
|
||||
Scalar iTime;
|
||||
} frag_uniforms = {.iResolution = Vector2(400, 400), .iTime = 100.0};
|
||||
auto uniform_data = std::make_shared<std::vector<uint8_t>>();
|
||||
uniform_data->resize(sizeof(FragUniforms));
|
||||
memcpy(uniform_data->data(), &frag_uniforms, sizeof(FragUniforms));
|
||||
|
||||
std::vector<RuntimeEffectContents::TextureInput> texture_inputs;
|
||||
|
||||
Paint paint;
|
||||
paint.color_source = ColorSource::MakeRuntimeEffect(
|
||||
runtime_stage, uniform_data, texture_inputs);
|
||||
|
||||
Canvas canvas;
|
||||
canvas.Save();
|
||||
canvas.ClipRRect(Rect::MakeXYWH(0, 0, 400, 400), {10.0, 10.0},
|
||||
Entity::ClipOperation::kIntersect);
|
||||
canvas.DrawRect(Rect::MakeXYWH(0, 0, 400, 400), paint);
|
||||
canvas.Restore();
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawPaintTransformsBounds) {
|
||||
auto runtime_stages = OpenAssetAsRuntimeStage("gradient.frag.iplr");
|
||||
auto runtime_stage =
|
||||
runtime_stages[PlaygroundBackendToRuntimeStageBackend(GetBackend())];
|
||||
ASSERT_TRUE(runtime_stage);
|
||||
ASSERT_TRUE(runtime_stage->IsDirty());
|
||||
|
||||
struct FragUniforms {
|
||||
Size size;
|
||||
} frag_uniforms = {.size = Size::MakeWH(400, 400)};
|
||||
auto uniform_data = std::make_shared<std::vector<uint8_t>>();
|
||||
uniform_data->resize(sizeof(FragUniforms));
|
||||
memcpy(uniform_data->data(), &frag_uniforms, sizeof(FragUniforms));
|
||||
|
||||
std::vector<RuntimeEffectContents::TextureInput> texture_inputs;
|
||||
|
||||
Paint paint;
|
||||
paint.color_source = ColorSource::MakeRuntimeEffect(
|
||||
runtime_stage, uniform_data, texture_inputs);
|
||||
|
||||
Canvas canvas;
|
||||
canvas.Save();
|
||||
canvas.Scale(GetContentScale());
|
||||
canvas.DrawPaint(paint);
|
||||
canvas.Restore();
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
// This currently renders solid blue, as the support for text color sources was
|
||||
// moved into DLDispatching. Path data requires the SkTextBlobs which are not
|
||||
// used in impeller::TextFrames.
|
||||
|
||||
@@ -58,6 +58,7 @@ template("display_list_unittests_component") {
|
||||
"aiks_dl_gradient_unittests.cc",
|
||||
"aiks_dl_opacity_unittests.cc",
|
||||
"aiks_dl_path_unittests.cc",
|
||||
"aiks_dl_runtime_effect_unittests.cc",
|
||||
"aiks_dl_unittests.cc",
|
||||
"aiks_dl_vertices_unittests.cc",
|
||||
"dl_golden_blur_unittests.cc",
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
// 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 <memory>
|
||||
|
||||
#include "display_list/effects/dl_color_source.h"
|
||||
#include "flutter/impeller/aiks/aiks_unittests.h"
|
||||
|
||||
#include "flutter/display_list/dl_builder.h"
|
||||
#include "flutter/display_list/dl_paint.h"
|
||||
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkRRect.h"
|
||||
|
||||
namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
using namespace flutter;
|
||||
|
||||
namespace {
|
||||
std::shared_ptr<DlRuntimeEffectColorSource> MakeRuntimeEffect(
|
||||
AiksTest* test,
|
||||
std::string_view name,
|
||||
const std::shared_ptr<std::vector<uint8_t>>& uniform_data = {},
|
||||
const std::vector<std::shared_ptr<DlColorSource>>& samplers = {}) {
|
||||
auto runtime_stages = test->OpenAssetAsRuntimeStage(name.data());
|
||||
auto runtime_stage = runtime_stages[PlaygroundBackendToRuntimeStageBackend(
|
||||
test->GetBackend())];
|
||||
FML_CHECK(runtime_stage);
|
||||
FML_CHECK(runtime_stage->IsDirty());
|
||||
|
||||
auto dl_runtime_effect = DlRuntimeEffect::MakeImpeller(runtime_stage);
|
||||
|
||||
return std::make_shared<DlRuntimeEffectColorSource>(dl_runtime_effect,
|
||||
samplers, uniform_data);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/126701 .
|
||||
TEST_P(AiksTest, CanRenderClippedRuntimeEffects) {
|
||||
struct FragUniforms {
|
||||
Vector2 iResolution;
|
||||
Scalar iTime;
|
||||
} frag_uniforms = {.iResolution = Vector2(400, 400), .iTime = 100.0};
|
||||
auto uniform_data = std::make_shared<std::vector<uint8_t>>();
|
||||
uniform_data->resize(sizeof(FragUniforms));
|
||||
memcpy(uniform_data->data(), &frag_uniforms, sizeof(FragUniforms));
|
||||
|
||||
DlPaint paint;
|
||||
paint.setColorSource(
|
||||
MakeRuntimeEffect(this, "runtime_stage_example.frag.iplr", uniform_data));
|
||||
|
||||
DisplayListBuilder builder;
|
||||
builder.Save();
|
||||
builder.ClipRRect(
|
||||
SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 400, 400), 10.0, 10.0),
|
||||
DlCanvas::ClipOp::kIntersect);
|
||||
builder.DrawRect(SkRect::MakeXYWH(0, 0, 400, 400), paint);
|
||||
builder.Restore();
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawPaintTransformsBounds) {
|
||||
struct FragUniforms {
|
||||
Size size;
|
||||
} frag_uniforms = {.size = Size::MakeWH(400, 400)};
|
||||
auto uniform_data = std::make_shared<std::vector<uint8_t>>();
|
||||
uniform_data->resize(sizeof(FragUniforms));
|
||||
memcpy(uniform_data->data(), &frag_uniforms, sizeof(FragUniforms));
|
||||
|
||||
DlPaint paint;
|
||||
paint.setColorSource(
|
||||
MakeRuntimeEffect(this, "gradient.frag.iplr", uniform_data));
|
||||
|
||||
DisplayListBuilder builder;
|
||||
builder.Save();
|
||||
builder.Scale(GetContentScale().x, GetContentScale().y);
|
||||
builder.DrawPaint(paint);
|
||||
builder.Restore();
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
Reference in New Issue
Block a user