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).
This commit is contained in:
Chinmay Garde 2019-04-09 19:18:51 -07:00 committed by GitHub
parent 905c571db5
commit e356dbca2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 39 additions and 74 deletions

View File

@ -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",
]

View File

@ -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

View File

@ -65,7 +65,6 @@ source_set("flow") {
deps = [
"$flutter_root/common",
"$flutter_root/fml",
"$flutter_root/synchronization",
"//third_party/skia",
]

View File

@ -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",

View File

@ -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 <dispatch/dispatch.h>
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 <windows.h>
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 <semaphore.h>
#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

View File

@ -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 <memory>
#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_

View File

@ -4,21 +4,21 @@
#include <thread>
#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();

View File

@ -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",
]

View File

@ -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<LayerTreePipeline> layer_tree_pipeline_;
Semaphore pending_frame_semaphore_;
fml::Semaphore pending_frame_semaphore_;
LayerTreePipeline::ProducerContinuation producer_continuation_;
int64_t frame_number_;
bool paused_;

View File

@ -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 {

View File

@ -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 <memory>
#include <mutex>
@ -142,8 +141,8 @@ class Pipeline : public fml::RefCountedThreadSafe<Pipeline<R>> {
}
private:
Semaphore empty_;
Semaphore available_;
fml::Semaphore empty_;
fml::Semaphore available_;
std::mutex queue_mutex_;
std::queue<std::pair<ResourcePtr, size_t>> queue_;
@ -162,4 +161,4 @@ class Pipeline : public fml::RefCountedThreadSafe<Pipeline<R>> {
} // namespace flutter
#endif // SYNCHRONIZATION_PIPELINE_H_
#endif // FLUTTER_SHELL_COMMON_PIPELINE_H_

View File

@ -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 {

View File

@ -11,7 +11,6 @@ gpu_common_deps = [
"$flutter_root/flow",
"$flutter_root/fml",
"$flutter_root/shell/common",
"$flutter_root/synchronization",
"//third_party/skia",
]

View File

@ -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",
]
}

View File

@ -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"