Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ group("flutter") {

if (is_win) {
if (target_os == "winuwp") {
# TODO: Add winnup variant of the unit tests here; see
# TODO: Add winnup variant of client_wrapper_windows_unittests here; see
# https://github.com/flutter/flutter/issues/70197
public_deps +=
[ "//flutter/shell/platform/windows:flutter_windows_unittests" ]
} else {
public_deps += [
"//flutter/shell/platform/windows:flutter_windows_unittests",
Expand Down
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,8 @@ FILE: ../../../flutter/shell/platform/windows/external_texture_gl.h
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle.cc
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle.h
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle_unittests.cc
FILE: ../../../flutter/shell/platform/windows/flutter_window_winuwp.cc
FILE: ../../../flutter/shell/platform/windows/flutter_window_winuwp.h
FILE: ../../../flutter/shell/platform/windows/flutter_windows.cc
FILE: ../../../flutter/shell/platform/windows/flutter_windows_engine.cc
FILE: ../../../flutter/shell/platform/windows/flutter_windows_engine.h
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/common/cpp/engine_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ std::vector<std::string> GetSwitchesFromEnvironment() {
// Read engine switches from the environment in debug/profile. If release mode
// support is needed in the future, it should likely use a whitelist.
#ifndef FLUTTER_RELEASE
// TODO(clarkezone): figure out how to handle engine switches in UWP mode
// https://github.com/flutter/flutter/issues/74153
#ifndef WINUWP
const char* switch_count_key = "FLUTTER_ENGINE_SWITCHES";
const int kMaxSwitchCount = 50;
const char* switch_count_string = std::getenv(switch_count_key);
Expand All @@ -36,6 +39,7 @@ std::vector<std::string> GetSwitchesFromEnvironment() {
<< ", but " << switch_key.str() << " is missing." << std::endl;
}
}
#endif // !WINUWP
#endif // !FLUTTER_RELEASE
return switches;
}
Expand Down
62 changes: 40 additions & 22 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ source_set("flutter_windows_source") {
# Target-specific sources.
if (target_os == "winuwp") {
sources += [
"flutter_window_winuwp.cc",
"flutter_window_winuwp.h",
"flutter_windows_winuwp.cc",
"platform_handler_winuwp.cc",
"platform_handler_winuwp.h",
Expand Down Expand Up @@ -118,7 +120,10 @@ source_set("flutter_windows_source") {

public_configs = [ ":relative_angle_headers" ]

defines = [ "FLUTTER_ENGINE_NO_PROTOTYPES" ]
defines = [
"FLUTTER_ENGINE_NO_PROTOTYPES",
"USECOREWINDOW",
]

deps = [
":flutter_windows_headers",
Expand Down Expand Up @@ -162,20 +167,33 @@ test_fixtures("flutter_windows_fixtures") {
fixtures = []
}

if (target_os == "winuwp") {
# disabled until the uwp implementation is present
} else {
executable("flutter_windows_unittests") {
testonly = true
executable("flutter_windows_unittests") {
testonly = true

if (target_os == "winuwp") {
libs = [ "windowsapp.lib" ]
}

sources = [
# Common Windows test sources.
sources = [
# "flutter_project_bundle_unittests.cc", //TODO failing due to switches test failing. Blocked on https://github.com/flutter/flutter/issues/74153
# "flutter_windows_engine_unittests.cc", //TODO failing to send / receive platform message get plugins working first. Blocked on https://github.com/flutter/flutter/issues/74155
"string_conversion_unittests.cc",
"system_utils_unittests.cc",
"testing/engine_embedder_api_modifier.h",
]

# Target-specific sources.
if (target_os == "winuwp") {
# TODO(clarkezone) add UWP tests
# https://github.com/flutter/flutter/issues/70197
} else {
sources += [
# TODO move first two tests to common once above TODO's unblocked.
"flutter_project_bundle_unittests.cc",
"flutter_windows_engine_unittests.cc",
"flutter_windows_texture_registrar_unittests.cc",
"key_event_handler_unittests.cc",
"string_conversion_unittests.cc",
"system_utils_unittests.cc",
"testing/engine_embedder_api_modifier.h",
"testing/mock_win32_window.cc",
"testing/mock_win32_window.h",
"testing/mock_window_binding_handler.cc",
Expand All @@ -187,20 +205,20 @@ if (target_os == "winuwp") {
"win32_window_proc_delegate_manager_unittests.cc",
"win32_window_unittests.cc",
]
}

public_configs = [ "//flutter:config" ]
public_configs = [ "//flutter:config" ]

deps = [
":flutter_windows_fixtures",
":flutter_windows_headers",
":flutter_windows_source",
"//flutter/shell/platform/common/cpp:common_cpp",
"//flutter/shell/platform/embedder:embedder_as_internal_library",
"//flutter/shell/platform/embedder:embedder_test_utils",
"//flutter/testing",
"//third_party/rapidjson",
]
}
deps = [
":flutter_windows_fixtures",
":flutter_windows_headers",
":flutter_windows_source",
"//flutter/shell/platform/common/cpp:common_cpp",
"//flutter/shell/platform/embedder:embedder_as_internal_library",
"//flutter/shell/platform/embedder:embedder_test_utils",
"//flutter/testing",
"//third_party/rapidjson",
]
}

shared_library("flutter_windows_glfw") {
Expand Down
24 changes: 24 additions & 0 deletions shell/platform/windows/angle_surface_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
#include <iostream>
#include <vector>

#ifdef WINUWP
#include <windows.ui.core.h>
#include <winrt/Windows.UI.Composition.h>
#endif

#if defined(WINUWP) && defined(USECOREWINDOW)
#include <winrt/Windows.UI.Core.h>
#endif

namespace flutter {

AngleSurfaceManager::AngleSurfaceManager()
Expand Down Expand Up @@ -188,10 +197,23 @@ bool AngleSurfaceManager::CreateSurface(WindowsRenderTarget* render_target,
EGL_FIXED_SIZE_ANGLE, EGL_TRUE, EGL_WIDTH, width,
EGL_HEIGHT, height, EGL_NONE};

#ifdef WINUWP
#ifdef USECOREWINDOW
auto target = std::get<winrt::Windows::UI::Core::CoreWindow>(*render_target);
#else
auto target =
std::get<winrt::Windows::UI::Composition::SpriteVisual>(*render_target);
#endif
surface = eglCreateWindowSurface(
egl_display_, egl_config_,
static_cast<EGLNativeWindowType>(winrt::get_abi(target)),
surfaceAttributes);
#else
surface = eglCreateWindowSurface(
egl_display_, egl_config_,
static_cast<EGLNativeWindowType>(std::get<HWND>(*render_target)),
surfaceAttributes);
#endif
if (surface == EGL_NO_SURFACE) {
std::cerr << "Surface creation failed." << std::endl;
}
Expand All @@ -212,6 +234,8 @@ void AngleSurfaceManager::ResizeSurface(WindowsRenderTarget* render_target,
// preserve the previous surface contents. This resize approach could be
// further optimized if Angle exposed a public entrypoint for
// SwapChain11::reset or SwapChain11::resize.
// a possible starting point for that could build on
// eglPostSubBufferNV(egl_display_, render_surface_, 1, 1, width, height);
DestroySurface();
if (!CreateSurface(render_target, width, height)) {
std::cerr << "AngleSurfaceManager::ResizeSurface failed to create surface"
Expand Down
16 changes: 16 additions & 0 deletions shell/platform/windows/client_wrapper/flutter_view_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@

namespace flutter {

#ifdef WINUWP
FlutterViewController::FlutterViewController(
ABI::Windows::UI::Core::CoreWindow* window,
const DartProject& project) {
engine_ = std::make_unique<FlutterEngine>(project);
controller_ = FlutterDesktopViewControllerCreateFromCoreWindow(
window, engine_->RelinquishEngine());
if (!controller_) {
std::cerr << "Failed to create view controller." << std::endl;
return;
}
view_ = std::make_unique<FlutterView>(
FlutterDesktopViewControllerGetView(controller_));
}
#else
FlutterViewController::FlutterViewController(int width,
int height,
const DartProject& project) {
Expand All @@ -22,6 +37,7 @@ FlutterViewController::FlutterViewController(int width,
view_ = std::make_unique<FlutterView>(
FlutterDesktopViewControllerGetView(controller_));
}
#endif

FlutterViewController::~FlutterViewController() {
if (controller_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ namespace flutter {
// A set of Flutter and Dart assets used to initialize a Flutter engine.
class DartProject {
public:
#ifdef WINUWP
// Creates a DartProject from a series of absolute paths.
// The directory should contain the following top-level items:
// - icudtl.dat (provided as a resource by the Flutter tool)
// - flutter_assets (as built by the Flutter tool)
// - app.so, for an AOT build (as built by the Flutter tool)
//
// The path must be absolute.
explicit DartProject(const std::wstring& assetspath,
const std::wstring& icupath,
const std::wstring& aotpath) {
assets_path_ = assetspath;
icu_data_path_ = icupath;
aot_library_path_ = aotpath;
}
#else
// Creates a DartProject from a directory path. The directory should contain
// the following top-level items:
// - icudtl.dat (provided as a resource by the Flutter tool)
Expand All @@ -26,6 +42,7 @@ class DartProject {
icu_data_path_ = path + L"\\icudtl.dat";
aot_library_path_ = path + L"\\app.so";
}
#endif

~DartProject() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ class FlutterView {
FlutterView(FlutterView const&) = delete;
FlutterView& operator=(FlutterView const&) = delete;

#ifndef WINUWP
// Returns the backing HWND for the view.
HWND GetNativeWindow() { return FlutterDesktopViewGetHWND(view_); }
#endif

private:
// Handle for interacting with the C API's view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include "plugin_registrar.h"
#include "plugin_registry.h"

#ifdef WINUWP
#include <windows.ui.core.h>
#endif

namespace flutter {

// A controller for a view displaying Flutter content.
Expand All @@ -26,13 +30,22 @@ namespace flutter {
// methods in the C API directly, as this class will do that internally.
class FlutterViewController {
public:
#ifndef WINUWP
// Creates a FlutterView that can be parented into a Windows View hierarchy
// either using HWNDs or in the future into a CoreWindow, or using compositor.
// either using HWNDs.
//
// |dart_project| will be used to configure the engine backing this view.
explicit FlutterViewController(int width,
int height,
const DartProject& project);
#else
// Creates a FlutterView that can be parented into a Windows View hierarchy
// either using CoreWindow.
//
// |dart_project| will be used to configure the engine backing this view.
explicit FlutterViewController(ABI::Windows::UI::Core::CoreWindow* window,
const DartProject& project);
#endif

virtual ~FlutterViewController();

Expand Down
Loading