[Impeller] Make Entity move only, simplify construction of geometry/filter contents. (flutter/engine#48596)
Redo of https://github.com/flutter/engine/pull/48585 Removes the Copy constructor of Entity, adds a clone method. Allows us to ensure that we move entity into the entity pass without using rvalue reference parameters Fixes https://github.com/flutter/flutter/issues/139569
This commit is contained in:
@@ -2547,7 +2547,7 @@ TEST_P(AiksTest, OpacityPeepHoleApplicationTest) {
|
||||
Entity entity;
|
||||
entity.SetContents(SolidColorContents::Make(
|
||||
PathBuilder{}.AddRect(rect).TakePath(), Color::Red()));
|
||||
entity_pass->AddEntity(entity);
|
||||
entity_pass->AddEntity(std::move(entity));
|
||||
paint.color = Color::Red().WithAlpha(0.5);
|
||||
|
||||
delegate = std::make_shared<OpacityPeepholePassDelegate>(paint);
|
||||
@@ -3239,20 +3239,22 @@ TEST_P(AiksTest, OpaqueEntitiesGetCoercedToSource) {
|
||||
Picture picture = canvas.EndRecordingAsPicture();
|
||||
|
||||
// Extract the SolidColorSource.
|
||||
Entity entity;
|
||||
// Entity entity;
|
||||
std::vector<Entity> entity;
|
||||
std::shared_ptr<SolidColorContents> contents;
|
||||
picture.pass->IterateAllEntities([&e = entity, &contents](Entity& entity) {
|
||||
picture.pass->IterateAllEntities([e = &entity, &contents](Entity& entity) {
|
||||
if (ScalarNearlyEqual(entity.GetTransform().GetScale().x, 1.618f)) {
|
||||
e = entity;
|
||||
contents =
|
||||
std::static_pointer_cast<SolidColorContents>(entity.GetContents());
|
||||
e->emplace_back(entity.Clone());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
ASSERT_TRUE(entity.size() >= 1);
|
||||
ASSERT_TRUE(contents->IsOpaque());
|
||||
ASSERT_EQ(entity.GetBlendMode(), BlendMode::kSource);
|
||||
ASSERT_EQ(entity[0].GetBlendMode(), BlendMode::kSource);
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, CanRenderDestructiveSaveLayer) {
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "impeller/aiks/paint_pass_delegate.h"
|
||||
#include "impeller/entity/contents/atlas_contents.h"
|
||||
#include "impeller/entity/contents/clip_contents.h"
|
||||
#include "impeller/entity/contents/color_source_contents.h"
|
||||
#include "impeller/entity/contents/filters/filter_contents.h"
|
||||
#include "impeller/entity/contents/solid_rrect_blur_contents.h"
|
||||
#include "impeller/entity/contents/text_contents.h"
|
||||
#include "impeller/entity/contents/texture_contents.h"
|
||||
@@ -23,6 +25,80 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
namespace {
|
||||
|
||||
static std::shared_ptr<Contents> CreateContentsForGeometryWithFilters(
|
||||
const Paint& paint,
|
||||
std::shared_ptr<Geometry> geometry) {
|
||||
std::shared_ptr<ColorSourceContents> contents =
|
||||
paint.color_source.GetContents(paint);
|
||||
|
||||
// Attempt to apply the color filter on the CPU first.
|
||||
// Note: This is not just an optimization; some color sources rely on
|
||||
// CPU-applied color filters to behave properly.
|
||||
bool needs_color_filter = paint.HasColorFilter();
|
||||
if (needs_color_filter) {
|
||||
auto color_filter = paint.GetColorFilter();
|
||||
if (contents->ApplyColorFilter(color_filter->GetCPUColorFilterProc())) {
|
||||
needs_color_filter = false;
|
||||
}
|
||||
}
|
||||
|
||||
contents->SetGeometry(std::move(geometry));
|
||||
if (paint.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
|
||||
// colors. CreateMaskBlur is able to handle this case.
|
||||
return paint.mask_blur_descriptor->CreateMaskBlur(
|
||||
contents, needs_color_filter ? paint.GetColorFilter() : nullptr);
|
||||
}
|
||||
|
||||
std::shared_ptr<Contents> contents_copy = std::move(contents);
|
||||
// Image input types will directly set their color filter,
|
||||
// if any. See `TiledTextureContents.SetColorFilter`.
|
||||
if (needs_color_filter &&
|
||||
paint.color_source.GetType() != ColorSource::Type::kImage) {
|
||||
std::shared_ptr<ColorFilter> color_filter = paint.GetColorFilter();
|
||||
contents_copy = color_filter->WrapWithGPUColorFilter(
|
||||
FilterInput::Make(std::move(contents_copy)),
|
||||
ColorFilterContents::AbsorbOpacity::kYes);
|
||||
}
|
||||
|
||||
if (paint.image_filter) {
|
||||
std::shared_ptr<FilterContents> filter = paint.image_filter->WrapInput(
|
||||
FilterInput::Make(std::move(contents_copy)));
|
||||
filter->SetRenderingMode(Entity::RenderingMode::kDirect);
|
||||
return filter;
|
||||
}
|
||||
|
||||
return contents_copy;
|
||||
}
|
||||
|
||||
static std::shared_ptr<Contents> CreatePathContentsWithFilters(
|
||||
const Paint& paint,
|
||||
Path path = {}) {
|
||||
std::shared_ptr<Geometry> geometry;
|
||||
switch (paint.style) {
|
||||
case Paint::Style::kFill:
|
||||
geometry = Geometry::MakeFillPath(std::move(path));
|
||||
break;
|
||||
case Paint::Style::kStroke:
|
||||
geometry = Geometry::MakeStrokePath(std::move(path), paint.stroke_width,
|
||||
paint.stroke_miter, paint.stroke_cap,
|
||||
paint.stroke_join);
|
||||
break;
|
||||
}
|
||||
|
||||
return CreateContentsForGeometryWithFilters(paint, std::move(geometry));
|
||||
}
|
||||
|
||||
static std::shared_ptr<Contents> CreateCoverContentsWithFilters(
|
||||
const Paint& paint) {
|
||||
return CreateContentsForGeometryWithFilters(paint, Geometry::MakeCover());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Canvas::Canvas() {
|
||||
Initialize(std::nullopt);
|
||||
}
|
||||
@@ -176,10 +252,9 @@ void Canvas::DrawPath(Path path, const Paint& paint) {
|
||||
entity.SetTransform(GetCurrentTransform());
|
||||
entity.SetClipDepth(GetClipDepth());
|
||||
entity.SetBlendMode(paint.blend_mode);
|
||||
entity.SetContents(
|
||||
paint.WithFilters(paint.CreateContentsForEntity(std::move(path))));
|
||||
entity.SetContents(CreatePathContentsWithFilters(paint, std::move(path)));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
void Canvas::DrawPaint(const Paint& paint) {
|
||||
@@ -187,9 +262,9 @@ void Canvas::DrawPaint(const Paint& paint) {
|
||||
entity.SetTransform(GetCurrentTransform());
|
||||
entity.SetClipDepth(GetClipDepth());
|
||||
entity.SetBlendMode(paint.blend_mode);
|
||||
entity.SetContents(paint.CreateContentsForEntity({}, true));
|
||||
entity.SetContents(CreateCoverContentsWithFilters(paint));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
|
||||
@@ -227,7 +302,7 @@ bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
|
||||
entity.SetBlendMode(new_paint.blend_mode);
|
||||
entity.SetContents(new_paint.WithFilters(std::move(contents)));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -237,10 +312,10 @@ void Canvas::DrawLine(const Point& p0, const Point& p1, const Paint& paint) {
|
||||
entity.SetTransform(GetCurrentTransform());
|
||||
entity.SetClipDepth(GetClipDepth());
|
||||
entity.SetBlendMode(paint.blend_mode);
|
||||
entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry(
|
||||
Geometry::MakeLine(p0, p1, paint.stroke_width, paint.stroke_cap))));
|
||||
entity.SetContents(CreateContentsForGeometryWithFilters(
|
||||
paint, Geometry::MakeLine(p0, p1, paint.stroke_width, paint.stroke_cap)));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
void Canvas::DrawRect(Rect rect, const Paint& paint) {
|
||||
@@ -257,10 +332,10 @@ void Canvas::DrawRect(Rect rect, const Paint& paint) {
|
||||
entity.SetTransform(GetCurrentTransform());
|
||||
entity.SetClipDepth(GetClipDepth());
|
||||
entity.SetBlendMode(paint.blend_mode);
|
||||
entity.SetContents(paint.WithFilters(
|
||||
paint.CreateContentsForGeometry(Geometry::MakeRect(rect))));
|
||||
entity.SetContents(
|
||||
CreateContentsForGeometryWithFilters(paint, Geometry::MakeRect(rect)));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
void Canvas::DrawRRect(Rect rect, Point corner_radii, const Paint& paint) {
|
||||
@@ -278,10 +353,10 @@ void Canvas::DrawRRect(Rect rect, Point corner_radii, const Paint& paint) {
|
||||
entity.SetTransform(GetCurrentTransform());
|
||||
entity.SetClipDepth(GetClipDepth());
|
||||
entity.SetBlendMode(paint.blend_mode);
|
||||
entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry(
|
||||
Geometry::MakeFillPath(std::move(path)))));
|
||||
entity.SetContents(CreateContentsForGeometryWithFilters(
|
||||
paint, Geometry::MakeFillPath(std::move(path))));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
return;
|
||||
}
|
||||
DrawPath(std::move(path), paint);
|
||||
@@ -304,9 +379,9 @@ void Canvas::DrawCircle(Point center, Scalar radius, const Paint& paint) {
|
||||
? Geometry::MakeStrokedCircle(center, radius, paint.stroke_width)
|
||||
: Geometry::MakeCircle(center, radius);
|
||||
entity.SetContents(
|
||||
paint.WithFilters(paint.CreateContentsForGeometry(geometry)));
|
||||
CreateContentsForGeometryWithFilters(paint, std::move(geometry)));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
void Canvas::ClipPath(Path path, Entity::ClipOperation clip_op) {
|
||||
@@ -401,7 +476,7 @@ void Canvas::ClipGeometry(const std::shared_ptr<Geometry>& geometry,
|
||||
entity.SetContents(std::move(contents));
|
||||
entity.SetClipDepth(GetClipDepth());
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
|
||||
++transform_stack_.back().clip_depth;
|
||||
transform_stack_.back().contains_clips = true;
|
||||
@@ -440,7 +515,7 @@ void Canvas::RestoreClip() {
|
||||
entity.SetContents(std::make_shared<ClipRestoreContents>());
|
||||
entity.SetClipDepth(GetClipDepth());
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
void Canvas::DrawPoints(std::vector<Point> points,
|
||||
@@ -455,11 +530,12 @@ void Canvas::DrawPoints(std::vector<Point> points,
|
||||
entity.SetTransform(GetCurrentTransform());
|
||||
entity.SetClipDepth(GetClipDepth());
|
||||
entity.SetBlendMode(paint.blend_mode);
|
||||
entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry(
|
||||
entity.SetContents(CreateContentsForGeometryWithFilters(
|
||||
paint,
|
||||
Geometry::MakePointField(std::move(points), radius,
|
||||
/*round=*/point_style == PointStyle::kRound))));
|
||||
/*round=*/point_style == PointStyle::kRound)));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
void Canvas::DrawPicture(const Picture& picture) {
|
||||
@@ -533,7 +609,7 @@ void Canvas::DrawImageRect(const std::shared_ptr<Image>& image,
|
||||
entity.SetContents(paint.WithFilters(contents));
|
||||
entity.SetTransform(GetCurrentTransform());
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
Picture Canvas::EndRecordingAsPicture() {
|
||||
@@ -597,7 +673,7 @@ void Canvas::DrawTextFrame(const std::shared_ptr<TextFrame>& text_frame,
|
||||
entity.SetContents(
|
||||
paint.WithFilters(paint.WithMaskBlur(std::move(text_contents), true)));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
static bool UseColorSourceContents(
|
||||
@@ -635,9 +711,8 @@ void Canvas::DrawVertices(const std::shared_ptr<VerticesGeometry>& vertices,
|
||||
// If there are no vertex color or texture coordinates. Or if there
|
||||
// are vertex coordinates then only if the contents are an image.
|
||||
if (UseColorSourceContents(vertices, paint)) {
|
||||
auto contents = paint.CreateContentsForGeometry(vertices);
|
||||
entity.SetContents(paint.WithFilters(std::move(contents)));
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
entity.SetContents(CreateContentsForGeometryWithFilters(paint, vertices));
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -675,7 +750,7 @@ void Canvas::DrawVertices(const std::shared_ptr<VerticesGeometry>& vertices,
|
||||
contents->SetSourceContents(std::move(src_contents));
|
||||
entity.SetContents(paint.WithFilters(std::move(contents)));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
void Canvas::DrawAtlas(const std::shared_ptr<Image>& atlas,
|
||||
@@ -706,7 +781,7 @@ void Canvas::DrawAtlas(const std::shared_ptr<Image>& atlas,
|
||||
entity.SetBlendMode(paint.blend_mode);
|
||||
entity.SetContents(paint.WithFilters(contents));
|
||||
|
||||
GetCurrentPass().AddEntity(entity);
|
||||
GetCurrentPass().AddEntity(std::move(entity));
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -26,24 +26,6 @@ constexpr ColorMatrix kColorInversion = {
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
std::shared_ptr<Contents> Paint::CreateContentsForEntity(Path path,
|
||||
bool cover) const {
|
||||
std::shared_ptr<Geometry> geometry;
|
||||
switch (style) {
|
||||
case Style::kFill:
|
||||
geometry = cover ? Geometry::MakeCover()
|
||||
: Geometry::MakeFillPath(std::move(path));
|
||||
break;
|
||||
case Style::kStroke:
|
||||
geometry = cover ? Geometry::MakeCover()
|
||||
: Geometry::MakeStrokePath(std::move(path), stroke_width,
|
||||
stroke_miter, stroke_cap,
|
||||
stroke_join);
|
||||
break;
|
||||
}
|
||||
return CreateContentsForGeometry(geometry);
|
||||
}
|
||||
|
||||
std::shared_ptr<Contents> Paint::CreateContentsForGeometry(
|
||||
const std::shared_ptr<Geometry>& geometry) const {
|
||||
auto contents = color_source.GetContents(*this);
|
||||
|
||||
@@ -84,9 +84,6 @@ struct Paint {
|
||||
std::shared_ptr<Contents> input,
|
||||
const Matrix& effect_transform = Matrix()) const;
|
||||
|
||||
std::shared_ptr<Contents> CreateContentsForEntity(Path path = {},
|
||||
bool cover = false) const;
|
||||
|
||||
std::shared_ptr<Contents> CreateContentsForGeometry(
|
||||
const std::shared_ptr<Geometry>& geometry) const;
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ std::optional<Rect> FilterContents::GetLocalCoverage(
|
||||
}
|
||||
|
||||
std::optional<Rect> FilterContents::GetCoverage(const Entity& entity) const {
|
||||
Entity entity_with_local_transform = entity;
|
||||
Entity entity_with_local_transform = entity.Clone();
|
||||
entity_with_local_transform.SetTransform(GetTransform(entity.GetTransform()));
|
||||
|
||||
return GetLocalCoverage(entity_with_local_transform);
|
||||
@@ -269,7 +269,7 @@ std::optional<Entity> FilterContents::GetEntity(
|
||||
const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
const std::optional<Rect>& coverage_hint) const {
|
||||
Entity entity_with_local_transform = entity;
|
||||
Entity entity_with_local_transform = entity.Clone();
|
||||
entity_with_local_transform.SetTransform(GetTransform(entity.GetTransform()));
|
||||
|
||||
auto coverage = GetLocalCoverage(entity_with_local_transform);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "impeller/core/formats.h"
|
||||
#include "impeller/entity/contents/filters/inputs/filter_input.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/geometry/matrix.h"
|
||||
#include "impeller/geometry/sigma.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -230,7 +231,7 @@ class FilterContents : public Contents {
|
||||
std::optional<Rect> GetLocalCoverage(const Entity& local_entity) const;
|
||||
|
||||
FilterInput::Vector inputs_;
|
||||
Matrix effect_transform_;
|
||||
Matrix effect_transform_ = Matrix();
|
||||
|
||||
FilterContents(const FilterContents&) = delete;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ Matrix FilterInput::GetLocalTransform(const Entity& entity) const {
|
||||
}
|
||||
|
||||
std::optional<Rect> FilterInput::GetLocalCoverage(const Entity& entity) const {
|
||||
Entity local_entity = entity;
|
||||
Entity local_entity = entity.Clone();
|
||||
local_entity.SetTransform(GetLocalTransform(entity));
|
||||
return GetCoverage(local_entity);
|
||||
}
|
||||
|
||||
@@ -174,6 +174,10 @@ Capture& Entity::GetCapture() const {
|
||||
return capture_;
|
||||
}
|
||||
|
||||
Entity Entity::Clone() const {
|
||||
return Entity(*this);
|
||||
}
|
||||
|
||||
void Entity::SetCapture(Capture capture) const {
|
||||
capture_ = std::move(capture);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ class Entity {
|
||||
|
||||
~Entity();
|
||||
|
||||
Entity(Entity&&) = default;
|
||||
|
||||
/// @brief Get the global transform matrix for this Entity.
|
||||
const Matrix& GetTransform() const;
|
||||
|
||||
@@ -113,7 +115,11 @@ class Entity {
|
||||
|
||||
void SetCapture(Capture capture) const;
|
||||
|
||||
Entity Clone() const;
|
||||
|
||||
private:
|
||||
Entity(const Entity&) = default;
|
||||
|
||||
Matrix transform_;
|
||||
std::shared_ptr<Contents> contents_;
|
||||
BlendMode blend_mode_ = BlendMode::kSourceOver;
|
||||
|
||||
@@ -227,9 +227,10 @@ void EntityPass::AddSubpassInline(std::unique_ptr<EntityPass> pass) {
|
||||
}
|
||||
FML_DCHECK(pass->superpass_ == nullptr);
|
||||
|
||||
elements_.insert(elements_.end(),
|
||||
std::make_move_iterator(pass->elements_.begin()),
|
||||
std::make_move_iterator(pass->elements_.end()));
|
||||
std::vector<Element>& elements = pass->elements_;
|
||||
for (auto i = 0u; i < elements.size(); i++) {
|
||||
elements_.emplace_back(std::move(elements[i]));
|
||||
}
|
||||
|
||||
backdrop_filter_reads_from_pass_texture_ +=
|
||||
pass->backdrop_filter_reads_from_pass_texture_;
|
||||
@@ -474,13 +475,11 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
|
||||
uint32_t pass_depth,
|
||||
ClipCoverageStack& clip_coverage_stack,
|
||||
size_t clip_depth_floor) const {
|
||||
Entity element_entity;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
/// Setup entity element.
|
||||
///
|
||||
if (const auto& entity = std::get_if<Entity>(&element)) {
|
||||
element_entity = *entity;
|
||||
Entity element_entity = entity->Clone();
|
||||
element_entity.SetCapture(capture.CreateChild("Entity"));
|
||||
|
||||
if (!global_pass_position.IsZero()) {
|
||||
@@ -491,7 +490,7 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
|
||||
Matrix::MakeTranslation(Vector3(-global_pass_position)) *
|
||||
element_entity.GetTransform());
|
||||
}
|
||||
return EntityPass::EntityResult::Success(element_entity);
|
||||
return EntityPass::EntityResult::Success(std::move(element_entity));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -661,6 +660,7 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
|
||||
// right thing.
|
||||
return EntityPass::EntityResult::Failure();
|
||||
}
|
||||
Entity element_entity;
|
||||
Capture subpass_texture_capture =
|
||||
capture.CreateChild("Entity (Subpass texture)");
|
||||
element_entity.SetCapture(subpass_texture_capture);
|
||||
@@ -671,7 +671,7 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
|
||||
"Transform", Matrix::MakeTranslation(Vector3(subpass_coverage->origin -
|
||||
global_pass_position))));
|
||||
|
||||
return EntityPass::EntityResult::Success(element_entity);
|
||||
return EntityPass::EntityResult::Success(std::move(element_entity));
|
||||
}
|
||||
FML_UNREACHABLE();
|
||||
}
|
||||
@@ -1084,7 +1084,7 @@ std::unique_ptr<EntityPass> EntityPass::Clone() const {
|
||||
|
||||
for (const auto& element : elements_) {
|
||||
if (auto entity = std::get_if<Entity>(&element)) {
|
||||
new_elements.push_back(*entity);
|
||||
new_elements.push_back(entity->Clone());
|
||||
continue;
|
||||
}
|
||||
if (auto subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
|
||||
@@ -1164,7 +1164,7 @@ void EntityPassClipRecorder::RecordEntity(const Entity& entity,
|
||||
case Contents::ClipCoverage::Type::kNoChange:
|
||||
return;
|
||||
case Contents::ClipCoverage::Type::kAppend:
|
||||
rendered_clip_entities_.push_back(entity);
|
||||
rendered_clip_entities_.push_back(entity.Clone());
|
||||
break;
|
||||
case Contents::ClipCoverage::Type::kRestore:
|
||||
rendered_clip_entities_.pop_back();
|
||||
|
||||
@@ -72,6 +72,7 @@ class EntityPass {
|
||||
|
||||
std::unique_ptr<EntityPass> Clone() const;
|
||||
|
||||
/// @brief Add an entity to the current entity pass.
|
||||
void AddEntity(Entity entity);
|
||||
|
||||
void SetElements(std::vector<Element> elements);
|
||||
@@ -183,7 +184,7 @@ class EntityPass {
|
||||
/// error while resolving the Entity.
|
||||
Status status = kFailure;
|
||||
|
||||
static EntityResult Success(const Entity& e) { return {e, kSuccess}; }
|
||||
static EntityResult Success(Entity e) { return {std::move(e), kSuccess}; }
|
||||
static EntityResult Failure() { return {{}, kFailure}; }
|
||||
static EntityResult Skip() { return {{}, kSkip}; }
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ auto CreatePassWithRectPath(Rect rect,
|
||||
Entity entity;
|
||||
entity.SetContents(SolidColorContents::Make(
|
||||
PathBuilder{}.AddRect(rect).TakePath(), Color::Red()));
|
||||
subpass->AddEntity(entity);
|
||||
subpass->AddEntity(std::move(entity));
|
||||
subpass->SetDelegate(std::make_unique<TestPassDelegate>(collapse));
|
||||
subpass->SetBoundsLimit(bounds_hint);
|
||||
return subpass;
|
||||
@@ -152,7 +152,7 @@ TEST_P(EntityTest, EntityPassCanMergeSubpassIntoParent) {
|
||||
contents->SetColor(Color::Blue());
|
||||
entity.SetContents(std::move(contents));
|
||||
|
||||
pass.AddEntity(entity);
|
||||
pass.AddEntity(std::move(entity));
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(pass));
|
||||
}
|
||||
@@ -221,7 +221,7 @@ TEST_P(EntityTest, CanDrawRect) {
|
||||
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
entity.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, CanDrawRRect) {
|
||||
@@ -237,7 +237,7 @@ TEST_P(EntityTest, CanDrawRRect) {
|
||||
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
entity.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, GeometryBoundsAreTransformed) {
|
||||
@@ -264,7 +264,7 @@ TEST_P(EntityTest, ThreeStrokesInOnePath) {
|
||||
contents->SetGeometry(Geometry::MakeStrokePath(std::move(path), 5.0));
|
||||
contents->SetColor(Color::Red());
|
||||
entity.SetContents(std::move(contents));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, StrokeWithTextureContents) {
|
||||
@@ -285,7 +285,7 @@ TEST_P(EntityTest, StrokeWithTextureContents) {
|
||||
contents->SetTexture(bridge);
|
||||
contents->SetTileModes(Entity::TileMode::kClamp, Entity::TileMode::kClamp);
|
||||
entity.SetContents(std::move(contents));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, TriangleInsideASquare) {
|
||||
@@ -471,7 +471,7 @@ TEST_P(EntityTest, CubicCurveTest) {
|
||||
Entity entity;
|
||||
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
entity.SetContents(SolidColorContents::Make(std::move(path), Color::Red()));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, CanDrawCorrectlyWithRotatedTransform) {
|
||||
@@ -745,7 +745,7 @@ TEST_P(EntityTest, CubicCurveAndOverlapTest) {
|
||||
Entity entity;
|
||||
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
entity.SetContents(SolidColorContents::Make(std::move(path), Color::Red()));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, SolidColorContentsStrokeSetStrokeCapsAndJoins) {
|
||||
@@ -1360,7 +1360,7 @@ TEST_P(EntityTest, DrawAtlasNoColor) {
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(e));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasWithColorAdvanced) {
|
||||
@@ -1395,7 +1395,7 @@ TEST_P(EntityTest, DrawAtlasWithColorAdvanced) {
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(e));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasWithColorSimple) {
|
||||
@@ -1431,7 +1431,7 @@ TEST_P(EntityTest, DrawAtlasWithColorSimple) {
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(e));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasUsesProvidedCullRectForCoverage) {
|
||||
@@ -1504,7 +1504,7 @@ TEST_P(EntityTest, DrawAtlasWithOpacity) {
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(e));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasNoColorFullSize) {
|
||||
@@ -1524,7 +1524,7 @@ TEST_P(EntityTest, DrawAtlasNoColorFullSize) {
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(e));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, SolidFillCoverageIsCorrect) {
|
||||
@@ -2401,7 +2401,7 @@ TEST_P(EntityTest, ColorFilterContentsWithLargeGeometry) {
|
||||
BlendMode::kSourceOver, {FilterInput::Make(dst_contents, false),
|
||||
FilterInput::Make(src_contents, false)});
|
||||
entity.SetContents(std::move(contents));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(entity));
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(entity)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, TextContentsCeilsGlyphScaleToDecimal) {
|
||||
@@ -2465,7 +2465,7 @@ TEST_P(EntityTest, AdvancedBlendCoverageHintIsNotResetByEntityPass) {
|
||||
RenderTarget::kDefaultColorAttachmentConfig, stencil_config);
|
||||
auto content_context = ContentContext(
|
||||
GetContext(), TypographerContextSkia::Make(), test_allocator);
|
||||
pass->AddEntity(entity);
|
||||
pass->AddEntity(std::move(entity));
|
||||
|
||||
EXPECT_TRUE(pass->Render(content_context, rt));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user