From 4c450841f4efe55b8c9cfd9708236b504502479c Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Sun, 26 Mar 2023 01:34:11 -0700 Subject: [PATCH] [Impeller] Fix AtlasContents crash --- impeller/entity/contents/atlas_contents.cc | 17 ++++++++++------- impeller/entity/contents/atlas_contents.h | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/impeller/entity/contents/atlas_contents.cc b/impeller/entity/contents/atlas_contents.cc index f1a82ef6616df..e1065be972d22 100644 --- a/impeller/entity/contents/atlas_contents.cc +++ b/impeller/entity/contents/atlas_contents.cc @@ -304,15 +304,18 @@ bool AtlasTextureContents::Render(const ContentContext& renderer, using VS = TextureFillVertexShader; using FS = TextureFillFragmentShader; - auto texture = texture_.value_or(parent_.GetTexture()); + auto texture = texture_ ? texture_ : parent_.GetTexture(); + if (texture == nullptr) { + return true; + } + std::vector texture_coords; std::vector transforms; - if (subatlas_.has_value()) { - auto subatlas = subatlas_.value(); - texture_coords = use_destination_ ? subatlas->result_texture_coords - : subatlas->sub_texture_coords; - transforms = use_destination_ ? subatlas->result_transforms - : subatlas->sub_transforms; + if (subatlas_) { + texture_coords = use_destination_ ? subatlas_->result_texture_coords + : subatlas_->sub_texture_coords; + transforms = use_destination_ ? subatlas_->result_transforms + : subatlas_->sub_transforms; } else { texture_coords = parent_.GetTextureCoordinates(); transforms = parent_.GetTransforms(); diff --git a/impeller/entity/contents/atlas_contents.h b/impeller/entity/contents/atlas_contents.h index ea2e035a04c2b..67fa20ef66fdf 100644 --- a/impeller/entity/contents/atlas_contents.h +++ b/impeller/entity/contents/atlas_contents.h @@ -118,9 +118,9 @@ class AtlasTextureContents final : public Contents { const AtlasContents& parent_; Scalar alpha_ = 1.0; Rect coverage_; - std::optional> texture_; + std::shared_ptr texture_; bool use_destination_ = false; - std::optional> subatlas_ = std::nullopt; + std::shared_ptr subatlas_; FML_DISALLOW_COPY_AND_ASSIGN(AtlasTextureContents); };