diff --git a/.clang-tidy b/.clang-tidy index 25c20c5c95e2f..60dc76bf226fc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,7 +10,9 @@ readability-identifier-naming,\ -clang-analyzer-nullability.NullPassedToNonnull,\ -clang-analyzer-nullability.NullablePassedToNonnull,\ -clang-analyzer-nullability.NullReturnedFromNonnull,\ --clang-analyzer-nullability.NullableReturnedFromNonnull" +-clang-analyzer-nullability.NullableReturnedFromNonnull,\ +performance-move-const-arg,\ +performance-unnecessary-value-param" # Only warnings treated as errors are reported # in the "ci/lint.sh" script and pre-push git hook. diff --git a/common/graphics/persistent_cache.cc b/common/graphics/persistent_cache.cc index a68186688a0ba..50d09bb8fcbc6 100644 --- a/common/graphics/persistent_cache.cc +++ b/common/graphics/persistent_cache.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include "flutter/fml/base32.h" #include "flutter/fml/file.h" @@ -74,7 +75,7 @@ void PersistentCache::ResetCacheForProcess() { } void PersistentCache::SetCacheDirectoryPath(std::string path) { - cache_base_path_ = path; + cache_base_path_ = std::move(path); } bool PersistentCache::Purge() { @@ -343,10 +344,11 @@ sk_sp PersistentCache::load(const SkData& key) { return result; } -static void PersistentCacheStore(fml::RefPtr worker, - std::shared_ptr cache_directory, - std::string key, - std::unique_ptr value) { +static void PersistentCacheStore( + const fml::RefPtr& worker, + const std::shared_ptr& cache_directory, + std::string key, + std::unique_ptr value) { // The static leak checker gets confused by the use of fml::MakeCopyable. // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) auto task = fml::MakeCopyable([cache_directory, // @@ -440,13 +442,13 @@ void PersistentCache::DumpSkp(const SkData& data) { } void PersistentCache::AddWorkerTaskRunner( - fml::RefPtr task_runner) { + const fml::RefPtr& task_runner) { std::scoped_lock lock(worker_task_runners_mutex_); worker_task_runners_.insert(task_runner); } void PersistentCache::RemoveWorkerTaskRunner( - fml::RefPtr task_runner) { + const fml::RefPtr& task_runner) { std::scoped_lock lock(worker_task_runners_mutex_); auto found = worker_task_runners_.find(task_runner); if (found != worker_task_runners_.end()) { @@ -467,7 +469,7 @@ fml::RefPtr PersistentCache::GetWorkerTaskRunner() const { void PersistentCache::SetAssetManager(std::shared_ptr value) { TRACE_EVENT_INSTANT0("flutter", "PersistentCache::SetAssetManager"); - asset_manager_ = value; + asset_manager_ = std::move(value); } std::vector> diff --git a/common/graphics/persistent_cache.h b/common/graphics/persistent_cache.h index 3266654069e39..cee0254736a28 100644 --- a/common/graphics/persistent_cache.h +++ b/common/graphics/persistent_cache.h @@ -68,9 +68,9 @@ class PersistentCache : public GrContextOptions::PersistentCache { ~PersistentCache() override; - void AddWorkerTaskRunner(fml::RefPtr task_runner); + void AddWorkerTaskRunner(const fml::RefPtr& task_runner); - void RemoveWorkerTaskRunner(fml::RefPtr task_runner); + void RemoveWorkerTaskRunner(const fml::RefPtr& task_runner); // Whether Skia tries to store any shader into this persistent cache after // |ResetStoredNewShaders| is called. This flag is usually reset before each diff --git a/common/graphics/texture.cc b/common/graphics/texture.cc index f12a5959fc088..318dcc244b928 100644 --- a/common/graphics/texture.cc +++ b/common/graphics/texture.cc @@ -16,7 +16,7 @@ Texture::~Texture() = default; TextureRegistry::TextureRegistry() = default; -void TextureRegistry::RegisterTexture(std::shared_ptr texture) { +void TextureRegistry::RegisterTexture(const std::shared_ptr& texture) { if (!texture) { return; } diff --git a/common/graphics/texture.h b/common/graphics/texture.h index 69cfa3ba0f9a4..0edb84526f994 100644 --- a/common/graphics/texture.h +++ b/common/graphics/texture.h @@ -62,7 +62,7 @@ class TextureRegistry { TextureRegistry(); // Called from raster thread. - void RegisterTexture(std::shared_ptr texture); + void RegisterTexture(const std::shared_ptr& texture); // Called from raster thread. void RegisterContextListener(uintptr_t id, diff --git a/display_list/display_list_builder.cc b/display_list/display_list_builder.cc index 5adcb3b5b729e..c9de7c4f2c3a4 100644 --- a/display_list/display_list_builder.cc +++ b/display_list/display_list_builder.cc @@ -897,7 +897,7 @@ void DisplayListBuilder::drawImage(const sk_sp image, : Push(0, 1, std::move(image), point, sampling); CheckLayerOpacityCompatibility(render_with_attributes); } -void DisplayListBuilder::drawImage(const sk_sp image, +void DisplayListBuilder::drawImage(const sk_sp& image, const SkPoint point, DlImageSampling sampling, const DlPaint* paint) { @@ -919,7 +919,7 @@ void DisplayListBuilder::drawImageRect(const sk_sp image, render_with_attributes, constraint); CheckLayerOpacityCompatibility(render_with_attributes); } -void DisplayListBuilder::drawImageRect(const sk_sp image, +void DisplayListBuilder::drawImageRect(const sk_sp& image, const SkRect& src, const SkRect& dst, DlImageSampling sampling, @@ -944,7 +944,7 @@ void DisplayListBuilder::drawImageNine(const sk_sp image, : Push(0, 1, std::move(image), center, dst, filter); CheckLayerOpacityCompatibility(render_with_attributes); } -void DisplayListBuilder::drawImageNine(const sk_sp image, +void DisplayListBuilder::drawImageNine(const sk_sp& image, const SkIRect& center, const SkRect& dst, DlFilterMode filter, @@ -1017,7 +1017,7 @@ void DisplayListBuilder::drawAtlas(const sk_sp atlas, // of the transforms and texture rectangles. UpdateLayerOpacityCompatibility(false); } -void DisplayListBuilder::drawAtlas(const sk_sp atlas, +void DisplayListBuilder::drawAtlas(const sk_sp& atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], diff --git a/display_list/display_list_builder.h b/display_list/display_list_builder.h index 759b7280ed0f1..8bcc3ffa56db6 100644 --- a/display_list/display_list_builder.h +++ b/display_list/display_list_builder.h @@ -275,7 +275,7 @@ class DisplayListBuilder final : public virtual Dispatcher, const SkPoint point, DlImageSampling sampling, bool render_with_attributes) override; - void drawImage(const sk_sp image, + void drawImage(const sk_sp& image, const SkPoint point, DlImageSampling sampling, const DlPaint* paint = nullptr); @@ -287,7 +287,7 @@ class DisplayListBuilder final : public virtual Dispatcher, bool render_with_attributes, SkCanvas::SrcRectConstraint constraint = SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint) override; - void drawImageRect(const sk_sp image, + void drawImageRect(const sk_sp& image, const SkRect& src, const SkRect& dst, DlImageSampling sampling, @@ -299,7 +299,7 @@ class DisplayListBuilder final : public virtual Dispatcher, const SkRect& dst, DlFilterMode filter, bool render_with_attributes) override; - void drawImageNine(const sk_sp image, + void drawImageNine(const sk_sp& image, const SkIRect& center, const SkRect& dst, DlFilterMode filter, @@ -318,7 +318,7 @@ class DisplayListBuilder final : public virtual Dispatcher, DlImageSampling sampling, const SkRect* cullRect, bool render_with_attributes) override; - void drawAtlas(const sk_sp atlas, + void drawAtlas(const sk_sp& atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], diff --git a/display_list/display_list_canvas_unittests.cc b/display_list/display_list_canvas_unittests.cc index 346523b60b9f2..0c285c1fde4e4 100644 --- a/display_list/display_list_canvas_unittests.cc +++ b/display_list/display_list_canvas_unittests.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + #include "flutter/display_list/display_list.h" #include "flutter/display_list/display_list_canvas_dispatcher.h" #include "flutter/display_list/display_list_canvas_recorder.h" @@ -239,7 +241,8 @@ static void EmptyDlRenderer(DisplayListBuilder&) {} class RenderSurface { public: - explicit RenderSurface(sk_sp surface) : surface_(surface) { + explicit RenderSurface(sk_sp surface) + : surface_(std::move(surface)) { EXPECT_EQ(canvas()->save(), 1); } ~RenderSurface() { sk_free(addr_); } @@ -597,10 +600,10 @@ class TestParameters { class CaseParameters { public: explicit CaseParameters(std::string info) - : CaseParameters(info, EmptyCvRenderer, EmptyDlRenderer) {} + : CaseParameters(std::move(info), EmptyCvRenderer, EmptyDlRenderer) {} - CaseParameters(std::string info, CvSetup cv_setup, DlRenderer dl_setup) - : CaseParameters(info, + CaseParameters(std::string info, CvSetup& cv_setup, DlRenderer& dl_setup) + : CaseParameters(std::move(info), cv_setup, dl_setup, EmptyCvRenderer, @@ -611,15 +614,15 @@ class CaseParameters { false) {} CaseParameters(std::string info, - CvSetup cv_setup, - DlRenderer dl_setup, - CvRenderer cv_restore, - DlRenderer dl_restore, + CvSetup& cv_setup, + DlRenderer& dl_setup, + CvRenderer& cv_restore, + DlRenderer& dl_restore, DlColor bg, bool has_diff_clip, bool has_mutating_save_layer, bool fuzzy_compare_components) - : info_(info), + : info_(std::move(info)), bg_(bg), cv_setup_(cv_setup), dl_setup_(dl_setup), @@ -629,8 +632,8 @@ class CaseParameters { has_mutating_save_layer_(has_mutating_save_layer), fuzzy_compare_components_(fuzzy_compare_components) {} - CaseParameters with_restore(CvRenderer cv_restore, - DlRenderer dl_restore, + CaseParameters with_restore(CvRenderer& cv_restore, + DlRenderer& dl_restore, bool mutating_layer, bool fuzzy_compare_components = false) { return CaseParameters(info_, cv_setup_, dl_setup_, cv_restore, dl_restore, @@ -1945,9 +1948,9 @@ class CanvasCompareTester { } static void checkGroupOpacity(const RenderEnvironment& env, - sk_sp display_list, + const sk_sp& display_list, const SkPixmap* ref_pixmap, - const std::string info, + const std::string& info, DlColor bg) { SkScalar opacity = 128.0 / 255.0; @@ -2002,7 +2005,7 @@ class CanvasCompareTester { static void checkPixels(const SkPixmap* ref_pixels, const SkRect ref_bounds, - const std::string info, + const std::string& info, const DlColor bg) { uint32_t untouched = bg.premultipliedArgb(); int pixels_touched = 0; @@ -2026,7 +2029,7 @@ class CanvasCompareTester { static void quickCompareToReference(const SkPixmap* ref_pixels, const SkPixmap* test_pixels, bool should_match, - const std::string info) { + const std::string& info) { ASSERT_EQ(test_pixels->width(), ref_pixels->width()) << info; ASSERT_EQ(test_pixels->height(), ref_pixels->height()) << info; ASSERT_EQ(test_pixels->info().bytesPerPixel(), 4) << info; @@ -2050,7 +2053,7 @@ class CanvasCompareTester { static void compareToReference(const SkPixmap* test_pixels, const SkPixmap* ref_pixels, - const std::string info, + const std::string& info, SkRect* bounds, const BoundsTolerance* tolerance, const DlColor bg, @@ -2121,7 +2124,7 @@ class CanvasCompareTester { ASSERT_EQ(pixels_different, 0) << info; } - static void showBoundsOverflow(std::string info, + static void showBoundsOverflow(const std::string& info, SkIRect& bounds, const BoundsTolerance* tolerance, int pixLeft, @@ -2186,7 +2189,7 @@ class CanvasCompareTester { static const DlImageColorSource kTestImageColorSource; - static sk_sp MakeTextBlob(std::string string, + static sk_sp MakeTextBlob(const std::string& string, SkScalar font_height) { SkFont font(SkTypeface::MakeFromName("ahem", SkFontStyle::Normal()), font_height); diff --git a/display_list/display_list_mask_filter_unittests.cc b/display_list/display_list_mask_filter_unittests.cc index ea79eee36fb6f..5a46856e22cf7 100644 --- a/display_list/display_list_mask_filter_unittests.cc +++ b/display_list/display_list_mask_filter_unittests.cc @@ -131,7 +131,7 @@ void testNotEquals(DlMaskFilter* a, DlMaskFilter* b) { ASSERT_TRUE(NotEquals(b, a)); } -void testEquals(std::shared_ptr a, DlMaskFilter* b) { +void testEquals(const std::shared_ptr& a, DlMaskFilter* b) { // a and b have the same nullness or values ASSERT_TRUE(Equals(a, b)); ASSERT_FALSE(NotEquals(a, b)); @@ -139,7 +139,8 @@ void testEquals(std::shared_ptr a, DlMaskFilter* b) { ASSERT_FALSE(NotEquals(b, a)); } -void testNotEquals(std::shared_ptr a, DlMaskFilter* b) { +void testNotEquals(const std::shared_ptr& a, + DlMaskFilter* b) { // a and b do not have the same nullness or values ASSERT_FALSE(Equals(a, b)); ASSERT_TRUE(NotEquals(a, b)); @@ -147,8 +148,8 @@ void testNotEquals(std::shared_ptr a, DlMaskFilter* b) { ASSERT_TRUE(NotEquals(b, a)); } -void testEquals(std::shared_ptr a, - std::shared_ptr b) { +void testEquals(const std::shared_ptr& a, + const std::shared_ptr& b) { // a and b have the same nullness or values ASSERT_TRUE(Equals(a, b)); ASSERT_FALSE(NotEquals(a, b)); @@ -156,8 +157,8 @@ void testEquals(std::shared_ptr a, ASSERT_FALSE(NotEquals(b, a)); } -void testNotEquals(std::shared_ptr a, - std::shared_ptr b) { +void testNotEquals(const std::shared_ptr& a, + const std::shared_ptr& b) { // a and b do not have the same nullness or values ASSERT_FALSE(Equals(a, b)); ASSERT_TRUE(NotEquals(a, b)); diff --git a/display_list/display_list_unittests.cc b/display_list/display_list_unittests.cc index b06ce5914c0fd..9ca2877a046a6 100644 --- a/display_list/display_list_unittests.cc +++ b/display_list/display_list_unittests.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "flutter/display_list/display_list.h" @@ -591,7 +592,7 @@ TEST(DisplayList, DisplayListTransformResetHandling) { } TEST(DisplayList, SingleOpsMightSupportGroupOpacityWithOrWithoutBlendMode) { - auto run_tests = [](std::string name, + auto run_tests = [](const std::string& name, void build(DisplayListBuilder & builder), bool expect_for_op, bool expect_with_kSrc) { { @@ -783,12 +784,12 @@ class SaveLayerOptionsExpector : public virtual Dispatcher, public IgnoreTransformDispatchHelper, public IgnoreDrawDispatchHelper { public: - explicit SaveLayerOptionsExpector(SaveLayerOptions expected) { + explicit SaveLayerOptionsExpector(const SaveLayerOptions& expected) { expected_.push_back(expected); } explicit SaveLayerOptionsExpector(std::vector expected) - : expected_(expected) {} + : expected_(std::move(expected)) {} void saveLayer(const SkRect* bounds, const SaveLayerOptions options, @@ -1541,10 +1542,10 @@ TEST(DisplayList, FlatDrawPointsProducesBounds) { } } -static void test_rtree(sk_sp rtree, +static void test_rtree(const sk_sp& rtree, const SkRect& query, std::vector expected_rects, - std::vector expected_indices) { + const std::vector& expected_indices) { std::vector indices; rtree->search(query, &indices); EXPECT_EQ(indices, expected_indices); diff --git a/flow/compositor_context.cc b/flow/compositor_context.cc index e8fd35984bbdf..b40df6a186dab 100644 --- a/flow/compositor_context.cc +++ b/flow/compositor_context.cc @@ -5,6 +5,7 @@ #include "flutter/flow/compositor_context.h" #include +#include #include "flutter/flow/layers/layer_tree.h" #include "third_party/skia/include/core/SkCanvas.h" @@ -106,7 +107,7 @@ CompositorContext::ScopedFrame::ScopedFrame( root_surface_transformation_(root_surface_transformation), instrumentation_enabled_(instrumentation_enabled), surface_supports_readback_(surface_supports_readback), - raster_thread_merger_(raster_thread_merger) { + raster_thread_merger_(std::move(raster_thread_merger)) { context_.BeginFrame(*this, instrumentation_enabled_); } diff --git a/flow/diff_context.cc b/flow/diff_context.cc index abf3af1325d3f..dafea24ddd7f3 100644 --- a/flow/diff_context.cc +++ b/flow/diff_context.cc @@ -31,7 +31,7 @@ void DiffContext::EndSubtree() { if (state_.has_filter_bounds_adjustment) { filter_bounds_adjustment_stack_.pop_back(); } - state_ = std::move(state_stack_.back()); + state_ = state_stack_.back(); state_stack_.pop_back(); } @@ -50,7 +50,8 @@ void DiffContext::SetTransform(const SkMatrix& transform) { state_.transform = transform; } -void DiffContext::PushFilterBoundsAdjustment(FilterBoundsAdjustment filter) { +void DiffContext::PushFilterBoundsAdjustment( + const FilterBoundsAdjustment& filter) { FML_DCHECK(state_.has_filter_bounds_adjustment == false); state_.has_filter_bounds_adjustment = true; filter_bounds_adjustment_stack_.push_back(filter); diff --git a/flow/diff_context.h b/flow/diff_context.h index 9fcf227ddbfa7..586c6cb255938 100644 --- a/flow/diff_context.h +++ b/flow/diff_context.h @@ -81,7 +81,7 @@ class DiffContext { // Pushes filter bounds adjustment to current subtree. Every layer in this // subtree will have bounds adjusted by this function. - void PushFilterBoundsAdjustment(FilterBoundsAdjustment filter); + void PushFilterBoundsAdjustment(const FilterBoundsAdjustment& filter); // Returns transform matrix for current subtree const SkMatrix& GetTransform() const { return state_.transform; } diff --git a/flow/embedded_views.cc b/flow/embedded_views.cc index 959986dada16f..ebc1812755488 100644 --- a/flow/embedded_views.cc +++ b/flow/embedded_views.cc @@ -100,7 +100,7 @@ void MutatorsStack::PushOpacity(const int& alpha) { }; void MutatorsStack::PushBackdropFilter( - std::shared_ptr filter) { + const std::shared_ptr& filter) { std::shared_ptr element = std::make_shared(filter); vector_.push_back(element); }; diff --git a/flow/embedded_views.h b/flow/embedded_views.h index cc252ae527835..14ca2ba12b348 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -154,7 +154,7 @@ class MutatorsStack { void PushClipPath(const SkPath& path); void PushTransform(const SkMatrix& matrix); void PushOpacity(const int& alpha); - void PushBackdropFilter(std::shared_ptr filter); + void PushBackdropFilter(const std::shared_ptr& filter); // Removes the `Mutator` on the top of the stack // and destroys it. diff --git a/flow/layers/clip_path_layer_unittests.cc b/flow/layers/clip_path_layer_unittests.cc index f0b49083caf60..4408185aed5e2 100644 --- a/flow/layers/clip_path_layer_unittests.cc +++ b/flow/layers/clip_path_layer_unittests.cc @@ -209,7 +209,7 @@ TEST_F(ClipPathLayerTest, PartiallyContainedChild) { static bool ReadbackResult(PrerollContext* context, Clip clip_behavior, - std::shared_ptr child, + const std::shared_ptr& child, bool before) { const SkMatrix initial_matrix = SkMatrix(); const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0); diff --git a/flow/layers/clip_rect_layer_unittests.cc b/flow/layers/clip_rect_layer_unittests.cc index 49f640c435883..2b11cb588dd65 100644 --- a/flow/layers/clip_rect_layer_unittests.cc +++ b/flow/layers/clip_rect_layer_unittests.cc @@ -205,7 +205,7 @@ TEST_F(ClipRectLayerTest, PartiallyContainedChild) { static bool ReadbackResult(PrerollContext* context, Clip clip_behavior, - std::shared_ptr child, + const std::shared_ptr& child, bool before) { const SkMatrix initial_matrix = SkMatrix(); const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0); diff --git a/flow/layers/clip_rrect_layer_unittests.cc b/flow/layers/clip_rrect_layer_unittests.cc index 9709d08be2c52..918c36ec47e44 100644 --- a/flow/layers/clip_rrect_layer_unittests.cc +++ b/flow/layers/clip_rrect_layer_unittests.cc @@ -209,7 +209,7 @@ TEST_F(ClipRRectLayerTest, PartiallyContainedChild) { static bool ReadbackResult(PrerollContext* context, Clip clip_behavior, - std::shared_ptr child, + const std::shared_ptr& child, bool before) { const SkMatrix initial_matrix = SkMatrix(); const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0); diff --git a/flow/layers/layer_tree.cc b/flow/layers/layer_tree.cc index 3b4907b5336bf..0e5aacc98fe92 100644 --- a/flow/layers/layer_tree.cc +++ b/flow/layers/layer_tree.cc @@ -173,7 +173,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame, sk_sp LayerTree::Flatten( const SkRect& bounds, - std::shared_ptr texture_registry, + const std::shared_ptr& texture_registry, GrDirectContext* gr_context) { TRACE_EVENT0("flutter", "LayerTree::Flatten"); diff --git a/flow/layers/layer_tree.h b/flow/layers/layer_tree.h index 167500400b758..fba4180975e44 100644 --- a/flow/layers/layer_tree.h +++ b/flow/layers/layer_tree.h @@ -44,7 +44,7 @@ class LayerTree { sk_sp Flatten( const SkRect& bounds, - std::shared_ptr texture_registry = nullptr, + const std::shared_ptr& texture_registry = nullptr, GrDirectContext* gr_context = nullptr); Layer* root_layer() const { return root_layer_.get(); } diff --git a/flow/layers/offscreen_surface.cc b/flow/layers/offscreen_surface.cc index dc50bd8bc1cd9..cb29360e576ad 100644 --- a/flow/layers/offscreen_surface.cc +++ b/flow/layers/offscreen_surface.cc @@ -33,7 +33,7 @@ static sk_sp CreateSnapshotSurface(GrDirectContext* surface_context, /// Returns a buffer containing a snapshot of the surface. /// /// If compressed is true the data is encoded as PNG. -static sk_sp GetRasterData(sk_sp offscreen_surface, +static sk_sp GetRasterData(const sk_sp& offscreen_surface, bool compressed) { // Prepare an image from the surface, this image may potentially be on th GPU. auto potentially_gpu_snapshot = offscreen_surface->makeImageSnapshot(); diff --git a/flow/layers/physical_shape_layer_unittests.cc b/flow/layers/physical_shape_layer_unittests.cc index 41ec9e37543ab..97937a9de8c97 100644 --- a/flow/layers/physical_shape_layer_unittests.cc +++ b/flow/layers/physical_shape_layer_unittests.cc @@ -355,7 +355,7 @@ TEST_F(PhysicalShapeLayerTest, ShadowNotDependsPathSize) { static bool ReadbackResult(PrerollContext* context, Clip clip_behavior, - std::shared_ptr child, + const std::shared_ptr& child, bool before) { const SkMatrix initial_matrix = SkMatrix(); const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0); diff --git a/flow/skia_gpu_object_unittests.cc b/flow/skia_gpu_object_unittests.cc index 1a523af7b9575..b6b439ffba830 100644 --- a/flow/skia_gpu_object_unittests.cc +++ b/flow/skia_gpu_object_unittests.cc @@ -5,6 +5,7 @@ #include "flutter/flow/skia_gpu_object.h" #include +#include #include "flutter/fml/message_loop.h" #include "flutter/fml/synchronization/waitable_event.h" @@ -20,7 +21,7 @@ class TestSkObject : public SkRefCnt { public: TestSkObject(std::shared_ptr latch, fml::TaskQueueId* dtor_task_queue_id) - : latch_(latch), dtor_task_queue_id_(dtor_task_queue_id) {} + : latch_(std::move(latch)), dtor_task_queue_id_(dtor_task_queue_id) {} virtual ~TestSkObject() { if (dtor_task_queue_id_) { @@ -38,10 +39,10 @@ class TestResourceContext : public TestSkObject { public: TestResourceContext(std::shared_ptr latch, fml::TaskQueueId* dtor_task_queue_id) - : TestSkObject(latch, dtor_task_queue_id) {} + : TestSkObject(std::move(latch), dtor_task_queue_id) {} ~TestResourceContext() = default; void performDeferredCleanup(std::chrono::milliseconds msNotUsed) {} - void deleteBackendTexture(GrBackendTexture texture) {} + void deleteBackendTexture(const GrBackendTexture& texture) {} }; class SkiaGpuObjectTest : public ThreadTest { diff --git a/flow/surface_frame.cc b/flow/surface_frame.cc index 947cf0f201326..44c9f706d4e2c 100644 --- a/flow/surface_frame.cc +++ b/flow/surface_frame.cc @@ -5,6 +5,7 @@ #include "flutter/flow/surface_frame.h" #include +#include #include "flutter/fml/logging.h" #include "flutter/fml/trace_event.h" @@ -18,8 +19,8 @@ SurfaceFrame::SurfaceFrame(sk_sp surface, SkISize frame_size, std::unique_ptr context_result, bool display_list_fallback) - : surface_(surface), - framebuffer_info_(std::move(framebuffer_info)), + : surface_(std::move(surface)), + framebuffer_info_(framebuffer_info), submit_callback_(submit_callback), context_result_(std::move(context_result)) { FML_DCHECK(submit_callback_); diff --git a/flow/testing/diff_context_test.cc b/flow/testing/diff_context_test.cc index 47b35f5b80258..888923af483ca 100644 --- a/flow/testing/diff_context_test.cc +++ b/flow/testing/diff_context_test.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "diff_context_test.h" + +#include #include "flutter/display_list/display_list_builder.h" namespace flutter { @@ -42,7 +44,8 @@ std::shared_ptr DiffContextTest::CreateDisplayListLayer( sk_sp display_list, const SkPoint& offset) { return std::make_shared( - offset, SkiaGPUObject(display_list, unref_queue()), false, false); + offset, SkiaGPUObject(std::move(display_list), unref_queue()), false, + false); } std::shared_ptr DiffContextTest::CreateContainerLayer( diff --git a/flow/testing/mock_layer.cc b/flow/testing/mock_layer.cc index 755944cbe14fa..838095ad49389 100644 --- a/flow/testing/mock_layer.cc +++ b/flow/testing/mock_layer.cc @@ -4,14 +4,16 @@ #include "flutter/flow/testing/mock_layer.h" +#include + #include "flutter/flow/layers/container_layer.h" #include "flutter/flow/layers/layer.h" #include "flutter/flow/testing/mock_raster_cache.h" namespace flutter { namespace testing { -MockLayer::MockLayer(SkPath path, SkPaint paint) - : fake_paint_path_(path), fake_paint_(paint) {} +MockLayer::MockLayer(const SkPath& path, SkPaint paint) + : fake_paint_path_(path), fake_paint_(std::move(paint)) {} bool MockLayer::IsReplacing(DiffContext* context, const Layer* layer) const { // Similar to PictureLayer, only return true for identical mock layers; diff --git a/flow/testing/mock_layer.h b/flow/testing/mock_layer.h index 20fc73e4e8341..bc351f3fc3270 100644 --- a/flow/testing/mock_layer.h +++ b/flow/testing/mock_layer.h @@ -24,7 +24,7 @@ namespace testing { // verify the data against expected values. class MockLayer : public Layer { public: - explicit MockLayer(SkPath path, SkPaint paint = SkPaint()); + explicit MockLayer(const SkPath& path, SkPaint paint = SkPaint()); static std::shared_ptr Make(SkPath path, SkPaint paint = SkPaint()) { diff --git a/fml/concurrent_message_loop.cc b/fml/concurrent_message_loop.cc index abb7f491296de..681b983fca3ed 100644 --- a/fml/concurrent_message_loop.cc +++ b/fml/concurrent_message_loop.cc @@ -123,7 +123,7 @@ void ConcurrentMessageLoop::Terminate() { tasks_condition_.notify_all(); } -void ConcurrentMessageLoop::PostTaskToAllWorkers(fml::closure task) { +void ConcurrentMessageLoop::PostTaskToAllWorkers(const fml::closure& task) { if (!task) { return; } diff --git a/fml/concurrent_message_loop.h b/fml/concurrent_message_loop.h index b79f3091767e4..c043705935e57 100644 --- a/fml/concurrent_message_loop.h +++ b/fml/concurrent_message_loop.h @@ -32,7 +32,7 @@ class ConcurrentMessageLoop void Terminate(); - void PostTaskToAllWorkers(fml::closure task); + void PostTaskToAllWorkers(const fml::closure& task); private: friend ConcurrentTaskRunner; diff --git a/fml/icu_util.cc b/fml/icu_util.cc index d05c68677582f..12e7392925e4c 100644 --- a/fml/icu_util.cc +++ b/fml/icu_util.cc @@ -57,8 +57,7 @@ class ICUContext { std::initializer_list protection = { fml::FileMapping::Protection::kRead}; - auto file_mapping = - std::make_unique(fd, std::move(protection)); + auto file_mapping = std::make_unique(fd, protection); if (file_mapping->GetSize() != 0) { mapping_ = std::move(file_mapping); diff --git a/fml/message_loop_task_queues_merge_unmerge_unittests.cc b/fml/message_loop_task_queues_merge_unmerge_unittests.cc index ff16929b5a5c3..e3e40d4f4a8d4 100644 --- a/fml/message_loop_task_queues_merge_unmerge_unittests.cc +++ b/fml/message_loop_task_queues_merge_unmerge_unittests.cc @@ -5,6 +5,7 @@ #define FML_USED_ON_EMBEDDER #include +#include #include "flutter/fml/message_loop_task_queues.h" #include "flutter/fml/synchronization/count_down_latch.h" @@ -19,7 +20,7 @@ class TestWakeable : public fml::Wakeable { public: using WakeUpCall = std::function; - explicit TestWakeable(WakeUpCall call) : wake_up_call_(call) {} + explicit TestWakeable(WakeUpCall call) : wake_up_call_(std::move(call)) {} void WakeUp(fml::TimePoint time_point) override { wake_up_call_(time_point); } diff --git a/fml/message_loop_task_queues_unittests.cc b/fml/message_loop_task_queues_unittests.cc index 792156d4df015..f9753ea8ad34c 100644 --- a/fml/message_loop_task_queues_unittests.cc +++ b/fml/message_loop_task_queues_unittests.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include "flutter/fml/synchronization/count_down_latch.h" #include "flutter/fml/synchronization/waitable_event.h" @@ -22,7 +23,7 @@ class TestWakeable : public fml::Wakeable { public: using WakeUpCall = std::function; - explicit TestWakeable(WakeUpCall call) : wake_up_call_(call) {} + explicit TestWakeable(WakeUpCall call) : wake_up_call_(std::move(call)) {} void WakeUp(fml::TimePoint time_point) override { wake_up_call_(time_point); } diff --git a/fml/raster_thread_merger.cc b/fml/raster_thread_merger.cc index 88b33dc1e774f..7eb108faf9110 100644 --- a/fml/raster_thread_merger.cc +++ b/fml/raster_thread_merger.cc @@ -6,6 +6,8 @@ #include "flutter/fml/raster_thread_merger.h" +#include + #include "flutter/fml/message_loop_impl.h" namespace fml { @@ -23,7 +25,7 @@ RasterThreadMerger::RasterThreadMerger( fml::TaskQueueId gpu_queue_id) : platform_queue_id_(platform_queue_id), gpu_queue_id_(gpu_queue_id), - shared_merger_(shared_merger) {} + shared_merger_(std::move(shared_merger)) {} void RasterThreadMerger::SetMergeUnmergeCallback(const fml::closure& callback) { merge_unmerge_callback_ = callback; diff --git a/fml/synchronization/sync_switch.cc b/fml/synchronization/sync_switch.cc index 9add886975577..ac951062267f8 100644 --- a/fml/synchronization/sync_switch.cc +++ b/fml/synchronization/sync_switch.cc @@ -8,13 +8,13 @@ namespace fml { SyncSwitch::Handlers& SyncSwitch::Handlers::SetIfTrue( const std::function& handler) { - true_handler = std::move(handler); + true_handler = handler; return *this; } SyncSwitch::Handlers& SyncSwitch::Handlers::SetIfFalse( const std::function& handler) { - false_handler = std::move(handler); + false_handler = handler; return *this; } diff --git a/fml/task_runner.cc b/fml/task_runner.cc index 66d3bbdbd6ec2..5f9dd019c685e 100644 --- a/fml/task_runner.cc +++ b/fml/task_runner.cc @@ -52,13 +52,13 @@ bool TaskRunner::RunsTasksOnCurrentThread() { loop_queue_id); } -void TaskRunner::RunNowOrPostTask(fml::RefPtr runner, +void TaskRunner::RunNowOrPostTask(const fml::RefPtr& runner, const fml::closure& task) { FML_DCHECK(runner); if (runner->RunsTasksOnCurrentThread()) { task(); } else { - runner->PostTask(std::move(task)); + runner->PostTask(task); } } diff --git a/fml/task_runner.h b/fml/task_runner.h index cdab31181ebac..885c1b3efb566 100644 --- a/fml/task_runner.h +++ b/fml/task_runner.h @@ -59,7 +59,7 @@ class TaskRunner : public fml::RefCountedThreadSafe, /// Executes the \p task directly if the TaskRunner \p runner is the /// TaskRunner associated with the current executing thread. - static void RunNowOrPostTask(fml::RefPtr runner, + static void RunNowOrPostTask(const fml::RefPtr& runner, const fml::closure& task); protected: diff --git a/impeller/archivist/archive.cc b/impeller/archivist/archive.cc index 8cf81ddb65ec4..022b30de51485 100644 --- a/impeller/archivist/archive.cc +++ b/impeller/archivist/archive.cc @@ -107,7 +107,7 @@ bool Archive::UnarchiveInstance(const ArchiveDef& definition, } size_t Archive::UnarchiveInstances(const ArchiveDef& definition, - Archive::UnarchiveStep stepper, + const Archive::UnarchiveStep& stepper, PrimaryKey primary_key) { if (!IsValid()) { return 0; diff --git a/impeller/archivist/archive.h b/impeller/archivist/archive.h index 9c727c9015aaf..a8907935317f7 100644 --- a/impeller/archivist/archive.h +++ b/impeller/archivist/archive.h @@ -65,7 +65,7 @@ class Archive { Archivable& archivable); size_t UnarchiveInstances(const ArchiveDef& definition, - UnarchiveStep stepper, + const UnarchiveStep& stepper, PrimaryKey primary_key = std::nullopt); FML_DISALLOW_COPY_AND_ASSIGN(Archive); diff --git a/impeller/base/allocation.cc b/impeller/base/allocation.cc index 5418eef58bfdf..06af6f22442a8 100644 --- a/impeller/base/allocation.cc +++ b/impeller/base/allocation.cc @@ -94,11 +94,11 @@ std::shared_ptr CreateMappingWithCopy(const uint8_t* contents, std::memmove(allocation->GetBuffer(), contents, length); - return CreateMappingFromAllocation(std::move(allocation)); + return CreateMappingFromAllocation(allocation); } std::shared_ptr CreateMappingFromAllocation( - std::shared_ptr allocation) { + const std::shared_ptr& allocation) { if (!allocation) { return nullptr; } diff --git a/impeller/base/allocation.h b/impeller/base/allocation.h index 075c21b0cb8cb..e352837d11362 100644 --- a/impeller/base/allocation.h +++ b/impeller/base/allocation.h @@ -44,7 +44,7 @@ std::shared_ptr CreateMappingWithCopy(const uint8_t* contents, size_t length); std::shared_ptr CreateMappingFromAllocation( - std::shared_ptr allocation); + const std::shared_ptr& allocation); std::shared_ptr CreateMappingWithString( std::shared_ptr string); diff --git a/impeller/compiler/compiler.cc b/impeller/compiler/compiler.cc index 1cd435c06e5df..ae893373a693b 100644 --- a/impeller/compiler/compiler.cc +++ b/impeller/compiler/compiler.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include "flutter/fml/paths.h" #include "impeller/base/allocation.h" @@ -21,7 +22,7 @@ namespace compiler { const uint32_t kFragBindingBase = 128; const size_t kNumUniformKinds = - int(shaderc_uniform_kind::shaderc_uniform_kind_buffer) + 1; + static_cast(shaderc_uniform_kind::shaderc_uniform_kind_buffer) + 1; static CompilerBackend CreateMSLCompiler(const spirv_cross::ParsedIR& ir, const SourceOptions& source_options) { @@ -238,7 +239,7 @@ void Compiler::SetBindingBase(shaderc::CompileOptions& compiler_opts) const { } Compiler::Compiler(const fml::Mapping& source_mapping, - SourceOptions source_options, + const SourceOptions& source_options, Reflector::Options reflector_options) : options_(source_options) { if (source_mapping.GetMapping() == nullptr) { @@ -482,7 +483,7 @@ const std::vector& Compiler::GetIncludedFileNames() const { } static std::string JoinStrings(std::vector items, - std::string separator) { + const std::string& separator) { std::stringstream stream; for (size_t i = 0, count = items.size(); i < count; i++) { const auto is_last = (i == count - 1); @@ -495,7 +496,7 @@ static std::string JoinStrings(std::vector items, return stream.str(); } -std::string Compiler::GetDependencyNames(std::string separator) const { +std::string Compiler::GetDependencyNames(const std::string& separator) const { std::vector dependencies = included_file_names_; dependencies.push_back(options_.file_name); return JoinStrings(dependencies, separator); diff --git a/impeller/compiler/compiler.h b/impeller/compiler/compiler.h index 379f610fd2286..d79f0c5e574a4 100644 --- a/impeller/compiler/compiler.h +++ b/impeller/compiler/compiler.h @@ -24,7 +24,7 @@ namespace compiler { class Compiler { public: Compiler(const fml::Mapping& source_mapping, - SourceOptions options, + const SourceOptions& options, Reflector::Options reflector_options); ~Compiler(); @@ -55,7 +55,7 @@ class Compiler { std::string GetSourcePrefix() const; - std::string GetDependencyNames(std::string separator) const; + std::string GetDependencyNames(const std::string& separator) const; void SetBindingBase(shaderc::CompileOptions& compiler_opts) const; diff --git a/impeller/entity/contents/filters/inputs/contents_filter_input.cc b/impeller/entity/contents/filters/inputs/contents_filter_input.cc index 0d462f78de7f3..fda5df7760efa 100644 --- a/impeller/entity/contents/filters/inputs/contents_filter_input.cc +++ b/impeller/entity/contents/filters/inputs/contents_filter_input.cc @@ -4,10 +4,12 @@ #include "impeller/entity/contents/filters/inputs/contents_filter_input.h" +#include + namespace impeller { ContentsFilterInput::ContentsFilterInput(std::shared_ptr contents) - : contents_(contents) {} + : contents_(std::move(contents)) {} ContentsFilterInput::~ContentsFilterInput() = default; diff --git a/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc b/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc index 5e7d3396f8c19..8b19b87e20ec1 100644 --- a/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc +++ b/impeller/entity/contents/filters/inputs/filter_contents_filter_input.cc @@ -4,13 +4,15 @@ #include "impeller/entity/contents/filters/inputs/filter_contents_filter_input.h" +#include + #include "impeller/entity/contents/filters/filter_contents.h" namespace impeller { FilterContentsFilterInput::FilterContentsFilterInput( std::shared_ptr filter) - : filter_(filter) {} + : filter_(std::move(filter)) {} FilterContentsFilterInput::~FilterContentsFilterInput() = default; diff --git a/impeller/entity/contents/filters/inputs/filter_input.cc b/impeller/entity/contents/filters/inputs/filter_input.cc index 5d87caa7d03cf..4f61ba49fa9d5 100644 --- a/impeller/entity/contents/filters/inputs/filter_input.cc +++ b/impeller/entity/contents/filters/inputs/filter_input.cc @@ -5,6 +5,7 @@ #include "impeller/entity/contents/filters/inputs/filter_input.h" #include +#include #include "flutter/fml/logging.h" #include "impeller/entity/contents/filters/filter_contents.h" @@ -37,7 +38,7 @@ FilterInput::Ref FilterInput::Make(Variant input) { FilterInput::Ref FilterInput::Make(std::shared_ptr texture, Matrix local_transform) { return std::shared_ptr( - new TextureFilterInput(texture, local_transform)); + new TextureFilterInput(std::move(texture), local_transform)); } FilterInput::Vector FilterInput::Make(std::initializer_list inputs) { diff --git a/impeller/entity/contents/filters/inputs/texture_filter_input.cc b/impeller/entity/contents/filters/inputs/texture_filter_input.cc index 02004e83f9ceb..09a393bc51e07 100644 --- a/impeller/entity/contents/filters/inputs/texture_filter_input.cc +++ b/impeller/entity/contents/filters/inputs/texture_filter_input.cc @@ -4,11 +4,13 @@ #include "impeller/entity/contents/filters/inputs/texture_filter_input.h" +#include + namespace impeller { TextureFilterInput::TextureFilterInput(std::shared_ptr texture, Matrix local_transform) - : texture_(texture), local_transform_(local_transform) {} + : texture_(std::move(texture)), local_transform_(local_transform) {} TextureFilterInput::~TextureFilterInput() = default; diff --git a/impeller/entity/inline_pass_context.cc b/impeller/entity/inline_pass_context.cc index 7c657fe531d78..9a8e0e0173ab7 100644 --- a/impeller/entity/inline_pass_context.cc +++ b/impeller/entity/inline_pass_context.cc @@ -4,6 +4,8 @@ #include "impeller/entity/inline_pass_context.h" +#include + #include "impeller/base/validation.h" #include "impeller/renderer/command_buffer.h" #include "impeller/renderer/formats.h" @@ -12,9 +14,9 @@ namespace impeller { InlinePassContext::InlinePassContext(std::shared_ptr context, - RenderTarget render_target, + const RenderTarget& render_target, uint32_t pass_texture_reads) - : context_(context), + : context_(std::move(context)), render_target_(render_target), total_pass_reads_(pass_texture_reads) {} diff --git a/impeller/entity/inline_pass_context.h b/impeller/entity/inline_pass_context.h index fa4c44ce130e5..ee393bda6c4b2 100644 --- a/impeller/entity/inline_pass_context.h +++ b/impeller/entity/inline_pass_context.h @@ -18,7 +18,7 @@ class InlinePassContext { }; InlinePassContext(std::shared_ptr context, - RenderTarget render_target, + const RenderTarget& render_target, uint32_t pass_texture_reads); ~InlinePassContext(); diff --git a/impeller/geometry/path.cc b/impeller/geometry/path.cc index 72e9488e4f057..bc4164c7cfccf 100644 --- a/impeller/geometry/path.cc +++ b/impeller/geometry/path.cc @@ -75,10 +75,10 @@ void Path::SetContourClosed(bool is_closed) { } void Path::EnumerateComponents( - Applier linear_applier, - Applier quad_applier, - Applier cubic_applier, - Applier contour_applier) const { + const Applier& linear_applier, + const Applier& quad_applier, + const Applier& cubic_applier, + const Applier& contour_applier) const { size_t currentIndex = 0; for (const auto& component : components_) { switch (component.type) { diff --git a/impeller/geometry/path.h b/impeller/geometry/path.h index 2faa4e5241d52..77a20fda0ef6a 100644 --- a/impeller/geometry/path.h +++ b/impeller/geometry/path.h @@ -89,10 +89,11 @@ class Path { template using Applier = std::function; - void EnumerateComponents(Applier linear_applier, - Applier quad_applier, - Applier cubic_applier, - Applier contour_applier) const; + void EnumerateComponents( + const Applier& linear_applier, + const Applier& quad_applier, + const Applier& cubic_applier, + const Applier& contour_applier) const; bool GetLinearComponentAtIndex(size_t index, LinearPathComponent& linear) const; diff --git a/impeller/geometry/path_builder.cc b/impeller/geometry/path_builder.cc index 1456b7c745b7b..f7f68cf8496b3 100644 --- a/impeller/geometry/path_builder.cc +++ b/impeller/geometry/path_builder.cc @@ -19,7 +19,7 @@ Path PathBuilder::CopyPath(FillType fill) const { } Path PathBuilder::TakePath(FillType fill) { - auto path = std::move(prototype_); + auto path = prototype_; path.SetFillType(fill); return path; } diff --git a/impeller/playground/playground.cc b/impeller/playground/playground.cc index dcf9036c1e910..ac56a3e9b4029 100644 --- a/impeller/playground/playground.cc +++ b/impeller/playground/playground.cc @@ -161,7 +161,8 @@ void Playground::SetCursorPosition(Point pos) { cursor_position_ = pos; } -bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) { +bool Playground::OpenPlaygroundHere( + const Renderer::RenderCallback& render_callback) { if (!is_enabled()) { return true; } diff --git a/impeller/playground/playground.h b/impeller/playground/playground.h index 8b65b6f68ce3c..d2feb0ef1df7f 100644 --- a/impeller/playground/playground.h +++ b/impeller/playground/playground.h @@ -48,7 +48,7 @@ class Playground { std::shared_ptr GetContext() const; - bool OpenPlaygroundHere(Renderer::RenderCallback render_callback); + bool OpenPlaygroundHere(const Renderer::RenderCallback& render_callback); bool OpenPlaygroundHere(SinglePassCallback pass_callback); diff --git a/impeller/renderer/backend/gles/allocator_gles.cc b/impeller/renderer/backend/gles/allocator_gles.cc index 86aa1ec1910e0..dc6a15c88dad8 100644 --- a/impeller/renderer/backend/gles/allocator_gles.cc +++ b/impeller/renderer/backend/gles/allocator_gles.cc @@ -40,7 +40,7 @@ std::shared_ptr AllocatorGLES::OnCreateBuffer( // |Allocator| std::shared_ptr AllocatorGLES::OnCreateTexture( const TextureDescriptor& desc) { - return std::make_shared(reactor_, std::move(desc)); + return std::make_shared(reactor_, desc); } // |Allocator| diff --git a/impeller/renderer/backend/gles/buffer_bindings_gles.cc b/impeller/renderer/backend/gles/buffer_bindings_gles.cc index 665bef5ae4d33..649c6b7fb2d0e 100644 --- a/impeller/renderer/backend/gles/buffer_bindings_gles.cc +++ b/impeller/renderer/backend/gles/buffer_bindings_gles.cc @@ -50,7 +50,7 @@ bool BufferBindingsGLES::RegisterVertexStageInput( attrib.normalized = GL_FALSE; attrib.offset = offset; offset += (input.bit_width * input.vec_size) / 8; - vertex_attrib_arrays.emplace_back(std::move(attrib)); + vertex_attrib_arrays.emplace_back(attrib); } for (auto& array : vertex_attrib_arrays) { array.stride = offset; diff --git a/impeller/renderer/backend/gles/command_buffer_gles.cc b/impeller/renderer/backend/gles/command_buffer_gles.cc index d68f8419ea421..c53c774330399 100644 --- a/impeller/renderer/backend/gles/command_buffer_gles.cc +++ b/impeller/renderer/backend/gles/command_buffer_gles.cc @@ -45,7 +45,7 @@ std::shared_ptr CommandBufferGLES::OnCreateRenderPass( return nullptr; } auto pass = std::shared_ptr( - new RenderPassGLES(context_, std::move(target), reactor_)); + new RenderPassGLES(context_, target, reactor_)); if (!pass->IsValid()) { return nullptr; } diff --git a/impeller/renderer/backend/gles/context_gles.cc b/impeller/renderer/backend/gles/context_gles.cc index 49f454f542cb3..e6234c642038e 100644 --- a/impeller/renderer/backend/gles/context_gles.cc +++ b/impeller/renderer/backend/gles/context_gles.cc @@ -12,14 +12,14 @@ namespace impeller { std::shared_ptr ContextGLES::Create( std::unique_ptr gl, - std::vector> shader_libraries) { + const std::vector>& shader_libraries) { return std::shared_ptr( - new ContextGLES(std::move(gl), std::move(shader_libraries))); + new ContextGLES(std::move(gl), shader_libraries)); } -ContextGLES::ContextGLES( - std::unique_ptr gl, - std::vector> shader_libraries_mappings) { +ContextGLES::ContextGLES(std::unique_ptr gl, + const std::vector>& + shader_libraries_mappings) { reactor_ = std::make_shared(std::move(gl)); if (!reactor_->IsValid()) { VALIDATION_LOG << "Could not create valid reactor."; @@ -29,7 +29,7 @@ ContextGLES::ContextGLES( // Create the shader library. { auto library = std::shared_ptr( - new ShaderLibraryGLES(std::move(shader_libraries_mappings))); + new ShaderLibraryGLES(shader_libraries_mappings)); if (!library->IsValid()) { VALIDATION_LOG << "Could not create valid shader library."; return; @@ -78,11 +78,11 @@ const ReactorGLES::Ref& ContextGLES::GetReactor() const { } std::optional ContextGLES::AddReactorWorker( - std::shared_ptr worker) { + const std::shared_ptr& worker) { if (!IsValid()) { return std::nullopt; } - return reactor_->AddWorker(std::move(worker)); + return reactor_->AddWorker(worker); } bool ContextGLES::RemoveReactorWorker(ReactorGLES::WorkerID id) { diff --git a/impeller/renderer/backend/gles/context_gles.h b/impeller/renderer/backend/gles/context_gles.h index 405f31d1b168b..138843a7fb7a3 100644 --- a/impeller/renderer/backend/gles/context_gles.h +++ b/impeller/renderer/backend/gles/context_gles.h @@ -21,7 +21,7 @@ class ContextGLES final : public Context, public: static std::shared_ptr Create( std::unique_ptr gl, - std::vector> shader_libraries); + const std::vector>& shader_libraries); // |Context| ~ContextGLES() override; @@ -29,7 +29,7 @@ class ContextGLES final : public Context, const ReactorGLES::Ref& GetReactor() const; std::optional AddReactorWorker( - std::shared_ptr worker); + const std::shared_ptr& worker); bool RemoveReactorWorker(ReactorGLES::WorkerID id); @@ -42,8 +42,9 @@ class ContextGLES final : public Context, std::shared_ptr resource_allocator_; bool is_valid_ = false; - ContextGLES(std::unique_ptr gl, - std::vector> shader_libraries); + ContextGLES( + std::unique_ptr gl, + const std::vector>& shader_libraries); // |Context| bool IsValid() const override; diff --git a/impeller/renderer/backend/gles/description_gles.cc b/impeller/renderer/backend/gles/description_gles.cc index 92dfa31ca646e..cc86b7fd8ec32 100644 --- a/impeller/renderer/backend/gles/description_gles.cc +++ b/impeller/renderer/backend/gles/description_gles.cc @@ -62,7 +62,7 @@ static std::optional DetermineVersion(std::string version) { std::getline(istream, version_component, '.');) { version_components.push_back(std::stoul(version_component)); } - return Version::FromVector(std::move(version_components)); + return Version::FromVector(version_components); } DescriptionGLES::DescriptionGLES(const ProcTableGLES& gl) diff --git a/impeller/renderer/backend/gles/device_buffer_gles.cc b/impeller/renderer/backend/gles/device_buffer_gles.cc index 087bf4d6e4e84..ffb9f2543adbb 100644 --- a/impeller/renderer/backend/gles/device_buffer_gles.cc +++ b/impeller/renderer/backend/gles/device_buffer_gles.cc @@ -17,7 +17,7 @@ namespace impeller { DeviceBufferGLES::DeviceBufferGLES(DeviceBufferDescriptor desc, ReactorGLES::Ref reactor, std::shared_ptr backing_store) - : DeviceBuffer(std::move(desc)), + : DeviceBuffer(desc), reactor_(std::move(reactor)), handle_(reactor_ ? reactor_->CreateHandle(HandleType::kBuffer) : HandleGLES::DeadHandle()), diff --git a/impeller/renderer/backend/gles/pipeline_gles.cc b/impeller/renderer/backend/gles/pipeline_gles.cc index fd0bb5ba08426..31063ce43d64f 100644 --- a/impeller/renderer/backend/gles/pipeline_gles.cc +++ b/impeller/renderer/backend/gles/pipeline_gles.cc @@ -8,8 +8,8 @@ namespace impeller { PipelineGLES::PipelineGLES(ReactorGLES::Ref reactor, std::weak_ptr library, - PipelineDescriptor desc) - : Pipeline(std::move(library), std::move(desc)), + const PipelineDescriptor& desc) + : Pipeline(std::move(library), desc), reactor_(std::move(reactor)), handle_(reactor_ ? reactor_->CreateHandle(HandleType::kProgram) : HandleGLES::DeadHandle()), @@ -22,7 +22,7 @@ PipelineGLES::PipelineGLES(ReactorGLES::Ref reactor, // |Pipeline| PipelineGLES::~PipelineGLES() { if (!handle_.IsDead()) { - reactor_->CollectHandle(std::move(handle_)); + reactor_->CollectHandle(handle_); } } diff --git a/impeller/renderer/backend/gles/pipeline_gles.h b/impeller/renderer/backend/gles/pipeline_gles.h index 19d7d837a753b..4097684a24717 100644 --- a/impeller/renderer/backend/gles/pipeline_gles.h +++ b/impeller/renderer/backend/gles/pipeline_gles.h @@ -46,7 +46,7 @@ class PipelineGLES final PipelineGLES(ReactorGLES::Ref reactor, std::weak_ptr library, - PipelineDescriptor desc); + const PipelineDescriptor& desc); FML_DISALLOW_COPY_AND_ASSIGN(PipelineGLES); }; diff --git a/impeller/renderer/backend/gles/pipeline_library_gles.cc b/impeller/renderer/backend/gles/pipeline_library_gles.cc index fa4bf10049f99..9e60d4529ebd8 100644 --- a/impeller/renderer/backend/gles/pipeline_library_gles.cc +++ b/impeller/renderer/backend/gles/pipeline_library_gles.cc @@ -70,7 +70,7 @@ static void LogShaderCompilationFailure(const ProcTableGLES& gl, static bool LinkProgram( const ReactorGLES& reactor, - std::shared_ptr pipeline, + const std::shared_ptr& pipeline, const std::shared_ptr& vert_function, const std::shared_ptr& frag_function) { TRACE_EVENT0("impeller", __FUNCTION__); @@ -217,10 +217,10 @@ PipelineFuture PipelineLibraryGLES::GetPipeline( VALIDATION_LOG << "Could not obtain program handle."; return; } - const auto link_result = LinkProgram(reactor, // - pipeline, // - std::move(vert_function), // - std::move(frag_function) // + const auto link_result = LinkProgram(reactor, // + pipeline, // + vert_function, // + frag_function // ); if (!link_result) { promise->set_value(nullptr); diff --git a/impeller/renderer/backend/gles/proc_table_gles.cc b/impeller/renderer/backend/gles/proc_table_gles.cc index a01246ed23087..b3c8a8ff434f4 100644 --- a/impeller/renderer/backend/gles/proc_table_gles.cc +++ b/impeller/renderer/backend/gles/proc_table_gles.cc @@ -32,7 +32,8 @@ const char* GLErrorToString(GLenum value) { return "Unknown."; } -ProcTableGLES::Resolver WrappedResolver(ProcTableGLES::Resolver resolver) { +ProcTableGLES::Resolver WrappedResolver( + const ProcTableGLES::Resolver& resolver) { return [resolver](const char* function_name) -> void* { auto resolved = resolver(function_name); if (resolved) { diff --git a/impeller/renderer/backend/gles/reactor_gles.cc b/impeller/renderer/backend/gles/reactor_gles.cc index bf5d9346fcbb9..f4d9ca9396233 100644 --- a/impeller/renderer/backend/gles/reactor_gles.cc +++ b/impeller/renderer/backend/gles/reactor_gles.cc @@ -141,7 +141,7 @@ HandleGLES ReactorGLES::CreateHandle(HandleType type) { auto gl_handle = CanReactOnCurrentThread() ? CreateGLHandle(GetProcTable(), type) : std::nullopt; - handles_[new_handle] = LiveHandle{std::move(gl_handle)}; + handles_[new_handle] = LiveHandle{gl_handle}; return new_handle; } @@ -214,7 +214,7 @@ bool ReactorGLES::ConsolidateHandles() { VALIDATION_LOG << "Could not create GL handle."; return false; } - handle.second.name = std::move(gl_handle); + handle.second.name = gl_handle; } // Set pending debug labels. if (handle.second.pending_debug_label.has_value()) { diff --git a/impeller/renderer/backend/gles/render_pass_gles.cc b/impeller/renderer/backend/gles/render_pass_gles.cc index 3e96e82c054b1..acf86ad6a0e29 100644 --- a/impeller/renderer/backend/gles/render_pass_gles.cc +++ b/impeller/renderer/backend/gles/render_pass_gles.cc @@ -17,9 +17,9 @@ namespace impeller { RenderPassGLES::RenderPassGLES(std::weak_ptr context, - RenderTarget target, + const RenderTarget& target, ReactorGLES::Ref reactor) - : RenderPass(std::move(context), std::move(target)), + : RenderPass(std::move(context), target), reactor_(std::move(reactor)), is_valid_(reactor_ && reactor_->IsValid()) {} diff --git a/impeller/renderer/backend/gles/render_pass_gles.h b/impeller/renderer/backend/gles/render_pass_gles.h index 7ffc5202a2cad..48e50760aa921 100644 --- a/impeller/renderer/backend/gles/render_pass_gles.h +++ b/impeller/renderer/backend/gles/render_pass_gles.h @@ -23,7 +23,7 @@ class RenderPassGLES final : public RenderPass { bool is_valid_ = false; RenderPassGLES(std::weak_ptr context, - RenderTarget target, + const RenderTarget& target, ReactorGLES::Ref reactor); // |RenderPass| diff --git a/impeller/renderer/backend/gles/shader_library_gles.cc b/impeller/renderer/backend/gles/shader_library_gles.cc index 0bba3aefebd87..bcf5c83e0bbde 100644 --- a/impeller/renderer/backend/gles/shader_library_gles.cc +++ b/impeller/renderer/backend/gles/shader_library_gles.cc @@ -55,7 +55,7 @@ static std::string GLESShaderNameToShaderKeyName(const std::string& name, } ShaderLibraryGLES::ShaderLibraryGLES( - std::vector> shader_libraries) { + const std::vector>& shader_libraries) { ShaderFunctionMap functions; auto iterator = [&functions, library_id = library_id_](auto type, // const auto& name, // diff --git a/impeller/renderer/backend/gles/shader_library_gles.h b/impeller/renderer/backend/gles/shader_library_gles.h index 6bfa794d50c2b..a5e909809299b 100644 --- a/impeller/renderer/backend/gles/shader_library_gles.h +++ b/impeller/renderer/backend/gles/shader_library_gles.h @@ -31,7 +31,7 @@ class ShaderLibraryGLES final : public ShaderLibrary { bool is_valid_ = false; ShaderLibraryGLES( - std::vector> shader_libraries); + const std::vector>& shader_libraries); // |ShaderLibrary| std::shared_ptr GetFunction(std::string_view name, diff --git a/impeller/renderer/backend/gles/surface_gles.cc b/impeller/renderer/backend/gles/surface_gles.cc index 3de1764865efc..a179b3798f3d9 100644 --- a/impeller/renderer/backend/gles/surface_gles.cc +++ b/impeller/renderer/backend/gles/surface_gles.cc @@ -11,11 +11,12 @@ namespace impeller { -std::unique_ptr SurfaceGLES::WrapFBO(std::shared_ptr context, - SwapCallback swap_callback, - GLuint fbo, - PixelFormat color_format, - ISize fbo_size) { +std::unique_ptr SurfaceGLES::WrapFBO( + const std::shared_ptr& context, + SwapCallback swap_callback, + GLuint fbo, + PixelFormat color_format, + ISize fbo_size) { TRACE_EVENT0("impeller", "SurfaceGLES::WrapOnScreenFBO"); if (context == nullptr || !context->IsValid() || !swap_callback) { @@ -34,8 +35,7 @@ std::unique_ptr SurfaceGLES::WrapFBO(std::shared_ptr context, ColorAttachment color0; color0.texture = std::make_shared( - gl_context.GetReactor(), std::move(color0_tex), - TextureGLES::IsWrapped::kWrapped); + gl_context.GetReactor(), color0_tex, TextureGLES::IsWrapped::kWrapped); color0.clear_color = Color::DarkSlateGray(); color0.load_action = LoadAction::kClear; color0.store_action = StoreAction::kStore; @@ -51,8 +51,7 @@ std::unique_ptr SurfaceGLES::WrapFBO(std::shared_ptr context, StencilAttachment stencil0; stencil0.clear_stencil = 0; stencil0.texture = std::make_shared( - gl_context.GetReactor(), std::move(stencil0_tex), - TextureGLES::IsWrapped::kWrapped); + gl_context.GetReactor(), stencil0_tex, TextureGLES::IsWrapped::kWrapped); stencil0.load_action = LoadAction::kClear; stencil0.store_action = StoreAction::kDontCare; @@ -62,12 +61,12 @@ std::unique_ptr SurfaceGLES::WrapFBO(std::shared_ptr context, render_target_desc.SetStencilAttachment(stencil0); return std::unique_ptr( - new SurfaceGLES(std::move(swap_callback), std::move(render_target_desc))); + new SurfaceGLES(std::move(swap_callback), render_target_desc)); } -SurfaceGLES::SurfaceGLES(SwapCallback swap_callback, RenderTarget target_desc) - : Surface(std::move(target_desc)), - swap_callback_(std::move(swap_callback)) {} +SurfaceGLES::SurfaceGLES(SwapCallback swap_callback, + const RenderTarget& target_desc) + : Surface(target_desc), swap_callback_(std::move(swap_callback)) {} // |Surface| SurfaceGLES::~SurfaceGLES() = default; diff --git a/impeller/renderer/backend/gles/surface_gles.h b/impeller/renderer/backend/gles/surface_gles.h index 0016c41750af3..b2d8819041058 100644 --- a/impeller/renderer/backend/gles/surface_gles.h +++ b/impeller/renderer/backend/gles/surface_gles.h @@ -18,11 +18,12 @@ class SurfaceGLES final : public Surface { public: using SwapCallback = std::function; - static std::unique_ptr WrapFBO(std::shared_ptr context, - SwapCallback swap_callback, - GLuint fbo, - PixelFormat color_format, - ISize fbo_size); + static std::unique_ptr WrapFBO( + const std::shared_ptr& context, + SwapCallback swap_callback, + GLuint fbo, + PixelFormat color_format, + ISize fbo_size); // |Surface| ~SurfaceGLES() override; @@ -30,7 +31,7 @@ class SurfaceGLES final : public Surface { private: SwapCallback swap_callback_; - SurfaceGLES(SwapCallback swap_callback, RenderTarget target_desc); + SurfaceGLES(SwapCallback swap_callback, const RenderTarget& target_desc); // |Surface| bool Present() const override; diff --git a/impeller/renderer/backend/gles/texture_gles.cc b/impeller/renderer/backend/gles/texture_gles.cc index f88bd377dacb2..0c18dab461979 100644 --- a/impeller/renderer/backend/gles/texture_gles.cc +++ b/impeller/renderer/backend/gles/texture_gles.cc @@ -5,6 +5,7 @@ #include "impeller/renderer/backend/gles/texture_gles.h" #include +#include #include "flutter/fml/mapping.h" #include "flutter/fml/trace_event.h" @@ -38,18 +39,18 @@ HandleType ToHandleType(TextureGLES::Type type) { } TextureGLES::TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc) - : TextureGLES(std::move(reactor), std::move(desc), false) {} + : TextureGLES(std::move(reactor), desc, false) {} TextureGLES::TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc, enum IsWrapped wrapped) - : TextureGLES(std::move(reactor), std::move(desc), true) {} + : TextureGLES(std::move(reactor), desc, true) {} TextureGLES::TextureGLES(std::shared_ptr reactor, TextureDescriptor desc, bool is_wrapped) - : Texture(std::move(desc)), - reactor_(reactor), + : Texture(desc), + reactor_(std::move(reactor)), type_(GetTextureTypeFromDescriptor(GetTextureDescriptor())), handle_(reactor_->CreateHandle(ToHandleType(type_))), is_wrapped_(is_wrapped) { @@ -72,7 +73,7 @@ TextureGLES::TextureGLES(std::shared_ptr reactor, // |Texture| TextureGLES::~TextureGLES() { - reactor_->CollectHandle(std::move(handle_)); + reactor_->CollectHandle(handle_); } // |Texture| diff --git a/impeller/renderer/backend/metal/command_buffer_mtl.h b/impeller/renderer/backend/metal/command_buffer_mtl.h index a1ed6db74c624..30dd3f6f5d6a4 100644 --- a/impeller/renderer/backend/metal/command_buffer_mtl.h +++ b/impeller/renderer/backend/metal/command_buffer_mtl.h @@ -21,7 +21,7 @@ class CommandBufferMTL final : public CommandBuffer { id buffer_ = nullptr; - CommandBufferMTL(const std::weak_ptr context, + CommandBufferMTL(const std::weak_ptr& context, id queue); // |CommandBuffer| diff --git a/impeller/renderer/backend/metal/command_buffer_mtl.mm b/impeller/renderer/backend/metal/command_buffer_mtl.mm index b7672b36e471a..2e8a5f7d8a5af 100644 --- a/impeller/renderer/backend/metal/command_buffer_mtl.mm +++ b/impeller/renderer/backend/metal/command_buffer_mtl.mm @@ -121,9 +121,9 @@ static bool LogMTLCommandBufferErrorIfPresent(id buffer) { return [queue commandBuffer]; } -CommandBufferMTL::CommandBufferMTL(const std::weak_ptr context, +CommandBufferMTL::CommandBufferMTL(const std::weak_ptr& context, id queue) - : CommandBuffer(std::move(context)), buffer_(CreateCommandBuffer(queue)) {} + : CommandBuffer(context), buffer_(CreateCommandBuffer(queue)) {} CommandBufferMTL::~CommandBufferMTL() = default; @@ -176,7 +176,7 @@ static bool LogMTLCommandBufferErrorIfPresent(id buffer) { } auto pass = std::shared_ptr( - new RenderPassMTL(context_, std::move(target), buffer_)); + new RenderPassMTL(context_, target, buffer_)); if (!pass->IsValid()) { return nullptr; } diff --git a/impeller/renderer/backend/metal/device_buffer_mtl.mm b/impeller/renderer/backend/metal/device_buffer_mtl.mm index 8d5c5afcf11e1..123ef1263213c 100644 --- a/impeller/renderer/backend/metal/device_buffer_mtl.mm +++ b/impeller/renderer/backend/metal/device_buffer_mtl.mm @@ -14,9 +14,7 @@ DeviceBufferMTL::DeviceBufferMTL(DeviceBufferDescriptor desc, id buffer, MTLStorageMode storage_mode) - : DeviceBuffer(std::move(desc)), - buffer_(buffer), - storage_mode_(storage_mode) {} + : DeviceBuffer(desc), buffer_(buffer), storage_mode_(storage_mode) {} DeviceBufferMTL::~DeviceBufferMTL() = default; diff --git a/impeller/renderer/backend/metal/pipeline_mtl.h b/impeller/renderer/backend/metal/pipeline_mtl.h index b57c972d9b1e0..7820d595473ce 100644 --- a/impeller/renderer/backend/metal/pipeline_mtl.h +++ b/impeller/renderer/backend/metal/pipeline_mtl.h @@ -31,7 +31,7 @@ class PipelineMTL final bool is_valid_ = false; PipelineMTL(std::weak_ptr library, - PipelineDescriptor desc, + const PipelineDescriptor& desc, id state, id depth_stencil_state); diff --git a/impeller/renderer/backend/metal/pipeline_mtl.mm b/impeller/renderer/backend/metal/pipeline_mtl.mm index 9fcbe324f3870..684ca305c5123 100644 --- a/impeller/renderer/backend/metal/pipeline_mtl.mm +++ b/impeller/renderer/backend/metal/pipeline_mtl.mm @@ -7,10 +7,10 @@ namespace impeller { PipelineMTL::PipelineMTL(std::weak_ptr library, - PipelineDescriptor desc, + const PipelineDescriptor& desc, id state, id depth_stencil_state) - : Pipeline(std::move(library), std::move(desc)), + : Pipeline(std::move(library), desc), pipeline_state_(state), depth_stencil_state_(depth_stencil_state) { if (!pipeline_state_) { diff --git a/impeller/renderer/backend/metal/render_pass_mtl.h b/impeller/renderer/backend/metal/render_pass_mtl.h index fd9d4bd80b46d..9a286d3978e99 100644 --- a/impeller/renderer/backend/metal/render_pass_mtl.h +++ b/impeller/renderer/backend/metal/render_pass_mtl.h @@ -26,7 +26,7 @@ class RenderPassMTL final : public RenderPass { bool is_valid_ = false; RenderPassMTL(std::weak_ptr context, - RenderTarget target, + const RenderTarget& target, id buffer); // |RenderPass| diff --git a/impeller/renderer/backend/metal/render_pass_mtl.mm b/impeller/renderer/backend/metal/render_pass_mtl.mm index e8c825af36b2b..f9351ffb38c36 100644 --- a/impeller/renderer/backend/metal/render_pass_mtl.mm +++ b/impeller/renderer/backend/metal/render_pass_mtl.mm @@ -131,9 +131,9 @@ static bool ConfigureStencilAttachment( } RenderPassMTL::RenderPassMTL(std::weak_ptr context, - RenderTarget target, + const RenderTarget& target, id buffer) - : RenderPass(std::move(context), std::move(target)), + : RenderPass(std::move(context), target), buffer_(buffer), desc_(ToMTLRenderPassDescriptor(GetRenderTarget())) { if (!buffer_ || !desc_ || !render_target_.IsValid()) { diff --git a/impeller/renderer/backend/metal/shader_function_mtl.mm b/impeller/renderer/backend/metal/shader_function_mtl.mm index 55c7e06b19cf3..04751af1b8f13 100644 --- a/impeller/renderer/backend/metal/shader_function_mtl.mm +++ b/impeller/renderer/backend/metal/shader_function_mtl.mm @@ -10,7 +10,7 @@ id function, std::string name, ShaderStage stage) - : ShaderFunction(std::move(parent_library_id), std::move(name), stage), + : ShaderFunction(parent_library_id, std::move(name), stage), function_(function) {} ShaderFunctionMTL::~ShaderFunctionMTL() = default; diff --git a/impeller/renderer/backend/metal/surface_mtl.h b/impeller/renderer/backend/metal/surface_mtl.h index 993ca65c63843..e922b8ac46283 100644 --- a/impeller/renderer/backend/metal/surface_mtl.h +++ b/impeller/renderer/backend/metal/surface_mtl.h @@ -33,7 +33,7 @@ class SurfaceMTL final : public Surface { /// @return A pointer to the wrapped surface or null. /// static std::unique_ptr WrapCurrentMetalLayerDrawable( - std::shared_ptr context, + const std::shared_ptr& context, CAMetalLayer* layer); #pragma GCC diagnostic pop @@ -43,7 +43,7 @@ class SurfaceMTL final : public Surface { private: id drawable_ = nil; - SurfaceMTL(RenderTarget target, id drawable); + SurfaceMTL(const RenderTarget& target, id drawable); // |Surface| bool Present() const override; diff --git a/impeller/renderer/backend/metal/surface_mtl.mm b/impeller/renderer/backend/metal/surface_mtl.mm index ee89074c9cb59..1a2d06b09ca12 100644 --- a/impeller/renderer/backend/metal/surface_mtl.mm +++ b/impeller/renderer/backend/metal/surface_mtl.mm @@ -16,7 +16,7 @@ #pragma GCC diagnostic ignored "-Wunguarded-availability-new" std::unique_ptr SurfaceMTL::WrapCurrentMetalLayerDrawable( - std::shared_ptr context, + const std::shared_ptr& context, CAMetalLayer* layer) { TRACE_EVENT0("impeller", "SurfaceMTL::WrapCurrentMetalLayerDrawable"); @@ -106,11 +106,11 @@ // The constructor is private. So make_unique may not be used. return std::unique_ptr( - new SurfaceMTL(std::move(render_target_desc), current_drawable)); + new SurfaceMTL(render_target_desc, current_drawable)); } -SurfaceMTL::SurfaceMTL(RenderTarget target, id drawable) - : Surface(std::move(target)), drawable_(drawable) {} +SurfaceMTL::SurfaceMTL(const RenderTarget& target, id drawable) + : Surface(target), drawable_(drawable) {} // |Surface| SurfaceMTL::~SurfaceMTL() = default; diff --git a/impeller/renderer/backend/metal/texture_mtl.mm b/impeller/renderer/backend/metal/texture_mtl.mm index 663a76cf831af..c220a2967acde 100644 --- a/impeller/renderer/backend/metal/texture_mtl.mm +++ b/impeller/renderer/backend/metal/texture_mtl.mm @@ -9,7 +9,7 @@ namespace impeller { TextureMTL::TextureMTL(TextureDescriptor p_desc, id texture) - : Texture(std::move(p_desc)), texture_(texture) { + : Texture(p_desc), texture_(texture) { const auto& desc = GetTextureDescriptor(); if (!desc.IsValid() || !texture_) { diff --git a/impeller/renderer/command.cc b/impeller/renderer/command.cc index 16d8c5a1bd129..cac510881c35f 100644 --- a/impeller/renderer/command.cc +++ b/impeller/renderer/command.cc @@ -4,6 +4,8 @@ #include "impeller/renderer/command.h" +#include + #include "impeller/base/validation.h" #include "impeller/renderer/formats.h" #include "impeller/renderer/vertex_descriptor.h" @@ -36,7 +38,7 @@ BufferView Command::GetVertexBuffer() const { bool Command::BindResource(ShaderStage stage, const ShaderUniformSlot& slot, const ShaderMetadata& metadata, - BufferView view) { + const BufferView& view) { if (!view) { return false; } @@ -64,7 +66,7 @@ bool Command::BindResource(ShaderStage stage, bool Command::BindResource(ShaderStage stage, const SampledImageSlot& slot, const ShaderMetadata& metadata, - std::shared_ptr texture) { + const std::shared_ptr& texture) { if (!texture || !texture->IsValid()) { return false; } @@ -94,7 +96,7 @@ bool Command::BindResource(ShaderStage stage, bool Command::BindResource(ShaderStage stage, const SampledImageSlot& slot, const ShaderMetadata& metadata, - std::shared_ptr sampler) { + const std::shared_ptr& sampler) { if (!sampler || !sampler->IsValid()) { return false; } @@ -124,8 +126,8 @@ bool Command::BindResource(ShaderStage stage, bool Command::BindResource(ShaderStage stage, const SampledImageSlot& slot, const ShaderMetadata& metadata, - std::shared_ptr texture, - std::shared_ptr sampler) { + const std::shared_ptr& texture, + const std::shared_ptr& sampler) { return BindResource(stage, slot, metadata, texture) && BindResource(stage, slot, metadata, sampler); } diff --git a/impeller/renderer/command.h b/impeller/renderer/command.h index 489cf0d267e0c..c804c0e5c2240 100644 --- a/impeller/renderer/command.h +++ b/impeller/renderer/command.h @@ -154,23 +154,23 @@ struct Command { bool BindResource(ShaderStage stage, const ShaderUniformSlot& slot, const ShaderMetadata& metadata, - BufferView view); + const BufferView& view); bool BindResource(ShaderStage stage, const SampledImageSlot& slot, const ShaderMetadata& metadata, - std::shared_ptr texture); + const std::shared_ptr& texture); bool BindResource(ShaderStage stage, const SampledImageSlot& slot, const ShaderMetadata& metadata, - std::shared_ptr sampler); + const std::shared_ptr& sampler); bool BindResource(ShaderStage stage, const SampledImageSlot& slot, const ShaderMetadata& metadata, - std::shared_ptr texture, - std::shared_ptr sampler); + const std::shared_ptr& texture, + const std::shared_ptr& sampler); BufferView GetVertexBuffer() const; diff --git a/impeller/renderer/command_buffer.cc b/impeller/renderer/command_buffer.cc index 8cfa6990ca734..c5e9c5920d180 100644 --- a/impeller/renderer/command_buffer.cc +++ b/impeller/renderer/command_buffer.cc @@ -16,7 +16,7 @@ CommandBuffer::CommandBuffer(std::weak_ptr context) CommandBuffer::~CommandBuffer() = default; -bool CommandBuffer::SubmitCommands(CompletionCallback callback) { +bool CommandBuffer::SubmitCommands(const CompletionCallback& callback) { TRACE_EVENT0("impeller", "CommandBuffer::SubmitCommands"); if (!IsValid()) { // Already committed or was never valid. Either way, this is caller error. @@ -33,8 +33,8 @@ bool CommandBuffer::SubmitCommands() { } std::shared_ptr CommandBuffer::CreateRenderPass( - RenderTarget render_target) { - auto pass = OnCreateRenderPass(std::move(render_target)); + const RenderTarget& render_target) { + auto pass = OnCreateRenderPass(render_target); if (pass && pass->IsValid()) { pass->SetLabel("RenderPass"); return pass; diff --git a/impeller/renderer/command_buffer.h b/impeller/renderer/command_buffer.h index e0f07a9f7ffd5..e043e165c2fd4 100644 --- a/impeller/renderer/command_buffer.h +++ b/impeller/renderer/command_buffer.h @@ -61,7 +61,7 @@ class CommandBuffer { /// /// @param[in] callback The completion callback. /// - [[nodiscard]] bool SubmitCommands(CompletionCallback callback); + [[nodiscard]] bool SubmitCommands(const CompletionCallback& callback); [[nodiscard]] bool SubmitCommands(); @@ -73,7 +73,8 @@ class CommandBuffer { /// /// @return A valid render pass or null. /// - std::shared_ptr CreateRenderPass(RenderTarget render_target); + std::shared_ptr CreateRenderPass( + const RenderTarget& render_target); //---------------------------------------------------------------------------- /// @brief Create a blit pass to record blit commands into. diff --git a/impeller/renderer/device_buffer.cc b/impeller/renderer/device_buffer.cc index 975912187a144..ff07f6eda9c34 100644 --- a/impeller/renderer/device_buffer.cc +++ b/impeller/renderer/device_buffer.cc @@ -6,8 +6,7 @@ namespace impeller { -DeviceBuffer::DeviceBuffer(DeviceBufferDescriptor desc) - : desc_(std::move(desc)) {} +DeviceBuffer::DeviceBuffer(DeviceBufferDescriptor desc) : desc_(desc) {} DeviceBuffer::~DeviceBuffer() = default; diff --git a/impeller/renderer/pipeline_descriptor.cc b/impeller/renderer/pipeline_descriptor.cc index aeaa753b62ef7..1de9e8d80f5d9 100644 --- a/impeller/renderer/pipeline_descriptor.cc +++ b/impeller/renderer/pipeline_descriptor.cc @@ -94,7 +94,7 @@ PipelineDescriptor& PipelineDescriptor::SetVertexDescriptor( PipelineDescriptor& PipelineDescriptor::SetColorAttachmentDescriptor( size_t index, ColorAttachmentDescriptor desc) { - color_attachment_descriptors_[index] = std::move(desc); + color_attachment_descriptors_[index] = desc; return *this; } diff --git a/impeller/renderer/pipeline_library.cc b/impeller/renderer/pipeline_library.cc index 577034f313e59..8b0732d6cb019 100644 --- a/impeller/renderer/pipeline_library.cc +++ b/impeller/renderer/pipeline_library.cc @@ -13,7 +13,7 @@ PipelineLibrary::~PipelineLibrary() = default; PipelineFuture PipelineLibrary::GetPipeline( std::optional descriptor) { if (descriptor.has_value()) { - return GetPipeline(std::move(descriptor.value())); + return GetPipeline(descriptor.value()); } auto promise = std::make_shared< std::promise>>>(); @@ -24,7 +24,7 @@ PipelineFuture PipelineLibrary::GetPipeline( PipelineFuture PipelineLibrary::GetPipeline( std::optional descriptor) { if (descriptor.has_value()) { - return GetPipeline(std::move(descriptor.value())); + return GetPipeline(descriptor.value()); } auto promise = std::make_shared< std::promise>>>(); diff --git a/impeller/renderer/render_pass.cc b/impeller/renderer/render_pass.cc index ba084ff442b33..5ca17a0342ee0 100644 --- a/impeller/renderer/render_pass.cc +++ b/impeller/renderer/render_pass.cc @@ -7,9 +7,9 @@ namespace impeller { RenderPass::RenderPass(std::weak_ptr context, - RenderTarget target) + const RenderTarget& target) : context_(std::move(context)), - render_target_(std::move(target)), + render_target_(target), transients_buffer_(HostBuffer::Create()) {} RenderPass::~RenderPass() = default; diff --git a/impeller/renderer/render_pass.h b/impeller/renderer/render_pass.h index 4386d5c9e00b0..1e7c2c087c12d 100644 --- a/impeller/renderer/render_pass.h +++ b/impeller/renderer/render_pass.h @@ -62,7 +62,7 @@ class RenderPass { std::shared_ptr transients_buffer_; std::vector commands_; - RenderPass(std::weak_ptr context, RenderTarget target); + RenderPass(std::weak_ptr context, const RenderTarget& target); virtual void OnSetLabel(std::string label) = 0; diff --git a/impeller/renderer/render_target.cc b/impeller/renderer/render_target.cc index bf5e1873f76bc..16f398192f359 100644 --- a/impeller/renderer/render_target.cc +++ b/impeller/renderer/render_target.cc @@ -82,7 +82,7 @@ bool RenderTarget::IsValid() const { } void RenderTarget::IterateAllAttachments( - std::function iterator) const { + const std::function& iterator) const { for (const auto& color : colors_) { if (!iterator(color.second)) { return; @@ -140,8 +140,9 @@ std::shared_ptr RenderTarget::GetRenderTargetTexture() const { : found->second.texture; } -RenderTarget& RenderTarget::SetColorAttachment(ColorAttachment attachment, - size_t index) { +RenderTarget& RenderTarget::SetColorAttachment( + const ColorAttachment& attachment, + size_t index) { if (attachment.IsValid()) { colors_[index] = attachment; } diff --git a/impeller/renderer/render_target.h b/impeller/renderer/render_target.h index 06a998b1d4350..1a940dea9827a 100644 --- a/impeller/renderer/render_target.h +++ b/impeller/renderer/render_target.h @@ -35,7 +35,8 @@ class RenderTarget { std::optional GetColorAttachmentSize(size_t index) const; - RenderTarget& SetColorAttachment(ColorAttachment attachment, size_t index); + RenderTarget& SetColorAttachment(const ColorAttachment& attachment, + size_t index); RenderTarget& SetDepthAttachment(DepthAttachment attachment); @@ -53,7 +54,7 @@ class RenderTarget { std::optional stencil_; void IterateAllAttachments( - std::function iterator) const; + const std::function& iterator) const; }; } // namespace impeller diff --git a/impeller/renderer/renderer.cc b/impeller/renderer/renderer.cc index c4c431c9ed8a8..d1fda89cf726f 100644 --- a/impeller/renderer/renderer.cc +++ b/impeller/renderer/renderer.cc @@ -33,7 +33,7 @@ bool Renderer::IsValid() const { } bool Renderer::Render(std::unique_ptr surface, - RenderCallback render_callback) const { + const RenderCallback& render_callback) const { TRACE_EVENT0("impeller", "Renderer::Render"); if (!IsValid()) { return false; diff --git a/impeller/renderer/renderer.h b/impeller/renderer/renderer.h index fe539737a7aad..b620e760bed63 100644 --- a/impeller/renderer/renderer.h +++ b/impeller/renderer/renderer.h @@ -31,7 +31,8 @@ class Renderer { bool IsValid() const; - bool Render(std::unique_ptr surface, RenderCallback callback) const; + bool Render(std::unique_ptr surface, + const RenderCallback& callback) const; std::shared_ptr GetContext() const; diff --git a/impeller/renderer/surface.cc b/impeller/renderer/surface.cc index 5e21f6169ff91..ce38697f4726a 100644 --- a/impeller/renderer/surface.cc +++ b/impeller/renderer/surface.cc @@ -10,7 +10,7 @@ namespace impeller { Surface::Surface() : Surface(RenderTarget{}) {} -Surface::Surface(RenderTarget target_desc) : desc_(std::move(target_desc)) { +Surface::Surface(const RenderTarget& target_desc) : desc_(target_desc) { if (auto size = desc_.GetColorAttachmentSize(0u); size.has_value()) { size_ = size.value(); } else { diff --git a/impeller/renderer/surface.h b/impeller/renderer/surface.h index 2a9377c5aa668..fe9a8747de06d 100644 --- a/impeller/renderer/surface.h +++ b/impeller/renderer/surface.h @@ -18,7 +18,7 @@ class Surface { public: Surface(); - explicit Surface(RenderTarget target_desc); + explicit Surface(const RenderTarget& target_desc); virtual ~Surface(); diff --git a/impeller/renderer/texture.cc b/impeller/renderer/texture.cc index 4a2a335b4709f..a2c2079936713 100644 --- a/impeller/renderer/texture.cc +++ b/impeller/renderer/texture.cc @@ -8,7 +8,7 @@ namespace impeller { -Texture::Texture(TextureDescriptor desc) : desc_(std::move(desc)) {} +Texture::Texture(TextureDescriptor desc) : desc_(desc) {} Texture::~Texture() = default; diff --git a/impeller/tessellator/tessellator.cc b/impeller/tessellator/tessellator.cc index fe1569365e3ca..0b4176f930985 100644 --- a/impeller/tessellator/tessellator.cc +++ b/impeller/tessellator/tessellator.cc @@ -34,9 +34,10 @@ static void DestroyTessellator(TESStesselator* tessellator) { } } -Tessellator::Result Tessellator::Tessellate(FillType fill_type, - const Path::Polyline& polyline, - VertexCallback callback) const { +Tessellator::Result Tessellator::Tessellate( + FillType fill_type, + const Path::Polyline& polyline, + const VertexCallback& callback) const { if (!callback) { return Result::kInputError; } diff --git a/impeller/tessellator/tessellator.h b/impeller/tessellator/tessellator.h index e42dfcbe0766c..595fb68acb8b3 100644 --- a/impeller/tessellator/tessellator.h +++ b/impeller/tessellator/tessellator.h @@ -49,7 +49,7 @@ class Tessellator { /// Tessellator::Result Tessellate(FillType fill_type, const Path::Polyline& polyline, - VertexCallback callback) const; + const VertexCallback& callback) const; private: FML_DISALLOW_COPY_AND_ASSIGN(Tessellator); diff --git a/impeller/typographer/backends/skia/text_frame_skia.cc b/impeller/typographer/backends/skia/text_frame_skia.cc index 132d896b699f0..8b649c6c5efca 100644 --- a/impeller/typographer/backends/skia/text_frame_skia.cc +++ b/impeller/typographer/backends/skia/text_frame_skia.cc @@ -27,10 +27,10 @@ static Font ToFont(const SkFont& font, Scalar scale) { metrics.min_extent = {sk_metrics.fXMin, sk_metrics.fAscent}; metrics.max_extent = {sk_metrics.fXMax, sk_metrics.fDescent}; - return Font{std::move(typeface), std::move(metrics)}; + return Font{std::move(typeface), metrics}; } -TextFrame TextFrameFromTextBlob(sk_sp blob, Scalar scale) { +TextFrame TextFrameFromTextBlob(const sk_sp& blob, Scalar scale) { if (!blob) { return {}; } @@ -74,7 +74,7 @@ TextFrame TextFrameFromTextBlob(sk_sp blob, Scalar scale) { FML_DLOG(ERROR) << "Unimplemented."; continue; } - frame.AddTextRun(std::move(text_run)); + frame.AddTextRun(text_run); } return frame; diff --git a/impeller/typographer/backends/skia/text_frame_skia.h b/impeller/typographer/backends/skia/text_frame_skia.h index a7b8074135c3f..80d6c33921fa3 100644 --- a/impeller/typographer/backends/skia/text_frame_skia.h +++ b/impeller/typographer/backends/skia/text_frame_skia.h @@ -10,6 +10,7 @@ namespace impeller { -TextFrame TextFrameFromTextBlob(sk_sp blob, Scalar scale = 1.0f); +TextFrame TextFrameFromTextBlob(const sk_sp& blob, + Scalar scale = 1.0f); } // namespace impeller diff --git a/impeller/typographer/backends/skia/text_render_context_skia.cc b/impeller/typographer/backends/skia/text_render_context_skia.cc index c29eb372b2d55..96ef3f6851839 100644 --- a/impeller/typographer/backends/skia/text_render_context_skia.cc +++ b/impeller/typographer/backends/skia/text_render_context_skia.cc @@ -4,6 +4,8 @@ #include "impeller/typographer/backends/skia/text_render_context_skia.h" +#include + #include "flutter/fml/logging.h" #include "flutter/fml/trace_event.h" #include "impeller/base/allocation.h" @@ -27,7 +29,7 @@ TextRenderContextSkia::~TextRenderContextSkia() = default; static FontGlyphPair::Set CollectUniqueFontGlyphPairsSet( GlyphAtlas::Type type, - TextRenderContext::FrameIterator frame_iterator) { + const TextRenderContext::FrameIterator& frame_iterator) { FontGlyphPair::Set set; while (auto frame = frame_iterator()) { for (const auto& run : frame->GetRuns()) { @@ -48,10 +50,10 @@ static FontGlyphPair::Vector CollectUniqueFontGlyphPairs( TextRenderContext::FrameIterator frame_iterator) { TRACE_EVENT0("impeller", __FUNCTION__); FontGlyphPair::Vector vector; - auto set = CollectUniqueFontGlyphPairsSet(type, frame_iterator); + auto set = CollectUniqueFontGlyphPairsSet(type, std::move(frame_iterator)); vector.reserve(set.size()); for (const auto& item : set) { - vector.emplace_back(std::move(item)); + vector.emplace_back(item); } return vector; } @@ -296,7 +298,7 @@ static std::shared_ptr CreateAtlasBitmap(const GlyphAtlas& atlas, } static std::shared_ptr UploadGlyphTextureAtlas( - std::shared_ptr allocator, + const std::shared_ptr& allocator, std::shared_ptr bitmap, const ISize& atlas_size, PixelFormat format) { diff --git a/impeller/typographer/font.cc b/impeller/typographer/font.cc index f8287341a2f10..75ba05f9774f5 100644 --- a/impeller/typographer/font.cc +++ b/impeller/typographer/font.cc @@ -7,7 +7,7 @@ namespace impeller { Font::Font(std::shared_ptr typeface, Metrics metrics) - : typeface_(std::move(typeface)), metrics_(std::move(metrics)) { + : typeface_(std::move(typeface)), metrics_(metrics) { if (!typeface_) { return; } diff --git a/impeller/typographer/glyph_atlas.cc b/impeller/typographer/glyph_atlas.cc index 76867746eebca..dc1d48ccbbf21 100644 --- a/impeller/typographer/glyph_atlas.cc +++ b/impeller/typographer/glyph_atlas.cc @@ -26,7 +26,8 @@ void GlyphAtlas::SetTexture(std::shared_ptr texture) { texture_ = std::move(texture); } -void GlyphAtlas::AddTypefaceGlyphPosition(FontGlyphPair pair, Rect rect) { +void GlyphAtlas::AddTypefaceGlyphPosition(const FontGlyphPair& pair, + Rect rect) { positions_[pair] = rect; } @@ -44,8 +45,8 @@ size_t GlyphAtlas::GetGlyphCount() const { } size_t GlyphAtlas::IterateGlyphs( - std::function iterator) - const { + const std::function& + iterator) const { if (!iterator) { return 0u; } diff --git a/impeller/typographer/glyph_atlas.h b/impeller/typographer/glyph_atlas.h index 676b934416bf4..3c278f64550e1 100644 --- a/impeller/typographer/glyph_atlas.h +++ b/impeller/typographer/glyph_atlas.h @@ -84,7 +84,7 @@ class GlyphAtlas { /// @param[in] pair The font-glyph pair /// @param[in] rect The rectangle /// - void AddTypefaceGlyphPosition(FontGlyphPair pair, Rect rect); + void AddTypefaceGlyphPosition(const FontGlyphPair& pair, Rect rect); //---------------------------------------------------------------------------- /// @brief Get the number of unique font-glyph pairs in this atlas. @@ -102,8 +102,9 @@ class GlyphAtlas { /// /// @return The number of glyphs iterated over. /// - size_t IterateGlyphs(std::function iterator) const; + size_t IterateGlyphs( + const std::function& + iterator) const; //---------------------------------------------------------------------------- /// @brief Find the location of a specific font-glyph pair in the atlas. diff --git a/impeller/typographer/lazy_glyph_atlas.cc b/impeller/typographer/lazy_glyph_atlas.cc index 812e8b4dbe5dd..c8e05330acf58 100644 --- a/impeller/typographer/lazy_glyph_atlas.cc +++ b/impeller/typographer/lazy_glyph_atlas.cc @@ -14,10 +14,10 @@ LazyGlyphAtlas::LazyGlyphAtlas() = default; LazyGlyphAtlas::~LazyGlyphAtlas() = default; -void LazyGlyphAtlas::AddTextFrame(TextFrame frame) { +void LazyGlyphAtlas::AddTextFrame(const TextFrame& frame) { FML_DCHECK(atlas_map_.empty()); has_color_ |= frame.HasColor(); - frames_.emplace_back(std::move(frame)); + frames_.emplace_back(frame); } bool LazyGlyphAtlas::HasColor() const { diff --git a/impeller/typographer/lazy_glyph_atlas.h b/impeller/typographer/lazy_glyph_atlas.h index 7651baa3d7925..68869aba11fe5 100644 --- a/impeller/typographer/lazy_glyph_atlas.h +++ b/impeller/typographer/lazy_glyph_atlas.h @@ -19,7 +19,7 @@ class LazyGlyphAtlas { ~LazyGlyphAtlas(); - void AddTextFrame(TextFrame frame); + void AddTextFrame(const TextFrame& frame); std::shared_ptr CreateOrGetGlyphAtlas( GlyphAtlas::Type type, diff --git a/impeller/typographer/text_frame.cc b/impeller/typographer/text_frame.cc index a4a05add87013..30e304e1cbbd8 100644 --- a/impeller/typographer/text_frame.cc +++ b/impeller/typographer/text_frame.cc @@ -25,12 +25,12 @@ std::optional TextFrame::GetBounds() const { return result; } -bool TextFrame::AddTextRun(TextRun run) { +bool TextFrame::AddTextRun(const TextRun& run) { if (!run.IsValid()) { return false; } has_color_ |= run.HasColor(); - runs_.emplace_back(std::move(run)); + runs_.emplace_back(run); return true; } diff --git a/impeller/typographer/text_frame.h b/impeller/typographer/text_frame.h index fdbba9d6e5f21..f64bef492e842 100644 --- a/impeller/typographer/text_frame.h +++ b/impeller/typographer/text_frame.h @@ -43,7 +43,7 @@ class TextFrame { /// /// @return If the text run could be added to this frame. /// - bool AddTextRun(TextRun run); + bool AddTextRun(const TextRun& run); //---------------------------------------------------------------------------- /// @brief Returns a reference to all the text runs in this frame. diff --git a/impeller/typographer/text_run.cc b/impeller/typographer/text_run.cc index f7f542a28bfd3..ee0af62b5029f 100644 --- a/impeller/typographer/text_run.cc +++ b/impeller/typographer/text_run.cc @@ -6,7 +6,7 @@ namespace impeller { -TextRun::TextRun(Font font) : font_(std::move(font)) { +TextRun::TextRun(const Font& font) : font_(font) { if (!font_.IsValid()) { return; } diff --git a/impeller/typographer/text_run.h b/impeller/typographer/text_run.h index 24851c6dda7b5..2bf433afca2f8 100644 --- a/impeller/typographer/text_run.h +++ b/impeller/typographer/text_run.h @@ -31,7 +31,7 @@ class TextRun { /// /// @param[in] font The font /// - TextRun(Font font); + TextRun(const Font& font); ~TextRun(); diff --git a/lib/io/dart_io.cc b/lib/io/dart_io.cc index a227a877713bf..75bb37e898135 100644 --- a/lib/io/dart_io.cc +++ b/lib/io/dart_io.cc @@ -16,7 +16,7 @@ using tonic::ToDart; namespace flutter { void DartIO::InitForIsolate(bool may_insecurely_connect_to_all_domains, - std::string domain_network_policy) { + const std::string& domain_network_policy) { Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io")); Dart_Handle result = Dart_SetNativeResolver(io_lib, dart::bin::LookupIONative, dart::bin::LookupIONativeSymbol); diff --git a/lib/io/dart_io.h b/lib/io/dart_io.h index 34bc8a54aaed9..1fb4204cf1efc 100644 --- a/lib/io/dart_io.h +++ b/lib/io/dart_io.h @@ -15,7 +15,7 @@ namespace flutter { class DartIO { public: static void InitForIsolate(bool may_insecurely_connect_to_all_domains, - std::string domain_network_policy); + const std::string& domain_network_policy); private: FML_DISALLOW_IMPLICIT_CONSTRUCTORS(DartIO); diff --git a/lib/ui/compositing/scene_builder.cc b/lib/ui/compositing/scene_builder.cc index 9a543c284a18a..71419b22f2e0b 100644 --- a/lib/ui/compositing/scene_builder.cc +++ b/lib/ui/compositing/scene_builder.cc @@ -44,7 +44,7 @@ SceneBuilder::~SceneBuilder() = default; void SceneBuilder::pushTransform(Dart_Handle layer_handle, tonic::Float64List& matrix4, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { SkMatrix sk_matrix = ToSkMatrix(matrix4); auto layer = std::make_shared(sk_matrix); PushLayer(layer); @@ -60,7 +60,7 @@ void SceneBuilder::pushTransform(Dart_Handle layer_handle, void SceneBuilder::pushOffset(Dart_Handle layer_handle, double dx, double dy, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { SkMatrix sk_matrix = SkMatrix::Translate(dx, dy); auto layer = std::make_shared(sk_matrix); PushLayer(layer); @@ -77,7 +77,7 @@ void SceneBuilder::pushClipRect(Dart_Handle layer_handle, double top, double bottom, int clipBehavior, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { SkRect clipRect = SkRect::MakeLTRB(left, top, right, bottom); flutter::Clip clip_behavior = static_cast(clipBehavior); auto layer = @@ -93,7 +93,7 @@ void SceneBuilder::pushClipRect(Dart_Handle layer_handle, void SceneBuilder::pushClipRRect(Dart_Handle layer_handle, const RRect& rrect, int clipBehavior, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { flutter::Clip clip_behavior = static_cast(clipBehavior); auto layer = std::make_shared(rrect.sk_rrect, clip_behavior); @@ -108,7 +108,7 @@ void SceneBuilder::pushClipRRect(Dart_Handle layer_handle, void SceneBuilder::pushClipPath(Dart_Handle layer_handle, const CanvasPath* path, int clipBehavior, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { flutter::Clip clip_behavior = static_cast(clipBehavior); FML_DCHECK(clip_behavior != flutter::Clip::none); auto layer = @@ -125,7 +125,7 @@ void SceneBuilder::pushOpacity(Dart_Handle layer_handle, int alpha, double dx, double dy, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { auto layer = std::make_shared(alpha, SkPoint::Make(dx, dy)); PushLayer(layer); @@ -138,7 +138,7 @@ void SceneBuilder::pushOpacity(Dart_Handle layer_handle, void SceneBuilder::pushColorFilter(Dart_Handle layer_handle, const ColorFilter* color_filter, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { auto layer = std::make_shared(color_filter->filter()); PushLayer(layer); @@ -151,7 +151,7 @@ void SceneBuilder::pushColorFilter(Dart_Handle layer_handle, void SceneBuilder::pushImageFilter(Dart_Handle layer_handle, const ImageFilter* image_filter, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { auto layer = std::make_shared(image_filter->filter()); PushLayer(layer); @@ -162,10 +162,11 @@ void SceneBuilder::pushImageFilter(Dart_Handle layer_handle, } } -void SceneBuilder::pushBackdropFilter(Dart_Handle layer_handle, - ImageFilter* filter, - int blendMode, - fml::RefPtr oldLayer) { +void SceneBuilder::pushBackdropFilter( + Dart_Handle layer_handle, + ImageFilter* filter, + int blendMode, + const fml::RefPtr& oldLayer) { auto layer = std::make_shared( filter->filter(), static_cast(blendMode)); PushLayer(layer); @@ -184,7 +185,7 @@ void SceneBuilder::pushShaderMask(Dart_Handle layer_handle, double maskRectBottom, int blendMode, int filterQualityIndex, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { SkRect rect = SkRect::MakeLTRB(maskRectLeft, maskRectTop, maskRectRight, maskRectBottom); auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex); @@ -204,7 +205,7 @@ void SceneBuilder::pushPhysicalShape(Dart_Handle layer_handle, int color, int shadow_color, int clipBehavior, - fml::RefPtr oldLayer) { + const fml::RefPtr& oldLayer) { auto layer = std::make_shared( static_cast(color), static_cast(shadow_color), static_cast(elevation), path->path(), @@ -217,7 +218,7 @@ void SceneBuilder::pushPhysicalShape(Dart_Handle layer_handle, } } -void SceneBuilder::addRetained(fml::RefPtr retainedLayer) { +void SceneBuilder::addRetained(const fml::RefPtr& retainedLayer) { AddLayer(retainedLayer->Layer()); } diff --git a/lib/ui/compositing/scene_builder.h b/lib/ui/compositing/scene_builder.h index a1fb47603f35a..1ef7e0773eb7e 100644 --- a/lib/ui/compositing/scene_builder.h +++ b/lib/ui/compositing/scene_builder.h @@ -44,41 +44,41 @@ class SceneBuilder : public RefCountedDartWrappable { } void pushTransform(Dart_Handle layer_handle, tonic::Float64List& matrix4, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushOffset(Dart_Handle layer_handle, double dx, double dy, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushClipRect(Dart_Handle layer_handle, double left, double right, double top, double bottom, int clipBehavior, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushClipRRect(Dart_Handle layer_handle, const RRect& rrect, int clipBehavior, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushClipPath(Dart_Handle layer_handle, const CanvasPath* path, int clipBehavior, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushOpacity(Dart_Handle layer_handle, int alpha, double dx, double dy, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushColorFilter(Dart_Handle layer_handle, const ColorFilter* color_filter, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushImageFilter(Dart_Handle layer_handle, const ImageFilter* image_filter, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushBackdropFilter(Dart_Handle layer_handle, ImageFilter* filter, int blendMode, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushShaderMask(Dart_Handle layer_handle, Shader* shader, double maskRectLeft, @@ -87,16 +87,16 @@ class SceneBuilder : public RefCountedDartWrappable { double maskRectBottom, int blendMode, int filterQualityIndex, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); void pushPhysicalShape(Dart_Handle layer_handle, const CanvasPath* path, double elevation, int color, int shadowColor, int clipBehavior, - fml::RefPtr oldLayer); + const fml::RefPtr& oldLayer); - void addRetained(fml::RefPtr retainedLayer); + void addRetained(const fml::RefPtr& retainedLayer); void pop(); diff --git a/lib/ui/compositing/scene_builder_unittests.cc b/lib/ui/compositing/scene_builder_unittests.cc index bfdbda698a08f..41efcdc64efd5 100644 --- a/lib/ui/compositing/scene_builder_unittests.cc +++ b/lib/ui/compositing/scene_builder_unittests.cc @@ -93,7 +93,7 @@ TEST_F(ShellTest, SceneBuilderBuildAndSceneDisposeReleasesLayerStack) { }); message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, EngineLayerDisposeReleasesReference) { @@ -152,7 +152,7 @@ TEST_F(ShellTest, EngineLayerDisposeReleasesReference) { }); message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } } // namespace testing diff --git a/lib/ui/dart_runtime_hooks.cc b/lib/ui/dart_runtime_hooks.cc index 5b7021a0317d2..1b3dde7b44886 100644 --- a/lib/ui/dart_runtime_hooks.cc +++ b/lib/ui/dart_runtime_hooks.cc @@ -138,13 +138,13 @@ void DartRuntimeHooks::Install(bool is_ui_isolate, InitDartIO(builtin, script_uri); } -void DartRuntimeHooks::Logger_PrintDebugString(std::string message) { +void DartRuntimeHooks::Logger_PrintDebugString(const std::string& message) { #ifndef NDEBUG DartRuntimeHooks::Logger_PrintString(message); #endif } -void DartRuntimeHooks::Logger_PrintString(std::string message) { +void DartRuntimeHooks::Logger_PrintString(const std::string& message) { const auto& tag = UIDartState::Current()->logger_prefix(); UIDartState::Current()->LogMessage(tag, message); diff --git a/lib/ui/dart_runtime_hooks.h b/lib/ui/dart_runtime_hooks.h index 163df335733ef..f41307a189685 100644 --- a/lib/ui/dart_runtime_hooks.h +++ b/lib/ui/dart_runtime_hooks.h @@ -15,9 +15,9 @@ class DartRuntimeHooks { public: static void Install(bool is_ui_isolate, const std::string& script_uri); - static void Logger_PrintDebugString(std::string message); + static void Logger_PrintDebugString(const std::string& message); - static void Logger_PrintString(std::string message); + static void Logger_PrintString(const std::string& message); static void ScheduleMicrotask(Dart_Handle closure); diff --git a/lib/ui/hooks_unittests.cc b/lib/ui/hooks_unittests.cc index abe48e7b8dd82..8fc69f42dcd7d 100644 --- a/lib/ui/hooks_unittests.cc +++ b/lib/ui/hooks_unittests.cc @@ -79,7 +79,7 @@ TEST_F(HooksTest, HooksUnitTests) { }); message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } } // namespace testing diff --git a/lib/ui/painting/display_list_deferred_image_gpu_skia.cc b/lib/ui/painting/display_list_deferred_image_gpu_skia.cc index ab95eac6d33e4..365ead72feedd 100644 --- a/lib/ui/painting/display_list_deferred_image_gpu_skia.cc +++ b/lib/ui/painting/display_list_deferred_image_gpu_skia.cc @@ -12,7 +12,7 @@ sk_sp DlDeferredImageGPUSkia::Make( const SkImageInfo& image_info, sk_sp display_list, fml::WeakPtr snapshot_delegate, - fml::RefPtr raster_task_runner, + const fml::RefPtr& raster_task_runner, fml::RefPtr unref_queue) { return sk_sp(new DlDeferredImageGPUSkia( ImageWrapper::Make(image_info, std::move(display_list), @@ -25,7 +25,7 @@ sk_sp DlDeferredImageGPUSkia::MakeFromLayerTree( const SkImageInfo& image_info, std::shared_ptr layer_tree, fml::WeakPtr snapshot_delegate, - fml::RefPtr raster_task_runner, + const fml::RefPtr& raster_task_runner, fml::RefPtr unref_queue) { return sk_sp(new DlDeferredImageGPUSkia( ImageWrapper::MakeFromLayerTree( @@ -191,7 +191,7 @@ void DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList( wrapper->image_ = std::move(result->image); } else { std::scoped_lock lock(wrapper->error_mutex_); - wrapper->error_ = std::move(result->error); + wrapper->error_ = result->error; } }); } @@ -210,7 +210,7 @@ void DlDeferredImageGPUSkia::ImageWrapper::Unregister() { void DlDeferredImageGPUSkia::ImageWrapper::DeleteTexture() { if (texture_.isValid()) { - unref_queue_->DeleteTexture(std::move(texture_)); + unref_queue_->DeleteTexture(texture_); texture_ = GrBackendTexture(); } image_.reset(); diff --git a/lib/ui/painting/display_list_deferred_image_gpu_skia.h b/lib/ui/painting/display_list_deferred_image_gpu_skia.h index 0cb5bddfbcd5f..d5e3f807fdf9b 100644 --- a/lib/ui/painting/display_list_deferred_image_gpu_skia.h +++ b/lib/ui/painting/display_list_deferred_image_gpu_skia.h @@ -26,14 +26,14 @@ class DlDeferredImageGPUSkia final : public DlImage { const SkImageInfo& image_info, sk_sp display_list, fml::WeakPtr snapshot_delegate, - fml::RefPtr raster_task_runner, + const fml::RefPtr& raster_task_runner, fml::RefPtr unref_queue); static sk_sp MakeFromLayerTree( const SkImageInfo& image_info, std::shared_ptr layer_tree, fml::WeakPtr snapshot_delegate, - fml::RefPtr raster_task_runner, + const fml::RefPtr& raster_task_runner, fml::RefPtr unref_queue); // |DlImage| diff --git a/lib/ui/painting/engine_layer.cc b/lib/ui/painting/engine_layer.cc index d8e34f190e72b..be9e4ffbe59bf 100644 --- a/lib/ui/painting/engine_layer.cc +++ b/lib/ui/painting/engine_layer.cc @@ -4,6 +4,8 @@ #include "flutter/lib/ui/painting/engine_layer.h" +#include + #include "flutter/lib/ui/ui_dart_state.h" #include "third_party/tonic/converter/dart_converter.h" #include "third_party/tonic/dart_args.h" @@ -15,7 +17,7 @@ namespace flutter { IMPLEMENT_WRAPPERTYPEINFO(ui, EngineLayer); EngineLayer::EngineLayer(std::shared_ptr layer) - : layer_(layer) {} + : layer_(std::move(layer)) {} EngineLayer::~EngineLayer() = default; diff --git a/lib/ui/painting/fragment_program.cc b/lib/ui/painting/fragment_program.cc index 2f717c071c8fa..87b8ef59ee92b 100644 --- a/lib/ui/painting/fragment_program.cc +++ b/lib/ui/painting/fragment_program.cc @@ -23,7 +23,7 @@ namespace flutter { IMPLEMENT_WRAPPERTYPEINFO(ui, FragmentProgram); -std::string FragmentProgram::initFromAsset(std::string asset_name) { +std::string FragmentProgram::initFromAsset(const std::string& asset_name) { FML_TRACE_EVENT("flutter", "FragmentProgram::initFromAsset", "asset", asset_name); std::shared_ptr asset_manager = UIDartState::Current() @@ -98,7 +98,7 @@ std::string FragmentProgram::initFromAsset(std::string asset_name) { std::shared_ptr FragmentProgram::MakeDlColorSource( sk_sp float_uniforms, const std::vector>& children) { - return DlColorSource::MakeRuntimeEffect(runtime_effect_, std::move(children), + return DlColorSource::MakeRuntimeEffect(runtime_effect_, children, std::move(float_uniforms)); } diff --git a/lib/ui/painting/fragment_program.h b/lib/ui/painting/fragment_program.h index 0f40ddffd9d41..b7250b6aadcd3 100644 --- a/lib/ui/painting/fragment_program.h +++ b/lib/ui/painting/fragment_program.h @@ -27,7 +27,7 @@ class FragmentProgram : public RefCountedDartWrappable { ~FragmentProgram() override; static void Create(Dart_Handle wrapper); - std::string initFromAsset(std::string asset_name); + std::string initFromAsset(const std::string& asset_name); fml::RefPtr shader(Dart_Handle shader, Dart_Handle uniforms_handle, diff --git a/lib/ui/painting/fragment_shader.cc b/lib/ui/painting/fragment_shader.cc index 215d4e235eb5c..84c8aa2291693 100644 --- a/lib/ui/painting/fragment_shader.cc +++ b/lib/ui/painting/fragment_shader.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include +#include #include "flutter/lib/ui/painting/fragment_shader.h" @@ -24,7 +25,7 @@ ReusableFragmentShader::ReusableFragmentShader( fml::RefPtr program, uint64_t float_count, uint64_t sampler_count) - : program_(program), + : program_(std::move(program)), uniform_data_(SkData::MakeUninitialized( (float_count + 2 * sampler_count) * sizeof(float))), samplers_(sampler_count), diff --git a/lib/ui/painting/image_decoder.cc b/lib/ui/painting/image_decoder.cc index 7fabd46115a10..dabdb2b7513ae 100644 --- a/lib/ui/painting/image_decoder.cc +++ b/lib/ui/painting/image_decoder.cc @@ -14,30 +14,30 @@ namespace flutter { std::unique_ptr ImageDecoder::Make( const Settings& settings, - TaskRunners runners, + const TaskRunners& runners, std::shared_ptr concurrent_task_runner, fml::WeakPtr io_manager) { #if IMPELLER_SUPPORTS_RENDERING if (settings.enable_impeller) { return std::make_unique( - std::move(runners), // + runners, // std::move(concurrent_task_runner), // std::move(io_manager) // ); } #endif // IMPELLER_SUPPORTS_RENDERING return std::make_unique( - std::move(runners), // + runners, // std::move(concurrent_task_runner), // std::move(io_manager) // ); } ImageDecoder::ImageDecoder( - TaskRunners runners, + const TaskRunners& runners, std::shared_ptr concurrent_task_runner, fml::WeakPtr io_manager) - : runners_(std::move(runners)), + : runners_(runners), concurrent_task_runner_(std::move(concurrent_task_runner)), io_manager_(std::move(io_manager)), weak_factory_(this) { diff --git a/lib/ui/painting/image_decoder.h b/lib/ui/painting/image_decoder.h index 11c3757e9c894..e6e82d7146627 100644 --- a/lib/ui/painting/image_decoder.h +++ b/lib/ui/painting/image_decoder.h @@ -25,7 +25,7 @@ class ImageDecoder { public: static std::unique_ptr Make( const Settings& settings, - TaskRunners runners, + const TaskRunners& runners, std::shared_ptr concurrent_task_runner, fml::WeakPtr io_manager); @@ -51,7 +51,7 @@ class ImageDecoder { fml::WeakPtr io_manager_; ImageDecoder( - TaskRunners runners, + const TaskRunners& runners, std::shared_ptr concurrent_task_runner, fml::WeakPtr io_manager); diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc index 211d77aad479c..31a5ab0db815d 100644 --- a/lib/ui/painting/image_decoder_impeller.cc +++ b/lib/ui/painting/image_decoder_impeller.cc @@ -23,12 +23,10 @@ namespace flutter { ImageDecoderImpeller::ImageDecoderImpeller( - TaskRunners runners, + const TaskRunners& runners, std::shared_ptr concurrent_task_runner, - fml::WeakPtr io_manager) - : ImageDecoder(std::move(runners), - std::move(concurrent_task_runner), - io_manager) { + const fml::WeakPtr& io_manager) + : ImageDecoder(runners, std::move(concurrent_task_runner), io_manager) { std::promise> context_promise; context_ = context_promise.get_future(); runners_.GetIOTaskRunner()->PostTask(fml::MakeCopyable( @@ -139,8 +137,9 @@ std::shared_ptr ImageDecoderImpeller::DecompressTexture( return scaled_bitmap; } -static sk_sp UploadTexture(std::shared_ptr context, - std::shared_ptr bitmap) { +static sk_sp UploadTexture( + const std::shared_ptr& context, + std::shared_ptr bitmap) { TRACE_EVENT0("impeller", __FUNCTION__); if (!context || !bitmap) { return nullptr; diff --git a/lib/ui/painting/image_decoder_impeller.h b/lib/ui/painting/image_decoder_impeller.h index 921419f11ef5b..0d1afcf2a3dcc 100644 --- a/lib/ui/painting/image_decoder_impeller.h +++ b/lib/ui/painting/image_decoder_impeller.h @@ -20,9 +20,9 @@ namespace flutter { class ImageDecoderImpeller final : public ImageDecoder { public: ImageDecoderImpeller( - TaskRunners runners, + const TaskRunners& runners, std::shared_ptr concurrent_task_runner, - fml::WeakPtr io_manager); + const fml::WeakPtr& io_manager); ~ImageDecoderImpeller() override; diff --git a/lib/ui/painting/image_decoder_skia.cc b/lib/ui/painting/image_decoder_skia.cc index 3067894e9ff63..2dc6891c86d1f 100644 --- a/lib/ui/painting/image_decoder_skia.cc +++ b/lib/ui/painting/image_decoder_skia.cc @@ -13,16 +13,16 @@ namespace flutter { ImageDecoderSkia::ImageDecoderSkia( - TaskRunners runners, + const TaskRunners& runners, std::shared_ptr concurrent_task_runner, fml::WeakPtr io_manager) - : ImageDecoder(std::move(runners), + : ImageDecoder(runners, std::move(concurrent_task_runner), std::move(io_manager)) {} ImageDecoderSkia::~ImageDecoderSkia() = default; -static sk_sp ResizeRasterImage(sk_sp image, +static sk_sp ResizeRasterImage(const sk_sp& image, const SkISize& resized_dimensions, const fml::tracing::TraceFlow& flow) { FML_DCHECK(!image->isTextureBacked()); @@ -90,8 +90,8 @@ static sk_sp ImageFromDecompressedData( return image->makeRasterImage(); } - return ResizeRasterImage(std::move(image), - SkISize::Make(target_width, target_height), flow); + return ResizeRasterImage(image, SkISize::Make(target_width, target_height), + flow); } sk_sp ImageDecoderSkia::ImageFromCompressedData( @@ -144,8 +144,7 @@ sk_sp ImageDecoderSkia::ImageFromCompressedData( << "Could not create a scaled image from a scaled bitmap."; return nullptr; } - return ResizeRasterImage(std::move(decoded_image), resized_dimensions, - flow); + return ResizeRasterImage(decoded_image, resized_dimensions, flow); } } @@ -154,12 +153,12 @@ sk_sp ImageDecoderSkia::ImageFromCompressedData( return nullptr; } - return ResizeRasterImage(std::move(image), resized_dimensions, flow); + return ResizeRasterImage(image, resized_dimensions, flow); } static SkiaGPUObject UploadRasterImage( sk_sp image, - fml::WeakPtr io_manager, + const fml::WeakPtr& io_manager, const fml::tracing::TraceFlow& flow) { TRACE_EVENT0("flutter", __FUNCTION__); flow.Step(__FUNCTION__); diff --git a/lib/ui/painting/image_decoder_skia.h b/lib/ui/painting/image_decoder_skia.h index 2e6837784b90f..aca9fad94dad0 100644 --- a/lib/ui/painting/image_decoder_skia.h +++ b/lib/ui/painting/image_decoder_skia.h @@ -13,7 +13,7 @@ namespace flutter { class ImageDecoderSkia final : public ImageDecoder { public: ImageDecoderSkia( - TaskRunners runners, + const TaskRunners& runners, std::shared_ptr concurrent_task_runner, fml::WeakPtr io_manager); diff --git a/lib/ui/painting/image_decoder_unittests.cc b/lib/ui/painting/image_decoder_unittests.cc index 658ec8d97864e..55c5e7e756bee 100644 --- a/lib/ui/painting/image_decoder_unittests.cc +++ b/lib/ui/painting/image_decoder_unittests.cc @@ -24,7 +24,7 @@ namespace testing { class TestIOManager final : public IOManager { public: - explicit TestIOManager(fml::RefPtr task_runner, + explicit TestIOManager(const fml::RefPtr& task_runner, bool has_gpu_context = true) : gl_surface_(SkISize::Make(1, 1)), gl_context_(has_gpu_context ? gl_surface_.CreateGrContext() : nullptr), @@ -140,9 +140,8 @@ TEST_F(ImageDecoderFixtureTest, CanCreateImageDecoder) { PostTaskSync(runners.GetIOTaskRunner(), [&]() { TestIOManager manager(runners.GetIOTaskRunner()); Settings settings; - auto decoder = - ImageDecoder::Make(settings, std::move(runners), loop->GetTaskRunner(), - manager.GetWeakIOManager()); + auto decoder = ImageDecoder::Make(settings, runners, loop->GetTaskRunner(), + manager.GetWeakIOManager()); ASSERT_NE(decoder, nullptr); }); } @@ -202,7 +201,7 @@ TEST_F(ImageDecoderFixtureTest, InvalidImageResultsError) { fml::MakeRefCounted( std::move(data), std::make_unique()); - ImageDecoder::ImageResult callback = [&](sk_sp image) { + ImageDecoder::ImageResult callback = [&](const sk_sp& image) { ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread()); ASSERT_FALSE(image); latch.Signal(); @@ -248,7 +247,7 @@ TEST_F(ImageDecoderFixtureTest, ValidImageResultsInSuccess) { auto descriptor = fml::MakeRefCounted( std::move(data), std::move(generator)); - ImageDecoder::ImageResult callback = [&](sk_sp image) { + ImageDecoder::ImageResult callback = [&](const sk_sp& image) { ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread()); ASSERT_TRUE(image && image->skia_image()); EXPECT_TRUE(io_manager->did_access_is_gpu_disabled_sync_switch_); @@ -306,7 +305,7 @@ TEST_F(ImageDecoderFixtureTest, ExifDataIsRespectedOnDecode) { auto descriptor = fml::MakeRefCounted( std::move(data), std::move(generator)); - ImageDecoder::ImageResult callback = [&](sk_sp image) { + ImageDecoder::ImageResult callback = [&](const sk_sp& image) { ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread()); ASSERT_TRUE(image && image->skia_image()); decoded_size = image->skia_image()->dimensions(); @@ -366,7 +365,7 @@ TEST_F(ImageDecoderFixtureTest, CanDecodeWithoutAGPUContext) { auto descriptor = fml::MakeRefCounted( std::move(data), std::move(generator)); - ImageDecoder::ImageResult callback = [&](sk_sp image) { + ImageDecoder::ImageResult callback = [&](const sk_sp& image) { ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread()); ASSERT_TRUE(image && image->skia_image()); runners.GetIOTaskRunner()->PostTask(release_io_manager); @@ -437,7 +436,7 @@ TEST_F(ImageDecoderFixtureTest, CanDecodeWithResizes) { auto descriptor = fml::MakeRefCounted( std::move(data), std::move(generator)); - ImageDecoder::ImageResult callback = [&](sk_sp image) { + ImageDecoder::ImageResult callback = [&](const sk_sp& image) { ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread()); ASSERT_TRUE(image && image->skia_image()); final_size = image->skia_image()->dimensions(); diff --git a/lib/ui/painting/image_descriptor.cc b/lib/ui/painting/image_descriptor.cc index 5c117008df1b5..c31d1ba0cd1dd 100644 --- a/lib/ui/painting/image_descriptor.cc +++ b/lib/ui/painting/image_descriptor.cc @@ -27,7 +27,7 @@ ImageDescriptor::ImageDescriptor(sk_sp buffer, std::optional row_bytes) : buffer_(std::move(buffer)), generator_(nullptr), - image_info_(std::move(image_info)), + image_info_(image_info), row_bytes_(row_bytes) {} ImageDescriptor::ImageDescriptor(sk_sp buffer, @@ -79,7 +79,7 @@ Dart_Handle ImageDescriptor::initEncoded(Dart_Handle descriptor_handle, } void ImageDescriptor::initRaw(Dart_Handle descriptor_handle, - fml::RefPtr data, + const fml::RefPtr& data, int width, int height, int row_bytes, diff --git a/lib/ui/painting/image_descriptor.h b/lib/ui/painting/image_descriptor.h index 191e2f49fb02c..c712f247df7bc 100644 --- a/lib/ui/painting/image_descriptor.h +++ b/lib/ui/painting/image_descriptor.h @@ -51,7 +51,7 @@ class ImageDescriptor : public RefCountedDartWrappable { /// @brief Synchronously initializes an `ImageDescriptor` for decompressed /// image data as specified by the `PixelFormat`. static void initRaw(Dart_Handle descriptor_handle, - fml::RefPtr data, + const fml::RefPtr& data, int width, int height, int row_bytes, diff --git a/lib/ui/painting/image_dispose_unittests.cc b/lib/ui/painting/image_dispose_unittests.cc index 4d88d488c91ca..0f8bb6d027062 100644 --- a/lib/ui/painting/image_dispose_unittests.cc +++ b/lib/ui/painting/image_dispose_unittests.cc @@ -107,7 +107,7 @@ TEST_F(ImageDisposeTest, ImageReleasedAfterFrameAndDisposePictureAndLayer) { current_image_.reset(); shell->GetPlatformView()->NotifyDestroyed(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } } // namespace testing diff --git a/lib/ui/painting/image_encoding.cc b/lib/ui/painting/image_encoding.cc index 1e28774932910..6b1fa6b9dfd30 100644 --- a/lib/ui/painting/image_encoding.cc +++ b/lib/ui/painting/image_encoding.cc @@ -61,12 +61,12 @@ void InvokeDataCallback(std::unique_ptr callback, } void ConvertImageToRaster( - sk_sp dl_image, + const sk_sp& dl_image, std::function)> encode_task, - fml::RefPtr raster_task_runner, - fml::RefPtr io_task_runner, - fml::WeakPtr resource_context, - fml::WeakPtr snapshot_delegate, + const fml::RefPtr& raster_task_runner, + const fml::RefPtr& io_task_runner, + const fml::WeakPtr& resource_context, + const fml::WeakPtr& snapshot_delegate, const std::shared_ptr& is_gpu_disabled_sync_switch) { // If the owning_context is kRaster, we can't access it on this task runner. if (dl_image->owning_context() != DlImage::OwningContext::kRaster) { @@ -111,16 +111,14 @@ void ConvertImageToRaster( auto image = dl_image->skia_image(); if (!image || !snapshot_delegate) { io_task_runner->PostTask( - [encode_task = std::move(encode_task)]() mutable { - encode_task(nullptr); - }); + [encode_task = encode_task]() mutable { encode_task(nullptr); }); return; } sk_sp raster_image = snapshot_delegate->ConvertToRasterImage(image); - io_task_runner->PostTask([image, encode_task = std::move(encode_task), + io_task_runner->PostTask([image, encode_task = encode_task, raster_image = std::move(raster_image), resource_context, is_gpu_disabled_sync_switch, owning_context = dl_image->owning_context(), @@ -140,7 +138,7 @@ void ConvertImageToRaster( }); } -sk_sp CopyImageByteData(sk_sp raster_image, +sk_sp CopyImageByteData(const sk_sp& raster_image, SkColorType color_type, SkAlphaType alpha_type) { FML_DCHECK(raster_image); @@ -177,7 +175,8 @@ sk_sp CopyImageByteData(sk_sp raster_image, return SkData::MakeWithCopy(pixmap.addr(), pixmap.computeByteSize()); } -sk_sp EncodeImage(sk_sp raster_image, ImageByteFormat format) { +sk_sp EncodeImage(const sk_sp& raster_image, + ImageByteFormat format) { TRACE_EVENT0("flutter", __FUNCTION__); if (!raster_image) { @@ -214,14 +213,14 @@ sk_sp EncodeImage(sk_sp raster_image, ImageByteFormat format) { } void EncodeImageAndInvokeDataCallback( - sk_sp image, + const sk_sp& image, std::unique_ptr callback, ImageByteFormat format, - fml::RefPtr ui_task_runner, - fml::RefPtr raster_task_runner, - fml::RefPtr io_task_runner, - fml::WeakPtr resource_context, - fml::WeakPtr snapshot_delegate, + const fml::RefPtr& ui_task_runner, + const fml::RefPtr& raster_task_runner, + const fml::RefPtr& io_task_runner, + const fml::WeakPtr& resource_context, + const fml::WeakPtr& snapshot_delegate, const std::shared_ptr& is_gpu_disabled_sync_switch) { auto callback_task = fml::MakeCopyable( [callback = std::move(callback)](sk_sp encoded) mutable { @@ -231,17 +230,17 @@ void EncodeImageAndInvokeDataCallback( // EncodeImage. // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) auto encode_task = [callback_task = std::move(callback_task), format, - ui_task_runner](sk_sp raster_image) { - sk_sp encoded = EncodeImage(std::move(raster_image), format); - ui_task_runner->PostTask([callback_task = std::move(callback_task), + ui_task_runner](const sk_sp& raster_image) { + sk_sp encoded = EncodeImage(raster_image, format); + ui_task_runner->PostTask([callback_task = callback_task, encoded = std::move(encoded)]() mutable { callback_task(std::move(encoded)); }); }; FML_DCHECK(image); - ConvertImageToRaster(std::move(image), encode_task, raster_task_runner, - io_task_runner, resource_context, snapshot_delegate, + ConvertImageToRaster(image, encode_task, raster_task_runner, io_task_runner, + resource_context, snapshot_delegate, is_gpu_disabled_sync_switch); } @@ -276,10 +275,9 @@ Dart_Handle EncodeImage(CanvasImage* canvas_image, snapshot_delegate = UIDartState::Current()->GetSnapshotDelegate()]() mutable { EncodeImageAndInvokeDataCallback( - std::move(image), std::move(callback), image_format, - std::move(ui_task_runner), std::move(raster_task_runner), - std::move(io_task_runner), io_manager->GetResourceContext(), - std::move(snapshot_delegate), + std::move(image), std::move(callback), image_format, ui_task_runner, + std::move(raster_task_runner), std::move(io_task_runner), + io_manager->GetResourceContext(), std::move(snapshot_delegate), io_manager->GetIsGpuDisabledSyncSwitch()); })); diff --git a/lib/ui/painting/image_encoding_unittests.cc b/lib/ui/painting/image_encoding_unittests.cc index 818727745e236..1899054a94c1d 100644 --- a/lib/ui/painting/image_encoding_unittests.cc +++ b/lib/ui/painting/image_encoding_unittests.cc @@ -28,11 +28,11 @@ class MockSyncSwitch { public: struct Handlers { Handlers& SetIfTrue(const std::function& handler) { - true_handler = std::move(handler); + true_handler = handler; return *this; } Handlers& SetIfFalse(const std::function& handler) { - false_handler = std::move(handler); + false_handler = handler; return *this; } std::function true_handler = [] {}; @@ -99,7 +99,7 @@ TEST_F(ShellTest, EncodeImageGivesExternalTypedData) { }); message_latch.Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, EncodeImageAccessesSyncSwitch) { @@ -163,7 +163,7 @@ TEST_F(ShellTest, EncodeImageAccessesSyncSwitch) { }); message_latch.Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } } // namespace testing diff --git a/lib/ui/painting/image_generator.cc b/lib/ui/painting/image_generator.cc index 59ee40768fe8f..d8dbe8371b4e2 100644 --- a/lib/ui/painting/image_generator.cc +++ b/lib/ui/painting/image_generator.cc @@ -4,6 +4,8 @@ #include "flutter/lib/ui/painting/image_generator.h" +#include + #include "flutter/fml/logging.h" namespace flutter { @@ -85,7 +87,8 @@ BuiltinSkiaCodecImageGenerator::BuiltinSkiaCodecImageGenerator( BuiltinSkiaCodecImageGenerator::BuiltinSkiaCodecImageGenerator( sk_sp buffer) : codec_generator_(static_cast( - SkCodecImageGenerator::MakeFromEncodedCodec(buffer).release())) {} + SkCodecImageGenerator::MakeFromEncodedCodec(std::move(buffer)) + .release())) {} const SkImageInfo& BuiltinSkiaCodecImageGenerator::GetInfo() { return codec_generator_->getInfo(); @@ -133,7 +136,7 @@ bool BuiltinSkiaCodecImageGenerator::GetPixels( std::unique_ptr BuiltinSkiaCodecImageGenerator::MakeFromData( sk_sp data) { - auto codec = SkCodec::MakeFromData(data); + auto codec = SkCodec::MakeFromData(std::move(data)); if (!codec) { return nullptr; } diff --git a/lib/ui/painting/image_generator_registry.cc b/lib/ui/painting/image_generator_registry.cc index bb520f54ab78c..4460182f0a673 100644 --- a/lib/ui/painting/image_generator_registry.cc +++ b/lib/ui/painting/image_generator_registry.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include +#include #include "flutter/lib/ui/painting/image_generator_registry.h" #include "third_party/skia/include/codec/SkCodec.h" @@ -18,7 +19,7 @@ namespace flutter { ImageGeneratorRegistry::ImageGeneratorRegistry() : weak_factory_(this) { AddFactory( [](sk_sp buffer) { - return BuiltinSkiaCodecImageGenerator::MakeFromData(buffer); + return BuiltinSkiaCodecImageGenerator::MakeFromData(std::move(buffer)); }, 0); @@ -26,7 +27,8 @@ ImageGeneratorRegistry::ImageGeneratorRegistry() : weak_factory_(this) { #ifdef FML_OS_MACOSX AddFactory( [](sk_sp buffer) { - auto generator = SkImageGeneratorCG::MakeFromEncodedCG(buffer); + auto generator = + SkImageGeneratorCG::MakeFromEncodedCG(std::move(buffer)); return BuiltinSkiaImageGenerator::MakeFromGenerator( std::move(generator)); }, @@ -46,11 +48,11 @@ ImageGeneratorRegistry::~ImageGeneratorRegistry() = default; void ImageGeneratorRegistry::AddFactory(ImageGeneratorFactory factory, int32_t priority) { - image_generator_factories_.insert({factory, priority, ++nonce_}); + image_generator_factories_.insert({std::move(factory), priority, ++nonce_}); } std::shared_ptr -ImageGeneratorRegistry::CreateCompatibleGenerator(sk_sp buffer) { +ImageGeneratorRegistry::CreateCompatibleGenerator(const sk_sp& buffer) { if (!image_generator_factories_.size()) { FML_LOG(WARNING) << "There are currently no image decoders installed. If you're writing " diff --git a/lib/ui/painting/image_generator_registry.h b/lib/ui/painting/image_generator_registry.h index b04dc1cc24eba..96f8dc86a6fc1 100644 --- a/lib/ui/painting/image_generator_registry.h +++ b/lib/ui/painting/image_generator_registry.h @@ -56,7 +56,7 @@ class ImageGeneratorRegistry { /// `std::shared_ptr(nullptr)` is returned. /// @see `ImageGenerator` std::shared_ptr CreateCompatibleGenerator( - sk_sp buffer); + const sk_sp& buffer); fml::WeakPtr GetWeakPtr() const; diff --git a/lib/ui/painting/image_generator_registry_unittests.cc b/lib/ui/painting/image_generator_registry_unittests.cc index ea3fb2254c469..66ff6424a0b90 100644 --- a/lib/ui/painting/image_generator_registry_unittests.cc +++ b/lib/ui/painting/image_generator_registry_unittests.cc @@ -85,7 +85,7 @@ TEST_F(ShellTest, PositivePriorityTakesPrecedentOverDefaultGenerators) { const int fake_width = 1337; registry.AddFactory( - [fake_width](sk_sp buffer) { + [fake_width](const sk_sp& buffer) { return std::make_unique(fake_width); }, 1); @@ -99,7 +99,7 @@ TEST_F(ShellTest, DefaultGeneratorsTakePrecedentOverNegativePriority) { ImageGeneratorRegistry registry; registry.AddFactory( - [](sk_sp buffer) { + [](const sk_sp& buffer) { return std::make_unique(1337); }, -1); @@ -115,7 +115,7 @@ TEST_F(ShellTest, DefaultGeneratorsTakePrecedentOverZeroPriority) { ImageGeneratorRegistry registry; registry.AddFactory( - [](sk_sp buffer) { + [](const sk_sp& buffer) { return std::make_unique(1337); }, 0); @@ -132,12 +132,12 @@ TEST_F(ShellTest, ImageGeneratorsWithSamePriorityCascadeChronologically) { // Add 2 factories with the same high priority. registry.AddFactory( - [](sk_sp buffer) { + [](const sk_sp& buffer) { return std::make_unique(1337); }, 5); registry.AddFactory( - [](sk_sp buffer) { + [](const sk_sp& buffer) { return std::make_unique(7777); }, 5); diff --git a/lib/ui/painting/multi_frame_codec.cc b/lib/ui/painting/multi_frame_codec.cc index 0e949df080669..986c2f5e6721f 100644 --- a/lib/ui/painting/multi_frame_codec.cc +++ b/lib/ui/painting/multi_frame_codec.cc @@ -4,6 +4,8 @@ #include "flutter/lib/ui/painting/multi_frame_codec.h" +#include + #include "flutter/fml/make_copyable.h" #include "flutter/lib/ui/painting/image.h" #include "third_party/dart/runtime/include/dart_api.h" @@ -27,7 +29,7 @@ MultiFrameCodec::State::State(std::shared_ptr generator) nextFrameIndex_(0) {} static void InvokeNextFrameCallback( - fml::RefPtr image, + const fml::RefPtr& image, int duration, std::unique_ptr callback, size_t trace_id) { @@ -151,7 +153,7 @@ sk_sp MultiFrameCodec::State::GetNextFrameImage( void MultiFrameCodec::State::GetNextFrameAndInvokeCallback( std::unique_ptr callback, - fml::RefPtr ui_task_runner, + const fml::RefPtr& ui_task_runner, fml::WeakPtr resourceContext, fml::RefPtr unref_queue, const std::shared_ptr& gpu_disable_sync_switch, @@ -159,7 +161,7 @@ void MultiFrameCodec::State::GetNextFrameAndInvokeCallback( fml::RefPtr image = nullptr; int duration = 0; sk_sp skImage = - GetNextFrameImage(resourceContext, gpu_disable_sync_switch); + GetNextFrameImage(std::move(resourceContext), gpu_disable_sync_switch); if (skImage) { image = CanvasImage::Create(); image->set_image(DlImageGPU::Make({skImage, std::move(unref_queue)})); @@ -174,8 +176,7 @@ void MultiFrameCodec::State::GetNextFrameAndInvokeCallback( ui_task_runner->PostTask(fml::MakeCopyable([callback = std::move(callback), image = std::move(image), duration, trace_id]() mutable { - InvokeNextFrameCallback(std::move(image), duration, std::move(callback), - trace_id); + InvokeNextFrameCallback(image, duration, std::move(callback), trace_id); })); } @@ -215,7 +216,7 @@ Dart_Handle MultiFrameCodec::getNextFrame(Dart_Handle callback_handle) { return; } state->GetNextFrameAndInvokeCallback( - std::move(callback), std::move(ui_task_runner), + std::move(callback), ui_task_runner, io_manager->GetResourceContext(), io_manager->GetSkiaUnrefQueue(), io_manager->GetIsGpuDisabledSyncSwitch(), trace_id); })); diff --git a/lib/ui/painting/multi_frame_codec.h b/lib/ui/painting/multi_frame_codec.h index ba394bb69a9bb..3ccf8c7699ffc 100644 --- a/lib/ui/painting/multi_frame_codec.h +++ b/lib/ui/painting/multi_frame_codec.h @@ -61,7 +61,7 @@ class MultiFrameCodec : public Codec { void GetNextFrameAndInvokeCallback( std::unique_ptr callback, - fml::RefPtr ui_task_runner, + const fml::RefPtr& ui_task_runner, fml::WeakPtr resourceContext, fml::RefPtr unref_queue, const std::shared_ptr& gpu_disable_sync_switch, diff --git a/lib/ui/painting/path_unittests.cc b/lib/ui/painting/path_unittests.cc index e1287799b3220..f02b72ff5a511 100644 --- a/lib/ui/painting/path_unittests.cc +++ b/lib/ui/painting/path_unittests.cc @@ -62,7 +62,7 @@ TEST_F(ShellTest, PathVolatilityOldPathsBecomeNonVolatile) { message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, PathVolatilityGCRemovesPathFromTracker) { @@ -120,7 +120,7 @@ TEST_F(ShellTest, PathVolatilityGCRemovesPathFromTracker) { message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } // Screen diffing tests use deterministic rendering. Allowing a path to be @@ -176,7 +176,7 @@ TEST_F(ShellTest, DeterministicRenderingDisablesPathVolatility) { message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } } // namespace testing diff --git a/lib/ui/painting/picture.cc b/lib/ui/painting/picture.cc index 49622ce7d2a5a..32ad74fabe372 100644 --- a/lib/ui/painting/picture.cc +++ b/lib/ui/painting/picture.cc @@ -5,6 +5,7 @@ #include "flutter/lib/ui/painting/picture.h" #include +#include #include "flutter/fml/make_copyable.h" #include "flutter/lib/ui/painting/canvas.h" @@ -76,7 +77,7 @@ static sk_sp CreateDeferredImage( width, height, kRGBA_8888_SkColorType, kPremul_SkAlphaType); return DlDeferredImageGPUSkia::Make( image_info, std::move(display_list), std::move(snapshot_delegate), - std::move(raster_task_runner), std::move(unref_queue)); + raster_task_runner, std::move(unref_queue)); } // static @@ -94,7 +95,7 @@ void Picture::RasterizeToImageSync(sk_sp display_list, auto image = CanvasImage::Create(); auto dl_image = CreateDeferredImage( - dart_state->IsImpellerEnabled(), display_list, width, height, + dart_state->IsImpellerEnabled(), std::move(display_list), width, height, std::move(snapshot_delegate), std::move(raster_task_runner), std::move(unref_queue)); image->set_image(dl_image); @@ -114,7 +115,7 @@ size_t Picture::GetAllocationSize() const { } } -Dart_Handle Picture::RasterizeToImage(sk_sp display_list, +Dart_Handle Picture::RasterizeToImage(const sk_sp& display_list, uint32_t width, uint32_t height, Dart_Handle raw_image_callback) { @@ -131,7 +132,7 @@ Dart_Handle Picture::RasterizeLayerTreeToImage( raw_image_callback); } -Dart_Handle Picture::RasterizeToImage(sk_sp display_list, +Dart_Handle Picture::RasterizeToImage(const sk_sp& display_list, std::shared_ptr layer_tree, uint32_t width, uint32_t height, @@ -183,7 +184,7 @@ Dart_Handle Picture::RasterizeToImage(sk_sp display_list, auto dart_image = CanvasImage::Create(); dart_image->set_image(image); - auto* raw_dart_image = tonic::ToDart(std::move(dart_image)); + auto* raw_dart_image = tonic::ToDart(dart_image); // All done! tonic::DartInvoke(image_callback->Get(), {raw_dart_image}); diff --git a/lib/ui/painting/picture.h b/lib/ui/painting/picture.h index 68e1ced710f88..33bee1994f9ec 100644 --- a/lib/ui/painting/picture.h +++ b/lib/ui/painting/picture.h @@ -47,7 +47,7 @@ class Picture : public RefCountedDartWrappable { uint32_t height, Dart_Handle raw_image_handle); - static Dart_Handle RasterizeToImage(sk_sp display_list, + static Dart_Handle RasterizeToImage(const sk_sp& display_list, uint32_t width, uint32_t height, Dart_Handle raw_image_callback); @@ -61,7 +61,7 @@ class Picture : public RefCountedDartWrappable { // Callers may provide either a display list or a layer tree. If a layer tree // is provided, it will be flattened on the raster thread. In this case the // display list will be ignored. - static Dart_Handle RasterizeToImage(sk_sp display_list, + static Dart_Handle RasterizeToImage(const sk_sp& display_list, std::shared_ptr layer_tree, uint32_t width, uint32_t height, diff --git a/lib/ui/painting/single_frame_codec_unittests.cc b/lib/ui/painting/single_frame_codec_unittests.cc index da99755fc3ade..d9a76af262ed5 100644 --- a/lib/ui/painting/single_frame_codec_unittests.cc +++ b/lib/ui/painting/single_frame_codec_unittests.cc @@ -52,7 +52,7 @@ TEST_F(ShellTest, SingleFrameCodecAccuratelyReportsSize) { }); message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } } // namespace testing diff --git a/lib/ui/semantics/semantics_update_builder.cc b/lib/ui/semantics/semantics_update_builder.cc index d91c4ad57fecf..595ecf85f7c67 100644 --- a/lib/ui/semantics/semantics_update_builder.cc +++ b/lib/ui/semantics/semantics_update_builder.cc @@ -4,6 +4,8 @@ #include "flutter/lib/ui/semantics/semantics_update_builder.h" +#include + #include "flutter/lib/ui/ui_dart_state.h" #include "third_party/skia/include/core/SkScalar.h" #include "third_party/tonic/converter/dart_converter.h" @@ -48,15 +50,15 @@ void SemanticsUpdateBuilder::updateNode( double elevation, double thickness, std::string label, - std::vector labelAttributes, + const std::vector& labelAttributes, std::string value, - std::vector valueAttributes, + const std::vector& valueAttributes, std::string increasedValue, - std::vector increasedValueAttributes, + const std::vector& increasedValueAttributes, std::string decreasedValue, - std::vector decreasedValueAttributes, + const std::vector& decreasedValueAttributes, std::string hint, - std::vector hintAttributes, + const std::vector& hintAttributes, std::string tooltip, int textDirection, const tonic::Float64List& transform, @@ -86,17 +88,17 @@ void SemanticsUpdateBuilder::updateNode( node.rect = SkRect::MakeLTRB(left, top, right, bottom); node.elevation = elevation; node.thickness = thickness; - node.label = label; + node.label = std::move(label); pushStringAttributes(node.labelAttributes, labelAttributes); - node.value = value; + node.value = std::move(value); pushStringAttributes(node.valueAttributes, valueAttributes); - node.increasedValue = increasedValue; + node.increasedValue = std::move(increasedValue); pushStringAttributes(node.increasedValueAttributes, increasedValueAttributes); - node.decreasedValue = decreasedValue; + node.decreasedValue = std::move(decreasedValue); pushStringAttributes(node.decreasedValueAttributes, decreasedValueAttributes); - node.hint = hint; + node.hint = std::move(hint); pushStringAttributes(node.hintAttributes, hintAttributes); - node.tooltip = tooltip; + node.tooltip = std::move(tooltip); node.textDirection = textDirection; SkScalar scalarTransform[16]; for (int i = 0; i < 16; ++i) { @@ -123,8 +125,8 @@ void SemanticsUpdateBuilder::updateCustomAction(int id, CustomAccessibilityAction action; action.id = id; action.overrideId = overrideId; - action.label = label; - action.hint = hint; + action.label = std::move(label); + action.hint = std::move(hint); actions_[id] = action; } diff --git a/lib/ui/semantics/semantics_update_builder.h b/lib/ui/semantics/semantics_update_builder.h index b69a735140562..37d45d9f746be 100644 --- a/lib/ui/semantics/semantics_update_builder.h +++ b/lib/ui/semantics/semantics_update_builder.h @@ -29,41 +29,42 @@ class SemanticsUpdateBuilder ~SemanticsUpdateBuilder() override; - void updateNode(int id, - int flags, - int actions, - int maxValueLength, - int currentValueLength, - int textSelectionBase, - int textSelectionExtent, - int platformViewId, - int scrollChildren, - int scrollIndex, - double scrollPosition, - double scrollExtentMax, - double scrollExtentMin, - double left, - double top, - double right, - double bottom, - double elevation, - double thickness, - std::string label, - std::vector labelAttributes, - std::string value, - std::vector valueAttributes, - std::string increasedValue, - std::vector increasedValueAttributes, - std::string decreasedValue, - std::vector decreasedValueAttributes, - std::string hint, - std::vector hintAttributes, - std::string tooltip, - int textDirection, - const tonic::Float64List& transform, - const tonic::Int32List& childrenInTraversalOrder, - const tonic::Int32List& childrenInHitTestOrder, - const tonic::Int32List& customAccessibilityActions); + void updateNode( + int id, + int flags, + int actions, + int maxValueLength, + int currentValueLength, + int textSelectionBase, + int textSelectionExtent, + int platformViewId, + int scrollChildren, + int scrollIndex, + double scrollPosition, + double scrollExtentMax, + double scrollExtentMin, + double left, + double top, + double right, + double bottom, + double elevation, + double thickness, + std::string label, + const std::vector& labelAttributes, + std::string value, + const std::vector& valueAttributes, + std::string increasedValue, + const std::vector& increasedValueAttributes, + std::string decreasedValue, + const std::vector& decreasedValueAttributes, + std::string hint, + const std::vector& hintAttributes, + std::string tooltip, + int textDirection, + const tonic::Float64List& transform, + const tonic::Int32List& childrenInTraversalOrder, + const tonic::Int32List& childrenInHitTestOrder, + const tonic::Int32List& customAccessibilityActions); void updateCustomAction(int id, std::string label, diff --git a/lib/ui/semantics/semantics_update_builder_unittests.cc b/lib/ui/semantics/semantics_update_builder_unittests.cc index 50b1d1d60db1c..004d7f8f78296 100644 --- a/lib/ui/semantics/semantics_update_builder_unittests.cc +++ b/lib/ui/semantics/semantics_update_builder_unittests.cc @@ -85,7 +85,7 @@ TEST_F(SemanticsUpdateBuilderTest, CanHandleAttributedStrings) { }); message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } } // namespace testing diff --git a/lib/ui/semantics/string_attribute.cc b/lib/ui/semantics/string_attribute.cc index 3434f6888aa99..2f11711c0b71a 100644 --- a/lib/ui/semantics/string_attribute.cc +++ b/lib/ui/semantics/string_attribute.cc @@ -10,6 +10,7 @@ #include "third_party/tonic/dart_binding_macros.h" #include +#include namespace flutter { @@ -47,7 +48,7 @@ void NativeStringAttribute::initLocaleStringAttribute( locale_attribute->start = start; locale_attribute->end = end; locale_attribute->type = StringAttributeType::kLocale; - locale_attribute->locale = locale; + locale_attribute->locale = std::move(locale); native_string_attribute->attribute_ = locale_attribute; } diff --git a/lib/ui/text/asset_manager_font_provider.cc b/lib/ui/text/asset_manager_font_provider.cc index b07472f7e7292..fe3d258cfd041 100644 --- a/lib/ui/text/asset_manager_font_provider.cc +++ b/lib/ui/text/asset_manager_font_provider.cc @@ -4,6 +4,8 @@ #include "flutter/lib/ui/text/asset_manager_font_provider.h" +#include + #include "flutter/fml/logging.h" #include "third_party/skia/include/core/SkData.h" #include "third_party/skia/include/core/SkStream.h" @@ -22,7 +24,7 @@ void MappingReleaseProc(const void* ptr, void* context) { AssetManagerFontProvider::AssetManagerFontProvider( std::shared_ptr asset_manager) - : asset_manager_(asset_manager) {} + : asset_manager_(std::move(asset_manager)) {} AssetManagerFontProvider::~AssetManagerFontProvider() = default; @@ -48,8 +50,8 @@ SkFontStyleSet* AssetManagerFontProvider::MatchFamily( return font_style_set.release(); } -void AssetManagerFontProvider::RegisterAsset(std::string family_name, - std::string asset) { +void AssetManagerFontProvider::RegisterAsset(const std::string& family_name, + const std::string& asset) { std::string canonical_name = CanonicalFamilyName(family_name); auto family_it = registered_families_.find(canonical_name); @@ -67,11 +69,12 @@ void AssetManagerFontProvider::RegisterAsset(std::string family_name, AssetManagerFontStyleSet::AssetManagerFontStyleSet( std::shared_ptr asset_manager, std::string family_name) - : asset_manager_(asset_manager), family_name_(family_name) {} + : asset_manager_(std::move(asset_manager)), + family_name_(std::move(family_name)) {} AssetManagerFontStyleSet::~AssetManagerFontStyleSet() = default; -void AssetManagerFontStyleSet::registerAsset(std::string asset) { +void AssetManagerFontStyleSet::registerAsset(const std::string& asset) { assets_.emplace_back(asset); } diff --git a/lib/ui/text/asset_manager_font_provider.h b/lib/ui/text/asset_manager_font_provider.h index 5ffbf897cdbfd..ba78ad2ecd45a 100644 --- a/lib/ui/text/asset_manager_font_provider.h +++ b/lib/ui/text/asset_manager_font_provider.h @@ -25,7 +25,7 @@ class AssetManagerFontStyleSet : public SkFontStyleSet { ~AssetManagerFontStyleSet() override; - void registerAsset(std::string asset); + void registerAsset(const std::string& asset); // |SkFontStyleSet| int count() override; @@ -65,7 +65,7 @@ class AssetManagerFontProvider : public txt::FontAssetProvider { ~AssetManagerFontProvider() override; - void RegisterAsset(std::string family_name, std::string asset); + void RegisterAsset(const std::string& family_name, const std::string& asset); // |FontAssetProvider| size_t GetFamilyCount() const override; diff --git a/lib/ui/text/font_collection.cc b/lib/ui/text/font_collection.cc index 3a5327b6fec03..afc39b007aca3 100644 --- a/lib/ui/text/font_collection.cc +++ b/lib/ui/text/font_collection.cc @@ -62,7 +62,7 @@ void FontCollection::SetupDefaultFontManager( // // Structure described in https://docs.flutter.dev/cookbook/design/fonts void FontCollection::RegisterFonts( - std::shared_ptr asset_manager) { + const std::shared_ptr& asset_manager) { std::unique_ptr manifest_mapping = asset_manager->GetAsMapping("FontManifest.json"); if (manifest_mapping == nullptr) { @@ -145,7 +145,7 @@ void FontCollection::RegisterTestFonts() { void FontCollection::LoadFontFromList(Dart_Handle font_data_handle, Dart_Handle callback, - std::string family_name) { + const std::string& family_name) { tonic::Uint8List font_data(font_data_handle); UIDartState::ThrowIfUIOperationsProhibited(); FontCollection& font_collection = UIDartState::Current() diff --git a/lib/ui/text/font_collection.h b/lib/ui/text/font_collection.h index c13f6c65f90ca..9c8d41f3ba773 100644 --- a/lib/ui/text/font_collection.h +++ b/lib/ui/text/font_collection.h @@ -26,13 +26,13 @@ class FontCollection { void SetupDefaultFontManager(uint32_t font_initialization_data); - void RegisterFonts(std::shared_ptr asset_manager); + void RegisterFonts(const std::shared_ptr& asset_manager); void RegisterTestFonts(); static void LoadFontFromList(Dart_Handle font_data_handle, Dart_Handle callback, - std::string family_name); + const std::string& family_name); private: std::shared_ptr collection_; diff --git a/lib/ui/text/paragraph_builder.cc b/lib/ui/text/paragraph_builder.cc index 990c2957e95ed..03daf9358452c 100644 --- a/lib/ui/text/paragraph_builder.cc +++ b/lib/ui/text/paragraph_builder.cc @@ -239,11 +239,13 @@ ParagraphBuilder::ParagraphBuilder( mask = encoded[0]; if (mask & kPSTextAlignMask) { - style.text_align = txt::TextAlign(encoded[kPSTextAlignIndex]); + style.text_align = + static_cast(encoded[kPSTextAlignIndex]); } if (mask & kPSTextDirectionMask) { - style.text_direction = txt::TextDirection(encoded[kPSTextDirectionIndex]); + style.text_direction = + static_cast(encoded[kPSTextDirectionIndex]); } if (mask & kPSFontWeightMask) { diff --git a/lib/ui/ui_dart_state.cc b/lib/ui/ui_dart_state.cc index 133ea55395203..d67b540a045dc 100644 --- a/lib/ui/ui_dart_state.cc +++ b/lib/ui/ui_dart_state.cc @@ -5,6 +5,7 @@ #include "flutter/lib/ui/ui_dart_state.h" #include +#include #include "flutter/fml/message_loop.h" #include "flutter/lib/ui/window/platform_configuration.h" @@ -39,14 +40,14 @@ UIDartState::Context::Context( std::shared_ptr volatile_path_tracker, bool enable_impeller) : task_runners(task_runners), - snapshot_delegate(snapshot_delegate), - io_manager(io_manager), - unref_queue(unref_queue), - image_decoder(image_decoder), - image_generator_registry(image_generator_registry), - advisory_script_uri(advisory_script_uri), - advisory_script_entrypoint(advisory_script_entrypoint), - volatile_path_tracker(volatile_path_tracker), + snapshot_delegate(std::move(snapshot_delegate)), + io_manager(std::move(io_manager)), + unref_queue(std::move(unref_queue)), + image_decoder(std::move(image_decoder)), + image_generator_registry(std::move(image_generator_registry)), + advisory_script_uri(std::move(advisory_script_uri)), + advisory_script_entrypoint(std::move(advisory_script_entrypoint)), + volatile_path_tracker(std::move(volatile_path_tracker)), enable_impeller(enable_impeller) {} UIDartState::UIDartState( @@ -63,11 +64,11 @@ UIDartState::UIDartState( remove_callback_(std::move(remove_callback)), logger_prefix_(std::move(logger_prefix)), is_root_isolate_(is_root_isolate), - unhandled_exception_callback_(unhandled_exception_callback), - log_message_callback_(log_message_callback), + unhandled_exception_callback_(std::move(unhandled_exception_callback)), + log_message_callback_(std::move(log_message_callback)), isolate_name_server_(std::move(isolate_name_server)), enable_skparagraph_(enable_skparagraph), - context_(std::move(context)) { + context_(context) { AddOrRemoveTaskObserver(true /* add */); } @@ -99,7 +100,7 @@ void UIDartState::ThrowIfUIOperationsProhibited() { } } -void UIDartState::SetDebugName(const std::string debug_name) { +void UIDartState::SetDebugName(const std::string& debug_name) { debug_name_ = debug_name; if (platform_configuration_) { platform_configuration_->client()->UpdateIsolateDescription(debug_name_, @@ -124,7 +125,7 @@ void UIDartState::SetPlatformConfiguration( void UIDartState::SetPlatformMessageHandler( std::weak_ptr handler) { FML_DCHECK(!IsRootIsolate()); - platform_message_handler_ = handler; + platform_message_handler_ = std::move(handler); } const TaskRunners& UIDartState::GetTaskRunners() const { diff --git a/lib/ui/ui_dart_state.h b/lib/ui/ui_dart_state.h index e0deb57cbd5ae..2103cda24f451 100644 --- a/lib/ui/ui_dart_state.h +++ b/lib/ui/ui_dart_state.h @@ -102,7 +102,7 @@ class UIDartState : public tonic::DartState { bool IsRootIsolate() const { return is_root_isolate_; } static void ThrowIfUIOperationsProhibited(); - void SetDebugName(const std::string name); + void SetDebugName(const std::string& name); const std::string& debug_name() const { return debug_name_; } diff --git a/lib/ui/volatile_path_tracker.cc b/lib/ui/volatile_path_tracker.cc index 073395b4d7417..ce2556ad6610e 100644 --- a/lib/ui/volatile_path_tracker.cc +++ b/lib/ui/volatile_path_tracker.cc @@ -4,14 +4,16 @@ #include "flutter/lib/ui/volatile_path_tracker.h" +#include + namespace flutter { VolatilePathTracker::VolatilePathTracker( fml::RefPtr ui_task_runner, bool enabled) - : ui_task_runner_(ui_task_runner), enabled_(enabled) {} + : ui_task_runner_(std::move(ui_task_runner)), enabled_(enabled) {} -void VolatilePathTracker::Track(std::shared_ptr path) { +void VolatilePathTracker::Track(const std::shared_ptr& path) { FML_DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); FML_DCHECK(path); FML_DCHECK(path->path.isVolatile()); @@ -29,7 +31,7 @@ void VolatilePathTracker::OnFrame() { } paths_.erase(std::remove_if(paths_.begin(), paths_.end(), - [](std::weak_ptr weak_path) { + [](const std::weak_ptr& weak_path) { auto path = weak_path.lock(); if (!path) { return true; diff --git a/lib/ui/volatile_path_tracker.h b/lib/ui/volatile_path_tracker.h index 32636dc76dd97..1506239c31ac0 100644 --- a/lib/ui/volatile_path_tracker.h +++ b/lib/ui/volatile_path_tracker.h @@ -51,7 +51,7 @@ class VolatilePathTracker { // Must be called from the UI task runner. // // Callers should only insert paths that are currently volatile. - void Track(std::shared_ptr path); + void Track(const std::shared_ptr& path); // Called by the shell at the end of a frame after notifying Dart about idle // time. diff --git a/lib/ui/window/platform_configuration.cc b/lib/ui/window/platform_configuration.cc index 0b61621ea9c17..940e6a968c872 100644 --- a/lib/ui/window/platform_configuration.cc +++ b/lib/ui/window/platform_configuration.cc @@ -368,7 +368,7 @@ void PlatformConfigurationNativeApi::RespondToPlatformMessage( } void PlatformConfigurationNativeApi::SetIsolateDebugName( - const std::string name) { + const std::string& name) { UIDartState::ThrowIfUIOperationsProhibited(); UIDartState::Current()->SetDebugName(name); } diff --git a/lib/ui/window/platform_configuration.h b/lib/ui/window/platform_configuration.h index d482c756984d3..268bbdc4a017b 100644 --- a/lib/ui/window/platform_configuration.h +++ b/lib/ui/window/platform_configuration.h @@ -484,7 +484,7 @@ class PlatformConfigurationNativeApi { static Dart_Handle ComputePlatformResolvedLocale( Dart_Handle supportedLocalesHandle); - static void SetIsolateDebugName(const std::string name); + static void SetIsolateDebugName(const std::string& name); static Dart_Handle SendPlatformMessage(const std::string& name, Dart_Handle callback, diff --git a/lib/ui/window/platform_configuration_unittests.cc b/lib/ui/window/platform_configuration_unittests.cc index 66f3f6628b389..9b971947f5e84 100644 --- a/lib/ui/window/platform_configuration_unittests.cc +++ b/lib/ui/window/platform_configuration_unittests.cc @@ -60,7 +60,7 @@ TEST_F(ShellTest, PlatformConfigurationInitialization) { }); message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, PlatformConfigurationWindowMetricsUpdate) { @@ -110,7 +110,7 @@ TEST_F(ShellTest, PlatformConfigurationWindowMetricsUpdate) { }); message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, PlatformConfigurationOnErrorHandlesError) { @@ -156,7 +156,7 @@ TEST_F(ShellTest, PlatformConfigurationOnErrorHandlesError) { message_latch->Wait(); ASSERT_FALSE(did_throw); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, PlatformConfigurationOnErrorDoesNotHandleError) { @@ -175,8 +175,8 @@ TEST_F(ShellTest, PlatformConfigurationOnErrorDoesNotHandleError) { [&ex, &st, &throw_count](const std::string& exception, const std::string& stack_trace) -> bool { throw_count += 1; - ex = std::move(exception); - st = std::move(stack_trace); + ex = exception; + st = stack_trace; return true; }; @@ -208,7 +208,7 @@ TEST_F(ShellTest, PlatformConfigurationOnErrorDoesNotHandleError) { ASSERT_EQ(throw_count, 1ul); ASSERT_EQ(ex, "Exception: false") << ex; ASSERT_EQ(st.rfind("#0 customOnErrorFalse", 0), 0ul) << st; - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, PlatformConfigurationOnErrorThrows) { @@ -226,8 +226,8 @@ TEST_F(ShellTest, PlatformConfigurationOnErrorThrows) { [&errors, &throw_count](const std::string& exception, const std::string& stack_trace) -> bool { throw_count += 1; - errors.push_back(std::move(exception)); - errors.push_back(std::move(stack_trace)); + errors.push_back(exception); + errors.push_back(stack_trace); return true; }; @@ -263,7 +263,7 @@ TEST_F(ShellTest, PlatformConfigurationOnErrorThrows) { ASSERT_EQ(errors[2], "Exception: throw1") << errors[2]; ASSERT_EQ(errors[3].rfind("#0 customOnErrorThrow"), 0ul) << errors[3]; - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, PlatformConfigurationSetDartPerformanceMode) { @@ -297,7 +297,7 @@ TEST_F(ShellTest, PlatformConfigurationSetDartPerformanceMode) { }); message_latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } } // namespace testing diff --git a/lib/ui/window/viewport_metrics.cc b/lib/ui/window/viewport_metrics.cc index 82867c2e6c917..1d61a6fc552a3 100644 --- a/lib/ui/window/viewport_metrics.cc +++ b/lib/ui/window/viewport_metrics.cc @@ -36,9 +36,9 @@ ViewportMetrics::ViewportMetrics( double p_physical_system_gesture_inset_bottom, double p_physical_system_gesture_inset_left, double p_physical_touch_slop, - const std::vector p_physical_display_features_bounds, - const std::vector p_physical_display_features_type, - const std::vector p_physical_display_features_state) + const std::vector& p_physical_display_features_bounds, + const std::vector& p_physical_display_features_type, + const std::vector& p_physical_display_features_state) : device_pixel_ratio(p_device_pixel_ratio), physical_width(p_physical_width), physical_height(p_physical_height), diff --git a/lib/ui/window/viewport_metrics.h b/lib/ui/window/viewport_metrics.h index 1dab8927afb38..414a8b132d56d 100644 --- a/lib/ui/window/viewport_metrics.h +++ b/lib/ui/window/viewport_metrics.h @@ -32,9 +32,9 @@ struct ViewportMetrics { double p_physical_system_gesture_inset_bottom, double p_physical_system_gesture_inset_left, double p_physical_touch_slop, - const std::vector p_physical_display_features_bounds, - const std::vector p_physical_display_features_type, - const std::vector p_physical_display_features_state); + const std::vector& p_physical_display_features_bounds, + const std::vector& p_physical_display_features_type, + const std::vector& p_physical_display_features_state); double device_pixel_ratio = 1.0; double physical_width = 0; diff --git a/lib/ui/window/window.cc b/lib/ui/window/window.cc index 454608c251e92..b269e97f7bf87 100644 --- a/lib/ui/window/window.cc +++ b/lib/ui/window/window.cc @@ -4,6 +4,8 @@ #include "flutter/lib/ui/window/window.h" +#include + #include "third_party/tonic/converter/dart_converter.h" #include "third_party/tonic/dart_args.h" #include "third_party/tonic/logging/dart_invoke.h" @@ -12,7 +14,7 @@ namespace flutter { Window::Window(int64_t window_id, ViewportMetrics metrics) - : window_id_(window_id), viewport_metrics_(metrics) { + : window_id_(window_id), viewport_metrics_(std::move(metrics)) { library_.Set(tonic::DartState::Current(), Dart_LookupLibrary(tonic::ToDart("dart:ui"))); } diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index e12059d229e95..0f819ef9981c1 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -6,6 +6,7 @@ #include #include +#include #include "flutter/fml/logging.h" #include "flutter/fml/posix_wrappers.h" @@ -85,10 +86,10 @@ Dart_IsolateFlags DartIsolate::Flags::Get() const { std::weak_ptr DartIsolate::CreateRunningRootIsolate( const Settings& settings, - fml::RefPtr isolate_snapshot, + const fml::RefPtr& isolate_snapshot, std::unique_ptr platform_configuration, Flags isolate_flags, - fml::closure root_isolate_create_callback, + const fml::closure& root_isolate_create_callback, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, std::optional dart_entrypoint, @@ -161,8 +162,8 @@ std::weak_ptr DartIsolate::CreateRunningRootIsolate( root_isolate_create_callback(); } - if (!isolate->RunFromLibrary(dart_entrypoint_library, // - dart_entrypoint, // + if (!isolate->RunFromLibrary(std::move(dart_entrypoint_library), // + std::move(dart_entrypoint), // dart_entrypoint_args)) { FML_LOG(ERROR) << "Could not run the run main Dart entrypoint."; return {}; @@ -188,7 +189,7 @@ std::weak_ptr DartIsolate::CreateRootIsolate( const Settings& settings, fml::RefPtr isolate_snapshot, std::unique_ptr platform_configuration, - Flags flags, + const Flags& flags, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, const UIDartState::Context& context, @@ -210,11 +211,10 @@ std::weak_ptr DartIsolate::CreateRootIsolate( ))); auto isolate_data = std::make_unique>( - std::shared_ptr(new DartIsolate( - settings, // settings - true, // is_root_isolate - std::move(context) // context - ))); + std::shared_ptr(new DartIsolate(settings, // settings + true, // is_root_isolate + context // context + ))); DartErrorString error; Dart_Isolate vm_isolate = nullptr; @@ -285,7 +285,7 @@ DartIsolate::DartIsolate(const Settings& settings, DartVMRef::GetIsolateNameServer(), is_root_isolate, settings.enable_skparagraph, - std::move(context)), + context), may_insecurely_connect_to_all_domains_( settings.may_insecurely_connect_to_all_domains), domain_network_policy_(settings.domain_network_policy) { @@ -376,7 +376,7 @@ bool DartIsolate::LoadLoadingUnit( } void DartIsolate::LoadLoadingUnitError(intptr_t loading_unit_id, - const std::string error_message, + const std::string& error_message, bool transient) { tonic::DartState::Scope scope(this); Dart_Handle result = Dart_DeferredLoadCompleteError( @@ -385,7 +385,7 @@ void DartIsolate::LoadLoadingUnitError(intptr_t loading_unit_id, } void DartIsolate::SetMessageHandlingTaskRunner( - fml::RefPtr runner) { + const fml::RefPtr& runner) { if (!IsRootIsolate() || !runner) { return; } @@ -509,7 +509,7 @@ bool DartIsolate::PrepareForRunningFromPrecompiledCode() { return true; } -bool DartIsolate::LoadKernel(std::shared_ptr mapping, +bool DartIsolate::LoadKernel(const std::shared_ptr& mapping, bool last_piece) { if (!Dart_IsKernel(mapping->GetMapping(), mapping->GetSize())) { return false; @@ -537,7 +537,7 @@ bool DartIsolate::LoadKernel(std::shared_ptr mapping, } [[nodiscard]] bool DartIsolate::PrepareForRunningFromKernel( - std::shared_ptr mapping, + const std::shared_ptr& mapping, bool child_isolate, bool last_piece) { TRACE_EVENT0("flutter", "DartIsolate::PrepareForRunningFromKernel"); @@ -998,7 +998,7 @@ Dart_Isolate DartIsolate::CreateDartIsolateGroup( isolate_data.release(); // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) - success = InitializeIsolate(std::move(embedder_isolate), isolate, error); + success = InitializeIsolate(embedder_isolate, isolate, error); } if (!success) { Dart_ShutdownIsolate(); @@ -1011,7 +1011,7 @@ Dart_Isolate DartIsolate::CreateDartIsolateGroup( } bool DartIsolate::InitializeIsolate( - std::shared_ptr embedder_isolate, + const std::shared_ptr& embedder_isolate, Dart_Isolate isolate, char** error) { TRACE_EVENT0("flutter", "DartIsolate::InitializeIsolate"); diff --git a/runtime/dart_isolate.h b/runtime/dart_isolate.h index c51eb7081ab37..16efd22c3a729 100644 --- a/runtime/dart_isolate.h +++ b/runtime/dart_isolate.h @@ -208,10 +208,10 @@ class DartIsolate : public UIDartState { /// static std::weak_ptr CreateRunningRootIsolate( const Settings& settings, - fml::RefPtr isolate_snapshot, + const fml::RefPtr& isolate_snapshot, std::unique_ptr platform_configuration, Flags flags, - fml::closure root_isolate_create_callback, + const fml::closure& root_isolate_create_callback, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, std::optional dart_entrypoint, @@ -283,7 +283,7 @@ class DartIsolate : public UIDartState { /// prepare the isolate. /// [[nodiscard]] bool PrepareForRunningFromKernel( - std::shared_ptr kernel, + const std::shared_ptr& kernel, bool child_isolate, bool last_piece); @@ -382,7 +382,7 @@ class DartIsolate : public UIDartState { std::unique_ptr snapshot_instructions); void LoadLoadingUnitError(intptr_t loading_unit_id, - const std::string error_message, + const std::string& error_message, bool transient); DartIsolateGroupData& GetIsolateGroupData(); @@ -415,7 +415,7 @@ class DartIsolate : public UIDartState { const Settings& settings, fml::RefPtr isolate_snapshot, std::unique_ptr platform_configuration, - Flags flags, + const Flags& flags, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, const UIDartState::Context& context, @@ -436,9 +436,10 @@ class DartIsolate : public UIDartState { /// [[nodiscard]] bool Initialize(Dart_Isolate dart_isolate); - void SetMessageHandlingTaskRunner(fml::RefPtr runner); + void SetMessageHandlingTaskRunner(const fml::RefPtr& runner); - bool LoadKernel(std::shared_ptr mapping, bool last_piece); + bool LoadKernel(const std::shared_ptr& mapping, + bool last_piece); [[nodiscard]] bool LoadLibraries(); @@ -481,9 +482,10 @@ class DartIsolate : public UIDartState { char** error, const IsolateMaker& make_isolate); - static bool InitializeIsolate(std::shared_ptr embedder_isolate, - Dart_Isolate isolate, - char** error); + static bool InitializeIsolate( + const std::shared_ptr& embedder_isolate, + Dart_Isolate isolate, + char** error); // |Dart_IsolateShutdownCallback| static void DartIsolateShutdownCallback( diff --git a/runtime/dart_isolate_group_data.cc b/runtime/dart_isolate_group_data.cc index 3aeff009b855e..131f887715bfe 100644 --- a/runtime/dart_isolate_group_data.cc +++ b/runtime/dart_isolate_group_data.cc @@ -4,6 +4,8 @@ #include "flutter/runtime/dart_isolate_group_data.h" +#include + #include "flutter/runtime/dart_snapshot.h" namespace flutter { @@ -17,9 +19,9 @@ DartIsolateGroupData::DartIsolateGroupData( const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback) : settings_(settings), - isolate_snapshot_(isolate_snapshot), - advisory_script_uri_(advisory_script_uri), - advisory_script_entrypoint_(advisory_script_entrypoint), + isolate_snapshot_(std::move(isolate_snapshot)), + advisory_script_uri_(std::move(advisory_script_uri)), + advisory_script_entrypoint_(std::move(advisory_script_entrypoint)), child_isolate_preparer_(child_isolate_preparer), isolate_create_callback_(isolate_create_callback), isolate_shutdown_callback_(isolate_shutdown_callback) { diff --git a/runtime/dart_isolate_unittests.cc b/runtime/dart_isolate_unittests.cc index 0bb56a542b363..e5f43fd56616a 100644 --- a/runtime/dart_isolate_unittests.cc +++ b/runtime/dart_isolate_unittests.cc @@ -54,7 +54,7 @@ TEST_F(DartIsolateTest, RootIsolateCreationAndShutdown) { auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); - UIDartState::Context context(std::move(task_runners)); + UIDartState::Context context(task_runners); context.advisory_script_uri = "main.dart"; context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( @@ -69,7 +69,7 @@ TEST_F(DartIsolateTest, RootIsolateCreationAndShutdown) { std::nullopt, // dart entrypoint library {}, // dart entrypoint arguments std::move(isolate_configuration), // isolate configuration - std::move(context) // engine context + context // engine context ); auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); @@ -93,7 +93,7 @@ TEST_F(DartIsolateTest, IsolateShutdownCallbackIsInIsolateScope) { auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); - UIDartState::Context context(std::move(task_runners)); + UIDartState::Context context(task_runners); context.advisory_script_uri = "main.dart"; context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( @@ -108,7 +108,7 @@ TEST_F(DartIsolateTest, IsolateShutdownCallbackIsInIsolateScope) { std::nullopt, // dart entrypoint library {}, // dart entrypoint arguments std::move(isolate_configuration), // isolate configuration - std::move(context) // engine context + context // engine context ); auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); @@ -425,7 +425,7 @@ TEST_F(DartIsolateTest, CanCreateServiceIsolate) { auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); - UIDartState::Context context(std::move(task_runners)); + UIDartState::Context context(task_runners); context.advisory_script_uri = "main.dart"; context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( @@ -440,7 +440,7 @@ TEST_F(DartIsolateTest, CanCreateServiceIsolate) { std::nullopt, // dart entrypoint library {}, // dart entrypoint arguments std::move(isolate_configuration), // isolate configuration - std::move(context) // engine context + context // engine context ); auto root_isolate = weak_isolate.lock(); @@ -525,7 +525,7 @@ TEST_F(DartIsolateTest, InvalidLoadingUnitFails) { auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); - UIDartState::Context context(std::move(task_runners)); + UIDartState::Context context(task_runners); context.advisory_script_uri = "main.dart"; context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( @@ -540,7 +540,7 @@ TEST_F(DartIsolateTest, InvalidLoadingUnitFails) { std::nullopt, // dart entrypoint library {}, // dart entrypoint arguments std::move(isolate_configuration), // isolate configuration - std::move(context) // engine context + context // engine context ); auto root_isolate = weak_isolate.lock(); diff --git a/runtime/dart_lifecycle_unittests.cc b/runtime/dart_lifecycle_unittests.cc index 3ae1b06af0e0e..d3162905e3ae6 100644 --- a/runtime/dart_lifecycle_unittests.cc +++ b/runtime/dart_lifecycle_unittests.cc @@ -46,7 +46,7 @@ TEST_F(DartLifecycleTest, CanStartAndShutdownVMOverAndOver) { static std::shared_ptr CreateAndRunRootIsolate( const Settings& settings, const DartVMData& vm, - fml::RefPtr task_runner, + const fml::RefPtr& task_runner, std::string entrypoint) { FML_CHECK(!entrypoint.empty()); TaskRunners runners("io.flutter.test", task_runner, task_runner, task_runner, @@ -71,7 +71,7 @@ static std::shared_ptr CreateAndRunRootIsolate( std::nullopt, // dart entrypoint library {}, // dart entrypoint arguments std::move(isolate_configuration), // isolate configuration - std::move(context) // engine context + context // engine context ) .lock(); diff --git a/runtime/dart_service_isolate.cc b/runtime/dart_service_isolate.cc index e819f6e97c305..18b51a32a6f1a 100644 --- a/runtime/dart_service_isolate.cc +++ b/runtime/dart_service_isolate.cc @@ -126,7 +126,7 @@ void DartServiceIsolate::Shutdown(Dart_NativeArguments args) { // NO-OP. } -bool DartServiceIsolate::Startup(std::string server_ip, +bool DartServiceIsolate::Startup(const std::string& server_ip, intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, diff --git a/runtime/dart_service_isolate.h b/runtime/dart_service_isolate.h index 1649d3e3343ed..754a963d13693 100644 --- a/runtime/dart_service_isolate.h +++ b/runtime/dart_service_isolate.h @@ -59,7 +59,7 @@ class DartServiceIsolate { /// @return If the startup was successful. Refer to the `error` for /// details on failure. /// - static bool Startup(std::string server_ip, + static bool Startup(const std::string& server_ip, intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, diff --git a/runtime/dart_snapshot.cc b/runtime/dart_snapshot.cc index df162ebc83dcd..5943524aa9f80 100644 --- a/runtime/dart_snapshot.cc +++ b/runtime/dart_snapshot.cc @@ -51,7 +51,7 @@ static std::unique_ptr GetFileMapping( // moves to the embedder API, this method can effectively be reduced to just // invoking the embedder_mapping_callback directly. static std::shared_ptr SearchMapping( - MappingCallback embedder_mapping_callback, + const MappingCallback& embedder_mapping_callback, const std::string& file_path, const std::vector& native_library_path, const char* native_library_symbol_name, @@ -203,8 +203,8 @@ fml::RefPtr DartSnapshot::IsolateSnapshotFromSettings( } fml::RefPtr DartSnapshot::IsolateSnapshotFromMappings( - std::shared_ptr snapshot_data, - std::shared_ptr snapshot_instructions) { + const std::shared_ptr& snapshot_data, + const std::shared_ptr& snapshot_instructions) { auto snapshot = fml::MakeRefCounted(snapshot_data, snapshot_instructions); if (snapshot->IsValid()) { diff --git a/runtime/dart_snapshot.h b/runtime/dart_snapshot.h index 47cef0d57ad32..96cd3c764166a 100644 --- a/runtime/dart_snapshot.h +++ b/runtime/dart_snapshot.h @@ -111,8 +111,8 @@ class DartSnapshot : public fml::RefCountedThreadSafe { /// /// @return A valid isolate snapshot or nullptr. static fml::RefPtr IsolateSnapshotFromMappings( - std::shared_ptr snapshot_data, - std::shared_ptr snapshot_instructions); + const std::shared_ptr& snapshot_data, + const std::shared_ptr& snapshot_instructions); //---------------------------------------------------------------------------- /// @brief Create an isolate snapshot specialized for launching the diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index 829e4be21f26f..b8b75719b3e4e 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -255,7 +255,7 @@ static void EmbedderInformationCallback(Dart_EmbedderInformation* info) { } std::shared_ptr DartVM::Create( - Settings settings, + const Settings& settings, fml::RefPtr vm_snapshot, fml::RefPtr isolate_snapshot, std::shared_ptr isolate_name_server) { @@ -271,7 +271,7 @@ std::shared_ptr DartVM::Create( // Note: std::make_shared unviable due to hidden constructor. return std::shared_ptr( - new DartVM(std::move(vm_data), std::move(isolate_name_server))); + new DartVM(vm_data, std::move(isolate_name_server))); } static std::atomic_size_t gVMLaunchCount; @@ -280,13 +280,13 @@ size_t DartVM::GetVMLaunchCount() { return gVMLaunchCount; } -DartVM::DartVM(std::shared_ptr vm_data, +DartVM::DartVM(const std::shared_ptr& vm_data, std::shared_ptr isolate_name_server) : settings_(vm_data->GetSettings()), concurrent_message_loop_(fml::ConcurrentMessageLoop::Create()), skia_concurrent_executor_( [runner = concurrent_message_loop_->GetTaskRunner()]( - fml::closure work) { runner->PostTask(work); }), + const fml::closure& work) { runner->PostTask(work); }), vm_data_(vm_data), isolate_name_server_(std::move(isolate_name_server)), service_protocol_(std::make_shared()) { diff --git a/runtime/dart_vm.h b/runtime/dart_vm.h index 829014c9def0d..4903987a29788 100644 --- a/runtime/dart_vm.h +++ b/runtime/dart_vm.h @@ -172,12 +172,12 @@ class DartVM { friend class DartIsolate; static std::shared_ptr Create( - Settings settings, + const Settings& settings, fml::RefPtr vm_snapshot, fml::RefPtr isolate_snapshot, std::shared_ptr isolate_name_server); - DartVM(std::shared_ptr data, + DartVM(const std::shared_ptr& data, std::shared_ptr isolate_name_server); FML_DISALLOW_COPY_AND_ASSIGN(DartVM); diff --git a/runtime/dart_vm_data.cc b/runtime/dart_vm_data.cc index a47f5d1cc4887..012ad68306864 100644 --- a/runtime/dart_vm_data.cc +++ b/runtime/dart_vm_data.cc @@ -4,10 +4,12 @@ #include "flutter/runtime/dart_vm_data.h" +#include + namespace flutter { std::shared_ptr DartVMData::Create( - Settings settings, + const Settings& settings, fml::RefPtr vm_snapshot, fml::RefPtr isolate_snapshot) { if (!vm_snapshot || !vm_snapshot->IsValid()) { @@ -36,21 +38,21 @@ std::shared_ptr DartVMData::Create( DartSnapshot::VMServiceIsolateSnapshotFromSettings(settings); return std::shared_ptr(new DartVMData( - std::move(settings), // + settings, // std::move(vm_snapshot), // std::move(isolate_snapshot), // std::move(service_isolate_snapshot) // )); } -DartVMData::DartVMData(Settings settings, +DartVMData::DartVMData(const Settings& settings, fml::RefPtr vm_snapshot, fml::RefPtr isolate_snapshot, fml::RefPtr service_isolate_snapshot) : settings_(settings), - vm_snapshot_(vm_snapshot), - isolate_snapshot_(isolate_snapshot), - service_isolate_snapshot_(service_isolate_snapshot) {} + vm_snapshot_(std::move(vm_snapshot)), + isolate_snapshot_(std::move(isolate_snapshot)), + service_isolate_snapshot_(std::move(service_isolate_snapshot)) {} DartVMData::~DartVMData() = default; diff --git a/runtime/dart_vm_data.h b/runtime/dart_vm_data.h index e0d914ea28a84..6f384b20d0752 100644 --- a/runtime/dart_vm_data.h +++ b/runtime/dart_vm_data.h @@ -36,7 +36,7 @@ class DartVMData { /// inferred from the settings object. /// static std::shared_ptr Create( - Settings settings, + const Settings& settings, fml::RefPtr vm_snapshot, fml::RefPtr isolate_snapshot); @@ -93,7 +93,7 @@ class DartVMData { const fml::RefPtr isolate_snapshot_; const fml::RefPtr service_isolate_snapshot_; - DartVMData(Settings settings, + DartVMData(const Settings& settings, fml::RefPtr vm_snapshot, fml::RefPtr isolate_snapshot, fml::RefPtr service_isolate_snapshot); diff --git a/runtime/dart_vm_lifecycle.cc b/runtime/dart_vm_lifecycle.cc index 5df46f1aaa5d8..9c681deef7e86 100644 --- a/runtime/dart_vm_lifecycle.cc +++ b/runtime/dart_vm_lifecycle.cc @@ -5,6 +5,7 @@ #include "flutter/runtime/dart_vm_lifecycle.h" #include +#include namespace flutter { @@ -25,7 +26,7 @@ static std::weak_ptr gVMData; static std::weak_ptr gVMServiceProtocol; static std::weak_ptr gVMIsolateNameServer; -DartVMRef::DartVMRef(std::shared_ptr vm) : vm_(vm) {} +DartVMRef::DartVMRef(std::shared_ptr vm) : vm_(std::move(vm)) {} DartVMRef::DartVMRef(DartVMRef&& other) = default; @@ -41,7 +42,7 @@ DartVMRef::~DartVMRef() { vm_.reset(); } -DartVMRef DartVMRef::Create(Settings settings, +DartVMRef DartVMRef::Create(const Settings& settings, fml::RefPtr vm_snapshot, fml::RefPtr isolate_snapshot) { std::scoped_lock lifecycle_lock(gVMMutex); diff --git a/runtime/dart_vm_lifecycle.h b/runtime/dart_vm_lifecycle.h index 2573fa50fcd5d..c5b016be89cad 100644 --- a/runtime/dart_vm_lifecycle.h +++ b/runtime/dart_vm_lifecycle.h @@ -28,7 +28,7 @@ namespace flutter { class DartVMRef { public: [[nodiscard]] static DartVMRef Create( - Settings settings, + const Settings& settings, fml::RefPtr vm_snapshot = nullptr, fml::RefPtr isolate_snapshot = nullptr); diff --git a/runtime/isolate_configuration.cc b/runtime/isolate_configuration.cc index 649d52e46f8c1..54eb6c35ee3c4 100644 --- a/runtime/isolate_configuration.cc +++ b/runtime/isolate_configuration.cc @@ -172,9 +172,9 @@ static std::vector ParseKernelListPaths( } static std::vector>> -PrepareKernelMappings(std::vector kernel_pieces_paths, - std::shared_ptr asset_manager, - fml::RefPtr io_worker) { +PrepareKernelMappings(const std::vector& kernel_pieces_paths, + const std::shared_ptr& asset_manager, + const fml::RefPtr& io_worker) { FML_DCHECK(asset_manager); std::vector>> fetch_futures; @@ -201,8 +201,8 @@ PrepareKernelMappings(std::vector kernel_pieces_paths, std::unique_ptr IsolateConfiguration::InferFromSettings( const Settings& settings, - std::shared_ptr asset_manager, - fml::RefPtr io_worker) { + const std::shared_ptr& asset_manager, + const fml::RefPtr& io_worker) { // Running in AOT mode. if (DartVM::IsRunningPrecompiledCode()) { return CreateForAppSnapshot(); @@ -251,8 +251,8 @@ std::unique_ptr IsolateConfiguration::InferFromSettings( return nullptr; } auto kernel_pieces_paths = ParseKernelListPaths(std::move(kernel_list)); - auto kernel_mappings = PrepareKernelMappings(std::move(kernel_pieces_paths), - asset_manager, io_worker); + auto kernel_mappings = + PrepareKernelMappings(kernel_pieces_paths, asset_manager, io_worker); return CreateForKernelList(std::move(kernel_mappings)); } diff --git a/runtime/isolate_configuration.h b/runtime/isolate_configuration.h index f1a018704d6c0..46f9c9368c2d3 100644 --- a/runtime/isolate_configuration.h +++ b/runtime/isolate_configuration.h @@ -63,8 +63,8 @@ class IsolateConfiguration { /// [[nodiscard]] static std::unique_ptr InferFromSettings( const Settings& settings, - std::shared_ptr asset_manager = nullptr, - fml::RefPtr io_worker = nullptr); + const std::shared_ptr& asset_manager = nullptr, + const fml::RefPtr& io_worker = nullptr); //---------------------------------------------------------------------------- /// @brief Creates an AOT isolate configuration using snapshot symbols diff --git a/runtime/runtime_controller.cc b/runtime/runtime_controller.cc index 3522901705e42..9c95a586f7a6b 100644 --- a/runtime/runtime_controller.cc +++ b/runtime/runtime_controller.cc @@ -4,6 +4,8 @@ #include "flutter/runtime/runtime_controller.h" +#include + #include "flutter/fml/message_loop.h" #include "flutter/fml/trace_event.h" #include "flutter/lib/ui/compositing/scene.h" @@ -19,7 +21,7 @@ namespace flutter { RuntimeController::RuntimeController(RuntimeDelegate& p_client, - TaskRunners task_runners) + const TaskRunners& task_runners) : client_(p_client), vm_(nullptr), context_(task_runners) {} RuntimeController::RuntimeController( @@ -34,9 +36,9 @@ RuntimeController::RuntimeController( const UIDartState::Context& p_context) : client_(p_client), vm_(p_vm), - isolate_snapshot_(p_isolate_snapshot), + isolate_snapshot_(std::move(p_isolate_snapshot)), idle_notification_callback_(p_idle_notification_callback), - platform_data_(std::move(p_platform_data)), + platform_data_(p_platform_data), isolate_create_callback_(p_isolate_create_callback), isolate_shutdown_callback_(p_isolate_shutdown_callback), persistent_isolate_data_(std::move(p_persistent_isolate_data)), @@ -49,21 +51,17 @@ std::unique_ptr RuntimeController::Spawn( const std::function& p_idle_notification_callback, const fml::closure& p_isolate_create_callback, const fml::closure& p_isolate_shutdown_callback, - std::shared_ptr p_persistent_isolate_data, + const std::shared_ptr& p_persistent_isolate_data, fml::WeakPtr io_manager, fml::WeakPtr image_decoder, fml::WeakPtr image_generator_registry, fml::WeakPtr snapshot_delegate) const { - UIDartState::Context spawned_context{context_.task_runners, - std::move(snapshot_delegate), - std::move(io_manager), - context_.unref_queue, - std::move(image_decoder), - std::move(image_generator_registry), - advisory_script_uri, - advisory_script_entrypoint, - context_.volatile_path_tracker, - context_.enable_impeller}; + UIDartState::Context spawned_context{ + context_.task_runners, std::move(snapshot_delegate), + std::move(io_manager), context_.unref_queue, + std::move(image_decoder), std::move(image_generator_registry), + std::move(advisory_script_uri), std::move(advisory_script_entrypoint), + context_.volatile_path_tracker, context_.enable_impeller}; auto result = std::make_unique(p_client, // vm_, // @@ -360,7 +358,7 @@ tonic::DartErrorHandleType RuntimeController::GetLastError() { bool RuntimeController::LaunchRootIsolate( const Settings& settings, - fml::closure root_isolate_create_callback, + const fml::closure& root_isolate_create_callback, std::optional dart_entrypoint, std::optional dart_entrypoint_library, const std::vector& dart_entrypoint_args, @@ -379,8 +377,8 @@ bool RuntimeController::LaunchRootIsolate( root_isolate_create_callback, // isolate_create_callback_, // isolate_shutdown_callback_, // - dart_entrypoint, // - dart_entrypoint_library, // + std::move(dart_entrypoint), // + std::move(dart_entrypoint_library), // dart_entrypoint_args, // std::move(isolate_configuration), // context_, // @@ -470,10 +468,10 @@ RuntimeController::Locale::Locale(std::string language_code_, std::string country_code_, std::string script_code_, std::string variant_code_) - : language_code(language_code_), - country_code(country_code_), - script_code(script_code_), - variant_code(variant_code_) {} + : language_code(std::move(language_code_)), + country_code(std::move(country_code_)), + script_code(std::move(script_code_)), + variant_code(std::move(variant_code_)) {} RuntimeController::Locale::~Locale() = default; diff --git a/runtime/runtime_controller.h b/runtime/runtime_controller.h index d62c8dc252013..590635c30f84a 100644 --- a/runtime/runtime_controller.h +++ b/runtime/runtime_controller.h @@ -103,7 +103,7 @@ class RuntimeController : public PlatformConfigurationClient { const std::function& idle_notification_callback, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, - std::shared_ptr persistent_isolate_data, + const std::shared_ptr& persistent_isolate_data, fml::WeakPtr io_manager, fml::WeakPtr image_decoder, fml::WeakPtr image_generator_registry, @@ -146,7 +146,7 @@ class RuntimeController : public PlatformConfigurationClient { /// [[nodiscard]] bool LaunchRootIsolate( const Settings& settings, - fml::closure root_isolate_create_callback, + const fml::closure& root_isolate_create_callback, std::optional dart_entrypoint, std::optional dart_entrypoint_library, const std::vector& dart_entrypoint_args, @@ -564,7 +564,7 @@ class RuntimeController : public PlatformConfigurationClient { protected: /// Constructor for Mocks. - RuntimeController(RuntimeDelegate& p_client, TaskRunners task_runners); + RuntimeController(RuntimeDelegate& p_client, const TaskRunners& task_runners); private: struct Locale { diff --git a/runtime/service_protocol.cc b/runtime/service_protocol.cc index 0f25565ada9b8..20382264ce0b0 100644 --- a/runtime/service_protocol.cc +++ b/runtime/service_protocol.cc @@ -71,7 +71,7 @@ ServiceProtocol::~ServiceProtocol() { } void ServiceProtocol::AddHandler(Handler* handler, - Handler::Description description) { + const Handler::Description& description) { fml::UniqueLock lock(*handlers_mutex_); handlers_.emplace(handler, description); } @@ -81,8 +81,9 @@ void ServiceProtocol::RemoveHandler(Handler* handler) { handlers_.erase(handler); } -void ServiceProtocol::SetHandlerDescription(Handler* handler, - Handler::Description description) { +void ServiceProtocol::SetHandlerDescription( + Handler* handler, + const Handler::Description& description) { fml::SharedLock lock(*handlers_mutex_); auto it = handlers_.find(handler); if (it != handlers_.end()) { diff --git a/runtime/service_protocol.h b/runtime/service_protocol.h index dc3a4d186e1ca..e014cb22192a0 100644 --- a/runtime/service_protocol.h +++ b/runtime/service_protocol.h @@ -68,12 +68,12 @@ class ServiceProtocol { void ToggleHooks(bool set); - void AddHandler(Handler* handler, Handler::Description description); + void AddHandler(Handler* handler, const Handler::Description& description); void RemoveHandler(Handler* handler); void SetHandlerDescription(Handler* handler, - Handler::Description description); + const Handler::Description& description); private: const std::set endpoints_; diff --git a/shell/common/animator.cc b/shell/common/animator.cc index d8614dc22f69c..dacf8fad50d6b 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -22,10 +22,10 @@ constexpr fml::TimeDelta kNotifyIdleTaskWaitTime = } // namespace Animator::Animator(Delegate& delegate, - TaskRunners task_runners, + const TaskRunners& task_runners, std::unique_ptr waiter) : delegate_(delegate), - task_runners_(std::move(task_runners)), + task_runners_(task_runners), waiter_(std::move(waiter)), #if SHELL_ENABLE_METAL layer_tree_pipeline_(std::make_shared(2)), diff --git a/shell/common/animator.h b/shell/common/animator.h index 6550452ba481e..116682d2d76ee 100644 --- a/shell/common/animator.h +++ b/shell/common/animator.h @@ -47,7 +47,7 @@ class Animator final { }; Animator(Delegate& delegate, - TaskRunners task_runners, + const TaskRunners& task_runners, std::unique_ptr waiter); ~Animator(); diff --git a/shell/common/animator_unittests.cc b/shell/common/animator_unittests.cc index 91c2bad1b033f..0a68325e89f1b 100644 --- a/shell/common/animator_unittests.cc +++ b/shell/common/animator_unittests.cc @@ -80,8 +80,7 @@ TEST_F(ShellTest, VSyncTargetTime) { flutter::PlatformData(), task_runners, settings, [vsync_clock, &create_vsync_waiter](Shell& shell) { return ShellTestPlatformView::Create( - shell, shell.GetTaskRunners(), vsync_clock, - std::move(create_vsync_waiter), + shell, shell.GetTaskRunners(), vsync_clock, create_vsync_waiter, ShellTestPlatformView::BackendType::kDefaultBackend, nullptr); }, [](Shell& shell) { return std::make_unique(shell); }); @@ -104,7 +103,7 @@ TEST_F(ShellTest, VSyncTargetTime) { ASSERT_EQ(GetLatestFrameTargetTime(shell.get()), vsync_waiter_target_time); // teardown. - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } diff --git a/shell/common/engine.cc b/shell/common/engine.cc index 1a07631ccabd5..b80d866dbf21e 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -40,22 +40,22 @@ Engine::Engine( Delegate& delegate, const PointerDataDispatcherMaker& dispatcher_maker, std::shared_ptr image_decoder_task_runner, - TaskRunners task_runners, - Settings settings, + const TaskRunners& task_runners, + const Settings& settings, std::unique_ptr animator, fml::WeakPtr io_manager, const std::shared_ptr& font_collection, std::unique_ptr runtime_controller) : delegate_(delegate), - settings_(std::move(settings)), + settings_(settings), animator_(std::move(animator)), runtime_controller_(std::move(runtime_controller)), font_collection_(font_collection), image_decoder_(ImageDecoder::Make(settings_, task_runners, - image_decoder_task_runner, - io_manager)), - task_runners_(std::move(task_runners)), + std::move(image_decoder_task_runner), + std::move(io_manager))), + task_runners_(task_runners), weak_factory_(this) { pointer_data_dispatcher_ = dispatcher_maker(*this); } @@ -64,9 +64,9 @@ Engine::Engine(Delegate& delegate, const PointerDataDispatcherMaker& dispatcher_maker, DartVM& vm, fml::RefPtr isolate_snapshot, - TaskRunners task_runners, + const TaskRunners& task_runners, const PlatformData& platform_data, - Settings settings, + const Settings& settings, std::unique_ptr animator, fml::WeakPtr io_manager, fml::RefPtr unref_queue, @@ -107,10 +107,10 @@ Engine::Engine(Delegate& delegate, std::unique_ptr Engine::Spawn( Delegate& delegate, const PointerDataDispatcherMaker& dispatcher_maker, - Settings settings, + const Settings& settings, std::unique_ptr animator, const std::string& initial_route, - fml::WeakPtr io_manager, + const fml::WeakPtr& io_manager, fml::WeakPtr snapshot_delegate) const { auto result = std::make_unique( /*delegate=*/delegate, @@ -134,7 +134,7 @@ std::unique_ptr Engine::Spawn( /*io_manager=*/io_manager, /*image_decoder=*/result->GetImageDecoderWeakPtr(), /*image_generator_registry=*/result->GetImageGeneratorRegistry(), - /*snapshot_delegate=*/snapshot_delegate); + /*snapshot_delegate=*/std::move(snapshot_delegate)); result->initial_route_ = initial_route; return result; } @@ -163,7 +163,7 @@ fml::WeakPtr Engine::GetImageGeneratorRegistry() { } bool Engine::UpdateAssetManager( - std::shared_ptr new_asset_manager) { + const std::shared_ptr& new_asset_manager) { if (asset_manager_ == new_asset_manager) { return false; } @@ -351,7 +351,7 @@ bool Engine::HandleNavigationPlatformMessage( return false; } auto route = root.FindMember("args"); - initial_route_ = std::move(route->value.GetString()); + initial_route_ = route->value.GetString(); return true; } @@ -402,7 +402,7 @@ void Engine::HandleSettingsPlatformMessage(PlatformMessage* message) { const auto& data = message->data(); std::string jsonData(reinterpret_cast(data.GetMapping()), data.GetSize()); - if (runtime_controller_->SetUserSettingsData(std::move(jsonData))) { + if (runtime_controller_->SetUserSettingsData(jsonData)) { ScheduleFrame(); } } @@ -561,7 +561,7 @@ void Engine::LoadDartDeferredLibrary( } void Engine::LoadDartDeferredLibraryError(intptr_t loading_unit_id, - const std::string error_message, + const std::string& error_message, bool transient) { if (runtime_controller_->IsRootIsolateRunning()) { runtime_controller_->LoadDartDeferredLibraryError(loading_unit_id, diff --git a/shell/common/engine.h b/shell/common/engine.h index cc178c31735e8..5d05048c8d2e3 100644 --- a/shell/common/engine.h +++ b/shell/common/engine.h @@ -304,8 +304,8 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { Engine(Delegate& delegate, const PointerDataDispatcherMaker& dispatcher_maker, std::shared_ptr image_decoder_task_runner, - TaskRunners task_runners, - Settings settings, + const TaskRunners& task_runners, + const Settings& settings, std::unique_ptr animator, fml::WeakPtr io_manager, const std::shared_ptr& font_collection, @@ -357,9 +357,9 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { const PointerDataDispatcherMaker& dispatcher_maker, DartVM& vm, fml::RefPtr isolate_snapshot, - TaskRunners task_runners, + const TaskRunners& task_runners, const PlatformData& platform_data, - Settings settings, + const Settings& settings, std::unique_ptr animator, fml::WeakPtr io_manager, fml::RefPtr unref_queue, @@ -378,10 +378,10 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { std::unique_ptr Spawn( Delegate& delegate, const PointerDataDispatcherMaker& dispatcher_maker, - Settings settings, + const Settings& settings, std::unique_ptr animator, const std::string& initial_route, - fml::WeakPtr io_manager, + const fml::WeakPtr& io_manager, fml::WeakPtr snapshot_delegate) const; //---------------------------------------------------------------------------- @@ -465,7 +465,7 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { /// @return If the asset manager was successfully replaced. This may fail /// if the new asset manager is invalid. /// - bool UpdateAssetManager(std::shared_ptr asset_manager); + bool UpdateAssetManager(const std::shared_ptr& asset_manager); //---------------------------------------------------------------------------- /// @brief Notifies the engine that it is time to begin working on a new @@ -868,7 +868,7 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { /// re-request the library will instantly /// complete with an error. void LoadDartDeferredLibraryError(intptr_t loading_unit_id, - const std::string error_message, + const std::string& error_message, bool transient); //-------------------------------------------------------------------------- diff --git a/shell/common/engine_unittests.cc b/shell/common/engine_unittests.cc index 365012b84f507..046775e8ef46f 100644 --- a/shell/common/engine_unittests.cc +++ b/shell/common/engine_unittests.cc @@ -69,7 +69,8 @@ class MockRuntimeDelegate : public RuntimeDelegate { class MockRuntimeController : public RuntimeController { public: - MockRuntimeController(RuntimeDelegate& client, TaskRunners p_task_runners) + MockRuntimeController(RuntimeDelegate& client, + const TaskRunners& p_task_runners) : RuntimeController(client, p_task_runners) {} MOCK_METHOD0(IsRootIsolateRunning, bool()); MOCK_METHOD1(DispatchPlatformMessage, bool(std::unique_ptr)); @@ -82,7 +83,7 @@ class MockRuntimeController : public RuntimeController { std::unique_ptr MakePlatformMessage( const std::string& channel, const std::map& values, - fml::RefPtr response) { + const fml::RefPtr& response) { rapidjson::Document document; auto& allocator = document.GetAllocator(); document.SetObject(); diff --git a/shell/common/persistent_cache_unittests.cc b/shell/common/persistent_cache_unittests.cc index 3bf8d1f9bb519..c1d27bfa77794 100644 --- a/shell/common/persistent_cache_unittests.cc +++ b/shell/common/persistent_cache_unittests.cc @@ -66,7 +66,7 @@ TEST_F(PersistentCacheTest, CacheSkSLWorks) { ASSERT_EQ(cache.size(), 0u); // Draw something to trigger shader compilations. - LayerTreeBuilder builder = [](std::shared_ptr root) { + LayerTreeBuilder builder = [](const std::shared_ptr& root) { SkPath path; path.addCircle(50, 50, 20); auto physical_shape_layer = std::make_shared( @@ -165,7 +165,7 @@ TEST_F(PersistentCacheTest, CanPrecompileMetalShaders) { } // Draw something to trigger shader compilations. - LayerTreeBuilder builder = [](std::shared_ptr root) { + LayerTreeBuilder builder = [](const std::shared_ptr& root) { SkPath path; path.addCircle(50, 50, 20); auto physical_shape_layer = std::make_shared( @@ -186,7 +186,8 @@ TEST_F(PersistentCacheTest, CanPrecompileMetalShaders) { DestroyShell(std::move(shell)); } -static void CheckTextSkData(sk_sp data, const std::string& expected) { +static void CheckTextSkData(const sk_sp& data, + const std::string& expected) { std::string data_string(reinterpret_cast(data->bytes()), data->size()); ASSERT_EQ(data_string, expected); diff --git a/shell/common/platform_view.cc b/shell/common/platform_view.cc index e27d6fddc875a..51c98dc3af809 100644 --- a/shell/common/platform_view.cc +++ b/shell/common/platform_view.cc @@ -13,10 +13,8 @@ namespace flutter { -PlatformView::PlatformView(Delegate& delegate, TaskRunners task_runners) - : delegate_(delegate), - task_runners_(std::move(task_runners)), - weak_factory_(this) {} +PlatformView::PlatformView(Delegate& delegate, const TaskRunners& task_runners) + : delegate_(delegate), task_runners_(task_runners), weak_factory_(this) {} PlatformView::~PlatformView() = default; diff --git a/shell/common/platform_view.h b/shell/common/platform_view.h index 794f7f78a517c..d46b8b1326ff6 100644 --- a/shell/common/platform_view.h +++ b/shell/common/platform_view.h @@ -336,7 +336,7 @@ class PlatformView { /// @param delegate The delegate. This is typically the shell. /// @param[in] task_runners The task runners used by this platform view. /// - explicit PlatformView(Delegate& delegate, TaskRunners task_runners); + explicit PlatformView(Delegate& delegate, const TaskRunners& task_runners); //---------------------------------------------------------------------------- /// @brief Destroys the platform view. The platform view is owned by the diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index 9019e08e6ceb2..7f66f93ff8830 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -172,8 +172,9 @@ void Rasterizer::DrawLastLayerTree( } } -RasterStatus Rasterizer::Draw(std::shared_ptr pipeline, - LayerTreeDiscardCallback discard_callback) { +RasterStatus Rasterizer::Draw( + const std::shared_ptr& pipeline, + LayerTreeDiscardCallback discard_callback) { TRACE_EVENT0("flutter", "GPURasterizer::Draw"); if (raster_thread_merger_ && !raster_thread_merger_->IsOnRasterizingThread()) { @@ -255,7 +256,7 @@ bool Rasterizer::ShouldResubmitFrame(const RasterStatus& raster_status) { namespace { std::unique_ptr MakeBitmapImage( - sk_sp display_list, + const sk_sp& display_list, const SkImageInfo& image_info) { FML_DCHECK(display_list); // Use 16384 as a proxy for the maximum texture size for a GPU image. @@ -298,20 +299,20 @@ std::unique_ptr Rasterizer::MakeSkiaGpuImage( delegate_.GetIsGpuDisabledSyncSwitch()->Execute( fml::SyncSwitch::Handlers() .SetIfTrue([&result, &image_info, &display_list] { - result = MakeBitmapImage(std::move(display_list), image_info); + result = MakeBitmapImage(display_list, image_info); }) .SetIfFalse([&result, &image_info, &display_list, surface = surface_.get(), gpu_image_behavior = gpu_image_behavior_] { if (!surface || gpu_image_behavior == MakeGpuImageBehavior::kBitmap) { - result = MakeBitmapImage(std::move(display_list), image_info); + result = MakeBitmapImage(display_list, image_info); return; } auto* context = surface->GetContext(); if (!context) { - result = MakeBitmapImage(std::move(display_list), image_info); + result = MakeBitmapImage(display_list, image_info); return; } diff --git a/shell/common/rasterizer.h b/shell/common/rasterizer.h index 0c28af9c758d8..32ff4de421a0e 100644 --- a/shell/common/rasterizer.h +++ b/shell/common/rasterizer.h @@ -256,7 +256,7 @@ class Rasterizer final : public SnapshotDelegate, /// @param[in] discard_callback if specified and returns true, the layer tree /// is discarded instead of being rendered /// - RasterStatus Draw(std::shared_ptr pipeline, + RasterStatus Draw(const std::shared_ptr& pipeline, LayerTreeDiscardCallback discard_callback = NoDiscard); //---------------------------------------------------------------------------- diff --git a/shell/common/run_configuration.cc b/shell/common/run_configuration.cc index 91d7a413c0c8c..964d5d6c15fe6 100644 --- a/shell/common/run_configuration.cc +++ b/shell/common/run_configuration.cc @@ -5,6 +5,7 @@ #include "flutter/shell/common/run_configuration.h" #include +#include #include "flutter/assets/directory_asset_bundle.h" #include "flutter/common/graphics/persistent_cache.h" @@ -16,7 +17,7 @@ namespace flutter { RunConfiguration RunConfiguration::InferFromSettings( const Settings& settings, - fml::RefPtr io_worker) { + const fml::RefPtr& io_worker) { auto asset_manager = std::make_shared(); if (fml::UniqueFD::traits_type::IsValid(settings.assets_dir)) { @@ -73,7 +74,7 @@ void RunConfiguration::SetEntrypoint(std::string entrypoint) { void RunConfiguration::SetEntrypointAndLibrary(std::string entrypoint, std::string library) { - SetEntrypoint(entrypoint); + SetEntrypoint(std::move(entrypoint)); entrypoint_library_ = std::move(library); } diff --git a/shell/common/run_configuration.h b/shell/common/run_configuration.h index 15a3ce4e5b5a1..c1efeec34d8ca 100644 --- a/shell/common/run_configuration.h +++ b/shell/common/run_configuration.h @@ -57,7 +57,7 @@ class RunConfiguration { /// static RunConfiguration InferFromSettings( const Settings& settings, - fml::RefPtr io_worker = nullptr); + const fml::RefPtr& io_worker = nullptr); //---------------------------------------------------------------------------- /// @brief Creates a run configuration with only an isolate diff --git a/shell/common/shell.cc b/shell/common/shell.cc index cf061e11eba66..fd4cc9003fa0c 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include "flutter/assets/directory_asset_bundle.h" @@ -45,15 +46,15 @@ std::unique_ptr CreateEngine( Engine::Delegate& delegate, const PointerDataDispatcherMaker& dispatcher_maker, DartVM& vm, - fml::RefPtr isolate_snapshot, - TaskRunners task_runners, + const fml::RefPtr& isolate_snapshot, + const TaskRunners& task_runners, const PlatformData& platform_data, - Settings settings, + const Settings& settings, std::unique_ptr animator, - fml::WeakPtr io_manager, - fml::RefPtr unref_queue, - fml::WeakPtr snapshot_delegate, - std::shared_ptr volatile_path_tracker) { + const fml::WeakPtr& io_manager, + const fml::RefPtr& unref_queue, + const fml::WeakPtr& snapshot_delegate, + const std::shared_ptr& volatile_path_tracker) { return std::make_unique(delegate, // dispatcher_maker, // vm, // @@ -119,7 +120,7 @@ void PerformInitializationTasks(Settings& settings) { std::unique_ptr Shell::Create( const PlatformData& platform_data, - TaskRunners task_runners, + const TaskRunners& task_runners, Settings settings, const Shell::CreateCallback& on_create_platform_view, const Shell::CreateCallback& on_create_rasterizer, @@ -145,16 +146,16 @@ std::unique_ptr Shell::Create( auto resource_cache_limit_calculator = std::make_shared( settings.resource_cache_max_bytes_threshold); - return CreateWithSnapshot(std::move(platform_data), // - std::move(task_runners), // - /*parent_merger=*/nullptr, // - /*parent_io_manager=*/nullptr, // - resource_cache_limit_calculator, // - std::move(settings), // - std::move(vm), // - std::move(isolate_snapshot), // - std::move(on_create_platform_view), // - std::move(on_create_rasterizer), // + return CreateWithSnapshot(platform_data, // + task_runners, // + /*parent_merger=*/nullptr, // + /*parent_io_manager=*/nullptr, // + resource_cache_limit_calculator, // + settings, // + std::move(vm), // + std::move(isolate_snapshot), // + on_create_platform_view, // + on_create_rasterizer, // CreateEngine, is_gpu_disabled); } @@ -164,9 +165,9 @@ std::unique_ptr Shell::CreateShellOnPlatformThread( std::shared_ptr parent_io_manager, const std::shared_ptr& resource_cache_limit_calculator, - TaskRunners task_runners, + const TaskRunners& task_runners, const PlatformData& platform_data, - Settings settings, + const Settings& settings, fml::RefPtr isolate_snapshot, const Shell::CreateCallback& on_create_platform_view, const Shell::CreateCallback& on_create_rasterizer, @@ -178,7 +179,7 @@ std::unique_ptr Shell::CreateShellOnPlatformThread( } auto shell = std::unique_ptr( - new Shell(std::move(vm), task_runners, parent_merger, + new Shell(std::move(vm), task_runners, std::move(parent_merger), resource_cache_limit_calculator, settings, std::make_shared( task_runners.GetUITaskRunner(), @@ -312,9 +313,9 @@ std::unique_ptr Shell::CreateShellOnPlatformThread( std::unique_ptr Shell::CreateWithSnapshot( const PlatformData& platform_data, - TaskRunners task_runners, - fml::RefPtr parent_thread_merger, - std::shared_ptr parent_io_manager, + const TaskRunners& task_runners, + const fml::RefPtr& parent_thread_merger, + const std::shared_ptr& parent_io_manager, const std::shared_ptr& resource_cache_limit_calculator, Settings settings, @@ -340,51 +341,49 @@ std::unique_ptr Shell::CreateWithSnapshot( auto platform_task_runner = task_runners.GetPlatformTaskRunner(); fml::TaskRunner::RunNowOrPostTask( platform_task_runner, - fml::MakeCopyable( - [&latch, // - &shell, // - parent_thread_merger, // - parent_io_manager, // - resource_cache_limit_calculator, // - task_runners = std::move(task_runners), // - platform_data = std::move(platform_data), // - settings = std::move(settings), // - vm = std::move(vm), // - isolate_snapshot = std::move(isolate_snapshot), // - on_create_platform_view = std::move(on_create_platform_view), // - on_create_rasterizer = std::move(on_create_rasterizer), // - on_create_engine = std::move(on_create_engine), - is_gpu_disabled]() mutable { - shell = CreateShellOnPlatformThread( - std::move(vm), // - parent_thread_merger, // - parent_io_manager, // - resource_cache_limit_calculator, // - std::move(task_runners), // - std::move(platform_data), // - std::move(settings), // - std::move(isolate_snapshot), // - std::move(on_create_platform_view), // - std::move(on_create_rasterizer), // - std::move(on_create_engine), is_gpu_disabled); - latch.Signal(); - })); + fml::MakeCopyable([&latch, // + &shell, // + parent_thread_merger, // + parent_io_manager, // + resource_cache_limit_calculator, // + task_runners = task_runners, // + platform_data = platform_data, // + settings = settings, // + vm = std::move(vm), // + isolate_snapshot = std::move(isolate_snapshot), // + on_create_platform_view = on_create_platform_view, // + on_create_rasterizer = on_create_rasterizer, // + on_create_engine = on_create_engine, + is_gpu_disabled]() mutable { + shell = CreateShellOnPlatformThread(std::move(vm), // + parent_thread_merger, // + parent_io_manager, // + resource_cache_limit_calculator, // + task_runners, // + platform_data, // + settings, // + std::move(isolate_snapshot), // + on_create_platform_view, // + on_create_rasterizer, // + on_create_engine, is_gpu_disabled); + latch.Signal(); + })); latch.Wait(); return shell; } Shell::Shell(DartVMRef vm, - TaskRunners task_runners, + const TaskRunners& task_runners, fml::RefPtr parent_merger, const std::shared_ptr& resource_cache_limit_calculator, - Settings settings, + const Settings& settings, std::shared_ptr volatile_path_tracker, bool is_gpu_disabled) - : task_runners_(std::move(task_runners)), - parent_raster_thread_merger_(parent_merger), + : task_runners_(task_runners), + parent_raster_thread_merger_(std::move(parent_merger)), resource_cache_limit_calculator_(resource_cache_limit_calculator), - settings_(std::move(settings)), + settings_(settings), vm_(std::move(vm)), is_gpu_disabled_sync_switch_(new fml::SyncSwitch(is_gpu_disabled)), volatile_path_tracker_(std::move(volatile_path_tracker)), @@ -529,20 +528,20 @@ std::unique_ptr Shell::Spawn( [engine = this->engine_.get(), initial_route]( Engine::Delegate& delegate, const PointerDataDispatcherMaker& dispatcher_maker, DartVM& vm, - fml::RefPtr isolate_snapshot, - TaskRunners task_runners, const PlatformData& platform_data, - Settings settings, std::unique_ptr animator, - fml::WeakPtr io_manager, - fml::RefPtr unref_queue, + const fml::RefPtr& isolate_snapshot, + const TaskRunners& task_runners, const PlatformData& platform_data, + const Settings& settings, std::unique_ptr animator, + const fml::WeakPtr& io_manager, + const fml::RefPtr& unref_queue, fml::WeakPtr snapshot_delegate, - std::shared_ptr volatile_path_tracker) { + const std::shared_ptr& volatile_path_tracker) { return engine->Spawn( /*delegate=*/delegate, /*dispatcher_maker=*/dispatcher_maker, /*settings=*/settings, /*animator=*/std::move(animator), /*initial_route=*/initial_route, - /*io_manager=*/std::move(io_manager), + /*io_manager=*/io_manager, /*snapshot_delegate=*/std::move(snapshot_delegate)); }, is_gpu_disabled); @@ -648,7 +647,7 @@ bool Shell::IsSetup() const { bool Shell::Setup(std::unique_ptr platform_view, std::unique_ptr engine, std::unique_ptr rasterizer, - std::shared_ptr io_manager) { + const std::shared_ptr& io_manager) { if (is_setup_) { return false; } @@ -1098,7 +1097,7 @@ void Shell::OnPlatformViewSetNextFrameCallback(const fml::closure& closure) { task_runners_.GetRasterTaskRunner()->PostTask( [rasterizer = rasterizer_->GetWeakPtr(), closure = closure]() { if (rasterizer) { - rasterizer->SetNextFrameCallback(std::move(closure)); + rasterizer->SetNextFrameCallback(closure); } }); } @@ -1169,7 +1168,7 @@ void Shell::OnAnimatorDraw(std::shared_ptr pipeline) { if (rasterizer) { std::shared_ptr pipeline = weak_pipeline.lock(); if (pipeline) { - rasterizer->Draw(std::move(pipeline), std::move(discard_callback)); + rasterizer->Draw(pipeline, std::move(discard_callback)); } if (waiting_for_first_frame.load()) { @@ -1206,7 +1205,7 @@ void Shell::OnEngineUpdateSemantics(SemanticsNodeUpdates update, [view = platform_view_->GetWeakPtr(), update = std::move(update), actions = std::move(actions)] { if (view) { - view->UpdateSemantics(std::move(update), std::move(actions)); + view->UpdateSemantics(update, actions); } }); } @@ -1292,7 +1291,7 @@ void Shell::HandleEngineSkiaMessage(std::unique_ptr message) { task_runners_.GetRasterTaskRunner()->PostTask( [rasterizer = rasterizer_->GetWeakPtr(), max_bytes = args->value.GetInt(), - response = std::move(message->response())] { + response = message->response()] { if (rasterizer) { rasterizer->SetResourceCacheMaxBytes(static_cast(max_bytes), true); @@ -1421,7 +1420,7 @@ void Shell::ReportTimings() { unreported_timings_ = {}; task_runners_.GetUITaskRunner()->PostTask([timings, engine = weak_engine_] { if (engine) { - engine->ReportTimings(std::move(timings)); + engine->ReportTimings(timings); } }); } @@ -1564,7 +1563,7 @@ static void ServiceProtocolParameterError(rapidjson::Document* response, response->AddMember("message", "Invalid params", allocator); { rapidjson::Value details(rapidjson::kObjectType); - details.AddMember("details", error_details, allocator); + details.AddMember("details", std::move(error_details), allocator); response->AddMember("data", details, allocator); } } @@ -1575,7 +1574,7 @@ static void ServiceProtocolFailureError(rapidjson::Document* response, response->SetObject(); const int64_t kJsonServerError = -32000; response->AddMember("code", kJsonServerError, allocator); - response->AddMember("message", message, allocator); + response->AddMember("message", std::move(message), allocator); } // Service protocol handler @@ -1824,7 +1823,7 @@ bool Shell::OnServiceProtocolSetAssetBundlePath( } } - if (engine_->UpdateAssetManager(std::move(asset_manager))) { + if (engine_->UpdateAssetManager(asset_manager)) { response->AddMember("type", "Success", allocator); auto new_description = GetServiceProtocolDescription(); rapidjson::Value view(rapidjson::kObjectType); diff --git a/shell/common/shell.h b/shell/common/shell.h index 431ae99437d23..c92df4cd32388 100644 --- a/shell/common/shell.h +++ b/shell/common/shell.h @@ -162,7 +162,7 @@ class Shell final : public PlatformView::Delegate, /// static std::unique_ptr Create( const PlatformData& platform_data, - TaskRunners task_runners, + const TaskRunners& task_runners, Settings settings, const CreateCallback& on_create_platform_view, const CreateCallback& on_create_rasterizer, @@ -478,11 +478,11 @@ class Shell final : public PlatformView::Delegate, size_t UnreportedFramesCount() const; Shell(DartVMRef vm, - TaskRunners task_runners, + const TaskRunners& task_runners, fml::RefPtr parent_merger, const std::shared_ptr& resource_cache_limit_calculator, - Settings settings, + const Settings& settings, std::shared_ptr volatile_path_tracker, bool is_gpu_disabled); @@ -492,9 +492,9 @@ class Shell final : public PlatformView::Delegate, std::shared_ptr parent_io_manager, const std::shared_ptr& resource_cache_limit_calculator, - TaskRunners task_runners, + const TaskRunners& task_runners, const PlatformData& platform_data, - Settings settings, + const Settings& settings, fml::RefPtr isolate_snapshot, const Shell::CreateCallback& on_create_platform_view, const Shell::CreateCallback& on_create_rasterizer, @@ -503,9 +503,9 @@ class Shell final : public PlatformView::Delegate, static std::unique_ptr CreateWithSnapshot( const PlatformData& platform_data, - TaskRunners task_runners, - fml::RefPtr parent_thread_merger, - std::shared_ptr parent_io_manager, + const TaskRunners& task_runners, + const fml::RefPtr& parent_thread_merger, + const std::shared_ptr& parent_io_manager, const std::shared_ptr& resource_cache_limit_calculator, Settings settings, @@ -519,7 +519,7 @@ class Shell final : public PlatformView::Delegate, bool Setup(std::unique_ptr platform_view, std::unique_ptr engine, std::unique_ptr rasterizer, - std::shared_ptr io_manager); + const std::shared_ptr& io_manager); void ReportTimings(); diff --git a/shell/common/shell_benchmarks.cc b/shell/common/shell_benchmarks.cc index 09a696c8af026..efd53d0b31b54 100644 --- a/shell/common/shell_benchmarks.cc +++ b/shell/common/shell_benchmarks.cc @@ -25,7 +25,7 @@ static void StartupAndShutdownShell(benchmark::State& state, { benchmarking::ScopedPauseTiming pause(state, !measure_startup); Settings settings = {}; - settings.task_observer_add = [](intptr_t, fml::closure) {}; + settings.task_observer_add = [](intptr_t, const fml::closure&) {}; settings.task_observer_remove = [](intptr_t) {}; if (DartVM::IsRunningPrecompiledCode()) { @@ -55,7 +55,7 @@ static void StartupAndShutdownShell(benchmark::State& state, thread_host->io_thread->GetTaskRunner()); shell = Shell::Create( - flutter::PlatformData(), std::move(task_runners), settings, + flutter::PlatformData(), task_runners, settings, [](Shell& shell) { return std::make_unique(shell, shell.GetTaskRunners()); }, diff --git a/shell/common/shell_io_manager.cc b/shell/common/shell_io_manager.cc index b48a6e9af65d3..0338855f27f94 100644 --- a/shell/common/shell_io_manager.cc +++ b/shell/common/shell_io_manager.cc @@ -4,6 +4,8 @@ #include "flutter/shell/common/shell_io_manager.h" +#include + #include "flutter/fml/message_loop.h" #include "flutter/shell/common/context_options.h" #include "third_party/skia/include/gpu/gl/GrGLInterface.h" @@ -20,7 +22,8 @@ sk_sp ShellIOManager::CreateCompatibleResourceLoadingContext( const auto options = MakeDefaultContextOptions(ContextType::kResource); - if (auto context = GrDirectContext::MakeGL(gl_interface, options)) { + if (auto context = + GrDirectContext::MakeGL(std::move(gl_interface), options)) { // Do not cache textures created by the image decoder. These textures // should be deleted when they are no longer referenced by an SkImage. context->setResourceCacheLimit(0); @@ -47,7 +50,7 @@ ShellIOManager::ShellIOManager( std::move(unref_queue_task_runner), unref_queue_drain_delay, resource_context_)), - is_gpu_disabled_sync_switch_(is_gpu_disabled_sync_switch), + is_gpu_disabled_sync_switch_(std::move(is_gpu_disabled_sync_switch)), impeller_context_(std::move(impeller_context)), weak_factory_(this) { if (!resource_context_) { diff --git a/shell/common/shell_test.cc b/shell/common/shell_test.cc index eca345058787f..078455d3f8e5b 100644 --- a/shell/common/shell_test.cc +++ b/shell/common/shell_test.cc @@ -138,7 +138,7 @@ void ShellTest::SetViewportMetrics(Shell* shell, double width, double height) { shell->GetTaskRunners().GetUITaskRunner()->PostTask( [&latch, engine = shell->weak_engine_, viewport_metrics]() { if (engine) { - engine->SetViewportMetrics(std::move(viewport_metrics)); + engine->SetViewportMetrics(viewport_metrics); const auto frame_begin_time = fml::TimePoint::Now(); const auto frame_end_time = frame_begin_time + fml::TimeDelta::FromSecondsF(1.0 / 60.0); @@ -172,7 +172,7 @@ void ShellTest::PumpOneFrame(Shell* shell, } void ShellTest::PumpOneFrame(Shell* shell, - flutter::ViewportMetrics viewport_metrics, + const flutter::ViewportMetrics& viewport_metrics, LayerTreeBuilder builder) { // Set viewport to nonempty, and call Animator::BeginFrame to make the layer // tree pipeline nonempty. Without either of this, the layer tree below @@ -180,7 +180,7 @@ void ShellTest::PumpOneFrame(Shell* shell, fml::AutoResetWaitableEvent latch; shell->GetTaskRunners().GetUITaskRunner()->PostTask( [&latch, engine = shell->weak_engine_, viewport_metrics]() { - engine->SetViewportMetrics(std::move(viewport_metrics)); + engine->SetViewportMetrics(viewport_metrics); const auto frame_begin_time = fml::TimePoint::Now(); const auto frame_end_time = frame_begin_time + fml::TimeDelta::FromSecondsF(1.0 / 60.0); @@ -252,7 +252,7 @@ void ShellTest::StorePersistentCache(PersistentCache* cache, void ShellTest::OnServiceProtocol( Shell* shell, ServiceProtocolEnum some_protocol, - fml::RefPtr task_runner, + const fml::RefPtr& task_runner, const ServiceProtocol::Handler::ServiceProtocolMap& params, rapidjson::Document* response) { std::promise finished; @@ -288,7 +288,7 @@ std::shared_ptr ShellTest::GetFontCollection( Settings ShellTest::CreateSettingsForFixture() { Settings settings; settings.leak_vm = false; - settings.task_observer_add = [](intptr_t key, fml::closure handler) { + settings.task_observer_add = [](intptr_t key, const fml::closure& handler) { fml::MessageLoop::GetCurrent().AddTaskObserver(key, handler); }; settings.task_observer_remove = [](intptr_t key) { @@ -318,17 +318,16 @@ fml::TimePoint ShellTest::GetLatestFrameTargetTime(Shell* shell) const { return shell->GetLatestFrameTargetTime(); } -std::unique_ptr ShellTest::CreateShell(Settings settings, +std::unique_ptr ShellTest::CreateShell(const Settings& settings, bool simulate_vsync) { - return CreateShell(std::move(settings), GetTaskRunnersForFixture(), - simulate_vsync); + return CreateShell(settings, GetTaskRunnersForFixture(), simulate_vsync); } std::unique_ptr ShellTest::CreateShell( - Settings settings, + const Settings& settings, TaskRunners task_runners, bool simulate_vsync, - std::shared_ptr + const std::shared_ptr& shell_test_external_view_embedder, bool is_gpu_disabled, ShellTestPlatformView::BackendType rendering_backend, @@ -354,7 +353,7 @@ std::unique_ptr ShellTest::CreateShell( return ShellTestPlatformView::Create(shell, // shell.GetTaskRunners(), // vsync_clock, // - std::move(create_vsync_waiter), // + create_vsync_waiter, // rendering_backend, // shell_test_external_view_embedder // ); @@ -378,7 +377,7 @@ void ShellTest::DestroyShell(std::unique_ptr shell) { } void ShellTest::DestroyShell(std::unique_ptr shell, - TaskRunners task_runners) { + const TaskRunners& task_runners) { fml::AutoResetWaitableEvent latch; fml::TaskRunner::RunNowOrPostTask(task_runners.GetPlatformTaskRunner(), [&shell, &latch]() mutable { @@ -389,10 +388,10 @@ void ShellTest::DestroyShell(std::unique_ptr shell, } size_t ShellTest::GetLiveTrackedPathCount( - std::shared_ptr tracker) { + const std::shared_ptr& tracker) { return std::count_if( tracker->paths_.begin(), tracker->paths_.end(), - [](std::weak_ptr path) { + [](const std::weak_ptr& path) { return path.lock(); }); } diff --git a/shell/common/shell_test.h b/shell/common/shell_test.h index 29c2da65b4a80..5dad608088c2c 100644 --- a/shell/common/shell_test.h +++ b/shell/common/shell_test.h @@ -34,13 +34,13 @@ class ShellTest : public FixtureTest { ShellTest(); Settings CreateSettingsForFixture() override; - std::unique_ptr CreateShell(Settings settings, + std::unique_ptr CreateShell(const Settings& settings, bool simulate_vsync = false); std::unique_ptr CreateShell( - Settings settings, + const Settings& settings, TaskRunners task_runners, bool simulate_vsync = false, - std::shared_ptr + const std::shared_ptr& shell_test_external_view_embedder = nullptr, bool is_gpu_disabled = false, ShellTestPlatformView::BackendType rendering_backend = @@ -48,7 +48,8 @@ class ShellTest : public FixtureTest { Shell::CreateCallback platform_view_create_callback = nullptr); void DestroyShell(std::unique_ptr shell); - void DestroyShell(std::unique_ptr shell, TaskRunners task_runners); + void DestroyShell(std::unique_ptr shell, + const TaskRunners& task_runners); TaskRunners GetTaskRunnersForFixture(); fml::TimePoint GetLatestFrameTargetTime(Shell* shell) const; @@ -80,7 +81,7 @@ class ShellTest : public FixtureTest { double height = 1, LayerTreeBuilder = {}); static void PumpOneFrame(Shell* shell, - flutter::ViewportMetrics viewport_metrics, + const flutter::ViewportMetrics& viewport_metrics, LayerTreeBuilder = {}); static void DispatchFakePointerData(Shell* shell); static void DispatchPointerData(Shell* shell, @@ -115,7 +116,7 @@ class ShellTest : public FixtureTest { static void OnServiceProtocol( Shell* shell, ServiceProtocolEnum some_protocol, - fml::RefPtr task_runner, + const fml::RefPtr& task_runner, const ServiceProtocol::Handler::ServiceProtocolMap& params, rapidjson::Document* response); @@ -127,7 +128,7 @@ class ShellTest : public FixtureTest { static int UnreportedTimingsCount(Shell* shell); static size_t GetLiveTrackedPathCount( - std::shared_ptr tracker); + const std::shared_ptr& tracker); private: ThreadHost thread_host_; diff --git a/shell/common/shell_test_platform_view.cc b/shell/common/shell_test_platform_view.cc index a0a75c4647573..7653b75a4d96a 100644 --- a/shell/common/shell_test_platform_view.cc +++ b/shell/common/shell_test_platform_view.cc @@ -19,11 +19,11 @@ namespace testing { std::unique_ptr ShellTestPlatformView::Create( PlatformView::Delegate& delegate, - TaskRunners task_runners, - std::shared_ptr vsync_clock, - CreateVsyncWaiter create_vsync_waiter, + const TaskRunners& task_runners, + const std::shared_ptr& vsync_clock, + const CreateVsyncWaiter& create_vsync_waiter, BackendType backend, - std::shared_ptr + const std::shared_ptr& shell_test_external_view_embedder) { // TODO(gw280): https://github.com/flutter/flutter/issues/50298 // Make this fully runtime configurable diff --git a/shell/common/shell_test_platform_view.h b/shell/common/shell_test_platform_view.h index 9ba69ec5bb53a..08a8baf3b43d6 100644 --- a/shell/common/shell_test_platform_view.h +++ b/shell/common/shell_test_platform_view.h @@ -23,11 +23,11 @@ class ShellTestPlatformView : public PlatformView { static std::unique_ptr Create( PlatformView::Delegate& delegate, - TaskRunners task_runners, - std::shared_ptr vsync_clock, - CreateVsyncWaiter create_vsync_waiter, + const TaskRunners& task_runners, + const std::shared_ptr& vsync_clock, + const CreateVsyncWaiter& create_vsync_waiter, BackendType backend, - std::shared_ptr + const std::shared_ptr& shell_test_external_view_embedder); virtual void SimulateVSync() = 0; diff --git a/shell/common/shell_test_platform_view_gl.cc b/shell/common/shell_test_platform_view_gl.cc index ac68ff3971d0b..98323108fac44 100644 --- a/shell/common/shell_test_platform_view_gl.cc +++ b/shell/common/shell_test_platform_view_gl.cc @@ -4,6 +4,8 @@ #include "flutter/shell/common/shell_test_platform_view_gl.h" +#include + #include "flutter/shell/gpu/gpu_surface_gl_skia.h" namespace flutter { @@ -11,16 +13,17 @@ namespace testing { ShellTestPlatformViewGL::ShellTestPlatformViewGL( PlatformView::Delegate& delegate, - TaskRunners task_runners, + const TaskRunners& task_runners, std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr shell_test_external_view_embedder) - : ShellTestPlatformView(delegate, std::move(task_runners)), + : ShellTestPlatformView(delegate, task_runners), gl_surface_(SkISize::Make(800, 600)), create_vsync_waiter_(std::move(create_vsync_waiter)), - vsync_clock_(vsync_clock), - shell_test_external_view_embedder_(shell_test_external_view_embedder) {} + vsync_clock_(std::move(vsync_clock)), + shell_test_external_view_embedder_( + std::move(shell_test_external_view_embedder)) {} ShellTestPlatformViewGL::~ShellTestPlatformViewGL() = default; diff --git a/shell/common/shell_test_platform_view_gl.h b/shell/common/shell_test_platform_view_gl.h index b4afc1266975b..4dca801da3c34 100644 --- a/shell/common/shell_test_platform_view_gl.h +++ b/shell/common/shell_test_platform_view_gl.h @@ -17,7 +17,7 @@ class ShellTestPlatformViewGL : public ShellTestPlatformView, public GPUSurfaceGLDelegate { public: ShellTestPlatformViewGL(PlatformView::Delegate& delegate, - TaskRunners task_runners, + const TaskRunners& task_runners, std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr diff --git a/shell/common/shell_test_platform_view_metal.h b/shell/common/shell_test_platform_view_metal.h index 319fa04f7a34a..be9dc9ebd4de2 100644 --- a/shell/common/shell_test_platform_view_metal.h +++ b/shell/common/shell_test_platform_view_metal.h @@ -18,7 +18,7 @@ class ShellTestPlatformViewMetal final : public ShellTestPlatformView, public GPUSurfaceMetalDelegate { public: ShellTestPlatformViewMetal(PlatformView::Delegate& delegate, - TaskRunners task_runners, + const TaskRunners& task_runners, std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr diff --git a/shell/common/shell_test_platform_view_metal.mm b/shell/common/shell_test_platform_view_metal.mm index f5ba212c6a837..42794260749d1 100644 --- a/shell/common/shell_test_platform_view_metal.mm +++ b/shell/common/shell_test_platform_view_metal.mm @@ -6,6 +6,8 @@ #import +#include + #include "flutter/fml/platform/darwin/scoped_nsobject.h" #include "flutter/shell/gpu/gpu_surface_metal_skia.h" #include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetal.h" @@ -53,16 +55,16 @@ GPUMTLTextureInfo offscreen_texture_info() const { ShellTestPlatformViewMetal::ShellTestPlatformViewMetal( PlatformView::Delegate& delegate, - TaskRunners task_runners, + const TaskRunners& task_runners, std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr shell_test_external_view_embedder) - : ShellTestPlatformView(delegate, std::move(task_runners)), + : ShellTestPlatformView(delegate, task_runners), GPUSurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), metal_context_(std::make_unique()), create_vsync_waiter_(std::move(create_vsync_waiter)), - vsync_clock_(vsync_clock), - shell_test_external_view_embedder_(shell_test_external_view_embedder) { + vsync_clock_(std::move(vsync_clock)), + shell_test_external_view_embedder_(std::move(shell_test_external_view_embedder)) { FML_CHECK([metal_context_->context() mainContext] != nil); } diff --git a/shell/common/shell_test_platform_view_vulkan.cc b/shell/common/shell_test_platform_view_vulkan.cc index a25c980e6ceee..eb70a26bcc6eb 100644 --- a/shell/common/shell_test_platform_view_vulkan.cc +++ b/shell/common/shell_test_platform_view_vulkan.cc @@ -4,6 +4,8 @@ #include "flutter/shell/common/shell_test_platform_view_vulkan.h" +#include + #include "flutter/common/graphics/persistent_cache.h" #include "flutter/shell/common/context_options.h" #include "flutter/vulkan/vulkan_utilities.h" @@ -23,16 +25,17 @@ namespace testing { ShellTestPlatformViewVulkan::ShellTestPlatformViewVulkan( PlatformView::Delegate& delegate, - TaskRunners task_runners, + const TaskRunners& task_runners, std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr shell_test_external_view_embedder) - : ShellTestPlatformView(delegate, std::move(task_runners)), + : ShellTestPlatformView(delegate, task_runners), create_vsync_waiter_(std::move(create_vsync_waiter)), - vsync_clock_(vsync_clock), + vsync_clock_(std::move(vsync_clock)), proc_table_(fml::MakeRefCounted(VULKAN_SO_PATH)), - shell_test_external_view_embedder_(shell_test_external_view_embedder) {} + shell_test_external_view_embedder_( + std::move(shell_test_external_view_embedder)) {} ShellTestPlatformViewVulkan::~ShellTestPlatformViewVulkan() = default; @@ -73,7 +76,8 @@ ShellTestPlatformViewVulkan::OffScreenSurface::OffScreenSurface( shell_test_external_view_embedder) : valid_(false), vk_(std::move(vk)), - shell_test_external_view_embedder_(shell_test_external_view_embedder) { + shell_test_external_view_embedder_( + std::move(shell_test_external_view_embedder)) { if (!vk_ || !vk_->HasAcquiredMandatoryProcAddresses()) { FML_DLOG(ERROR) << "Proc table has not acquired mandatory proc addresses."; return; @@ -192,9 +196,9 @@ ShellTestPlatformViewVulkan::OffScreenSurface::AcquireFrame( SurfaceFrame::FramebufferInfo framebuffer_info; framebuffer_info.supports_readback = true; - return std::make_unique( - std::move(surface), std::move(framebuffer_info), std::move(callback), - /*frame_size=*/SkISize::Make(800, 600)); + return std::make_unique(std::move(surface), framebuffer_info, + std::move(callback), + /*frame_size=*/SkISize::Make(800, 600)); } GrDirectContext* ShellTestPlatformViewVulkan::OffScreenSurface::GetContext() { diff --git a/shell/common/shell_test_platform_view_vulkan.h b/shell/common/shell_test_platform_view_vulkan.h index 5a3ea47b9dec6..724fe455639fc 100644 --- a/shell/common/shell_test_platform_view_vulkan.h +++ b/shell/common/shell_test_platform_view_vulkan.h @@ -17,7 +17,7 @@ namespace testing { class ShellTestPlatformViewVulkan : public ShellTestPlatformView { public: ShellTestPlatformViewVulkan(PlatformView::Delegate& delegate, - TaskRunners task_runners, + const TaskRunners& task_runners, std::shared_ptr vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index e85d2dcdb52a7..1780a9b7d53e0 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "assets/directory_asset_bundle.h" @@ -127,7 +128,8 @@ class MockSurface : public Surface { class MockPlatformView : public PlatformView { public: - MockPlatformView(MockPlatformViewDelegate& delegate, TaskRunners task_runners) + MockPlatformView(MockPlatformViewDelegate& delegate, + const TaskRunners& task_runners) : PlatformView(delegate, task_runners) {} MOCK_METHOD0(CreateRenderingSurface, std::unique_ptr()); MOCK_CONST_METHOD0(GetPlatformMessageHandler, @@ -136,7 +138,7 @@ class MockPlatformView : public PlatformView { class TestPlatformView : public PlatformView { public: - TestPlatformView(Shell& shell, TaskRunners task_runners) + TestPlatformView(Shell& shell, const TaskRunners& task_runners) : PlatformView(shell, task_runners) {} MOCK_METHOD0(CreateRenderingSurface, std::unique_ptr()); }; @@ -306,7 +308,7 @@ TEST_F(ShellTest, InitializeWithDifferentThreads) { auto shell = CreateShell(settings, task_runners); ASSERT_TRUE(ValidateShell(shell.get())); ASSERT_TRUE(DartVMRef::IsInstanceRunning()); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -321,7 +323,7 @@ TEST_F(ShellTest, InitializeWithSingleThread) { auto shell = CreateShell(settings, task_runners); ASSERT_TRUE(DartVMRef::IsInstanceRunning()); ASSERT_TRUE(ValidateShell(shell.get())); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -335,7 +337,7 @@ TEST_F(ShellTest, InitializeWithSingleThreadWhichIsTheCallingThread) { auto shell = CreateShell(settings, task_runners); ASSERT_TRUE(ValidateShell(shell.get())); ASSERT_TRUE(DartVMRef::IsInstanceRunning()); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -369,7 +371,7 @@ TEST_F(ShellTest, [](Shell& shell) { return std::make_unique(shell); }); ASSERT_TRUE(ValidateShell(shell.get())); ASSERT_TRUE(DartVMRef::IsInstanceRunning()); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -392,7 +394,7 @@ TEST_F(ShellTest, InitializeWithDisabledGpu) { fml::SyncSwitch::Handlers().SetIfTrue([&] { is_disabled = true; })); ASSERT_TRUE(is_disabled); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -412,7 +414,7 @@ TEST_F(ShellTest, InitializeWithGPUAndPlatformThreadsTheSame) { auto shell = CreateShell(settings, task_runners); ASSERT_TRUE(DartVMRef::IsInstanceRunning()); ASSERT_TRUE(ValidateShell(shell.get())); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -739,7 +741,7 @@ TEST_F(ShellTest, ExternalEmbedderNoThreadMerger) { bool end_frame_called = false; auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { ASSERT_TRUE(raster_thread_merger.get() == nullptr); ASSERT_FALSE(should_resubmit_frame); end_frame_called = true; @@ -758,7 +760,7 @@ TEST_F(ShellTest, ExternalEmbedderNoThreadMerger) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -793,9 +795,10 @@ TEST_F(ShellTest, PushBackdropFilterToVisitedPlatformViews) { MutatorsStack stack_75; auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { - if (end_frame_called) + const fml::RefPtr& raster_thread_merger) { + if (end_frame_called) { return; + } ASSERT_TRUE(raster_thread_merger.get() == nullptr); ASSERT_FALSE(should_resubmit_frame); end_frame_called = true; @@ -819,7 +822,7 @@ TEST_F(ShellTest, PushBackdropFilterToVisitedPlatformViews) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { auto platform_view_layer = std::make_shared( SkPoint::Make(10, 10), SkSize::Make(10, 10), 50); root->Add(platform_view_layer); @@ -859,7 +862,7 @@ TEST_F(ShellTest, bool end_frame_called = false; auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { ASSERT_TRUE(raster_thread_merger.get() != nullptr); ASSERT_TRUE(should_resubmit_frame); end_frame_called = true; @@ -878,7 +881,7 @@ TEST_F(ShellTest, RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -908,7 +911,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyDisablesThreadMerger) { auto end_frame_callback = [&](bool should_resubmit_frame, fml::RefPtr thread_merger) { - raster_thread_merger = thread_merger; + raster_thread_merger = std::move(thread_merger); }; auto external_view_embedder = std::make_shared( end_frame_callback, PostPrerollResult::kSuccess, true); @@ -924,7 +927,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyDisablesThreadMerger) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -965,7 +968,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyAfterMergingThreads) { auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { if (should_resubmit_frame && !raster_thread_merger->IsMerged()) { raster_thread_merger->MergeWithLease(ThreadMergingLease); @@ -991,7 +994,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyAfterMergingThreads) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -1037,7 +1040,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWhenThreadsAreMerging) { fml::AutoResetWaitableEvent end_frame_latch; auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { if (should_resubmit_frame && !raster_thread_merger->IsMerged()) { raster_thread_merger->MergeWithLease(kThreadMergingLease); } @@ -1060,7 +1063,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWhenThreadsAreMerging) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -1112,7 +1115,7 @@ TEST_F(ShellTest, fml::AutoResetWaitableEvent end_frame_latch; auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { end_frame_latch.Signal(); }; auto external_view_embedder = std::make_shared( @@ -1128,7 +1131,7 @@ TEST_F(ShellTest, RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -1172,7 +1175,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWithoutRasterThreadMerger) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -1212,7 +1215,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWithStaticThreadMerging) { fml::AutoResetWaitableEvent end_frame_latch; auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { end_frame_latch.Signal(); }; auto external_view_embedder = std::make_shared( @@ -1238,7 +1241,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWithStaticThreadMerging) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -1256,7 +1259,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWithStaticThreadMerging) { // Validate the platform view can be recreated and destroyed again ValidateShell(shell.get()); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, GetUsedThisFrameShouldBeSetBeforeEndFrame) { @@ -1266,7 +1269,7 @@ TEST_F(ShellTest, GetUsedThisFrameShouldBeSetBeforeEndFrame) { bool used_this_frame = true; auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { // We expect `used_this_frame` to be false. used_this_frame = external_view_embedder->GetUsedThisFrame(); end_frame_latch.Signal(); @@ -1284,7 +1287,7 @@ TEST_F(ShellTest, GetUsedThisFrameShouldBeSetBeforeEndFrame) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -1318,7 +1321,7 @@ TEST_F(ShellTest, DISABLED_SkipAndSubmitFrame) { auto end_frame_callback = [&](bool should_resubmit_frame, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { if (should_resubmit_frame && !raster_thread_merger->IsMerged()) { raster_thread_merger->MergeWithLease(10); external_view_embedder->UpdatePostPrerollResult( @@ -1543,7 +1546,7 @@ TEST_F(ShellTest, WaitForFirstFrameInlined) { }); ASSERT_FALSE(event.WaitWithTimeout(fml::TimeDelta::Max())); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } static size_t GetRasterizerResourceCacheBytesSync(const Shell& shell) { @@ -1679,7 +1682,7 @@ TEST_F(ShellTest, MultipleFluttersSetResourceCacheBytes) { static_cast(960000U)); DestroyShell(std::move(second_shell), task_runners); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, SetResourceCacheSize) { @@ -1738,7 +1741,7 @@ TEST_F(ShellTest, SetResourceCacheSize) { PumpOneFrame(shell.get()); EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell), 10000U); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, SetResourceCacheSizeEarly) { @@ -1765,7 +1768,7 @@ TEST_F(ShellTest, SetResourceCacheSizeEarly) { EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell), static_cast(3840000U)); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, SetResourceCacheSizeNotifiesDart) { @@ -1802,7 +1805,7 @@ TEST_F(ShellTest, SetResourceCacheSizeNotifiesDart) { EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell), static_cast(10000U)); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, CanCreateImagefromDecompressedBytes) { @@ -1835,14 +1838,14 @@ TEST_F(ShellTest, CanCreateImagefromDecompressedBytes) { RunEngine(shell.get(), std::move(configuration)); latch.Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } class MockTexture : public Texture { public: MockTexture(int64_t textureId, std::shared_ptr latch) - : Texture(textureId), latch_(latch) {} + : Texture(textureId), latch_(std::move(latch)) {} ~MockTexture() override = default; @@ -1911,7 +1914,7 @@ TEST_F(ShellTest, TextureFrameMarkedAvailableAndUnregister) { latch->Wait(); EXPECT_EQ(mockTexture->unregistered(), true); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, IsolateCanAccessPersistentIsolateData) { @@ -1949,7 +1952,7 @@ TEST_F(ShellTest, IsolateCanAccessPersistentIsolateData) { }); message_latch.Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, CanScheduleFrameFromPlatform) { @@ -1978,7 +1981,7 @@ TEST_F(ShellTest, CanScheduleFrameFromPlatform) { shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() { shell->GetPlatformView()->ScheduleFrame(); }); check_latch.Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, SecondaryVsyncCallbackShouldBeCalledAfterVsyncCallback) { @@ -2021,10 +2024,10 @@ TEST_F(ShellTest, SecondaryVsyncCallbackShouldBeCalledAfterVsyncCallback) { count_down_latch.Wait(); EXPECT_TRUE(is_on_begin_frame_called); EXPECT_TRUE(is_secondary_callback_called); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } -static void LogSkData(sk_sp data, const char* title) { +static void LogSkData(const sk_sp& data, const char* title) { FML_LOG(ERROR) << "---------- " << title; std::ostringstream ostr; for (size_t i = 0; i < data->size();) { @@ -2055,7 +2058,7 @@ TEST_F(ShellTest, Screenshot) { RunEngine(shell.get(), std::move(configuration)); - LayerTreeBuilder builder = [&](std::shared_ptr root) { + LayerTreeBuilder builder = [&](const std::shared_ptr& root) { fml::RefPtr queue = fml::MakeRefCounted( this->GetCurrentTaskRunner(), fml::TimeDelta::Zero()); auto display_list_layer = std::make_shared( @@ -2282,7 +2285,7 @@ TEST_F(ShellTest, CanRegisterImageDecoders) { fml::TaskRunner::RunNowOrPostTask( shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() { shell->RegisterImageDecoder( - [](sk_sp buffer) { + [](const sk_sp& buffer) { return std::make_unique(); }, 100); @@ -2374,7 +2377,7 @@ TEST_F(ShellTest, RasterizerScreenshot) { latch->Signal(); }); latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, RasterizerMakeRasterSnapshot) { @@ -2405,7 +2408,7 @@ TEST_F(ShellTest, RasterizerMakeRasterSnapshot) { latch->Signal(); }); latch->Wait(); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, OnServiceProtocolEstimateRasterCacheMemoryWorks) { @@ -2577,7 +2580,7 @@ TEST_F(ShellTest, DISABLED_DiscardLayerTreeOnResize) { fml::AutoResetWaitableEvent end_frame_latch; auto end_frame_callback = [&](bool should_merge_thread, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { end_frame_latch.Signal(); }; auto external_view_embedder = std::make_shared( @@ -2636,7 +2639,7 @@ TEST_F(ShellTest, DISABLED_DiscardResubmittedLayerTreeOnResize) { fml::RefPtr raster_thread_merger_ref; auto end_frame_callback = [&](bool should_merge_thread, - fml::RefPtr raster_thread_merger) { + const fml::RefPtr& raster_thread_merger) { if (!raster_thread_merger_ref) { raster_thread_merger_ref = raster_thread_merger; } @@ -2773,7 +2776,7 @@ TEST_F(ShellTest, IgnoresInvalidMetrics) { ASSERT_EQ(last_width, 600.0); ASSERT_EQ(last_height, 300.0); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); } TEST_F(ShellTest, OnServiceProtocolSetAssetBundlePathWorks) { @@ -3373,7 +3376,7 @@ TEST_F(ShellTest, UpdateAssetResolverByTypeReplaces) { ASSERT_FALSE(resolvers[1]->IsValidAfterAssetManagerChange()); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -3413,7 +3416,7 @@ TEST_F(ShellTest, UpdateAssetResolverByTypeAppends) { ASSERT_FALSE(resolvers[1]->IsValidAfterAssetManagerChange()); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -3444,14 +3447,14 @@ TEST_F(ShellTest, UpdateAssetResolverByTypeNull) { asset_manager->PushBack(std::move(old_resolver)); platform_view->UpdateAssetResolverByType( - std::move(nullptr), AssetResolver::AssetResolverType::kApkAssetProvider); + nullptr, AssetResolver::AssetResolverType::kApkAssetProvider); auto resolvers = asset_manager->TakeResolvers(); ASSERT_EQ(resolvers.size(), 2ull); ASSERT_TRUE(resolvers[0]->IsValidAfterAssetManagerChange()); ASSERT_TRUE(resolvers[1]->IsValidAfterAssetManagerChange()); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -3498,7 +3501,7 @@ TEST_F(ShellTest, UpdateAssetResolverByTypeDoesNotReplaceMismatchType) { ASSERT_FALSE(resolvers[2]->IsValidAfterAssetManagerChange()); - DestroyShell(std::move(shell), std::move(task_runners)); + DestroyShell(std::move(shell), task_runners); ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } @@ -3728,7 +3731,7 @@ TEST_F(ShellTest, UsesPlatformMessageHandler) { return result; }; auto shell = CreateShell( - /*settings=*/std::move(settings), + /*settings=*/settings, /*task_runners=*/task_runners, /*simulate_vsync=*/false, /*shell_test_external_view_embedder=*/nullptr, diff --git a/shell/common/switches.cc b/shell/common/switches.cc index b3ce13c7da3af..1d518824aa819 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -199,8 +199,9 @@ static bool GetSwitchValue(const fml::CommandLine& command_line, return false; } -std::unique_ptr GetSymbolMapping(std::string symbol_prefix, - std::string native_lib_path) { +std::unique_ptr GetSymbolMapping( + const std::string& symbol_prefix, + const std::string& native_lib_path) { const uint8_t* mapping = nullptr; intptr_t size; diff --git a/shell/common/thread_host.cc b/shell/common/thread_host.cc index 7da4ec979ee20..e1edd2bd5ccbe 100644 --- a/shell/common/thread_host.cc +++ b/shell/common/thread_host.cc @@ -73,7 +73,7 @@ ThreadHost::ThreadHost() = default; ThreadHost::ThreadHost(ThreadHost&&) = default; -ThreadHost::ThreadHost(const std::string name_prefix, uint64_t mask) +ThreadHost::ThreadHost(const std::string& name_prefix, uint64_t mask) : ThreadHost(ThreadHostConfig(name_prefix, mask)) {} ThreadHost::ThreadHost(const ThreadHostConfig& host_config) diff --git a/shell/common/thread_host.h b/shell/common/thread_host.h index b79d015d22f46..cc423cd027b1d 100644 --- a/shell/common/thread_host.h +++ b/shell/common/thread_host.h @@ -92,7 +92,7 @@ struct ThreadHost { ThreadHost& operator=(ThreadHost&&) = default; - ThreadHost(const std::string name_prefix, uint64_t mask); + ThreadHost(const std::string& name_prefix, uint64_t mask); explicit ThreadHost(const ThreadHostConfig& host_config); diff --git a/shell/common/variable_refresh_rate_display.cc b/shell/common/variable_refresh_rate_display.cc index 6fda9cde450e0..d51af1a08a724 100644 --- a/shell/common/variable_refresh_rate_display.cc +++ b/shell/common/variable_refresh_rate_display.cc @@ -18,12 +18,12 @@ namespace flutter { VariableRefreshRateDisplay::VariableRefreshRateDisplay( DisplayId display_id, - const std::weak_ptr refresh_rate_reporter) + const std::weak_ptr& refresh_rate_reporter) : Display(display_id, GetInitialRefreshRate(refresh_rate_reporter)), refresh_rate_reporter_(refresh_rate_reporter) {} VariableRefreshRateDisplay::VariableRefreshRateDisplay( - const std::weak_ptr refresh_rate_reporter) + const std::weak_ptr& refresh_rate_reporter) : Display(GetInitialRefreshRate(refresh_rate_reporter)), refresh_rate_reporter_(refresh_rate_reporter) {} diff --git a/shell/common/variable_refresh_rate_display.h b/shell/common/variable_refresh_rate_display.h index b26f1014bcc11..38cb979c36926 100644 --- a/shell/common/variable_refresh_rate_display.h +++ b/shell/common/variable_refresh_rate_display.h @@ -18,9 +18,9 @@ class VariableRefreshRateDisplay : public Display { public: explicit VariableRefreshRateDisplay( DisplayId display_id, - const std::weak_ptr refresh_rate_reporter); + const std::weak_ptr& refresh_rate_reporter); explicit VariableRefreshRateDisplay( - const std::weak_ptr refresh_rate_reporter); + const std::weak_ptr& refresh_rate_reporter); ~VariableRefreshRateDisplay() = default; // |Display| diff --git a/shell/common/vsync_waiter.cc b/shell/common/vsync_waiter.cc index e787b0384d927..db9d5389f2758 100644 --- a/shell/common/vsync_waiter.cc +++ b/shell/common/vsync_waiter.cc @@ -18,8 +18,8 @@ static constexpr const char* kVsyncFlowName = "VsyncFlow"; static constexpr const char* kVsyncTraceName = "VsyncProcessCallback"; -VsyncWaiter::VsyncWaiter(TaskRunners task_runners) - : task_runners_(std::move(task_runners)) {} +VsyncWaiter::VsyncWaiter(const TaskRunners& task_runners) + : task_runners_(task_runners) {} VsyncWaiter::~VsyncWaiter() = default; @@ -40,7 +40,7 @@ void VsyncWaiter::AsyncWaitForVsync(const Callback& callback) { TRACE_EVENT_INSTANT0("flutter", "MultipleCallsToVsyncInFrameInterval"); return; } - callback_ = std::move(callback); + callback_ = callback; if (!secondary_callbacks_.empty()) { // Return directly as `AwaitVSync` is already called by // `ScheduleSecondaryCallback`. @@ -62,7 +62,7 @@ void VsyncWaiter::ScheduleSecondaryCallback(uintptr_t id, { std::scoped_lock lock(callback_mutex_); - auto [_, inserted] = secondary_callbacks_.emplace(id, std::move(callback)); + auto [_, inserted] = secondary_callbacks_.emplace(id, callback); if (!inserted) { // Multiple schedules must result in a single callback per frame interval. TRACE_EVENT_INSTANT0("flutter", @@ -138,7 +138,7 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time, } for (auto& secondary_callback : secondary_callbacks) { - task_runners_.GetUITaskRunner()->PostTask(std::move(secondary_callback)); + task_runners_.GetUITaskRunner()->PostTask(secondary_callback); } } diff --git a/shell/common/vsync_waiter.h b/shell/common/vsync_waiter.h index b381f432a9bca..df70342c399e4 100644 --- a/shell/common/vsync_waiter.h +++ b/shell/common/vsync_waiter.h @@ -40,7 +40,7 @@ class VsyncWaiter : public std::enable_shared_from_this { const TaskRunners task_runners_; - explicit VsyncWaiter(TaskRunners task_runners); + explicit VsyncWaiter(const TaskRunners& task_runners); // There are two distinct situations where VsyncWaiter wishes to awaken at // the next vsync. Although the functionality can be the same, the intent is diff --git a/shell/common/vsync_waiter_fallback.cc b/shell/common/vsync_waiter_fallback.cc index cb042c5e082e6..89c3fb0c805fc 100644 --- a/shell/common/vsync_waiter_fallback.cc +++ b/shell/common/vsync_waiter_fallback.cc @@ -25,9 +25,9 @@ static fml::TimePoint SnapToNextTick(fml::TimePoint value, } // namespace -VsyncWaiterFallback::VsyncWaiterFallback(TaskRunners task_runners, +VsyncWaiterFallback::VsyncWaiterFallback(const TaskRunners& task_runners, bool for_testing) - : VsyncWaiter(std::move(task_runners)), + : VsyncWaiter(task_runners), phase_(fml::TimePoint::Now()), for_testing_(for_testing) {} diff --git a/shell/common/vsync_waiter_fallback.h b/shell/common/vsync_waiter_fallback.h index b2ae63f72045b..b2a6ccfed05bf 100644 --- a/shell/common/vsync_waiter_fallback.h +++ b/shell/common/vsync_waiter_fallback.h @@ -15,7 +15,7 @@ namespace flutter { /// A |VsyncWaiter| that will fire at 60 fps irrespective of the vsync. class VsyncWaiterFallback final : public VsyncWaiter { public: - explicit VsyncWaiterFallback(TaskRunners task_runners, + explicit VsyncWaiterFallback(const TaskRunners& task_runners, bool for_testing = false); ~VsyncWaiterFallback() override; diff --git a/shell/gpu/gpu_surface_gl_delegate.cc b/shell/gpu/gpu_surface_gl_delegate.cc index 2aea45cf21d52..2e737f03a9b6d 100644 --- a/shell/gpu/gpu_surface_gl_delegate.cc +++ b/shell/gpu/gpu_surface_gl_delegate.cc @@ -35,7 +35,7 @@ GPUSurfaceGLDelegate::GLProcResolver GPUSurfaceGLDelegate::GetGLProcResolver() } static bool IsProcResolverOpenGLES( - GPUSurfaceGLDelegate::GLProcResolver proc_resolver) { + const GPUSurfaceGLDelegate::GLProcResolver& proc_resolver) { // Version string prefix that identifies an OpenGL ES implementation. #define GPU_GL_VERSION 0x1F02 constexpr char kGLESVersionPrefix[] = "OpenGL ES"; @@ -62,7 +62,7 @@ static bool IsProcResolverOpenGLES( } static sk_sp CreateGLInterface( - GPUSurfaceGLDelegate::GLProcResolver proc_resolver) { + const GPUSurfaceGLDelegate::GLProcResolver& proc_resolver) { if (proc_resolver == nullptr) { // If there is no custom proc resolver, ask Skia to guess the native // interface. This often leads to interesting results on most platforms. diff --git a/shell/gpu/gpu_surface_gl_skia.cc b/shell/gpu/gpu_surface_gl_skia.cc index c377e87cddb19..01be975ee831a 100644 --- a/shell/gpu/gpu_surface_gl_skia.cc +++ b/shell/gpu/gpu_surface_gl_skia.cc @@ -68,7 +68,7 @@ GPUSurfaceGLSkia::GPUSurfaceGLSkia(GPUSurfaceGLDelegate* delegate, context_owner_ = true; } -GPUSurfaceGLSkia::GPUSurfaceGLSkia(sk_sp gr_context, +GPUSurfaceGLSkia::GPUSurfaceGLSkia(const sk_sp& gr_context, GPUSurfaceGLDelegate* delegate, bool render_to_surface) : delegate_(delegate), @@ -226,7 +226,7 @@ std::unique_ptr GPUSurfaceGLSkia::AcquireFrame( if (!render_to_surface_) { framebuffer_info.supports_readback = true; return std::make_unique( - nullptr, std::move(framebuffer_info), + nullptr, framebuffer_info, [](const SurfaceFrame& surface_frame, SkCanvas* canvas) { return true; }, @@ -253,7 +253,7 @@ std::unique_ptr GPUSurfaceGLSkia::AcquireFrame( if (!framebuffer_info.existing_damage.has_value()) { framebuffer_info.existing_damage = existing_damage_; } - return std::make_unique(surface, std::move(framebuffer_info), + return std::make_unique(surface, framebuffer_info, submit_callback, size, std::move(context_switch)); } diff --git a/shell/gpu/gpu_surface_gl_skia.h b/shell/gpu/gpu_surface_gl_skia.h index 35caee497eb6f..9b2cac089f8ed 100644 --- a/shell/gpu/gpu_surface_gl_skia.h +++ b/shell/gpu/gpu_surface_gl_skia.h @@ -25,7 +25,7 @@ class GPUSurfaceGLSkia : public Surface { GPUSurfaceGLSkia(GPUSurfaceGLDelegate* delegate, bool render_to_surface); // Creates a new GL surface reusing an existing GrDirectContext. - GPUSurfaceGLSkia(sk_sp gr_context, + GPUSurfaceGLSkia(const sk_sp& gr_context, GPUSurfaceGLDelegate* delegate, bool render_to_surface); diff --git a/shell/gpu/gpu_surface_metal_skia.mm b/shell/gpu/gpu_surface_metal_skia.mm index 7acfb1f6051d0..8e92d81ae27c8 100644 --- a/shell/gpu/gpu_surface_metal_skia.mm +++ b/shell/gpu/gpu_surface_metal_skia.mm @@ -7,6 +7,8 @@ #import #import +#include + #include "flutter/common/graphics/persistent_cache.h" #include "flutter/fml/make_copyable.h" #include "flutter/fml/platform/darwin/cf_utils.h" @@ -41,8 +43,8 @@ info.fTexture.reset([texture retain]); GrBackendTexture backend_texture(texture.width, texture.height, GrMipmapped::kNo, info); return SkSurface::MakeFromBackendTexture(context, backend_texture, origin, - static_cast(sample_cnt), color_type, color_space, - props); + static_cast(sample_cnt), color_type, + std::move(color_space), props); } } // namespace @@ -229,8 +231,8 @@ SurfaceFrame::FramebufferInfo framebuffer_info; framebuffer_info.supports_readback = true; - return std::make_unique(std::move(surface), std::move(framebuffer_info), - submit_callback, frame_info); + return std::make_unique(std::move(surface), framebuffer_info, submit_callback, + frame_info); } // |Surface| diff --git a/shell/gpu/gpu_surface_software.cc b/shell/gpu/gpu_surface_software.cc index babf988fa2039..862cb7d3e9694 100644 --- a/shell/gpu/gpu_surface_software.cc +++ b/shell/gpu/gpu_surface_software.cc @@ -32,7 +32,7 @@ std::unique_ptr GPUSurfaceSoftware::AcquireFrame( // external view embedder may want to render to the root surface. if (!render_to_surface_) { return std::make_unique( - nullptr, std::move(framebuffer_info), + nullptr, framebuffer_info, [](const SurfaceFrame& surface_frame, SkCanvas* canvas) { return true; }, @@ -74,8 +74,8 @@ std::unique_ptr GPUSurfaceSoftware::AcquireFrame( return self->delegate_->PresentBackingStore(surface_frame.SkiaSurface()); }; - return std::make_unique( - backing_store, std::move(framebuffer_info), on_submit, logical_size); + return std::make_unique(backing_store, framebuffer_info, + on_submit, logical_size); } // |Surface| diff --git a/shell/gpu/gpu_surface_vulkan.cc b/shell/gpu/gpu_surface_vulkan.cc index afe458ac7fa46..ba8383c1343cf 100644 --- a/shell/gpu/gpu_surface_vulkan.cc +++ b/shell/gpu/gpu_surface_vulkan.cc @@ -78,8 +78,7 @@ std::unique_ptr GPUSurfaceVulkan::AcquireFrame( SurfaceFrame::FramebufferInfo framebuffer_info{.supports_readback = true}; - return std::make_unique(std::move(surface), - std::move(framebuffer_info), + return std::make_unique(std::move(surface), framebuffer_info, std::move(callback), frame_size); } diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.cc b/shell/platform/android/external_view_embedder/external_view_embedder.cc index 3545cb1453dce..c1054c78b9ee6 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder.cc @@ -4,6 +4,8 @@ #include "flutter/shell/platform/android/external_view_embedder/external_view_embedder.h" +#include + #include "flutter/fml/synchronization/waitable_event.h" #include "flutter/fml/task_runner.h" #include "flutter/fml/trace_event.h" @@ -15,11 +17,11 @@ AndroidExternalViewEmbedder::AndroidExternalViewEmbedder( const AndroidContext& android_context, std::shared_ptr jni_facade, std::shared_ptr surface_factory, - TaskRunners task_runners) + const TaskRunners& task_runners) : ExternalViewEmbedder(), android_context_(android_context), - jni_facade_(jni_facade), - surface_factory_(surface_factory), + jni_facade_(std::move(jni_facade)), + surface_factory_(std::move(surface_factory)), surface_pool_(std::make_unique()), task_runners_(task_runners) {} diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.h b/shell/platform/android/external_view_embedder/external_view_embedder.h index 5bae7a4e1c9e7..0b258854408d6 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.h +++ b/shell/platform/android/external_view_embedder/external_view_embedder.h @@ -34,7 +34,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { const AndroidContext& android_context, std::shared_ptr jni_facade, std::shared_ptr surface_factory, - TaskRunners task_runners); + const TaskRunners& task_runners); // |ExternalViewEmbedder| void PrerollCompositeEmbeddedView( diff --git a/shell/platform/android/external_view_embedder/surface_pool.cc b/shell/platform/android/external_view_embedder/surface_pool.cc index 3941ce48ebb88..6e71e97247c9b 100644 --- a/shell/platform/android/external_view_embedder/surface_pool.cc +++ b/shell/platform/android/external_view_embedder/surface_pool.cc @@ -4,6 +4,8 @@ #include "flutter/shell/platform/android/external_view_embedder/surface_pool.h" +#include + namespace flutter { OverlayLayer::OverlayLayer(int id, @@ -22,8 +24,8 @@ SurfacePool::~SurfacePool() = default; std::shared_ptr SurfacePool::GetLayer( GrDirectContext* gr_context, const AndroidContext& android_context, - std::shared_ptr jni_facade, - std::shared_ptr surface_factory) { + const std::shared_ptr& jni_facade, + const std::shared_ptr& surface_factory) { std::lock_guard lock(mutex_); // Destroy current layers in the pool if the frame size has changed. if (requested_frame_size_ != current_frame_size_) { @@ -84,13 +86,13 @@ bool SurfacePool::HasLayers() { } void SurfacePool::DestroyLayers( - std::shared_ptr jni_facade) { + const std::shared_ptr& jni_facade) { std::lock_guard lock(mutex_); DestroyLayersLocked(jni_facade); } void SurfacePool::DestroyLayersLocked( - std::shared_ptr jni_facade) { + const std::shared_ptr& jni_facade) { if (layers_.empty()) { return; } diff --git a/shell/platform/android/external_view_embedder/surface_pool.h b/shell/platform/android/external_view_embedder/surface_pool.h index 341cc819a4af3..5f09d6db916d5 100644 --- a/shell/platform/android/external_view_embedder/surface_pool.h +++ b/shell/platform/android/external_view_embedder/surface_pool.h @@ -55,8 +55,8 @@ class SurfacePool { std::shared_ptr GetLayer( GrDirectContext* gr_context, const AndroidContext& android_context, - std::shared_ptr jni_facade, - std::shared_ptr surface_factory); + const std::shared_ptr& jni_facade, + const std::shared_ptr& surface_factory); // Gets the layers in the pool that aren't currently used. // This method doesn't mark the layers as unused. @@ -66,7 +66,7 @@ class SurfacePool { void RecycleLayers(); // Destroys all the layers in the pool. - void DestroyLayers(std::shared_ptr jni_facade); + void DestroyLayers(const std::shared_ptr& jni_facade); // Sets the frame size used by the layers in the pool. // If the current layers in the pool have a different frame size, @@ -103,7 +103,8 @@ class SurfacePool { // Used to guard public methods. std::mutex mutex_; - void DestroyLayersLocked(std::shared_ptr jni_facade); + void DestroyLayersLocked( + const std::shared_ptr& jni_facade); }; } // namespace flutter diff --git a/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc b/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc index 5509d02a022e5..aaebecc618c34 100644 --- a/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc +++ b/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc @@ -4,6 +4,8 @@ #include "flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.h" +#include + namespace flutter { void putStringAttributesIntoBuffer( @@ -37,11 +39,11 @@ void putStringAttributesIntoBuffer( PlatformViewAndroidDelegate::PlatformViewAndroidDelegate( std::shared_ptr jni_facade) - : jni_facade_(jni_facade){}; + : jni_facade_(std::move(jni_facade)){}; void PlatformViewAndroidDelegate::UpdateSemantics( - flutter::SemanticsNodeUpdates update, - flutter::CustomAccessibilityActionUpdates actions) { + const flutter::SemanticsNodeUpdates& update, + const flutter::CustomAccessibilityActionUpdates& actions) { constexpr size_t kBytesPerNode = 47 * sizeof(int32_t); constexpr size_t kBytesPerChild = sizeof(int32_t); constexpr size_t kBytesPerCustomAction = sizeof(int32_t); diff --git a/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.h b/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.h index e1e55a2300e20..6e4b18de19ff0 100644 --- a/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.h +++ b/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.h @@ -18,8 +18,9 @@ class PlatformViewAndroidDelegate { public: explicit PlatformViewAndroidDelegate( std::shared_ptr jni_facade); - void UpdateSemantics(flutter::SemanticsNodeUpdates update, - flutter::CustomAccessibilityActionUpdates actions); + void UpdateSemantics( + const flutter::SemanticsNodeUpdates& update, + const flutter::CustomAccessibilityActionUpdates& actions); private: const std::shared_ptr jni_facade_; diff --git a/shell/platform/common/accessibility_bridge.cc b/shell/platform/common/accessibility_bridge.cc index 3ec39b9f5ea9b..d0f19089dd86f 100644 --- a/shell/platform/common/accessibility_bridge.cc +++ b/shell/platform/common/accessibility_bridge.cc @@ -257,7 +257,7 @@ AccessibilityBridge::CreateRemoveReparentedNodesUpdate() { } // Private method. -void AccessibilityBridge::GetSubTreeList(SemanticsNode target, +void AccessibilityBridge::GetSubTreeList(const SemanticsNode& target, std::vector& result) { result.push_back(target); for (int32_t child : target.children_in_traversal_order) { diff --git a/shell/platform/common/accessibility_bridge.h b/shell/platform/common/accessibility_bridge.h index 9c4cc9919b81d..70fcd20c3d2f7 100644 --- a/shell/platform/common/accessibility_bridge.h +++ b/shell/platform/common/accessibility_bridge.h @@ -227,7 +227,8 @@ class AccessibilityBridge // pending_semantics_updates_. Returns std::nullopt if none are reparented. std::optional CreateRemoveReparentedNodesUpdate(); - void GetSubTreeList(SemanticsNode target, std::vector& result); + void GetSubTreeList(const SemanticsNode& target, + std::vector& result); void ConvertFlutterUpdate(const SemanticsNode& node, ui::AXTreeUpdate& tree_update); void SetRoleFromFlutterUpdate(ui::AXNodeData& node_data, diff --git a/shell/platform/common/client_wrapper/plugin_registrar_unittests.cc b/shell/platform/common/client_wrapper/plugin_registrar_unittests.cc index c18459a07490f..1884c6488718b 100644 --- a/shell/platform/common/client_wrapper/plugin_registrar_unittests.cc +++ b/shell/platform/common/client_wrapper/plugin_registrar_unittests.cc @@ -146,7 +146,7 @@ TEST(PluginRegistrarTest, MessengerSetMessageHandler) { // Register. BinaryMessageHandler binary_handler = [](const uint8_t* message, const size_t message_size, - BinaryReply reply) {}; + const BinaryReply& reply) {}; messenger->SetMessageHandler(channel_name, std::move(binary_handler)); EXPECT_NE(test_api->last_message_callback_set(), nullptr); diff --git a/shell/platform/common/client_wrapper/standard_message_codec_unittests.cc b/shell/platform/common/client_wrapper/standard_message_codec_unittests.cc index dd30f0e8f6a01..df02aae2e77f9 100644 --- a/shell/platform/common/client_wrapper/standard_message_codec_unittests.cc +++ b/shell/platform/common/client_wrapper/standard_message_codec_unittests.cc @@ -35,7 +35,7 @@ static void CheckEncodeDecode( const EncodableValue& value, const std::vector& expected_encoding, const StandardCodecSerializer* serializer = nullptr, - std::function + const std::function& custom_comparator = nullptr) { const StandardMessageCodec& codec = StandardMessageCodec::GetInstance(serializer); diff --git a/shell/platform/common/flutter_platform_node_delegate.cc b/shell/platform/common/flutter_platform_node_delegate.cc index 8f636909a243d..cf5464fc861ba 100644 --- a/shell/platform/common/flutter_platform_node_delegate.cc +++ b/shell/platform/common/flutter_platform_node_delegate.cc @@ -4,6 +4,8 @@ #include "flutter_platform_node_delegate.h" +#include + #include "flutter/third_party/accessibility/ax/ax_action_data.h" #include "flutter/third_party/accessibility/gfx/geometry/rect_conversions.h" @@ -15,7 +17,7 @@ FlutterPlatformNodeDelegate::~FlutterPlatformNodeDelegate() = default; void FlutterPlatformNodeDelegate::Init(std::weak_ptr bridge, ui::AXNode* node) { - bridge_ = bridge; + bridge_ = std::move(bridge); ax_node_ = node; } diff --git a/shell/platform/common/text_editing_delta.cc b/shell/platform/common/text_editing_delta.cc index 2c89a2cd5ef31..600c292802187 100644 --- a/shell/platform/common/text_editing_delta.cc +++ b/shell/platform/common/text_editing_delta.cc @@ -9,7 +9,7 @@ namespace flutter { TextEditingDelta::TextEditingDelta(const std::u16string& text_before_change, - TextRange range, + const TextRange& range, const std::u16string& text) : old_text_(text_before_change), delta_text_(text), @@ -17,7 +17,7 @@ TextEditingDelta::TextEditingDelta(const std::u16string& text_before_change, delta_end_(range.start() + range.length()) {} TextEditingDelta::TextEditingDelta(const std::string& text_before_change, - TextRange range, + const TextRange& range, const std::string& text) : old_text_(fml::Utf8ToUtf16(text_before_change)), delta_text_(fml::Utf8ToUtf16(text)), diff --git a/shell/platform/common/text_editing_delta.h b/shell/platform/common/text_editing_delta.h index 528277b67306f..90f7fd89f1952 100644 --- a/shell/platform/common/text_editing_delta.h +++ b/shell/platform/common/text_editing_delta.h @@ -15,11 +15,11 @@ namespace flutter { /// A change in the state of an input field. struct TextEditingDelta { TextEditingDelta(const std::u16string& text_before_change, - TextRange range, + const TextRange& range, const std::u16string& text); TextEditingDelta(const std::string& text_before_change, - TextRange range, + const TextRange& range, const std::string& text); explicit TextEditingDelta(const std::u16string& text); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index f638e0fe79578..6a5f22b80a6dd 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -645,9 +645,9 @@ - (void)sendUserLocales { // Convert to a list of pointers, and send to the engine. std::vector flutterLocaleList; flutterLocaleList.reserve(flutterLocales.size()); - std::transform( - flutterLocales.begin(), flutterLocales.end(), std::back_inserter(flutterLocaleList), - [](const auto& arg) -> const auto* { return &arg; }); + std::transform(flutterLocales.begin(), flutterLocales.end(), + std::back_inserter(flutterLocaleList), + [](const auto& arg) -> const auto* { return &arg; }); _embedderAPI.UpdateLocales(_engine, flutterLocaleList.data(), flutterLocaleList.size()); } diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 0cdc73b13106d..4bf972aaf66ad 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -248,7 +248,7 @@ static inline flutter::Shell::CreateCallback InferOpenGLPlatformViewCreationCallback( const FlutterRendererConfig* config, void* user_data, - flutter::PlatformViewEmbedder::PlatformDispatchTable + const flutter::PlatformViewEmbedder::PlatformDispatchTable& platform_dispatch_table, std::unique_ptr external_view_embedder) { @@ -447,7 +447,7 @@ static flutter::Shell::CreateCallback InferMetalPlatformViewCreationCallback( const FlutterRendererConfig* config, void* user_data, - flutter::PlatformViewEmbedder::PlatformDispatchTable + const flutter::PlatformViewEmbedder::PlatformDispatchTable& platform_dispatch_table, std::unique_ptr external_view_embedder) { @@ -517,7 +517,7 @@ static flutter::Shell::CreateCallback InferVulkanPlatformViewCreationCallback( const FlutterRendererConfig* config, void* user_data, - flutter::PlatformViewEmbedder::PlatformDispatchTable + const flutter::PlatformViewEmbedder::PlatformDispatchTable& platform_dispatch_table, std::unique_ptr external_view_embedder) { @@ -600,7 +600,7 @@ static flutter::Shell::CreateCallback InferSoftwarePlatformViewCreationCallback( const FlutterRendererConfig* config, void* user_data, - flutter::PlatformViewEmbedder::PlatformDispatchTable + const flutter::PlatformViewEmbedder::PlatformDispatchTable& platform_dispatch_table, std::unique_ptr external_view_embedder) { @@ -637,7 +637,7 @@ static flutter::Shell::CreateCallback InferPlatformViewCreationCallback( const FlutterRendererConfig* config, void* user_data, - flutter::PlatformViewEmbedder::PlatformDispatchTable + const flutter::PlatformViewEmbedder::PlatformDispatchTable& platform_dispatch_table, std::unique_ptr external_view_embedder) { @@ -1371,8 +1371,8 @@ FlutterEngineResult FlutterEngineInitialize(size_t version, settings.application_kernel_asset = kApplicationKernelSnapshotFileName; } - settings.task_observer_add = [](intptr_t key, fml::closure callback) { - fml::MessageLoop::GetCurrent().AddTaskObserver(key, std::move(callback)); + settings.task_observer_add = [](intptr_t key, const fml::closure& callback) { + fml::MessageLoop::GetCurrent().AddTaskObserver(key, callback); }; settings.task_observer_remove = [](intptr_t key) { fml::MessageLoop::GetCurrent().RemoveTaskObserver(key); @@ -1416,8 +1416,8 @@ FlutterEngineResult FlutterEngineInitialize(size_t version, update_semantics_callback = [update_semantics_node_callback, update_semantics_custom_action_callback, - user_data](flutter::SemanticsNodeUpdates update, - flutter::CustomAccessibilityActionUpdates actions) { + user_data](const flutter::SemanticsNodeUpdates& update, + const flutter::CustomAccessibilityActionUpdates& actions) { // First, queue all node and custom action updates. if (update_semantics_node_callback != nullptr) { for (const auto& value : update) { @@ -1862,7 +1862,7 @@ FlutterEngineResult FlutterEngineSendWindowMetricsEvent( } return reinterpret_cast(engine)->SetViewportMetrics( - std::move(metrics)) + metrics) ? kSuccess : LOG_EMBEDDER_ERROR(kInvalidArguments, "Viewport metrics were invalid."); @@ -2470,7 +2470,7 @@ FlutterEngineResult FlutterEngineRunTask(FLUTTER_API_SYMBOL(FlutterEngine) static bool DispatchJSONPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, - rapidjson::Document document, + const rapidjson::Document& document, const std::string& channel_name) { if (channel_name.empty()) { return false; @@ -2552,8 +2552,7 @@ FlutterEngineResult FlutterEngineUpdateLocales(FLUTTER_API_SYMBOL(FlutterEngine) } document.AddMember("args", args, allocator); - return DispatchJSONPlatformMessage(engine, std::move(document), - "flutter/localization") + return DispatchJSONPlatformMessage(engine, document, "flutter/localization") ? kSuccess : LOG_EMBEDDER_ERROR(kInternalInconsistency, "Could not send message to update locale of " @@ -2703,8 +2702,7 @@ FlutterEngineResult FlutterEngineNotifyLowMemoryWarning( document.SetObject(); document.AddMember("type", "memoryPressure", allocator); - return DispatchJSONPlatformMessage(raw_engine, std::move(document), - "flutter/system") + return DispatchJSONPlatformMessage(raw_engine, document, "flutter/system") ? kSuccess : LOG_EMBEDDER_ERROR( kInternalInconsistency, diff --git a/shell/platform/embedder/embedder_engine.cc b/shell/platform/embedder/embedder_engine.cc index 1108e3e45c3be..498546c089220 100644 --- a/shell/platform/embedder/embedder_engine.cc +++ b/shell/platform/embedder/embedder_engine.cc @@ -13,26 +13,26 @@ struct ShellArgs { Settings settings; Shell::CreateCallback on_create_platform_view; Shell::CreateCallback on_create_rasterizer; - ShellArgs(Settings p_settings, + ShellArgs(const Settings& p_settings, Shell::CreateCallback p_on_create_platform_view, Shell::CreateCallback p_on_create_rasterizer) - : settings(std::move(p_settings)), + : settings(p_settings), on_create_platform_view(std::move(p_on_create_platform_view)), on_create_rasterizer(std::move(p_on_create_rasterizer)) {} }; EmbedderEngine::EmbedderEngine( std::unique_ptr thread_host, - flutter::TaskRunners task_runners, - flutter::Settings settings, + const flutter::TaskRunners& task_runners, + const flutter::Settings& settings, RunConfiguration run_configuration, - Shell::CreateCallback on_create_platform_view, - Shell::CreateCallback on_create_rasterizer, + const Shell::CreateCallback& on_create_platform_view, + const Shell::CreateCallback& on_create_rasterizer, std::unique_ptr external_texture_resolver) : thread_host_(std::move(thread_host)), task_runners_(task_runners), run_configuration_(std::move(run_configuration)), - shell_args_(std::make_unique(std::move(settings), + shell_args_(std::make_unique(settings, on_create_platform_view, on_create_rasterizer)), external_texture_resolver_(std::move(external_texture_resolver)) {} @@ -99,7 +99,8 @@ bool EmbedderEngine::NotifyDestroyed() { return true; } -bool EmbedderEngine::SetViewportMetrics(flutter::ViewportMetrics metrics) { +bool EmbedderEngine::SetViewportMetrics( + const flutter::ViewportMetrics& metrics) { if (!IsValid()) { return false; } @@ -108,7 +109,7 @@ bool EmbedderEngine::SetViewportMetrics(flutter::ViewportMetrics metrics) { if (!platform_view) { return false; } - platform_view->SetViewportMetrics(std::move(metrics)); + platform_view->SetViewportMetrics(metrics); return true; } @@ -246,13 +247,14 @@ bool EmbedderEngine::RunTask(const FlutterTask* task) { } bool EmbedderEngine::PostTaskOnEngineManagedNativeThreads( - std::function closure) const { + const std::function& closure) const { if (!IsValid() || closure == nullptr) { return false; } - const auto trampoline = [closure](FlutterNativeThreadType type, - fml::RefPtr runner) { + const auto trampoline = [closure]( + FlutterNativeThreadType type, + const fml::RefPtr& runner) { runner->PostTask([closure, type] { closure(type); }); }; diff --git a/shell/platform/embedder/embedder_engine.h b/shell/platform/embedder/embedder_engine.h index 135185695148f..80d2cbeffa8d0 100644 --- a/shell/platform/embedder/embedder_engine.h +++ b/shell/platform/embedder/embedder_engine.h @@ -22,14 +22,15 @@ struct ShellArgs; // instance of the Flutter engine. class EmbedderEngine { public: - EmbedderEngine(std::unique_ptr thread_host, - TaskRunners task_runners, - Settings settings, - RunConfiguration run_configuration, - Shell::CreateCallback on_create_platform_view, - Shell::CreateCallback on_create_rasterizer, - std::unique_ptr - external_texture_resolver); + EmbedderEngine( + std::unique_ptr thread_host, + const TaskRunners& task_runners, + const Settings& settings, + RunConfiguration run_configuration, + const Shell::CreateCallback& on_create_platform_view, + const Shell::CreateCallback& on_create_rasterizer, + std::unique_ptr + external_texture_resolver); ~EmbedderEngine(); @@ -47,7 +48,7 @@ class EmbedderEngine { bool IsValid() const; - bool SetViewportMetrics(flutter::ViewportMetrics metrics); + bool SetViewportMetrics(const flutter::ViewportMetrics& metrics); bool DispatchPointerDataPacket( std::unique_ptr packet); @@ -79,7 +80,7 @@ class EmbedderEngine { bool RunTask(const FlutterTask* task); bool PostTaskOnEngineManagedNativeThreads( - std::function closure) const; + const std::function& closure) const; bool ScheduleFrame(); diff --git a/shell/platform/embedder/embedder_external_texture_resolver.cc b/shell/platform/embedder/embedder_external_texture_resolver.cc index f2aa18d11b3f0..4e4b41b8d4ad2 100644 --- a/shell/platform/embedder/embedder_external_texture_resolver.cc +++ b/shell/platform/embedder/embedder_external_texture_resolver.cc @@ -5,19 +5,20 @@ #include "flutter/shell/platform/embedder/embedder_external_texture_resolver.h" #include +#include namespace flutter { #ifdef SHELL_ENABLE_GL EmbedderExternalTextureResolver::EmbedderExternalTextureResolver( EmbedderExternalTextureGL::ExternalTextureCallback gl_callback) - : gl_callback_(gl_callback) {} + : gl_callback_(std::move(gl_callback)) {} #endif #ifdef SHELL_ENABLE_METAL EmbedderExternalTextureResolver::EmbedderExternalTextureResolver( EmbedderExternalTextureMetal::ExternalTextureCallback metal_callback) - : metal_callback_(metal_callback) {} + : metal_callback_(std::move(metal_callback)) {} #endif std::unique_ptr diff --git a/shell/platform/embedder/embedder_external_view_embedder.cc b/shell/platform/embedder/embedder_external_view_embedder.cc index 026d1c5d48dd3..0e61db48ce8d8 100644 --- a/shell/platform/embedder/embedder_external_view_embedder.cc +++ b/shell/platform/embedder/embedder_external_view_embedder.cc @@ -5,6 +5,7 @@ #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" #include +#include #include "flutter/shell/platform/embedder/embedder_layers.h" #include "flutter/shell/platform/embedder/embedder_render_target.h" @@ -27,7 +28,7 @@ EmbedderExternalViewEmbedder::~EmbedderExternalViewEmbedder() = default; void EmbedderExternalViewEmbedder::SetSurfaceTransformationCallback( SurfaceTransformationCallback surface_transformation_callback) { - surface_transformation_callback_ = surface_transformation_callback; + surface_transformation_callback_ = std::move(surface_transformation_callback); } SkMatrix EmbedderExternalViewEmbedder::GetSurfaceTransformation() const { diff --git a/shell/platform/embedder/embedder_layers.cc b/shell/platform/embedder/embedder_layers.cc index 7d9a4bc9a8892..6465293748f9f 100644 --- a/shell/platform/embedder/embedder_layers.cc +++ b/shell/platform/embedder/embedder_layers.cc @@ -206,7 +206,7 @@ void EmbedderLayers::InvokePresentCallback( for (const auto& layer : presented_layers_) { presented_layers_pointers.push_back(&layer); } - callback(std::move(presented_layers_pointers)); + callback(presented_layers_pointers); } } // namespace flutter diff --git a/shell/platform/embedder/embedder_render_target.cc b/shell/platform/embedder/embedder_render_target.cc index 8f6e447ba144e..c9ef521d6302b 100644 --- a/shell/platform/embedder/embedder_render_target.cc +++ b/shell/platform/embedder/embedder_render_target.cc @@ -4,6 +4,8 @@ #include "flutter/shell/platform/embedder/embedder_render_target.h" +#include + #include "flutter/fml/logging.h" namespace flutter { @@ -13,7 +15,7 @@ EmbedderRenderTarget::EmbedderRenderTarget(FlutterBackingStore backing_store, fml::closure on_release) : backing_store_(backing_store), render_surface_(std::move(render_surface)), - on_release_(on_release) { + on_release_(std::move(on_release)) { // TODO(38468): The optimization to elide backing store updates between frames // has not been implemented yet. backing_store_.did_update = true; diff --git a/shell/platform/embedder/embedder_surface_gl.cc b/shell/platform/embedder/embedder_surface_gl.cc index f08793429c4d5..44b1fddf808fb 100644 --- a/shell/platform/embedder/embedder_surface_gl.cc +++ b/shell/platform/embedder/embedder_surface_gl.cc @@ -4,6 +4,8 @@ #include "flutter/shell/platform/embedder/embedder_surface_gl.h" +#include + #include "flutter/shell/common/shell_io_manager.h" namespace flutter { @@ -12,9 +14,9 @@ EmbedderSurfaceGL::EmbedderSurfaceGL( GLDispatchTable gl_dispatch_table, bool fbo_reset_after_present, std::shared_ptr external_view_embedder) - : gl_dispatch_table_(gl_dispatch_table), + : gl_dispatch_table_(std::move(gl_dispatch_table)), fbo_reset_after_present_(fbo_reset_after_present), - external_view_embedder_(external_view_embedder) { + external_view_embedder_(std::move(external_view_embedder)) { // Make sure all required members of the dispatch table are checked. if (!gl_dispatch_table_.gl_make_current_callback || !gl_dispatch_table_.gl_clear_current_callback || diff --git a/shell/platform/embedder/embedder_surface_metal.mm b/shell/platform/embedder/embedder_surface_metal.mm index b50fdf79bc493..afa11d62f610b 100644 --- a/shell/platform/embedder/embedder_surface_metal.mm +++ b/shell/platform/embedder/embedder_surface_metal.mm @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + #include "flutter/shell/platform/embedder/embedder_surface_metal.h" #include "flutter/fml/logging.h" @@ -18,8 +20,8 @@ MetalDispatchTable metal_dispatch_table, std::shared_ptr external_view_embedder) : GPUSurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), - metal_dispatch_table_(metal_dispatch_table), - external_view_embedder_(external_view_embedder) { + metal_dispatch_table_(std::move(metal_dispatch_table)), + external_view_embedder_(std::move(external_view_embedder)) { main_context_ = [FlutterDarwinContextMetal createGrContext:(id)device commandQueue:(id)command_queue]; resource_context_ = diff --git a/shell/platform/embedder/embedder_surface_software.cc b/shell/platform/embedder/embedder_surface_software.cc index 986bab4df9768..f507e25e66646 100644 --- a/shell/platform/embedder/embedder_surface_software.cc +++ b/shell/platform/embedder/embedder_surface_software.cc @@ -4,6 +4,8 @@ #include "flutter/shell/platform/embedder/embedder_surface_software.h" +#include + #include "flutter/fml/trace_event.h" #include "third_party/skia/include/core/SkColorSpace.h" #include "third_party/skia/include/core/SkImageInfo.h" @@ -14,8 +16,8 @@ namespace flutter { EmbedderSurfaceSoftware::EmbedderSurfaceSoftware( SoftwareDispatchTable software_dispatch_table, std::shared_ptr external_view_embedder) - : software_dispatch_table_(software_dispatch_table), - external_view_embedder_(external_view_embedder) { + : software_dispatch_table_(std::move(software_dispatch_table)), + external_view_embedder_(std::move(external_view_embedder)) { if (!software_dispatch_table_.software_present_backing_store) { return; } diff --git a/shell/platform/embedder/embedder_surface_vulkan.cc b/shell/platform/embedder/embedder_surface_vulkan.cc index b3918a2420070..837d15882c648 100644 --- a/shell/platform/embedder/embedder_surface_vulkan.cc +++ b/shell/platform/embedder/embedder_surface_vulkan.cc @@ -4,6 +4,8 @@ #include "flutter/shell/platform/embedder/embedder_surface_vulkan.h" +#include + #include "flutter/shell/common/shell_io_manager.h" #include "include/gpu/GrDirectContext.h" #include "include/gpu/vk/GrVkBackendContext.h" @@ -24,7 +26,7 @@ EmbedderSurfaceVulkan::EmbedderSurfaceVulkan( VkDevice device, uint32_t queue_family_index, VkQueue queue, - VulkanDispatchTable vulkan_dispatch_table, + const VulkanDispatchTable& vulkan_dispatch_table, std::shared_ptr external_view_embedder) : vk_(fml::MakeRefCounted( vulkan_dispatch_table.get_instance_proc_address)), @@ -34,7 +36,7 @@ EmbedderSurfaceVulkan::EmbedderSurfaceVulkan( queue_family_index, vulkan::VulkanHandle{queue}), vulkan_dispatch_table_(vulkan_dispatch_table), - external_view_embedder_(external_view_embedder) { + external_view_embedder_(std::move(external_view_embedder)) { // Make sure all required members of the dispatch table are checked. if (!vulkan_dispatch_table_.get_instance_proc_address || !vulkan_dispatch_table_.get_next_image || diff --git a/shell/platform/embedder/embedder_surface_vulkan.h b/shell/platform/embedder/embedder_surface_vulkan.h index 3fa28fa09a7bd..d51ae5d8ce938 100644 --- a/shell/platform/embedder/embedder_surface_vulkan.h +++ b/shell/platform/embedder/embedder_surface_vulkan.h @@ -39,7 +39,7 @@ class EmbedderSurfaceVulkan final : public EmbedderSurface, VkDevice device, uint32_t queue_family_index, VkQueue queue, - VulkanDispatchTable vulkan_dispatch_table, + const VulkanDispatchTable& vulkan_dispatch_table, std::shared_ptr external_view_embedder); ~EmbedderSurfaceVulkan() override; diff --git a/shell/platform/embedder/embedder_thread_host.cc b/shell/platform/embedder/embedder_thread_host.cc index 225c14f2f2eca..73646cfc0cb09 100644 --- a/shell/platform/embedder/embedder_thread_host.cc +++ b/shell/platform/embedder/embedder_thread_host.cc @@ -82,7 +82,7 @@ CreateEmbedderTaskRunner(const FlutterTaskRunnerDescription* description) { std::unique_ptr EmbedderThreadHost::CreateEmbedderOrEngineManagedThreadHost( const FlutterCustomTaskRunners* custom_task_runners, - flutter::ThreadConfigSetter config_setter) { + const flutter::ThreadConfigSetter& config_setter) { { auto host = CreateEmbedderManagedThreadHost(custom_task_runners, config_setter); @@ -125,7 +125,7 @@ fml::Thread::ThreadConfig MakeThreadConfig( std::unique_ptr EmbedderThreadHost::CreateEmbedderManagedThreadHost( const FlutterCustomTaskRunners* custom_task_runners, - flutter::ThreadConfigSetter config_setter) { + const flutter::ThreadConfigSetter& config_setter) { if (custom_task_runners == nullptr) { return nullptr; } @@ -223,7 +223,7 @@ EmbedderThreadHost::CreateEmbedderManagedThreadHost( // static std::unique_ptr EmbedderThreadHost::CreateEngineManagedThreadHost( - flutter::ThreadConfigSetter config_setter) { + const flutter::ThreadConfigSetter& config_setter) { // Crate a thraed host config, and specified the thread name and priority. auto thread_host_config = ThreadHost::ThreadHostConfig(config_setter); thread_host_config.SetUIConfig(MakeThreadConfig( @@ -269,9 +269,9 @@ EmbedderThreadHost::CreateEngineManagedThreadHost( EmbedderThreadHost::EmbedderThreadHost( ThreadHost host, - flutter::TaskRunners runners, - std::set> embedder_task_runners) - : host_(std::move(host)), runners_(std::move(runners)) { + const flutter::TaskRunners& runners, + const std::set>& embedder_task_runners) + : host_(std::move(host)), runners_(runners) { for (const auto& runner : embedder_task_runners) { runners_map_[reinterpret_cast(runner.get())] = runner; } diff --git a/shell/platform/embedder/embedder_thread_host.h b/shell/platform/embedder/embedder_thread_host.h index 3e087e7c8b5b7..054812892e8bc 100644 --- a/shell/platform/embedder/embedder_thread_host.h +++ b/shell/platform/embedder/embedder_thread_host.h @@ -22,13 +22,13 @@ class EmbedderThreadHost { static std::unique_ptr CreateEmbedderOrEngineManagedThreadHost( const FlutterCustomTaskRunners* custom_task_runners, - flutter::ThreadConfigSetter config_setter = + const flutter::ThreadConfigSetter& config_setter = fml::Thread::SetCurrentThreadName); EmbedderThreadHost( ThreadHost host, - flutter::TaskRunners runners, - std::set> embedder_task_runners); + const flutter::TaskRunners& runners, + const std::set>& embedder_task_runners); ~EmbedderThreadHost(); @@ -45,11 +45,11 @@ class EmbedderThreadHost { static std::unique_ptr CreateEmbedderManagedThreadHost( const FlutterCustomTaskRunners* custom_task_runners, - flutter::ThreadConfigSetter config_setter = + const flutter::ThreadConfigSetter& config_setter = fml::Thread::SetCurrentThreadName); static std::unique_ptr CreateEngineManagedThreadHost( - flutter::ThreadConfigSetter config_setter = + const flutter::ThreadConfigSetter& config_setter = fml::Thread::SetCurrentThreadName); FML_DISALLOW_COPY_AND_ASSIGN(EmbedderThreadHost); diff --git a/shell/platform/embedder/platform_view_embedder.cc b/shell/platform/embedder/platform_view_embedder.cc index de09b4ebe1dc5..1cedc22810a50 100644 --- a/shell/platform/embedder/platform_view_embedder.cc +++ b/shell/platform/embedder/platform_view_embedder.cc @@ -4,6 +4,8 @@ #include "flutter/shell/platform/embedder/platform_view_embedder.h" +#include + #include "flutter/fml/make_copyable.h" namespace flutter { @@ -14,7 +16,8 @@ class PlatformViewEmbedder::EmbedderPlatformMessageHandler EmbedderPlatformMessageHandler( fml::WeakPtr parent, fml::RefPtr platform_task_runner) - : parent_(parent), platform_task_runner_(platform_task_runner) {} + : parent_(std::move(parent)), + platform_task_runner_(std::move(platform_task_runner)) {} virtual void HandlePlatformMessage(std::unique_ptr message) { platform_task_runner_->PostTask(fml::MakeCopyable( @@ -44,30 +47,31 @@ class PlatformViewEmbedder::EmbedderPlatformMessageHandler PlatformViewEmbedder::PlatformViewEmbedder( PlatformView::Delegate& delegate, - flutter::TaskRunners task_runners, - EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table, + const flutter::TaskRunners& task_runners, + const EmbedderSurfaceSoftware::SoftwareDispatchTable& + software_dispatch_table, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder) : PlatformView(delegate, task_runners), - external_view_embedder_(external_view_embedder), + external_view_embedder_(std::move(external_view_embedder)), embedder_surface_( std::make_unique(software_dispatch_table, external_view_embedder_)), platform_message_handler_(new EmbedderPlatformMessageHandler( GetWeakPtr(), task_runners.GetPlatformTaskRunner())), - platform_dispatch_table_(platform_dispatch_table) {} + platform_dispatch_table_(std::move(platform_dispatch_table)) {} #ifdef SHELL_ENABLE_GL PlatformViewEmbedder::PlatformViewEmbedder( PlatformView::Delegate& delegate, - flutter::TaskRunners task_runners, - EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table, + const flutter::TaskRunners& task_runners, + const EmbedderSurfaceGL::GLDispatchTable& gl_dispatch_table, bool fbo_reset_after_present, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder) : PlatformView(delegate, task_runners), - external_view_embedder_(external_view_embedder), + external_view_embedder_(std::move(external_view_embedder)), embedder_surface_( std::make_unique(gl_dispatch_table, fbo_reset_after_present, @@ -75,39 +79,39 @@ PlatformViewEmbedder::PlatformViewEmbedder( platform_message_handler_(new EmbedderPlatformMessageHandler( GetWeakPtr(), task_runners.GetPlatformTaskRunner())), - platform_dispatch_table_(platform_dispatch_table) {} + platform_dispatch_table_(std::move(platform_dispatch_table)) {} #endif #ifdef SHELL_ENABLE_METAL PlatformViewEmbedder::PlatformViewEmbedder( PlatformView::Delegate& delegate, - flutter::TaskRunners task_runners, + const flutter::TaskRunners& task_runners, std::unique_ptr embedder_surface, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder) : PlatformView(delegate, task_runners), - external_view_embedder_(external_view_embedder), + external_view_embedder_(std::move(external_view_embedder)), embedder_surface_(std::move(embedder_surface)), platform_message_handler_(new EmbedderPlatformMessageHandler( GetWeakPtr(), task_runners.GetPlatformTaskRunner())), - platform_dispatch_table_(platform_dispatch_table) {} + platform_dispatch_table_(std::move(platform_dispatch_table)) {} #endif #ifdef SHELL_ENABLE_VULKAN PlatformViewEmbedder::PlatformViewEmbedder( PlatformView::Delegate& delegate, - flutter::TaskRunners task_runners, + const flutter::TaskRunners& task_runners, std::unique_ptr embedder_surface, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder) : PlatformView(delegate, task_runners), - external_view_embedder_(external_view_embedder), + external_view_embedder_(std::move(external_view_embedder)), embedder_surface_(std::move(embedder_surface)), platform_message_handler_(new EmbedderPlatformMessageHandler( GetWeakPtr(), task_runners.GetPlatformTaskRunner())), - platform_dispatch_table_(platform_dispatch_table) {} + platform_dispatch_table_(std::move(platform_dispatch_table)) {} #endif PlatformViewEmbedder::~PlatformViewEmbedder() = default; diff --git a/shell/platform/embedder/platform_view_embedder.h b/shell/platform/embedder/platform_view_embedder.h index 562a5d074fd11..20f4dc139875b 100644 --- a/shell/platform/embedder/platform_view_embedder.h +++ b/shell/platform/embedder/platform_view_embedder.h @@ -54,8 +54,9 @@ class PlatformViewEmbedder final : public PlatformView { // Create a platform view that sets up a software rasterizer. PlatformViewEmbedder( PlatformView::Delegate& delegate, - flutter::TaskRunners task_runners, - EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table, + const flutter::TaskRunners& task_runners, + const EmbedderSurfaceSoftware::SoftwareDispatchTable& + software_dispatch_table, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder); @@ -63,8 +64,8 @@ class PlatformViewEmbedder final : public PlatformView { // Creates a platform view that sets up an OpenGL rasterizer. PlatformViewEmbedder( PlatformView::Delegate& delegate, - flutter::TaskRunners task_runners, - EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table, + const flutter::TaskRunners& task_runners, + const EmbedderSurfaceGL::GLDispatchTable& gl_dispatch_table, bool fbo_reset_after_present, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder); @@ -74,7 +75,7 @@ class PlatformViewEmbedder final : public PlatformView { // Creates a platform view that sets up an metal rasterizer. PlatformViewEmbedder( PlatformView::Delegate& delegate, - flutter::TaskRunners task_runners, + const flutter::TaskRunners& task_runners, std::unique_ptr embedder_surface, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder); @@ -84,7 +85,7 @@ class PlatformViewEmbedder final : public PlatformView { // Creates a platform view that sets up an Vulkan rasterizer. PlatformViewEmbedder( PlatformView::Delegate& delegate, - flutter::TaskRunners task_runners, + const flutter::TaskRunners& task_runners, std::unique_ptr embedder_surface, PlatformDispatchTable platform_dispatch_table, std::shared_ptr external_view_embedder); diff --git a/shell/platform/embedder/tests/embedder_test_backingstore_producer.cc b/shell/platform/embedder/tests/embedder_test_backingstore_producer.cc index 65560d654e430..8511864d5fc72 100644 --- a/shell/platform/embedder/tests/embedder_test_backingstore_producer.cc +++ b/shell/platform/embedder/tests/embedder_test_backingstore_producer.cc @@ -14,6 +14,7 @@ #include #include +#include namespace flutter { namespace testing { @@ -22,7 +23,7 @@ EmbedderTestBackingStoreProducer::EmbedderTestBackingStoreProducer( sk_sp context, RenderTargetType type, FlutterSoftwarePixelFormat software_pixfmt) - : context_(context), + : context_(std::move(context)), type_(type), software_pixfmt_(software_pixfmt) #ifdef SHELL_ENABLE_METAL diff --git a/shell/platform/embedder/tests/embedder_test_context_metal.cc b/shell/platform/embedder/tests/embedder_test_context_metal.cc index 151911e5d3f64..c649227b54800 100644 --- a/shell/platform/embedder/tests/embedder_test_context_metal.cc +++ b/shell/platform/embedder/tests/embedder_test_context_metal.cc @@ -5,6 +5,7 @@ #include "flutter/shell/platform/embedder/tests/embedder_test_context_metal.h" #include +#include #include "embedder.h" #include "flutter/fml/logging.h" @@ -14,7 +15,7 @@ namespace flutter { namespace testing { EmbedderTestContextMetal::EmbedderTestContextMetal(std::string assets_path) - : EmbedderTestContext(assets_path) { + : EmbedderTestContext(std::move(assets_path)) { metal_context_ = std::make_unique(); } @@ -55,7 +56,7 @@ bool EmbedderTestContextMetal::Present(int64_t texture_id) { void EmbedderTestContextMetal::SetExternalTextureCallback( TestExternalTextureCallback external_texture_frame_callback) { - external_texture_frame_callback_ = external_texture_frame_callback; + external_texture_frame_callback_ = std::move(external_texture_frame_callback); } bool EmbedderTestContextMetal::PopulateExternalTexture( diff --git a/shell/platform/embedder/tests/embedder_test_context_vulkan.cc b/shell/platform/embedder/tests/embedder_test_context_vulkan.cc index 0fb93fa1e367c..9260f19e98b70 100644 --- a/shell/platform/embedder/tests/embedder_test_context_vulkan.cc +++ b/shell/platform/embedder/tests/embedder_test_context_vulkan.cc @@ -5,6 +5,7 @@ #include "flutter/shell/platform/embedder/tests/embedder_test_context_vulkan.h" #include +#include #include "flutter/fml/logging.h" #include "flutter/shell/platform/embedder/tests/embedder_test_compositor_vulkan.h" @@ -18,7 +19,7 @@ namespace flutter { namespace testing { EmbedderTestContextVulkan::EmbedderTestContextVulkan(std::string assets_path) - : EmbedderTestContext(assets_path), surface_() { + : EmbedderTestContext(std::move(assets_path)), surface_() { vulkan_context_ = fml::MakeRefCounted(); } diff --git a/shell/platform/embedder/vsync_waiter_embedder.cc b/shell/platform/embedder/vsync_waiter_embedder.cc index bf566929e5a6f..078e75fb5aae0 100644 --- a/shell/platform/embedder/vsync_waiter_embedder.cc +++ b/shell/platform/embedder/vsync_waiter_embedder.cc @@ -6,9 +6,10 @@ namespace flutter { -VsyncWaiterEmbedder::VsyncWaiterEmbedder(const VsyncCallback& vsync_callback, - flutter::TaskRunners task_runners) - : VsyncWaiter(std::move(task_runners)), vsync_callback_(vsync_callback) { +VsyncWaiterEmbedder::VsyncWaiterEmbedder( + const VsyncCallback& vsync_callback, + const flutter::TaskRunners& task_runners) + : VsyncWaiter(task_runners), vsync_callback_(vsync_callback) { FML_DCHECK(vsync_callback_); } diff --git a/shell/platform/embedder/vsync_waiter_embedder.h b/shell/platform/embedder/vsync_waiter_embedder.h index 24e98e433fd70..4dac73a5a4789 100644 --- a/shell/platform/embedder/vsync_waiter_embedder.h +++ b/shell/platform/embedder/vsync_waiter_embedder.h @@ -15,7 +15,7 @@ class VsyncWaiterEmbedder final : public VsyncWaiter { using VsyncCallback = std::function; VsyncWaiterEmbedder(const VsyncCallback& callback, - flutter::TaskRunners task_runners); + const flutter::TaskRunners& task_runners); ~VsyncWaiterEmbedder() override; diff --git a/shell/profiling/sampling_profiler.cc b/shell/profiling/sampling_profiler.cc index e1f1a0c291c12..c6058b76cd4c7 100644 --- a/shell/profiling/sampling_profiler.cc +++ b/shell/profiling/sampling_profiler.cc @@ -4,6 +4,8 @@ #include "flutter/shell/profiling/sampling_profiler.h" +#include + namespace flutter { SamplingProfiler::SamplingProfiler( @@ -12,7 +14,7 @@ SamplingProfiler::SamplingProfiler( Sampler sampler, int num_samples_per_sec) : thread_label_(thread_label), - profiler_task_runner_(profiler_task_runner), + profiler_task_runner_(std::move(profiler_task_runner)), sampler_(std::move(sampler)), num_samples_per_sec_(num_samples_per_sec) {} diff --git a/shell/testing/tester_main.cc b/shell/testing/tester_main.cc index c1eab867f6a1c..9aec07a52e1d8 100644 --- a/shell/testing/tester_main.cc +++ b/shell/testing/tester_main.cc @@ -83,8 +83,8 @@ class TesterGPUSurfaceSoftware : public GPUSurfaceSoftware { class TesterPlatformView : public PlatformView, public GPUSurfaceSoftwareDelegate { public: - TesterPlatformView(Delegate& delegate, TaskRunners task_runners) - : PlatformView(delegate, std::move(task_runners)) {} + TesterPlatformView(Delegate& delegate, const TaskRunners& task_runners) + : PlatformView(delegate, task_runners) {} // |PlatformView| std::unique_ptr CreateRenderingSurface() override { @@ -406,8 +406,8 @@ int main(int argc, char* argv[]) { std::cout << message << std::endl; }; - settings.task_observer_add = [](intptr_t key, fml::closure callback) { - fml::MessageLoop::GetCurrent().AddTaskObserver(key, std::move(callback)); + settings.task_observer_add = [](intptr_t key, const fml::closure& callback) { + fml::MessageLoop::GetCurrent().AddTaskObserver(key, callback); }; settings.task_observer_remove = [](intptr_t key) { diff --git a/testing/dart_fixture.cc b/testing/dart_fixture.cc index ab0a15c9f7170..9fe8a5c5b0fc9 100644 --- a/testing/dart_fixture.cc +++ b/testing/dart_fixture.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "flutter/testing/dart_fixture.h" + +#include #include "flutter/fml/paths.h" namespace flutter::testing { @@ -16,18 +18,19 @@ DartFixture::DartFixture(std::string kernel_filename, std::string elf_filename, std::string elf_split_filename) : native_resolver_(std::make_shared()), - split_aot_symbols_( - LoadELFSplitSymbolFromFixturesIfNeccessary(elf_split_filename)), - kernel_filename_(kernel_filename), + split_aot_symbols_(LoadELFSplitSymbolFromFixturesIfNeccessary( + std::move(elf_split_filename))), + kernel_filename_(std::move(kernel_filename)), assets_dir_(fml::OpenDirectory(GetFixturesPath(), false, fml::FilePermission::kRead)), - aot_symbols_(LoadELFSymbolFromFixturesIfNeccessary(elf_filename)) {} + aot_symbols_( + LoadELFSymbolFromFixturesIfNeccessary(std::move(elf_filename))) {} Settings DartFixture::CreateSettingsForFixture() { Settings settings; settings.leak_vm = false; - settings.task_observer_add = [](intptr_t, fml::closure) {}; + settings.task_observer_add = [](intptr_t, const fml::closure&) {}; settings.task_observer_remove = [](intptr_t) {}; settings.isolate_create_callback = [this]() { native_resolver_->SetNativeResolverForIsolate(); @@ -69,13 +72,14 @@ void DartFixture::SetSnapshotsAndAssets(Settings& settings) { } } -void DartFixture::AddNativeCallback(std::string name, +void DartFixture::AddNativeCallback(const std::string& name, Dart_NativeFunction callback) { - native_resolver_->AddNativeCallback(std::move(name), callback); + native_resolver_->AddNativeCallback(name, callback); } -void DartFixture::AddFfiNativeCallback(std::string name, void* callback_ptr) { - native_resolver_->AddFfiNativeCallback(std::move(name), callback_ptr); +void DartFixture::AddFfiNativeCallback(const std::string& name, + void* callback_ptr) { + native_resolver_->AddFfiNativeCallback(name, callback_ptr); } } // namespace flutter::testing diff --git a/testing/dart_fixture.h b/testing/dart_fixture.h index 35a2aecfa05c2..87a2ba98dbfae 100644 --- a/testing/dart_fixture.h +++ b/testing/dart_fixture.h @@ -28,8 +28,8 @@ class DartFixture { virtual Settings CreateSettingsForFixture(); - void AddNativeCallback(std::string name, Dart_NativeFunction callback); - void AddFfiNativeCallback(std::string name, void* callback_ptr); + void AddNativeCallback(const std::string& name, Dart_NativeFunction callback); + void AddFfiNativeCallback(const std::string& name, void* callback_ptr); protected: void SetSnapshotsAndAssets(Settings& settings); diff --git a/testing/dart_isolate_runner.cc b/testing/dart_isolate_runner.cc index 4661bf86b340c..ff034a9e72f5b 100644 --- a/testing/dart_isolate_runner.cc +++ b/testing/dart_isolate_runner.cc @@ -4,6 +4,8 @@ #include "flutter/testing/dart_isolate_runner.h" +#include + #include "flutter/runtime/isolate_configuration.h" namespace flutter { @@ -42,7 +44,7 @@ void AutoIsolateShutdown::Shutdown() { } [[nodiscard]] bool AutoIsolateShutdown::RunInIsolateScope( - std::function closure) { + const std::function& closure) { if (!IsValid()) { return false; } @@ -70,7 +72,7 @@ std::unique_ptr RunDartCodeInIsolateOnUITaskRunner( const std::vector& args, const std::string& kernel_file_path, fml::WeakPtr io_manager, - std::shared_ptr volatile_path_tracker) { + const std::shared_ptr& volatile_path_tracker) { FML_CHECK(task_runners.GetUITaskRunner()->RunsTasksOnCurrentThread()); if (!vm_ref) { @@ -117,8 +119,8 @@ std::unique_ptr RunDartCodeInIsolateOnUITaskRunner( auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); - UIDartState::Context context(std::move(task_runners)); - context.io_manager = io_manager; + UIDartState::Context context(task_runners); + context.io_manager = std::move(io_manager); context.advisory_script_uri = "main.dart"; context.advisory_script_entrypoint = entrypoint.c_str(); @@ -163,7 +165,7 @@ std::unique_ptr RunDartCodeInIsolate( task_runners.GetUITaskRunner(), fml::MakeCopyable([&]() mutable { result = RunDartCodeInIsolateOnUITaskRunner( vm_ref, settings, task_runners, entrypoint, args, kernel_file_path, - io_manager, std::move(volatile_path_tracker)); + io_manager, volatile_path_tracker); latch.Signal(); })); latch.Wait(); diff --git a/testing/dart_isolate_runner.h b/testing/dart_isolate_runner.h index 40e34110b9807..ec1d477e83bbc 100644 --- a/testing/dart_isolate_runner.h +++ b/testing/dart_isolate_runner.h @@ -28,7 +28,8 @@ class AutoIsolateShutdown { bool IsValid() const { return isolate_ != nullptr && runner_; } - [[nodiscard]] bool RunInIsolateScope(std::function closure); + [[nodiscard]] bool RunInIsolateScope( + const std::function& closure); void Shutdown(); diff --git a/testing/elf_loader.cc b/testing/elf_loader.cc index 50b6e43960bec..2c7a989dbb34f 100644 --- a/testing/elf_loader.cc +++ b/testing/elf_loader.cc @@ -4,6 +4,8 @@ #include "flutter/testing/elf_loader.h" +#include + #include "flutter/fml/file.h" #include "flutter/fml/paths.h" #include "flutter/runtime/dart_vm.h" @@ -18,7 +20,7 @@ ELFAOTSymbols LoadELFSymbolFromFixturesIfNeccessary(std::string elf_filename) { } const auto elf_path = - fml::paths::JoinPaths({GetFixturesPath(), elf_filename}); + fml::paths::JoinPaths({GetFixturesPath(), std::move(elf_filename)}); if (!fml::IsFile(elf_path)) { FML_LOG(ERROR) << "App AOT file does not exist for this fixture. Attempts " @@ -67,7 +69,7 @@ ELFAOTSymbols LoadELFSplitSymbolFromFixturesIfNeccessary( } const auto elf_path = - fml::paths::JoinPaths({GetFixturesPath(), elf_split_filename}); + fml::paths::JoinPaths({GetFixturesPath(), std::move(elf_split_filename)}); if (!fml::IsFile(elf_path)) { // We do not log here, as there is no expectation for a split library to diff --git a/testing/fixture_test.cc b/testing/fixture_test.cc index ed451a50decff..dee760990cc7e 100644 --- a/testing/fixture_test.cc +++ b/testing/fixture_test.cc @@ -4,6 +4,8 @@ #include "flutter/testing/fixture_test.h" +#include + #include "flutter/testing/dart_fixture.h" namespace flutter { @@ -14,7 +16,9 @@ FixtureTest::FixtureTest() : DartFixture() {} FixtureTest::FixtureTest(std::string kernel_filename, std::string elf_filename, std::string elf_split_filename) - : DartFixture(kernel_filename, elf_filename, elf_split_filename) {} + : DartFixture(std::move(kernel_filename), + std::move(elf_filename), + std::move(elf_split_filename)) {} } // namespace testing } // namespace flutter diff --git a/testing/post_task_sync.cc b/testing/post_task_sync.cc index b5a6e36f5df87..1a4b2a1f0671f 100644 --- a/testing/post_task_sync.cc +++ b/testing/post_task_sync.cc @@ -9,7 +9,7 @@ namespace flutter { namespace testing { -void PostTaskSync(fml::RefPtr task_runner, +void PostTaskSync(const fml::RefPtr& task_runner, const std::function& function) { fml::AutoResetWaitableEvent latch; task_runner->PostTask([&] { diff --git a/testing/post_task_sync.h b/testing/post_task_sync.h index 7e5d362dc9c1c..ea9b64d0f0109 100644 --- a/testing/post_task_sync.h +++ b/testing/post_task_sync.h @@ -10,7 +10,7 @@ namespace flutter { namespace testing { -void PostTaskSync(fml::RefPtr task_runner, +void PostTaskSync(const fml::RefPtr& task_runner, const std::function& function); } // namespace testing diff --git a/testing/test_dart_native_resolver.cc b/testing/test_dart_native_resolver.cc index dc2cf3e303e34..b96371f514e52 100644 --- a/testing/test_dart_native_resolver.cc +++ b/testing/test_dart_native_resolver.cc @@ -18,17 +18,17 @@ TestDartNativeResolver::TestDartNativeResolver() = default; TestDartNativeResolver::~TestDartNativeResolver() = default; -void TestDartNativeResolver::AddNativeCallback(std::string name, +void TestDartNativeResolver::AddNativeCallback(const std::string& name, Dart_NativeFunction callback) { native_callbacks_[name] = callback; } -void TestDartNativeResolver::AddFfiNativeCallback(std::string name, +void TestDartNativeResolver::AddFfiNativeCallback(const std::string& name, void* callback_ptr) { ffi_native_callbacks_[name] = callback_ptr; } Dart_NativeFunction TestDartNativeResolver::ResolveCallback( - std::string name) const { + const std::string& name) const { auto found = native_callbacks_.find(name); if (found == native_callbacks_.end()) { return nullptr; @@ -37,7 +37,8 @@ Dart_NativeFunction TestDartNativeResolver::ResolveCallback( return found->second; } -void* TestDartNativeResolver::ResolveFfiCallback(std::string name) const { +void* TestDartNativeResolver::ResolveFfiCallback( + const std::string& name) const { auto found = ffi_native_callbacks_.find(name); if (found == ffi_native_callbacks_.end()) { return nullptr; @@ -63,7 +64,7 @@ Dart_NativeFunction TestDartNativeResolver::DartNativeEntryResolverCallback( } if (auto resolver = found->second.lock()) { - return resolver->ResolveCallback(std::move(name)); + return resolver->ResolveCallback(name); } else { gIsolateResolvers.erase(found); } diff --git a/testing/test_dart_native_resolver.h b/testing/test_dart_native_resolver.h index ee82efc3c1b59..a54ba6ab1e62e 100644 --- a/testing/test_dart_native_resolver.h +++ b/testing/test_dart_native_resolver.h @@ -34,8 +34,8 @@ class TestDartNativeResolver ~TestDartNativeResolver(); - void AddNativeCallback(std::string name, Dart_NativeFunction callback); - void AddFfiNativeCallback(std::string name, void* callback_ptr); + void AddNativeCallback(const std::string& name, Dart_NativeFunction callback); + void AddFfiNativeCallback(const std::string& name, void* callback_ptr); void SetNativeResolverForIsolate(); @@ -43,8 +43,8 @@ class TestDartNativeResolver std::map native_callbacks_; std::map ffi_native_callbacks_; - Dart_NativeFunction ResolveCallback(std::string name) const; - void* ResolveFfiCallback(std::string name) const; + Dart_NativeFunction ResolveCallback(const std::string& name) const; + void* ResolveFfiCallback(const std::string& name) const; static Dart_NativeFunction DartNativeEntryResolverCallback( Dart_Handle dart_name, diff --git a/testing/test_metal_surface_impl.mm b/testing/test_metal_surface_impl.mm index b29c27ddee057..5dd490910f223 100644 --- a/testing/test_metal_surface_impl.mm +++ b/testing/test_metal_surface_impl.mm @@ -37,7 +37,7 @@ GrBackendTexture backend_texture(surface_size.width(), surface_size.height(), Gr } surface_ = std::move(surface); - texture_info_ = std::move(texture_info); + texture_info_ = texture_info; is_valid_ = true; } diff --git a/testing/test_timeout_listener.cc b/testing/test_timeout_listener.cc index e4604cee0fa84..1163c921e78e4 100644 --- a/testing/test_timeout_listener.cc +++ b/testing/test_timeout_listener.cc @@ -104,7 +104,7 @@ void TestTimeoutListener::OnTestStart(const ::testing::TestInfo& test_info) { name = GetTestNameFromTestInfo(test_info), now = fml::TimePoint::Now()]() { if (auto tests = weak_tests.lock()) { - tests->OnTestBegin(std::move(name), now); + tests->OnTestBegin(name, now); } }); } @@ -115,7 +115,7 @@ void TestTimeoutListener::OnTestEnd(const ::testing::TestInfo& test_info) { [weak_tests = WeakPtr(pending_tests_), name = GetTestNameFromTestInfo(test_info)]() { if (auto tests = weak_tests.lock()) { - tests->OnTestEnd(std::move(name)); + tests->OnTestEnd(name); } }); } diff --git a/testing/testing.cc b/testing/testing.cc index fb7b4fc06b0c6..06de22adb85ab 100644 --- a/testing/testing.cc +++ b/testing/testing.cc @@ -4,6 +4,8 @@ #include "testing.h" +#include + #include "flutter/fml/file.h" #include "flutter/fml/paths.h" @@ -32,7 +34,7 @@ fml::UniqueFD OpenFixturesDirectory() { return fixtures_directory; } -fml::UniqueFD OpenFixture(std::string fixture_name) { +fml::UniqueFD OpenFixture(const std::string& fixture_name) { if (fixture_name.size() == 0) { FML_LOG(ERROR) << "Invalid fixture name."; return {}; @@ -54,7 +56,8 @@ fml::UniqueFD OpenFixture(std::string fixture_name) { return fixture_fd; } -std::unique_ptr OpenFixtureAsMapping(std::string fixture_name) { +std::unique_ptr OpenFixtureAsMapping( + const std::string& fixture_name) { return fml::FileMapping::CreateReadOnly(OpenFixture(fixture_name)); } diff --git a/testing/testing.h b/testing/testing.h index 3fd0cbd9a5193..43cf512162aed 100644 --- a/testing/testing.h +++ b/testing/testing.h @@ -59,7 +59,7 @@ fml::UniqueFD OpenFixturesDirectory(); /// @return The file descriptor of the given fixture. An invalid file /// descriptor is returned in case the fixture is not found. /// -fml::UniqueFD OpenFixture(std::string fixture_name); +fml::UniqueFD OpenFixture(const std::string& fixture_name); //------------------------------------------------------------------------------ /// @brief Opens a fixture of the given file name and returns a mapping to @@ -70,7 +70,8 @@ fml::UniqueFD OpenFixture(std::string fixture_name); /// @return A mapping to the contents of fixture or null if the fixture does /// not exist or its contents cannot be mapped in. /// -std::unique_ptr OpenFixtureAsMapping(std::string fixture_name); +std::unique_ptr OpenFixtureAsMapping( + const std::string& fixture_name); //------------------------------------------------------------------------------ /// @brief Gets the name of the currently running test. This is useful in diff --git a/testing/thread_test.cc b/testing/thread_test.cc index 2f67b6ee18368..64b082f1805c7 100644 --- a/testing/thread_test.cc +++ b/testing/thread_test.cc @@ -23,7 +23,8 @@ fml::RefPtr ThreadTest::GetCurrentTaskRunner() { return current_task_runner_; } -fml::RefPtr ThreadTest::CreateNewThread(std::string name) { +fml::RefPtr ThreadTest::CreateNewThread( + const std::string& name) { auto thread = std::make_unique(name); auto runner = thread->GetTaskRunner(); extra_threads_.emplace_back(std::move(thread)); diff --git a/testing/thread_test.h b/testing/thread_test.h index 4a7d60fb0312c..995bd45112a05 100644 --- a/testing/thread_test.h +++ b/testing/thread_test.h @@ -56,7 +56,7 @@ class ThreadTest : public ::testing::Test { /// /// @return The task runner for the newly created thread. /// - fml::RefPtr CreateNewThread(std::string name = ""); + fml::RefPtr CreateNewThread(const std::string& name = ""); private: fml::RefPtr current_task_runner_; diff --git a/vulkan/vulkan_application.cc b/vulkan/vulkan_application.cc index 31dd54aaa1bf1..c04522c54d8f6 100644 --- a/vulkan/vulkan_application.cc +++ b/vulkan/vulkan_application.cc @@ -218,7 +218,7 @@ VulkanApplication::GetSupportedInstanceExtensions( bool VulkanApplication::ExtensionSupported( const std::vector& supported_instance_extensions, - std::string extension_name) { + const std::string& extension_name) { uint32_t count = supported_instance_extensions.size(); for (size_t i = 0; i < count; i++) { if (strncmp(supported_instance_extensions[i].extensionName, diff --git a/vulkan/vulkan_application.h b/vulkan/vulkan_application.h index 3fbaf7aca9b9a..3abb558b512ef 100644 --- a/vulkan/vulkan_application.h +++ b/vulkan/vulkan_application.h @@ -56,7 +56,7 @@ class VulkanApplication { const VulkanProcTable& vk) const; bool ExtensionSupported( const std::vector& supported_extensions, - std::string extension_name); + const std::string& extension_name); FML_DISALLOW_COPY_AND_ASSIGN(VulkanApplication); }; diff --git a/vulkan/vulkan_device.cc b/vulkan/vulkan_device.cc index e58dd6e7db37f..16126133bbe66 100644 --- a/vulkan/vulkan_device.cc +++ b/vulkan/vulkan_device.cc @@ -300,9 +300,10 @@ std::vector VulkanDevice::GetQueueFamilyProperties() return properties; } -int VulkanDevice::ChooseSurfaceFormat(const VulkanSurface& surface, - std::vector desired_formats, - VkSurfaceFormatKHR* format) const { +int VulkanDevice::ChooseSurfaceFormat( + const VulkanSurface& surface, + const std::vector& desired_formats, + VkSurfaceFormatKHR* format) const { #if FML_OS_ANDROID if (!surface.IsValid() || format == nullptr) { return -1; diff --git a/vulkan/vulkan_device.h b/vulkan/vulkan_device.h index 22f848dd00e97..767624c01ebde 100644 --- a/vulkan/vulkan_device.h +++ b/vulkan/vulkan_device.h @@ -58,9 +58,10 @@ class VulkanDevice { [[nodiscard]] bool GetPhysicalDeviceFeaturesSkia( uint32_t* /* mask of GrVkFeatureFlags */ features) const; - [[nodiscard]] int ChooseSurfaceFormat(const VulkanSurface& surface, - std::vector desired_formats, - VkSurfaceFormatKHR* format) const; + [[nodiscard]] int ChooseSurfaceFormat( + const VulkanSurface& surface, + const std::vector& desired_formats, + VkSurfaceFormatKHR* format) const; [[nodiscard]] bool ChoosePresentMode(const VulkanSurface& surface, VkPresentModeKHR* present_mode) const; diff --git a/vulkan/vulkan_proc_table.cc b/vulkan/vulkan_proc_table.cc index f1ccbe88586b2..a4c21bf2d7065 100644 --- a/vulkan/vulkan_proc_table.cc +++ b/vulkan/vulkan_proc_table.cc @@ -4,6 +4,8 @@ #include "vulkan_proc_table.h" +#include + #include "flutter/fml/logging.h" #define ACQUIRE_PROC(name, context) \ @@ -26,7 +28,7 @@ VulkanProcTable::VulkanProcTable(const char* so_path) VulkanProcTable::VulkanProcTable( std::function get_instance_proc_addr) : handle_(nullptr), acquired_mandatory_proc_addresses_(false) { - GetInstanceProcAddr = get_instance_proc_addr; + GetInstanceProcAddr = std::move(get_instance_proc_addr); acquired_mandatory_proc_addresses_ = SetupLoaderProcAddresses(); }