[Impeller] Cleanups to geometry interfaces. (flutter/engine#48180)
* Removed virtual destructor. We only use Geometry types with std::shared_ptr which remembers the correct dtor, we'd only need the virtual destructor if we were using `free` ourselves. * Remove std:unique_ptr. We had a mix on unique and shared ptrs, and were even doing some copies/conversions between the two. I made it consistently shared_ptr, I don't see the advantage of unique given that geometries are essentially immutable. * made geometry classes have more const methods and final. * Added some asserts on trivial destruction.
This commit is contained in:
@@ -23,7 +23,9 @@
|
||||
#include "impeller/entity/contents/conical_gradient_contents.h"
|
||||
#include "impeller/entity/contents/filters/inputs/filter_input.h"
|
||||
#include "impeller/entity/contents/linear_gradient_contents.h"
|
||||
#include "impeller/entity/contents/radial_gradient_contents.h"
|
||||
#include "impeller/entity/contents/solid_color_contents.h"
|
||||
#include "impeller/entity/contents/sweep_gradient_contents.h"
|
||||
#include "impeller/entity/contents/tiled_texture_contents.h"
|
||||
#include "impeller/geometry/color.h"
|
||||
#include "impeller/geometry/constants.h"
|
||||
|
||||
@@ -329,7 +329,7 @@ void Canvas::ClipRect(const Rect& rect, Entity::ClipOperation clip_op) {
|
||||
return; // This clip will do nothing, so skip it.
|
||||
}
|
||||
|
||||
ClipGeometry(std::move(geometry), clip_op);
|
||||
ClipGeometry(geometry, clip_op);
|
||||
switch (clip_op) {
|
||||
case Entity::ClipOperation::kIntersect:
|
||||
IntersectCulling(rect);
|
||||
@@ -365,7 +365,7 @@ void Canvas::ClipRRect(const Rect& rect,
|
||||
return; // This clip will do nothing, so skip it.
|
||||
}
|
||||
|
||||
ClipGeometry(std::move(geometry), clip_op);
|
||||
ClipGeometry(geometry, clip_op);
|
||||
switch (clip_op) {
|
||||
case Entity::ClipOperation::kIntersect:
|
||||
IntersectCulling(rect);
|
||||
@@ -390,10 +390,10 @@ void Canvas::ClipRRect(const Rect& rect,
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::ClipGeometry(std::unique_ptr<Geometry> geometry,
|
||||
void Canvas::ClipGeometry(const std::shared_ptr<Geometry>& geometry,
|
||||
Entity::ClipOperation clip_op) {
|
||||
auto contents = std::make_shared<ClipContents>();
|
||||
contents->SetGeometry(std::move(geometry));
|
||||
contents->SetGeometry(geometry);
|
||||
contents->SetClipOperation(clip_op);
|
||||
|
||||
Entity entity;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/aiks/image.h"
|
||||
#include "impeller/aiks/image_filter.h"
|
||||
#include "impeller/aiks/paint.h"
|
||||
@@ -23,7 +22,6 @@
|
||||
#include "impeller/geometry/path.h"
|
||||
#include "impeller/geometry/point.h"
|
||||
#include "impeller/geometry/vector.h"
|
||||
#include "impeller/typographer/glyph_atlas.h"
|
||||
#include "impeller/typographer/text_frame.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -175,7 +173,7 @@ class Canvas {
|
||||
|
||||
size_t GetClipDepth() const;
|
||||
|
||||
void ClipGeometry(std::unique_ptr<Geometry> geometry,
|
||||
void ClipGeometry(const std::shared_ptr<Geometry>& geometry,
|
||||
Entity::ClipOperation clip_op);
|
||||
|
||||
void IntersectCulling(Rect clip_bounds);
|
||||
|
||||
@@ -28,7 +28,7 @@ constexpr ColorMatrix kColorInversion = {
|
||||
|
||||
std::shared_ptr<Contents> Paint::CreateContentsForEntity(const Path& path,
|
||||
bool cover) const {
|
||||
std::unique_ptr<Geometry> geometry;
|
||||
std::shared_ptr<Geometry> geometry;
|
||||
switch (style) {
|
||||
case Style::kFill:
|
||||
geometry = cover ? Geometry::MakeCover() : Geometry::MakeFillPath(path);
|
||||
@@ -40,11 +40,11 @@ std::shared_ptr<Contents> Paint::CreateContentsForEntity(const Path& path,
|
||||
stroke_cap, stroke_join);
|
||||
break;
|
||||
}
|
||||
return CreateContentsForGeometry(std::move(geometry));
|
||||
return CreateContentsForGeometry(geometry);
|
||||
}
|
||||
|
||||
std::shared_ptr<Contents> Paint::CreateContentsForGeometry(
|
||||
std::shared_ptr<Geometry> geometry) const {
|
||||
const std::shared_ptr<Geometry>& geometry) const {
|
||||
auto contents = color_source.GetContents(*this);
|
||||
|
||||
// Attempt to apply the color filter on the CPU first.
|
||||
@@ -57,7 +57,7 @@ std::shared_ptr<Contents> Paint::CreateContentsForGeometry(
|
||||
needs_color_filter = false;
|
||||
}
|
||||
|
||||
contents->SetGeometry(std::move(geometry));
|
||||
contents->SetGeometry(geometry);
|
||||
if (mask_blur_descriptor.has_value()) {
|
||||
// If there's a mask blur and we need to apply the color filter on the GPU,
|
||||
// we need to be careful to only apply the color filter to the source
|
||||
|
||||
@@ -6,16 +6,12 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/aiks/color_filter.h"
|
||||
#include "impeller/aiks/color_source.h"
|
||||
#include "impeller/aiks/image_filter.h"
|
||||
#include "impeller/entity/contents/contents.h"
|
||||
#include "impeller/entity/contents/filters/color_filter_contents.h"
|
||||
#include "impeller/entity/contents/filters/filter_contents.h"
|
||||
#include "impeller/entity/contents/linear_gradient_contents.h"
|
||||
#include "impeller/entity/contents/radial_gradient_contents.h"
|
||||
#include "impeller/entity/contents/sweep_gradient_contents.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/entity/geometry/geometry.h"
|
||||
#include "impeller/geometry/color.h"
|
||||
@@ -92,7 +88,7 @@ struct Paint {
|
||||
bool cover = false) const;
|
||||
|
||||
std::shared_ptr<Contents> CreateContentsForGeometry(
|
||||
std::shared_ptr<Geometry> geometry) const;
|
||||
const std::shared_ptr<Geometry>& geometry) const;
|
||||
|
||||
/// @brief Whether this paint has a color filter that can apply opacity
|
||||
bool HasColorFilter() const;
|
||||
|
||||
@@ -22,8 +22,8 @@ ClipContents::ClipContents() = default;
|
||||
|
||||
ClipContents::~ClipContents() = default;
|
||||
|
||||
void ClipContents::SetGeometry(std::unique_ptr<Geometry> geometry) {
|
||||
geometry_ = std::move(geometry);
|
||||
void ClipContents::SetGeometry(const std::shared_ptr<Geometry>& geometry) {
|
||||
geometry_ = geometry;
|
||||
}
|
||||
|
||||
void ClipContents::SetClipOperation(Entity::ClipOperation clip_op) {
|
||||
|
||||
@@ -21,7 +21,7 @@ class ClipContents final : public Contents {
|
||||
|
||||
~ClipContents();
|
||||
|
||||
void SetGeometry(std::unique_ptr<Geometry> geometry);
|
||||
void SetGeometry(const std::shared_ptr<Geometry>& geometry);
|
||||
|
||||
void SetClipOperation(Entity::ClipOperation clip_op);
|
||||
|
||||
@@ -48,7 +48,7 @@ class ClipContents final : public Contents {
|
||||
void SetInheritedOpacity(Scalar opacity) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Geometry> geometry_;
|
||||
std::shared_ptr<Geometry> geometry_;
|
||||
Entity::ClipOperation clip_op_ = Entity::ClipOperation::kIntersect;
|
||||
|
||||
ClipContents(const ClipContents&) = delete;
|
||||
|
||||
@@ -10,11 +10,9 @@ namespace impeller {
|
||||
|
||||
CoverGeometry::CoverGeometry() = default;
|
||||
|
||||
CoverGeometry::~CoverGeometry() = default;
|
||||
|
||||
GeometryResult CoverGeometry::GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
auto rect = Rect::MakeSize(pass.GetRenderTargetSize());
|
||||
constexpr uint16_t kRectIndicies[4] = {0, 1, 2, 3};
|
||||
auto& host_buffer = pass.GetTransientsBuffer();
|
||||
@@ -43,7 +41,7 @@ GeometryResult CoverGeometry::GetPositionUVBuffer(
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
auto rect = Rect::MakeSize(pass.GetRenderTargetSize());
|
||||
return ComputeUVGeometryForRect(rect, texture_coverage, effect_transform,
|
||||
renderer, entity, pass);
|
||||
|
||||
@@ -10,11 +10,11 @@ namespace impeller {
|
||||
|
||||
/// @brief A geometry that implements "drawPaint" like behavior by covering
|
||||
/// the entire render pass area.
|
||||
class CoverGeometry : public Geometry {
|
||||
class CoverGeometry final : public Geometry {
|
||||
public:
|
||||
CoverGeometry();
|
||||
|
||||
~CoverGeometry();
|
||||
~CoverGeometry() = default;
|
||||
|
||||
// |Geometry|
|
||||
bool CoversArea(const Matrix& transform, const Rect& rect) const override;
|
||||
@@ -23,7 +23,7 @@ class CoverGeometry : public Geometry {
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryVertexType GetVertexType() const override;
|
||||
@@ -36,11 +36,13 @@ class CoverGeometry : public Geometry {
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
CoverGeometry(const CoverGeometry&) = delete;
|
||||
|
||||
CoverGeometry& operator=(const CoverGeometry&) = delete;
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_destructible<CoverGeometry>::value);
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -11,12 +11,10 @@ FillPathGeometry::FillPathGeometry(const Path& path,
|
||||
std::optional<Rect> inner_rect)
|
||||
: path_(path), inner_rect_(inner_rect) {}
|
||||
|
||||
FillPathGeometry::~FillPathGeometry() = default;
|
||||
|
||||
GeometryResult FillPathGeometry::GetPositionBuffer(
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
auto& host_buffer = pass.GetTransientsBuffer();
|
||||
VertexBuffer vertex_buffer;
|
||||
|
||||
@@ -76,7 +74,7 @@ GeometryResult FillPathGeometry::GetPositionUVBuffer(
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
using VS = TextureFillVertexShader;
|
||||
|
||||
auto uv_transform =
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
namespace impeller {
|
||||
|
||||
/// @brief A geometry that is created from a filled path object.
|
||||
class FillPathGeometry : public Geometry {
|
||||
class FillPathGeometry final : public Geometry {
|
||||
public:
|
||||
explicit FillPathGeometry(const Path& path,
|
||||
std::optional<Rect> inner_rect = std::nullopt);
|
||||
|
||||
~FillPathGeometry();
|
||||
~FillPathGeometry() = default;
|
||||
|
||||
// |Geometry|
|
||||
bool CoversArea(const Matrix& transform, const Rect& rect) const override;
|
||||
@@ -26,7 +26,7 @@ class FillPathGeometry : public Geometry {
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryVertexType GetVertexType() const override;
|
||||
@@ -39,7 +39,7 @@ class FillPathGeometry : public Geometry {
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
Path path_;
|
||||
std::optional<Rect> inner_rect_;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "impeller/entity/geometry/geometry.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "impeller/entity/geometry/cover_geometry.h"
|
||||
@@ -69,31 +70,27 @@ GeometryResult ComputeUVGeometryForRect(Rect source_rect,
|
||||
};
|
||||
}
|
||||
|
||||
Geometry::Geometry() = default;
|
||||
|
||||
Geometry::~Geometry() = default;
|
||||
|
||||
GeometryResult Geometry::GetPositionUVBuffer(Rect texture_coverage,
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unique_ptr<Geometry> Geometry::MakeFillPath(
|
||||
std::shared_ptr<Geometry> Geometry::MakeFillPath(
|
||||
const Path& path,
|
||||
std::optional<Rect> inner_rect) {
|
||||
return std::make_unique<FillPathGeometry>(path, inner_rect);
|
||||
return std::make_shared<FillPathGeometry>(path, inner_rect);
|
||||
}
|
||||
|
||||
std::unique_ptr<Geometry> Geometry::MakePointField(std::vector<Point> points,
|
||||
std::shared_ptr<Geometry> Geometry::MakePointField(std::vector<Point> points,
|
||||
Scalar radius,
|
||||
bool round) {
|
||||
return std::make_unique<PointFieldGeometry>(std::move(points), radius, round);
|
||||
return std::make_shared<PointFieldGeometry>(std::move(points), radius, round);
|
||||
}
|
||||
|
||||
std::unique_ptr<Geometry> Geometry::MakeStrokePath(const Path& path,
|
||||
std::shared_ptr<Geometry> Geometry::MakeStrokePath(const Path& path,
|
||||
Scalar stroke_width,
|
||||
Scalar miter_limit,
|
||||
Cap stroke_cap,
|
||||
@@ -102,23 +99,23 @@ std::unique_ptr<Geometry> Geometry::MakeStrokePath(const Path& path,
|
||||
if (miter_limit < 0) {
|
||||
miter_limit = 4.0;
|
||||
}
|
||||
return std::make_unique<StrokePathGeometry>(path, stroke_width, miter_limit,
|
||||
return std::make_shared<StrokePathGeometry>(path, stroke_width, miter_limit,
|
||||
stroke_cap, stroke_join);
|
||||
}
|
||||
|
||||
std::unique_ptr<Geometry> Geometry::MakeCover() {
|
||||
return std::make_unique<CoverGeometry>();
|
||||
std::shared_ptr<Geometry> Geometry::MakeCover() {
|
||||
return std::make_shared<CoverGeometry>();
|
||||
}
|
||||
|
||||
std::unique_ptr<Geometry> Geometry::MakeRect(Rect rect) {
|
||||
return std::make_unique<RectGeometry>(rect);
|
||||
std::shared_ptr<Geometry> Geometry::MakeRect(Rect rect) {
|
||||
return std::make_shared<RectGeometry>(rect);
|
||||
}
|
||||
|
||||
std::unique_ptr<Geometry> Geometry::MakeLine(Point p0,
|
||||
std::shared_ptr<Geometry> Geometry::MakeLine(Point p0,
|
||||
Point p1,
|
||||
Scalar width,
|
||||
Cap cap) {
|
||||
return std::make_unique<LineGeometry>(p0, p1, width, cap);
|
||||
return std::make_shared<LineGeometry>(p0, p1, width, cap);
|
||||
}
|
||||
|
||||
bool Geometry::CoversArea(const Matrix& transform, const Rect& rect) const {
|
||||
|
||||
@@ -48,43 +48,39 @@ GeometryResult ComputeUVGeometryForRect(Rect source_rect,
|
||||
|
||||
class Geometry {
|
||||
public:
|
||||
Geometry();
|
||||
|
||||
virtual ~Geometry();
|
||||
|
||||
static std::unique_ptr<Geometry> MakeFillPath(
|
||||
static std::shared_ptr<Geometry> MakeFillPath(
|
||||
const Path& path,
|
||||
std::optional<Rect> inner_rect = std::nullopt);
|
||||
|
||||
static std::unique_ptr<Geometry> MakeStrokePath(
|
||||
static std::shared_ptr<Geometry> MakeStrokePath(
|
||||
const Path& path,
|
||||
Scalar stroke_width = 0.0,
|
||||
Scalar miter_limit = 4.0,
|
||||
Cap stroke_cap = Cap::kButt,
|
||||
Join stroke_join = Join::kMiter);
|
||||
|
||||
static std::unique_ptr<Geometry> MakeCover();
|
||||
static std::shared_ptr<Geometry> MakeCover();
|
||||
|
||||
static std::unique_ptr<Geometry> MakeRect(Rect rect);
|
||||
static std::shared_ptr<Geometry> MakeRect(Rect rect);
|
||||
|
||||
static std::unique_ptr<Geometry> MakeLine(Point p0,
|
||||
static std::shared_ptr<Geometry> MakeLine(Point p0,
|
||||
Point p1,
|
||||
Scalar width,
|
||||
Cap cap);
|
||||
|
||||
static std::unique_ptr<Geometry> MakePointField(std::vector<Point> points,
|
||||
static std::shared_ptr<Geometry> MakePointField(std::vector<Point> points,
|
||||
Scalar radius,
|
||||
bool round);
|
||||
|
||||
virtual GeometryResult GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) = 0;
|
||||
RenderPass& pass) const = 0;
|
||||
|
||||
virtual GeometryResult GetPositionUVBuffer(Rect texture_coverage,
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass);
|
||||
RenderPass& pass) const = 0;
|
||||
|
||||
virtual GeometryVertexType GetVertexType() const = 0;
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ LineGeometry::LineGeometry(Point p0, Point p1, Scalar width, Cap cap)
|
||||
FML_DCHECK(cap != Cap::kRound);
|
||||
}
|
||||
|
||||
LineGeometry::~LineGeometry() = default;
|
||||
|
||||
bool LineGeometry::ComputeCorners(Point corners[4],
|
||||
const Matrix& transform,
|
||||
bool extend_endpoints) const {
|
||||
@@ -55,7 +53,7 @@ bool LineGeometry::ComputeCorners(Point corners[4],
|
||||
|
||||
GeometryResult LineGeometry::GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
auto& host_buffer = pass.GetTransientsBuffer();
|
||||
|
||||
Point corners[4];
|
||||
@@ -84,7 +82,7 @@ GeometryResult LineGeometry::GetPositionUVBuffer(Rect texture_coverage,
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
auto& host_buffer = pass.GetTransientsBuffer();
|
||||
|
||||
auto uv_transform =
|
||||
|
||||
@@ -4,15 +4,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include "impeller/entity/geometry/geometry.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class LineGeometry : public Geometry {
|
||||
class LineGeometry final : public Geometry {
|
||||
public:
|
||||
explicit LineGeometry(Point p0, Point p1, Scalar width, Cap cap);
|
||||
|
||||
~LineGeometry();
|
||||
~LineGeometry() = default;
|
||||
|
||||
// |Geometry|
|
||||
bool CoversArea(const Matrix& transform, const Rect& rect) const override;
|
||||
@@ -42,7 +43,7 @@ class LineGeometry : public Geometry {
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryVertexType GetVertexType() const override;
|
||||
@@ -55,7 +56,7 @@ class LineGeometry : public Geometry {
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
Point p0_;
|
||||
Point p1_;
|
||||
@@ -67,4 +68,6 @@ class LineGeometry : public Geometry {
|
||||
LineGeometry& operator=(const LineGeometry&) = delete;
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_destructible<LineGeometry>::value);
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -14,12 +14,10 @@ PointFieldGeometry::PointFieldGeometry(std::vector<Point> points,
|
||||
bool round)
|
||||
: points_(std::move(points)), radius_(radius), round_(round) {}
|
||||
|
||||
PointFieldGeometry::~PointFieldGeometry() = default;
|
||||
|
||||
GeometryResult PointFieldGeometry::GetPositionBuffer(
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
if (renderer.GetDeviceCapabilities().SupportsCompute()) {
|
||||
return GetPositionBufferGPU(renderer, entity, pass);
|
||||
}
|
||||
@@ -43,7 +41,7 @@ GeometryResult PointFieldGeometry::GetPositionUVBuffer(
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
if (renderer.GetDeviceCapabilities().SupportsCompute()) {
|
||||
return GetPositionBufferGPU(renderer, entity, pass, texture_coverage,
|
||||
effect_transform);
|
||||
@@ -69,7 +67,7 @@ GeometryResult PointFieldGeometry::GetPositionUVBuffer(
|
||||
std::optional<VertexBufferBuilder<SolidFillVertexShader::PerVertexData>>
|
||||
PointFieldGeometry::GetPositionBufferCPU(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
if (radius_ < 0.0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -127,7 +125,7 @@ GeometryResult PointFieldGeometry::GetPositionBufferGPU(
|
||||
const Entity& entity,
|
||||
RenderPass& pass,
|
||||
std::optional<Rect> texture_coverage,
|
||||
std::optional<Matrix> effect_transform) {
|
||||
std::optional<Matrix> effect_transform) const {
|
||||
FML_DCHECK(renderer.GetDeviceCapabilities().SupportsCompute());
|
||||
if (radius_ < 0.0) {
|
||||
return {};
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class PointFieldGeometry : public Geometry {
|
||||
class PointFieldGeometry final : public Geometry {
|
||||
public:
|
||||
PointFieldGeometry(std::vector<Point> points, Scalar radius, bool round);
|
||||
|
||||
~PointFieldGeometry();
|
||||
~PointFieldGeometry() = default;
|
||||
|
||||
static size_t ComputeCircleDivisions(Scalar scaled_radius, bool round);
|
||||
|
||||
@@ -20,14 +20,14 @@ class PointFieldGeometry : public Geometry {
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionUVBuffer(Rect texture_coverage,
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryVertexType GetVertexType() const override;
|
||||
@@ -40,12 +40,12 @@ class PointFieldGeometry : public Geometry {
|
||||
const Entity& entity,
|
||||
RenderPass& pass,
|
||||
std::optional<Rect> texture_coverage = std::nullopt,
|
||||
std::optional<Matrix> effect_transform = std::nullopt);
|
||||
std::optional<Matrix> effect_transform = std::nullopt) const;
|
||||
|
||||
std::optional<VertexBufferBuilder<SolidFillVertexShader::PerVertexData>>
|
||||
GetPositionBufferCPU(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass);
|
||||
RenderPass& pass) const;
|
||||
|
||||
std::vector<Point> points_;
|
||||
Scalar radius_;
|
||||
|
||||
@@ -8,11 +8,9 @@ namespace impeller {
|
||||
|
||||
RectGeometry::RectGeometry(Rect rect) : rect_(rect) {}
|
||||
|
||||
RectGeometry::~RectGeometry() = default;
|
||||
|
||||
GeometryResult RectGeometry::GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
auto& host_buffer = pass.GetTransientsBuffer();
|
||||
return GeometryResult{
|
||||
.type = PrimitiveType::kTriangleStrip,
|
||||
@@ -34,7 +32,7 @@ GeometryResult RectGeometry::GetPositionUVBuffer(Rect texture_coverage,
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
return ComputeUVGeometryForRect(rect_, texture_coverage, effect_transform,
|
||||
renderer, entity, pass);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class RectGeometry : public Geometry {
|
||||
class RectGeometry final : public Geometry {
|
||||
public:
|
||||
explicit RectGeometry(Rect rect);
|
||||
|
||||
~RectGeometry();
|
||||
~RectGeometry() = default;
|
||||
|
||||
// |Geometry|
|
||||
bool CoversArea(const Matrix& transform, const Rect& rect) const override;
|
||||
@@ -24,7 +24,7 @@ class RectGeometry : public Geometry {
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryVertexType GetVertexType() const override;
|
||||
@@ -37,7 +37,7 @@ class RectGeometry : public Geometry {
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
Rect rect_;
|
||||
|
||||
@@ -46,4 +46,6 @@ class RectGeometry : public Geometry {
|
||||
RectGeometry& operator=(const RectGeometry&) = delete;
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_destructible<RectGeometry>::value);
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -439,7 +439,7 @@ StrokePathGeometry::CreateSolidStrokeVertices(
|
||||
GeometryResult StrokePathGeometry::GetPositionBuffer(
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
if (stroke_width_ < 0.0) {
|
||||
return {};
|
||||
}
|
||||
@@ -471,7 +471,7 @@ GeometryResult StrokePathGeometry::GetPositionUVBuffer(
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
if (stroke_width_ < 0.0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace impeller {
|
||||
|
||||
/// @brief A geometry that is created from a stroked path object.
|
||||
class StrokePathGeometry : public Geometry {
|
||||
class StrokePathGeometry final : public Geometry {
|
||||
public:
|
||||
StrokePathGeometry(const Path& path,
|
||||
Scalar stroke_width,
|
||||
@@ -47,14 +47,14 @@ class StrokePathGeometry : public Geometry {
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionUVBuffer(Rect texture_coverage,
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryVertexType GetVertexType() const override;
|
||||
|
||||
@@ -67,8 +67,6 @@ VerticesGeometry::VerticesGeometry(std::vector<Point> vertices,
|
||||
NormalizeIndices();
|
||||
}
|
||||
|
||||
VerticesGeometry::~VerticesGeometry() = default;
|
||||
|
||||
PrimitiveType VerticesGeometry::GetPrimitiveType() const {
|
||||
switch (vertex_mode_) {
|
||||
case VerticesGeometry::VertexMode::kTriangleFan:
|
||||
@@ -113,7 +111,7 @@ std::optional<Rect> VerticesGeometry::GetTextureCoordinateCoverge() const {
|
||||
GeometryResult VerticesGeometry::GetPositionBuffer(
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
auto index_count = indices_.size();
|
||||
auto vertex_count = vertices_.size();
|
||||
|
||||
@@ -222,7 +220,7 @@ GeometryResult VerticesGeometry::GetPositionUVBuffer(
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) {
|
||||
RenderPass& pass) const {
|
||||
using VS = TexturePipeline::VertexShader;
|
||||
|
||||
auto index_count = indices_.size();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace impeller {
|
||||
|
||||
/// @brief A geometry that is created from a vertices object.
|
||||
class VerticesGeometry : public Geometry {
|
||||
class VerticesGeometry final : public Geometry {
|
||||
public:
|
||||
enum class VertexMode {
|
||||
kTriangles,
|
||||
@@ -24,7 +24,7 @@ class VerticesGeometry : public Geometry {
|
||||
Rect bounds,
|
||||
VerticesGeometry::VertexMode vertex_mode);
|
||||
|
||||
~VerticesGeometry();
|
||||
~VerticesGeometry() = default;
|
||||
|
||||
GeometryResult GetPositionColorBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
@@ -35,12 +35,12 @@ class VerticesGeometry : public Geometry {
|
||||
Matrix effect_transform,
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
GeometryResult GetPositionBuffer(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) override;
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Geometry|
|
||||
std::optional<Rect> GetCoverage(const Matrix& transform) const override;
|
||||
|
||||
Reference in New Issue
Block a user