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
delete more uv computation.
  • Loading branch information
jonahwilliams committed Apr 19, 2024
commit 6ef532c4880ff21d8e14ae115b2d0750d6d3b631
21 changes: 0 additions & 21 deletions impeller/entity/geometry/geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,6 @@ GeometryResult Geometry::ComputePositionGeometry(
};
}

VertexBufferBuilder<TextureFillVertexShader::PerVertexData>
ComputeUVGeometryCPU(
VertexBufferBuilder<SolidFillVertexShader::PerVertexData>& input,
Point texture_origin,
Size texture_coverage,
Matrix effect_transform) {
VertexBufferBuilder<TextureFillVertexShader::PerVertexData> vertex_builder;
vertex_builder.Reserve(input.GetVertexCount());
input.IterateVertices(
[&vertex_builder, &texture_coverage, &effect_transform,
&texture_origin](SolidFillVertexShader::PerVertexData old_vtx) {
TextureFillVertexShader::PerVertexData data;
data.position = old_vtx.position;
data.texture_coords = effect_transform *
(old_vtx.position - texture_origin) /
texture_coverage;
vertex_builder.AppendVertex(data);
});
return vertex_builder;
}

GeometryResult::Mode Geometry::GetResultMode() const {
return GeometryResult::Mode::kNormal;
}
Expand Down
1 change: 0 additions & 1 deletion impeller/entity/geometry/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "impeller/core/vertex_buffer.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/entity.h"
#include "impeller/entity/texture_fill.vert.h"
#include "impeller/renderer/render_pass.h"
#include "impeller/renderer/vertex_buffer_builder.h"

Expand Down
44 changes: 0 additions & 44 deletions impeller/entity/geometry/stroke_path_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "impeller/core/buffer_view.h"
#include "impeller/core/formats.h"
#include "impeller/entity/geometry/geometry.h"
#include "impeller/entity/texture_fill.vert.h"
#include "impeller/geometry/path_builder.h"
#include "impeller/geometry/path_component.h"

Expand Down Expand Up @@ -45,49 +44,6 @@ class PositionWriter {
std::vector<SolidFillVertexShader::PerVertexData> data_ = {};
};

class PositionUVWriter {
public:
PositionUVWriter(const Point& texture_origin,
const Size& texture_size,
const Matrix& effect_transform)
: texture_origin_(texture_origin),
texture_size_(texture_size),
effect_transform_(effect_transform) {}

const std::vector<TextureFillVertexShader::PerVertexData>& GetData() {
if (effect_transform_.IsIdentity()) {
auto origin = texture_origin_;
auto scale = 1.0 / texture_size_;

for (auto& pvd : data_) {
pvd.texture_coords = (pvd.position - origin) * scale;
}
} else {
auto texture_rect = Rect::MakeOriginSize(texture_origin_, texture_size_);
Matrix uv_transform =
texture_rect.GetNormalizingTransform() * effect_transform_;

for (auto& pvd : data_) {
pvd.texture_coords = uv_transform * pvd.position;
}
}
return data_;
}

void AppendVertex(const Point& point) {
data_.emplace_back(TextureFillVertexShader::PerVertexData{
.position = point,
// .texture_coords = default, will be filled in during |GetData()|
});
}

private:
std::vector<TextureFillVertexShader::PerVertexData> data_ = {};
const Point texture_origin_;
const Size texture_size_;
const Matrix effect_transform_;
};

template <typename VertexWriter>
class StrokeGenerator {
public:
Expand Down
60 changes: 0 additions & 60 deletions impeller/entity/geometry/vertices_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,66 +187,6 @@ GeometryResult VerticesGeometry::GetPositionColorBuffer(
};
}

// GeometryResult VerticesGeometry::GetPositionUVBuffer(
// Rect texture_coverage,
// Matrix effect_transform,
// const ContentContext& renderer,
// const Entity& entity,
// RenderPass& pass) const {
// using VS = TexturePipeline::VertexShader;

// auto index_count = indices_.size();
// auto vertex_count = vertices_.size();
// auto uv_transform =
// texture_coverage.GetNormalizingTransform() * effect_transform;
// auto has_texture_coordinates = HasTextureCoordinates();

// size_t total_vtx_bytes = vertices_.size() * sizeof(VS::PerVertexData);
// size_t total_idx_bytes = index_count * sizeof(uint16_t);
// auto vertex_buffer = renderer.GetTransientsBuffer().Emplace(
// total_vtx_bytes, alignof(VS::PerVertexData), [&](uint8_t* data) {
// VS::PerVertexData* vtx_contents =
// reinterpret_cast<VS::PerVertexData*>(data);
// for (auto i = 0u; i < vertices_.size(); i++) {
// auto vertex = vertices_[i];
// auto texture_coord =
// has_texture_coordinates ? texture_coordinates_[i] :
// vertices_[i];
// auto uv = uv_transform * texture_coord;
// // From experimentation we need to clamp these values to < 1.0 or
// else
// // there can be flickering.
// VS::PerVertexData vertex_data = {
// .position = vertex,
// .texture_coords =
// Point(std::clamp(uv.x, 0.0f, 1.0f - kEhCloseEnough),
// std::clamp(uv.y, 0.0f, 1.0f - kEhCloseEnough)),
// };
// std::memcpy(vtx_contents++, &vertex_data,
// sizeof(VS::PerVertexData));
// }
// });

// BufferView index_buffer = {};
// if (index_count > 0) {
// index_buffer = renderer.GetTransientsBuffer().Emplace(
// indices_.data(), total_idx_bytes, alignof(uint16_t));
// }

// return GeometryResult{
// .type = GetPrimitiveType(),
// .vertex_buffer =
// {
// .vertex_buffer = vertex_buffer,
// .index_buffer = index_buffer,
// .vertex_count = index_count > 0 ? index_count : vertex_count,
// .index_type =
// index_count > 0 ? IndexType::k16bit : IndexType::kNone,
// },
// .transform = entity.GetShaderTransform(pass),
// };
// }

GeometryResult VerticesGeometry::GetPositionUVColorBuffer(
Rect texture_coverage,
Matrix effect_transform,
Expand Down