Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ deps = {

'src/third_party/angle':
Var('github_git') + '/google/angle.git' + '@' + '3ea90d609720b7b9b9d05ca094860382f2425294',
#Var('github_git') + '/clarkezone/angle.git' + '@' + 'cf00b8ccd9ff59645e7fab8837ca4547e1954695',

'src/third_party/pkg/when':
Var('dart_git') + '/when.git' + '@' + '0.2.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TestGlfwApi : public testing::StubFlutterGlfwApi {

} // namespace

TEST(FlutterViewControllerTest, CreateDestroy) {
TEST(Win32FlutterViewControllerTest, CreateDestroy) {
const std::string icu_data_path = "fake/path/to/icu";
testing::ScopedStubFlutterGlfwApi scoped_api_stub(
std::make_unique<TestGlfwApi>());
Expand Down
28 changes: 12 additions & 16 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ source_set("flutter_windows_source") {
sources = [
"angle_surface_manager.cc",
"angle_surface_manager.h",
"dpi_utils.cc",
"dpi_utils.h",
"flutter_windows.cc",
"key_event_handler.cc",
"key_event_handler.h",
Expand All @@ -53,13 +51,11 @@ source_set("flutter_windows_source") {
"string_conversion.h",
"text_input_plugin.cc",
"text_input_plugin.h",
"win32_flutter_window.cc",
"win32_flutter_window.h",
"win32_task_runner.cc",
"win32_task_runner.h",
"win32_window.cc",
"win32_window.h",
"window_state.h",
"flutter_windows_view.cc",
"flutter_windows_view.h",
"window_state_comp.h",
"task_runner.cc",
"task_runner.h",
]

configs += [
Expand Down Expand Up @@ -98,6 +94,8 @@ shared_library("flutter_windows") {
":flutter_windows_source",
]

libs = [ "windowsapp.lib" ]

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

Expand All @@ -109,14 +107,10 @@ executable("flutter_windows_unittests") {
testonly = true

sources = [
"dpi_utils_unittests.cc",
"string_conversion_unittests.cc",
"testing/win32_flutter_window_test.cc",
"testing/win32_flutter_window_test.h",
"testing/win32_window_test.cc",
"testing/win32_window_test.h",
"win32_flutter_window_unittests.cc",
"win32_window_unittests.cc",
"testing/flutter_compview_test.cc",
"testing/flutter_compview_test.h",
"flutter_compview_unittests.cc",
]

public_configs = [ "//flutter:config" ]
Expand All @@ -128,6 +122,8 @@ executable("flutter_windows_unittests") {
"//flutter/testing",
"//third_party/rapidjson",
]

libs = [ "windowsapp.lib" ]
}

shared_library("flutter_windows_glfw") {
Expand Down
29 changes: 29 additions & 0 deletions shell/platform/windows/angle_surface_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,35 @@ EGLSurface AngleSurfaceManager::CreateSurface(HWND window) {
return surface;
}

EGLSurface AngleSurfaceManager::CreateSurface(
ABI::Windows::UI::Composition::ISpriteVisual* visual) {
auto displayExtensions = eglQueryString(egl_display_, EGL_EXTENSIONS);

// Check that the EGL_ANGLE_windows_ui_composition display extension is
// available
if (strstr(displayExtensions, "EGL_ANGLE_windows_ui_composition") ==
nullptr) {
OutputDebugString(L"EGL: Composition display check failed");
}

if (visual == nullptr || !initialize_succeeded_) {
return EGL_NO_SURFACE;
}

EGLSurface surface = EGL_NO_SURFACE;

const EGLint surfaceAttributes[] = {EGL_NONE};

surface = eglCreateWindowSurface(
egl_display_, egl_config_,
static_cast<EGLNativeWindowType>((void*)visual), surfaceAttributes);
if (surface == EGL_NO_SURFACE) {
OutputDebugString(L"Surface creation failed.");
}

return surface;
}

void AngleSurfaceManager::GetSurfaceDimensions(const EGLSurface surface,
EGLint* width,
EGLint* height) {
Expand Down
6 changes: 6 additions & 0 deletions shell/platform/windows/angle_surface_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// Windows platform specific includes
#include <windows.h>
#include <windows.ui.composition.h>

namespace flutter {

Expand All @@ -33,6 +34,11 @@ class AngleSurfaceManager {
// HWND-backed window.
EGLSurface CreateSurface(HWND window);

// Creates and returns an EGLSurface wrapper and backing DirectX 11 SwapChain
// asociated with a compositor visual.
EGLSurface CreateSurface(
ABI::Windows::UI::Composition::ISpriteVisual* visual);

// queries EGL for the dimensions of surface in physical
// pixels returning width and height as out params.
void GetSurfaceDimensions(const EGLSurface surface,
Expand Down
23 changes: 18 additions & 5 deletions shell/platform/windows/client_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ import("//flutter/testing/testing.gni")

_wrapper_includes = [
"include/flutter/dart_project.h",
"include/flutter/flutter_view_controller.h",
"include/flutter/flutter_view.h",
"include/flutter/win32_flutter_view_controller.h",
"include/flutter/win32_flutter_view.h",
"include/flutter/plugin_registrar_windows.h",
"include/flutter/win32_window_pub.h",
"include/flutter/win32_flutter_window_pub.h",
"include/flutter/dpi_utils_pub.h",
]

_wrapper_sources = [ "flutter_view_controller.cc" ]
_wrapper_sources = [ "win32_flutter_view_controller.cc",
"win32_flutter_window_pub.cc",
"win32_window_pub.cc",
"dpi_utils_pub.cc",
]

# This code will be merged into .../common/cpp/client_wrapper for client use,
# so uses header paths that assume the merged state. Include the header
Expand Down Expand Up @@ -43,6 +50,8 @@ source_set("client_wrapper_windows") {
]
}



# Copies the Windows client wrapper code to the output directory.
publish_client_wrapper_extension("publish_wrapper_windows") {
public = _wrapper_includes
Expand All @@ -69,10 +78,14 @@ test_fixtures("client_wrapper_windows_fixtures") {
executable("client_wrapper_windows_unittests") {
testonly = true

cflags = ["/EHsc"]

libs = [ "windowsapp.lib", "CoreMessaging.lib" ]

sources = [
"dart_project_unittests.cc",
"flutter_view_controller_unittests.cc",
"flutter_view_unittests.cc",
"win32_flutter_view_controller_unittests.cc",
"win32_flutter_view_unittests.cc",
"plugin_registrar_windows_unittests.cc",
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "dpi_utils.h"
#include "include/flutter/dpi_utils_pub.h"

namespace flutter {

namespace {
namespace pubdpi {

constexpr UINT kDefaultDpi = 96;

Expand All @@ -22,11 +22,11 @@ bool AssignProcAddress(HMODULE comBaseModule, const char* name, T*& outProc) {

/// A helper class for abstracting various Windows DPI related functions across
/// Windows OS versions.
class Win32DpiHelper {
class Win32DpiHelperPub {
public:
Win32DpiHelper();
Win32DpiHelperPub();

~Win32DpiHelper();
~Win32DpiHelperPub();

/// Returns the DPI for |hwnd|. Supports all DPI awareness modes, and is
/// backward compatible down to Windows Vista. If |hwnd| is nullptr, returns
Expand Down Expand Up @@ -56,7 +56,7 @@ class Win32DpiHelper {
bool dpi_for_monitor_supported_ = false;
};

Win32DpiHelper::Win32DpiHelper() {
Win32DpiHelperPub::Win32DpiHelperPub() {
if ((user32_module_ = LoadLibraryA("User32.dll")) != nullptr) {
dpi_for_window_supported_ = (AssignProcAddress(
user32_module_, "GetDpiForWindow", get_dpi_for_window_));
Expand All @@ -67,7 +67,7 @@ Win32DpiHelper::Win32DpiHelper() {
}
}

Win32DpiHelper::~Win32DpiHelper() {
Win32DpiHelperPub::~Win32DpiHelperPub() {
if (user32_module_ != nullptr) {
FreeLibrary(user32_module_);
}
Expand All @@ -76,7 +76,7 @@ Win32DpiHelper::~Win32DpiHelper() {
}
}

UINT Win32DpiHelper::GetDpiForWindow(HWND hwnd) {
UINT Win32DpiHelperPub::GetDpiForWindow(HWND hwnd) {
// GetDpiForWindow returns the DPI for any awareness mode. If not available,
// or no |hwnd| is provided, fallback to a per monitor, system, or default
// DPI.
Expand All @@ -97,7 +97,7 @@ UINT Win32DpiHelper::GetDpiForWindow(HWND hwnd) {
return dpi;
}

UINT Win32DpiHelper::GetDpiForMonitor(HMONITOR monitor) {
UINT Win32DpiHelperPub::GetDpiForMonitor(HMONITOR monitor) {
if (dpi_for_monitor_supported_) {
if (monitor == nullptr) {
const POINT target_point = {0, 0};
Expand All @@ -113,10 +113,10 @@ UINT Win32DpiHelper::GetDpiForMonitor(HMONITOR monitor) {
return kDefaultDpi;
} // namespace

Win32DpiHelper* GetHelper() {
static Win32DpiHelper* dpi_helper = new Win32DpiHelper();
Win32DpiHelperPub* GetHelper() {
static Win32DpiHelperPub* dpi_helper = new Win32DpiHelperPub();
return dpi_helper;
}

} // namespace

UINT GetDpiForHWND(HWND hwnd) {
Expand All @@ -126,4 +126,5 @@ UINT GetDpiForHWND(HWND hwnd) {
UINT GetDpiForMonitor(HMONITOR monitor) {
return GetHelper()->GetDpiForMonitor(monitor);
}
} // namespace pubdpi
} // namespace flutter
82 changes: 0 additions & 82 deletions shell/platform/windows/client_wrapper/flutter_view_controller.cc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DartProject {
// flexible options for project structures are needed later without it
// being a breaking change. Provide access to internal classes that need
// them.
friend class FlutterViewController;
friend class Win32FlutterViewController;
friend class DartProjectTest;

const std::wstring& assets_path() const { return assets_path_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define FLUTTER_SHELL_PLATFORM_WINDOWS_DPI_UTILS_H_

namespace flutter {
namespace pubdpi {

/// Returns the DPI for |hwnd|. Supports all DPI awareness modes, and is
/// backward compatible down to Windows Vista. If |hwnd| is nullptr, returns the
Expand All @@ -18,7 +19,7 @@ UINT GetDpiForHWND(HWND hwnd);
/// Returns the DPI of a given monitor. Defaults to 96 if the API is not
/// available.
UINT GetDpiForMonitor(HMONITOR monitor);

} // namespace pubdpi
} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_DPI_UTILS_H_
Loading