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 Nov 22, 2022
commit cfeb71b70a02f64e448ed87522da5929e26af07b
1 change: 0 additions & 1 deletion impeller/aiks/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "impeller/renderer/sampler_descriptor.h"
#include "impeller/typographer/glyph_atlas.h"
#include "impeller/typographer/text_frame.h"
#include "impeller/display_list/vertices_geometry.h"

namespace impeller {

Expand Down
4 changes: 2 additions & 2 deletions impeller/display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ impeller_component("display_list") {
"display_list_image_impeller.h",
"nine_patch_converter.cc",
"nine_patch_converter.h",
"vertices_geometry.cc",
"vertices_geometry.h",
"display_list_vertices_geometry.cc",
"display_list_vertices_geometry.h",
]

public_deps = [
Expand Down
5 changes: 3 additions & 2 deletions impeller/display_list/display_list_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "flutter/fml/logging.h"
#include "flutter/fml/trace_event.h"
#include "impeller/display_list/display_list_image_impeller.h"
#include "impeller/display_list/display_list_vertices_geometry.h"
#include "impeller/display_list/nine_patch_converter.h"
#include "impeller/display_list/vertices_geometry.h"
#include "impeller/entity/contents/filters/filter_contents.h"
#include "impeller/entity/contents/filters/inputs/filter_input.h"
#include "impeller/entity/contents/linear_gradient_contents.h"
Expand Down Expand Up @@ -1103,7 +1103,8 @@ void DisplayListDispatcher::drawSkVertices(const sk_sp<SkVertices> vertices,
// |flutter::Dispatcher|
void DisplayListDispatcher::drawVertices(const flutter::DlVertices* vertices,
flutter::DlBlendMode dl_mode) {
canvas_.DrawVertices(VerticesGeometry::MakeVertices(vertices), ToBlendMode(dl_mode), paint_);
canvas_.DrawVertices(DLVerticesGeometry::MakeVertices(vertices),
ToBlendMode(dl_mode), paint_);
}

// |flutter::Dispatcher|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "impeller/display_list/vertices_geometry.h"
#include "impeller/display_list/display_list_vertices_geometry.h"

#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/entity.h"
Expand Down Expand Up @@ -58,19 +58,19 @@ static std::vector<uint16_t> fromFanIndices(
/////// Vertices Geometry ///////

// static
std::unique_ptr<VerticesGeometry> VerticesGeometry::MakeVertices(
std::unique_ptr<VerticesGeometry> DLVerticesGeometry::MakeVertices(
const flutter::DlVertices* vertices) {
return std::make_unique<VerticesGeometry>(vertices);
return std::make_unique<DLVerticesGeometry>(vertices);
}

VerticesGeometry::VerticesGeometry(const flutter::DlVertices* vertices)
DLVerticesGeometry::DLVerticesGeometry(const flutter::DlVertices* vertices)
: vertices_(vertices) {
NormalizeIndices();
}

VerticesGeometry::~VerticesGeometry() = default;
DLVerticesGeometry::~DLVerticesGeometry() = default;

void VerticesGeometry::NormalizeIndices() {
void DLVerticesGeometry::NormalizeIndices() {
// Convert triangle fan if present.
if (vertices_->mode() == flutter::DlVertexMode::kTriangleFan) {
normalized_indices_ = fromFanIndices(vertices_);
Expand All @@ -79,13 +79,11 @@ void VerticesGeometry::NormalizeIndices() {

auto index_count = vertices_->index_count();
auto vertex_count = vertices_->vertex_count();
auto* dl_indices = vertices_->indices();
auto* dl_vertices = vertices_->vertices();
if (index_count != 0 || vertex_count == 0) {
return;
}
normalized_indices_.reserve(vertex_count);
for (size_t i = 0; i < vertex_count; i++) {
for (auto i = 0; i < vertex_count; i++) {
normalized_indices_.push_back(i);
}
}
Expand All @@ -102,7 +100,7 @@ static PrimitiveType GetPrimitiveType(const flutter::DlVertices* vertices) {
}
}

GeometryResult VerticesGeometry::GetPositionBuffer(
GeometryResult DLVerticesGeometry::GetPositionBuffer(
const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) {
Expand Down Expand Up @@ -153,7 +151,7 @@ GeometryResult VerticesGeometry::GetPositionBuffer(
};
}

GeometryResult VerticesGeometry::GetPositionColorBuffer(
GeometryResult DLVerticesGeometry::GetPositionColorBuffer(
const ContentContext& renderer,
const Entity& entity,
RenderPass& pass,
Expand All @@ -173,7 +171,7 @@ GeometryResult VerticesGeometry::GetPositionColorBuffer(

std::vector<VS::PerVertexData> vertex_data(vertex_count);
{
for (size_t i = 0; i < vertex_count; i++) {
for (auto i = 0; i < vertex_count; i++) {
auto dl_color = dl_colors[i];
auto pre_color = Color(dl_color.getRedF(), dl_color.getGreenF(),
dl_color.getBlueF(), dl_color.getAlphaF());
Expand Down Expand Up @@ -224,7 +222,7 @@ GeometryResult VerticesGeometry::GetPositionColorBuffer(
};
}

GeometryResult VerticesGeometry::GetPositionUVBuffer(
GeometryResult DLVerticesGeometry::GetPositionUVBuffer(
const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) {
Expand All @@ -233,15 +231,15 @@ GeometryResult VerticesGeometry::GetPositionUVBuffer(
return {};
}

GeometryVertexType VerticesGeometry::GetVertexType() const {
GeometryVertexType DLVerticesGeometry::GetVertexType() const {
auto* dl_colors = vertices_->colors();
if (dl_colors != nullptr) {
return GeometryVertexType::kColor;
}
return GeometryVertexType::kPosition;
}

std::optional<Rect> VerticesGeometry::GetCoverage(
std::optional<Rect> DLVerticesGeometry::GetCoverage(
const Matrix& transform) const {
return ToRect(vertices_->bounds());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@
namespace impeller {

/// @brief A geometry that is created from a vertices object.
class VerticesGeometry : public Geometry {
class DLVerticesGeometry : public VerticesGeometry {
public:
explicit VerticesGeometry(const flutter::DlVertices* vertices);
explicit DLVerticesGeometry(const flutter::DlVertices* vertices);

~VerticesGeometry();
~DLVerticesGeometry();

static std::unique_ptr<VerticesGeometry> MakeVertices(
const flutter::DlVertices* vertices);

// |VerticesGeometry|
GeometryResult GetPositionColorBuffer(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass,
Color paint_color,
BlendMode blend_mode);
BlendMode blend_mode) override;

// |VerticesGeometry|
GeometryResult GetPositionUVBuffer(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass);
RenderPass& pass) override;

// |Geometry|
GeometryResult GetPositionBuffer(const ContentContext& renderer,
Expand All @@ -53,7 +55,7 @@ class VerticesGeometry : public Geometry {
const flutter::DlVertices* vertices_;
std::vector<uint16_t> normalized_indices_;

FML_DISALLOW_COPY_AND_ASSIGN(VerticesGeometry);
FML_DISALLOW_COPY_AND_ASSIGN(DLVerticesGeometry);
};

} // namespace impeller
1 change: 0 additions & 1 deletion impeller/entity/contents/vertices_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "impeller/geometry/path.h"
#include "impeller/geometry/point.h"
#include "impeller/renderer/sampler_descriptor.h"
#include "impeller/display_list/vertices_geometry.h"

namespace impeller {

Expand Down
14 changes: 14 additions & 0 deletions impeller/entity/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ class Geometry {
virtual std::optional<Rect> GetCoverage(const Matrix& transform) const = 0;
};

/// @brief A geometry that is created from a vertices object.
class VerticesGeometry : public Geometry {
public:
virtual GeometryResult GetPositionColorBuffer(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass,
Color paint_color,
BlendMode blend_mode) = 0;

virtual GeometryResult GetPositionUVBuffer(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass) = 0;
};

/// @brief A geometry that is created from a filled path object.
class FillPathGeometry : public Geometry {
public:
Expand Down