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

[Impeller] Fix DrawPaint regression #37561

Merged
merged 1 commit into from
Nov 13, 2022
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 impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ TEST_P(AiksTest, CanDrawPaint) {
Paint paint;
paint.color = Color::MediumTurquoise();
Canvas canvas;
canvas.Scale(Vector2(0.2, 0.2));
canvas.DrawPaint(paint);
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
Expand Down
3 changes: 1 addition & 2 deletions impeller/entity/contents/clip_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ bool ClipContents::Render(const ContentContext& renderer,
auto allocator = renderer.GetContext()->GetResourceAllocator();
cmd.BindVertices(geometry_result.vertex_buffer);

info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
info.mvp = geometry_result.transform;
VS::BindVertInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(info));

pass.AddCommand(std::move(cmd));
Expand Down
8 changes: 4 additions & 4 deletions impeller/entity/contents/linear_gradient_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ bool LinearGradientContents::Render(const ContentContext& renderer,
gradient_info.half_texel = Vector2(0.5 / gradient_texture->GetSize().width,
0.5 / gradient_texture->GetSize().height);

auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);

VS::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
frame_info.mvp = geometry_result.transform;
frame_info.matrix = GetInverseMatrix();

Command cmd;
cmd.label = "LinearGradientFill";
cmd.stencil_reference = entity.GetStencilDepth();

auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);
auto options = OptionsFromPassAndEntity(pass, entity);
if (geometry_result.prevent_overdraw) {
options.stencil_compare = CompareFunction::kEqual;
Expand Down
8 changes: 4 additions & 4 deletions impeller/entity/contents/radial_gradient_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ bool RadialGradientContents::Render(const ContentContext& renderer,
gradient_info.half_texel = Vector2(0.5 / gradient_texture->GetSize().width,
0.5 / gradient_texture->GetSize().height);

auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);

VS::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
frame_info.mvp = geometry_result.transform;
frame_info.matrix = GetInverseMatrix();

Command cmd;
cmd.label = "RadialGradientFill";
cmd.stencil_reference = entity.GetStencilDepth();

auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);
auto options = OptionsFromPassAndEntity(pass, entity);
if (geometry_result.prevent_overdraw) {
options.stencil_compare = CompareFunction::kEqual;
Expand Down
3 changes: 1 addition & 2 deletions impeller/entity/contents/runtime_effect_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ bool RuntimeEffectContents::Render(const ContentContext& renderer,
///

VS::VertInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
frame_info.mvp = geometry_result.transform;
VS::BindVertInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info));

//--------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions impeller/entity/contents/solid_color_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ bool SolidColorContents::Render(const ContentContext& renderer,
cmd.BindVertices(geometry_result.vertex_buffer);

VS::VertInfo vert_info;
vert_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
vert_info.mvp = geometry_result.transform;
VS::BindVertInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(vert_info));

FS::FragInfo frag_info;
Expand Down
8 changes: 4 additions & 4 deletions impeller/entity/contents/sweep_gradient_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ bool SweepGradientContents::Render(const ContentContext& renderer,
gradient_info.half_texel = Vector2(0.5 / gradient_texture->GetSize().width,
0.5 / gradient_texture->GetSize().height);

auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);

VS::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
frame_info.mvp = geometry_result.transform;
frame_info.matrix = GetInverseMatrix();

Command cmd;
cmd.label = "SweepGradientFill";
cmd.stencil_reference = entity.GetStencilDepth();
auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);

auto options = OptionsFromPassAndEntity(pass, entity);
if (geometry_result.prevent_overdraw) {
Expand Down
9 changes: 4 additions & 5 deletions impeller/entity/contents/tiled_texture_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ bool TiledTextureContents::Render(const ContentContext& renderer,

auto& host_buffer = pass.GetTransientsBuffer();

auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);

VS::VertInfo vert_info;
vert_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
vert_info.mvp = geometry_result.transform;
vert_info.matrix = GetInverseMatrix();
vert_info.texture_size = Vector2{static_cast<Scalar>(texture_size.width),
static_cast<Scalar>(texture_size.height)};
Expand All @@ -67,9 +69,6 @@ bool TiledTextureContents::Render(const ContentContext& renderer,
cmd.label = "TiledTextureFill";
cmd.stencil_reference = entity.GetStencilDepth();

auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);

auto options = OptionsFromPassAndEntity(pass, entity);
if (geometry_result.prevent_overdraw) {
options.stencil_compare = CompareFunction::kEqual;
Expand Down
3 changes: 1 addition & 2 deletions impeller/entity/contents/vertices_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ bool VerticesContents::Render(const ContentContext& renderer,
cmd.BindVertices(geometry_result.vertex_buffer);

VS::VertInfo vert_info;
vert_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation();
vert_info.mvp = geometry_result.transform;
vert_info.color = color_.Premultiply();
VS::BindVertInfo(cmd,
pass.GetTransientsBuffer().EmplaceUniform(vert_info));
Expand Down
46 changes: 30 additions & 16 deletions impeller/entity/geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "impeller/entity/geometry.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/position_color.vert.h"
#include "impeller/geometry/matrix.h"
#include "impeller/geometry/path_builder.h"
#include "impeller/renderer/device_buffer.h"
#include "impeller/renderer/render_pass.h"
Expand Down Expand Up @@ -106,6 +107,8 @@ GeometryResult VerticesGeometry::GetPositionBuffer(
.index_count = vertices_.GetIndices().size(),
.index_type = IndexType::k16bit,
},
.transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation(),
.prevent_overdraw = false,
};
}
Expand Down Expand Up @@ -168,6 +171,8 @@ GeometryResult VerticesGeometry::GetPositionColorBuffer(
.index_count = vertices_.GetIndices().size(),
.index_type = IndexType::k16bit,
},
.transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation(),
.prevent_overdraw = false,
};
}
Expand Down Expand Up @@ -224,6 +229,8 @@ GeometryResult FillPathGeometry::GetPositionBuffer(
return GeometryResult{
.type = PrimitiveType::kTriangle,
.vertex_buffer = vertex_buffer,
.transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation(),
.prevent_overdraw = false,
};
}
Expand Down Expand Up @@ -577,6 +584,8 @@ GeometryResult StrokePathGeometry::GetPositionBuffer(
return GeometryResult{
.type = PrimitiveType::kTriangleStrip,
.vertex_buffer = vertex_buffer,
.transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation(),
.prevent_overdraw = true,
};
}
Expand Down Expand Up @@ -627,14 +636,16 @@ GeometryResult CoverGeometry::GetPositionBuffer(const ContentContext& renderer,
auto& host_buffer = pass.GetTransientsBuffer();
return GeometryResult{
.type = PrimitiveType::kTriangleStrip,
.vertex_buffer = {.vertex_buffer = host_buffer.Emplace(
rect.GetPoints().data(), 8 * sizeof(float),
alignof(float)),
.index_buffer = host_buffer.Emplace(
kRectIndicies, 4 * sizeof(uint16_t),
alignof(uint16_t)),
.index_count = 4,
.index_type = IndexType::k16bit},
.vertex_buffer =
{
.vertex_buffer = host_buffer.Emplace(
rect.GetPoints().data(), 8 * sizeof(float), alignof(float)),
.index_buffer = host_buffer.Emplace(
kRectIndicies, 4 * sizeof(uint16_t), alignof(uint16_t)),
.index_count = 4,
.index_type = IndexType::k16bit,
},
.transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()),
.prevent_overdraw = false,
};
}
Expand All @@ -660,14 +671,17 @@ GeometryResult RectGeometry::GetPositionBuffer(const ContentContext& renderer,
auto& host_buffer = pass.GetTransientsBuffer();
return GeometryResult{
.type = PrimitiveType::kTriangleStrip,
.vertex_buffer = {.vertex_buffer = host_buffer.Emplace(
rect_.GetPoints().data(), 8 * sizeof(float),
alignof(float)),
.index_buffer = host_buffer.Emplace(
kRectIndicies, 4 * sizeof(uint16_t),
alignof(uint16_t)),
.index_count = 4,
.index_type = IndexType::k16bit},
.vertex_buffer =
{
.vertex_buffer = host_buffer.Emplace(
rect_.GetPoints().data(), 8 * sizeof(float), alignof(float)),
.index_buffer = host_buffer.Emplace(
kRectIndicies, 4 * sizeof(uint16_t), alignof(uint16_t)),
.index_count = 4,
.index_type = IndexType::k16bit,
},
.transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
entity.GetTransformation(),
.prevent_overdraw = false,
};
}
Expand Down
1 change: 1 addition & 0 deletions impeller/entity/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Tessellator;
struct GeometryResult {
PrimitiveType type;
VertexBuffer vertex_buffer;
Matrix transform;
bool prevent_overdraw;
};

Expand Down