From 810607e52c80d48e5035e7e312130bae3bba90e5 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 24 May 2023 20:54:45 -0700 Subject: [PATCH] [Impeller] Simplify CreateContentsForGeometry overloads (flutter/engine#42306) Came across this while working on generic fallbacks for mask blurs. For the unique_ptr case, we always capture ownership and convert to a shared_ptr anyhow. For the shared_ptr case, we always need to capture a copy, and so better to not take a const ref and allow the caller to move if possible. --- engine/src/flutter/impeller/aiks/paint.cc | 9 +-------- engine/src/flutter/impeller/aiks/paint.h | 5 +---- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/engine/src/flutter/impeller/aiks/paint.cc b/engine/src/flutter/impeller/aiks/paint.cc index fa0dc47eef..2077c00829 100644 --- a/engine/src/flutter/impeller/aiks/paint.cc +++ b/engine/src/flutter/impeller/aiks/paint.cc @@ -27,19 +27,12 @@ std::shared_ptr Paint::CreateContentsForEntity(const Path& path, } std::shared_ptr Paint::CreateContentsForGeometry( - std::unique_ptr geometry) const { + std::shared_ptr geometry) const { auto contents = color_source.GetContents(*this); contents->SetGeometry(std::move(geometry)); return contents; } -std::shared_ptr Paint::CreateContentsForGeometry( - const std::shared_ptr& geometry) const { - auto contents = color_source.GetContents(*this); - contents->SetGeometry(geometry); - return contents; -} - std::shared_ptr Paint::WithFilters( std::shared_ptr input, std::optional is_solid_color) const { diff --git a/engine/src/flutter/impeller/aiks/paint.h b/engine/src/flutter/impeller/aiks/paint.h index 077b5264c0..d14fda6a8f 100644 --- a/engine/src/flutter/impeller/aiks/paint.h +++ b/engine/src/flutter/impeller/aiks/paint.h @@ -94,10 +94,7 @@ struct Paint { bool cover = false) const; std::shared_ptr CreateContentsForGeometry( - std::unique_ptr geometry) const; - - std::shared_ptr CreateContentsForGeometry( - const std::shared_ptr& geometry) const; + std::shared_ptr geometry) const; /// @brief Whether this paint has a color filter that can apply opacity bool HasColorFilter() const;