diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 43992af7790..45074c8482c 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -500,6 +500,7 @@ FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/branching.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/color.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/constants.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/texture.glsl +FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/transform.glsl FILE: ../../../flutter/impeller/compiler/shader_lib/impeller/types.glsl FILE: ../../../flutter/impeller/compiler/source_options.cc FILE: ../../../flutter/impeller/compiler/source_options.h @@ -556,6 +557,8 @@ FILE: ../../../flutter/impeller/entity/contents/atlas_contents.cc FILE: ../../../flutter/impeller/entity/contents/atlas_contents.h FILE: ../../../flutter/impeller/entity/contents/clip_contents.cc FILE: ../../../flutter/impeller/entity/contents/clip_contents.h +FILE: ../../../flutter/impeller/entity/contents/color_source_contents.cc +FILE: ../../../flutter/impeller/entity/contents/color_source_contents.h FILE: ../../../flutter/impeller/entity/contents/content_context.cc FILE: ../../../flutter/impeller/entity/contents/content_context.h FILE: ../../../flutter/impeller/entity/contents/contents.cc @@ -581,8 +584,6 @@ FILE: ../../../flutter/impeller/entity/contents/filters/inputs/texture_filter_in FILE: ../../../flutter/impeller/entity/contents/filters/inputs/texture_filter_input.h FILE: ../../../flutter/impeller/entity/contents/linear_gradient_contents.cc FILE: ../../../flutter/impeller/entity/contents/linear_gradient_contents.h -FILE: ../../../flutter/impeller/entity/contents/path_contents.cc -FILE: ../../../flutter/impeller/entity/contents/path_contents.h FILE: ../../../flutter/impeller/entity/contents/radial_gradient_contents.cc FILE: ../../../flutter/impeller/entity/contents/radial_gradient_contents.h FILE: ../../../flutter/impeller/entity/contents/rrect_shadow_contents.cc @@ -641,10 +642,9 @@ FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur.frag FILE: ../../../flutter/impeller/entity/shaders/gaussian_blur.vert FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas.frag FILE: ../../../flutter/impeller/entity/shaders/glyph_atlas.vert -FILE: ../../../flutter/impeller/entity/shaders/gradient_fill.frag FILE: ../../../flutter/impeller/entity/shaders/gradient_fill.vert +FILE: ../../../flutter/impeller/entity/shaders/linear_gradient_fill.frag FILE: ../../../flutter/impeller/entity/shaders/radial_gradient_fill.frag -FILE: ../../../flutter/impeller/entity/shaders/radial_gradient_fill.vert FILE: ../../../flutter/impeller/entity/shaders/rrect_blur.frag FILE: ../../../flutter/impeller/entity/shaders/rrect_blur.vert FILE: ../../../flutter/impeller/entity/shaders/solid_fill.frag @@ -652,7 +652,6 @@ FILE: ../../../flutter/impeller/entity/shaders/solid_fill.vert FILE: ../../../flutter/impeller/entity/shaders/solid_stroke.frag FILE: ../../../flutter/impeller/entity/shaders/solid_stroke.vert FILE: ../../../flutter/impeller/entity/shaders/sweep_gradient_fill.frag -FILE: ../../../flutter/impeller/entity/shaders/sweep_gradient_fill.vert FILE: ../../../flutter/impeller/entity/shaders/texture_fill.frag FILE: ../../../flutter/impeller/entity/shaders/texture_fill.vert FILE: ../../../flutter/impeller/entity/shaders/tiled_texture_fill.frag diff --git a/engine/src/flutter/impeller/aiks/aiks_unittests.cc b/engine/src/flutter/impeller/aiks/aiks_unittests.cc index 55a8c32993f..05b4a381696 100644 --- a/engine/src/flutter/impeller/aiks/aiks_unittests.cc +++ b/engine/src/flutter/impeller/aiks/aiks_unittests.cc @@ -13,6 +13,7 @@ #include "impeller/entity/contents/tiled_texture_contents.h" #include "impeller/geometry/color.h" #include "impeller/geometry/geometry_unittests.h" +#include "impeller/geometry/matrix.h" #include "impeller/geometry/path_builder.h" #include "impeller/playground/widgets.h" #include "impeller/renderer/command_buffer.h" @@ -125,7 +126,21 @@ TEST_P(AiksTest, CanRenderTiledTexture) { ImGui::Combo("Min Mag filter", &selected_min_mag_filter, min_mag_filter_names, sizeof(min_mag_filter_names) / sizeof(char*)); + static Matrix matrix = { + 1, 0, 0, 0, // + 0, 1, 0, 0, // + 0, 0, 1, 0, // + 0, 0, 0, 1 // + }; + std::string label = "##1"; + label.c_str(); + for (int i = 0; i < 4; i++) { + ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, &(matrix.vec[i]), + 4, NULL, NULL, "%.2f", 0); + label[2]++; + } ImGui::End(); + Canvas canvas; Paint paint; canvas.Translate({100.0, 100.0, 0}); @@ -140,6 +155,7 @@ TEST_P(AiksTest, CanRenderTiledTexture) { contents->SetTexture(texture); contents->SetTileModes(x_tile_mode, y_tile_mode); contents->SetSamplerDescriptor(descriptor); + contents->SetMatrix(matrix); return contents; }; canvas.DrawRect({0, 0, 600, 600}, paint); @@ -282,86 +298,162 @@ TEST_P(AiksTest, CanSaveLayerStandalone) { } TEST_P(AiksTest, CanRenderLinearGradient) { - Canvas canvas; - Paint paint; - std::vector offsets = { - {0, 0, 0}, {0, 300, 0}, {300, 0, 0}, {300, 300, 0}}; - std::vector tile_modes = { - Entity::TileMode::kClamp, Entity::TileMode::kRepeat, - Entity::TileMode::kMirror, Entity::TileMode::kDecal}; - for (int i = 0; i < 4; i++) { - canvas.Save(); - canvas.Translate(offsets[i]); - Entity::TileMode tile_mode = tile_modes[i]; + bool first_frame = true; + auto callback = [&](AiksContext& renderer, RenderTarget& render_target) { + if (first_frame) { + first_frame = false; + ImGui::SetNextWindowSize({480, 100}); + ImGui::SetNextWindowPos({100, 550}); + } + + const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"}; + const Entity::TileMode tile_modes[] = { + Entity::TileMode::kClamp, Entity::TileMode::kRepeat, + Entity::TileMode::kMirror, Entity::TileMode::kDecal}; + + static int selected_tile_mode = 0; + ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, + sizeof(tile_mode_names) / sizeof(char*)); + static Matrix matrix = { + 1, 0, 0, 0, // + 0, 1, 0, 0, // + 0, 0, 1, 0, // + 0, 0, 0, 1 // + }; + std::string label = "##1"; + label.c_str(); + for (int i = 0; i < 4; i++) { + ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, &(matrix.vec[i]), + 4, NULL, NULL, "%.2f", 0); + label[2]++; + } + ImGui::End(); + + Canvas canvas; + Paint paint; + canvas.Translate({100.0, 100.0, 0}); + auto tile_mode = tile_modes[selected_tile_mode]; paint.color_source = [tile_mode]() { auto contents = std::make_shared(); - contents->SetEndPoints({0, 0}, {100, 100}); + contents->SetEndPoints({0, 0}, {200, 200}); std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, Color{0.1294, 0.5882, 0.9529, 1.0}}; contents->SetColors(std::move(colors)); contents->SetTileMode(tile_mode); + contents->SetMatrix(matrix); return contents; }; - canvas.DrawRect({0, 0, 200, 200}, paint); - canvas.Restore(); - } - ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); + canvas.DrawRect({0, 0, 600, 600}, paint); + return renderer.Render(canvas.EndRecordingAsPicture(), render_target); + }; + ASSERT_TRUE(OpenPlaygroundHere(callback)); } TEST_P(AiksTest, CanRenderRadialGradient) { - Canvas canvas; - Paint paint; - std::vector offsets = { - {0, 0, 0}, {0, 300, 0}, {300, 0, 0}, {300, 300, 0}}; - std::vector tile_modes = { - Entity::TileMode::kClamp, Entity::TileMode::kRepeat, - Entity::TileMode::kMirror, Entity::TileMode::kDecal}; - for (int i = 0; i < 4; i++) { - canvas.Save(); - canvas.Translate(offsets[i]); - Entity::TileMode tile_mode = tile_modes[i]; + bool first_frame = true; + auto callback = [&](AiksContext& renderer, RenderTarget& render_target) { + if (first_frame) { + first_frame = false; + ImGui::SetNextWindowSize({480, 100}); + ImGui::SetNextWindowPos({100, 550}); + } + + const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"}; + const Entity::TileMode tile_modes[] = { + Entity::TileMode::kClamp, Entity::TileMode::kRepeat, + Entity::TileMode::kMirror, Entity::TileMode::kDecal}; + + static int selected_tile_mode = 0; + ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, + sizeof(tile_mode_names) / sizeof(char*)); + static Matrix matrix = { + 1, 0, 0, 0, // + 0, 1, 0, 0, // + 0, 0, 1, 0, // + 0, 0, 0, 1 // + }; + std::string label = "##1"; + label.c_str(); + for (int i = 0; i < 4; i++) { + ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, &(matrix.vec[i]), + 4, NULL, NULL, "%.2f", 0); + label[2]++; + } + ImGui::End(); + + Canvas canvas; + Paint paint; + canvas.Translate({100.0, 100.0, 0}); + auto tile_mode = tile_modes[selected_tile_mode]; paint.color_source = [tile_mode]() { auto contents = std::make_shared(); - contents->SetCenterAndRadius({50, 50}, 50); + contents->SetCenterAndRadius({100, 100}, 100); std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, Color{0.1294, 0.5882, 0.9529, 1.0}}; contents->SetColors(std::move(colors)); contents->SetTileMode(tile_mode); + contents->SetMatrix(matrix); return contents; }; - canvas.DrawRect({0, 0, 200, 200}, paint); - canvas.Restore(); - } - - ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); + canvas.DrawRect({0, 0, 600, 600}, paint); + return renderer.Render(canvas.EndRecordingAsPicture(), render_target); + }; + ASSERT_TRUE(OpenPlaygroundHere(callback)); } TEST_P(AiksTest, CanRenderSweepGradient) { - Canvas canvas; - Paint paint; - std::vector offsets = { - {0, 0, 0}, {0, 300, 0}, {300, 0, 0}, {300, 300, 0}}; - std::vector tile_modes = { - Entity::TileMode::kClamp, Entity::TileMode::kRepeat, - Entity::TileMode::kMirror, Entity::TileMode::kDecal}; - for (int i = 0; i < 4; i++) { - canvas.Save(); - canvas.Translate(offsets[i]); - Entity::TileMode tile_mode = tile_modes[i]; + bool first_frame = true; + auto callback = [&](AiksContext& renderer, RenderTarget& render_target) { + if (first_frame) { + first_frame = false; + ImGui::SetNextWindowSize({480, 100}); + ImGui::SetNextWindowPos({100, 550}); + } + + const char* tile_mode_names[] = {"Clamp", "Repeat", "Mirror", "Decal"}; + const Entity::TileMode tile_modes[] = { + Entity::TileMode::kClamp, Entity::TileMode::kRepeat, + Entity::TileMode::kMirror, Entity::TileMode::kDecal}; + + static int selected_tile_mode = 0; + ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Combo("Tile mode", &selected_tile_mode, tile_mode_names, + sizeof(tile_mode_names) / sizeof(char*)); + static Matrix matrix = { + 1, 0, 0, 0, // + 0, 1, 0, 0, // + 0, 0, 1, 0, // + 0, 0, 0, 1 // + }; + std::string label = "##1"; + label.c_str(); + for (int i = 0; i < 4; i++) { + ImGui::InputScalarN(label.c_str(), ImGuiDataType_Float, &(matrix.vec[i]), + 4, NULL, NULL, "%.2f", 0); + label[2]++; + } + ImGui::End(); + + Canvas canvas; + Paint paint; + canvas.Translate({100.0, 100.0, 0}); + auto tile_mode = tile_modes[selected_tile_mode]; paint.color_source = [tile_mode]() { auto contents = std::make_shared(); - contents->SetCenterAndAngles({50, 50}, Degrees(45), Degrees(135)); + contents->SetCenterAndAngles({100, 100}, Degrees(45), Degrees(135)); std::vector colors = {Color{0.9568, 0.2627, 0.2118, 1.0}, Color{0.1294, 0.5882, 0.9529, 1.0}}; contents->SetColors(std::move(colors)); contents->SetTileMode(tile_mode); + contents->SetMatrix(matrix); return contents; }; - canvas.DrawRect({0, 0, 200, 200}, paint); - canvas.Restore(); - } - - ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); + canvas.DrawRect({0, 0, 600, 600}, paint); + return renderer.Render(canvas.EndRecordingAsPicture(), render_target); + }; + ASSERT_TRUE(OpenPlaygroundHere(callback)); } TEST_P(AiksTest, CanRenderDifferentShapesWithSameColorSource) { diff --git a/engine/src/flutter/impeller/aiks/paint.h b/engine/src/flutter/impeller/aiks/paint.h index b150c868e3b..ba01221e3b3 100644 --- a/engine/src/flutter/impeller/aiks/paint.h +++ b/engine/src/flutter/impeller/aiks/paint.h @@ -25,7 +25,7 @@ struct Paint { using MaskFilterProc = std::function(FilterInput::Ref, bool is_solid_color)>; - using ColorSourceProc = std::function()>; + using ColorSourceProc = std::function()>; enum class Style { kFill, diff --git a/engine/src/flutter/impeller/compiler/shader_lib/impeller/transform.glsl b/engine/src/flutter/impeller/compiler/shader_lib/impeller/transform.glsl new file mode 100644 index 00000000000..e57bdf0b141 --- /dev/null +++ b/engine/src/flutter/impeller/compiler/shader_lib/impeller/transform.glsl @@ -0,0 +1,14 @@ +// 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. + +#ifndef TRANSFORM_GLSL_ +#define TRANSFORM_GLSL_ + +/// Returns the Cartesian coordinates of `position` in `transform` space. +vec2 IPVec2TransformPosition(mat4 matrix, vec2 point) { + vec4 transformed = matrix * vec4(point, 0, 1); + return transformed.xy / transformed.w; +} + +#endif diff --git a/engine/src/flutter/impeller/display_list/display_list_dispatcher.cc b/engine/src/flutter/impeller/display_list/display_list_dispatcher.cc index e01b4d5c986..9f08a4bfc49 100644 --- a/engine/src/flutter/impeller/display_list/display_list_dispatcher.cc +++ b/engine/src/flutter/impeller/display_list/display_list_dispatcher.cc @@ -161,6 +161,17 @@ static impeller::SamplerDescriptor ToSamplerDescriptor( return desc; } +static 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 + }; +} + // |flutter::Dispatcher| void DisplayListDispatcher::setAntiAlias(bool aa) { // Nothing to do because AA is implicit. @@ -305,12 +316,14 @@ void DisplayListDispatcher::setColorSource( colors.emplace_back(ToColor(linear->colors()[i])); } auto tile_mode = ToTileMode(linear->tile_mode()); + auto matrix = ToMatrix(linear->matrix()); paint_.color_source = [start_point, end_point, colors = std::move(colors), - tile_mode]() { + tile_mode, matrix]() { auto contents = std::make_shared(); contents->SetEndPoints(start_point, end_point); contents->SetColors(std::move(colors)); contents->SetTileMode(tile_mode); + contents->SetMatrix(matrix); return contents; }; return; @@ -326,12 +339,14 @@ void DisplayListDispatcher::setColorSource( colors.emplace_back(ToColor(radialGradient->colors()[i])); } auto tile_mode = ToTileMode(radialGradient->tile_mode()); + auto matrix = ToMatrix(radialGradient->matrix()); paint_.color_source = [center, radius, colors = std::move(colors), - tile_mode]() { + tile_mode, matrix]() { auto contents = std::make_shared(); - contents->SetCenterAndRadius(center, radius), - contents->SetColors(std::move(colors)); + contents->SetCenterAndRadius(center, radius); + contents->SetColors(std::move(colors)); contents->SetTileMode(tile_mode); + contents->SetMatrix(matrix); return contents; }; return; @@ -349,12 +364,14 @@ void DisplayListDispatcher::setColorSource( colors.emplace_back(ToColor(sweepGradient->colors()[i])); } auto tile_mode = ToTileMode(sweepGradient->tile_mode()); + auto matrix = ToMatrix(sweepGradient->matrix()); paint_.color_source = [center, start_angle, end_angle, - colors = std::move(colors), tile_mode]() { + colors = std::move(colors), tile_mode, matrix]() { auto contents = std::make_shared(); contents->SetCenterAndAngles(center, start_angle, end_angle); contents->SetColors(std::move(colors)); contents->SetTileMode(tile_mode); + contents->SetMatrix(matrix); return contents; }; return; @@ -367,12 +384,14 @@ void DisplayListDispatcher::setColorSource( auto x_tile_mode = ToTileMode(image_color_source->horizontal_tile_mode()); auto y_tile_mode = ToTileMode(image_color_source->vertical_tile_mode()); auto desc = ToSamplerDescriptor(image_color_source->sampling()); - paint_.color_source = [texture, x_tile_mode, y_tile_mode, desc]() { + auto matrix = ToMatrix(image_color_source->matrix()); + paint_.color_source = [texture, x_tile_mode, y_tile_mode, desc, + matrix]() { auto contents = std::make_shared(); contents->SetTexture(texture); contents->SetTileModes(x_tile_mode, y_tile_mode); contents->SetSamplerDescriptor(desc); - // TODO(109384) Support 'matrix' parameter for all color sources. + contents->SetMatrix(matrix); return contents; }; return; diff --git a/engine/src/flutter/impeller/entity/BUILD.gn b/engine/src/flutter/impeller/entity/BUILD.gn index cce9b2e1383..8ac8d402be1 100644 --- a/engine/src/flutter/impeller/entity/BUILD.gn +++ b/engine/src/flutter/impeller/entity/BUILD.gn @@ -36,10 +36,9 @@ impeller_shaders("entity_shaders") { "shaders/gaussian_blur.vert", "shaders/glyph_atlas.frag", "shaders/glyph_atlas.vert", - "shaders/gradient_fill.frag", "shaders/gradient_fill.vert", + "shaders/linear_gradient_fill.frag", "shaders/radial_gradient_fill.frag", - "shaders/radial_gradient_fill.vert", "shaders/rrect_blur.vert", "shaders/rrect_blur.frag", "shaders/solid_fill.frag", @@ -47,7 +46,6 @@ impeller_shaders("entity_shaders") { "shaders/solid_stroke.frag", "shaders/solid_stroke.vert", "shaders/sweep_gradient_fill.frag", - "shaders/sweep_gradient_fill.vert", "shaders/texture_fill.frag", "shaders/texture_fill.vert", "shaders/tiled_texture_fill.frag", @@ -63,6 +61,8 @@ impeller_component("entity") { "contents/atlas_contents.h", "contents/clip_contents.cc", "contents/clip_contents.h", + "contents/color_source_contents.cc", + "contents/color_source_contents.h", "contents/content_context.cc", "contents/content_context.h", "contents/contents.cc", @@ -87,8 +87,6 @@ impeller_component("entity") { "contents/filters/inputs/texture_filter_input.h", "contents/linear_gradient_contents.cc", "contents/linear_gradient_contents.h", - "contents/path_contents.cc", - "contents/path_contents.h", "contents/radial_gradient_contents.cc", "contents/radial_gradient_contents.h", "contents/rrect_shadow_contents.cc", diff --git a/engine/src/flutter/impeller/entity/contents/color_source_contents.cc b/engine/src/flutter/impeller/entity/contents/color_source_contents.cc new file mode 100644 index 00000000000..3a8f26a29e7 --- /dev/null +++ b/engine/src/flutter/impeller/entity/contents/color_source_contents.cc @@ -0,0 +1,37 @@ +// 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 "color_source_contents.h" + +#include "impeller/entity/entity.h" +#include "impeller/geometry/matrix.h" + +namespace impeller { + +ColorSourceContents::ColorSourceContents() = default; + +ColorSourceContents::~ColorSourceContents() = default; + +void ColorSourceContents::SetPath(Path path) { + path_ = path; +} + +const Path& ColorSourceContents::GetPath() const { + return path_; +} + +void ColorSourceContents::SetMatrix(Matrix matrix) { + inverse_matrix_ = matrix.Invert(); +} + +const Matrix& ColorSourceContents::GetInverseMatrix() const { + return inverse_matrix_; +} + +std::optional ColorSourceContents::GetCoverage( + const Entity& entity) const { + return path_.GetTransformedBoundingBox(entity.GetTransformation()); +}; + +} // namespace impeller diff --git a/engine/src/flutter/impeller/entity/contents/color_source_contents.h b/engine/src/flutter/impeller/entity/contents/color_source_contents.h new file mode 100644 index 00000000000..94386bd111e --- /dev/null +++ b/engine/src/flutter/impeller/entity/contents/color_source_contents.h @@ -0,0 +1,39 @@ +// 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. + +#pragma once + +#include "flutter/fml/macros.h" +#include "impeller/entity/contents/contents.h" +#include "impeller/geometry/matrix.h" +#include "impeller/geometry/path.h" + +namespace impeller { + +class ColorSourceContents : public Contents { + public: + ColorSourceContents(); + + ~ColorSourceContents() override; + + void SetPath(Path path); + + void SetMatrix(Matrix matrix); + + // |Contents| + std::optional GetCoverage(const Entity& entity) const override; + + protected: + const Path& GetPath() const; + + const Matrix& GetInverseMatrix() const; + + private: + Path path_; + Matrix inverse_matrix_; + + FML_DISALLOW_COPY_AND_ASSIGN(ColorSourceContents); +}; + +} // namespace impeller diff --git a/engine/src/flutter/impeller/entity/contents/content_context.cc b/engine/src/flutter/impeller/entity/contents/content_context.cc index 3ab9ec79738..10d9bee9cc0 100644 --- a/engine/src/flutter/impeller/entity/contents/content_context.cc +++ b/engine/src/flutter/impeller/entity/contents/content_context.cc @@ -149,10 +149,10 @@ ContentContext::ContentContext(std::shared_ptr context) return; } - gradient_fill_pipelines_[{}] = - CreateDefaultPipeline(*context_); solid_fill_pipelines_[{}] = CreateDefaultPipeline(*context_); + linear_gradient_fill_pipelines_[{}] = + CreateDefaultPipeline(*context_); radial_gradient_fill_pipelines_[{}] = CreateDefaultPipeline(*context_); sweep_gradient_fill_pipelines_[{}] = diff --git a/engine/src/flutter/impeller/entity/contents/content_context.h b/engine/src/flutter/impeller/entity/contents/content_context.h index 98b50420c9d..194278a437b 100644 --- a/engine/src/flutter/impeller/entity/contents/content_context.h +++ b/engine/src/flutter/impeller/entity/contents/content_context.h @@ -40,10 +40,9 @@ #include "impeller/entity/gaussian_blur.vert.h" #include "impeller/entity/glyph_atlas.frag.h" #include "impeller/entity/glyph_atlas.vert.h" -#include "impeller/entity/gradient_fill.frag.h" #include "impeller/entity/gradient_fill.vert.h" +#include "impeller/entity/linear_gradient_fill.frag.h" #include "impeller/entity/radial_gradient_fill.frag.h" -#include "impeller/entity/radial_gradient_fill.vert.h" #include "impeller/entity/rrect_blur.frag.h" #include "impeller/entity/rrect_blur.vert.h" #include "impeller/entity/solid_fill.frag.h" @@ -51,7 +50,6 @@ #include "impeller/entity/solid_stroke.frag.h" #include "impeller/entity/solid_stroke.vert.h" #include "impeller/entity/sweep_gradient_fill.frag.h" -#include "impeller/entity/sweep_gradient_fill.vert.h" #include "impeller/entity/texture_fill.frag.h" #include "impeller/entity/texture_fill.vert.h" #include "impeller/entity/tiled_texture_fill.frag.h" @@ -62,14 +60,14 @@ namespace impeller { -using GradientFillPipeline = - PipelineT; +using LinearGradientFillPipeline = + PipelineT; using SolidFillPipeline = PipelineT; using RadialGradientFillPipeline = - PipelineT; + PipelineT; using SweepGradientFillPipeline = - PipelineT; + PipelineT; using BlendPipeline = PipelineT; using RRectBlurPipeline = PipelineT; @@ -160,9 +158,9 @@ class ContentContext { bool IsValid() const; - std::shared_ptr GetGradientFillPipeline( + std::shared_ptr GetLinearGradientFillPipeline( ContentContextOptions opts) const { - return GetPipeline(gradient_fill_pipelines_, opts); + return GetPipeline(linear_gradient_fill_pipelines_, opts); } std::shared_ptr GetRadialGradientFillPipeline( @@ -335,8 +333,8 @@ class ContentContext { // These are mutable because while the prototypes are created eagerly, any // variants requested from that are lazily created and cached in the variants // map. - mutable Variants gradient_fill_pipelines_; mutable Variants solid_fill_pipelines_; + mutable Variants linear_gradient_fill_pipelines_; mutable Variants radial_gradient_fill_pipelines_; mutable Variants sweep_gradient_fill_pipelines_; mutable Variants rrect_blur_pipelines_; diff --git a/engine/src/flutter/impeller/entity/contents/linear_gradient_contents.cc b/engine/src/flutter/impeller/entity/contents/linear_gradient_contents.cc index 374e990d4e5..7eb09622eb6 100644 --- a/engine/src/flutter/impeller/entity/contents/linear_gradient_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/linear_gradient_contents.cc @@ -16,10 +16,6 @@ LinearGradientContents::LinearGradientContents() = default; LinearGradientContents::~LinearGradientContents() = default; -void LinearGradientContents::SetPath(Path path) { - path_ = std::move(path); -} - void LinearGradientContents::SetEndPoints(Point start_point, Point end_point) { start_point_ = start_point; end_point_ = end_point; @@ -43,26 +39,21 @@ const std::vector& LinearGradientContents::GetColors() const { return colors_; } -std::optional LinearGradientContents::GetCoverage( - const Entity& entity) const { - return path_.GetTransformedBoundingBox(entity.GetTransformation()); -}; - bool LinearGradientContents::Render(const ContentContext& renderer, const Entity& entity, RenderPass& pass) const { - using VS = GradientFillPipeline::VertexShader; - using FS = GradientFillPipeline::FragmentShader; + using VS = LinearGradientFillPipeline::VertexShader; + using FS = LinearGradientFillPipeline::FragmentShader; auto vertices_builder = VertexBufferBuilder(); { - auto result = - Tessellator{}.Tessellate(path_.GetFillType(), path_.CreatePolyline(), - [&vertices_builder](Point point) { - VS::PerVertexData vtx; - vtx.vertices = point; - vertices_builder.AppendVertex(vtx); - }); + auto result = Tessellator{}.Tessellate(GetPath().GetFillType(), + GetPath().CreatePolyline(), + [&vertices_builder](Point point) { + VS::PerVertexData vtx; + vtx.position = point; + vertices_builder.AppendVertex(vtx); + }); if (result == Tessellator::Result::kInputError) { return true; @@ -75,6 +66,7 @@ bool LinearGradientContents::Render(const ContentContext& renderer, VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * entity.GetTransformation(); + frame_info.matrix = GetInverseMatrix(); FS::GradientInfo gradient_info; gradient_info.start_point = start_point_; @@ -85,8 +77,8 @@ bool LinearGradientContents::Render(const ContentContext& renderer, Command cmd; cmd.label = "LinearGradientFill"; - cmd.pipeline = - renderer.GetGradientFillPipeline(OptionsFromPassAndEntity(pass, entity)); + cmd.pipeline = renderer.GetLinearGradientFillPipeline( + OptionsFromPassAndEntity(pass, entity)); cmd.stencil_reference = entity.GetStencilDepth(); cmd.BindVertices( vertices_builder.CreateVertexBuffer(pass.GetTransientsBuffer())); diff --git a/engine/src/flutter/impeller/entity/contents/linear_gradient_contents.h b/engine/src/flutter/impeller/entity/contents/linear_gradient_contents.h index 71605fdd0fd..4ba2c82afce 100644 --- a/engine/src/flutter/impeller/entity/contents/linear_gradient_contents.h +++ b/engine/src/flutter/impeller/entity/contents/linear_gradient_contents.h @@ -9,7 +9,7 @@ #include #include "flutter/fml/macros.h" -#include "impeller/entity/contents/path_contents.h" +#include "impeller/entity/contents/color_source_contents.h" #include "impeller/entity/entity.h" #include "impeller/geometry/color.h" #include "impeller/geometry/path.h" @@ -17,17 +17,12 @@ namespace impeller { -class LinearGradientContents final : public PathContents { +class LinearGradientContents final : public ColorSourceContents { public: LinearGradientContents(); ~LinearGradientContents() override; - void SetPath(Path path) override; - - // |Contents| - std::optional GetCoverage(const Entity& entity) const override; - // |Contents| bool Render(const ContentContext& renderer, const Entity& entity, @@ -42,7 +37,6 @@ class LinearGradientContents final : public PathContents { const std::vector& GetColors() const; private: - Path path_; Point start_point_; Point end_point_; std::vector colors_; diff --git a/engine/src/flutter/impeller/entity/contents/path_contents.cc b/engine/src/flutter/impeller/entity/contents/path_contents.cc deleted file mode 100644 index afa956a8cdb..00000000000 --- a/engine/src/flutter/impeller/entity/contents/path_contents.cc +++ /dev/null @@ -1,13 +0,0 @@ -// 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 "path_contents.h" - -namespace impeller { - -PathContents::PathContents() = default; - -PathContents::~PathContents() = default; - -} // namespace impeller diff --git a/engine/src/flutter/impeller/entity/contents/path_contents.h b/engine/src/flutter/impeller/entity/contents/path_contents.h deleted file mode 100644 index f02430570f6..00000000000 --- a/engine/src/flutter/impeller/entity/contents/path_contents.h +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -#pragma once - -#include "flutter/fml/macros.h" -#include "impeller/entity/contents/contents.h" -#include "impeller/geometry/path.h" - -namespace impeller { - -class PathContents : public Contents { - public: - PathContents(); - - ~PathContents() override; - - virtual void SetPath(Path path) = 0; - - FML_DISALLOW_COPY_AND_ASSIGN(PathContents); -}; - -} // namespace impeller diff --git a/engine/src/flutter/impeller/entity/contents/radial_gradient_contents.cc b/engine/src/flutter/impeller/entity/contents/radial_gradient_contents.cc index e39b622dc4a..605a5fe81d5 100644 --- a/engine/src/flutter/impeller/entity/contents/radial_gradient_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/radial_gradient_contents.cc @@ -16,10 +16,6 @@ RadialGradientContents::RadialGradientContents() = default; RadialGradientContents::~RadialGradientContents() = default; -void RadialGradientContents::SetPath(Path path) { - path_ = std::move(path); -} - void RadialGradientContents::SetCenterAndRadius(Point center, Scalar radius) { center_ = center; radius_ = radius; @@ -43,11 +39,6 @@ const std::vector& RadialGradientContents::GetColors() const { return colors_; } -std::optional RadialGradientContents::GetCoverage( - const Entity& entity) const { - return path_.GetTransformedBoundingBox(entity.GetTransformation()); -}; - bool RadialGradientContents::Render(const ContentContext& renderer, const Entity& entity, RenderPass& pass) const { @@ -56,13 +47,13 @@ bool RadialGradientContents::Render(const ContentContext& renderer, auto vertices_builder = VertexBufferBuilder(); { - auto result = - Tessellator{}.Tessellate(path_.GetFillType(), path_.CreatePolyline(), - [&vertices_builder](Point point) { - VS::PerVertexData vtx; - vtx.vertices = point; - vertices_builder.AppendVertex(vtx); - }); + auto result = Tessellator{}.Tessellate(GetPath().GetFillType(), + GetPath().CreatePolyline(), + [&vertices_builder](Point point) { + VS::PerVertexData vtx; + vtx.position = point; + vertices_builder.AppendVertex(vtx); + }); if (result == Tessellator::Result::kInputError) { return true; @@ -75,6 +66,7 @@ bool RadialGradientContents::Render(const ContentContext& renderer, VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * entity.GetTransformation(); + frame_info.matrix = GetInverseMatrix(); FS::GradientInfo gradient_info; gradient_info.center = center_; diff --git a/engine/src/flutter/impeller/entity/contents/radial_gradient_contents.h b/engine/src/flutter/impeller/entity/contents/radial_gradient_contents.h index 7db7cef5adf..226e9d8b7b5 100644 --- a/engine/src/flutter/impeller/entity/contents/radial_gradient_contents.h +++ b/engine/src/flutter/impeller/entity/contents/radial_gradient_contents.h @@ -9,7 +9,7 @@ #include #include "flutter/fml/macros.h" -#include "impeller/entity/contents/path_contents.h" +#include "impeller/entity/contents/color_source_contents.h" #include "impeller/entity/entity.h" #include "impeller/geometry/color.h" #include "impeller/geometry/path.h" @@ -17,17 +17,12 @@ namespace impeller { -class RadialGradientContents final : public PathContents { +class RadialGradientContents final : public ColorSourceContents { public: RadialGradientContents(); ~RadialGradientContents() override; - void SetPath(Path path) override; - - // |Contents| - std::optional GetCoverage(const Entity& entity) const override; - // |Contents| bool Render(const ContentContext& renderer, const Entity& entity, @@ -42,7 +37,6 @@ class RadialGradientContents final : public PathContents { const std::vector& GetColors() const; private: - Path path_; Point center_; Scalar radius_; std::vector colors_; diff --git a/engine/src/flutter/impeller/entity/contents/sweep_gradient_contents.cc b/engine/src/flutter/impeller/entity/contents/sweep_gradient_contents.cc index d3874e1095b..a5b332d239e 100644 --- a/engine/src/flutter/impeller/entity/contents/sweep_gradient_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/sweep_gradient_contents.cc @@ -16,10 +16,6 @@ SweepGradientContents::SweepGradientContents() = default; SweepGradientContents::~SweepGradientContents() = default; -void SweepGradientContents::SetPath(Path path) { - path_ = std::move(path); -} - void SweepGradientContents::SetCenterAndAngles(Point center, Degrees start_angle, Degrees end_angle) { @@ -49,11 +45,6 @@ const std::vector& SweepGradientContents::GetColors() const { return colors_; } -std::optional SweepGradientContents::GetCoverage( - const Entity& entity) const { - return path_.GetTransformedBoundingBox(entity.GetTransformation()); -}; - bool SweepGradientContents::Render(const ContentContext& renderer, const Entity& entity, RenderPass& pass) const { @@ -62,13 +53,13 @@ bool SweepGradientContents::Render(const ContentContext& renderer, auto vertices_builder = VertexBufferBuilder(); { - auto result = - Tessellator{}.Tessellate(path_.GetFillType(), path_.CreatePolyline(), - [&vertices_builder](Point point) { - VS::PerVertexData vtx; - vtx.vertices = point; - vertices_builder.AppendVertex(vtx); - }); + auto result = Tessellator{}.Tessellate(GetPath().GetFillType(), + GetPath().CreatePolyline(), + [&vertices_builder](Point point) { + VS::PerVertexData vtx; + vtx.position = point; + vertices_builder.AppendVertex(vtx); + }); if (result == Tessellator::Result::kInputError) { return true; @@ -81,6 +72,7 @@ bool SweepGradientContents::Render(const ContentContext& renderer, VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * entity.GetTransformation(); + frame_info.matrix = GetInverseMatrix(); FS::GradientInfo gradient_info; gradient_info.center = center_; diff --git a/engine/src/flutter/impeller/entity/contents/sweep_gradient_contents.h b/engine/src/flutter/impeller/entity/contents/sweep_gradient_contents.h index cfd21249b49..2a2b345f740 100644 --- a/engine/src/flutter/impeller/entity/contents/sweep_gradient_contents.h +++ b/engine/src/flutter/impeller/entity/contents/sweep_gradient_contents.h @@ -9,7 +9,7 @@ #include #include "flutter/fml/macros.h" -#include "impeller/entity/contents/path_contents.h" +#include "impeller/entity/contents/color_source_contents.h" #include "impeller/entity/entity.h" #include "impeller/geometry/color.h" #include "impeller/geometry/path.h" @@ -18,17 +18,12 @@ namespace impeller { -class SweepGradientContents final : public PathContents { +class SweepGradientContents final : public ColorSourceContents { public: SweepGradientContents(); ~SweepGradientContents() override; - void SetPath(Path path) override; - - // |Contents| - std::optional GetCoverage(const Entity& entity) const override; - // |Contents| bool Render(const ContentContext& renderer, const Entity& entity, @@ -43,7 +38,6 @@ class SweepGradientContents final : public PathContents { const std::vector& GetColors() const; private: - Path path_; Point center_; Scalar bias_; Scalar scale_; diff --git a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.cc b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.cc index c3b6521ca97..d6eacd3385e 100644 --- a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.cc @@ -17,10 +17,6 @@ TiledTextureContents::TiledTextureContents() = default; TiledTextureContents::~TiledTextureContents() = default; -void TiledTextureContents::SetPath(Path path) { - path_ = std::move(path); -} - void TiledTextureContents::SetTexture(std::shared_ptr texture) { texture_ = std::move(texture); } @@ -35,11 +31,6 @@ void TiledTextureContents::SetSamplerDescriptor(SamplerDescriptor desc) { sampler_descriptor_ = std::move(desc); } -std::optional TiledTextureContents::GetCoverage( - const Entity& entity) const { - return path_.GetTransformedBoundingBox(entity.GetTransformation()); -}; - bool TiledTextureContents::Render(const ContentContext& renderer, const Entity& entity, RenderPass& pass) const { @@ -50,7 +41,7 @@ bool TiledTextureContents::Render(const ContentContext& renderer, using VS = TiledTextureFillVertexShader; using FS = TiledTextureFillFragmentShader; - const auto coverage_rect = path_.GetBoundingBox(); + const auto coverage_rect = GetPath().GetBoundingBox(); if (!coverage_rect.has_value()) { return true; @@ -67,14 +58,13 @@ bool TiledTextureContents::Render(const ContentContext& renderer, VertexBufferBuilder vertex_builder; { - const auto tess_result = - Tessellator{}.Tessellate(path_.GetFillType(), path_.CreatePolyline(), - [&vertex_builder, &texture_size](Point vtx) { - VS::PerVertexData data; - data.position = vtx; - data.texture_coords = vtx / texture_size; - vertex_builder.AppendVertex(data); - }); + const auto tess_result = Tessellator{}.Tessellate( + GetPath().GetFillType(), GetPath().CreatePolyline(), + [&vertex_builder](Point vtx) { + VS::PerVertexData data; + data.position = vtx; + vertex_builder.AppendVertex(data); + }); if (tess_result == Tessellator::Result::kInputError) { return true; @@ -93,6 +83,9 @@ bool TiledTextureContents::Render(const ContentContext& renderer, VS::VertInfo vert_info; vert_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * entity.GetTransformation(); + vert_info.matrix = GetInverseMatrix(); + vert_info.texture_size = Vector2{static_cast(texture_size.width), + static_cast(texture_size.height)}; FS::FragInfo frag_info; frag_info.texture_sampler_y_coord_scale = texture_->GetYCoordScale(); diff --git a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.h b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.h index 378ff9051eb..95806119c29 100644 --- a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.h +++ b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents.h @@ -9,24 +9,19 @@ #include #include "flutter/fml/macros.h" -#include "impeller/entity/contents/path_contents.h" +#include "impeller/entity/contents/color_source_contents.h" #include "impeller/entity/entity.h" #include "impeller/geometry/path.h" #include "impeller/renderer/sampler_descriptor.h" namespace impeller { -class TiledTextureContents final : public PathContents { +class TiledTextureContents final : public ColorSourceContents { public: TiledTextureContents(); ~TiledTextureContents() override; - void SetPath(Path path) override; - - // |Contents| - std::optional GetCoverage(const Entity& entity) const override; - // |Contents| bool Render(const ContentContext& renderer, const Entity& entity, @@ -39,7 +34,6 @@ class TiledTextureContents final : public PathContents { void SetSamplerDescriptor(SamplerDescriptor desc); private: - Path path_; std::shared_ptr texture_; SamplerDescriptor sampler_descriptor_ = {}; Entity::TileMode x_tile_mode_; diff --git a/engine/src/flutter/impeller/entity/shaders/gradient_fill.vert b/engine/src/flutter/impeller/entity/shaders/gradient_fill.vert index f9d0ccdabfc..4b793dbfa18 100644 --- a/engine/src/flutter/impeller/entity/shaders/gradient_fill.vert +++ b/engine/src/flutter/impeller/entity/shaders/gradient_fill.vert @@ -2,15 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + uniform FrameInfo { mat4 mvp; + mat4 matrix; } frame_info; -in vec2 vertices; +in vec2 position; -out vec2 interpolated_vertices; +out vec2 v_position; void main() { - gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0); - interpolated_vertices = vertices; + gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0); + v_position = IPVec2TransformPosition(frame_info.matrix, position); } diff --git a/engine/src/flutter/impeller/entity/shaders/gradient_fill.frag b/engine/src/flutter/impeller/entity/shaders/linear_gradient_fill.frag similarity index 90% rename from engine/src/flutter/impeller/entity/shaders/gradient_fill.frag rename to engine/src/flutter/impeller/entity/shaders/linear_gradient_fill.frag index 407cd98bc2d..5282d4d623b 100644 --- a/engine/src/flutter/impeller/entity/shaders/gradient_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/linear_gradient_fill.frag @@ -12,14 +12,14 @@ uniform GradientInfo { float tile_mode; } gradient_info; -in vec2 interpolated_vertices; +in vec2 v_position; out vec4 frag_color; void main() { float len = length(gradient_info.end_point - gradient_info.start_point); float dot = dot( - interpolated_vertices - gradient_info.start_point, + v_position - gradient_info.start_point, gradient_info.end_point - gradient_info.start_point ); float t = dot / (len * len); diff --git a/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.frag b/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.frag index 07a7f9eeb39..3804d2f9bba 100644 --- a/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.frag @@ -12,12 +12,12 @@ uniform GradientInfo { float tile_mode; } gradient_info; -in vec2 interpolated_vertices; +in vec2 v_position; out vec4 frag_color; void main() { - float len = length(interpolated_vertices - gradient_info.center); + float len = length(v_position - gradient_info.center); float t = len / gradient_info.radius; if ((t < 0.0 || t > 1.0) && gradient_info.tile_mode == kTileModeDecal) { frag_color = vec4(0); diff --git a/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.vert b/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.vert deleted file mode 100644 index f9d0ccdabfc..00000000000 --- a/engine/src/flutter/impeller/entity/shaders/radial_gradient_fill.vert +++ /dev/null @@ -1,16 +0,0 @@ -// 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. - -uniform FrameInfo { - mat4 mvp; -} frame_info; - -in vec2 vertices; - -out vec2 interpolated_vertices; - -void main() { - gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0); - interpolated_vertices = vertices; -} diff --git a/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.frag b/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.frag index 8a7365d0c29..f7ab313319c 100644 --- a/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.frag +++ b/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.frag @@ -14,12 +14,12 @@ uniform GradientInfo { float tile_mode; } gradient_info; -in vec2 interpolated_vertices; +in vec2 v_position; out vec4 frag_color; void main() { - vec2 coord = interpolated_vertices - gradient_info.center; + vec2 coord = v_position - gradient_info.center; float angle = atan(-coord.y, -coord.x); float t = (angle * k1Over2Pi + 0.5 + gradient_info.bias) * gradient_info.scale; diff --git a/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.vert b/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.vert deleted file mode 100644 index f9d0ccdabfc..00000000000 --- a/engine/src/flutter/impeller/entity/shaders/sweep_gradient_fill.vert +++ /dev/null @@ -1,16 +0,0 @@ -// 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. - -uniform FrameInfo { - mat4 mvp; -} frame_info; - -in vec2 vertices; - -out vec2 interpolated_vertices; - -void main() { - gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0); - interpolated_vertices = vertices; -} diff --git a/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.vert b/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.vert index c8abc9aaabb..db737699400 100644 --- a/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.vert +++ b/engine/src/flutter/impeller/entity/shaders/tiled_texture_fill.vert @@ -2,17 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + uniform VertInfo { mat4 mvp; + mat4 matrix; + vec2 texture_size; } vert_info; in vec2 position; -in vec2 texture_coords; out vec2 v_texture_coords; void main() { gl_Position = vert_info.mvp * vec4(position, 0.0, 1.0); - v_texture_coords = texture_coords; + vec2 transformed = IPVec2TransformPosition(vert_info.matrix, position); + v_texture_coords = transformed / vert_info.texture_size; }