Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Merge branch 'main' into surface_producer_platform_views
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmccutchan authored Dec 19, 2023
2 parents e90c27c + bde7c61 commit 8b212a8
Show file tree
Hide file tree
Showing 50 changed files with 536 additions and 753 deletions.
6 changes: 3 additions & 3 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ targets:

- name: Linux mac_android_aot_engine
recipe: engine_v2/engine_v2
timeout: 120
timeout: 240
properties:
add_recipes_cq: "true"
release_build: "true"
Expand Down Expand Up @@ -353,7 +353,7 @@ targets:

- name: Mac mac_host_engine
recipe: engine_v2/engine_v2
timeout: 120
timeout: 240
properties:
add_recipes_cq: "true"
release_build: "true"
Expand All @@ -379,7 +379,7 @@ targets:

- name: Mac mac_ios_engine
recipe: engine_v2/engine_v2
timeout: 120
timeout: 240
properties:
add_recipes_cq: "true"
release_build: "true"
Expand Down
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ vars = {
'llvm_git': 'https://llvm.googlesource.com',
# OCMock is for testing only so there is no google clone
'ocmock_git': 'https://github.com/erikdoe/ocmock.git',
'skia_revision': '4b2639427e7e1a2fdd87a6c4401722fe5a8680cb',
'skia_revision': '27ab8a8d2a0d6d6650ed8113a3608f629526e8e5',

# WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY
# See `lib/web_ui/README.md` for how to roll CanvasKit to a new version.
Expand Down Expand Up @@ -66,7 +66,7 @@ vars = {
# Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS
# You can use //tools/dart/create_updated_flutter_deps.py to produce
# updated revision list of existing dependencies.
'dart_revision': 'e1a26302800d2e9c9bd7d65744bf89d2d54de158',
'dart_revision': 'b21443096387b281a14e947b300df3e9f91054f2',

# WARNING: DO NOT EDIT MANUALLY
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py
Expand Down
5 changes: 3 additions & 2 deletions build/secondary/third_party/libcxx/config/__config_site
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef _LIBCPP_CONFIG_SITE
#define _LIBCPP_CONFIG_SITE

/* #undef _LIBCPP_ABI_VERSION */
/* #undef _LIBCPP_ABI_UNSTABLE */
#define _LIBCPP_ABI_VERSION 1
#define _LIBCPP_ABI_NAMESPACE _fl

/* #undef _LIBCPP_ABI_FORCE_ITANIUM */
/* #undef _LIBCPP_ABI_FORCE_MICROSOFT */
/* #undef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT */
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/licenses_dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: d99bcb9a47be134ddce44fd02437b94c
Signature: 06486b08d62f2d74956d6d88fab85d66

====================================================================================================
LIBRARY: dart
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/licenses_skia
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: a1c63268f5cc6b22cc16f9dc839f5745
Signature: 16cc4ef5c1af101923d051b79aff4789

====================================================================================================
LIBRARY: etc1
Expand Down
7 changes: 3 additions & 4 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void Canvas::DrawRect(const Rect& rect, const Paint& paint) {
void Canvas::DrawOval(const Rect& rect, const Paint& paint) {
if (rect.IsSquare()) {
// Circles have slightly less overhead and can do stroking
DrawCircle(rect.GetCenter(), rect.GetSize().width * 0.5f, paint);
DrawCircle(rect.GetCenter(), rect.GetWidth() * 0.5f, paint);
return;
}

Expand Down Expand Up @@ -471,10 +471,9 @@ void Canvas::ClipOval(const Rect& bounds, Entity::ClipOperation clip_op) {
void Canvas::ClipRRect(const Rect& rect,
const Size& corner_radii,
Entity::ClipOperation clip_op) {
auto size = rect.GetSize();
// Does the rounded rect have a flat part on the top/bottom or left/right?
bool flat_on_TB = corner_radii.width * 2 < size.width;
bool flat_on_LR = corner_radii.height * 2 < size.height;
bool flat_on_TB = corner_radii.width * 2 < rect.GetWidth();
bool flat_on_LR = corner_radii.height * 2 < rect.GetHeight();
auto geometry = Geometry::MakeRoundRect(rect, corner_radii);
auto& cull_rect = transform_stack_.back().cull_rect;
if (clip_op == Entity::ClipOperation::kIntersect && //
Expand Down
39 changes: 16 additions & 23 deletions impeller/entity/contents/atlas_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ struct AtlasBlenderKey {

struct Hash {
std::size_t operator()(const AtlasBlenderKey& key) const {
return fml::HashCombine(key.color_key, key.rect.size.width,
key.rect.size.height, key.rect.origin.x,
key.rect.origin.y);
return fml::HashCombine(key.color_key, key.rect.GetWidth(),
key.rect.GetHeight(), key.rect.GetX(),
key.rect.GetY());
}
};

Expand Down Expand Up @@ -124,18 +124,18 @@ std::shared_ptr<SubAtlasResult> AtlasContents::GenerateSubAtlas() const {
auto key = it->first;
auto transforms = it->second;

auto new_rect = Rect::MakeXYWH(x_offset, y_offset, key.rect.size.width,
key.rect.size.height);
auto new_rect = Rect::MakeXYWH(x_offset, y_offset, key.rect.GetWidth(),
key.rect.GetHeight());
auto sub_transform = Matrix::MakeTranslation(Vector2(x_offset, y_offset));

x_offset += std::ceil(key.rect.size.width) + 1.0;
x_offset += std::ceil(key.rect.GetWidth()) + 1.0;

result->sub_texture_coords.push_back(key.rect);
result->sub_colors.push_back(key.color);
result->sub_transforms.push_back(sub_transform);

x_extent = std::max(x_extent, x_offset);
y_extent = std::max(y_extent, std::ceil(y_offset + key.rect.size.height));
y_extent = std::max(y_extent, std::ceil(y_offset + key.rect.GetHeight()));

for (auto transform : transforms) {
result->result_texture_coords.push_back(new_rect);
Expand All @@ -159,7 +159,8 @@ Rect AtlasContents::ComputeBoundingBox() const {
for (size_t i = 0; i < texture_coords_.size(); i++) {
auto matrix = transforms_[i];
auto sample_rect = texture_coords_[i];
auto bounds = Rect::MakeSize(sample_rect.size).TransformBounds(matrix);
auto bounds =
Rect::MakeSize(sample_rect.GetSize()).TransformBounds(matrix);
bounding_box = bounds.Union(bounding_box);
}
bounding_box_cache_ = bounding_box;
Expand Down Expand Up @@ -213,8 +214,6 @@ bool AtlasContents::Render(const ContentContext& renderer,
}

constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
constexpr Scalar width[6] = {0, 1, 0, 1, 0, 1};
constexpr Scalar height[6] = {0, 0, 1, 0, 1, 1};

if (blend_mode_ <= BlendMode::kModulate) {
// Simple Porter-Duff blends can be accomplished without a subpass.
Expand All @@ -229,16 +228,14 @@ bool AtlasContents::Render(const ContentContext& renderer,
for (size_t i = 0; i < texture_coords_.size(); i++) {
auto sample_rect = texture_coords_[i];
auto matrix = transforms_[i];
auto points = sample_rect.GetPoints();
auto transformed_points =
Rect::MakeSize(sample_rect.size).GetTransformedPoints(matrix);
Rect::MakeSize(sample_rect.GetSize()).GetTransformedPoints(matrix);
auto color = colors_[i].Premultiply();
for (size_t j = 0; j < 6; j++) {
VS::PerVertexData data;
data.vertices = transformed_points[indices[j]];
data.texture_coords =
(sample_rect.origin + Point(sample_rect.size.width * width[j],
sample_rect.size.height * height[j])) /
texture_size;
data.texture_coords = points[indices[j]] / texture_size;
data.color = color;
vtx_builder.AppendVertex(data);
}
Expand Down Expand Up @@ -387,21 +384,17 @@ bool AtlasTextureContents::Render(const ContentContext& renderer,
VertexBufferBuilder<VS::PerVertexData> vertex_builder;
vertex_builder.Reserve(texture_coords.size() * 6);
constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
constexpr Scalar width[6] = {0, 1, 0, 1, 0, 1};
constexpr Scalar height[6] = {0, 0, 1, 0, 1, 1};
for (size_t i = 0; i < texture_coords.size(); i++) {
auto sample_rect = texture_coords[i];
auto matrix = transforms[i];
auto points = sample_rect.GetPoints();
auto transformed_points =
Rect::MakeSize(sample_rect.size).GetTransformedPoints(matrix);
Rect::MakeSize(sample_rect.GetSize()).GetTransformedPoints(matrix);

for (size_t j = 0; j < 6; j++) {
VS::PerVertexData data;
data.position = transformed_points[indices[j]];
data.texture_coords =
(sample_rect.origin + Point(sample_rect.size.width * width[j],
sample_rect.size.height * height[j])) /
texture_size;
data.texture_coords = points[indices[j]] / texture_size;
vertex_builder.AppendVertex(data);
}
}
Expand Down Expand Up @@ -484,7 +477,7 @@ bool AtlasColorContents::Render(const ContentContext& renderer,
auto sample_rect = texture_coords[i];
auto matrix = transforms[i];
auto transformed_points =
Rect::MakeSize(sample_rect.size).GetTransformedPoints(matrix);
Rect::MakeSize(sample_rect.GetSize()).GetTransformedPoints(matrix);

for (size_t j = 0; j < 6; j++) {
VS::PerVertexData data;
Expand Down
6 changes: 3 additions & 3 deletions impeller/entity/contents/contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ std::optional<Snapshot> Contents::RenderToSnapshot(
}

auto texture = renderer.MakeSubpass(
label, ISize::Ceil(coverage->size),
label, ISize::Ceil(coverage->GetSize()),
[&contents = *this, &entity, &coverage](const ContentContext& renderer,
RenderPass& pass) -> bool {
Entity sub_entity;
sub_entity.SetBlendMode(BlendMode::kSourceOver);
sub_entity.SetTransform(
Matrix::MakeTranslation(Vector3(-coverage->origin)) *
Matrix::MakeTranslation(Vector3(-coverage->GetOrigin())) *
entity.GetTransform());
return contents.Render(renderer, sub_entity, pass);
},
Expand All @@ -98,7 +98,7 @@ std::optional<Snapshot> Contents::RenderToSnapshot(

auto snapshot = Snapshot{
.texture = texture,
.transform = Matrix::MakeTranslation(coverage->origin),
.transform = Matrix::MakeTranslation(coverage->GetOrigin()),
};
if (sampler_descriptor.has_value()) {
snapshot.sampler_descriptor = sampler_descriptor.value();
Expand Down
24 changes: 12 additions & 12 deletions impeller/entity/contents/filters/blend_filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ static std::optional<Entity> AdvancedBlend(
auto blend_uniform = host_buffer.EmplaceUniform(blend_info);
FS::BindBlendInfo(cmd, blend_uniform);

frame_info.mvp =
Matrix::MakeOrthographic(size) *
Matrix::MakeTranslation(coverage.origin - subpass_coverage.origin);
frame_info.mvp = Matrix::MakeOrthographic(size) *
Matrix::MakeTranslation(coverage.GetOrigin() -
subpass_coverage.GetOrigin());

auto uniform_view = host_buffer.EmplaceUniform(frame_info);
VS::BindFrameInfo(cmd, uniform_view);
Expand All @@ -224,15 +224,15 @@ static std::optional<Entity> AdvancedBlend(
};

auto out_texture = renderer.MakeSubpass(
"Advanced Blend Filter", ISize(subpass_coverage.size), callback);
"Advanced Blend Filter", ISize(subpass_coverage.GetSize()), callback);
if (!out_texture) {
return std::nullopt;
}

return Entity::FromSnapshot(
Snapshot{
.texture = out_texture,
.transform = Matrix::MakeTranslation(subpass_coverage.origin),
.transform = Matrix::MakeTranslation(subpass_coverage.GetOrigin()),
// Since we absorbed the transform of the inputs and used the
// respective snapshot sampling modes when blending, pass on
// the default NN clamp sampler.
Expand Down Expand Up @@ -274,8 +274,8 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
}
auto dst_uvs = maybe_dst_uvs.value();

auto size = coverage.size;
auto origin = coverage.origin;
auto size = coverage.GetSize();
auto origin = coverage.GetOrigin();
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
vtx_builder.AddVertices({
{origin, dst_uvs[0], dst_uvs[0]},
Expand Down Expand Up @@ -444,8 +444,8 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
}
auto dst_uvs = maybe_dst_uvs.value();

auto size = coverage.size;
auto origin = coverage.origin;
auto size = coverage.GetSize();
auto origin = coverage.GetOrigin();
auto color = foreground_color.Premultiply();
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
vtx_builder.AddVertices({
Expand Down Expand Up @@ -587,7 +587,7 @@ static std::optional<Entity> PipelineBlend(

VS::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
Matrix::MakeTranslation(-subpass_coverage.origin) *
Matrix::MakeTranslation(-subpass_coverage.GetOrigin()) *
input->transform;
frame_info.texture_sampler_y_coord_scale =
input->texture->GetYCoordScale();
Expand Down Expand Up @@ -647,7 +647,7 @@ static std::optional<Entity> PipelineBlend(
};

auto out_texture = renderer.MakeSubpass(
"Pipeline Blend Filter", ISize(subpass_coverage.size), callback);
"Pipeline Blend Filter", ISize(subpass_coverage.GetSize()), callback);

if (!out_texture) {
return std::nullopt;
Expand All @@ -656,7 +656,7 @@ static std::optional<Entity> PipelineBlend(
return Entity::FromSnapshot(
Snapshot{
.texture = out_texture,
.transform = Matrix::MakeTranslation(subpass_coverage.origin),
.transform = Matrix::MakeTranslation(subpass_coverage.GetOrigin()),
// Since we absorbed the transform of the inputs and used the
// respective snapshot sampling modes when blending, pass on
// the default NN clamp sampler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,13 @@ std::optional<Entity> BorderMaskBlurFilterContents::RenderFilter(
auto& host_buffer = pass.GetTransientsBuffer();

VertexBufferBuilder<VS::PerVertexData> vtx_builder;
auto origin = coverage.GetOrigin();
auto size = coverage.GetSize();
vtx_builder.AddVertices({
{coverage.origin, input_uvs[0]},
{{coverage.origin.x + coverage.size.width, coverage.origin.y},
input_uvs[1]},
{{coverage.origin.x, coverage.origin.y + coverage.size.height},
input_uvs[2]},
{{coverage.origin.x + coverage.size.width,
coverage.origin.y + coverage.size.height},
input_uvs[3]},
{origin, input_uvs[0]},
{{origin.x + size.width, origin.y}, input_uvs[1]},
{{origin.x, origin.y + size.height}, input_uvs[2]},
{{origin.x + size.width, origin.y + size.height}, input_uvs[3]},
});

Command cmd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ std::optional<Entity> DirectionalGaussianBlurFilterContents::RenderFilter(
// projection and as a source for the pass size. Note that it doesn't matter
// which direction the space is rotated in when grabbing the pass size.
auto pass_texture_rect = Rect::MakeSize(input_snapshot->texture->GetSize())
.TransformBounds(pass_transform);
pass_texture_rect.origin.x -= transformed_blur_radius_length;
pass_texture_rect.size.width += transformed_blur_radius_length * 2;
.TransformBounds(pass_transform)
.Expand(transformed_blur_radius_length, 0);

// UV mapping.

Expand Down Expand Up @@ -183,7 +182,7 @@ std::optional<Entity> DirectionalGaussianBlurFilterContents::RenderFilter(
// The blur direction is in input UV space.
frag_info.blur_uv_offset =
pass_transform.Invert().TransformDirection(Vector2(1, 0)).Normalize() /
Point(input_snapshot->GetCoverage().value().size);
Point(input_snapshot->GetCoverage().value().GetSize());

Command cmd;
DEBUG_COMMAND_INFO(cmd, SPrintF("Gaussian Blur Filter (Radius=%.2f)",
Expand Down Expand Up @@ -254,7 +253,7 @@ std::optional<Entity> DirectionalGaussianBlurFilterContents::RenderFilter(
scale.y = scale_curve(y_radius);
}

Vector2 scaled_size = pass_texture_rect.size * scale;
Vector2 scaled_size = pass_texture_rect.GetSize() * scale;
ISize floored_size = ISize(scaled_size.x, scaled_size.y);

auto out_texture = renderer.MakeSubpass("Directional Gaussian Blur Filter",
Expand All @@ -271,13 +270,14 @@ std::optional<Entity> DirectionalGaussianBlurFilterContents::RenderFilter(
sampler_desc.width_address_mode = SamplerAddressMode::kClampToEdge;

return Entity::FromSnapshot(
Snapshot{.texture = out_texture,
.transform = texture_rotate.Invert() *
Matrix::MakeTranslation(pass_texture_rect.origin) *
Matrix::MakeScale((1 / scale) *
(scaled_size / floored_size)),
.sampler_descriptor = sampler_desc,
.opacity = input_snapshot->opacity},
Snapshot{
.texture = out_texture,
.transform =
texture_rotate.Invert() *
Matrix::MakeTranslation(pass_texture_rect.GetOrigin()) *
Matrix::MakeScale((1 / scale) * (scaled_size / floored_size)),
.sampler_descriptor = sampler_desc,
.opacity = input_snapshot->opacity},
entity.GetBlendMode(), entity.GetClipDepth());
}

Expand Down
Loading

0 comments on commit 8b212a8

Please sign in to comment.