5#include <unordered_map>
11#include "gtest/gtest.h"
22#include "third_party/abseil-cpp/absl/status/status_matchers.h"
29 std::optional<Rect> cull_rect = std::nullopt,
30 bool requires_readback =
false) {
32 onscreen_desc.
size = {100, 100};
38 std::shared_ptr<Texture> onscreen =
39 context.
GetContext()->GetResourceAllocator()->CreateTexture(
44 if (context.
GetContext()->GetCapabilities()->SupportsOffscreenMSAA()) {
50 std::shared_ptr<Texture> onscreen_msaa =
51 context.
GetContext()->GetResourceAllocator()->CreateTexture(
63 if (cull_rect.has_value()) {
64 return std::make_unique<Canvas>(
65 context, render_target,
false,
66 requires_readback, cull_rect.value());
68 return std::make_unique<Canvas>(context, render_target,
false,
79 canvas->Translate(
Vector3(100, 200));
81 canvas->GetCurrentTransform(),
89 canvas->GetCurrentTransform(),
97 canvas->GetCurrentTransform(),
103 canvas->Translate(
Vector3(100, 200));
105 canvas->GetCurrentTransform(),
117 ASSERT_EQ(canvas->GetSaveCount(), 1u);
118 ASSERT_EQ(canvas->Restore(),
false);
120 canvas->Translate(
Size{100, 100});
122 ASSERT_EQ(canvas->GetSaveCount(), 2u);
125 ASSERT_TRUE(canvas->Restore());
126 ASSERT_EQ(canvas->GetSaveCount(), 1u);
137 canvas->Translate(
Size{100, 100});
145 GTEST_SKIP() <<
"Test requires device with framebuffer fetch";
150 canvas->SetBackdropData({}, 3);
156 EXPECT_TRUE(canvas->RequiresReadback());
158 canvas->SaveLayer({}, rect, blur.get(),
162 EXPECT_TRUE(canvas->RequiresReadback());
164 canvas->SaveLayer({}, rect, blur.get(),
168 EXPECT_TRUE(canvas->RequiresReadback());
170 canvas->SaveLayer({}, rect, blur.get(),
174 EXPECT_FALSE(canvas->RequiresReadback());
180 GTEST_SKIP() <<
"Test requires device with framebuffer fetch";
185 std::unordered_map<int64_t, BackdropData>
data;
187 canvas->SetBackdropData(
data, 3);
192 EXPECT_TRUE(canvas->RequiresReadback());
195 canvas->SaveLayer({}, std::nullopt, blur.get(),
200 EXPECT_FALSE(canvas->RequiresReadback());
202 canvas->SaveLayer({}, std::nullopt, blur.get(),
207 EXPECT_FALSE(canvas->RequiresReadback());
209 canvas->SaveLayer({}, std::nullopt, blur.get(),
214 EXPECT_FALSE(canvas->RequiresReadback());
220 GTEST_SKIP() <<
"Test requires device with framebuffer fetch";
225 std::unordered_map<int64_t, BackdropData>
data;
227 canvas->SetBackdropData(
data, 3);
232 EXPECT_TRUE(canvas->RequiresReadback());
235 canvas->SaveLayer({}, std::nullopt, blur.get(),
238 EXPECT_TRUE(canvas->RequiresReadback());
240 canvas->SaveLayer({}, std::nullopt, blur.get(),
243 EXPECT_FALSE(canvas->RequiresReadback());
245 canvas->SaveLayer({}, std::nullopt, blur.get(),
248 EXPECT_FALSE(canvas->RequiresReadback());
257 GTEST_SKIP() <<
"Test requires device with framebuffer fetch";
262 canvas->SetBackdropData({}, 2);
267 EXPECT_TRUE(canvas->RequiresReadback());
270 canvas->SaveLayer({}, std::nullopt, blur.get(),
276 canvas->SaveLayer({}, std::nullopt, blur.get(),
280 EXPECT_TRUE(canvas->RequiresReadback());
283 EXPECT_TRUE(canvas->RequiresReadback());
289 Canvas canvas(context, render_target,
true,
false);
291 std::vector<flutter::DlPoint> vertex_coordinates = {
296 std::vector<flutter::DlPoint> texture_coordinates = {
301 std::vector<uint16_t> indices = {0, 1, 2};
308 auto vertices = vertices_builder.
build();
313 std::vector<Scalar> stops = {0.0, 1.0};
315 {0, 0}, {0, 600}, 2, colors.data(), stops.data(),
320 canvas.
DrawVertices(std::make_shared<DlVerticesGeometry>(vertices, context),
331 auto runtime_stages_result =
332 OpenAssetAsRuntimeStage(
"runtime_stage_simple.frag.iplr");
333 ABSL_ASSERT_OK(runtime_stages_result);
334 std::shared_ptr<RuntimeStage> runtime_stage =
335 runtime_stages_result
337 ASSERT_TRUE(runtime_stage);
340 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
342 runtime_effect, {}, uniform_data);
346 Canvas canvas(context, render_target,
true,
false);
348 std::vector<flutter::DlPoint> vertex_coordinates = {
354 std::vector<flutter::DlPoint> texture_coordinates = {
359 std::vector<uint16_t> indices = {0, 1, 2};
366 auto vertices = vertices_builder.
build();
370 canvas.
DrawVertices(std::make_shared<DlVerticesGeometry>(vertices, context),
386 EXPECT_FALSE(canvas->SupportsBlitToOnscreen());
388 EXPECT_TRUE(canvas->SupportsBlitToOnscreen());
394 Size default_size(600, 400);
395 Point left_center(400, 700);
396 Point right_center(1300, 700);
402 std::shared_ptr<flutter::DlColorSource> color_source;
405 std::vector<flutter::DlColor> colors = {dl_color, dl_color};
406 std::vector<Scalar> stops = {0.0, 1.0};
408 {0, 0}, {1000, 1000}, 2, colors.data(), stops.data(),
412 auto RectMakeCenterHalfSize = [](
Point center,
Point half_size) {
413 Size size(half_size.x * 2, half_size.y * 2);
419 Canvas canvas(context, render_target,
true,
false);
424 static Scalar sigma = 0.05;
425 static Scalar radius = 200;
428 ImGui::Begin(
"Shadow",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
430 ImGui::SliderFloat(
"Sigma", &sigma, 0, 100);
431 ImGui::SliderFloat(
"Radius", &radius, 0, 1000);
436 ctm * (right_center + default_size / 2), 30,
Color::White());
438 Point half_size = (right_reference - right_center).Abs();
439 Rect left_bounds = RectMakeCenterHalfSize(left_center, half_size);
440 Rect right_bounds = RectMakeCenterHalfSize(right_center, half_size);
444 .mask_blur_descriptor =
455 paint.color_source = color_source.get();
static std::shared_ptr< DlColorSource > MakeLinear(const DlPoint start_point, const DlPoint end_point, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeRuntimeEffect(sk_sp< DlRuntimeEffect > runtime_effect, std::vector< std::shared_ptr< DlColorSource > > samplers, std::shared_ptr< std::vector< uint8_t > > uniform_data)
static std::shared_ptr< DlImageFilter > MakeBlur(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode)
static sk_sp< DlRuntimeEffect > Make(std::shared_ptr< impeller::RuntimeStage > runtime_stage)
A utility class to build up a |DlVertices| object one set of data at a time.
void store_vertices(const DlPoint vertices[])
Copies the indicated list of points as vertices.
void store_indices(const uint16_t indices[])
Copies the indicated list of 16-bit indices as vertex indices.
void store_texture_coordinates(const DlPoint points[])
Copies the indicated list of points as texture coordinates.
std::shared_ptr< DlVertices > build()
Finalizes and the constructed DlVertices object.
static constexpr Flags kHasTextureCoordinates
void DrawRoundSuperellipse(const RoundSuperellipse &rse, const Paint &paint)
void DrawVertices(const std::shared_ptr< VerticesGeometry > &vertices, BlendMode blend_mode, const Paint &paint)
virtual bool SupportsFramebufferFetch() const =0
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
virtual PixelFormat GetDefaultColorFormat() const =0
Returns a supported PixelFormat for textures that store 4-channel colors (red/green/blue/alpha).
const Capabilities & GetDeviceCapabilities() const
std::shared_ptr< Context > GetContext() const
bool OpenPlaygroundHere(const RenderCallback &render_callback)
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
FlutterDesktopBinaryReply callback
#define ASSERT_MATRIX_NEAR(a, b)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
std::unique_ptr< Canvas > CreateTestCanvas(ContentContext &context, std::optional< Rect > cull_rect=std::nullopt, bool requires_readback=false)
TEST_P(AiksTest, DrawAtlasNoColor)
Point DrawPlaygroundPoint(PlaygroundPoint &point)
constexpr RuntimeStageBackend PlaygroundBackendToRuntimeStageBackend(PlaygroundBackend backend)
@ kContainsContents
The caller claims the bounds are a reasonably tight estimate of the coverage of the contents and shou...
static constexpr DlColor kBlue()
static constexpr DlColor kRed()
std::shared_ptr< Texture > resolve_texture
std::shared_ptr< Texture > texture
uint32_t ToARGB() const
Convert to ARGB 32 bit color.
static constexpr Color Azure()
static constexpr Color White()
static constexpr Color Red()
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static constexpr Matrix MakeScale(const Vector3 &s)
const flutter::DlColorSource * color_source
static RoundSuperellipse MakeRectRadius(const Rect &rect, Scalar radius)
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
static constexpr TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...