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

Commit 0540cbd

Browse files
committed
++
1 parent c5f80f0 commit 0540cbd

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

impeller/aiks/canvas.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -926,16 +926,16 @@ void Canvas::DrawVertices(const std::shared_ptr<VerticesGeometry>& vertices,
926926
entity.SetTransform(GetCurrentTransform());
927927
entity.SetBlendMode(paint.blend_mode);
928928

929-
// If there are no vertex color or texture coordinates.
929+
// If there are no vertex colors.
930930
if (UseColorSourceContents(vertices, paint)) {
931931
entity.SetContents(CreateContentsForGeometryWithFilters(paint, vertices));
932932
AddRenderEntityToCurrentPass(std::move(entity));
933933
return;
934934
}
935935

936-
// If there is are per-vertex colors, an image, and the blend mode
937-
// is simple we can draw without a sub-renderpass.
938-
if (blend_mode <= BlendMode::kModulate && vertices->HasVertexColors()) {
936+
// If there is an image, and the blend mode is simple we can draw without a
937+
// sub-renderpass. per-vertex colors aren't required but are supported.
938+
if (blend_mode <= BlendMode::kModulate) {
939939
if (std::optional<ImageData> maybe_image_data =
940940
GetImageColorSourceData(paint.color_source)) {
941941
const ImageData& image_data = maybe_image_data.value();

impeller/entity/contents/vertices_contents.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ bool VerticesSimpleBlendContents::Render(const ContentContext& renderer,
275275
const Entity& entity,
276276
RenderPass& pass) const {
277277
FML_DCHECK(texture_);
278-
FML_DCHECK(geometry_->HasVertexColors());
279278

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

322-
auto inverted_blend_mode =
321+
BlendMode inverted_blend_mode =
323322
InvertPorterDuffBlend(blend_mode_).value_or(BlendMode::kSource);
323+
if (geometry_->HasVertexColors()) {
324+
inverted_blend_mode = BlendMode::kSource;
325+
}
324326
auto blend_coefficients =
325327
kPorterDuffCoefficients[static_cast<int>(inverted_blend_mode)];
326328
frag_info.src_coeff = blend_coefficients[0];

impeller/entity/geometry/vertices_geometry.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "impeller/core/buffer_view.h"
1111
#include "impeller/entity/contents/content_context.h"
12+
#include "impeller/geometry/color.h"
1213

1314
namespace impeller {
1415

@@ -256,6 +257,7 @@ GeometryResult VerticesGeometry::GetPositionUVColorBuffer(
256257
auto uv_transform =
257258
texture_coverage.GetNormalizingTransform() * effect_transform;
258259
auto has_texture_coordinates = HasTextureCoordinates();
260+
auto has_colors = HasVertexColors();
259261

260262
size_t total_vtx_bytes = vertices_.size() * sizeof(VS::PerVertexData);
261263
auto vertex_buffer = renderer.GetTransientsBuffer().Emplace(
@@ -274,8 +276,7 @@ GeometryResult VerticesGeometry::GetPositionUVColorBuffer(
274276
.texture_coords =
275277
Point(std::clamp(uv.x, 0.0f, 1.0f - kEhCloseEnough),
276278
std::clamp(uv.y, 0.0f, 1.0f - kEhCloseEnough)),
277-
.color = colors_[i],
278-
};
279+
.color = has_colors ? colors_[i] : Color::BlackTransparent()};
279280
std::memcpy(vtx_contents++, &vertex_data, sizeof(VS::PerVertexData));
280281
}
281282
});

0 commit comments

Comments
 (0)