Skip to content

Commit

Permalink
[Windows] Alternative Windows shell platform implementation (#9835)
Browse files Browse the repository at this point in the history
Start work on flutter/flutter#30726 by adding an alternative win32 shell platform implementation for Windows that is not based on GLFW and that uses LIBANGLE for rendering and native win32 windowing and input. This change does not replace the GLFW implementation but rather runs side by side with it producing a secondary flutter_windows_win32.dll artifact. The following items must be added to attain parity with the GLFW implementation:
- Custom task scheduling
- Support for keyboard modifier keys
- Async texture uploads
- Correct high DPI handling on Windows versions < 1703
and will be added in subsequent changes.
  • Loading branch information
clarkezone authored and stuartmorgan committed Aug 14, 2019
1 parent c5e3055 commit ff484d4
Show file tree
Hide file tree
Showing 39 changed files with 9,990 additions and 1,254 deletions.
4 changes: 4 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ group("flutter") {
"$flutter_root/third_party/txt:txt_unittests",
]

if (is_win) {
public_deps += [ "$flutter_root/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests" ]
}

if (!is_win) {
public_deps += [
"$flutter_root/fml:fml_benchmarks",
Expand Down
3 changes: 3 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ deps = {
'src/third_party/swiftshader':
Var('swiftshader_git') + '/SwiftShader.git' + '@' + 'd70129a3d3409dac58e14f819b62620393afb652',

'src/third_party/angle':
Var('github_git') + '/google/angle.git' + '@' + '2d0a9acb05511a8fdaf0cd27d0da22599516a68b',

'src/third_party/pkg/when':
Var('dart_git') + '/when.git' + '@' + '0.2.0',

Expand Down
23 changes: 23 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,29 @@ FILE: ../../../flutter/shell/platform/glfw/platform_handler.h
FILE: ../../../flutter/shell/platform/glfw/public/flutter_glfw.h
FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.cc
FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.h
FILE: ../../../flutter/shell/platform/windows/angle_surface_manager.cc
FILE: ../../../flutter/shell/platform/windows/angle_surface_manager.h
FILE: ../../../flutter/shell/platform/windows/client_wrapper/flutter_window_controller.cc
FILE: ../../../flutter/shell/platform/windows/client_wrapper/flutter_window_controller_unittests.cc
FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/flutter_window.h
FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/flutter_window_controller.h
FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/plugin_registrar_windows.h
FILE: ../../../flutter/shell/platform/windows/flutter_windows.cc
FILE: ../../../flutter/shell/platform/windows/key_event_handler.cc
FILE: ../../../flutter/shell/platform/windows/key_event_handler.h
FILE: ../../../flutter/shell/platform/windows/keyboard_hook_handler.h
FILE: ../../../flutter/shell/platform/windows/platform_handler.cc
FILE: ../../../flutter/shell/platform/windows/platform_handler.h
FILE: ../../../flutter/shell/platform/windows/public/flutter_windows.h
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.cc
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.h
FILE: ../../../flutter/shell/platform/windows/win32_dpi_helper.cc
FILE: ../../../flutter/shell/platform/windows/win32_dpi_helper.h
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.cc
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.h
FILE: ../../../flutter/shell/platform/windows/win32_window.cc
FILE: ../../../flutter/shell/platform/windows/win32_window.h
FILE: ../../../flutter/shell/platform/windows/window_state.h
FILE: ../../../flutter/shell/version/version.cc
FILE: ../../../flutter/shell/version/version.h
FILE: ../../../flutter/sky/packages/flutter_services/lib/empty.dart
Expand Down
4,711 changes: 4,201 additions & 510 deletions ci/licenses_golden/licenses_third_party

Large diffs are not rendered by default.

43 changes: 3 additions & 40 deletions shell/platform/common/cpp/client_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,12 @@
# found in the LICENSE file.

import("$flutter_root/testing/testing.gni")
import("publish.gni")

_wrapper_includes = [
"include/flutter/basic_message_channel.h",
"include/flutter/binary_messenger.h",
"include/flutter/encodable_value.h",
"include/flutter/engine_method_result.h",
"include/flutter/json_message_codec.h",
"include/flutter/json_method_codec.h",
"include/flutter/json_type.h",
"include/flutter/message_codec.h",
"include/flutter/method_call.h",
"include/flutter/method_channel.h",
"include/flutter/method_codec.h",
"include/flutter/method_result.h",
"include/flutter/plugin_registrar.h",
"include/flutter/standard_message_codec.h",
"include/flutter/standard_method_codec.h",
]

# TODO: Once the wrapper API is more stable, consolidate to as few files as is
# reasonable (without forcing different kinds of clients to take unnecessary
# code) to simplify use.
_wrapper_sources = [
"byte_stream_wrappers.h",
"engine_method_result.cc",
"json_message_codec.cc", # TODO combine into a single json_codec.cc.
"json_method_codec.cc", # TODO combine into a single json_codec.cc.
"plugin_registrar.cc",
"standard_codec_serializer.h",
"standard_codec.cc",
]
import("core_wrapper_files.gni")

# Client library build for internal use by the shell implementation.
source_set("client_wrapper") {
sources = _wrapper_sources
public = _wrapper_includes
sources = core_cpp_client_wrapper_sources
public = core_cpp_client_wrapper_includes

deps = [
"$flutter_root/shell/platform/common/cpp:common_cpp_library_headers",
Expand All @@ -57,12 +26,6 @@ source_set("client_wrapper") {
]
}

# Copies the client wrapper code to the output directory.
publish_client_wrapper("publish_wrapper") {
public = _wrapper_includes
sources = _wrapper_sources + [ "README" ]
}

source_set("client_wrapper_library_stubs") {
sources = [
"testing/stub_flutter_api.cc",
Expand Down
39 changes: 39 additions & 0 deletions shell/platform/common/cpp/client_wrapper/core_wrapper_files.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

core_cpp_client_wrapper_includes =
get_path_info([
"include/flutter/basic_message_channel.h",
"include/flutter/binary_messenger.h",
"include/flutter/encodable_value.h",
"include/flutter/engine_method_result.h",
"include/flutter/json_message_codec.h",
"include/flutter/json_method_codec.h",
"include/flutter/json_type.h",
"include/flutter/message_codec.h",
"include/flutter/method_call.h",
"include/flutter/method_channel.h",
"include/flutter/method_codec.h",
"include/flutter/method_result.h",
"include/flutter/plugin_registrar.h",
"include/flutter/standard_message_codec.h",
"include/flutter/standard_method_codec.h",
],
"abspath")

# TODO: Once the wrapper API is more stable, consolidate to as few files as is
# reasonable (without forcing different kinds of clients to take unnecessary
# code) to simplify use.
core_cpp_client_wrapper_sources =
get_path_info(
[
"byte_stream_wrappers.h",
"engine_method_result.cc",
"json_message_codec.cc", # TODO combine into a single json_codec.cc.
"json_method_codec.cc", # TODO combine into a single json_codec.cc.
"plugin_registrar.cc",
"standard_codec_serializer.h",
"standard_codec.cc",
],
"abspath")
60 changes: 59 additions & 1 deletion shell/platform/common/cpp/client_wrapper/publish.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("core_wrapper_files.gni")

# Publishes client wrapper files to the output directory for distribution.
# This can be used multiple times to combine various portions of a wrapper
# library into one cohesive library for clients to consume.
Expand All @@ -11,15 +13,28 @@
#
# All public code is assumed to be in the 'flutter' namespace.
template("publish_client_wrapper") {
forward_variables_from(invoker, [ "directory_suffix" ])
if (defined(directory_suffix)) {
publish_dir_root = "$root_out_dir/cpp_client_wrapper_$directory_suffix"
} else {
publish_dir_root = "$root_out_dir/cpp_client_wrapper"
}
template_target_name = target_name
publish_dir_root = "$root_out_dir/cpp_client_wrapper"
namespace = "flutter"

group(template_target_name) {
forward_variables_from(invoker,
[
"public_deps",
"visibility",
])
deps = [
":${template_target_name}_publish_includes",
":${template_target_name}_publish_sources",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
}

copy("${template_target_name}_publish_includes") {
Expand Down Expand Up @@ -50,3 +65,46 @@ template("publish_client_wrapper") {
]
}
}

_wrapper_readme = get_path_info("README", "abspath")

# Copies the client wrapper code to the output directory.
template("publish_client_wrapper_core") {
publish_client_wrapper(target_name) {
forward_variables_from(invoker,
[
"directory_suffix",
"visibility",
])
public = core_cpp_client_wrapper_includes
sources = core_cpp_client_wrapper_sources + [ _wrapper_readme ]
}
}

# A wrapper for publish_client_wrapper that will also
# publish_client_wrapper_core into the same directory.
#
# This is a convenience utility for the common case of wanting to publish
# the core wrapper and a single set of extra wrapper files corresponding to
# the platform.
template("publish_client_wrapper_extension") {
extension_target_name = target_name
core_target_name = "${target_name}_core"

publish_client_wrapper_core(core_target_name) {
visibility = [ ":$extension_target_name" ]
forward_variables_from(invoker, [ "directory_suffix" ])
}

publish_client_wrapper(extension_target_name) {
forward_variables_from(invoker,
[
"public",
"sources",
"directory_suffix",
])
public_deps = [
":$core_target_name",
]
}
}
1 change: 0 additions & 1 deletion shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ group("macos") {
if (build_glfw_shell) {
deps += [
":flutter_macos_glfw",
"$flutter_root/shell/platform/common/cpp/client_wrapper:publish_wrapper",
"$flutter_root/shell/platform/glfw:publish_headers_glfw",
"$flutter_root/shell/platform/glfw/client_wrapper:publish_wrapper_glfw",
]
Expand Down
15 changes: 12 additions & 3 deletions shell/platform/glfw/client_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,22 @@ source_set("client_wrapper_glfw") {
]
}

# Copies the GLFW client wrapper code to the output directory, merging it into
# the core wrapper.
publish_client_wrapper("publish_wrapper_glfw") {
# Copies the GLFW client wrapper code to the output directory in the legacy
# unsuffixed location.
# TODO: Remove this copy once build recipes are using the _glfw version below.
publish_client_wrapper_extension("publish_wrapper_unprefixed") {
public = _wrapper_includes
sources = _wrapper_sources
}

# Copies the GLFW client wrapper code to the output directory with a _glfw
# suffix.
publish_client_wrapper_extension("publish_wrapper_glfw") {
public = _wrapper_includes
sources = _wrapper_sources
directory_suffix = "glfw"
}

source_set("client_wrapper_library_stubs_glfw") {
sources = [
"testing/stub_flutter_glfw_api.cc",
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group("linux") {
if (build_glfw_shell) {
deps = [
":flutter_linux",
"$flutter_root/shell/platform/common/cpp/client_wrapper:publish_wrapper",
"$flutter_root/shell/platform/glfw:publish_headers_glfw",
"$flutter_root/shell/platform/glfw/client_wrapper:publish_wrapper_glfw",
"$flutter_root/shell/platform/glfw/client_wrapper:publish_wrapper_unprefixed",
]
}
}
Expand Down
Loading

0 comments on commit ff484d4

Please sign in to comment.