From e356dbca2c442ed751cf0d27fcf883e0279c4a87 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Tue, 9 Apr 2019 19:18:51 -0700 Subject: [PATCH] Merge flutter/synchronization contents into fml. (#8525) When flutter/synchronization was first authored, we did not own fml (it was called fxl then). Now we do, so use a single spot for such utilities. The pipeline was meant to be a general purpose utility that was only ever used by the animator (it even has animator specific tracing), so move that to shell instead (where the animator resides). --- BUILD.gn | 1 - ci/licenses_golden/licenses_flutter | 10 +++--- flow/BUILD.gn | 1 - fml/BUILD.gn | 3 ++ .../synchronization}/semaphore.cc | 18 +++++------ .../synchronization}/semaphore.h | 10 +++--- .../synchronization}/semaphore_unittest.cc | 8 ++--- shell/common/BUILD.gn | 3 +- shell/common/animator.h | 6 ++-- {synchronization => shell/common}/pipeline.cc | 2 +- {synchronization => shell/common}/pipeline.h | 13 ++++---- shell/common/rasterizer.h | 2 +- shell/gpu/BUILD.gn | 1 - synchronization/BUILD.gn | 32 ------------------- testing/run_tests.sh | 3 -- 15 files changed, 39 insertions(+), 74 deletions(-) rename {synchronization => fml/synchronization}/semaphore.cc (92%) rename {synchronization => fml/synchronization}/semaphore.h (75%) rename {synchronization => fml/synchronization}/semaphore_unittest.cc (80%) rename {synchronization => shell/common}/pipeline.cc (87%) rename {synchronization => shell/common}/pipeline.h (94%) delete mode 100644 synchronization/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 2766d1b986f..2e7cc0fa71e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -50,7 +50,6 @@ group("flutter") { "$flutter_root/runtime:runtime_unittests", "$flutter_root/shell/common:shell_unittests", "$flutter_root/shell/platform/embedder:embedder_unittests", - "$flutter_root/synchronization:synchronization_unittests", "$flutter_root/third_party/txt:txt_unittests", ] diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index c9288e49432..fcca26c69d6 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -219,6 +219,9 @@ FILE: ../../../flutter/fml/synchronization/atomic_object.h FILE: ../../../flutter/fml/synchronization/count_down_latch.cc FILE: ../../../flutter/fml/synchronization/count_down_latch.h FILE: ../../../flutter/fml/synchronization/count_down_latch_unittests.cc +FILE: ../../../flutter/fml/synchronization/semaphore.cc +FILE: ../../../flutter/fml/synchronization/semaphore.h +FILE: ../../../flutter/fml/synchronization/semaphore_unittest.cc FILE: ../../../flutter/fml/synchronization/shared_mutex.h FILE: ../../../flutter/fml/synchronization/shared_mutex_std.cc FILE: ../../../flutter/fml/synchronization/shared_mutex_std.h @@ -417,6 +420,8 @@ FILE: ../../../flutter/shell/common/isolate_configuration.cc FILE: ../../../flutter/shell/common/isolate_configuration.h FILE: ../../../flutter/shell/common/persistent_cache.cc FILE: ../../../flutter/shell/common/persistent_cache.h +FILE: ../../../flutter/shell/common/pipeline.cc +FILE: ../../../flutter/shell/common/pipeline.h FILE: ../../../flutter/shell/common/platform_view.cc FILE: ../../../flutter/shell/common/platform_view.h FILE: ../../../flutter/shell/common/rasterizer.cc @@ -717,11 +722,6 @@ FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.cc FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.h FILE: ../../../flutter/sky/packages/flutter_services/lib/empty.dart FILE: ../../../flutter/sky/tools/roll/patches/chromium/android_build.patch -FILE: ../../../flutter/synchronization/pipeline.cc -FILE: ../../../flutter/synchronization/pipeline.h -FILE: ../../../flutter/synchronization/semaphore.cc -FILE: ../../../flutter/synchronization/semaphore.h -FILE: ../../../flutter/synchronization/semaphore_unittest.cc FILE: ../../../flutter/third_party/txt/src/txt/platform.cc FILE: ../../../flutter/third_party/txt/src/txt/platform.h FILE: ../../../flutter/third_party/txt/src/txt/platform_android.cc diff --git a/flow/BUILD.gn b/flow/BUILD.gn index 23fc36d3a8b..756861f5e79 100644 --- a/flow/BUILD.gn +++ b/flow/BUILD.gn @@ -65,7 +65,6 @@ source_set("flow") { deps = [ "$flutter_root/common", "$flutter_root/fml", - "$flutter_root/synchronization", "//third_party/skia", ] diff --git a/fml/BUILD.gn b/fml/BUILD.gn index 629bb1c8229..614f1b1d5de 100644 --- a/fml/BUILD.gn +++ b/fml/BUILD.gn @@ -50,6 +50,8 @@ source_set("fml") { "synchronization/atomic_object.h", "synchronization/count_down_latch.cc", "synchronization/count_down_latch.h", + "synchronization/semaphore.cc", + "synchronization/semaphore.h", "synchronization/shared_mutex.h", "synchronization/thread_annotations.h", "synchronization/waitable_event.cc", @@ -188,6 +190,7 @@ executable("fml_unittests") { "paths_unittests.cc", "string_view_unittest.cc", "synchronization/count_down_latch_unittests.cc", + "synchronization/semaphore_unittest.cc", "synchronization/thread_annotations_unittest.cc", "synchronization/waitable_event_unittest.cc", "thread_local_unittests.cc", diff --git a/synchronization/semaphore.cc b/fml/synchronization/semaphore.cc similarity index 92% rename from synchronization/semaphore.cc rename to fml/synchronization/semaphore.cc index 4d8e5003d59..9dff734603a 100644 --- a/synchronization/semaphore.cc +++ b/fml/synchronization/semaphore.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/synchronization/semaphore.h" +#include "flutter/fml/synchronization/semaphore.h" #include "flutter/fml/build_config.h" #include "flutter/fml/logging.h" @@ -10,7 +10,7 @@ #if OS_MACOSX #include -namespace flutter { +namespace fml { class PlatformSemaphore { public: @@ -50,12 +50,12 @@ class PlatformSemaphore { FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore); }; -} // namespace flutter +} // namespace fml #elif OS_WIN #include -namespace flutter { +namespace fml { class PlatformSemaphore { public: @@ -91,13 +91,13 @@ class PlatformSemaphore { FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore); }; -} // namespace flutter +} // namespace fml #else #include #include "flutter/fml/eintr_wrapper.h" -namespace flutter { +namespace fml { class PlatformSemaphore { public: @@ -140,11 +140,11 @@ class PlatformSemaphore { FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore); }; -} // namespace flutter +} // namespace fml #endif -namespace flutter { +namespace fml { Semaphore::Semaphore(uint32_t count) : _impl(new PlatformSemaphore(count)) {} @@ -162,4 +162,4 @@ void Semaphore::Signal() { return _impl->Signal(); } -} // namespace flutter +} // namespace fml diff --git a/synchronization/semaphore.h b/fml/synchronization/semaphore.h similarity index 75% rename from synchronization/semaphore.h rename to fml/synchronization/semaphore.h index 594b0a559bc..b5871017b13 100644 --- a/synchronization/semaphore.h +++ b/fml/synchronization/semaphore.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SYNCHRONIZATION_SEMAPHORE_H_ -#define SYNCHRONIZATION_SEMAPHORE_H_ +#ifndef FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_ +#define FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_ #include #include "flutter/fml/compiler_specific.h" #include "flutter/fml/macros.h" -namespace flutter { +namespace fml { class PlatformSemaphore; @@ -33,6 +33,6 @@ class Semaphore { FML_DISALLOW_COPY_AND_ASSIGN(Semaphore); }; -} // namespace flutter +} // namespace fml -#endif // SYNCHRONIZATION_SEMAPHORE_H_ +#endif // FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_ diff --git a/synchronization/semaphore_unittest.cc b/fml/synchronization/semaphore_unittest.cc similarity index 80% rename from synchronization/semaphore_unittest.cc rename to fml/synchronization/semaphore_unittest.cc index 61810b641be..e109c6deb18 100644 --- a/synchronization/semaphore_unittest.cc +++ b/fml/synchronization/semaphore_unittest.cc @@ -4,21 +4,21 @@ #include -#include "flutter/synchronization/semaphore.h" +#include "flutter/fml/synchronization/semaphore.h" #include "gtest/gtest.h" TEST(SemaphoreTest, SimpleValidity) { - flutter::Semaphore sem(100); + fml::Semaphore sem(100); ASSERT_TRUE(sem.IsValid()); } TEST(SemaphoreTest, WaitOnZero) { - flutter::Semaphore sem(0); + fml::Semaphore sem(0); ASSERT_FALSE(sem.TryWait()); } TEST(SemaphoreTest, WaitOnZeroSignalThenWait) { - flutter::Semaphore sem(0); + fml::Semaphore sem(0); ASSERT_FALSE(sem.TryWait()); std::thread thread([&sem]() { sem.Signal(); }); thread.join(); diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index fcfcd156d2a..0e5c5b90d71 100644 --- a/shell/common/BUILD.gn +++ b/shell/common/BUILD.gn @@ -68,6 +68,8 @@ source_set("common") { "isolate_configuration.h", "persistent_cache.cc", "persistent_cache.h", + "pipeline.cc", + "pipeline.h", "platform_view.cc", "platform_view.h", "rasterizer.cc", @@ -99,7 +101,6 @@ source_set("common") { "$flutter_root/fml", "$flutter_root/lib/ui", "$flutter_root/runtime", - "$flutter_root/synchronization", "//third_party/dart/runtime:dart_api", "//third_party/skia", ] diff --git a/shell/common/animator.h b/shell/common/animator.h index c8397befab9..e0cd52bf7bc 100644 --- a/shell/common/animator.h +++ b/shell/common/animator.h @@ -10,11 +10,11 @@ #include "flutter/common/task_runners.h" #include "flutter/fml/memory/ref_ptr.h" #include "flutter/fml/memory/weak_ptr.h" +#include "flutter/fml/synchronization/semaphore.h" #include "flutter/fml/time/time_point.h" +#include "flutter/shell/common/pipeline.h" #include "flutter/shell/common/rasterizer.h" #include "flutter/shell/common/vsync_waiter.h" -#include "flutter/synchronization/pipeline.h" -#include "flutter/synchronization/semaphore.h" namespace flutter { @@ -74,7 +74,7 @@ class Animator final { fml::TimePoint last_begin_frame_time_; int64_t dart_frame_deadline_; fml::RefPtr layer_tree_pipeline_; - Semaphore pending_frame_semaphore_; + fml::Semaphore pending_frame_semaphore_; LayerTreePipeline::ProducerContinuation producer_continuation_; int64_t frame_number_; bool paused_; diff --git a/synchronization/pipeline.cc b/shell/common/pipeline.cc similarity index 87% rename from synchronization/pipeline.cc rename to shell/common/pipeline.cc index 2baede8dfbd..fb80c187181 100644 --- a/synchronization/pipeline.cc +++ b/shell/common/pipeline.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/synchronization/pipeline.h" +#include "flutter/shell/common/pipeline.h" namespace flutter { diff --git a/synchronization/pipeline.h b/shell/common/pipeline.h similarity index 94% rename from synchronization/pipeline.h rename to shell/common/pipeline.h index 3aafc1767a7..b9aa1d89c6c 100644 --- a/synchronization/pipeline.h +++ b/shell/common/pipeline.h @@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SYNCHRONIZATION_PIPELINE_H_ -#define SYNCHRONIZATION_PIPELINE_H_ +#ifndef FLUTTER_SHELL_COMMON_PIPELINE_H_ +#define FLUTTER_SHELL_COMMON_PIPELINE_H_ #include "flutter/fml/macros.h" #include "flutter/fml/memory/ref_counted.h" +#include "flutter/fml/synchronization/semaphore.h" #include "flutter/fml/trace_event.h" -#include "flutter/synchronization/pipeline.h" -#include "flutter/synchronization/semaphore.h" #include #include @@ -142,8 +141,8 @@ class Pipeline : public fml::RefCountedThreadSafe> { } private: - Semaphore empty_; - Semaphore available_; + fml::Semaphore empty_; + fml::Semaphore available_; std::mutex queue_mutex_; std::queue> queue_; @@ -162,4 +161,4 @@ class Pipeline : public fml::RefCountedThreadSafe> { } // namespace flutter -#endif // SYNCHRONIZATION_PIPELINE_H_ +#endif // FLUTTER_SHELL_COMMON_PIPELINE_H_ diff --git a/shell/common/rasterizer.h b/shell/common/rasterizer.h index f3df4819e33..f9d472b3808 100644 --- a/shell/common/rasterizer.h +++ b/shell/common/rasterizer.h @@ -14,8 +14,8 @@ #include "flutter/fml/memory/weak_ptr.h" #include "flutter/fml/synchronization/waitable_event.h" #include "flutter/lib/ui/snapshot_delegate.h" +#include "flutter/shell/common/pipeline.h" #include "flutter/shell/common/surface.h" -#include "flutter/synchronization/pipeline.h" namespace flutter { diff --git a/shell/gpu/BUILD.gn b/shell/gpu/BUILD.gn index 02130c85e18..93e94429684 100644 --- a/shell/gpu/BUILD.gn +++ b/shell/gpu/BUILD.gn @@ -11,7 +11,6 @@ gpu_common_deps = [ "$flutter_root/flow", "$flutter_root/fml", "$flutter_root/shell/common", - "$flutter_root/synchronization", "//third_party/skia", ] diff --git a/synchronization/BUILD.gn b/synchronization/BUILD.gn deleted file mode 100644 index 95b8655964b..00000000000 --- a/synchronization/BUILD.gn +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2013 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -source_set("synchronization") { - sources = [ - "pipeline.cc", - "pipeline.h", - "semaphore.cc", - "semaphore.h", - ] - - public_configs = [ "$flutter_root:config" ] - - public_deps = [ - "$flutter_root/fml", - ] -} - -executable("synchronization_unittests") { - testonly = true - - sources = [ - "semaphore_unittest.cc", - ] - - deps = [ - ":synchronization", - "$flutter_root/testing", - "//third_party/dart/runtime:libdart_jit", - ] -} diff --git a/testing/run_tests.sh b/testing/run_tests.sh index ea491b4bb72..66126634646 100755 --- a/testing/run_tests.sh +++ b/testing/run_tests.sh @@ -38,9 +38,6 @@ echo "Running runtime_unittests..." echo "Running shell_unittests..." "$HOST_DIR/shell_unittests" -echo "Running synchronization_unittests..." -"$HOST_DIR/synchronization_unittests" - echo "Running txt_unittests..." "$HOST_DIR/txt_unittests" --font-directory="$BUILDROOT_DIR/flutter/third_party/txt/third_party/fonts"