From 0745ce5fa9c62b551adcb317d74b73ac08e02480 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Sat, 22 Sep 2018 15:56:50 -0700 Subject: [PATCH] Remove the unused Mac Desktop shell. (flutter/engine#6314) This shell used to serve the dual purpose of running Flutter tests as well as optionally being able to run Flutter applications on a Mac desktop. After all the test runner targets were consolidated (flutter_tester), this target was no longer used to run the tests. This target is currently only used by engine developers to test changes quickly on the host. Even for this purpose, the Desktop embedders are more full featured and use the stable embedder API. The presence of a cross-platform tester target, alternatives for Desktop targets that use the stable embedder API and the fact that this target is no longer tested, makes having this code in the source entirely redundant. --- .../ci/licenses_golden/licenses_flutter | 10 - .../flutter/shell/platform/darwin/BUILD.gn | 10 +- .../shell/platform/darwin/desktop/BUILD.gn | 64 ----- .../shell/platform/darwin/desktop/Info.plist | 32 --- .../desktop/flutter_application_delegate.h | 14 - .../desktop/flutter_application_delegate.mm | 80 ------ .../platform/darwin/desktop/flutter_window.h | 14 - .../platform/darwin/desktop/flutter_window.mm | 271 ------------------ .../shell/platform/darwin/desktop/main_mac.mm | 34 --- .../darwin/desktop/platform_view_mac.h | 52 ---- .../darwin/desktop/platform_view_mac.mm | 90 ------ .../darwin/desktop/vsync_waiter_mac.cc | 58 ---- .../darwin/desktop/vsync_waiter_mac.h | 33 --- 13 files changed, 1 insertion(+), 761 deletions(-) delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/BUILD.gn delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/Info.plist delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/flutter_application_delegate.h delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/flutter_application_delegate.mm delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/flutter_window.h delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/flutter_window.mm delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/main_mac.mm delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/platform_view_mac.h delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/platform_view_mac.mm delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/vsync_waiter_mac.cc delete mode 100644 engine/src/flutter/shell/platform/darwin/desktop/vsync_waiter_mac.h diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 600bd35039..02466d418a 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -200,7 +200,6 @@ FILE: ../../../flutter/lib/ui/window/window.h FILE: ../../../flutter/shell/common/skia_event_tracer_impl.cc FILE: ../../../flutter/shell/platform/android/apk_asset_provider.cc FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/JSONUtil.java -FILE: ../../../flutter/shell/platform/darwin/desktop/Info.plist FILE: ../../../flutter/shell/platform/darwin/ios/framework/Flutter.podspec FILE: ../../../flutter/shell/platform/darwin/ios/framework/Info.plist FILE: ../../../flutter/shell/platform/darwin/ios/framework/module.modulemap @@ -271,8 +270,6 @@ FILE: ../../../flutter/shell/common/thread_host.cc FILE: ../../../flutter/shell/common/thread_host.h FILE: ../../../flutter/shell/platform/darwin/common/command_line.h FILE: ../../../flutter/shell/platform/darwin/common/command_line.mm -FILE: ../../../flutter/shell/platform/darwin/desktop/flutter_application_delegate.h -FILE: ../../../flutter/shell/platform/darwin/desktop/flutter_application_delegate.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h FILE: ../../../flutter/shell/platform/embedder/embedder.h FILE: ../../../flutter/shell/platform/embedder/embedder_engine.cc @@ -382,7 +379,6 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/view/VsyncWaiter.java FILE: ../../../flutter/shell/platform/android/vsync_waiter_android.cc FILE: ../../../flutter/shell/platform/android/vsync_waiter_android.h FILE: ../../../flutter/shell/platform/darwin/common/buffer_conversions.mm -FILE: ../../../flutter/shell/platform/darwin/desktop/vsync_waiter_mac.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h @@ -837,12 +833,6 @@ FILE: ../../../flutter/shell/platform/android/library_loader.cc FILE: ../../../flutter/shell/platform/android/platform_view_android.cc FILE: ../../../flutter/shell/platform/android/platform_view_android.h FILE: ../../../flutter/shell/platform/darwin/common/buffer_conversions.h -FILE: ../../../flutter/shell/platform/darwin/desktop/flutter_window.h -FILE: ../../../flutter/shell/platform/darwin/desktop/flutter_window.mm -FILE: ../../../flutter/shell/platform/darwin/desktop/main_mac.mm -FILE: ../../../flutter/shell/platform/darwin/desktop/platform_view_mac.h -FILE: ../../../flutter/shell/platform/darwin/desktop/platform_view_mac.mm -FILE: ../../../flutter/shell/platform/darwin/desktop/vsync_waiter_mac.cc FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm diff --git a/engine/src/flutter/shell/platform/darwin/BUILD.gn b/engine/src/flutter/shell/platform/darwin/BUILD.gn index 9f4dfca071..3c04dda634 100644 --- a/engine/src/flutter/shell/platform/darwin/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/BUILD.gn @@ -5,18 +5,10 @@ assert(is_mac || is_ios) group("darwin") { - if (is_mac) { - if (!is_fuchsia_host) { - deps = [ - "desktop:shell_application_bundle", - ] - } - } else if (is_ios) { + if (is_ios) { deps = [ "ios:flutter_framework", ] - } else { - assert(false, "Unknown darwin platform type.") } } diff --git a/engine/src/flutter/shell/platform/darwin/desktop/BUILD.gn b/engine/src/flutter/shell/platform/darwin/desktop/BUILD.gn deleted file mode 100644 index a574249398..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/BUILD.gn +++ /dev/null @@ -1,64 +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. - -assert(is_mac) - -import("$flutter_root/shell/gpu/gpu.gni") - -shell_gpu_configuration("darwin_desktop_gpu_configuration") { - enable_software = false - enable_vulkan = false - enable_gl = true -} - -source_set("mac_desktop_platform") { - visibility = [ ":*" ] - - sources = [ - "flutter_application_delegate.h", - "flutter_application_delegate.mm", - "flutter_window.h", - "flutter_window.mm", - "main_mac.mm", - "platform_view_mac.h", - "platform_view_mac.mm", - "vsync_waiter_mac.cc", - "vsync_waiter_mac.h", - ] - - deps = [ - ":darwin_desktop_gpu_configuration", - "$flutter_root/common", - "$flutter_root/fml", - "$flutter_root/lib/snapshot", - "$flutter_root/shell/common", - "$flutter_root/shell/platform/darwin/common", - "$flutter_root/synchronization", - "//third_party/dart/runtime:libdart_jit", - "//third_party/skia", - "//third_party/skia:gpu", - ] - - public_configs = [ "$flutter_root:config" ] -} - -if (!is_fuchsia_host) { - import("//build/config/mac/rules.gni") - - resource_copy_mac("mac_desktop_resources") { - app_name = "FlutterTester" - resources = [ "//third_party/icu/flutter/icudtl.dat" ] - bundle_directory = "." - } - - mac_app("shell_application_bundle") { - app_name = "FlutterTester" - info_plist = "Info.plist" - - deps = [ - ":mac_desktop_platform", - ":mac_desktop_resources", - ] - } -} diff --git a/engine/src/flutter/shell/platform/darwin/desktop/Info.plist b/engine/src/flutter/shell/platform/darwin/desktop/Info.plist deleted file mode 100644 index 048afb6dad..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/Info.plist +++ /dev/null @@ -1,32 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - FlutterTester - CFBundleIconFile - - CFBundleIdentifier - io.flutter.engine - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Flutter Engine - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSMinimumSystemVersion - 10.6 - NSHumanReadableCopyright - Copyright 2015 The Flutter Authors. All rights reserved. - NSPrincipalClass - NSApplication - - diff --git a/engine/src/flutter/shell/platform/darwin/desktop/flutter_application_delegate.h b/engine/src/flutter/shell/platform/darwin/desktop/flutter_application_delegate.h deleted file mode 100644 index 3995557b25..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/flutter_application_delegate.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APPLICATION_DELEGATE_H_ -#define FLUTTER_SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APPLICATION_DELEGATE_H_ - -#import - -@interface FlutterApplicationDelegate : NSObject - -@end - -#endif // FLUTTER_SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_APPLICATION_DELEGATE_H_ diff --git a/engine/src/flutter/shell/platform/darwin/desktop/flutter_application_delegate.mm b/engine/src/flutter/shell/platform/darwin/desktop/flutter_application_delegate.mm deleted file mode 100644 index 50670cf25b..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/flutter_application_delegate.mm +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2017 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/shell/platform/darwin/desktop/flutter_application_delegate.h" -#include "flutter/shell/platform/darwin/desktop/flutter_window.h" - -#include - -@implementation FlutterApplicationDelegate - -- (void)applicationWillFinishLaunching:(NSNotification*)notification { - [self configureMainMenuBar]; - [self onNewFlutterWindow:self]; -} - -- (void)configureMainMenuBar { - NSMenu* mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; - - NSMenuItem* engineItem = - [[[NSMenuItem alloc] initWithTitle:@"Engine" action:NULL keyEquivalent:@""] autorelease]; - - NSMenu* engineMenu = [[[NSMenu alloc] initWithTitle:@"EngineMenu"] autorelease]; - - NSMenuItem* newEngineItem = [[[NSMenuItem alloc] initWithTitle:@"New Engine" - action:@selector(onNewFlutterWindow:) - keyEquivalent:@""] autorelease]; - newEngineItem.keyEquivalent = @"n"; - newEngineItem.keyEquivalentModifierMask = NSEventModifierFlagCommand; - - NSMenuItem* shutdownEngineItem = - [[[NSMenuItem alloc] initWithTitle:@"Shutdown Engine" - action:@selector(onShutdownFlutterWindow:) - keyEquivalent:@""] autorelease]; - shutdownEngineItem.keyEquivalent = @"w"; - shutdownEngineItem.keyEquivalentModifierMask = NSEventModifierFlagCommand; - - NSMenuItem* quitItem = [[[NSMenuItem alloc] initWithTitle:@"Quit" - action:@selector(onQuitFlutterApplication:) - keyEquivalent:@""] autorelease]; - quitItem.keyEquivalent = @"q"; - quitItem.keyEquivalentModifierMask = NSEventModifierFlagCommand; - - [mainMenu addItem:engineItem]; - [engineItem setSubmenu:engineMenu]; - [engineMenu addItem:newEngineItem]; - [engineMenu addItem:shutdownEngineItem]; - [engineMenu addItem:quitItem]; - - [NSApplication sharedApplication].mainMenu = mainMenu; -} - -- (void)onNewFlutterWindow:(id)sender { - FlutterWindow* window = [[FlutterWindow alloc] init]; - [window setReleasedWhenClosed:YES]; - - NSWindow* currentKeyWindow = [NSApplication sharedApplication].keyWindow; - - if (currentKeyWindow == nil) { - [window center]; - } else { - [window center]; - NSPoint currentWindowFrameOrigin = window.frame.origin; - currentWindowFrameOrigin.x = currentKeyWindow.frame.origin.x + 20; - currentWindowFrameOrigin.y = currentKeyWindow.frame.origin.y - 20; - [window setFrameOrigin:currentWindowFrameOrigin]; - } - - [window makeKeyAndOrderFront:sender]; -} - -- (void)onShutdownFlutterWindow:(id)sender { - [[NSApplication sharedApplication].keyWindow close]; -} - -- (void)onQuitFlutterApplication:(id)sender { - exit(0); -} - -@end diff --git a/engine/src/flutter/shell/platform/darwin/desktop/flutter_window.h b/engine/src/flutter/shell/platform/darwin/desktop/flutter_window.h deleted file mode 100644 index e07fe4eeb7..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/flutter_window.h +++ /dev/null @@ -1,14 +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. - -#ifndef SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_WINDOW_H_ -#define SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_WINDOW_H_ - -#import - -@interface FlutterWindow : NSWindow - -@end - -#endif // SHELL_PLATFORM_DARWIN_DESKTOP_FLUTTER_WINDOW_H_ diff --git a/engine/src/flutter/shell/platform/darwin/desktop/flutter_window.mm b/engine/src/flutter/shell/platform/darwin/desktop/flutter_window.mm deleted file mode 100644 index 28591b950d..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/flutter_window.mm +++ /dev/null @@ -1,271 +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. - -#define FML_USED_ON_EMBEDDER - -#import "flutter_window.h" - -#include - -#include "flutter/common/task_runners.h" -#include "flutter/fml/make_copyable.h" -#include "flutter/fml/message_loop.h" -#include "flutter/shell/common/rasterizer.h" -#include "flutter/shell/common/switches.h" -#include "flutter/shell/common/thread_host.h" -#include "flutter/shell/gpu/gpu_surface_gl.h" -#include "flutter/shell/platform/darwin/common/command_line.h" -#include "flutter/shell/platform/darwin/desktop/platform_view_mac.h" - -@interface FlutterWindow () - -@property(strong) NSOpenGLView* renderSurface; - -@end - -static inline blink::PointerData::Change PointerChangeFromNSEventPhase(NSEventPhase phase) { - switch (phase) { - case NSEventPhaseNone: - return blink::PointerData::Change::kCancel; - case NSEventPhaseBegan: - return blink::PointerData::Change::kDown; - case NSEventPhaseStationary: - // There is no EVENT_TYPE_POINTER_STATIONARY. So we just pass a move type - // with the same coordinates - case NSEventPhaseChanged: - return blink::PointerData::Change::kMove; - case NSEventPhaseEnded: - return blink::PointerData::Change::kUp; - case NSEventPhaseCancelled: - return blink::PointerData::Change::kCancel; - case NSEventPhaseMayBegin: - return blink::PointerData::Change::kCancel; - } - return blink::PointerData::Change::kCancel; -} - -@implementation FlutterWindow { - shell::ThreadHost _thread_host; - std::unique_ptr _shell; - bool _mouseIsDown; -} - -- (instancetype)init { - self = [super initWithContentRect:NSMakeRect(10.0, 10.0, 800.0, 600.0) - styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | - NSWindowStyleMaskResizable - backing:NSBackingStoreBuffered - defer:YES]; - if (self) { - self.delegate = self; - [self setupRenderSurface]; - [self setupShell]; - [self updateWindowSize]; - } - - return self; -} - -- (void)setupRenderSurface { - NSOpenGLView* renderSurface = [[[NSOpenGLView alloc] init] autorelease]; - const NSOpenGLPixelFormatAttribute attrs[] = { - NSOpenGLPFADoubleBuffer, // - NSOpenGLPFAAllowOfflineRenderers, // - 0 // - }; - renderSurface.pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease]; - renderSurface.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; - renderSurface.frame = - NSMakeRect(0.0, 0.0, self.contentView.bounds.size.width, self.contentView.bounds.size.height); - [self.contentView addSubview:renderSurface]; - self.renderSurface = renderSurface; -} - -static std::string CreateThreadLabel() { - std::stringstream stream; - static int index = 1; - stream << "io.flutter." << index++; - return stream.str(); -} - -- (void)setupShell { - FML_DCHECK(!_shell) << "The shell must not already be set."; - - auto thread_label = CreateThreadLabel(); - - // Create the threads on which to run the shell. - _thread_host = {thread_label, shell::ThreadHost::Type::GPU | shell::ThreadHost::Type::UI | - shell::ThreadHost::Type::IO}; - - // Grab the task runners for the newly created threads. - fml::MessageLoop::EnsureInitializedForCurrentThread(); - blink::TaskRunners task_runners(thread_label, // label - fml::MessageLoop::GetCurrent().GetTaskRunner(), // platform - _thread_host.gpu_thread->GetTaskRunner(), // GPU - _thread_host.ui_thread->GetTaskRunner(), // UI - _thread_host.io_thread->GetTaskRunner() // IO - ); - - // Figure out the settings from the command line arguments. - auto settings = shell::SettingsFromCommandLine(shell::CommandLineFromNSProcessInfo()); - - if (settings.icu_data_path.size() == 0) { - settings.icu_data_path = - [[NSBundle mainBundle] pathForResource:@"icudtl.dat" ofType:@""].UTF8String; - } - - settings.task_observer_add = [](intptr_t key, fml::closure callback) { - fml::MessageLoop::GetCurrent().AddTaskObserver(key, std::move(callback)); - }; - - settings.task_observer_remove = [](intptr_t key) { - fml::MessageLoop::GetCurrent().RemoveTaskObserver(key); - }; - - // Setup the callback that will be run on the appropriate threads. - shell::Shell::CreateCallback on_create_platform_view = - [render_surface = self.renderSurface](shell::Shell& shell) { - return std::make_unique(shell, render_surface); - }; - - shell::Shell::CreateCallback on_create_rasterizer = [](shell::Shell& shell) { - return std::make_unique(shell.GetTaskRunners()); - }; - - // Finally, create the shell. - _shell = shell::Shell::Create(std::move(task_runners), settings, on_create_platform_view, - on_create_rasterizer); - - // Launch the engine with the inferred run configuration. - _shell->GetTaskRunners().GetUITaskRunner()->PostTask(fml::MakeCopyable( - [engine = _shell->GetEngine(), - config = shell::RunConfiguration::InferFromSettings(_shell->GetSettings())]() mutable { - if (engine) { - auto result = engine->Run(std::move(config)); - if (!result) { - FML_LOG(ERROR) << "Could not launch the engine with configuration."; - } - } - })); - - [self notifySurfaceCreated]; -} - -- (void)notifySurfaceCreated { - if (!_shell || !_shell->IsSetup()) { - return; - } - - // Tell the platform view that it has a GL surface. - _shell->GetPlatformView()->NotifyCreated(); -} - -- (void)notifySurfaceDestroyed { - if (!_shell || !_shell->IsSetup()) { - return; - } - - // Tell the platform view that its surface is about to be lost. - _shell->GetPlatformView()->NotifyDestroyed(); -} - -- (void)windowDidResize:(NSNotification*)notification { - [self updateWindowSize]; -} - -- (void)updateWindowSize { - if (!_shell) { - return; - } - - blink::ViewportMetrics metrics; - auto size = self.renderSurface.frame.size; - metrics.physical_width = size.width; - metrics.physical_height = size.height; - _shell->GetTaskRunners().GetUITaskRunner()->PostTask([engine = _shell->GetEngine(), metrics]() { - if (engine) { - engine->SetViewportMetrics(metrics); - } - }); -} - -#pragma mark - Responder overrides - -- (void)dispatchEvent:(NSEvent*)event phase:(NSEventPhase)phase { - if (!_shell) { - return; - } - - NSPoint location = [_renderSurface convertPoint:event.locationInWindow fromView:nil]; - location.y = _renderSurface.frame.size.height - location.y; - - blink::PointerData pointer_data; - pointer_data.Clear(); - - constexpr int kMicrosecondsPerSecond = 1000 * 1000; - pointer_data.time_stamp = event.timestamp * kMicrosecondsPerSecond; - pointer_data.change = PointerChangeFromNSEventPhase(phase); - pointer_data.kind = blink::PointerData::DeviceKind::kMouse; - pointer_data.physical_x = location.x; - pointer_data.physical_y = location.y; - pointer_data.pressure = 1.0; - pointer_data.pressure_max = 1.0; - - switch (pointer_data.change) { - case blink::PointerData::Change::kDown: - _mouseIsDown = true; - break; - case blink::PointerData::Change::kCancel: - case blink::PointerData::Change::kUp: - _mouseIsDown = false; - break; - case blink::PointerData::Change::kMove: - if (!_mouseIsDown) - pointer_data.change = blink::PointerData::Change::kHover; - break; - case blink::PointerData::Change::kAdd: - case blink::PointerData::Change::kRemove: - case blink::PointerData::Change::kHover: - FML_DCHECK(!_mouseIsDown); - break; - } - - _shell->GetTaskRunners().GetUITaskRunner()->PostTask( - [engine = _shell->GetEngine(), pointer_data] { - if (engine) { - blink::PointerDataPacket packet(1); - packet.SetPointerData(0, pointer_data); - engine->DispatchPointerDataPacket(packet); - } - }); -} - -- (void)mouseDown:(NSEvent*)event { - [self dispatchEvent:event phase:NSEventPhaseBegan]; -} - -- (void)mouseDragged:(NSEvent*)event { - [self dispatchEvent:event phase:NSEventPhaseChanged]; -} - -- (void)mouseUp:(NSEvent*)event { - [self dispatchEvent:event phase:NSEventPhaseEnded]; -} - -- (void)reset { - [self notifySurfaceDestroyed]; - _shell.reset(); - _thread_host.Reset(); -} - -- (void)windowWillClose:(NSNotification*)notification { - [self reset]; -} - -- (void)dealloc { - [self reset]; - [super dealloc]; -} - -@end diff --git a/engine/src/flutter/shell/platform/darwin/desktop/main_mac.mm b/engine/src/flutter/shell/platform/darwin/desktop/main_mac.mm deleted file mode 100644 index 55a8e6a6de..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/main_mac.mm +++ /dev/null @@ -1,34 +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 - -#include - -#include "flutter/fml/command_line.h" -#include "flutter/fml/logging.h" -#include "flutter/fml/message_loop.h" -#include "flutter/shell/common/shell.h" -#include "flutter/shell/common/switches.h" -#include "flutter/shell/platform/darwin/desktop/flutter_application_delegate.h" - -int main(int argc, const char* argv[]) { - std::vector args_vector; - - for (NSString* arg in [NSProcessInfo processInfo].arguments) { - args_vector.emplace_back(arg.UTF8String); - } - - auto command_line = fml::CommandLineFromIterators(args_vector.begin(), args_vector.end()); - - // Print help. - if (command_line.HasOption(shell::FlagForSwitch(shell::Switch::Help))) { - shell::PrintUsage([NSProcessInfo processInfo].processName.UTF8String); - return EXIT_SUCCESS; - } - - [NSApplication sharedApplication].delegate = - [[[FlutterApplicationDelegate alloc] init] autorelease]; - return NSApplicationMain(argc, argv); -} diff --git a/engine/src/flutter/shell/platform/darwin/desktop/platform_view_mac.h b/engine/src/flutter/shell/platform/darwin/desktop/platform_view_mac.h deleted file mode 100644 index c288d324ab..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/platform_view_mac.h +++ /dev/null @@ -1,52 +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. - -#ifndef SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ -#define SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ - -#include "flutter/fml/memory/weak_ptr.h" -#include "flutter/fml/platform/darwin/scoped_nsobject.h" -#include "flutter/shell/common/platform_view.h" -#include "flutter/shell/common/shell.h" -#include "flutter/shell/gpu/gpu_surface_gl.h" - -@class NSOpenGLView; -@class NSOpenGLContext; - -namespace shell { - -class PlatformViewMac final : public PlatformView, public GPUSurfaceGLDelegate { - public: - PlatformViewMac(Shell& shell, NSOpenGLView* gl_view); - - ~PlatformViewMac() override; - - std::unique_ptr CreateVSyncWaiter() override; - - bool GLContextMakeCurrent() override; - - bool GLContextClearCurrent() override; - - bool GLContextPresent() override; - - intptr_t GLContextFBO() const override; - - private: - fml::scoped_nsobject opengl_view_; - fml::scoped_nsobject resource_loading_context_; - - bool IsValid() const; - - // |shell::PlatformView| - std::unique_ptr CreateRenderingSurface() override; - - // |shell::PlatformView| - sk_sp CreateResourceContext() const override; - - FML_DISALLOW_COPY_AND_ASSIGN(PlatformViewMac); -}; - -} // namespace shell - -#endif // SHELL_PLATFORM_MAC_PLATFORM_VIEW_MAC_H_ diff --git a/engine/src/flutter/shell/platform/darwin/desktop/platform_view_mac.mm b/engine/src/flutter/shell/platform/darwin/desktop/platform_view_mac.mm deleted file mode 100644 index 2a08de681f..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/platform_view_mac.mm +++ /dev/null @@ -1,90 +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/shell/platform/darwin/desktop/platform_view_mac.h" - -#include -#include - -#include "flutter/fml/command_line.h" -#include "flutter/fml/synchronization/waitable_event.h" -#include "flutter/fml/trace_event.h" -#include "flutter/shell/common/io_manager.h" -#include "flutter/shell/common/rasterizer.h" -#include "flutter/shell/common/switches.h" -#include "flutter/shell/platform/darwin/desktop/vsync_waiter_mac.h" - -namespace shell { - -PlatformViewMac::PlatformViewMac(Shell& shell, NSOpenGLView* gl_view) - : PlatformView(shell, shell.GetTaskRunners()), - opengl_view_([gl_view retain]), - resource_loading_context_([[NSOpenGLContext alloc] initWithFormat:gl_view.pixelFormat - shareContext:gl_view.openGLContext]) {} - -PlatformViewMac::~PlatformViewMac() = default; - -std::unique_ptr PlatformViewMac::CreateVSyncWaiter() { - return std::make_unique(task_runners_); -} - -intptr_t PlatformViewMac::GLContextFBO() const { - // Default window bound framebuffer FBO 0. - return 0; -} - -bool PlatformViewMac::GLContextMakeCurrent() { - TRACE_EVENT0("flutter", "PlatformViewMac::GLContextMakeCurrent"); - if (!IsValid()) { - return false; - } - - [opengl_view_.get().openGLContext makeCurrentContext]; - return true; -} - -bool PlatformViewMac::GLContextClearCurrent() { - TRACE_EVENT0("flutter", "PlatformViewMac::GLContextClearCurrent"); - if (!IsValid()) { - return false; - } - - [NSOpenGLContext clearCurrentContext]; - return true; -} - -bool PlatformViewMac::GLContextPresent() { - TRACE_EVENT0("flutter", "PlatformViewMac::GLContextPresent"); - if (!IsValid()) { - return false; - } - - [opengl_view_.get().openGLContext flushBuffer]; - return true; -} - -sk_sp PlatformViewMac::CreateResourceContext() const { - [resource_loading_context_.get() makeCurrentContext]; - return IOManager::CreateCompatibleResourceLoadingContext(GrBackend::kOpenGL_GrBackend); -} - -bool PlatformViewMac::IsValid() const { - if (opengl_view_ == nullptr) { - return false; - } - - auto context = opengl_view_.get().openGLContext; - - if (context == nullptr) { - return false; - } - - return true; -} - -std::unique_ptr PlatformViewMac::CreateRenderingSurface() { - return std::make_unique(this); -} - -} // namespace shell diff --git a/engine/src/flutter/shell/platform/darwin/desktop/vsync_waiter_mac.cc b/engine/src/flutter/shell/platform/darwin/desktop/vsync_waiter_mac.cc deleted file mode 100644 index 27aff35fb3..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/vsync_waiter_mac.cc +++ /dev/null @@ -1,58 +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/shell/platform/darwin/desktop/vsync_waiter_mac.h" - -#include - -#include "flutter/fml/logging.h" - -namespace shell { - -#define link_ (reinterpret_cast(opaque_)) - -VsyncWaiterMac::VsyncWaiterMac(blink::TaskRunners task_runners) - : VsyncWaiter(std::move(task_runners)), opaque_(nullptr) { - // Create the link. - CVDisplayLinkRef link = nullptr; - CVDisplayLinkCreateWithActiveCGDisplays(&link); - opaque_ = link; - - // Set the output callback. - CVDisplayLinkSetOutputCallback( - link_, - [](CVDisplayLinkRef link, const CVTimeStamp* now, - const CVTimeStamp* output, CVOptionFlags flags_in, - CVOptionFlags* flags_out, void* context) -> CVReturn { - OnDisplayLink(context); - return kCVReturnSuccess; - }, - this); -} - -VsyncWaiterMac::~VsyncWaiterMac() { - CVDisplayLinkRelease(link_); -} - -void VsyncWaiterMac::OnDisplayLink(void* context) { - reinterpret_cast(context)->OnDisplayLink(); -} - -void VsyncWaiterMac::OnDisplayLink() { - fml::TimePoint frame_start_time = fml::TimePoint::Now(); - fml::TimePoint frame_target_time = - frame_start_time + - fml::TimeDelta::FromSecondsF( - CVDisplayLinkGetActualOutputVideoRefreshPeriod(link_)); - - CVDisplayLinkStop(link_); - - FireCallback(frame_start_time, frame_target_time); -} - -void VsyncWaiterMac::AwaitVSync() { - CVDisplayLinkStart(link_); -} - -} // namespace shell diff --git a/engine/src/flutter/shell/platform/darwin/desktop/vsync_waiter_mac.h b/engine/src/flutter/shell/platform/darwin/desktop/vsync_waiter_mac.h deleted file mode 100644 index 1bc4176263..0000000000 --- a/engine/src/flutter/shell/platform/darwin/desktop/vsync_waiter_mac.h +++ /dev/null @@ -1,33 +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 FLUTTER_SHELL_PLATFORM_DARWIN_DESKTOP_VSYNC_WAITER_MAC_H_ -#define FLUTTER_SHELL_PLATFORM_DARWIN_DESKTOP_VSYNC_WAITER_MAC_H_ - -#include "flutter/fml/macros.h" -#include "flutter/shell/common/vsync_waiter.h" - -namespace shell { - -class VsyncWaiterMac final : public VsyncWaiter { - public: - VsyncWaiterMac(blink::TaskRunners task_runners); - - ~VsyncWaiterMac() override; - - private: - void* opaque_; - - void AwaitVSync() override; - - static void OnDisplayLink(void* context); - - void OnDisplayLink(); - - FML_DISALLOW_COPY_AND_ASSIGN(VsyncWaiterMac); -}; - -} // namespace shell - -#endif // FLUTTER_SHELL_PLATFORM_DARWIN_DESKTOP_VSYNC_WAITER_MAC_H_