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

Commit ba6d65f

Browse files
committed
switched up FromSnapshot
1 parent 9da273f commit ba6d65f

File tree

6 files changed

+28
-33
lines changed

6 files changed

+28
-33
lines changed

impeller/entity/contents/filters/blend_filter_contents.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ static std::optional<Entity> AdvancedBlend(
111111
if (!dst_snapshot.has_value()) {
112112
return std::nullopt;
113113
}
114-
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
114+
return Entity::FromSnapshot(dst_snapshot.value(), entity.GetBlendMode(),
115115
entity.GetClipDepth());
116116
}
117117
auto maybe_src_uvs = src_snapshot->GetCoverageUVs(coverage);
118118
if (!maybe_src_uvs.has_value()) {
119119
if (!dst_snapshot.has_value()) {
120120
return std::nullopt;
121121
}
122-
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
122+
return Entity::FromSnapshot(dst_snapshot.value(), entity.GetBlendMode(),
123123
entity.GetClipDepth());
124124
}
125125
src_uvs = maybe_src_uvs.value();
@@ -426,7 +426,7 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
426426
}
427427

428428
if (blend_mode == BlendMode::kDestination) {
429-
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
429+
return Entity::FromSnapshot(dst_snapshot.value(), entity.GetBlendMode(),
430430
entity.GetClipDepth());
431431
}
432432

impeller/entity/contents/filters/gaussian_blur_filter_contents.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,8 @@ Entity ApplyBlurStyle(FilterContents::BlurStyle blur_style,
297297
Entity blurred =
298298
ApplyClippedBlurStyle(Entity::ClipOperation::kIntersect, entity,
299299
input, input_snapshot, std::move(blur_entity));
300-
Entity snapshot_entity =
301-
Entity::FromSnapshot(input_snapshot, entity.GetBlendMode(),
302-
entity.GetClipDepth())
303-
.value();
300+
Entity snapshot_entity = Entity::FromSnapshot(
301+
input_snapshot, entity.GetBlendMode(), entity.GetClipDepth());
304302
Entity result;
305303
result.SetContents(Contents::MakeAnonymous(
306304
fml::MakeCopyable([blurred = blurred.Clone(),
@@ -568,12 +566,8 @@ std::optional<Entity> GaussianBlurFilterContents::RenderFilter(
568566
.opacity = input_snapshot->opacity},
569567
entity.GetBlendMode(), entity.GetClipDepth());
570568

571-
if (!blur_output_entity.has_value()) {
572-
return std::nullopt;
573-
}
574-
575569
return ApplyBlurStyle(blur_style_, entity, inputs[0], input_snapshot.value(),
576-
std::move(blur_output_entity.value()));
570+
std::move(blur_output_entity));
577571
}
578572

579573
Scalar GaussianBlurFilterContents::CalculateBlurRadius(Scalar sigma) {

impeller/entity/contents/filters/local_matrix_filter_contents.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ std::optional<Entity> LocalMatrixFilterContents::RenderFilter(
3737
const Matrix& effect_transform,
3838
const Rect& coverage,
3939
const std::optional<Rect>& coverage_hint) const {
40-
return Entity::FromSnapshot(
41-
inputs[0]->GetSnapshot("LocalMatrix", renderer, entity),
42-
entity.GetBlendMode(), entity.GetClipDepth());
40+
std::optional<Snapshot> snapshot =
41+
inputs[0]->GetSnapshot("LocalMatrix", renderer, entity);
42+
if (!snapshot.has_value()) {
43+
return std::nullopt;
44+
}
45+
return Entity::FromSnapshot(snapshot.value(), entity.GetBlendMode(),
46+
entity.GetClipDepth());
4347
}
4448

4549
} // namespace impeller

impeller/entity/contents/filters/matrix_filter_contents.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ std::optional<Entity> MatrixFilterContents::RenderFilter(
6464
snapshot->transform;
6565

6666
snapshot->sampler_descriptor = sampler_descriptor_;
67-
return Entity::FromSnapshot(snapshot, entity.GetBlendMode(),
67+
if (!snapshot.has_value()) {
68+
return std::nullopt;
69+
}
70+
return Entity::FromSnapshot(snapshot.value(), entity.GetBlendMode(),
6871
entity.GetClipDepth());
6972
}
7073

impeller/entity/entity.cc

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,21 @@
1919

2020
namespace impeller {
2121

22-
std::optional<Entity> Entity::FromSnapshot(
23-
const std::optional<Snapshot>& snapshot,
24-
BlendMode blend_mode,
25-
uint32_t clip_depth) {
26-
if (!snapshot.has_value()) {
27-
return std::nullopt;
28-
}
29-
30-
auto texture_rect = Rect::MakeSize(snapshot->texture->GetSize());
22+
Entity Entity::FromSnapshot(const Snapshot& snapshot,
23+
BlendMode blend_mode,
24+
uint32_t clip_depth) {
25+
auto texture_rect = Rect::MakeSize(snapshot.texture->GetSize());
3126

3227
auto contents = TextureContents::MakeRect(texture_rect);
33-
contents->SetTexture(snapshot->texture);
34-
contents->SetSamplerDescriptor(snapshot->sampler_descriptor);
28+
contents->SetTexture(snapshot.texture);
29+
contents->SetSamplerDescriptor(snapshot.sampler_descriptor);
3530
contents->SetSourceRect(texture_rect);
36-
contents->SetOpacity(snapshot->opacity);
31+
contents->SetOpacity(snapshot.opacity);
3732

3833
Entity entity;
3934
entity.SetBlendMode(blend_mode);
4035
entity.SetClipDepth(clip_depth);
41-
entity.SetTransform(snapshot->transform);
36+
entity.SetTransform(snapshot.transform);
4237
entity.SetContents(contents);
4338
return entity;
4439
}

impeller/entity/entity.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ class Entity {
6262
};
6363

6464
/// @brief Create an entity that can be used to render a given snapshot.
65-
static std::optional<Entity> FromSnapshot(
66-
const std::optional<Snapshot>& snapshot,
67-
BlendMode blend_mode = BlendMode::kSourceOver,
68-
uint32_t clip_depth = 0);
65+
static Entity FromSnapshot(const Snapshot& snapshot,
66+
BlendMode blend_mode = BlendMode::kSourceOver,
67+
uint32_t clip_depth = 0);
6968

7069
Entity();
7170

0 commit comments

Comments
 (0)