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

Commit 5be21e2

Browse files
authored
[Impeller] Fix AtlasContents crash (#40637)
1 parent 61b92a7 commit 5be21e2

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

impeller/entity/contents/atlas_contents.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,18 @@ bool AtlasTextureContents::Render(const ContentContext& renderer,
304304
using VS = TextureFillVertexShader;
305305
using FS = TextureFillFragmentShader;
306306

307-
auto texture = texture_.value_or(parent_.GetTexture());
307+
auto texture = texture_ ? texture_ : parent_.GetTexture();
308+
if (texture == nullptr) {
309+
return true;
310+
}
311+
308312
std::vector<Rect> texture_coords;
309313
std::vector<Matrix> transforms;
310-
if (subatlas_.has_value()) {
311-
auto subatlas = subatlas_.value();
312-
texture_coords = use_destination_ ? subatlas->result_texture_coords
313-
: subatlas->sub_texture_coords;
314-
transforms = use_destination_ ? subatlas->result_transforms
315-
: subatlas->sub_transforms;
314+
if (subatlas_) {
315+
texture_coords = use_destination_ ? subatlas_->result_texture_coords
316+
: subatlas_->sub_texture_coords;
317+
transforms = use_destination_ ? subatlas_->result_transforms
318+
: subatlas_->sub_transforms;
316319
} else {
317320
texture_coords = parent_.GetTextureCoordinates();
318321
transforms = parent_.GetTransforms();

impeller/entity/contents/atlas_contents.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ class AtlasTextureContents final : public Contents {
118118
const AtlasContents& parent_;
119119
Scalar alpha_ = 1.0;
120120
Rect coverage_;
121-
std::optional<std::shared_ptr<Texture>> texture_;
121+
std::shared_ptr<Texture> texture_;
122122
bool use_destination_ = false;
123-
std::optional<std::shared_ptr<SubAtlasResult>> subatlas_ = std::nullopt;
123+
std::shared_ptr<SubAtlasResult> subatlas_;
124124

125125
FML_DISALLOW_COPY_AND_ASSIGN(AtlasTextureContents);
126126
};

0 commit comments

Comments
 (0)