Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
++
  • Loading branch information
jonahwilliams committed Apr 23, 2024
commit 0540cbd91d4e343ae27c71869c4d286bce9be6ce
8 changes: 4 additions & 4 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -926,16 +926,16 @@ void Canvas::DrawVertices(const std::shared_ptr<VerticesGeometry>& vertices,
entity.SetTransform(GetCurrentTransform());
entity.SetBlendMode(paint.blend_mode);

// If there are no vertex color or texture coordinates.
// If there are no vertex colors.
if (UseColorSourceContents(vertices, paint)) {
entity.SetContents(CreateContentsForGeometryWithFilters(paint, vertices));
AddRenderEntityToCurrentPass(std::move(entity));
return;
}

// If there is are per-vertex colors, an image, and the blend mode
// is simple we can draw without a sub-renderpass.
if (blend_mode <= BlendMode::kModulate && vertices->HasVertexColors()) {
// If there is an image, and the blend mode is simple we can draw without a
// sub-renderpass. per-vertex colors aren't required but are supported.
if (blend_mode <= BlendMode::kModulate) {
if (std::optional<ImageData> maybe_image_data =
GetImageColorSourceData(paint.color_source)) {
const ImageData& image_data = maybe_image_data.value();
Expand Down
6 changes: 4 additions & 2 deletions impeller/entity/contents/vertices_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ bool VerticesSimpleBlendContents::Render(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) const {
FML_DCHECK(texture_);
FML_DCHECK(geometry_->HasVertexColors());

// Simple Porter-Duff blends can be accomplished without a sub renderpass.
using VS = PorterDuffBlendPipeline::VertexShader;
Expand Down Expand Up @@ -319,8 +318,11 @@ bool VerticesSimpleBlendContents::Render(const ContentContext& renderer,
frag_info.output_alpha = alpha_;
frag_info.input_alpha = 1.0;

auto inverted_blend_mode =
BlendMode inverted_blend_mode =
InvertPorterDuffBlend(blend_mode_).value_or(BlendMode::kSource);
if (geometry_->HasVertexColors()) {
inverted_blend_mode = BlendMode::kSource;
}
auto blend_coefficients =
kPorterDuffCoefficients[static_cast<int>(inverted_blend_mode)];
frag_info.src_coeff = blend_coefficients[0];
Expand Down
5 changes: 3 additions & 2 deletions impeller/entity/geometry/vertices_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "impeller/core/buffer_view.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/geometry/color.h"

namespace impeller {

Expand Down Expand Up @@ -256,6 +257,7 @@ GeometryResult VerticesGeometry::GetPositionUVColorBuffer(
auto uv_transform =
texture_coverage.GetNormalizingTransform() * effect_transform;
auto has_texture_coordinates = HasTextureCoordinates();
auto has_colors = HasVertexColors();

size_t total_vtx_bytes = vertices_.size() * sizeof(VS::PerVertexData);
auto vertex_buffer = renderer.GetTransientsBuffer().Emplace(
Expand All @@ -274,8 +276,7 @@ GeometryResult VerticesGeometry::GetPositionUVColorBuffer(
.texture_coords =
Point(std::clamp(uv.x, 0.0f, 1.0f - kEhCloseEnough),
std::clamp(uv.y, 0.0f, 1.0f - kEhCloseEnough)),
.color = colors_[i],
};
.color = has_colors ? colors_[i] : Color::BlackTransparent()};
std::memcpy(vtx_contents++, &vertex_data, sizeof(VS::PerVertexData));
}
});
Expand Down