diff --git a/BUILD.gn b/BUILD.gn index c478f43d46cc3049ec598421224c29c06e3bb245..fdf35daae9aa37e3a6f16359ee504788d23be662 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -24,7 +24,6 @@ group("flutter") { if (is_ios) { deps += [ "//flutter/services/dynamic:sdk_lib_archive", - "//flutter/sky/shell:flutter_framework", ] } } diff --git a/DEPS b/DEPS index c40f9aeded17508febba84ddd59e45a13753b83a..c1c02830c373539fc9b6d52592026ef0417daaa6 100644 --- a/DEPS +++ b/DEPS @@ -45,7 +45,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + '7b77c0acedf708749b68304cc5f0ac469c9d7136', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + '1c9494e60378bd119d910d530344077fc091b3a5', # Fuchsia compatibility # diff --git a/shell/BUILD.gn b/shell/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..dfaacd545f37e79165f0f86f972681d8cc6e6a51 --- /dev/null +++ b/shell/BUILD.gn @@ -0,0 +1,7 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +group("shell") { + deps = [ "platform" ] +} diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ad283f39af661d6b8305bf0b6ebd86354a4c5a94 --- /dev/null +++ b/shell/common/BUILD.gn @@ -0,0 +1,70 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//mojo/dart/embedder/embedder.gni") + +dart_embedder_resources("generate_embedder_diagnostic_server_resources_cc") { + inputs = [ + "//flutter/shell/common/diagnostic/diagnostic_server.dart" + ] + root_prefix = "//flutter/shell/common/diagnostic/" + output = "$target_gen_dir/embedder_diagnostic_server_resources.cc" + table_name = "sky_embedder_diagnostic_server" +} + +source_set("common") { + sources = [ + "$target_gen_dir/embedder_diagnostic_server_resources.cc", + "animator.cc", + "animator.h", + "diagnostic/diagnostic_server.cc", + "diagnostic/diagnostic_server.h", + "engine.cc", + "engine.h", + "picture_serializer.cc", + "picture_serializer.h", + "platform_view.cc", + "platform_view.h", + "platform_view_service_protocol.cc", + "platform_view_service_protocol.h", + "rasterizer.cc", + "rasterizer.h", + "shell.cc", + "shell.h", + "switches.cc", + "switches.h", + "systrace_logger.cc", + "systrace_logger.h", + "tracing_controller.cc", + "tracing_controller.h", + "ui_delegate.cc", + "ui_delegate.h", + ] + + deps = [ + "//base", + "//base:i18n", + "//dart/runtime/vm:libdart_platform", + "//dart/runtime:libdart", + "//flutter/assets", + "//flutter/common", + "//flutter/flow", + "//flutter/glue", + "//flutter/lib/ui", + "//flutter/runtime", + "//flutter/services/engine:interfaces", + "//flutter/services/vsync", + "//flutter/skia", + "//flutter/sky/engine/wtf", + "//flutter/synchronization", + "//lib/ftl", + "//lib/tonic", + "//mojo/application", + "//mojo/message_pump", + "//mojo/public/cpp/bindings:utility", + "//mojo/public/interfaces/application", + "//mojo/services/vsync/interfaces", + ":generate_embedder_diagnostic_server_resources_cc", + ] +} diff --git a/sky/shell/ui/animator.cc b/shell/common/animator.cc similarity index 97% rename from sky/shell/ui/animator.cc rename to shell/common/animator.cc index 25b57574711f215bc00708e6964f372b77821970..d7f419ed18a684b11dc21ee4ac88b8b6fdfb6c24 100644 --- a/sky/shell/ui/animator.cc +++ b/shell/common/animator.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/sky/shell/ui/animator.h" +#include "flutter/shell/common/animator.h" #include "base/bind.h" #include "base/message_loop/message_loop.h" @@ -10,7 +10,6 @@ #include "flutter/common/threads.h" #include "lib/ftl/time/stopwatch.h" -namespace sky { namespace shell { Animator::Animator(Rasterizer* rasterizer, Engine* engine) @@ -20,7 +19,7 @@ Animator::Animator(Rasterizer* rasterizer, Engine* engine) pending_frame_semaphore_(1), paused_(false), weak_factory_(this) { - new services::vsync::VsyncProviderFallbackImpl( + new sky::services::vsync::VsyncProviderFallbackImpl( mojo::InterfaceRequest<::vsync::VSyncProvider>( mojo::GetProxy(&fallback_vsync_provider_))); } @@ -144,4 +143,3 @@ void Animator::AwaitVSync( } } // namespace shell -} // namespace sky diff --git a/sky/shell/ui/animator.h b/shell/common/animator.h similarity index 87% rename from sky/shell/ui/animator.h rename to shell/common/animator.h index 81c0650bd39b8f3b32269eaf5d211ee0baec9ba0..2f95c5927d609381f01ebce11151b1871eef2c04 100644 --- a/sky/shell/ui/animator.h +++ b/shell/common/animator.h @@ -2,20 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_UI_ANIMATOR_H_ -#define SKY_SHELL_UI_ANIMATOR_H_ +#ifndef SHELL_COMMON_ANIMATOR_H_ +#define SHELL_COMMON_ANIMATOR_H_ #include "base/memory/weak_ptr.h" -#include "flutter/sky/shell/rasterizer.h" -#include "flutter/sky/shell/ui/engine.h" +#include "flutter/services/vsync/fallback/vsync_provider_fallback_impl.h" +#include "flutter/shell/common/engine.h" +#include "flutter/shell/common/rasterizer.h" #include "flutter/synchronization/pipeline.h" #include "flutter/synchronization/semaphore.h" #include "lib/ftl/memory/ref_ptr.h" #include "lib/ftl/time/time_point.h" #include "mojo/services/vsync/interfaces/vsync.mojom.h" -#include "flutter/services/vsync/fallback/vsync_provider_fallback_impl.h" -namespace sky { namespace shell { class Animator { @@ -57,6 +56,5 @@ class Animator { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_UI_ANIMATOR_H_ +#endif // SHELL_COMMON_ANIMATOR_H_ diff --git a/sky/shell/diagnostic/diagnostic_server.cc b/shell/common/diagnostic/diagnostic_server.cc similarity index 93% rename from sky/shell/diagnostic/diagnostic_server.cc rename to shell/common/diagnostic/diagnostic_server.cc index 5b671bcffbef3d158a063783fcd7950952ac1c1c..296a65569125785cfa972bbc615d8fc4c2c9593e 100644 --- a/sky/shell/diagnostic/diagnostic_server.cc +++ b/shell/common/diagnostic/diagnostic_server.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/diagnostic/diagnostic_server.h" +#include "flutter/shell/common/diagnostic/diagnostic_server.h" #include "dart/runtime/include/dart_api.h" #include "dart/runtime/include/dart_native_api.h" #include "flutter/common/threads.h" #include "flutter/flow/compositor_context.h" #include "flutter/runtime/embedder_resources.h" -#include "flutter/sky/shell/gpu/picture_serializer.h" -#include "flutter/sky/shell/rasterizer.h" -#include "flutter/sky/shell/shell.h" -#include "flutter/sky/shell/ui/engine.h" +#include "flutter/shell/common/engine.h" +#include "flutter/shell/common/rasterizer.h" +#include "flutter/shell/common/shell.h" +#include "flutter/shell/common/picture_serializer.h" #include "lib/ftl/logging.h" #include "lib/tonic/dart_binding_macros.h" #include "lib/tonic/dart_library_natives.h" @@ -25,7 +25,6 @@ extern ResourcesEntry __sky_embedder_diagnostic_server_resources_[]; } } -namespace sky { namespace shell { using tonic::DartLibraryNatives; @@ -134,7 +133,7 @@ void DiagnosticServer::SkiaPictureTask(Dart_Port port_id) { sk_sp picture = recorder.finishRecordingAsPicture(); SkDynamicMemoryWStream stream; - sky::PngPixelSerializer serializer; + PngPixelSerializer serializer; picture->serialize(&stream, &serializer); SkAutoTUnref picture_data(stream.copyToData()); @@ -149,4 +148,3 @@ void DiagnosticServer::SkiaPictureTask(Dart_Port port_id) { } } // namespace shell -} // namespace sky diff --git a/sky/shell/diagnostic/diagnostic_server.dart b/shell/common/diagnostic/diagnostic_server.dart similarity index 100% rename from sky/shell/diagnostic/diagnostic_server.dart rename to shell/common/diagnostic/diagnostic_server.dart diff --git a/sky/shell/diagnostic/diagnostic_server.h b/shell/common/diagnostic/diagnostic_server.h similarity index 94% rename from sky/shell/diagnostic/diagnostic_server.h rename to shell/common/diagnostic/diagnostic_server.h index 2bf50f7ea2ade56c85a8cf86ee3ced878e6f8b35..00553ca2e35962b206a488fbc425e8a08e2f4fda 100644 --- a/sky/shell/diagnostic/diagnostic_server.h +++ b/shell/common/diagnostic/diagnostic_server.h @@ -7,7 +7,6 @@ #include "dart/runtime/include/dart_api.h" -namespace sky { namespace shell { class DiagnosticServer { @@ -20,6 +19,5 @@ class DiagnosticServer { }; } // namespace shell -} // namespace sky #endif // SKY_ENGINE_CORE_DIAGNOSTIC_DIAGNOSTIC_SERVER_H_ diff --git a/sky/shell/ui/engine.cc b/shell/common/engine.cc similarity index 97% rename from sky/shell/ui/engine.cc rename to shell/common/engine.cc index 11ef2d0eb44757b3ad9103e6c62efe8aa20ccede..1e8dc278fc57199b281b59e59ce2bd51e89ebc7a 100644 --- a/sky/shell/ui/engine.cc +++ b/shell/common/engine.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/sky/shell/ui/engine.h" +#include "flutter/shell/common/engine.h" #include #include @@ -19,14 +19,13 @@ #include "flutter/runtime/dart_controller.h" #include "flutter/runtime/dart_init.h" #include "flutter/runtime/runtime_init.h" +#include "flutter/shell/common/animator.h" #include "flutter/sky/engine/public/web/Sky.h" -#include "flutter/sky/shell/ui/animator.h" #include "lib/ftl/files/path.h" #include "mojo/public/cpp/application/connect.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkPictureRecorder.h" -namespace sky { namespace shell { namespace { @@ -115,7 +114,7 @@ void Engine::OnOutputSurfaceDestroyed(const ftl::Closure& gpu_continuation) { blink::Threads::Gpu()->PostTask(gpu_continuation); } -void Engine::SetServices(ServicesDataPtr services) { +void Engine::SetServices(sky::ServicesDataPtr services) { services_ = services.Pass(); if (services_->incoming_services) { @@ -140,7 +139,7 @@ void Engine::SetServices(ServicesDataPtr services) { animator_->set_vsync_provider(vsync_provider.Pass()); } -void Engine::OnViewportMetricsChanged(ViewportMetricsPtr metrics) { +void Engine::OnViewportMetricsChanged(sky::ViewportMetricsPtr metrics) { viewport_metrics_ = metrics.Pass(); if (runtime_) runtime_->SetViewportMetrics(viewport_metrics_); @@ -335,4 +334,3 @@ void Engine::Render(std::unique_ptr layer_tree) { } } // namespace shell -} // namespace sky diff --git a/sky/shell/ui/engine.h b/shell/common/engine.h similarity index 89% rename from sky/shell/ui/engine.h rename to shell/common/engine.h index 77c41987d76ed291f9435a6140057618a00bd49b..f0601a04df98a5d2c0d6a5741704785d2b5fa02a 100644 --- a/sky/shell/ui/engine.h +++ b/shell/common/engine.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_UI_ENGINE_H_ -#define SKY_SHELL_UI_ENGINE_H_ +#ifndef SHELL_COMMON_ENGINE_H_ +#define SHELL_COMMON_ENGINE_H_ #include "flutter/assets/zip_asset_store.h" #include "flutter/glue/drain_data_pipe_job.h" #include "flutter/runtime/runtime_controller.h" #include "flutter/runtime/runtime_delegate.h" #include "flutter/services/engine/sky_engine.mojom.h" -#include "flutter/sky/shell/rasterizer.h" -#include "flutter/sky/shell/ui_delegate.h" +#include "flutter/shell/common/rasterizer.h" +#include "flutter/shell/common/ui_delegate.h" #include "lib/ftl/macros.h" #include "lib/ftl/memory/weak_ptr.h" #include "mojo/public/cpp/application/service_provider_impl.h" @@ -23,13 +23,11 @@ #include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h" #include "third_party/skia/include/core/SkPicture.h" -namespace sky { -class PlatformImpl; namespace shell { class Animator; class Engine : public UIDelegate, - public SkyEngine, + public sky::SkyEngine, public blink::RuntimeDelegate { public: explicit Engine(Rasterizer* rasterizer); @@ -57,8 +55,8 @@ class Engine : public UIDelegate, void OnOutputSurfaceDestroyed(const ftl::Closure& gpu_continuation) override; // SkyEngine implementation: - void SetServices(ServicesDataPtr services) override; - void OnViewportMetricsChanged(ViewportMetricsPtr metrics) override; + void SetServices(sky::ServicesDataPtr services) override; + void OnViewportMetricsChanged(sky::ViewportMetricsPtr metrics) override; void OnLocaleChanged(const mojo::String& language_code, const mojo::String& country_code) override; void OnPointerPacket(pointer::PointerPacketPtr packet) override; @@ -96,7 +94,7 @@ class Engine : public UIDelegate, std::unique_ptr animator_; - ServicesDataPtr services_; + sky::ServicesDataPtr services_; mojo::ServiceProviderImpl service_provider_impl_; mojo::ServiceProviderPtr incoming_services_; mojo::BindingSet service_provider_bindings_; @@ -107,7 +105,7 @@ class Engine : public UIDelegate, std::unique_ptr snapshot_drainer_; std::string initial_route_; - ViewportMetricsPtr viewport_metrics_; + sky::ViewportMetricsPtr viewport_metrics_; std::string language_code_; std::string country_code_; mojo::Binding binding_; @@ -123,6 +121,5 @@ class Engine : public UIDelegate, }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_UI_ENGINE_H_ +#endif // SHELL_COMMON_ENGINE_H_ diff --git a/sky/shell/gpu/picture_serializer.cc b/shell/common/picture_serializer.cc similarity index 91% rename from sky/shell/gpu/picture_serializer.cc rename to shell/common/picture_serializer.cc index 3176a0ab06d066c5501d88bc579df5f9641b376d..b925cf2948181802ab7c86fcef5c34403af04aa3 100644 --- a/sky/shell/gpu/picture_serializer.cc +++ b/shell/common/picture_serializer.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/sky/shell/gpu/picture_serializer.h" +#include "flutter/shell/common/picture_serializer.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkData.h" @@ -10,7 +10,7 @@ #include "third_party/skia/include/core/SkPixelSerializer.h" #include "third_party/skia/include/core/SkStream.h" -namespace sky { +namespace shell { bool PngPixelSerializer::onUseEncodedData(const void*, size_t) { return true; @@ -33,4 +33,4 @@ void SerializePicture(const std::string& path, SkPicture* picture) { picture->serialize(&stream, &serializer); } -} // namespace sky +} // namespace shell diff --git a/sky/shell/gpu/picture_serializer.h b/shell/common/picture_serializer.h similarity index 76% rename from sky/shell/gpu/picture_serializer.h rename to shell/common/picture_serializer.h index b5f75135af602df32c624d41b478987690810c40..9c7d5dd148b6972ff385de4c71dcf50c3e50f938 100644 --- a/sky/shell/gpu/picture_serializer.h +++ b/shell/common/picture_serializer.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 SKY_SHELL_GPU_PICTURE_SERIALIZER_H_ -#define SKY_SHELL_GPU_PICTURE_SERIALIZER_H_ +#ifndef SHELL_GPU_PICTURE_SERIALIZER_H_ +#define SHELL_GPU_PICTURE_SERIALIZER_H_ #include #include "third_party/skia/include/core/SkPicture.h" #include "third_party/skia/include/core/SkPixelSerializer.h" -namespace sky { +namespace shell { class PngPixelSerializer : public SkPixelSerializer { public: @@ -20,6 +20,6 @@ class PngPixelSerializer : public SkPixelSerializer { void SerializePicture(const std::string& path, SkPicture* picture); -} // namespace sky +} // namespace shell -#endif // SKY_SHELL_GPU_PICTURE_SERIALIZER_H_ +#endif // SHELL_GPU_PICTURE_SERIALIZER_H_ diff --git a/sky/shell/platform_view.cc b/shell/common/platform_view.cc similarity index 95% rename from sky/shell/platform_view.cc rename to shell/common/platform_view.cc index 1bc29b381618d87dccea7641b76a66957d28bfb9..7f16ad99246178f96f022df9efea05828071f1b1 100644 --- a/sky/shell/platform_view.cc +++ b/shell/common/platform_view.cc @@ -2,17 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform_view.h" +#include "flutter/shell/common/platform_view.h" #include #include "flutter/common/threads.h" #include "flutter/glue/movable_wrapper.h" #include "flutter/lib/ui/painting/resource_context.h" -#include "flutter/sky/shell/rasterizer.h" +#include "flutter/shell/common/rasterizer.h" #include "third_party/skia/include/gpu/gl/GrGLInterface.h" -namespace sky { namespace shell { PlatformView::Config::Config() : rasterizer(nullptr) {} @@ -39,7 +38,8 @@ PlatformView::~PlatformView() { blink::Threads::UI()->PostTask([engine]() { delete engine; }); } -void PlatformView::ConnectToEngine(mojo::InterfaceRequest request) { +void PlatformView::ConnectToEngine( + mojo::InterfaceRequest request) { ftl::WeakPtr ui_delegate = config_.ui_delegate; auto wrapped_request = glue::WrapMovable(std::move(request)); blink::Threads::UI()->PostTask([ui_delegate, wrapped_request]() mutable { @@ -138,4 +138,3 @@ void PlatformView::SetupResourceContextOnIOThreadPerform( } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform_view.h b/shell/common/platform_view.h similarity index 81% rename from sky/shell/platform_view.h rename to shell/common/platform_view.h index 93c86e73646de6521d073db93868693688623751..543bcca927d7d8850455fc2049c85a2b228e6a03 100644 --- a/sky/shell/platform_view.h +++ b/shell/common/platform_view.h @@ -2,21 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_VIEW_H_ -#define SKY_SHELL_PLATFORM_VIEW_H_ +#ifndef COMMON_PLATFORM_VIEW_H_ +#define COMMON_PLATFORM_VIEW_H_ #include +#include "flutter/shell/common/engine.h" +#include "flutter/shell/common/shell.h" +#include "flutter/shell/common/ui_delegate.h" #include "lib/ftl/macros.h" #include "lib/ftl/memory/weak_ptr.h" #include "lib/ftl/synchronization/waitable_event.h" -#include "flutter/sky/shell/shell.h" -#include "flutter/sky/shell/ui_delegate.h" -#include "flutter/sky/shell/ui/engine.h" #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/gpu/GrContext.h" -namespace sky { namespace shell { class Rasterizer; @@ -45,7 +44,7 @@ class PlatformView { virtual ~PlatformView(); - void ConnectToEngine(mojo::InterfaceRequest request); + void ConnectToEngine(mojo::InterfaceRequest request); void NotifyCreated(); @@ -53,7 +52,7 @@ class PlatformView { void NotifyDestroyed(); - virtual ftl::WeakPtr GetWeakViewPtr() = 0; + virtual ftl::WeakPtr GetWeakViewPtr() = 0; virtual uint64_t DefaultFramebuffer() const = 0; @@ -92,6 +91,5 @@ class PlatformView { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_VIEW_H_ +#endif // COMMON_PLATFORM_VIEW_H_ diff --git a/sky/shell/platform_view_service_protocol.cc b/shell/common/platform_view_service_protocol.cc similarity index 94% rename from sky/shell/platform_view_service_protocol.cc rename to shell/common/platform_view_service_protocol.cc index 49f0effbdd835558f6230b9051ff3156cda792dd..3b0a53fe74b7d7a24c08c18a473d823ae22ee228 100644 --- a/sky/shell/platform_view_service_protocol.cc +++ b/shell/common/platform_view_service_protocol.cc @@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform_view_service_protocol.h" +#include "flutter/shell/common/platform_view_service_protocol.h" #include #include -#include "flutter/sky/shell/shell.h" +#include "flutter/shell/common/shell.h" -namespace sky { namespace shell { namespace { @@ -90,9 +89,10 @@ static void AppendFlutterView(std::stringstream* stream, *stream << "{\"type\":\"FlutterView\", \"id\": \"" << kViewIdPrefx << "0x" << std::hex << view_id << std::dec; if (isolate_id != ILLEGAL_PORT) { - // Append the isolate (if it exists). - *stream << "\"," << "\"isolate\":"; - AppendIsolateRef(stream, isolate_id, isolate_name); + // Append the isolate (if it exists). + *stream << "\"," + << "\"isolate\":"; + AppendIsolateRef(stream, isolate_id, isolate_name); } *stream << "}"; } @@ -155,9 +155,7 @@ bool PlatformViewServiceProtocol::RunInView(const char* method, Dart_Port main_port = ILLEGAL_PORT; std::string isolate_name; shell.RunInPlatformView(view_id_as_num, main_script, packages_file, - asset_directory, - &view_existed, - &main_port, + asset_directory, &view_existed, &main_port, &isolate_name); if (!view_existed) { @@ -216,4 +214,3 @@ bool PlatformViewServiceProtocol::ListViews(const char* method, } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform_view_service_protocol.h b/shell/common/platform_view_service_protocol.h similarity index 81% rename from sky/shell/platform_view_service_protocol.h rename to shell/common/platform_view_service_protocol.h index b80fbbf6240d350ea565de02036da493afedef9b..599ea2aa28963642cf15bc56d91b2d22c74c42bd 100644 --- a/sky/shell/platform_view_service_protocol.h +++ b/shell/common/platform_view_service_protocol.h @@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_VIEW_SERVICE_PROTOCOL_H_ -#define SKY_SHELL_PLATFORM_VIEW_SERVICE_PROTOCOL_H_ +#ifndef SHELL_COMMON_VIEW_SERVICE_PROTOCOL_H_ +#define SHELL_COMMON_VIEW_SERVICE_PROTOCOL_H_ #include -#include "flutter/sky/shell/platform_view.h" #include "dart/runtime/include/dart_tools_api.h" +#include "flutter/shell/common/platform_view.h" -namespace sky { namespace shell { class PlatformViewServiceProtocol { @@ -36,6 +35,5 @@ class PlatformViewServiceProtocol { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_VIEW_SERVICE_PROTOCOL_H_ +#endif // SHELL_COMMON_VIEW_SERVICE_PROTOCOL_H_ diff --git a/sky/shell/rasterizer.cc b/shell/common/rasterizer.cc similarity index 65% rename from sky/shell/rasterizer.cc rename to shell/common/rasterizer.cc index 65de878dc7b392b6af8f5d97bb67256aeb9e5ca7..0c32386b1077974fe1d13105e78908f61cf9a494 100644 --- a/sky/shell/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -2,13 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/rasterizer.h" +#include "flutter/shell/common/rasterizer.h" -namespace sky { namespace shell { -Rasterizer::~Rasterizer() { -} +Rasterizer::~Rasterizer() {} } // namespace shell -} // namespace sky diff --git a/sky/shell/rasterizer.h b/shell/common/rasterizer.h similarity index 89% rename from sky/shell/rasterizer.h rename to shell/common/rasterizer.h index a0d96942a6286405fe1b58bbe830830b161d3a47..4c5619ccb20d6919f061453dc0c00b6ff0d5cbe2 100644 --- a/sky/shell/rasterizer.h +++ b/shell/common/rasterizer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_RASTERIZER_H_ -#define SKY_SHELL_RASTERIZER_H_ +#ifndef SHELL_COMMON_RASTERIZER_H_ +#define SHELL_COMMON_RASTERIZER_H_ #include @@ -14,7 +14,6 @@ #include "lib/ftl/synchronization/waitable_event.h" #include "mojo/public/cpp/bindings/binding.h" -namespace sky { namespace shell { class PlatformView; @@ -44,6 +43,5 @@ class Rasterizer { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_RASTERIZER_H_ +#endif // SHELL_COMMON_RASTERIZER_H_ diff --git a/sky/shell/shell.cc b/shell/common/shell.cc similarity index 97% rename from sky/shell/shell.cc rename to shell/common/shell.cc index a4fd0593dc11279858755aedba5eb4977220e7f8..ee6e53fbe812d6033120feab6721a19ac46f1200 100644 --- a/sky/shell/shell.cc +++ b/shell/common/shell.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/sky/shell/shell.h" +#include "flutter/shell/common/shell.h" #include #include @@ -12,8 +12,8 @@ #include "base/command_line.h" #include "base/i18n/icu_util.h" #include "base/lazy_instance.h" -#include "base/memory/discardable_memory_allocator.h" #include "base/memory/discardable_memory.h" +#include "base/memory/discardable_memory_allocator.h" #include "base/posix/eintr_wrapper.h" #include "base/single_thread_task_runner.h" #include "base/trace_event/trace_event.h" @@ -22,15 +22,14 @@ #include "flutter/common/threads.h" #include "flutter/glue/task_runner_adaptor.h" #include "flutter/runtime/dart_init.h" +#include "flutter/shell/common/engine.h" +#include "flutter/shell/common/platform_view_service_protocol.h" +#include "flutter/shell/common/switches.h" +#include "flutter/shell/common/diagnostic/diagnostic_server.h" #include "flutter/skia/ext/event_tracer_impl.h" -#include "flutter/sky/shell/diagnostic/diagnostic_server.h" -#include "flutter/sky/shell/platform_view_service_protocol.h" -#include "flutter/sky/shell/switches.h" -#include "flutter/sky/shell/ui/engine.h" #include "lib/ftl/files/unique_fd.h" #include "mojo/message_pump/message_pump_mojo.h" -namespace sky { namespace shell { namespace { @@ -326,4 +325,3 @@ void Shell::RunInPlatformViewUIThread(uintptr_t view_id, } } // namespace shell -} // namespace sky diff --git a/sky/shell/shell.h b/shell/common/shell.h similarity index 95% rename from sky/shell/shell.h rename to shell/common/shell.h index 60a86cc9c9e7de1e617fa65fd08fadb59c5403c9..cdab8dc8d753d8bbb9d2414f9c5687cb502b1358 100644 --- a/sky/shell/shell.h +++ b/shell/common/shell.h @@ -2,18 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_SHELL_H_ -#define SKY_SHELL_SHELL_H_ +#ifndef SHELL_COMMON_SHELL_H_ +#define SHELL_COMMON_SHELL_H_ #include "base/threading/thread.h" +#include "flutter/shell/common/tracing_controller.h" #include "lib/ftl/macros.h" #include "lib/ftl/memory/ref_ptr.h" #include "lib/ftl/memory/weak_ptr.h" #include "lib/ftl/synchronization/waitable_event.h" #include "lib/ftl/tasks/task_runner.h" -#include "flutter/sky/shell/tracing_controller.h" -namespace sky { namespace shell { class PlatformView; @@ -102,6 +101,5 @@ class Shell { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_SHELL_H_ +#endif // SHELL_COMMON_SHELL_H_ diff --git a/sky/shell/switches.cc b/shell/common/switches.cc similarity index 95% rename from sky/shell/switches.cc rename to shell/common/switches.cc index b648a9c4d99d1f40d8967cc7117cebe055e8e6ff..7e1e207f90f7e3e5c5140914c3515d993aee9eca 100644 --- a/sky/shell/switches.cc +++ b/shell/common/switches.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/switches.h" +#include "flutter/shell/common/switches.h" #include -namespace sky { namespace shell { namespace switches { @@ -44,4 +43,3 @@ void PrintUsage(const std::string& executable_name) { } // namespace switches } // namespace shell -} // namespace sky diff --git a/sky/shell/switches.h b/shell/common/switches.h similarity index 88% rename from sky/shell/switches.h rename to shell/common/switches.h index 74628139ca2dc6055a3335fe2399b0fa46774079..0f7c15a0cbb261ab01d651eceb573704334564df 100644 --- a/sky/shell/switches.h +++ b/shell/common/switches.h @@ -2,12 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_SWITCHES_H_ -#define SKY_SHELL_SWITCHES_H_ +#ifndef SHELL_COMMON_SWITCHES_H_ +#define SHELL_COMMON_SWITCHES_H_ #include -namespace sky { namespace shell { namespace switches { @@ -34,6 +33,5 @@ void PrintUsage(const std::string& executable_name); } // namespace switches } // namespace shell -} // namespace sky -#endif // SKY_SHELL_SWITCHES_H_ +#endif // SHELL_COMMON_SWITCHES_H_ diff --git a/sky/shell/systrace_logger.cc b/shell/common/systrace_logger.cc similarity index 94% rename from sky/shell/systrace_logger.cc rename to shell/common/systrace_logger.cc index 0db515e3e156a6a2bddeaac4ec2d22155dcac05f..1e13ecfb356583ca8dfe9b43714a73d2a5efb8b2 100644 --- a/sky/shell/systrace_logger.cc +++ b/shell/common/systrace_logger.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/systrace_logger.h" +#include "flutter/shell/common/systrace_logger.h" + #include "lib/ftl/files/eintr_wrapper.h" #include -#include #include #include +#include -namespace sky { namespace shell { static const int kBufferSize = 256; @@ -53,4 +53,3 @@ void SystraceLogger::TraceCount(const char* label, int count) const { } } // namespace shell -} // namespace sky diff --git a/sky/shell/systrace_logger.h b/shell/common/systrace_logger.h similarity index 76% rename from sky/shell/systrace_logger.h rename to shell/common/systrace_logger.h index ce6181baa5dd2421120c673cc59184acbf8dc2d9..6677c02ba01632bf0650e898382759e523eeb0f7 100644 --- a/sky/shell/systrace_logger.h +++ b/shell/common/systrace_logger.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 FLUTTER_SKY_SHELL_SYSTRACE_LOGGER_H_ -#define FLUTTER_SKY_SHELL_SYSTRACE_LOGGER_H_ +#ifndef SHELL_COMMON_SYSTRACE_LOGGER_H_ +#define SHELL_COMMON_SYSTRACE_LOGGER_H_ #include "lib/ftl/macros.h" #include -namespace sky { namespace shell { class SystraceLogger { @@ -32,6 +31,5 @@ class SystraceLogger { }; } // namespace shell -} // namespace sky -#endif // FLUTTER_SKY_SHELL_SYSTRACE_LOGGER_H_ +#endif // SHELL_COMMON_SYSTRACE_LOGGER_H_ diff --git a/sky/shell/tracing_controller.cc b/shell/common/tracing_controller.cc similarity index 98% rename from sky/shell/tracing_controller.cc rename to shell/common/tracing_controller.cc index 218657bed2cf56023528d2e03a28de2b1baf01ca..355b0d936196f9dd3a10c9d94bc27196ca469db4 100644 --- a/sky/shell/tracing_controller.cc +++ b/shell/common/tracing_controller.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/sky/shell/tracing_controller.h" +#include "flutter/shell/common/tracing_controller.h" #include @@ -10,10 +10,9 @@ #include "dart/runtime/include/dart_tools_api.h" #include "flutter/common/threads.h" #include "flutter/runtime/dart_init.h" -#include "flutter/sky/shell/shell.h" +#include "flutter/shell/common/shell.h" #include "lib/ftl/logging.h" -namespace sky { namespace shell { TracingController::TracingController() @@ -211,4 +210,3 @@ std::string TracingController::PictureTracingPathForCurrentTime( } } // namespace shell -} // namespace sky diff --git a/sky/shell/tracing_controller.h b/shell/common/tracing_controller.h similarity index 89% rename from sky/shell/tracing_controller.h rename to shell/common/tracing_controller.h index 4b92c5274d4a3bf382f1c1cdbd5650f09d87b4cb..2c2e6d00e2b80f6f1a6c93c8804c18225e6d50c6 100644 --- a/sky/shell/tracing_controller.h +++ b/shell/common/tracing_controller.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 __SKY_SHELL_TRACING_CONTROLLER__ -#define __SKY_SHELL_TRACING_CONTROLLER__ +#ifndef SHELL_COMMON_TRACING_CONTROLLER_H_ +#define SHELL_COMMON_TRACING_CONTROLLER_H_ #include #include "lib/ftl/macros.h" -namespace sky { namespace shell { class TracingController { @@ -57,6 +56,5 @@ class TracingController { }; } // namespace shell -} // namespace sky -#endif /* defined(__SKY_SHELL_TRACING_CONTROLLER__) */ +#endif // SHELL_COMMON_TRACING_CONTROLLER_H_ diff --git a/sky/shell/ui_delegate.cc b/shell/common/ui_delegate.cc similarity index 65% rename from sky/shell/ui_delegate.cc rename to shell/common/ui_delegate.cc index 1ff5301c054466066fd2b26309172744126c9a93..e08ab8c08c8bdc4e11c1e5b78de5f78da20f112e 100644 --- a/sky/shell/ui_delegate.cc +++ b/shell/common/ui_delegate.cc @@ -2,13 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/ui_delegate.h" +#include "flutter/shell/common/ui_delegate.h" -namespace sky { namespace shell { -UIDelegate::~UIDelegate() { -} +UIDelegate::~UIDelegate() = default; } // namespace shell -} // namespace sky diff --git a/sky/shell/ui_delegate.h b/shell/common/ui_delegate.h similarity index 73% rename from sky/shell/ui_delegate.h rename to shell/common/ui_delegate.h index f3b0296f2f4217cb0a53340b3baaba845b369358..993bfb29374e325e31ba12d5de1be0c1b4e84864 100644 --- a/sky/shell/ui_delegate.h +++ b/shell/common/ui_delegate.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_UI_DELEGATE_H_ -#define SKY_SHELL_UI_DELEGATE_H_ +#ifndef SHELL_COMMON_DELEGATE_H_ +#define SHELL_COMMON_DELEGATE_H_ +#include "flutter/services/engine/sky_engine.mojom.h" #include "lib/ftl/functional/closure.h" #include "mojo/public/cpp/bindings/interface_request.h" -#include "flutter/services/engine/sky_engine.mojom.h" -namespace sky { namespace shell { class UIDelegate { public: - virtual void ConnectToEngine(mojo::InterfaceRequest request) = 0; + virtual void ConnectToEngine( + mojo::InterfaceRequest request) = 0; virtual void OnOutputSurfaceCreated(const ftl::Closure& gpu_continuation) = 0; @@ -26,6 +26,5 @@ class UIDelegate { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_UI_DELEGATE_H_ +#endif // SHELL_COMMON_DELEGATE_H_ diff --git a/shell/gpu/BUILD.gn b/shell/gpu/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d0cc0cbd401b6a6361f4c8fd9f7cac9e2ce6baec --- /dev/null +++ b/shell/gpu/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright 2016 The Chromium 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("gpu") { + sources = [ + "ganesh_canvas.cc", + "ganesh_canvas.h", + "gpu_canvas.cc", + "gpu_canvas.h", + "gpu_canvas_gl.cc", + "gpu_canvas_gl.h", + "gpu_canvas_vulkan.cc", + "gpu_canvas_vulkan.h", + "gpu_rasterizer.cc", + "gpu_rasterizer.h", + ] + + deps = [ + "../common", + "//lib/ftl", + "//flutter/skia", + "//flutter/flow", + "//flutter/common", + "//flutter/glue", + "//mojo/public/cpp/system", + ] +} diff --git a/sky/shell/gpu/direct/ganesh_canvas.cc b/shell/gpu/ganesh_canvas.cc similarity index 96% rename from sky/shell/gpu/direct/ganesh_canvas.cc rename to shell/gpu/ganesh_canvas.cc index 86b279154774ae68c46c46b4c7c8ed89d40c5071..a5ae1fa7d6f8e0dbef5209967fcef3ee57456431 100644 --- a/sky/shell/gpu/direct/ganesh_canvas.cc +++ b/shell/gpu/ganesh_canvas.cc @@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/gpu/direct/ganesh_canvas.h" +#include "flutter/shell/gpu/ganesh_canvas.h" +#include "flutter/flow/gl_connection.h" #include "lib/ftl/arraysize.h" #include "lib/ftl/logging.h" #include "third_party/skia/include/gpu/gl/GrGLInterface.h" -#include "flutter/flow/gl_connection.h" -namespace sky { namespace shell { namespace { @@ -88,4 +87,3 @@ bool GaneshCanvas::IsValid() { } } // namespace shell -} // namespace sky diff --git a/sky/shell/gpu/direct/ganesh_canvas.h b/shell/gpu/ganesh_canvas.h similarity index 83% rename from sky/shell/gpu/direct/ganesh_canvas.h rename to shell/gpu/ganesh_canvas.h index 4c5db17520cf81ee460d5e6bf40c44471f9e3fab..c81fe65c6f839ef8f93b146352663a87d0a100b9 100644 --- a/sky/shell/gpu/direct/ganesh_canvas.h +++ b/shell/gpu/ganesh_canvas.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_GPU_DIRECT_GANESH_CANVAS_H_ -#define SKY_SHELL_GPU_DIRECT_GANESH_CANVAS_H_ +#ifndef SHELL_GPU_DIRECT_GANESH_CANVAS_H_ +#define SHELL_GPU_DIRECT_GANESH_CANVAS_H_ #include "lib/ftl/macros.h" #include "third_party/skia/include/core/SkSize.h" @@ -12,7 +12,6 @@ #include "third_party/skia/include/gpu/gl/GrGLInterface.h" #include "third_party/skia/include/gpu/GrContext.h" -namespace sky { namespace shell { class GaneshCanvas { @@ -38,6 +37,5 @@ class GaneshCanvas { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_GPU_DIRECT_GANESH_CANVAS_H_ +#endif // SHELL_GPU_DIRECT_GANESH_CANVAS_H_ diff --git a/shell/gpu/gpu_canvas.cc b/shell/gpu/gpu_canvas.cc new file mode 100644 index 0000000000000000000000000000000000000000..693a7e78e464891592bedf0e5d5862c7f402d170 --- /dev/null +++ b/shell/gpu/gpu_canvas.cc @@ -0,0 +1,11 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu_canvas.h" + +namespace shell { + +// + +} // namespace shell diff --git a/sky/shell/platform/glfw/init_glfw.h b/shell/gpu/gpu_canvas.h similarity index 51% rename from sky/shell/platform/glfw/init_glfw.h rename to shell/gpu/gpu_canvas.h index c7bb8410d6faebfeb986d6c582b05eeeb03802ac..972033d96ff9b25ec76ef17fc88371272274a300 100644 --- a/sky/shell/platform/glfw/init_glfw.h +++ b/shell/gpu/gpu_canvas.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 SKY_SHELL_PLATFORM_GLFW_INIT_GLFW_H_ -#define SKY_SHELL_PLATFORM_GLFW_INIT_GLFW_H_ +#ifndef SHELL_GPU_GPU_CANVAS_H_ +#define SHELL_GPU_GPU_CANVAS_H_ + +#include "lib/ftl/macros.h" -namespace sky { namespace shell { -bool InitInteractive(); +// } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_GLFW_INIT_GLFW_H_ +#endif // SHELL_GPU_GPU_CANVAS_H_ diff --git a/shell/gpu/gpu_canvas_gl.cc b/shell/gpu/gpu_canvas_gl.cc new file mode 100644 index 0000000000000000000000000000000000000000..088af3e5288c15b1ad26392e19cda7a541915f46 --- /dev/null +++ b/shell/gpu/gpu_canvas_gl.cc @@ -0,0 +1,11 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu_canvas_gl.h" + +namespace shell { + +// + +} // namespace shell diff --git a/shell/gpu/gpu_canvas_gl.h b/shell/gpu/gpu_canvas_gl.h new file mode 100644 index 0000000000000000000000000000000000000000..b67772cccb805d8a527ebb205cd9346fa9c9c736 --- /dev/null +++ b/shell/gpu/gpu_canvas_gl.h @@ -0,0 +1,16 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SHELL_GPU_GPU_CANVAS_GL_H_ +#define SHELL_GPU_GPU_CANVAS_GL_H_ + +#include "lib/ftl/macros.h" + +namespace shell { + +// + +} // namespace shell + +#endif // SHELL_GPU_GPU_CANVAS_GL_H_ diff --git a/shell/gpu/gpu_canvas_vulkan.cc b/shell/gpu/gpu_canvas_vulkan.cc new file mode 100644 index 0000000000000000000000000000000000000000..87a8230a41ba69c0a65a680e8b72a78f4f044081 --- /dev/null +++ b/shell/gpu/gpu_canvas_vulkan.cc @@ -0,0 +1,11 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu_canvas_vulkan.h" + +namespace shell { + +// + +} // namespace shell diff --git a/shell/gpu/gpu_canvas_vulkan.h b/shell/gpu/gpu_canvas_vulkan.h new file mode 100644 index 0000000000000000000000000000000000000000..0bcd3983b2bdf225804582e5d568c0f7209d7fa4 --- /dev/null +++ b/shell/gpu/gpu_canvas_vulkan.h @@ -0,0 +1,16 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SHELL_GPU_GPU_CANVAS_VULKAN_H_ +#define SHELL_GPU_GPU_CANVAS_VULKAN_H_ + +#include "lib/ftl/macros.h" + +namespace shell { + +// + +} // namespace shell + +#endif // SHELL_GPU_GPU_CANVAS_VULKAN_H_ diff --git a/sky/shell/gpu/direct/rasterizer_direct.cc b/shell/gpu/gpu_rasterizer.cc similarity index 78% rename from sky/shell/gpu/direct/rasterizer_direct.cc rename to shell/gpu/gpu_rasterizer.cc index fd9ceed1ef66d97e5da998cc72be879a439d1442..c7f7fa236c9c2800d565c582b66d9fccb671a208 100644 --- a/sky/shell/gpu/direct/rasterizer_direct.cc +++ b/shell/gpu/gpu_rasterizer.cc @@ -2,52 +2,44 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/gpu/direct/rasterizer_direct.h" +#include "gpu_rasterizer.h" #include #include #include "flutter/common/threads.h" #include "flutter/glue/trace_event.h" -#include "flutter/sky/engine/wtf/PassRefPtr.h" -#include "flutter/sky/engine/wtf/RefPtr.h" -#include "flutter/sky/shell/gpu/picture_serializer.h" -#include "flutter/sky/shell/platform_view.h" -#include "flutter/sky/shell/shell.h" +#include "flutter/shell/common/platform_view.h" +#include "flutter/shell/common/shell.h" +#include "flutter/shell/common/picture_serializer.h" #include "mojo/public/cpp/system/data_pipe.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkPicture.h" -namespace sky { namespace shell { -RasterizerDirect::RasterizerDirect() - : platform_view_(nullptr), weak_factory_(this) { +GPURasterizer::GPURasterizer() : platform_view_(nullptr), weak_factory_(this) { auto weak_ptr = weak_factory_.GetWeakPtr(); blink::Threads::Gpu()->PostTask( [weak_ptr]() { Shell::Shared().AddRasterizer(weak_ptr); }); } -RasterizerDirect::~RasterizerDirect() { +GPURasterizer::~GPURasterizer() { weak_factory_.InvalidateWeakPtrs(); Shell::Shared().PurgeRasterizers(); } -// Implementation of declaration in sky/shell/rasterizer.h. std::unique_ptr Rasterizer::Create() { - return std::unique_ptr(new RasterizerDirect()); + return std::unique_ptr(new GPURasterizer()); } -// sky::shell::Rasterizer override. -ftl::WeakPtr RasterizerDirect::GetWeakRasterizerPtr() { +ftl::WeakPtr GPURasterizer::GetWeakRasterizerPtr() { return weak_factory_.GetWeakPtr(); } -// sky::shell::Rasterizer override. -void RasterizerDirect::Setup( - PlatformView* platform_view, - ftl::Closure continuation, - ftl::AutoResetWaitableEvent* setup_completion_event) { +void GPURasterizer::Setup(PlatformView* platform_view, + ftl::Closure continuation, + ftl::AutoResetWaitableEvent* setup_completion_event) { FTL_CHECK(platform_view) << "Must be able to acquire the view."; // The context needs to be made current before the GrGL interface can be @@ -73,7 +65,7 @@ void RasterizerDirect::Setup( setup_completion_event->Signal(); } -void RasterizerDirect::Clear(SkColor color) { +void GPURasterizer::Clear(SkColor color) { SkCanvas* canvas = ganesh_canvas_.GetCanvas( platform_view_->DefaultFramebuffer(), platform_view_->GetSize()); canvas->clear(color); @@ -81,8 +73,7 @@ void RasterizerDirect::Clear(SkColor color) { platform_view_->SwapBuffers(); } -// sky::shell::Rasterizer override. -void RasterizerDirect::Teardown( +void GPURasterizer::Teardown( ftl::AutoResetWaitableEvent* teardown_completion_event) { platform_view_ = nullptr; last_layer_tree_.reset(); @@ -90,20 +81,19 @@ void RasterizerDirect::Teardown( teardown_completion_event->Signal(); } -// sky::shell::Rasterizer override. -flow::LayerTree* RasterizerDirect::GetLastLayerTree() { +flow::LayerTree* GPURasterizer::GetLastLayerTree() { return last_layer_tree_.get(); } -void RasterizerDirect::Draw( +void GPURasterizer::Draw( ftl::RefPtr> pipeline) { - TRACE_EVENT0("flutter", "RasterizerDirect::Draw"); + TRACE_EVENT0("flutter", "GPURasterizer::Draw"); if (!platform_view_) return; flutter::Pipeline::Consumer consumer = - std::bind(&RasterizerDirect::DoDraw, this, std::placeholders::_1); + std::bind(&GPURasterizer::DoDraw, this, std::placeholders::_1); // Consume as many pipeline items as possible. But yield the event loop // between successive tries. @@ -122,7 +112,7 @@ void RasterizerDirect::Draw( } } -void RasterizerDirect::DoDraw(std::unique_ptr layer_tree) { +void GPURasterizer::DoDraw(std::unique_ptr layer_tree) { if (!layer_tree) { return; } @@ -192,4 +182,3 @@ void RasterizerDirect::DoDraw(std::unique_ptr layer_tree) { } } // namespace shell -} // namespace sky diff --git a/sky/shell/gpu/direct/rasterizer_direct.h b/shell/gpu/gpu_rasterizer.h similarity index 64% rename from sky/shell/gpu/direct/rasterizer_direct.h rename to shell/gpu/gpu_rasterizer.h index 5b02d4fd8b3e34958d743957c77b24a032342983..ca6cc84ef8165649758ba6fcba0ba55ad5a73691 100644 --- a/sky/shell/gpu/direct/rasterizer_direct.h +++ b/shell/gpu/gpu_rasterizer.h @@ -2,23 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_ -#define SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_ +#ifndef SHELL_GPU_DIRECT_GPU_RASTERIZER_H_ +#define SHELL_GPU_DIRECT_GPU_RASTERIZER_H_ #include "flutter/flow/compositor_context.h" +#include "flutter/shell/common/rasterizer.h" +#include "flutter/shell/gpu/ganesh_canvas.h" #include "lib/ftl/memory/weak_ptr.h" #include "lib/ftl/synchronization/waitable_event.h" -#include "flutter/sky/shell/gpu/direct/ganesh_canvas.h" -#include "flutter/sky/shell/rasterizer.h" -namespace sky { namespace shell { -class RasterizerDirect : public Rasterizer { +class GPURasterizer : public Rasterizer { public: - RasterizerDirect(); + GPURasterizer(); - ~RasterizerDirect() override; + ~GPURasterizer() override; void Setup(PlatformView* platform_view, ftl::Closure continuation, @@ -29,7 +28,7 @@ class RasterizerDirect : public Rasterizer { void Teardown( ftl::AutoResetWaitableEvent* teardown_completion_event) override; - ftl::WeakPtr GetWeakRasterizerPtr() override; + ftl::WeakPtr GetWeakRasterizerPtr() override; flow::LayerTree* GetLastLayerTree() override; @@ -40,14 +39,13 @@ class RasterizerDirect : public Rasterizer { flow::CompositorContext compositor_context_; std::unique_ptr last_layer_tree_; PlatformView* platform_view_; - ftl::WeakPtrFactory weak_factory_; + ftl::WeakPtrFactory weak_factory_; void DoDraw(std::unique_ptr tree); - FTL_DISALLOW_COPY_AND_ASSIGN(RasterizerDirect); + FTL_DISALLOW_COPY_AND_ASSIGN(GPURasterizer); }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_GPU_DIRECT_RASTERIZER_DIRECT_H_ +#endif // SHELL_GPU_DIRECT_GPU_RASTERIZER_H_ diff --git a/shell/platform/BUILD.gn b/shell/platform/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..49cedfa78a39b4d9400a7cfbc7a3aad53e840f06 --- /dev/null +++ b/shell/platform/BUILD.gn @@ -0,0 +1,15 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +group("platform") { + if (is_mac || is_ios) { + deps = [ "darwin" ] + } else if (is_android) { + deps = [ "android" ] + } else if (is_linux) { + deps = [ "linux" ] + } else { + assert(false, "Unknown/Unsupported platform.") + } +} diff --git a/sky/shell/platform/android/AndroidManifest.xml b/shell/platform/android/AndroidManifest.xml similarity index 100% rename from sky/shell/platform/android/AndroidManifest.xml rename to shell/platform/android/AndroidManifest.xml diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fb3b775d7e5e6d59c7d1932a85483b188af9e78c --- /dev/null +++ b/shell/platform/android/BUILD.gn @@ -0,0 +1,127 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/android/config.gni") +import("//build/config/android/rules.gni") + +generate_jni("jni_headers") { + visibility = [ ":*" ] + + sources = [ + "io/flutter/view/FlutterMain.java", + "io/flutter/view/FlutterView.java", + ] + jni_package = "shell" +} + +shared_library("sky_shell") { + visibility = [ ":*" ] + + sources = [ + "flutter_main.cc", + "flutter_main.h", + "library_loader.cc", + "platform_view_android.cc", + "platform_view_android.h", + ] + + deps = [ + "//base", + "//dart/runtime:libdart", + "//flutter/common", + "//flutter/flow", + "//flutter/lib/jni", + "//flutter/runtime", + "//flutter/shell/common", + "//flutter/shell/gpu", + "//flutter/skia", + "//flutter/vulkan", + "//lib/ftl", + "//mojo/android:libsystem_java", + "//mojo/edk/base_edk", + "//mojo/edk/system", + ":jni_headers", + ] + + ldflags = [ + "-landroid", + "-lEGL", + "-lGLESv2", + ] +} + +android_library("java") { + visibility = [ ":*" ] + + java_files = [ + "io/flutter/view/AccessibilityBridge.java", + "io/flutter/view/FlutterMain.java", + "io/flutter/view/FlutterView.java", + "io/flutter/view/ResourceCleaner.java", + "io/flutter/view/ResourceExtractor.java", + "io/flutter/view/ServiceFactory.java", + "io/flutter/view/ServiceProviderImpl.java", + "io/flutter/view/ServiceRegistry.java", + "org/domokit/sky/shell/SkyActivity.java", + "org/domokit/sky/shell/SkyApplication.java", + ] + + deps = [ + "//base:base_java", + "//flutter/services/activity:activity_lib", + "//flutter/services/activity:interfaces_java", + "//flutter/services/common:common_lib", + "//flutter/services/editing:editing_lib", + "//flutter/services/editing:interfaces_java", + "//flutter/services/engine:interfaces_java", + "//flutter/services/media:interfaces_java", + "//flutter/services/media:media_lib", + "//flutter/services/platform:interfaces_java", + "//flutter/services/platform:platform_lib", + "//flutter/services/pointer:interfaces_java", + "//flutter/services/raw_keyboard:interfaces_java", + "//flutter/services/raw_keyboard:raw_keyboard_lib", + "//flutter/services/semantics:interfaces_java", + "//flutter/services/sensors:sensors_lib", + "//flutter/services/vsync:vsync_lib", + "//mojo/android:system_java", + "//mojo/public/interfaces/application:application_java", + "//mojo/public/java:bindings", + "//mojo/public/java:system", + "//mojo/services/sensors/interfaces:interfaces_java", + "//mojo/services/vsync/interfaces:interfaces_java", + ] +} + +copy_ex("assets") { + visibility = [ ":*" ] + + clear_dir = true + dest = "$root_build_dir/sky_shell/assets" + sources = [ + "$root_build_dir/icudtl.dat", + ] + deps = [ + "//third_party/icu:icudata", + ] +} + +android_apk("android") { + apk_name = "SkyShell" + android_manifest = "AndroidManifest.xml" + + native_libs = [ "libsky_shell.so" ] + asset_location = "$root_build_dir/sky_shell/assets" + + extensions_to_not_compress = ".flx" + + flutter_dist_jar = "$root_build_dir/flutter.jar" + + deps = [ + "//base:base_java", + ":assets", + ":java", + ":sky_shell", + ] +} diff --git a/sky/shell/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc similarity index 92% rename from sky/shell/platform/android/flutter_main.cc rename to shell/platform/android/flutter_main.cc index 698fa85472224c6ff11b7cd5e38701c9dd2500ec..49bed1ae8666f97f6855a84c865459e8ed295b6e 100644 --- a/sky/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform/android/flutter_main.h" +#include "flutter/shell/platform/android/flutter_main.h" + +#include #include "base/android/jni_android.h" #include "base/android/jni_array.h" @@ -19,7 +21,7 @@ #include "base/threading/simple_thread.h" #include "dart/runtime/include/dart_tools_api.h" #include "flutter/runtime/start_up.h" -#include "flutter/sky/shell/shell.h" +#include "flutter/shell/common/shell.h" #include "jni/FlutterMain_jni.h" #include "lib/ftl/macros.h" #include "mojo/edk/embedder/embedder.h" @@ -27,7 +29,6 @@ using base::LazyInstance; -namespace sky { namespace shell { namespace { @@ -50,7 +51,7 @@ void InitializeTracing() { base::FilePath path; bool result = ::PathService::Get(base::DIR_ANDROID_APP_DATA, &path); DCHECK(result); - sky::shell::Shell::Shared().tracing_controller().set_traces_base_path( + shell::Shell::Shared().tracing_controller().set_traces_base_path( path.AsUTF8Unsafe()); } @@ -95,5 +96,4 @@ bool RegisterFlutterMain(JNIEnv* env) { return RegisterNativesImpl(env); } -} // namespace sky -} // namespace mojo +} // namespace shell diff --git a/sky/shell/platform/android/flutter_main.h b/shell/platform/android/flutter_main.h similarity index 58% rename from sky/shell/platform/android/flutter_main.h rename to shell/platform/android/flutter_main.h index 43453d03591b139136e359663ceec8477e3086f6..f4f65c499f966ea6eb92644cd1ce773593c831f8 100644 --- a/sky/shell/platform/android/flutter_main.h +++ b/shell/platform/android/flutter_main.h @@ -2,17 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_ANDROID_FLUTTER_MAIN_H_ -#define SKY_SHELL_PLATFORM_ANDROID_FLUTTER_MAIN_H_ +#ifndef SHELL_PLATFORM_ANDROID_FLUTTER_MAIN_H_ +#define SHELL_PLATFORM_ANDROID_FLUTTER_MAIN_H_ #include -namespace sky { namespace shell { bool RegisterFlutterMain(JNIEnv* env); } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_ANDROID_FLUTTER_MAIN_H_ +#endif // SHELL_PLATFORM_ANDROID_FLUTTER_MAIN_H_ diff --git a/sky/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/shell/platform/android/io/flutter/view/AccessibilityBridge.java similarity index 100% rename from sky/shell/platform/android/io/flutter/view/AccessibilityBridge.java rename to shell/platform/android/io/flutter/view/AccessibilityBridge.java diff --git a/sky/shell/platform/android/io/flutter/view/FlutterMain.java b/shell/platform/android/io/flutter/view/FlutterMain.java similarity index 99% rename from sky/shell/platform/android/io/flutter/view/FlutterMain.java rename to shell/platform/android/io/flutter/view/FlutterMain.java index 3fc1290e32783758fe0e783afe6e31f5920b8deb..1e29f2117a54e8b9bc81d9e1b31dcfa5138beb0c 100644 --- a/sky/shell/platform/android/io/flutter/view/FlutterMain.java +++ b/shell/platform/android/io/flutter/view/FlutterMain.java @@ -58,7 +58,7 @@ import org.domokit.vsync.VSyncProviderImpl; /** * A class to intialize the Flutter engine. */ -@JNINamespace("sky::shell") +@JNINamespace("shell") public class FlutterMain { private static final String TAG = "FlutterMain"; diff --git a/sky/shell/platform/android/io/flutter/view/FlutterView.java b/shell/platform/android/io/flutter/view/FlutterView.java similarity index 99% rename from sky/shell/platform/android/io/flutter/view/FlutterView.java rename to shell/platform/android/io/flutter/view/FlutterView.java index 3d2ad25b338cc5cbbfe2f29b814d2d3c5784e74c..7e7b1e9b433d247c0998758843c8a39d0796ecec 100644 --- a/sky/shell/platform/android/io/flutter/view/FlutterView.java +++ b/shell/platform/android/io/flutter/view/FlutterView.java @@ -71,7 +71,7 @@ import org.domokit.raw_keyboard.RawKeyboardServiceState; /** * An Android view containing a Flutter app. */ -@JNINamespace("sky::shell") +@JNINamespace("shell") public class FlutterView extends SurfaceView implements AccessibilityManager.AccessibilityStateChangeListener, AccessibilityManager.TouchExplorationStateChangeListener { diff --git a/sky/shell/platform/android/io/flutter/view/ResourceCleaner.java b/shell/platform/android/io/flutter/view/ResourceCleaner.java similarity index 100% rename from sky/shell/platform/android/io/flutter/view/ResourceCleaner.java rename to shell/platform/android/io/flutter/view/ResourceCleaner.java diff --git a/sky/shell/platform/android/io/flutter/view/ResourceExtractor.java b/shell/platform/android/io/flutter/view/ResourceExtractor.java similarity index 100% rename from sky/shell/platform/android/io/flutter/view/ResourceExtractor.java rename to shell/platform/android/io/flutter/view/ResourceExtractor.java diff --git a/sky/shell/platform/android/io/flutter/view/ServiceFactory.java b/shell/platform/android/io/flutter/view/ServiceFactory.java similarity index 100% rename from sky/shell/platform/android/io/flutter/view/ServiceFactory.java rename to shell/platform/android/io/flutter/view/ServiceFactory.java diff --git a/sky/shell/platform/android/io/flutter/view/ServiceProviderImpl.java b/shell/platform/android/io/flutter/view/ServiceProviderImpl.java similarity index 100% rename from sky/shell/platform/android/io/flutter/view/ServiceProviderImpl.java rename to shell/platform/android/io/flutter/view/ServiceProviderImpl.java diff --git a/sky/shell/platform/android/io/flutter/view/ServiceRegistry.java b/shell/platform/android/io/flutter/view/ServiceRegistry.java similarity index 100% rename from sky/shell/platform/android/io/flutter/view/ServiceRegistry.java rename to shell/platform/android/io/flutter/view/ServiceRegistry.java diff --git a/sky/shell/platform/android/library_loader.cc b/shell/platform/android/library_loader.cc similarity index 86% rename from sky/shell/platform/android/library_loader.cc rename to shell/platform/android/library_loader.cc index 950e70021b9ad6288263ccaa9488333c3d7145ed..a50d132e0541ae08c7dd5e542a78f3b594e886d9 100644 --- a/sky/shell/platform/android/library_loader.cc +++ b/shell/platform/android/library_loader.cc @@ -12,16 +12,16 @@ #include "flutter/lib/jni/dart_jni.h" #include "mojo/android/system/base_run_loop.h" #include "mojo/android/system/core_impl.h" -#include "flutter/sky/shell/platform/android/flutter_main.h" -#include "flutter/sky/shell/platform/android/platform_view_android.h" +#include "flutter/shell/platform/android/flutter_main.h" +#include "flutter/shell/platform/android/platform_view_android.h" namespace { base::android::RegistrationMethod kSkyRegisteredMethods[] = { {"CoreImpl", mojo::android::RegisterCoreImpl}, {"BaseRunLoop", mojo::android::RegisterBaseRunLoop}, - {"FlutterView", sky::shell::PlatformViewAndroid::Register}, - {"FlutterMain", sky::shell::RegisterFlutterMain}, + {"FlutterView", shell::PlatformViewAndroid::Register}, + {"FlutterMain", shell::RegisterFlutterMain}, }; bool RegisterJNI(JNIEnv* env) { diff --git a/sky/shell/platform/android/org/domokit/sky/shell/SkyActivity.java b/shell/platform/android/org/domokit/sky/shell/SkyActivity.java similarity index 100% rename from sky/shell/platform/android/org/domokit/sky/shell/SkyActivity.java rename to shell/platform/android/org/domokit/sky/shell/SkyActivity.java diff --git a/sky/shell/platform/android/org/domokit/sky/shell/SkyApplication.java b/shell/platform/android/org/domokit/sky/shell/SkyApplication.java similarity index 100% rename from sky/shell/platform/android/org/domokit/sky/shell/SkyApplication.java rename to shell/platform/android/org/domokit/sky/shell/SkyApplication.java diff --git a/sky/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc similarity index 95% rename from sky/shell/platform/android/platform_view_android.cc rename to shell/platform/android/platform_view_android.cc index a419a0089a72b7e81aba0210f4e50cdb7e1b5cc4..10e81ebff0b4ba8fabc2d67ed37bd91a7f6e984c 100644 --- a/sky/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.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/sky/shell/platform/android/platform_view_android.h" +#include "flutter/shell/platform/android/platform_view_android.h" #include #include @@ -20,11 +20,10 @@ #include "flutter/common/threads.h" #include "flutter/flow/compositor_context.h" #include "flutter/runtime/dart_service_isolate.h" -#include "flutter/sky/shell/shell.h" +#include "flutter/shell/common/shell.h" #include "jni/FlutterView_jni.h" #include "third_party/skia/include/core/SkSurface.h" -namespace sky { namespace shell { namespace { @@ -352,7 +351,7 @@ static jlong Attach(JNIEnv* env, jint skyEngineHandle, jobject flutterView) { PlatformViewAndroid* view = new PlatformViewAndroid(); - view->ConnectToEngine(mojo::InterfaceRequest( + view->ConnectToEngine(mojo::InterfaceRequest( mojo::ScopedMessagePipeHandle(mojo::MessagePipeHandle(skyEngineHandle)))); // Create a weak reference to the flutterView Java object so that we can make @@ -430,7 +429,7 @@ void PlatformViewAndroid::ReleaseSurface() { } } -ftl::WeakPtr PlatformViewAndroid::GetWeakViewPtr() { +ftl::WeakPtr PlatformViewAndroid::GetWeakViewPtr() { return weak_factory_.GetWeakPtr(); } @@ -507,7 +506,8 @@ void PlatformViewAndroid::RunFromSource(const std::string& main, } base::android::ScopedJavaLocalRef PlatformViewAndroid::GetBitmap( - JNIEnv* env, jobject obj) { + JNIEnv* env, + jobject obj) { // Render the last frame to an array of pixels on the GPU thread. // The pixels will be returned as a global JNI reference to an int array. ftl::AutoResetWaitableEvent latch; @@ -549,16 +549,15 @@ base::android::ScopedJavaLocalRef PlatformViewAndroid::GetBitmap( FTL_CHECK(bitmap_config); jobject bitmap = env->CallStaticObjectMethod( - bitmap_class, create_bitmap, - pixels.obj(), frame_size.width(), frame_size.height(), bitmap_config); + bitmap_class, create_bitmap, pixels.obj(), frame_size.width(), + frame_size.height(), bitmap_config); return base::android::ScopedJavaLocalRef(env, bitmap); } -void PlatformViewAndroid::GetBitmapGpuTask( - ftl::AutoResetWaitableEvent* latch, - jobject* pixels_out, - SkISize* size_out) { +void PlatformViewAndroid::GetBitmapGpuTask(ftl::AutoResetWaitableEvent* latch, + jobject* pixels_out, + SkISize* size_out) { flow::LayerTree* layer_tree = rasterizer_->GetLastLayerTree(); if (layer_tree == nullptr) return; @@ -574,9 +573,9 @@ void PlatformViewAndroid::GetBitmapGpuTask( jint* pixels = env->GetIntArrayElements(pixels_array, nullptr); FTL_CHECK(pixels); - SkImageInfo image_info = SkImageInfo::Make( - frame_size.width(), frame_size.height(), kRGBA_8888_SkColorType, - kPremul_SkAlphaType); + SkImageInfo image_info = + SkImageInfo::Make(frame_size.width(), frame_size.height(), + kRGBA_8888_SkColorType, kPremul_SkAlphaType); sk_sp surface = SkSurface::MakeRasterDirect( image_info, pixels, frame_size.width() * sizeof(jint)); @@ -609,4 +608,3 @@ void PlatformViewAndroid::GetBitmapGpuTask( } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/android/platform_view_android.h b/shell/platform/android/platform_view_android.h similarity index 71% rename from sky/shell/platform/android/platform_view_android.h rename to shell/platform/android/platform_view_android.h index 89c19578063a2e4d7d6fbe8dca6251ab1af39074..6732523991967d31c71fb5fac049a5d3b1ef33e0 100644 --- a/sky/shell/platform/android/platform_view_android.h +++ b/shell/platform/android/platform_view_android.h @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_ -#define SKY_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_ +#ifndef SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_ +#define SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_ + +#include #include "base/android/jni_android.h" #include "base/android/jni_weak_ref.h" #include "lib/ftl/memory/weak_ptr.h" #include "lib/ftl/synchronization/waitable_event.h" -#include "flutter/sky/shell/platform_view.h" +#include "flutter/shell/common/platform_view.h" -namespace sky { namespace shell { class AndroidGLContext; @@ -20,45 +21,33 @@ class PlatformViewAndroid : public PlatformView { public: static bool Register(JNIEnv* env); - explicit PlatformViewAndroid(); + PlatformViewAndroid(); ~PlatformViewAndroid() override; - // Called from Java void Detach(JNIEnv* env, jobject obj); - // Called from Java void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface); - // Called from Java void SurfaceChanged(JNIEnv* env, jobject obj, jint backgroundColor); - // Called from Java void SurfaceDestroyed(JNIEnv* env, jobject obj); - // Called from Java base::android::ScopedJavaLocalRef GetBitmap(JNIEnv* env, jobject obj); - // sky::shell::PlatformView override - ftl::WeakPtr GetWeakViewPtr() override; + ftl::WeakPtr GetWeakViewPtr() override; - // sky::shell::PlatformView override uint64_t DefaultFramebuffer() const override; - // sky::shell::PlatformView override bool ContextMakeCurrent() override; - // sky::shell::PlatformView override bool ResourceContextMakeCurrent() override; - // sky::shell::PlatformView override bool SwapBuffers() override; - // sky::shell::PlatformView override virtual SkISize GetSize(); - // sky::shell::PlatformView override virtual void Resize(const SkISize& size); virtual void RunFromSource(const std::string& main, @@ -86,6 +75,5 @@ class PlatformViewAndroid : public PlatformView { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_ +#endif // SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_H_ diff --git a/shell/platform/darwin/BUILD.gn b/shell/platform/darwin/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..509d906fc19a6f14bfb1668844323a8985ebceae --- /dev/null +++ b/shell/platform/darwin/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +assert(is_mac || is_ios) + +group("darwin") { + if (is_mac) { + deps = [ + "desktop:shell_application_bundle", + "desktop:shell_standalone", + ] + } else if (is_ios) { + deps = [ + "ios:flutter_framework", + ] + } else { + assert(false, "Unknown darwin platform type.") + } +} diff --git a/shell/platform/darwin/common/BUILD.gn b/shell/platform/darwin/common/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fad4168c8f1edf8fe27416f2f77e1b5b14901cab --- /dev/null +++ b/shell/platform/darwin/common/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright 2016 The Chromium 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("common") { + # Disable the assignment filter because the files will be used on iOS as well + # as Mac. + set_sources_assignment_filter([]) + sources = [ + "platform_mac.h", + "platform_mac.mm", + "platform_service_provider.cc", + "platform_service_provider.h", + "view_service_provider.cc", + "view_service_provider.h", + ] + set_sources_assignment_filter(sources_assignment_filter) + + deps = [ + "//base", + "//base:i18n", + "//dart/runtime:libdart", + "//flutter/runtime", + "//flutter/services/activity", + "//flutter/services/editing", + "//flutter/services/engine:interfaces", + "//flutter/services/media", + "//flutter/services/platform", + "//flutter/services/pointer:interfaces", + "//flutter/services/vsync", + "//flutter/shell/common", + "//flutter/shell/gpu", + "//flutter/shell/testing", + "//flutter/skia", + "//flutter/sky/engine/wtf", + "//lib/ftl", + "//mojo/common", + "//mojo/edk/base_edk", + "//mojo/edk/system", + "//mojo/public/cpp/bindings:utility", + "//mojo/public/interfaces/application", + ] +} diff --git a/sky/shell/platform/mac/platform_mac.h b/shell/platform/darwin/common/platform_mac.h similarity index 69% rename from sky/shell/platform/mac/platform_mac.h rename to shell/platform/darwin/common/platform_mac.h index 8a1161a9328861c56c378ff889a9777a4699544e..d443cb079ac26caa5a0356dbe805cf3906c109fe 100644 --- a/sky/shell/platform/mac/platform_mac.h +++ b/shell/platform/darwin/common/platform_mac.h @@ -2,12 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_MAC_PLATFORM_MAC_H_ -#define SKY_SHELL_PLATFORM_MAC_PLATFORM_MAC_H_ +#ifndef SHELL_PLATFORM_MAC_PLATFORM_MAC_H_ +#define SHELL_PLATFORM_MAC_PLATFORM_MAC_H_ #include "flutter/services/engine/sky_engine.mojom.h" -namespace sky { namespace shell { void PlatformMacMain(int argc, const char* argv[], std::string icu_data_path); @@ -15,6 +14,5 @@ void PlatformMacMain(int argc, const char* argv[], std::string icu_data_path); bool AttemptLaunchFromCommandLineSwitches(sky::SkyEnginePtr& engine); } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_MAC_PLATFORM_MAC_H_ +#endif // SHELL_PLATFORM_MAC_PLATFORM_MAC_H_ diff --git a/sky/shell/platform/mac/platform_mac.mm b/shell/platform/darwin/common/platform_mac.mm similarity index 82% rename from sky/shell/platform/mac/platform_mac.mm rename to shell/platform/darwin/common/platform_mac.mm index 5fd48f50a495ec9a094af40698f7aa77d390fc17..f8f41dbb0c6fbd40c2da2ad3f76a56053fcdaa66 100644 --- a/sky/shell/platform/mac/platform_mac.mm +++ b/shell/platform/darwin/common/platform_mac.mm @@ -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/sky/shell/platform/mac/platform_mac.h" +#include "flutter/shell/platform/darwin/common/platform_mac.h" #include @@ -18,15 +18,14 @@ #include "base/trace_event/trace_event.h" #include "dart/runtime/include/dart_tools_api.h" #include "flutter/runtime/start_up.h" +#include "flutter/shell/common/shell.h" +#include "flutter/shell/common/switches.h" +#include "flutter/shell/common/tracing_controller.h" +#include "flutter/shell/common/ui_delegate.h" #include "flutter/sky/engine/wtf/MakeUnique.h" -#include "flutter/sky/shell/shell.h" -#include "flutter/sky/shell/switches.h" -#include "flutter/sky/shell/tracing_controller.h" -#include "flutter/sky/shell/ui_delegate.h" #include "mojo/edk/embedder/embedder.h" #include "mojo/edk/embedder/simple_platform_support.h" -namespace sky { namespace shell { static void InitializeLogging() { @@ -42,7 +41,7 @@ static void InitializeLogging() { static void RedirectIOConnectionsToSyslog() { #if TARGET_OS_IPHONE if (base::CommandLine::ForCurrentProcess()->HasSwitch( - sky::shell::switches::kNoRedirectToSyslog)) { + shell::switches::kNoRedirectToSyslog)) { return; } @@ -71,14 +70,14 @@ class EmbedderState { InitializeLogging(); base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(sky::shell::switches::kTraceStartup)) { + if (command_line.HasSwitch(shell::switches::kTraceStartup)) { // Usually, all tracing within flutter is managed via the tracing // controller // The tracing controller is accessed via the shell instance. This means // that tracing can only be enabled once that instance is created. Traces // early in startup are lost. This enables tracing only in base manually // till the tracing controller takes over. - sky::shell::TracingController::StartBaseTracing(); + shell::TracingController::StartBaseTracing(); } // This is about as early as tracing of any kind can start. Add an instant @@ -95,7 +94,7 @@ class EmbedderState { mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport()); - sky::shell::Shell::InitStandalone(icu_data_path); + shell::Shell::InitStandalone(icu_data_path); } ~EmbedderState() { @@ -168,28 +167,27 @@ static std::string ResolveCommandLineLaunchFlag(const char* name) { bool AttemptLaunchFromCommandLineSwitches(sky::SkyEnginePtr& engine) { base::mac::ScopedNSAutoreleasePool pool; - using namespace sky::shell::switches; - NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; auto command_line = *base::CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(kMainDartFile) || - command_line.HasSwitch(kPackages) || command_line.HasSwitch(kFLX)) { + if (command_line.HasSwitch(switches::kMainDartFile) || + command_line.HasSwitch(switches::kPackages) || + command_line.HasSwitch(switches::kFLX)) { // The main dart file, flx bundle and the package root must be specified in // one go. We dont want to end up in a situation where we take one value // from the command line and the others from user defaults. In case, any // new flags are specified, forget about all the old ones. - [defaults removeObjectForKey:@(kMainDartFile)]; - [defaults removeObjectForKey:@(kPackages)]; - [defaults removeObjectForKey:@(kFLX)]; + [defaults removeObjectForKey:@(switches::kMainDartFile)]; + [defaults removeObjectForKey:@(switches::kPackages)]; + [defaults removeObjectForKey:@(switches::kFLX)]; [defaults synchronize]; } - std::string dart_main = ResolveCommandLineLaunchFlag(kMainDartFile); - std::string packages = ResolveCommandLineLaunchFlag(kPackages); - std::string bundle = ResolveCommandLineLaunchFlag(kFLX); + std::string dart_main = ResolveCommandLineLaunchFlag(switches::kMainDartFile); + std::string packages = ResolveCommandLineLaunchFlag(switches::kPackages); + std::string bundle = ResolveCommandLineLaunchFlag(switches::kFLX); if (!FlagsValidForCommandLineLaunch(dart_main, packages, bundle)) { return false; @@ -198,9 +196,9 @@ bool AttemptLaunchFromCommandLineSwitches(sky::SkyEnginePtr& engine) { // Save the newly resolved dart main file and the package root to user // defaults so that the next time the user launches the application in the // simulator without the tooling, the application boots up. - [defaults setObject:@(dart_main.c_str()) forKey:@(kMainDartFile)]; - [defaults setObject:@(packages.c_str()) forKey:@(kPackages)]; - [defaults setObject:@(bundle.c_str()) forKey:@(kFLX)]; + [defaults setObject:@(dart_main.c_str()) forKey:@(switches::kMainDartFile)]; + [defaults setObject:@(packages.c_str()) forKey:@(switches::kPackages)]; + [defaults setObject:@(bundle.c_str()) forKey:@(switches::kFLX)]; [defaults synchronize]; @@ -210,4 +208,3 @@ bool AttemptLaunchFromCommandLineSwitches(sky::SkyEnginePtr& engine) { } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/mac/platform_service_provider.cc b/shell/platform/darwin/common/platform_service_provider.cc similarity index 97% rename from sky/shell/platform/mac/platform_service_provider.cc rename to shell/platform/darwin/common/platform_service_provider.cc index e8c90b8dc85a25048a78a89f77ae90727de13511..77d331a5c435327543309c6faa4bc14cc19297ec 100644 --- a/sky/shell/platform/mac/platform_service_provider.cc +++ b/shell/platform/darwin/common/platform_service_provider.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/sky/shell/platform/mac/platform_service_provider.h" +#include "flutter/shell/platform/darwin/common/platform_service_provider.h" #if TARGET_OS_IPHONE #include "flutter/services/activity/ios/activity_impl.h" @@ -19,7 +19,6 @@ #include "flutter/services/vsync/mac/vsync_provider_mac_impl.h" #endif // TARGET_OS_IPHONE -namespace sky { namespace shell { PlatformServiceProvider::PlatformServiceProvider( @@ -100,4 +99,3 @@ void PlatformServiceProvider::ConnectToService( } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/mac/platform_service_provider.h b/shell/platform/darwin/common/platform_service_provider.h similarity index 83% rename from sky/shell/platform/mac/platform_service_provider.h rename to shell/platform/darwin/common/platform_service_provider.h index 4a76c8d4f3d4d2d91419af89c4cb8b81d17bae6f..662dfb7aeff7f8a40ee93a27e5e7f2df9609e561 100644 --- a/sky/shell/platform/mac/platform_service_provider.h +++ b/shell/platform/darwin/common/platform_service_provider.h @@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_MAC_PLATFORM_SERVICE_PROVIDER_H_ -#define SKY_SHELL_PLATFORM_MAC_PLATFORM_SERVICE_PROVIDER_H_ +#ifndef SHELL_PLATFORM_MAC_PLATFORM_SERVICE_PROVIDER_H_ +#define SHELL_PLATFORM_MAC_PLATFORM_SERVICE_PROVIDER_H_ -#include "lib/ftl/macros.h" #include "base/callback.h" +#include "lib/ftl/macros.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/interfaces/application/service_provider.mojom.h" -namespace sky { namespace shell { class PlatformServiceProvider : public mojo::ServiceProvider { @@ -21,6 +20,7 @@ class PlatformServiceProvider : public mojo::ServiceProvider { PlatformServiceProvider(mojo::InterfaceRequest request, DynamicServiceProviderCallback callback); + ~PlatformServiceProvider() override; void ConnectToService(const mojo::String& service_name, @@ -34,6 +34,5 @@ class PlatformServiceProvider : public mojo::ServiceProvider { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_MAC_PLATFORM_SERVICE_PROVIDER_H_ +#endif // SHELL_PLATFORM_MAC_PLATFORM_SERVICE_PROVIDER_H_ diff --git a/sky/shell/platform/mac/view_service_provider.cc b/shell/platform/darwin/common/view_service_provider.cc similarity index 91% rename from sky/shell/platform/mac/view_service_provider.cc rename to shell/platform/darwin/common/view_service_provider.cc index 5f9be52e16fd1b841f9d2c310ebc2d9eb3f7c061..b982dc0e9516c9bfb887f8c73fc1ecf51ff28314 100644 --- a/sky/shell/platform/mac/view_service_provider.cc +++ b/shell/platform/darwin/common/view_service_provider.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform/mac/view_service_provider.h" +#include "flutter/shell/platform/darwin/common/view_service_provider.h" #include -namespace sky { namespace shell { ViewServiceProvider::ViewServiceProvider( @@ -36,4 +35,3 @@ void ViewServiceProvider::ConnectToService( } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/mac/view_service_provider.h b/shell/platform/darwin/common/view_service_provider.h similarity index 85% rename from sky/shell/platform/mac/view_service_provider.h rename to shell/platform/darwin/common/view_service_provider.h index 816c79c7e7aa07f8c65aa8d38b5fe4fc55b27647..357b3c5fda368f1eb73551a37d8933c401daa205 100644 --- a/sky/shell/platform/mac/view_service_provider.h +++ b/shell/platform/darwin/common/view_service_provider.h @@ -2,22 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_MAC_VIEW_SERVICE_PROVIDER_H_ -#define SKY_SHELL_PLATFORM_MAC_VIEW_SERVICE_PROVIDER_H_ +#ifndef SHELL_PLATFORM_MAC_VIEW_SERVICE_PROVIDER_H_ +#define SHELL_PLATFORM_MAC_VIEW_SERVICE_PROVIDER_H_ #include +#include "flutter/services/platform/app_messages.mojom.h" +#include "flutter/sky/engine/wtf/Assertions.h" #include "lib/ftl/macros.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/interfaces/application/service_provider.mojom.h" -#include "flutter/sky/engine/wtf/Assertions.h" -#include "flutter/services/platform/app_messages.mojom.h" #if TARGET_OS_IPHONE #include "flutter/services/editing/ios/keyboard_impl.h" #endif -namespace sky { namespace shell { typedef std::function + #include + #include "base/bind.h" #include "base/command_line.h" #include "base/message_loop/message_loop.h" -#include "flutter/sky/shell/platform/mac/platform_mac.h" -#include "flutter/sky/shell/platform/mac/sky_application.h" -#include "flutter/sky/shell/switches.h" -#include "flutter/sky/shell/testing/testing.h" +#include "flutter/shell/common/switches.h" +#include "flutter/shell/platform/darwin/common/platform_mac.h" +#include "flutter/shell/platform/darwin/desktop/sky_application.h" +#include "flutter/shell/testing/testing.h" -namespace sky { namespace shell { namespace { @@ -27,26 +28,25 @@ void AttachMessageLoopToMainRunLoop(void) { } // namespace } // namespace shell -} // namespace sky int main(int argc, const char* argv[]) { [SkyApplication sharedApplication]; - sky::shell::PlatformMacMain(argc, argv, ""); + shell::PlatformMacMain(argc, argv, ""); base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(sky::shell::switches::kHelp)) { - sky::shell::switches::PrintUsage("SkyShell"); + if (command_line.HasSwitch(shell::switches::kHelp)) { + shell::switches::PrintUsage("SkyShell"); return EXIT_SUCCESS; } - if (command_line.HasSwitch(sky::shell::switches::kNonInteractive)) { - if (!sky::shell::InitForTesting()) + if (command_line.HasSwitch(shell::switches::kNonInteractive)) { + if (!shell::InitForTesting()) return 1; base::MessageLoop::current()->Run(); return EXIT_SUCCESS; } - sky::shell::AttachMessageLoopToMainRunLoop(); + shell::AttachMessageLoopToMainRunLoop(); return NSApplicationMain(argc, argv); } diff --git a/sky/shell/platform/mac/platform_view_mac.h b/shell/platform/darwin/desktop/platform_view_mac.h similarity index 83% rename from sky/shell/platform/mac/platform_view_mac.h rename to shell/platform/darwin/desktop/platform_view_mac.h index 51949d1551ff3f50b5dcf9e6ba689680eeee5a61..de666905afe7cd512d9cefe7e1884d0595dbc7aa 100644 --- a/sky/shell/platform/mac/platform_view_mac.h +++ b/shell/platform/darwin/desktop/platform_view_mac.h @@ -2,17 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ -#define SKY_SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ +#ifndef SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ +#define SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ #include "base/mac/scoped_nsobject.h" +#include "flutter/shell/common/platform_view.h" #include "lib/ftl/memory/weak_ptr.h" -#include "flutter/sky/shell/platform_view.h" @class NSOpenGLView; @class NSOpenGLContext; -namespace sky { namespace shell { class PlatformViewMac : public PlatformView { @@ -23,7 +22,7 @@ class PlatformViewMac : public PlatformView { void SetupAndLoadDart(); - SkyEnginePtr& engineProxy(); + sky::SkyEnginePtr& engineProxy(); ftl::WeakPtr GetWeakViewPtr() override; @@ -57,6 +56,5 @@ class PlatformViewMac : public PlatformView { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ +#endif // SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ diff --git a/sky/shell/platform/mac/platform_view_mac.mm b/shell/platform/darwin/desktop/platform_view_mac.mm similarity index 89% rename from sky/shell/platform/mac/platform_view_mac.mm rename to shell/platform/darwin/desktop/platform_view_mac.mm index 60ba9b1cb064614d28de2c93a8d586b1f5a99f5d..153092a5ab965458f615c9cf56d04ae26ec2bd67 100644 --- a/sky/shell/platform/mac/platform_view_mac.mm +++ b/shell/platform/darwin/desktop/platform_view_mac.mm @@ -2,28 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform/mac/platform_view_mac.h" +#include "flutter/shell/platform/darwin/desktop/platform_view_mac.h" #include #include #include "base/command_line.h" #include "base/trace_event/trace_event.h" -#include "flutter/sky/shell/switches.h" -#include "flutter/sky/shell/platform/mac/view_service_provider.h" -#include "flutter/sky/shell/platform/mac/platform_mac.h" -#include "flutter/sky/shell/platform/mac/platform_service_provider.h" +#include "flutter/shell/common/switches.h" +#include "flutter/shell/platform/darwin/common/platform_mac.h" +#include "flutter/shell/platform/darwin/common/platform_service_provider.h" +#include "flutter/shell/platform/darwin/common/view_service_provider.h" #include "lib/ftl/synchronization/waitable_event.h" -namespace sky { namespace shell { -static void IgnoreRequest( - mojo::InterfaceRequest) {} - -static void DynamicServiceResolve(const mojo::String& service_name, - mojo::ScopedMessagePipeHandle handle) {} - PlatformViewMac::PlatformViewMac(NSOpenGLView* gl_view) : opengl_view_([gl_view retain]), resource_loading_context_([[NSOpenGLContext alloc] @@ -33,13 +26,21 @@ PlatformViewMac::PlatformViewMac(NSOpenGLView* gl_view) NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); if (paths.count > 0) { - sky::shell::Shell::Shared().tracing_controller().set_traces_base_path( + shell::Shell::Shared().tracing_controller().set_traces_base_path( [[paths objectAtIndex:0] UTF8String]); } } PlatformViewMac::~PlatformViewMac() = default; +static void DynamicServiceResolve(const mojo::String& service_name, + mojo::ScopedMessagePipeHandle handle) { + // This platform does not support dynamic service loading. +} + +static void IgnoreRequest( + mojo::InterfaceRequest) {} + void PlatformViewMac::ConnectToEngineAndSetupServices() { ConnectToEngine(mojo::GetProxy(&sky_engine_)); @@ -92,7 +93,7 @@ void PlatformViewMac::SetupAndLoadFromSource( sky_engine_->RunFromFile(main, packages, assets_directory); } -SkyEnginePtr& PlatformViewMac::engineProxy() { +sky::SkyEnginePtr& PlatformViewMac::engineProxy() { return sky_engine_; } @@ -165,4 +166,3 @@ void PlatformViewMac::RunFromSource(const std::string& main, } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/mac/sky_app_delegate.h b/shell/platform/darwin/desktop/sky_app_delegate.h similarity index 100% rename from sky/shell/platform/mac/sky_app_delegate.h rename to shell/platform/darwin/desktop/sky_app_delegate.h diff --git a/sky/shell/platform/mac/sky_app_delegate.m b/shell/platform/darwin/desktop/sky_app_delegate.m similarity index 100% rename from sky/shell/platform/mac/sky_app_delegate.m rename to shell/platform/darwin/desktop/sky_app_delegate.m diff --git a/sky/shell/platform/mac/sky_application.h b/shell/platform/darwin/desktop/sky_application.h similarity index 77% rename from sky/shell/platform/mac/sky_application.h rename to shell/platform/darwin/desktop/sky_application.h index a74edca41cc4f985d59e81353c8657a2d424097d..77d4ead94399826c24bab9654e68536dd2abb1ce 100644 --- a/sky/shell/platform/mac/sky_application.h +++ b/shell/platform/darwin/desktop/sky_application.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef __SKY_SHELL_MAC_SKY_APPLICATION__ -#define __SKY_SHELL_MAC_SKY_APPLICATION__ +#ifndef __SHELL_MAC_SKY_APPLICATION__ +#define __SHELL_MAC_SKY_APPLICATION__ #import @@ -15,4 +15,4 @@ @interface SkyApplication : NSApplication @end -#endif /* defined(__SKY_SHELL_MAC_SKY_APPLICATION__) */ +#endif /* defined(__SHELL_MAC_SKY_APPLICATION__) */ diff --git a/sky/shell/platform/mac/sky_application.mm b/shell/platform/darwin/desktop/sky_application.mm similarity index 93% rename from sky/shell/platform/mac/sky_application.mm rename to shell/platform/darwin/desktop/sky_application.mm index 3fbd8fbdb1647acc25fa12b451bc2a17a1fefe86..e2955175030ec75d9ecdf510b1c8b3c44d82e080 100644 --- a/sky/shell/platform/mac/sky_application.mm +++ b/shell/platform/darwin/desktop/sky_application.mm @@ -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/sky/shell/platform/mac/sky_application.h" +#include "flutter/shell/platform/darwin/desktop/sky_application.h" #include "base/auto_reset.h" #include "base/logging.h" diff --git a/sky/shell/platform/mac/sky_mac.xib b/shell/platform/darwin/desktop/sky_mac.xib similarity index 100% rename from sky/shell/platform/mac/sky_mac.xib rename to shell/platform/darwin/desktop/sky_mac.xib diff --git a/sky/shell/platform/mac/sky_window.h b/shell/platform/darwin/desktop/sky_window.h similarity index 100% rename from sky/shell/platform/mac/sky_window.h rename to shell/platform/darwin/desktop/sky_window.h diff --git a/sky/shell/platform/mac/sky_window.mm b/shell/platform/darwin/desktop/sky_window.mm similarity index 95% rename from sky/shell/platform/mac/sky_window.mm rename to shell/platform/darwin/desktop/sky_window.mm index c58a7c5a5a9d1eafc01c8d1923a7f83b712be80c..d6192e22a268977926e77027e3a1d6a5cd44b402 100644 --- a/sky/shell/platform/mac/sky_window.mm +++ b/shell/platform/darwin/desktop/sky_window.mm @@ -6,7 +6,7 @@ #include "base/time/time.h" #include "flutter/services/pointer/pointer.mojom.h" -#include "flutter/sky/shell/platform/mac/platform_view_mac.h" +#include "flutter/shell/platform/darwin/desktop/platform_view_mac.h" @interface SkyWindow () @@ -38,7 +38,7 @@ static inline pointer::PointerType EventTypeFromNSEventPhase( } @implementation SkyWindow { - std::unique_ptr _platform_view; + std::unique_ptr _platform_view; } @synthesize renderSurface = _renderSurface; @@ -56,7 +56,7 @@ static inline pointer::PointerType EventTypeFromNSEventPhase( DCHECK(_platform_view == nullptr) << "The platform view must not already be set."; - _platform_view.reset(new sky::shell::PlatformViewMac(self.renderSurface)); + _platform_view.reset(new shell::PlatformViewMac(self.renderSurface)); _platform_view->SetupResourceContextOnIOThread(); _platform_view->NotifyCreated(); } diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..595d00562ed9b825a473252d39152ab5aced4e6e --- /dev/null +++ b/shell/platform/darwin/ios/BUILD.gn @@ -0,0 +1,161 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +assert(is_ios) + +import("//build/config/ios/rules.gni") +import("//build/config/ios/ios_sdk.gni") + +shared_library("flutter_framework_dylib") { + visibility = [ ":*" ] + + output_name = "Flutter" + + sources = [ + "framework/Headers/Flutter.h", + "framework/Headers/FlutterAppDelegate.h", + "framework/Headers/FlutterAsyncMessageListener.h", + "framework/Headers/FlutterDartProject.h", + "framework/Headers/FlutterMacros.h", + "framework/Headers/FlutterMessageListener.h", + "framework/Headers/FlutterViewController.h", + "framework/Source/accessibility_bridge.h", + "framework/Source/accessibility_bridge.mm", + "framework/Source/application_messages_impl.h", + "framework/Source/application_messages_impl.mm", + "framework/Source/flutter_touch_mapper.h", + "framework/Source/flutter_touch_mapper.mm", + "framework/Source/FlutterAppDelegate.mm", + "framework/Source/FlutterDartProject.mm", + "framework/Source/FlutterDartProject_Internal.h", + "framework/Source/FlutterDartSource.h", + "framework/Source/FlutterDartSource.mm", + "framework/Source/FlutterDynamicServiceLoader.h", + "framework/Source/FlutterDynamicServiceLoader.mm", + "framework/Source/FlutterView.h", + "framework/Source/FlutterView.mm", + "framework/Source/FlutterViewController.mm", + "platform_view_ios.h", + "platform_view_ios.mm", + ] + + + deps = [ + "//base:base", + "//dart/runtime:libdart", + "//flutter/services/activity", + "//flutter/services/dynamic:embedder", + "//flutter/services/editing", + "//flutter/services/engine:interfaces", + "//flutter/services/media", + "//flutter/services/platform", + "//flutter/services/semantics", + "//flutter/services/vsync", + "//flutter/shell/common", + "//flutter/shell/gpu", + "//flutter/shell/platform/darwin/common", + "//flutter/skia", + "//flutter/sky/engine/platform", + "//flutter/sky/engine/wtf", + "//lib/ftl", + "//mojo/edk/base_edk", + "//mojo/edk/system", + "//mojo/public/cpp/application", + "//mojo/public/cpp/bindings", + "//mojo/public/interfaces/application", + ] + + defines = [ + "FLUTTER_FRAMEWORK" + ] + + libs = [ + "UIKit.framework", + "OpenGLES.framework", + "AVFoundation.framework", + "AudioToolbox.framework", + "QuartzCore.framework", + ] +} + +group("flutter_framework") { + framework_dir = "$root_out_dir/Flutter.framework" + + copy("framework_dylib") { + visibility = [ ":*" ] + sources = [ "$root_out_dir/libFlutter.dylib" ] + outputs = [ "$framework_dir/Flutter" ] + + deps = [ + ":flutter_framework_dylib", + ] + } + + action("framework_install_name") { + visibility = [ ":*" ] + stamp_file = "$root_out_dir/flutter_install_name_stamp" + script = "//flutter/sky/tools/change_install_name.py" + + inputs = [ "$framework_dir/Flutter" ] + outputs = [ stamp_file ] + + args = [ + "--dylib", + rebase_path("$framework_dir/Flutter"), + "--install_name", + "@rpath/Flutter.framework/Flutter", + "--stamp", + rebase_path(stamp_file), + ] + + deps = [ + ":framework_dylib" + ] + } + + copy("framework_info_plist") { + visibility = [ ":*" ] + sources = [ "framework/Info.plist" ] + outputs = [ "$framework_dir/Info.plist" ] + } + + copy("framework_module_map") { + visibility = [ ":*" ] + sources = [ "framework/module.modulemap" ] + outputs = [ "$framework_dir/Modules/module.modulemap" ] + } + + copy("framework_headers") { + visibility = [ ":*" ] + sources = [ + "framework/Headers/Flutter.h", + "framework/Headers/FlutterAppDelegate.h", + "framework/Headers/FlutterAsyncMessageListener.h", + "framework/Headers/FlutterDartProject.h", + "framework/Headers/FlutterMacros.h", + "framework/Headers/FlutterMessageListener.h", + "framework/Headers/FlutterViewController.h", + ] + outputs = [ "$framework_dir/Headers/{{source_file_part}}" ] + } + + copy("framework_icu") { + visibility = [ ":*" ] + set_sources_assignment_filter([]) + sources = [ + "//third_party/icu/android/icudtl.dat", + ] + set_sources_assignment_filter(sources_assignment_filter) + outputs = [ "$framework_dir/{{source_file_part}}" ] + } + + public_deps = [ + ":framework_dylib", + ":framework_headers", + ":framework_icu", + ":framework_info_plist", + ":framework_install_name", + ":framework_module_map", + ] +} diff --git a/sky/shell/platform/ios/framework/Headers/Flutter.h b/shell/platform/darwin/ios/framework/Headers/Flutter.h similarity index 100% rename from sky/shell/platform/ios/framework/Headers/Flutter.h rename to shell/platform/darwin/ios/framework/Headers/Flutter.h diff --git a/sky/shell/platform/ios/framework/Headers/FlutterAppDelegate.h b/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h similarity index 100% rename from sky/shell/platform/ios/framework/Headers/FlutterAppDelegate.h rename to shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h diff --git a/sky/shell/platform/ios/framework/Headers/FlutterAsyncMessageListener.h b/shell/platform/darwin/ios/framework/Headers/FlutterAsyncMessageListener.h similarity index 100% rename from sky/shell/platform/ios/framework/Headers/FlutterAsyncMessageListener.h rename to shell/platform/darwin/ios/framework/Headers/FlutterAsyncMessageListener.h diff --git a/sky/shell/platform/ios/framework/Headers/FlutterDartProject.h b/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h similarity index 100% rename from sky/shell/platform/ios/framework/Headers/FlutterDartProject.h rename to shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h diff --git a/sky/shell/platform/ios/framework/Headers/FlutterMacros.h b/shell/platform/darwin/ios/framework/Headers/FlutterMacros.h similarity index 100% rename from sky/shell/platform/ios/framework/Headers/FlutterMacros.h rename to shell/platform/darwin/ios/framework/Headers/FlutterMacros.h diff --git a/sky/shell/platform/ios/framework/Headers/FlutterMessageListener.h b/shell/platform/darwin/ios/framework/Headers/FlutterMessageListener.h similarity index 100% rename from sky/shell/platform/ios/framework/Headers/FlutterMessageListener.h rename to shell/platform/darwin/ios/framework/Headers/FlutterMessageListener.h diff --git a/sky/shell/platform/ios/framework/Headers/FlutterViewController.h b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h similarity index 100% rename from sky/shell/platform/ios/framework/Headers/FlutterViewController.h rename to shell/platform/darwin/ios/framework/Headers/FlutterViewController.h diff --git a/sky/shell/platform/ios/framework/Info.plist b/shell/platform/darwin/ios/framework/Info.plist similarity index 100% rename from sky/shell/platform/ios/framework/Info.plist rename to shell/platform/darwin/ios/framework/Info.plist diff --git a/sky/shell/platform/ios/framework/Source/FlutterAppDelegate.mm b/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm similarity index 71% rename from sky/shell/platform/ios/framework/Source/FlutterAppDelegate.mm rename to shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm index 8781df8e22c1735ab561c01d4ad6c4f67e19fdf6..b69ee926376d385e7a4b8c69b1cee75097699a33 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterAppDelegate.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm @@ -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/sky/shell/platform/ios/framework/Headers/FlutterAppDelegate.h" +#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h" @implementation FlutterAppDelegate diff --git a/sky/shell/platform/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm similarity index 93% rename from sky/shell/platform/ios/framework/Source/FlutterDartProject.mm rename to shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index be6790b5c014795a358ce6f833e155f847ddc7c0..8b96296c9b50adbf5d0d77404382fb3fb66dc24e 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform/ios/framework/Source/FlutterDartProject_Internal.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h" #include "base/command_line.h" #include "dart/runtime/include/dart_api.h" -#include "flutter/sky/shell/platform/ios/framework/Source/FlutterDartSource.h" -#include "flutter/sky/shell/switches.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartSource.h" +#include "flutter/shell/common/switches.h" static NSURL* URLForSwitch(const char* name) { auto cmd = *base::CommandLine::ForCurrentProcess(); @@ -91,7 +91,7 @@ static NSURL* URLForSwitch(const char* name) { // Load directly from sources if the appropriate command line flags are // specified. If not, try loading from a script snapshot in the framework // bundle. - NSURL* flxURL = URLForSwitch(sky::shell::switches::kFLX); + NSURL* flxURL = URLForSwitch(shell::switches::kFLX); if (flxURL == nil) { // If the URL was not specified on the command line, look inside the @@ -101,8 +101,8 @@ static NSURL* URLForSwitch(const char* name) { isDirectory:NO]; } - NSURL* dartMainURL = URLForSwitch(sky::shell::switches::kMainDartFile); - NSURL* dartPackagesURL = URLForSwitch(sky::shell::switches::kPackages); + NSURL* dartMainURL = URLForSwitch(shell::switches::kMainDartFile); + NSURL* dartPackagesURL = URLForSwitch(shell::switches::kPackages); return [self initWithFLXArchive:flxURL dartMain:dartMainURL diff --git a/sky/shell/platform/ios/framework/Source/FlutterDartProject_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h similarity index 67% rename from sky/shell/platform/ios/framework/Source/FlutterDartProject_Internal.h rename to shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h index 60c0059369c0243f8982ec3929253d9af7e126f8..31c1c28e73e6907daaef7e414c196a1043af90fc 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterDartProject_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ -#define SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ +#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ +#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ -#include "flutter/sky/shell/platform/ios/framework/Headers/FlutterDartProject.h" +#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h" #include "flutter/services/engine/sky_engine.mojom.h" @@ -28,4 +28,4 @@ typedef void (^LaunchResult)(BOOL success, NSString* message); @end -#endif // SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ +#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ diff --git a/sky/shell/platform/ios/framework/Source/FlutterDartSource.h b/shell/platform/darwin/ios/framework/Source/FlutterDartSource.h similarity index 80% rename from sky/shell/platform/ios/framework/Source/FlutterDartSource.h rename to shell/platform/darwin/ios/framework/Source/FlutterDartSource.h index 399ee5740627810164b3d866373753d55eb3ce65..ebf869bae8ddeab36b6f88aa2197f40eb26799e6 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterDartSource.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartSource.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTSOURCE_H_ -#define SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTSOURCE_H_ +#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTSOURCE_H_ +#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTSOURCE_H_ #import @@ -27,4 +27,4 @@ typedef void (^ValidationResult)(BOOL result, NSString* message); @end -#endif // SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTSOURCE_H_ +#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERDARTSOURCE_H_ diff --git a/sky/shell/platform/ios/framework/Source/FlutterDartSource.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartSource.mm similarity index 90% rename from sky/shell/platform/ios/framework/Source/FlutterDartSource.mm rename to shell/platform/darwin/ios/framework/Source/FlutterDartSource.mm index bedac879f9d19dbb57d972ad9d51e291c2bcb42f..dc4b1ed19dcf5544298a4da262ac6b176f36f656 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterDartSource.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartSource.mm @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform/ios/framework/Source/FlutterDartSource.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartSource.h" @implementation FlutterDartSource -@synthesize dartMain=_dartMain; -@synthesize packages=_packages; -@synthesize flxArchive=_flxArchive; -@synthesize archiveContainsScriptSnapshot=_archiveContainsScriptSnapshot; +@synthesize dartMain = _dartMain; +@synthesize packages = _packages; +@synthesize flxArchive = _flxArchive; +@synthesize archiveContainsScriptSnapshot = _archiveContainsScriptSnapshot; #pragma mark - Convenience Initializers @@ -17,7 +17,6 @@ return [self initWithDartMain:nil packages:nil flxArchive:nil]; } - #pragma mark - Designated Initializers - (instancetype)initWithDartMain:(NSURL*)dartMain diff --git a/sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.h b/shell/platform/darwin/ios/framework/Source/FlutterDynamicServiceLoader.h similarity index 53% rename from sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.h rename to shell/platform/darwin/ios/framework/Source/FlutterDynamicServiceLoader.h index 7ad5a0b766cd94f9e5507334dca818229777d516..9c05fce0df9815cbcea5a05199b87c0b24bfaad0 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterDynamicServiceLoader.h @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_DYNAMIC_SERVICE_LOADER_H_ -#define SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_DYNAMIC_SERVICE_LOADER_H_ +#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_DYNAMIC_SERVICE_LOADER_H_ +#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_DYNAMIC_SERVICE_LOADER_H_ #import -#include "flutter/sky/shell/platform/mac/platform_service_provider.h" +#include "flutter/shell/platform/darwin/common/platform_service_provider.h" @interface FlutterDynamicServiceLoader : NSObject @@ -15,4 +15,4 @@ @end -#endif // SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_DYNAMIC_SERVICE_LOADER_H_ +#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_DYNAMIC_SERVICE_LOADER_H_ diff --git a/sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.mm b/shell/platform/darwin/ios/framework/Source/FlutterDynamicServiceLoader.mm similarity index 97% rename from sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.mm rename to shell/platform/darwin/ios/framework/Source/FlutterDynamicServiceLoader.mm index 90b00dd6e4b5f669ac41fb4c0d280c12219cf465..79300a39b58c5f83c171c4b4d04d3f5df42953ed 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDynamicServiceLoader.mm @@ -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/sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterDynamicServiceLoader.h" #include "base/logging.h" #include "flutter/services/dynamic/dynamic_service_embedder.h" diff --git a/sky/shell/platform/ios/framework/Source/FlutterView.h b/shell/platform/darwin/ios/framework/Source/FlutterView.h similarity index 54% rename from sky/shell/platform/ios/framework/Source/FlutterView.h rename to shell/platform/darwin/ios/framework/Source/FlutterView.h index 84ec4c218ef7a326359ae3c847d6e5bfd86db0ae..661940620c947ddfb9e5d12d444a0003dd7ae8dc 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterView.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_VIEW_H_ -#define SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_VIEW_H_ +#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_VIEW_H_ +#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_VIEW_H_ #include @@ -11,4 +11,4 @@ @end -#endif // SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_VIEW_H_ +#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTER_VIEW_H_ diff --git a/sky/shell/platform/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm similarity index 89% rename from sky/shell/platform/ios/framework/Source/FlutterView.mm rename to shell/platform/darwin/ios/framework/Source/FlutterView.mm index 30081f7dccad1bf972b195675d006f5294e1423e..0bab07bf1d8dedfe7dcf54193a410ff386725f3e 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -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/sky/shell/platform/ios/framework/Source/FlutterView.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h" @interface FlutterView () diff --git a/sky/shell/platform/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm similarity index 96% rename from sky/shell/platform/ios/framework/Source/FlutterViewController.mm rename to shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 9866c8cea192d451eb78994b39afd02942c9ba37..2dd00a5f431b0f7cf0ebb0ac066c1408d5828bde 100644 --- a/sky/shell/platform/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "flutter/sky/shell/platform/ios/framework/Headers/FlutterViewController.h" +#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" #include "base/mac/scoped_block.h" #include "base/mac/scoped_nsobject.h" #include "base/strings/sys_string_conversions.h" #include "flutter/services/platform/ios/system_chrome_impl.h" #include "flutter/sky/engine/wtf/MakeUnique.h" -#include "flutter/sky/shell/platform/ios/framework/Source/flutter_touch_mapper.h" -#include "flutter/sky/shell/platform/ios/framework/Source/FlutterDartProject_Internal.h" -#include "flutter/sky/shell/platform/ios/platform_view_ios.h" -#include "flutter/sky/shell/platform/mac/platform_mac.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/flutter_touch_mapper.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h" +#include "flutter/shell/platform/darwin/ios/platform_view_ios.h" +#include "flutter/shell/platform/darwin/common/platform_mac.h" @interface FlutterViewController () @end @@ -20,7 +20,7 @@ void FlutterInit(int argc, const char* argv[]) { NSBundle* bundle = [NSBundle bundleForClass:[FlutterViewController class]]; NSString* icuDataPath = [bundle pathForResource:@"icudtl" ofType:@"dat"]; - sky::shell::PlatformMacMain(argc, argv, icuDataPath.UTF8String); + shell::PlatformMacMain(argc, argv, icuDataPath.UTF8String); } @implementation FlutterViewController { @@ -28,8 +28,8 @@ void FlutterInit(int argc, const char* argv[]) { UIInterfaceOrientationMask _orientationPreferences; UIStatusBarStyle _statusBarStyle; sky::ViewportMetricsPtr _viewportMetrics; - sky::shell::TouchMapper _touchMapper; - std::unique_ptr _platformView; + shell::TouchMapper _touchMapper; + std::unique_ptr _platformView; BOOL _initialized; } @@ -73,7 +73,7 @@ void FlutterInit(int argc, const char* argv[]) { _orientationPreferences = UIInterfaceOrientationMaskAll; _statusBarStyle = UIStatusBarStyleDefault; _viewportMetrics = sky::ViewportMetrics::New(); - _platformView = WTF::MakeUnique( + _platformView = WTF::MakeUnique( reinterpret_cast(self.view.layer)); _platformView->SetupResourceContextOnIOThread(); diff --git a/sky/shell/platform/ios/framework/Source/accessibility_bridge.h b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h similarity index 83% rename from sky/shell/platform/ios/framework/Source/accessibility_bridge.h rename to shell/platform/darwin/ios/framework/Source/accessibility_bridge.h index dd3f73ff9adc423ffef4eec825d0934168d4c0af..0f8be847db359a5fa4b3e42ebf3d97714473f803 100644 --- a/sky/shell/platform/ios/framework/Source/accessibility_bridge.h +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h @@ -2,28 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_H_ -#define SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_H_ +#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_H_ +#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_H_ #include #include #include +#include "flutter/services/semantics/semantics.mojom.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h" +#include "flutter/sky/engine/platform/geometry/FloatRect.h" #include "lib/ftl/macros.h" #include "mojo/public/cpp/bindings/array.h" #include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/interfaces/application/service_provider.mojom.h" -#include "flutter/sky/engine/platform/geometry/FloatRect.h" -#include "flutter/services/semantics/semantics.mojom.h" -#include "flutter/sky/shell/platform/ios/framework/Source/FlutterView.h" #include "third_party/skia/include/core/SkMatrix44.h" #include "third_party/skia/include/core/SkRect.h" -namespace sky { namespace shell { class AccessibilityBridge; -} -} +} // namespace shell @interface SemanticObject : NSObject @@ -39,12 +37,11 @@ class AccessibilityBridge; @property(nonatomic, assign) SemanticObject* parent; - (instancetype)init __attribute__((unavailable("Use initWithBridge instead"))); -- (instancetype)initWithBridge:(sky::shell::AccessibilityBridge*)bridge +- (instancetype)initWithBridge:(shell::AccessibilityBridge*)bridge uid:(uint32_t)uid NS_DESIGNATED_INITIALIZER; @end -namespace sky { namespace shell { class AccessibilityBridge final : public semantics::SemanticsListener { @@ -75,6 +72,5 @@ class AccessibilityBridge final : public semantics::SemanticsListener { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_H_ +#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_H_ diff --git a/sky/shell/platform/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm similarity index 85% rename from sky/shell/platform/ios/framework/Source/accessibility_bridge.mm rename to shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index f73783bd78a69fae3f865a43c9cfcfbcff7089ac..771b0dbd3db153d46cb4661ab30551891fac45f0 100644 --- a/sky/shell/platform/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -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/sky/shell/platform/ios/framework/Source/accessibility_bridge.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h" #import #include @@ -31,7 +31,7 @@ struct Geometry { } // namespace @implementation SemanticObject { - sky::shell::AccessibilityBridge* _bridge; + shell::AccessibilityBridge* _bridge; semantics::SemanticFlagsPtr _flags; semantics::SemanticStringsPtr _strings; @@ -56,7 +56,7 @@ struct Geometry { #pragma mark - Designated initializers -- (instancetype)initWithBridge:(sky::shell::AccessibilityBridge*)bridge +- (instancetype)initWithBridge:(shell::AccessibilityBridge*)bridge uid:(uint32_t)uid { DCHECK(bridge != nil) << "bridge must be set"; DCHECK(uid >= kRootNodeId); @@ -94,24 +94,24 @@ struct Geometry { _canBeScrolledVertically = false; for (int action : node->actions) { switch (static_cast(action)) { - case semantics::SemanticAction::TAP: - _canBeTapped = true; - break; - case semantics::SemanticAction::LONG_PRESS: - _canBeLongPressed = true; - break; - case semantics::SemanticAction::SCROLL_LEFT: - case semantics::SemanticAction::SCROLL_RIGHT: - _canBeScrolledHorizontally = true; - break; - case semantics::SemanticAction::SCROLL_UP: - case semantics::SemanticAction::SCROLL_DOWN: - _canBeScrolledVertically = true; - break; - case semantics::SemanticAction::INCREASE: - case semantics::SemanticAction::DECREASE: - _canBeAdjusted = true; - break; + case semantics::SemanticAction::TAP: + _canBeTapped = true; + break; + case semantics::SemanticAction::LONG_PRESS: + _canBeLongPressed = true; + break; + case semantics::SemanticAction::SCROLL_LEFT: + case semantics::SemanticAction::SCROLL_RIGHT: + _canBeScrolledHorizontally = true; + break; + case semantics::SemanticAction::SCROLL_UP: + case semantics::SemanticAction::SCROLL_DOWN: + _canBeScrolledVertically = true; + break; + case semantics::SemanticAction::INCREASE: + case semantics::SemanticAction::DECREASE: + _canBeAdjusted = true; + break; } } } @@ -246,16 +246,20 @@ struct Geometry { switch (direction) { case UIAccessibilityScrollDirectionRight: - _bridge->server()->PerformAction(_uid, semantics::SemanticAction::SCROLL_RIGHT); + _bridge->server()->PerformAction(_uid, + semantics::SemanticAction::SCROLL_RIGHT); break; case UIAccessibilityScrollDirectionLeft: - _bridge->server()->PerformAction(_uid, semantics::SemanticAction::SCROLL_LEFT); + _bridge->server()->PerformAction(_uid, + semantics::SemanticAction::SCROLL_LEFT); break; case UIAccessibilityScrollDirectionUp: - _bridge->server()->PerformAction(_uid, semantics::SemanticAction::SCROLL_UP); + _bridge->server()->PerformAction(_uid, + semantics::SemanticAction::SCROLL_UP); break; case UIAccessibilityScrollDirectionDown: - _bridge->server()->PerformAction(_uid, semantics::SemanticAction::SCROLL_DOWN); + _bridge->server()->PerformAction(_uid, + semantics::SemanticAction::SCROLL_DOWN); break; default: DCHECK(false) << "Unsupported scroll direction: " << direction; @@ -280,7 +284,6 @@ struct Geometry { #pragma mark - AccessibilityBridge impl -namespace sky { namespace shell { AccessibilityBridge::AccessibilityBridge(UIView* view, @@ -323,8 +326,8 @@ void AccessibilityBridge::UpdateSemanticsTree( } else { view_.accessibilityElements = nil; } - UIAccessibilityPostNotification( - UIAccessibilityLayoutChangedNotification, nil); + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, + nil); } SemanticObject* AccessibilityBridge::UpdateSemanticObject( @@ -370,4 +373,3 @@ void AccessibilityBridge::RemoveSemanticObject( } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/ios/framework/Source/application_messages_impl.h b/shell/platform/darwin/ios/framework/Source/application_messages_impl.h similarity index 76% rename from sky/shell/platform/ios/framework/Source/application_messages_impl.h rename to shell/platform/darwin/ios/framework/Source/application_messages_impl.h index 06073e3135e266eb9cca2b3d379141484ecc0187..d473ce3ca542dd9d4670fdfc963ab56cfaabc69f 100644 --- a/sky/shell/platform/ios/framework/Source/application_messages_impl.h +++ b/shell/platform/darwin/ios/framework/Source/application_messages_impl.h @@ -2,18 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_APPLICATION_MESSAGES_IMPL_H_ -#define SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_APPLICATION_MESSAGES_IMPL_H_ +#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_APPLICATION_MESSAGES_IMPL_H_ +#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_APPLICATION_MESSAGES_IMPL_H_ #include #include "lib/ftl/memory/weak_ptr.h" #include "mojo/public/cpp/bindings/binding_set.h" #include "flutter/services/platform/app_messages.mojom.h" -#include "flutter/sky/shell/platform/ios/framework/Headers/FlutterAsyncMessageListener.h" -#include "flutter/sky/shell/platform/ios/framework/Headers/FlutterMessageListener.h" +#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterAsyncMessageListener.h" +#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterMessageListener.h" -namespace sky { namespace shell { class ApplicationMessagesImpl : public flutter::platform::ApplicationMessages { @@ -45,6 +44,5 @@ class ApplicationMessagesImpl : public flutter::platform::ApplicationMessages { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_H_ +#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_BRIDGE_H_ diff --git a/sky/shell/platform/ios/framework/Source/application_messages_impl.mm b/shell/platform/darwin/ios/framework/Source/application_messages_impl.mm similarity index 73% rename from sky/shell/platform/ios/framework/Source/application_messages_impl.mm rename to shell/platform/darwin/ios/framework/Source/application_messages_impl.mm index f62b19655b58e7ce76e94507e6ef680cf9b0225a..b6d4de6832e9bfd038b71674bcc6287732a0a5ce 100644 --- a/sky/shell/platform/ios/framework/Source/application_messages_impl.mm +++ b/shell/platform/darwin/ios/framework/Source/application_messages_impl.mm @@ -2,18 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform/ios/framework/Source/application_messages_impl.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/application_messages_impl.h" #include "base/strings/sys_string_conversions.h" -namespace sky { namespace shell { -ApplicationMessagesImpl::ApplicationMessagesImpl() : weak_factory_(this) { -} +ApplicationMessagesImpl::ApplicationMessagesImpl() : weak_factory_(this) {} -ApplicationMessagesImpl::~ApplicationMessagesImpl() { -} +ApplicationMessagesImpl::~ApplicationMessagesImpl() {} ftl::WeakPtr ApplicationMessagesImpl::GetWeakPtr() { return weak_factory_.GetWeakPtr(); @@ -42,10 +39,9 @@ void ApplicationMessagesImpl::SetAsyncMessageListener( async_listeners_.erase(message_name); } -void ApplicationMessagesImpl::SendString( - const mojo::String& message_name, - const mojo::String& message, - const SendStringCallback& callback) { +void ApplicationMessagesImpl::SendString(const mojo::String& message_name, + const mojo::String& message, + const SendStringCallback& callback) { std::string message_name_str = message_name; NSString* ns_message = base::SysUTF8ToNSString(message); @@ -62,12 +58,13 @@ void ApplicationMessagesImpl::SendString( auto it = async_listeners_.find(message_name_str); if (it != async_listeners_.end()) { SendStringCallback local_callback = callback; - [it->second didReceiveString:ns_message callback:^(NSString* response){ - local_callback.Run(base::SysNSStringToUTF8(response)); - }]; + [it->second + didReceiveString:ns_message + callback:^(NSString* response) { + local_callback.Run(base::SysNSStringToUTF8(response)); + }]; } } } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/ios/framework/Source/flutter_touch_mapper.h b/shell/platform/darwin/ios/framework/Source/flutter_touch_mapper.h similarity index 78% rename from sky/shell/platform/ios/framework/Source/flutter_touch_mapper.h rename to shell/platform/darwin/ios/framework/Source/flutter_touch_mapper.h index 31e1ae75b05b23771ab9069d593bb6d16d82e879..1fa6b420d82bef5d360a356f0cb5724a5c20e9c7 100644 --- a/sky/shell/platform/ios/framework/Source/flutter_touch_mapper.h +++ b/shell/platform/darwin/ios/framework/Source/flutter_touch_mapper.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_TOUCH_MAPPER_H_ -#define SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_TOUCH_MAPPER_H_ +#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_TOUCH_MAPPER_H_ +#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_TOUCH_MAPPER_H_ #include @@ -11,7 +11,6 @@ #include -namespace sky { namespace shell { /// UITouch pointers cannot be used as touch ids (even though they remain @@ -37,6 +36,5 @@ class TouchMapper { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_TOUCH_MAPPER_H_ +#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_TOUCH_MAPPER_H_ diff --git a/sky/shell/platform/ios/framework/Source/flutter_touch_mapper.mm b/shell/platform/darwin/ios/framework/Source/flutter_touch_mapper.mm similarity index 86% rename from sky/shell/platform/ios/framework/Source/flutter_touch_mapper.mm rename to shell/platform/darwin/ios/framework/Source/flutter_touch_mapper.mm index 35e88b67f34972216a0a9f0004d903f5a23366ff..b0a69b03acd477057b7c52271c9009bacfd7cf62 100644 --- a/sky/shell/platform/ios/framework/Source/flutter_touch_mapper.mm +++ b/shell/platform/darwin/ios/framework/Source/flutter_touch_mapper.mm @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform/ios/framework/Source/flutter_touch_mapper.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/flutter_touch_mapper.h" -namespace sky { namespace shell { TouchMapper::TouchMapper() : free_spots_(~0) {} @@ -30,4 +29,3 @@ int TouchMapper::identifierOf(UITouch* touch) const { } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/ios/framework/module.modulemap b/shell/platform/darwin/ios/framework/module.modulemap similarity index 100% rename from sky/shell/platform/ios/framework/module.modulemap rename to shell/platform/darwin/ios/framework/module.modulemap diff --git a/sky/shell/platform/ios/platform_view_ios.h b/shell/platform/darwin/ios/platform_view_ios.h similarity index 76% rename from sky/shell/platform/ios/platform_view_ios.h rename to shell/platform/darwin/ios/platform_view_ios.h index 4c321558f9ca032b7a0ee71f15eb2e196b42d921..a086321e5ad0c33822b6f7eef658667849925521 100644 --- a/sky/shell/platform/ios/platform_view_ios.h +++ b/shell/platform/darwin/ios/platform_view_ios.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ -#define SKY_SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ +#ifndef SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ +#define SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ #include @@ -11,15 +11,14 @@ #include "lib/ftl/memory/weak_ptr.h" #include "base/mac/scoped_nsobject.h" #include "flutter/services/platform/app_messages.mojom.h" -#include "flutter/sky/shell/platform/ios/framework/Source/accessibility_bridge.h" -#include "flutter/sky/shell/platform/ios/framework/Source/application_messages_impl.h" -#include "flutter/sky/shell/platform/ios/framework/Source/FlutterDynamicServiceLoader.h" -#include "flutter/sky/shell/platform_view.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/application_messages_impl.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterDynamicServiceLoader.h" +#include "flutter/shell/common/platform_view.h" @class CAEAGLLayer; @class UIView; -namespace sky { namespace shell { class IOSGLContext; @@ -34,7 +33,7 @@ class PlatformViewIOS : public PlatformView { void ConnectToEngineAndSetupServices(); - SkyEnginePtr& engineProxy(); + sky::SkyEnginePtr& engineProxy(); flutter::platform::ApplicationMessagesPtr& AppMessageSender(); @@ -56,7 +55,7 @@ class PlatformViewIOS : public PlatformView { private: std::unique_ptr context_; - SkyEnginePtr engine_; + sky::SkyEnginePtr engine_; mojo::ServiceProviderPtr dart_services_; flutter::platform::ApplicationMessagesPtr app_message_sender_; ApplicationMessagesImpl app_message_receiver_; @@ -72,6 +71,5 @@ class PlatformViewIOS : public PlatformView { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ +#endif // SHELL_PLATFORM_IOS_PLATFORM_VIEW_IOS_H_ diff --git a/sky/shell/platform/ios/platform_view_ios.mm b/shell/platform/darwin/ios/platform_view_ios.mm similarity index 96% rename from sky/shell/platform/ios/platform_view_ios.mm rename to shell/platform/darwin/ios/platform_view_ios.mm index b86c8c52c7ba7d823ee9eef47a1b954b58bbb105..ef694ba781191d57a053b7cddcb018517667bc83 100644 --- a/sky/shell/platform/ios/platform_view_ios.mm +++ b/shell/platform/darwin/ios/platform_view_ios.mm @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/platform/ios/platform_view_ios.h" +#include "flutter/shell/platform/darwin/ios/platform_view_ios.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "base/trace_event/trace_event.h" +#include "flutter/shell/platform/darwin/common/view_service_provider.h" #include "flutter/sky/engine/wtf/MakeUnique.h" -#include "flutter/sky/shell/platform/mac/view_service_provider.h" #include "lib/ftl/synchronization/waitable_event.h" #include "mojo/public/cpp/application/connect.h" @@ -16,7 +16,6 @@ #import #import -namespace sky { namespace shell { struct GLintSize { @@ -278,13 +277,13 @@ PlatformViewIOS::PlatformViewIOS(CAEAGLLayer* layer) weak_factory_(this) { NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - sky::shell::Shell::Shared().tracing_controller().set_traces_base_path( + shell::Shell::Shared().tracing_controller().set_traces_base_path( [paths.firstObject UTF8String]); } PlatformViewIOS::~PlatformViewIOS() = default; -SkyEnginePtr& PlatformViewIOS::engineProxy() { +sky::SkyEnginePtr& PlatformViewIOS::engineProxy() { return engine_; } @@ -292,7 +291,7 @@ flutter::platform::ApplicationMessagesPtr& PlatformViewIOS::AppMessageSender() { return app_message_sender_; } -sky::shell::ApplicationMessagesImpl& PlatformViewIOS::AppMessageReceiver() { +shell::ApplicationMessagesImpl& PlatformViewIOS::AppMessageReceiver() { return app_message_receiver_; } @@ -300,7 +299,7 @@ void PlatformViewIOS::ToggleAccessibility(UIView* view, bool enable) { if (enable) { if (!accessibility_bridge_ && dart_services_.get() != nullptr) { accessibility_bridge_.reset( - new sky::shell::AccessibilityBridge(view, dart_services_.get())); + new shell::AccessibilityBridge(view, dart_services_.get())); } } else { accessibility_bridge_ = nullptr; @@ -397,4 +396,3 @@ void PlatformViewIOS::RunFromSource(const std::string& main, } } // namespace shell -} // namespace sky diff --git a/shell/platform/linux/BUILD.gn b/shell/platform/linux/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cd78ab8d6363067bfefdda73b7a75d645825a00b --- /dev/null +++ b/shell/platform/linux/BUILD.gn @@ -0,0 +1,38 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +executable("linux") { + output_name = "sky_shell" + + sources = [ + "glfw_service_provider.cc", + "glfw_service_provider.h", + "main_linux.cc", + "message_pump_glfw.cc", + "message_pump_glfw.h", + "platform_view_glfw.cc", + "platform_view_glfw.h", + ] + + deps = [ + "//base", + "//flutter/services/engine:interfaces", + "//flutter/services/raw_keyboard:interfaces", + "//flutter/shell/common", + "//flutter/shell/gpu", + "//flutter/shell/testing", + "//flutter/skia", + "//lib/ftl", + "//mojo/common", + "//mojo/edk/base_edk", + "//mojo/edk/system", + "//mojo/public/cpp/bindings:utility", + "//mojo/public/interfaces/application", + "//third_party/glfw", + ] + + ldflags = [ + "-lGL", + ] +} diff --git a/shell/platform/linux/glfw_service_provider.cc b/shell/platform/linux/glfw_service_provider.cc new file mode 100644 index 0000000000000000000000000000000000000000..4b1cb17b092c850b90e27cdf51d36558e9b4a7e8 --- /dev/null +++ b/shell/platform/linux/glfw_service_provider.cc @@ -0,0 +1,19 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "glfw_service_provider.h" + +namespace shell { + +GLFWServiceProvider::GLFWServiceProvider( + mojo::InterfaceRequest request) + : binding_(this, request.Pass()) {} + +GLFWServiceProvider::~GLFWServiceProvider() {} + +void GLFWServiceProvider::ConnectToService( + const mojo::String& service_name, + mojo::ScopedMessagePipeHandle client_handle) {} + +} // namespace shell diff --git a/shell/platform/linux/glfw_service_provider.h b/shell/platform/linux/glfw_service_provider.h new file mode 100644 index 0000000000000000000000000000000000000000..682ccb914de5b57567b02de88b2530356ab3ca05 --- /dev/null +++ b/shell/platform/linux/glfw_service_provider.h @@ -0,0 +1,31 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_LINUX_GLFW_SERVICE_PROVIDER_H_ +#define FLUTTER_SHELL_PLATFORM_LINUX_GLFW_SERVICE_PROVIDER_H_ + +#include "lib/ftl/macros.h" +#include "mojo/public/cpp/bindings/strong_binding.h" +#include "mojo/public/interfaces/application/service_provider.mojom.h" + +namespace shell { + +class GLFWServiceProvider : public mojo::ServiceProvider { + public: + GLFWServiceProvider(mojo::InterfaceRequest request); + + ~GLFWServiceProvider() override; + + void ConnectToService(const mojo::String& service_name, + mojo::ScopedMessagePipeHandle client_handle) override; + + private: + mojo::StrongBinding binding_; + + FTL_DISALLOW_COPY_AND_ASSIGN(GLFWServiceProvider); +}; + +} // namespace shell + +#endif // FLUTTER_SHELL_PLATFORM_LINUX_GLFW_SERVICE_PROVIDER_H_ diff --git a/shell/platform/linux/main_linux.cc b/shell/platform/linux/main_linux.cc new file mode 100644 index 0000000000000000000000000000000000000000..5f71f801e8ddb4242e0f192e54c9fec8b0f0fcf1 --- /dev/null +++ b/shell/platform/linux/main_linux.cc @@ -0,0 +1,108 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/at_exit.h" +#include "base/basictypes.h" +#include "base/bind.h" +#include "base/command_line.h" +#include "base/logging.h" +#include "base/message_loop/message_loop.h" +#include "flutter/shell/common/shell.h" +#include "flutter/shell/common/switches.h" +#include "flutter/shell/platform/linux/message_pump_glfw.h" +#include "flutter/shell/platform/linux/platform_view_glfw.h" +#include "flutter/shell/testing/testing.h" +#include "mojo/edk/embedder/embedder.h" +#include "mojo/edk/embedder/simple_platform_support.h" + +namespace { + +int RunNonInteractive() { + base::MessageLoop message_loop; + + mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport()); + shell::Shell::InitStandalone(); + + if (!shell::InitForTesting()) { + shell::switches::PrintUsage("sky_shell"); + return 1; + } + + message_loop.Run(); + return 0; +} + +static bool IsDartFile(const std::string& script_uri) { + std::string dart_extension = ".dart"; + return script_uri.rfind(dart_extension) == + (script_uri.size() - dart_extension.size()); +} + +int RunInteractive() { + base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); + + base::MessageLoop message_loop(shell::MessagePumpGLFW::Create()); + + mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport()); + shell::Shell::InitStandalone(); + + auto args = command_line.GetArgs(); + if (args.empty()) + return 1; + + std::string bundle_path = + command_line.GetSwitchValueASCII(shell::switches::kFLX); + + if (bundle_path.empty()) { + // Alternatively, use the first positional argument. + bundle_path = args[0]; + } + + if (bundle_path.empty()) { + return 1; + } + + std::unique_ptr platform_view( + new shell::PlatformViewGLFW()); + + platform_view->ConnectToEngineAndSetupServices(); + + platform_view->NotifyCreated(); + + if (IsDartFile(bundle_path)) { + // Load directly from source. + platform_view->EngineProxy()->RunFromFile(bundle_path, "", ""); + + } else { + // Load from a bundle. + std::string script_uri = std::string("file://") + bundle_path; + platform_view->EngineProxy()->RunFromBundle(script_uri, bundle_path); + } + + message_loop.Run(); + + platform_view->NotifyDestroyed(); + + return 0; +} + +} // namespace + +int main(int argc, const char* argv[]) { + base::AtExitManager exit_manager; + base::CommandLine::Init(argc, argv); + + base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); + + if (command_line.HasSwitch(shell::switches::kHelp)) { + shell::switches::PrintUsage("sky_shell"); + return 0; + } + + if (command_line.HasSwitch(shell::switches::kNonInteractive)) { + return RunNonInteractive(); + } + + return RunInteractive(); +} diff --git a/sky/shell/platform/glfw/message_pump_glfw.cc b/shell/platform/linux/message_pump_glfw.cc similarity index 92% rename from sky/shell/platform/glfw/message_pump_glfw.cc rename to shell/platform/linux/message_pump_glfw.cc index ac5763b5c37770f556ea700ed426da7c0fe68276..82ae94c6b6497e14da3bf216010f509a1cf351e0 100644 --- a/sky/shell/platform/glfw/message_pump_glfw.cc +++ b/shell/platform/linux/message_pump_glfw.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/sky/shell/platform/glfw/message_pump_glfw.h" +#include "flutter/shell/platform/linux/message_pump_glfw.h" #include @@ -10,16 +10,12 @@ #include "base/logging.h" #include "base/time/time.h" -namespace sky { namespace shell { -MessagePumpGLFW::MessagePumpGLFW() : in_run_(false), should_quit_(false) { -} +MessagePumpGLFW::MessagePumpGLFW() : in_run_(false), should_quit_(false) {} -MessagePumpGLFW::~MessagePumpGLFW() { -} +MessagePumpGLFW::~MessagePumpGLFW() = default; -// static scoped_ptr MessagePumpGLFW::Create() { return scoped_ptr(new MessagePumpGLFW()); } @@ -84,4 +80,3 @@ void MessagePumpGLFW::ScheduleDelayedWork( } } // namespace shell -} // namespace sky diff --git a/sky/shell/platform/glfw/message_pump_glfw.h b/shell/platform/linux/message_pump_glfw.h similarity index 78% rename from sky/shell/platform/glfw/message_pump_glfw.h rename to shell/platform/linux/message_pump_glfw.h index 66dcca5fae18622ded476dac55d78721dd2d2e35..f2b5767a550c673edeeb82c157980e69e3d5f6b8 100644 --- a/sky/shell/platform/glfw/message_pump_glfw.h +++ b/shell/platform/linux/message_pump_glfw.h @@ -2,27 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_ -#define SKY_SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_ +#ifndef SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_ +#define SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_ +#include "lib/ftl/macros.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_pump.h" #include "base/time/time.h" -namespace sky { namespace shell { class MessagePumpGLFW : public base::MessagePump { public: MessagePumpGLFW(); + ~MessagePumpGLFW() override; static scoped_ptr Create(); - // MessagePump methods: void Run(Delegate* delegate) override; + void Quit() override; + void ScheduleWork() override; + void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time) override; private: @@ -34,6 +37,5 @@ class MessagePumpGLFW : public base::MessagePump { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_ +#endif // SHELL_PLATFORM_GLFW_MESSAGE_PUMP_GLFW_H_ diff --git a/shell/platform/linux/platform_view_glfw.cc b/shell/platform/linux/platform_view_glfw.cc new file mode 100644 index 0000000000000000000000000000000000000000..eac3116dc33416fba95d1f24f5dbdf846e6ff192 --- /dev/null +++ b/shell/platform/linux/platform_view_glfw.cc @@ -0,0 +1,182 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/shell/platform/linux/platform_view_glfw.h" +#include "flutter/shell/platform/linux/glfw_service_provider.h" + +#include + +namespace shell { + +inline PlatformViewGLFW* ToPlatformView(GLFWwindow* window) { + return static_cast(glfwGetWindowUserPointer(window)); +} + +PlatformViewGLFW::PlatformViewGLFW() + : valid_(false), glfw_window_(nullptr), buttons_(0), weak_factory_(this) { + if (!glfwInit()) { + return; + } + + glfw_window_ = glfwCreateWindow(640, 480, "Flutter", NULL, NULL); + if (glfw_window_ == nullptr) { + return; + } + + glfwSetWindowUserPointer(glfw_window_, this); + + glfwSetWindowSizeCallback( + glfw_window_, [](GLFWwindow* window, int width, int height) { + ToPlatformView(window)->OnWindowSizeChanged(width, height); + }); + + glfwSetMouseButtonCallback( + glfw_window_, [](GLFWwindow* window, int button, int action, int mods) { + ToPlatformView(window)->OnMouseButtonChanged(button, action, mods); + }); + + glfwSetKeyCallback(glfw_window_, [](GLFWwindow* window, int key, int scancode, + int action, int mods) { + ToPlatformView(window)->OnKeyEvent(key, scancode, action, mods); + }); + + valid_ = true; +} + +PlatformViewGLFW::~PlatformViewGLFW() { + if (glfw_window_ != nullptr) { + glfwSetWindowUserPointer(glfw_window_, nullptr); + glfwDestroyWindow(glfw_window_); + glfw_window_ = nullptr; + } + + glfwTerminate(); +} + +void PlatformViewGLFW::ConnectToEngineAndSetupServices() { + ConnectToEngine(mojo::GetProxy(&engine_)); + + mojo::ServiceProviderPtr platform_service_provider; + new GLFWServiceProvider(mojo::GetProxy(&platform_service_provider)); + + sky::ServicesDataPtr services = sky::ServicesData::New(); + services->incoming_services = platform_service_provider.Pass(); + engine_->SetServices(services.Pass()); +} + +sky::SkyEnginePtr& PlatformViewGLFW::EngineProxy() { + return engine_; +} + +bool PlatformViewGLFW::IsValid() const { + return valid_; +} + +ftl::WeakPtr PlatformViewGLFW::GetWeakViewPtr() { + return weak_factory_.GetWeakPtr(); +} + +uint64_t PlatformViewGLFW::DefaultFramebuffer() const { + // The default window bound FBO. + return 0; +} + +bool PlatformViewGLFW::ContextMakeCurrent() { + glfwMakeContextCurrent(glfw_window_); + return true; +} + +bool PlatformViewGLFW::ResourceContextMakeCurrent() { + // Resource loading contexts are not supported on this platform. + return false; +} + +bool PlatformViewGLFW::SwapBuffers() { + glfwSwapBuffers(glfw_window_); + return true; +} + +void PlatformViewGLFW::RunFromSource(const std::string& main, + const std::string& packages, + const std::string& assets_directory) {} + +void PlatformViewGLFW::OnWindowSizeChanged(int width, int height) { + auto metrics = sky::ViewportMetrics::New(); + metrics->physical_width = width; + metrics->physical_height = height; + metrics->device_pixel_ratio = 1.0; + engine_->OnViewportMetricsChanged(metrics.Pass()); +} + +void PlatformViewGLFW::OnMouseButtonChanged(int button, int action, int mods) { + pointer::PointerType type; + if (action == GLFW_PRESS) { + if (!buttons_) { + type = pointer::PointerType::DOWN; + glfwSetCursorPosCallback( + glfw_window_, [](GLFWwindow* window, double x, double y) { + ToPlatformView(window)->OnCursorPosChanged(x, y); + }); + } else { + type = pointer::PointerType::MOVE; + } + // GLFW's button order matches what we want: + // https://github.com/flutter/engine/blob/master/sky/specs/pointer.md + // http://www.glfw.org/docs/3.2/group__buttons.html + buttons_ |= 1 << button; + } else if (action == GLFW_RELEASE) { + buttons_ &= ~(1 << button); + if (!buttons_) { + type = pointer::PointerType::UP; + glfwSetCursorPosCallback(glfw_window_, nullptr); + } else { + type = pointer::PointerType::MOVE; + } + } else { + DLOG(INFO) << "Unknown mouse action: " << action; + return; + } + + double x = 0.f, y = 0.f; + glfwGetCursorPos(glfw_window_, &x, &y); + + base::TimeDelta time_stamp = base::TimeTicks::Now() - base::TimeTicks(); + + auto pointer_data = pointer::Pointer::New(); + pointer_data->time_stamp = time_stamp.InMicroseconds(); + pointer_data->type = type; + pointer_data->kind = pointer::PointerKind::MOUSE; + pointer_data->x = x; + pointer_data->y = y; + pointer_data->buttons = buttons_; + pointer_data->pressure = 1.0; + pointer_data->pressure_max = 1.0; + + auto pointer_packet = pointer::PointerPacket::New(); + pointer_packet->pointers.push_back(pointer_data.Pass()); + engine_->OnPointerPacket(pointer_packet.Pass()); +} + +void PlatformViewGLFW::OnCursorPosChanged(double x, double y) { + base::TimeDelta time_stamp = base::TimeTicks::Now() - base::TimeTicks(); + + auto pointer_data = pointer::Pointer::New(); + pointer_data->time_stamp = time_stamp.InMicroseconds(); + pointer_data->type = pointer::PointerType::MOVE; + pointer_data->kind = pointer::PointerKind::MOUSE; + pointer_data->x = x; + pointer_data->y = y; + pointer_data->buttons = buttons_; + pointer_data->pressure = 1.0; + pointer_data->pressure_max = 1.0; + + auto pointer_packet = pointer::PointerPacket::New(); + pointer_packet->pointers.push_back(pointer_data.Pass()); + engine_->OnPointerPacket(pointer_packet.Pass()); +} + +void PlatformViewGLFW::OnKeyEvent(int key, int scancode, int action, int mods) { +} + +} // namespace shell diff --git a/shell/platform/linux/platform_view_glfw.h b/shell/platform/linux/platform_view_glfw.h new file mode 100644 index 0000000000000000000000000000000000000000..329dc590cdc4e1680199578b8aa624d7c2bebfc5 --- /dev/null +++ b/shell/platform/linux/platform_view_glfw.h @@ -0,0 +1,63 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_ +#define SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_ + +#include + +#include "flutter/shell/common/platform_view.h" +#include "lib/ftl/memory/weak_ptr.h" + +struct GLFWwindow; + +namespace shell { + +class PlatformViewGLFW : public PlatformView { + public: + PlatformViewGLFW(); + + ~PlatformViewGLFW() override; + + void ConnectToEngineAndSetupServices(); + + sky::SkyEnginePtr& EngineProxy(); + + bool IsValid() const; + + ftl::WeakPtr GetWeakViewPtr() override; + + uint64_t DefaultFramebuffer() const override; + + bool ContextMakeCurrent() override; + + bool ResourceContextMakeCurrent() override; + + bool SwapBuffers() override; + + void RunFromSource(const std::string& main, + const std::string& packages, + const std::string& assets_directory) override; + + private: + bool valid_; + GLFWwindow* glfw_window_; + sky::SkyEnginePtr engine_; + int buttons_; + ftl::WeakPtrFactory weak_factory_; + + void OnWindowSizeChanged(int width, int height); + + void OnMouseButtonChanged(int button, int action, int mods); + + void OnCursorPosChanged(double x, double y); + + void OnKeyEvent(int key, int scancode, int action, int mods); + + FTL_DISALLOW_COPY_AND_ASSIGN(PlatformViewGLFW); +}; + +} // namespace shell + +#endif // SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_ diff --git a/shell/testing/BUILD.gn b/shell/testing/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..67a7f011bf218a7e73449c35fa38462efbe631d5 --- /dev/null +++ b/shell/testing/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright 2016 The Chromium 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("testing") { + sources = [ + "platform_view_test.cc", + "platform_view_test.h", + "test_runner.cc", + "test_runner.h", + "testing.cc", + "testing.h", + ] + + deps = [ + "../common", + "//base", + "//flutter/services/engine:interfaces", + "//flutter/skia", + "//lib/ftl", + "//mojo/public/cpp/bindings", + ] +} diff --git a/sky/shell/testing/observatory/empty_main.dart b/shell/testing/observatory/empty_main.dart similarity index 100% rename from sky/shell/testing/observatory/empty_main.dart rename to shell/testing/observatory/empty_main.dart diff --git a/sky/shell/testing/observatory/launcher.dart b/shell/testing/observatory/launcher.dart similarity index 100% rename from sky/shell/testing/observatory/launcher.dart rename to shell/testing/observatory/launcher.dart diff --git a/sky/shell/testing/observatory/service_client.dart b/shell/testing/observatory/service_client.dart similarity index 100% rename from sky/shell/testing/observatory/service_client.dart rename to shell/testing/observatory/service_client.dart diff --git a/sky/shell/testing/observatory/test.dart b/shell/testing/observatory/test.dart similarity index 100% rename from sky/shell/testing/observatory/test.dart rename to shell/testing/observatory/test.dart diff --git a/sky/shell/testing/platform_view_test.cc b/shell/testing/platform_view_test.cc similarity index 85% rename from sky/shell/testing/platform_view_test.cc rename to shell/testing/platform_view_test.cc index 99b159814f7cf7115818ee8d92fdabf2814f6a29..392cd1db7f3722c39b5d9612dbdb16ed4eed402d 100644 --- a/sky/shell/testing/platform_view_test.cc +++ b/shell/testing/platform_view_test.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/testing/platform_view_test.h" +#include "flutter/shell/testing/platform_view_test.h" -#include "flutter/sky/shell/shell.h" +#include "flutter/shell/common/shell.h" -namespace sky { namespace shell { PlatformViewTest::PlatformViewTest() : weak_factory_(this) {} @@ -35,8 +34,6 @@ bool PlatformViewTest::SwapBuffers() { void PlatformViewTest::RunFromSource(const std::string& main, const std::string& packages, - const std::string& assets_directory) { -} + const std::string& assets_directory) {} } // namespace shell -} // namespace sky diff --git a/sky/shell/testing/platform_view_test.h b/shell/testing/platform_view_test.h similarity index 74% rename from sky/shell/testing/platform_view_test.h rename to shell/testing/platform_view_test.h index a11515529e4183766f72e1d34f4e6d2a6c0c4f91..357e4f2db8e7c7665e2cbfef454af0d2ecc9be08 100644 --- a/sky/shell/testing/platform_view_test.h +++ b/shell/testing/platform_view_test.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 SKY_SHELL_TESTING_PLATFORM_VIEW_TEST_H_ -#define SKY_SHELL_TESTING_PLATFORM_VIEW_TEST_H_ +#ifndef SHELL_TESTING_PLATFORM_VIEW_TEST_H_ +#define SHELL_TESTING_PLATFORM_VIEW_TEST_H_ +#include "flutter/shell/common/platform_view.h" #include "lib/ftl/macros.h" #include "lib/ftl/memory/weak_ptr.h" -#include "flutter/sky/shell/platform_view.h" -namespace sky { namespace shell { class Shell; @@ -20,7 +19,7 @@ class PlatformViewTest : public PlatformView { ~PlatformViewTest(); - ftl::WeakPtr GetWeakViewPtr() override; + ftl::WeakPtr GetWeakViewPtr() override; uint64_t DefaultFramebuffer() const override; @@ -41,6 +40,5 @@ class PlatformViewTest : public PlatformView { }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_TESTING_PLATFORM_VIEW_TEST_H_ +#endif // SHELL_TESTING_PLATFORM_VIEW_TEST_H_ diff --git a/sky/shell/testing/test_runner.cc b/shell/testing/test_runner.cc similarity index 75% rename from sky/shell/testing/test_runner.cc rename to shell/testing/test_runner.cc index bb0c2957f86543bc14d0ebb14d709d651618798c..7428041f354b571a3ba5c38b93ca78570f73a2a9 100644 --- a/sky/shell/testing/test_runner.cc +++ b/shell/testing/test_runner.cc @@ -2,25 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/testing/test_runner.h" +#include "flutter/shell/testing/test_runner.h" #include -#include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/strings/string_util.h" -#include "flutter/sky/shell/platform_view.h" -#include "flutter/sky/shell/shell.h" -#include "flutter/sky/shell/testing/platform_view_test.h" +#include "flutter/shell/common/platform_view.h" +#include "flutter/shell/common/shell.h" +#include "flutter/shell/testing/platform_view_test.h" -namespace sky { namespace shell { TestRunner::TestRunner() : platform_view_(new PlatformViewTest()), weak_ptr_factory_(this) { platform_view_->ConnectToEngine(GetProxy(&sky_engine_)); - ViewportMetricsPtr metrics = ViewportMetrics::New(); + sky::ViewportMetricsPtr metrics = sky::ViewportMetrics::New(); metrics->physical_width = 800; metrics->physical_height = 600; @@ -42,4 +40,3 @@ void TestRunner::Run(const TestDescriptor& test) { } } // namespace shell -} // namespace sky diff --git a/sky/shell/testing/test_runner.h b/shell/testing/test_runner.h similarity index 81% rename from sky/shell/testing/test_runner.h rename to shell/testing/test_runner.h index 3838708563e64919cd5ac9abef77f0c81153cf5c..0078a2e742419aa6e70c7bf363e4ac89bb9227b6 100644 --- a/sky/shell/testing/test_runner.h +++ b/shell/testing/test_runner.h @@ -2,18 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_TESTING_TEST_RUNNER_H_ -#define SKY_SHELL_TESTING_TEST_RUNNER_H_ +#ifndef SHELL_TESTING_TEST_RUNNER_H_ +#define SHELL_TESTING_TEST_RUNNER_H_ #include #include +#include "flutter/services/engine/sky_engine.mojom.h" #include "lib/ftl/macros.h" #include "lib/ftl/memory/weak_ptr.h" #include "mojo/public/cpp/bindings/binding_set.h" -#include "flutter/services/engine/sky_engine.mojom.h" -namespace sky { namespace shell { class PlatformView; @@ -34,13 +33,12 @@ class TestRunner { ~TestRunner(); std::unique_ptr platform_view_; - SkyEnginePtr sky_engine_; + sky::SkyEnginePtr sky_engine_; ftl::WeakPtrFactory weak_ptr_factory_; FTL_DISALLOW_COPY_AND_ASSIGN(TestRunner); }; } // namespace shell -} // namespace sky -#endif // SKY_SHELL_TESTING_TEST_RUNNER_H_ +#endif // SHELL_TESTING_TEST_RUNNER_H_ diff --git a/sky/shell/testing/testing.cc b/shell/testing/testing.cc similarity index 77% rename from sky/shell/testing/testing.cc rename to shell/testing/testing.cc index 8d4f78e5b4afe87adfb471f69271d90fa9c1b34a..e31c9224cd8172e463cfe29e2a534aa954adec06 100644 --- a/sky/shell/testing/testing.cc +++ b/shell/testing/testing.cc @@ -2,13 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/sky/shell/testing/testing.h" +#include "flutter/shell/testing/testing.h" #include "base/command_line.h" -#include "flutter/sky/shell/switches.h" -#include "flutter/sky/shell/testing/test_runner.h" +#include "flutter/shell/common/switches.h" +#include "flutter/shell/testing/test_runner.h" -namespace sky { namespace shell { bool InitForTesting() { @@ -26,4 +25,3 @@ bool InitForTesting() { } } // namespace shell -} // namespace sky diff --git a/sky/shell/testing/testing.h b/shell/testing/testing.h similarity index 60% rename from sky/shell/testing/testing.h rename to shell/testing/testing.h index 0af6efd6022701353cb03165b07bfade20da7138..e85e0b9c73f7a03f8719daa3ad0a6e25c2558b5e 100644 --- a/sky/shell/testing/testing.h +++ b/shell/testing/testing.h @@ -2,15 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKY_SHELL_TESTING_TESTING_H_ -#define SKY_SHELL_TESTING_TESTING_H_ +#ifndef SHELL_TESTING_TESTING_H_ +#define SHELL_TESTING_TESTING_H_ -namespace sky { namespace shell { bool InitForTesting(); } // namespace shell -} // namespace sky -#endif // SKY_SHELL_TESTING_TESTING_H_ +#endif // SHELL_TESTING_TESTING_H_ diff --git a/sky/BUILD.gn b/sky/BUILD.gn index 273025a05b4f0f743e56e02ba2472a2d70e52a62..a02ba1d835812159f6fe10cac5c92abda4577ec6 100644 --- a/sky/BUILD.gn +++ b/sky/BUILD.gn @@ -10,7 +10,7 @@ group("sky") { deps = [ "//flutter/sky/engine/wtf:unittests($host_toolchain)", "//flutter/sky/packages", - "//flutter/sky/shell", + "//flutter/shell", ] if (dart_host_toolchain == host_toolchain) { diff --git a/sky/shell/BUILD.gn b/sky/shell/BUILD.gn deleted file mode 100644 index 2d36bf477ad37f41e438886e5472bc4537a41dc4..0000000000000000000000000000000000000000 --- a/sky/shell/BUILD.gn +++ /dev/null @@ -1,483 +0,0 @@ -# Copyright 2015 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//mojo/dart/embedder/embedder.gni") - -dart_embedder_resources("generate_sky_embedder_diagnostic_server_resources_cc") { - inputs = [ - "//flutter/sky/shell/diagnostic/diagnostic_server.dart" - ] - root_prefix = "//flutter/sky/shell/diagnostic/" - output = "$target_gen_dir/sky_embedder_diagnostic_server_resources.cc" - table_name = "sky_embedder_diagnostic_server" -} - -source_set("common") { - sources = [ - "$target_gen_dir/sky_embedder_diagnostic_server_resources.cc", - "diagnostic/diagnostic_server.cc", - "diagnostic/diagnostic_server.h", - "gpu/picture_serializer.cc", - "gpu/picture_serializer.h", - "platform_view.cc", - "platform_view.h", - "platform_view_service_protocol.cc", - "platform_view_service_protocol.h", - "rasterizer.cc", - "rasterizer.h", - "shell.cc", - "shell.h", - "switches.cc", - "switches.h", - "systrace_logger.cc", - "systrace_logger.h", - "tracing_controller.cc", - "tracing_controller.h", - "ui/animator.cc", - "ui/animator.h", - "ui/engine.cc", - "ui/engine.h", - "ui_delegate.cc", - "ui_delegate.h", - ] - - public_deps = [ - "//base", - "//base:i18n", - "//build/config/sanitizers:deps", - "//dart/runtime:libdart", - "//flutter/assets", - "//flutter/common", - "//flutter/flow", - "//flutter/glue", - "//flutter/lib/ui", - "//flutter/runtime", - "//flutter/services/editing:interfaces", - "//flutter/services/engine:interfaces", - "//flutter/services/platform", - "//flutter/services/pointer:interfaces", - "//flutter/services/semantics:interfaces", - "//flutter/services/vsync:vsync_lib_fallback", - "//flutter/skia", - "//flutter/sky/engine", - "//flutter/sky/engine/core:core", - "//flutter/sky/engine/wtf", - "//flutter/synchronization", - "//lib/ftl", - "//lib/tonic", - "//mojo/application", - "//mojo/common", - "//mojo/data_pipe_utils", - "//mojo/message_pump", - "//mojo/public/cpp/application", - "//mojo/public/cpp/bindings:utility", - "//mojo/public/interfaces/application", - "//mojo/services/asset_bundle/interfaces", - "//mojo/services/gfx/composition/interfaces", - "//mojo/services/vsync/interfaces", - ":generate_sky_embedder_diagnostic_server_resources_cc", - ] -} - -source_set("gpu_direct") { - sources = [ - "gpu/direct/ganesh_canvas.cc", - "gpu/direct/ganesh_canvas.h", - "gpu/direct/rasterizer_direct.cc", - "gpu/direct/rasterizer_direct.h", - ] - - deps = [ - ":common", - ] -} - -if (is_linux || is_mac) { - - source_set("testing") { - sources = [ - "testing/platform_view_test.cc", - "testing/platform_view_test.h", - "testing/test_runner.cc", - "testing/test_runner.h", - "testing/testing.cc", - "testing/testing.h", - ] - - deps = [ - ":common", - ] - } - -} - -if (is_android) { - import("//build/config/android/config.gni") - import("//build/config/android/rules.gni") - - generate_jni("jni_headers") { - sources = [ - "platform/android/io/flutter/view/FlutterView.java", - "platform/android/io/flutter/view/FlutterMain.java", - ] - jni_package = "sky/shell" - } - - shared_library("sky_shell") { - sources = [ - "platform/android/flutter_main.cc", - "platform/android/flutter_main.h", - "platform/android/library_loader.cc", - "platform/android/platform_view_android.cc", - "platform/android/platform_view_android.h", - ] - - deps = [ - "//flutter/lib/jni", - "//flutter/vulkan", - "//mojo/android:libsystem_java", - "//mojo/edk/base_edk", - "//mojo/edk/system", - ":common", - ":gpu_direct", - ":jni_headers", - ] - - ldflags = [ - "-landroid", - "-lEGL", - "-lGLESv2", - ] - } - - android_library("java") { - java_files = [ - "platform/android/io/flutter/view/AccessibilityBridge.java", - "platform/android/io/flutter/view/FlutterMain.java", - "platform/android/io/flutter/view/FlutterView.java", - "platform/android/io/flutter/view/ResourceCleaner.java", - "platform/android/io/flutter/view/ResourceExtractor.java", - "platform/android/io/flutter/view/ServiceFactory.java", - "platform/android/io/flutter/view/ServiceProviderImpl.java", - "platform/android/io/flutter/view/ServiceRegistry.java", - "platform/android/org/domokit/sky/shell/SkyActivity.java", - "platform/android/org/domokit/sky/shell/SkyApplication.java", - ] - - deps = [ - "//base:base_java", - "//mojo/android:system_java", - "//mojo/public/interfaces/application:application_java", - "//mojo/public/java:bindings", - "//mojo/public/java:system", - "//mojo/services/sensors/interfaces:interfaces_java", - "//mojo/services/vsync/interfaces:interfaces_java", - "//flutter/services/sensors:sensors_lib", - "//flutter/services/activity:activity_lib", - "//flutter/services/activity:interfaces_java", - "//flutter/services/common:common_lib", - "//flutter/services/editing:editing_lib", - "//flutter/services/editing:interfaces_java", - "//flutter/services/engine:interfaces_java", - "//flutter/services/media:interfaces_java", - "//flutter/services/media:media_lib", - "//flutter/services/platform:interfaces_java", - "//flutter/services/platform:platform_lib", - "//flutter/services/pointer:interfaces_java", - "//flutter/services/raw_keyboard:interfaces_java", - "//flutter/services/raw_keyboard:raw_keyboard_lib", - "//flutter/services/semantics:interfaces_java", - "//flutter/services/vsync:vsync_lib", - ] - } - - copy_ex("assets") { - clear_dir = true - dest = "$root_build_dir/sky_shell/assets" - sources = [ - "$root_build_dir/icudtl.dat", - ] - deps = [ - "//third_party/icu:icudata", - ] - } - - android_apk("shell") { - apk_name = "SkyShell" - android_manifest = "platform/android/AndroidManifest.xml" - - native_libs = [ "libsky_shell.so" ] - asset_location = "$root_build_dir/sky_shell/assets" - - extensions_to_not_compress = ".flx" - - flutter_dist_jar = "$root_build_dir/flutter.jar" - - deps = [ - "//base:base_java", - ":assets", - ":java", - ":sky_shell", - ] - } -} else if (is_ios) { - import("//build/config/ios/rules.gni") - import("//build/config/ios/ios_sdk.gni") - - shared_library("flutter_framework_dylib") { - output_name = "Flutter" - - sources = [ - "platform/ios/framework/Headers/Flutter.h", - "platform/ios/framework/Headers/FlutterAppDelegate.h", - "platform/ios/framework/Headers/FlutterAsyncMessageListener.h", - "platform/ios/framework/Headers/FlutterDartProject.h", - "platform/ios/framework/Headers/FlutterMacros.h", - "platform/ios/framework/Headers/FlutterMessageListener.h", - "platform/ios/framework/Headers/FlutterViewController.h", - "platform/ios/framework/Source/accessibility_bridge.h", - "platform/ios/framework/Source/accessibility_bridge.mm", - "platform/ios/framework/Source/application_messages_impl.h", - "platform/ios/framework/Source/application_messages_impl.mm", - "platform/ios/framework/Source/flutter_touch_mapper.h", - "platform/ios/framework/Source/flutter_touch_mapper.mm", - "platform/ios/framework/Source/FlutterAppDelegate.mm", - "platform/ios/framework/Source/FlutterDartProject.mm", - "platform/ios/framework/Source/FlutterDartProject_Internal.h", - "platform/ios/framework/Source/FlutterDartSource.h", - "platform/ios/framework/Source/FlutterDartSource.mm", - "platform/ios/framework/Source/FlutterDynamicServiceLoader.h", - "platform/ios/framework/Source/FlutterDynamicServiceLoader.mm", - "platform/ios/framework/Source/FlutterView.h", - "platform/ios/framework/Source/FlutterView.mm", - "platform/ios/framework/Source/FlutterViewController.mm", - "platform/ios/platform_view_ios.h", - "platform/ios/platform_view_ios.mm", - ] - - set_sources_assignment_filter([]) - sources += [ - "platform/mac/platform_mac.h", - "platform/mac/platform_mac.mm", - "platform/mac/platform_service_provider.cc", - "platform/mac/platform_service_provider.h", - "platform/mac/view_service_provider.cc", - "platform/mac/view_service_provider.h", - ] - set_sources_assignment_filter(sources_assignment_filter) - - deps = [ - "//mojo/edk/base_edk", - "//mojo/edk/system", - "//flutter/skia", - "//flutter/services/activity", - "//flutter/services/dynamic:embedder", - "//flutter/services/editing", - "//flutter/services/media", - "//flutter/services/semantics", - "//flutter/services/vsync", - ":common", - ":gpu_direct", - ] - - defines = [ - "FLUTTER_FRAMEWORK" - ] - - libs = [ - "UIKit.framework", - "OpenGLES.framework", - "AVFoundation.framework", - "AudioToolbox.framework", - "QuartzCore.framework", - ] - } - - group("flutter_framework") { - framework_dir = "$root_out_dir/Flutter.framework" - - copy("framework_dylib") { - sources = [ "$root_out_dir/libFlutter.dylib" ] - outputs = [ "$framework_dir/Flutter" ] - - deps = [ - ":flutter_framework_dylib", - ] - } - - action("framework_install_name") { - stamp_file = "$root_out_dir/flutter_install_name_stamp" - script = "//flutter/sky/tools/change_install_name.py" - - inputs = [ "$framework_dir/Flutter" ] - outputs = [ stamp_file ] - - args = [ - "--dylib", - rebase_path("$framework_dir/Flutter"), - "--install_name", - "@rpath/Flutter.framework/Flutter", - "--stamp", - rebase_path(stamp_file), - ] - - deps = [ - ":framework_dylib" - ] - } - - copy("framework_info_plist") { - sources = [ "platform/ios/framework/Info.plist" ] - outputs = [ "$framework_dir/Info.plist" ] - } - - copy("framework_module_map") { - sources = [ "platform/ios/framework/module.modulemap" ] - outputs = [ "$framework_dir/Modules/module.modulemap" ] - } - - copy("framework_headers") { - sources = [ - "platform/ios/framework/Headers/Flutter.h", - "platform/ios/framework/Headers/FlutterAppDelegate.h", - "platform/ios/framework/Headers/FlutterAsyncMessageListener.h", - "platform/ios/framework/Headers/FlutterDartProject.h", - "platform/ios/framework/Headers/FlutterMacros.h", - "platform/ios/framework/Headers/FlutterMessageListener.h", - "platform/ios/framework/Headers/FlutterViewController.h", - ] - outputs = [ "$framework_dir/Headers/{{source_file_part}}" ] - } - - copy("framework_icu") { - set_sources_assignment_filter([]) - sources = [ - "//third_party/icu/android/icudtl.dat", - ] - set_sources_assignment_filter(sources_assignment_filter) - outputs = [ "$framework_dir/{{source_file_part}}" ] - } - - public_deps = [ - ":framework_dylib", - ":framework_headers", - ":framework_icu", - ":framework_info_plist", - ":framework_install_name", - ":framework_module_map", - ] - } - - group("shell") { - } -} else if (is_linux) { - executable("shell") { - output_name = "sky_shell" - - sources = [ - "platform/linux/main_linux.cc", - ] - - deps = [ - "//mojo/common", - "//mojo/edk/base_edk", - "//mojo/edk/system", - ":common", - ":gpu_direct", - ":testing", - ] - - ldflags = [ - "-lGL", - ] - - if (use_glfw) { - sources += [ - "//flutter/sky/shell/platform/glfw/init_glfw.cc", - "//flutter/sky/shell/platform/glfw/init_glfw.h", - "//flutter/sky/shell/platform/glfw/message_pump_glfw.cc", - "//flutter/sky/shell/platform/glfw/message_pump_glfw.h", - "//flutter/sky/shell/platform/glfw/platform_view_glfw.cc", - "//flutter/sky/shell/platform/glfw/platform_view_glfw.h", - "//flutter/sky/shell/platform/glfw/window_impl.cc", - "//flutter/sky/shell/platform/glfw/window_impl.h", - ] - - deps += [ - "//flutter/services/raw_keyboard:interfaces", - "//third_party/glfw", - "//ui/gl", - ] - } else { - sources += [ "platform/linux/platform_view_linux.cc" ] - } - } -} else if (is_mac) { - import("//build/config/mac/rules.gni") - - source_set("mac_scaffolding") { - sources = [ - "platform/mac/main_mac.mm", - "platform/mac/platform_mac.h", - "platform/mac/platform_mac.mm", - "platform/mac/platform_service_provider.cc", - "platform/mac/platform_service_provider.h", - "platform/mac/platform_view_mac.h", - "platform/mac/platform_view_mac.mm", - "platform/mac/sky_app_delegate.h", - "platform/mac/sky_app_delegate.m", - "platform/mac/sky_application.h", - "platform/mac/sky_application.mm", - "platform/mac/sky_window.h", - "platform/mac/sky_window.mm", - "platform/mac/view_service_provider.cc", - "platform/mac/view_service_provider.h", - ] - - deps = [ - "//mojo/common", - "//mojo/edk/base_edk", - "//mojo/edk/system", - "//flutter/services/vsync", - ":common", - ":gpu_direct", - ":testing", - ] - } - - executable("shell_standalone") { - output_name = "sky_shell" - deps = [ - ":mac_scaffolding", - ] - } - - mac_app("shell_application") { - app_name = "SkyShell" - info_plist = "platform/mac/Info.plist" - - xibs = [ "platform/mac/sky_mac.xib" ] - - resource_copy_mac("sky_resources") { - resources = [ - "//third_party/icu/android/icudtl.dat", - ] - bundle_directory = "." - } - - deps = [ - ":mac_scaffolding", - ":sky_resources", - ] - } - - group("shell") { - deps = [ - ":shell_application", - ":shell_standalone", - ] - } -} else { - assert(false, "Unsupported platform") -} diff --git a/sky/shell/platform/glfw/init_glfw.cc b/sky/shell/platform/glfw/init_glfw.cc deleted file mode 100644 index 539fc54b3892402745e230361b499201edfd727c..0000000000000000000000000000000000000000 --- a/sky/shell/platform/glfw/init_glfw.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/sky/shell/platform/glfw/init_glfw.h" - -#include -#include -#include - -#include "base/command_line.h" -#include "flutter/sky/shell/platform/glfw/platform_view_glfw.h" -#include "flutter/sky/shell/platform/glfw/window_impl.h" -#include "flutter/sky/shell/switches.h" -#include "ui/gl/gl_surface.h" - -namespace sky { -namespace shell { - -static bool IsDartFile(const std::string& script_uri) { - std::string dart_extension = ".dart"; - return script_uri.rfind(dart_extension) == - (script_uri.size() - dart_extension.size()); -} - -bool InitInteractive() { - base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - - auto args = command_line.GetArgs(); - if (args.empty()) - return false; - - std::string bundle_path = - command_line.GetSwitchValueASCII(sky::shell::switches::kFLX); - - if (bundle_path.empty()) { - // Alternatively, use the first positional argument. - bundle_path = args[0]; - } - - if (bundle_path.empty()) - return false; - - if (!glfwInit()) - return false; - - GLFWwindow* window = glfwCreateWindow(640, 480, "Flutter", NULL, NULL); - if (!window) { - glfwTerminate(); - return false; - } - - glfwMakeContextCurrent(window); - CHECK(gfx::GLSurface::InitializeOneOff()); - glfwMakeContextCurrent(NULL); - - if (IsDartFile(bundle_path)) { - // Load directly from source. - // TODO(abarth): Listen for a GLFW callback to delete this window. - (new WindowImpl(window))->RunFromFile(bundle_path); - } else { - std::string script_uri = std::string("file://") + bundle_path; - // Load from a bundle. - // TODO(abarth): Listen for a GLFW callback to delete this window. - (new WindowImpl(window))->RunFromBundle(script_uri, bundle_path); - } - return true; -} - - -} // namespace shell -} // namespace sky diff --git a/sky/shell/platform/glfw/platform_view_glfw.cc b/sky/shell/platform/glfw/platform_view_glfw.cc deleted file mode 100644 index 4f5963af3537d933e3bbf63a2783b7f2ad9da2cd..0000000000000000000000000000000000000000 --- a/sky/shell/platform/glfw/platform_view_glfw.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/sky/shell/platform/glfw/platform_view_glfw.h" - -#include "flutter/sky/shell/gpu/direct/surface_notifications_direct.h" - -namespace sky { -namespace shell { - -PlatformViewGLFW::PlatformViewGLFW(const Config& config) - : window_(gfx::kNullAcceleratedWidget) {} - -PlatformViewGLFW::~PlatformViewGLFW() {} - -void PlatformViewGLFW::SurfaceCreated(gfx::AcceleratedWidget widget) { - DCHECK(window_ == gfx::kNullAcceleratedWidget); - window_ = widget; - SurfaceNotificationsDirect::NotifyCreated(config_, window_, nullptr); -} - -void PlatformViewGLFW::SurfaceDestroyed() { - DCHECK(window_ != gfx::kNullAcceleratedWidget); - window_ = gfx::kNullAcceleratedWidget; - SurfaceNotificationsDirect::NotifyDestroyed(config_); -} - -} // namespace shell -} // namespace sky diff --git a/sky/shell/platform/glfw/platform_view_glfw.h b/sky/shell/platform/glfw/platform_view_glfw.h deleted file mode 100644 index 32d98fce4c9d8c9a747f9136dabaa292a5fd04d7..0000000000000000000000000000000000000000 --- a/sky/shell/platform/glfw/platform_view_glfw.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef SKY_SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_ -#define SKY_SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_ - -#include "flutter/sky/shell/platform_view.h" - -namespace sky { -namespace shell { - -class PlatformViewGLFW : public PlatformView { - public: - explicit PlatformViewGLFW(const Config& config); - ~PlatformViewGLFW() override; - - void SurfaceCreated(gfx::AcceleratedWidget widget); - void SurfaceDestroyed(void); - - private: - gfx::AcceleratedWidget window_; - - FTL_DISALLOW_COPY_AND_ASSIGN(PlatformViewGLFW); -}; - -} // namespace shell -} // namespace sky - -#endif // SKY_SHELL_PLATFORM_GLFW_PLATFORM_VIEW_GLFW_H_ diff --git a/sky/shell/platform/glfw/window_impl.cc b/sky/shell/platform/glfw/window_impl.cc deleted file mode 100644 index 46e10a33162454cdb1a8658a49a5de53eb99f4aa..0000000000000000000000000000000000000000 --- a/sky/shell/platform/glfw/window_impl.cc +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/sky/shell/platform/glfw/window_impl.h" - -#include - -#include "flutter/sky/shell/platform/glfw/platform_view_glfw.h" -#include "flutter/sky/shell/shell.h" - -namespace sky { -namespace shell { -namespace { - -WindowImpl* ToImpl(GLFWwindow* window) { - return static_cast(glfwGetWindowUserPointer(window)); -} - -void OnWindowSizeChanged(GLFWwindow* window, int width, int height) { - ToImpl(window)->UpdateViewportMetrics(width, height); -} - -void OnMouseButtonChanged(GLFWwindow* window, int button, int action, int mods) { - ToImpl(window)->DispatchMouseButtonEvent(button, action, mods); -} - -void OnCursorPosChanged(GLFWwindow* window, double x, double y) { - ToImpl(window)->DispatchMouseMoveEvent(x, y); -} - -void OnKeyEvent(GLFWwindow* window, int key, int scancode, int action, - int mods) { - sky::InputEventPtr result = sky::InputEvent::New(); - result->time_stamp = base::TimeTicks::Now().ToInternalValue(); - switch (action) { - case GLFW_PRESS: - case GLFW_REPEAT: - result->type = sky::EventType::KEY_PRESSED; - break; - case GLFW_RELEASE: - result->type = sky::EventType::KEY_RELEASED; - break; - default: - LOG(WARNING) << "Unknown key action: " << action; - return; - } - result->key_data = sky::KeyData::New(); - result->key_data->key_code = key; - result->key_data->scan_code = scancode; - - if (mods & GLFW_MOD_SHIFT) - result->key_data->meta_state |= 0x00000001; - if (mods & GLFW_MOD_CONTROL) - result->key_data->meta_state |= 0x00001000; - if (mods & GLFW_MOD_ALT) - result->key_data->meta_state |= 0x00000002; - - ToImpl(window)->DispatchKeyEvent(result.Pass()); -} - -} // namespace - -WindowImpl::WindowImpl(GLFWwindow* window) - : window_(window), - shell_view_(new ShellView(Shell::Shared())), - buttons_(0), - view_services_binding_(this) { - glfwSetWindowUserPointer(window_, this); - auto platform_view = - static_cast(shell_view_->view()); - platform_view->SurfaceCreated(window); - platform_view->ConnectToEngine(mojo::GetProxy(&engine_)); - - int width = 0; - int height = 0; - glfwGetWindowSize(window_, &width, &height); - UpdateViewportMetrics(width, height); - - glfwSetWindowSizeCallback(window_, OnWindowSizeChanged); - glfwSetMouseButtonCallback(window_, OnMouseButtonChanged); - glfwSetKeyCallback(window_, OnKeyEvent); -} - -WindowImpl::~WindowImpl() { - shell_view_.reset(); - glfwDestroyWindow(window_); - window_ = nullptr; -} - -void WindowImpl::RunFromBundle(const std::string& script_uri, - const std::string& bundle_path) { - mojo::ServiceProviderPtr view_services; - view_services_binding_.Bind(mojo::GetProxy(&view_services)); - - ServicesDataPtr services = ServicesData::New(); - services->view_services = view_services.Pass(); - engine_->SetServices(services.Pass()); - engine_->RunFromBundle(script_uri, bundle_path); -} - -void WindowImpl::RunFromFile(const std::string& file) { - // TODO(johnmccutchan): Wire up support for asset bundles when running - // from source. - engine_->RunFromFile(file, "", ""); -} - -void WindowImpl::UpdateViewportMetrics(int width, int height) { - auto metrics = sky::ViewportMetrics::New(); - metrics->physical_width = width; - metrics->physical_height = height; - // TODO(abarth): There doesn't appear to be a way to get the device pixel - // ratio from GLFW. - metrics->device_pixel_ratio = 1.0; - engine_->OnViewportMetricsChanged(metrics.Pass()); -} - -void WindowImpl::DispatchMouseButtonEvent(int button, int action, int mods) { - pointer::PointerType type; - if (action == GLFW_PRESS) { - if (!buttons_) { - type = pointer::PointerType::DOWN; - glfwSetCursorPosCallback(window_, OnCursorPosChanged); - } else { - type = pointer::PointerType::MOVE; - } - // GLFW's button order matches what we want: - // https://github.com/flutter/engine/blob/master/sky/specs/pointer.md - // http://www.glfw.org/docs/3.2/group__buttons.html - buttons_ |= 1 << button; - } else if (action == GLFW_RELEASE) { - buttons_ &= ~(1 << button); - if (!buttons_) { - type = pointer::PointerType::UP; - glfwSetCursorPosCallback(window_, nullptr); - } else { - type = pointer::PointerType::MOVE; - } - } else { - DLOG(INFO) << "Unknown mouse action: " << action; - return; - } - - double x = 0.f, y = 0.f; - glfwGetCursorPos(window_, &x, &y); - - base::TimeDelta time_stamp = base::TimeTicks::Now() - base::TimeTicks(); - - auto pointer_data = pointer::Pointer::New(); - pointer_data->time_stamp = time_stamp.InMicroseconds(); - pointer_data->type = type; - pointer_data->kind = pointer::PointerKind::MOUSE; - pointer_data->x = x; - pointer_data->y = y; - pointer_data->buttons = buttons_; - pointer_data->pressure = 1.0; - pointer_data->pressure_max = 1.0; - - auto pointer_packet = pointer::PointerPacket::New(); - pointer_packet->pointers.push_back(pointer_data.Pass()); - engine_->OnPointerPacket(pointer_packet.Pass()); -} - -void WindowImpl::DispatchMouseMoveEvent(double x, double y) { - base::TimeDelta time_stamp = base::TimeTicks::Now() - base::TimeTicks(); - - auto pointer_data = pointer::Pointer::New(); - pointer_data->time_stamp = time_stamp.InMicroseconds(); - pointer_data->type = pointer::PointerType::MOVE; - pointer_data->kind = pointer::PointerKind::MOUSE; - pointer_data->x = x; - pointer_data->y = y; - pointer_data->buttons = buttons_; - pointer_data->pressure = 1.0; - pointer_data->pressure_max = 1.0; - - auto pointer_packet = pointer::PointerPacket::New(); - pointer_packet->pointers.push_back(pointer_data.Pass()); - engine_->OnPointerPacket(pointer_packet.Pass()); -} - -void WindowImpl::DispatchKeyEvent(sky::InputEventPtr sky_event) { - for (auto& listener : raw_keyboard_listeners_) { - listener->OnKey(sky_event.Clone()); - } -} - -void WindowImpl::ConnectToService(const mojo::String& service_name, - mojo::ScopedMessagePipeHandle handle) { - if (service_name == raw_keyboard::RawKeyboardService::Name_) { - raw_keyboard_bindings_.AddBinding( - this, - mojo::InterfaceRequest(handle.Pass())); - } -} - -void WindowImpl::AddListener( - mojo::InterfaceHandle listener) { - raw_keyboard_listeners_.push_back( - raw_keyboard::RawKeyboardListenerPtr::Create(listener.Pass())); -} - -} // namespace shell -} // namespace sky diff --git a/sky/shell/platform/glfw/window_impl.h b/sky/shell/platform/glfw/window_impl.h deleted file mode 100644 index 5218dc0bb6d2a87f219fca4be8ee0d196d2b890d..0000000000000000000000000000000000000000 --- a/sky/shell/platform/glfw/window_impl.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef SKY_SHELL_PLATFORM_GLFW_WINDOW_IMPL_H_ -#define SKY_SHELL_PLATFORM_GLFW_WINDOW_IMPL_H_ - -#include -#include - -#include "mojo/common/binding_set.h" -#include "flutter/services/engine/sky_engine.mojom.h" -#include "flutter/services/raw_keyboard/raw_keyboard.mojom.h" -#include "flutter/sky/shell/platform_view.h" -#include "flutter/sky/shell/shell_view.h" - -namespace sky { -namespace shell { - -class WindowImpl : public mojo::ServiceProvider, - public raw_keyboard::RawKeyboardService { - public: - explicit WindowImpl(GLFWwindow* window); - ~WindowImpl() override; - - void RunFromBundle(const std::string& script_uri, - const std::string& bundle_path); - - void RunFromFile(const std::string& file); - - void UpdateViewportMetrics(int width, int height); - void DispatchMouseButtonEvent(int button, int action, int mods); - void DispatchMouseMoveEvent(double x, double y); - void DispatchKeyEvent(sky::InputEventPtr event); - - // mojo::ServiceProvider - void ConnectToService(const mojo::String& service_name, - mojo::ScopedMessagePipeHandle client_handle) override; - - // raw_keyboard::RawKeyboardService - void AddListener( - mojo::InterfaceHandle listener) - override; - - private: - GLFWwindow* window_; - std::unique_ptr shell_view_; - sky::SkyEnginePtr engine_; - int buttons_; - - mojo::Binding view_services_binding_; - mojo::BindingSet raw_keyboard_bindings_; - std::vector raw_keyboard_listeners_; - - FTL_DISALLOW_COPY_AND_ASSIGN(WindowImpl); -}; - -} // namespace shell -} // namespace sky - -#endif // SKY_SHELL_PLATFORM_GLFW_WINDOW_IMPL_H_ diff --git a/sky/shell/platform/linux/main_linux.cc b/sky/shell/platform/linux/main_linux.cc deleted file mode 100644 index 7f38b53be9d05c720b983aa7513778395a849b86..0000000000000000000000000000000000000000 --- a/sky/shell/platform/linux/main_linux.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/at_exit.h" -#include "base/basictypes.h" -#include "base/bind.h" -#include "base/command_line.h" -#include "base/logging.h" -#include "base/message_loop/message_loop.h" -#include "mojo/edk/embedder/embedder.h" -#include "mojo/edk/embedder/simple_platform_support.h" -#include "flutter/sky/shell/shell.h" -#include "flutter/sky/shell/switches.h" -#include "flutter/sky/shell/testing/testing.h" - -#if defined(USE_GLFW) -#include "flutter/sky/shell/platform/glfw/init_glfw.h" -#include "flutter/sky/shell/platform/glfw/message_pump_glfw.h" -#endif - -namespace { - -int RunNonInteractive() { - base::MessageLoop message_loop; - mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport()); - sky::shell::Shell::InitStandalone(); - - if (!sky::shell::InitForTesting()) { - sky::shell::switches::PrintUsage("sky_shell"); - return 1; - } - - message_loop.Run(); - return 0; -} - -#if defined(USE_GLFW) - -int RunInteractive() { - base::MessageLoop message_loop(sky::shell::MessagePumpGLFW::Create()); - mojo::embedder::Init(mojo::embedder::CreateSimplePlatformSupport()); - sky::shell::Shell::InitStandalone(); - - if (!sky::shell::InitInteractive()) - return 1; - - message_loop.Run(); - return 0; -} - -#endif // defined(USE_GLFW) - -} // namespace - -int main(int argc, const char* argv[]) { - base::AtExitManager exit_manager; - base::CommandLine::Init(argc, argv); - - base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); - - if (command_line.HasSwitch(sky::shell::switches::kHelp)) { - sky::shell::switches::PrintUsage("sky_shell"); - return 0; - } - -#if defined(USE_GLFW) - if (command_line.HasSwitch(sky::shell::switches::kNonInteractive)) - return RunNonInteractive(); - return RunInteractive(); -#endif - - return RunNonInteractive(); -} diff --git a/sky/shell/platform/linux/platform_view_linux.cc b/sky/shell/platform/linux/platform_view_linux.cc deleted file mode 100644 index 0955ac91264980d9b95cfeda1fc40c34a81447fb..0000000000000000000000000000000000000000 --- a/sky/shell/platform/linux/platform_view_linux.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/sky/shell/platform/linux/platform_view_linux.h" - -namespace sky { -namespace shell { - -PlatformViewLinux::PlatformViewLinux(const Config& config, - SurfaceConfig surface_config) - : weak_factory_(this) {} - -PlatformViewLinux::~PlatformViewLinux() {} - -ftl::WeakPtr PlatformViewLinux::GetWeakViewPtr() { - return weak_factory_.GetWeakPtr(); -} - -uint64_t PlatformViewLinux::DefaultFramebuffer() const { - return 0; -} - -bool PlatformViewLinux::ContextMakeCurrent() { - return false; -} - -bool PlatformViewLinux::SwapBuffers() { - return false; -} - -} // namespace shell -} // namespace sky diff --git a/sky/shell/platform/linux/platform_view_linux.h b/sky/shell/platform/linux/platform_view_linux.h deleted file mode 100644 index 1b10ee0888b8bef7bad35091dca3fccd5784f06a..0000000000000000000000000000000000000000 --- a/sky/shell/platform/linux/platform_view_linux.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef SKY_SHELL_PLATFORM_LINUX_PLATFORM_VIEW_LINUX_H_ -#define SKY_SHELL_PLATFORM_LINUX_PLATFORM_VIEW_LINUX_H_ - -#include "flutter/sky/shell/platform_view.h" - -namespace sky { -namespace shell { - -class PlatformViewLinux : public PlatformView { - public: - explicit PlatformViewLinux(const Config& config, - SurfaceConfig surface_config); - - ~PlatformViewLinux() override; - - // sky::shell::PlatformView override - ftl::WeakPtr GetWeakViewPtr() override; - - // sky::shell::PlatformView override - uint64_t DefaultFramebuffer() const override; - - // sky::shell::PlatformView override - bool ContextMakeCurrent() override; - - // sky::shell::PlatformView override - bool SwapBuffers() override; - - private: - ftl::WeakPtrFactory weak_factory_; - - FTL_DISALLOW_COPY_AND_ASSIGN(PlatformViewLinux); -}; - -} // namespace shell -} // namespace sky - -#endif // SKY_SHELL_PLATFORM_LINUX_PLATFORM_VIEW_LINUX_H_ diff --git a/sky/shell/platform/mac/.gitignore b/sky/shell/platform/mac/.gitignore deleted file mode 100644 index 962db51bbdbb55f85c84958bf475a290e0fc6a3a..0000000000000000000000000000000000000000 --- a/sky/shell/platform/mac/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ -.idea/ -.sconsign.dblite -.svn/ - -.DS_Store -*.swp -*.lock -profile - -DerivedData/ -build/ - -*.pbxuser -*.mode1v3 -*.mode2v3 -*.perspectivev3 - -!default.pbxuser -!default.mode1v3 -!default.mode2v3 -!default.perspectivev3 - -xcuserdata - -*.moved-aside -Sky.xcodeproj/