Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b3bde1d9
Unverified
Commit
b3bde1d9
authored
Jun 07, 2021
by
Jason Simmons
Committed by
GitHub
Jun 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the Windows runner for Gallery (#84020)
parent
190a1a4a
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
90 additions
and
133 deletions
+90
-133
CMakeLists.txt
...tion_tests/flutter_gallery/windows/flutter/CMakeLists.txt
+2
-0
generated_plugin_registrant.cc
...er_gallery/windows/flutter/generated_plugin_registrant.cc
+2
-0
generated_plugin_registrant.h
...ter_gallery/windows/flutter/generated_plugin_registrant.h
+2
-0
CMakeLists.txt
...ation_tests/flutter_gallery/windows/runner/CMakeLists.txt
+0
-1
Runner.rc
...ntegration_tests/flutter_gallery/windows/runner/Runner.rc
+12
-2
flutter_window.cpp
...n_tests/flutter_gallery/windows/runner/flutter_window.cpp
+3
-6
flutter_window.h
...ion_tests/flutter_gallery/windows/runner/flutter_window.h
+2
-8
main.cpp
...integration_tests/flutter_gallery/windows/runner/main.cpp
+12
-5
run_loop.cpp
...gration_tests/flutter_gallery/windows/runner/run_loop.cpp
+0
-66
run_loop.h
...tegration_tests/flutter_gallery/windows/runner/run_loop.h
+0
-44
utils.cpp
...ntegration_tests/flutter_gallery/windows/runner/utils.cpp
+42
-0
utils.h
dev/integration_tests/flutter_gallery/windows/runner/utils.h
+11
-0
win32_window.cpp
...ion_tests/flutter_gallery/windows/runner/win32_window.cpp
+2
-1
No files found.
dev/integration_tests/flutter_gallery/windows/flutter/CMakeLists.txt
View file @
b3bde1d9
...
...
@@ -23,6 +23,7 @@ list(APPEND FLUTTER_LIBRARY_HEADERS
"flutter_windows.h"
"flutter_messenger.h"
"flutter_plugin_registrar.h"
"flutter_texture_registrar.h"
)
list
(
TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND
"
${
EPHEMERAL_DIR
}
/"
)
add_library
(
flutter INTERFACE
)
...
...
@@ -91,6 +92,7 @@ add_custom_command(
${
FLUTTER_TOOL_ENVIRONMENT
}
"
${
FLUTTER_ROOT
}
/packages/flutter_tools/bin/tool_backend.bat"
windows-x64 $<CONFIG>
VERBATIM
)
add_custom_target
(
flutter_assemble DEPENDS
"
${
FLUTTER_LIBRARY
}
"
...
...
dev/integration_tests/flutter_gallery/windows/flutter/generated_plugin_registrant.cc
View file @
b3bde1d9
...
...
@@ -2,6 +2,8 @@
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
#include <url_launcher_windows/url_launcher_plugin.h>
...
...
dev/integration_tests/flutter_gallery/windows/flutter/generated_plugin_registrant.h
View file @
b3bde1d9
...
...
@@ -2,6 +2,8 @@
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
...
...
dev/integration_tests/flutter_gallery/windows/runner/CMakeLists.txt
View file @
b3bde1d9
...
...
@@ -4,7 +4,6 @@ project(runner LANGUAGES CXX)
add_executable
(
${
BINARY_NAME
}
WIN32
"flutter_window.cpp"
"main.cpp"
"run_loop.cpp"
"utils.cpp"
"win32_window.cpp"
"
${
FLUTTER_MANAGED_DIR
}
/generated_plugin_registrant.cc"
...
...
dev/integration_tests/flutter_gallery/windows/runner/Runner.rc
View file @
b3bde1d9
...
...
@@ -45,6 +45,16 @@ END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
// IDI_APP_ICON ICON "resources\\app_icon.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Version
...
...
@@ -79,11 +89,11 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "
io.flutter.demo
" "\0"
VALUE "CompanyName", "
com.example
" "\0"
VALUE "FileDescription", "A new Flutter project." "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "flutter_gallery" "\0"
VALUE "LegalCopyright", "Copyright (C) 202
0 io.flutter.demo
. All rights reserved." "\0"
VALUE "LegalCopyright", "Copyright (C) 202
1 com.example
. All rights reserved." "\0"
VALUE "OriginalFilename", "flutter_gallery.exe" "\0"
VALUE "ProductName", "flutter_gallery" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
...
...
dev/integration_tests/flutter_gallery/windows/runner/flutter_window.cpp
View file @
b3bde1d9
...
...
@@ -4,9 +4,8 @@
#include "flutter/generated_plugin_registrant.h"
FlutterWindow
::
FlutterWindow
(
RunLoop
*
run_loop
,
const
flutter
::
DartProject
&
project
)
:
run_loop_
(
run_loop
),
project_
(
project
)
{}
FlutterWindow
::
FlutterWindow
(
const
flutter
::
DartProject
&
project
)
:
project_
(
project
)
{}
FlutterWindow
::~
FlutterWindow
()
{}
...
...
@@ -26,14 +25,12 @@ bool FlutterWindow::OnCreate() {
return
false
;
}
RegisterPlugins
(
flutter_controller_
->
engine
());
run_loop_
->
RegisterFlutterInstance
(
flutter_controller_
->
engine
());
SetChildContent
(
flutter_controller_
->
view
()
->
GetNativeWindow
());
return
true
;
}
void
FlutterWindow
::
OnDestroy
()
{
if
(
flutter_controller_
)
{
run_loop_
->
UnregisterFlutterInstance
(
flutter_controller_
->
engine
());
flutter_controller_
=
nullptr
;
}
...
...
@@ -44,7 +41,7 @@ LRESULT
FlutterWindow
::
MessageHandler
(
HWND
hwnd
,
UINT
const
message
,
WPARAM
const
wparam
,
LPARAM
const
lparam
)
noexcept
{
// Give Flutter, including plugins, an oppor
u
tunity to handle window messages.
// Give Flutter, including plugins, an opportunity to handle window messages.
if
(
flutter_controller_
)
{
std
::
optional
<
LRESULT
>
result
=
flutter_controller_
->
HandleTopLevelWindowProc
(
hwnd
,
message
,
wparam
,
...
...
dev/integration_tests/flutter_gallery/windows/runner/flutter_window.h
View file @
b3bde1d9
...
...
@@ -10,16 +10,13 @@
#include <memory>
#include "run_loop.h"
#include "win32_window.h"
// A window that does nothing but host a Flutter view.
class
FlutterWindow
:
public
Win32Window
{
public
:
// Creates a new FlutterWindow driven by the |run_loop|, hosting a
// Flutter view running |project|.
explicit
FlutterWindow
(
RunLoop
*
run_loop
,
const
flutter
::
DartProject
&
project
);
// Creates a new FlutterWindow hosting a Flutter view running |project|.
explicit
FlutterWindow
(
const
flutter
::
DartProject
&
project
);
virtual
~
FlutterWindow
();
protected
:
...
...
@@ -30,9 +27,6 @@ class FlutterWindow : public Win32Window {
LPARAM
const
lparam
)
noexcept
override
;
private
:
// The run loop driving events for this window.
RunLoop
*
run_loop_
;
// The project to run.
flutter
::
DartProject
project_
;
...
...
dev/integration_tests/flutter_gallery/windows/runner/main.cpp
View file @
b3bde1d9
...
...
@@ -3,7 +3,6 @@
#include <windows.h>
#include "flutter_window.h"
#include "run_loop.h"
#include "utils.h"
int
APIENTRY
wWinMain
(
_In_
HINSTANCE
instance
,
_In_opt_
HINSTANCE
prev
,
...
...
@@ -18,10 +17,14 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
// plugins.
::
CoInitializeEx
(
nullptr
,
COINIT_APARTMENTTHREADED
);
RunLoop
run_loop
;
flutter
::
DartProject
project
(
L"data"
);
FlutterWindow
window
(
&
run_loop
,
project
);
std
::
vector
<
std
::
string
>
command_line_arguments
=
GetCommandLineArguments
();
project
.
set_dart_entrypoint_arguments
(
std
::
move
(
command_line_arguments
));
FlutterWindow
window
(
project
);
Win32Window
::
Point
origin
(
10
,
10
);
Win32Window
::
Size
size
(
1280
,
720
);
if
(
!
window
.
CreateAndShow
(
L"flutter_gallery"
,
origin
,
size
))
{
...
...
@@ -29,7 +32,11 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
}
window
.
SetQuitOnClose
(
true
);
run_loop
.
Run
();
::
MSG
msg
;
while
(
::
GetMessage
(
&
msg
,
nullptr
,
0
,
0
))
{
::
TranslateMessage
(
&
msg
);
::
DispatchMessage
(
&
msg
);
}
::
CoUninitialize
();
return
EXIT_SUCCESS
;
...
...
dev/integration_tests/flutter_gallery/windows/runner/run_loop.cpp
deleted
100644 → 0
View file @
190a1a4a
#include "run_loop.h"
#include <windows.h>
#include <algorithm>
RunLoop
::
RunLoop
()
{}
RunLoop
::~
RunLoop
()
{}
void
RunLoop
::
Run
()
{
bool
keep_running
=
true
;
TimePoint
next_flutter_event_time
=
TimePoint
::
clock
::
now
();
while
(
keep_running
)
{
std
::
chrono
::
nanoseconds
wait_duration
=
std
::
max
(
std
::
chrono
::
nanoseconds
(
0
),
next_flutter_event_time
-
TimePoint
::
clock
::
now
());
::
MsgWaitForMultipleObjects
(
0
,
nullptr
,
FALSE
,
static_cast
<
DWORD
>
(
wait_duration
.
count
()
/
1000
),
QS_ALLINPUT
);
bool
processed_events
=
false
;
MSG
message
;
// All pending Windows messages must be processed; MsgWaitForMultipleObjects
// won't return again for items left in the queue after PeekMessage.
while
(
::
PeekMessage
(
&
message
,
nullptr
,
0
,
0
,
PM_REMOVE
))
{
processed_events
=
true
;
if
(
message
.
message
==
WM_QUIT
)
{
keep_running
=
false
;
break
;
}
::
TranslateMessage
(
&
message
);
::
DispatchMessage
(
&
message
);
// Allow Flutter to process messages each time a Windows message is
// processed, to prevent starvation.
next_flutter_event_time
=
std
::
min
(
next_flutter_event_time
,
ProcessFlutterMessages
());
}
// If the PeekMessage loop didn't run, process Flutter messages.
if
(
!
processed_events
)
{
next_flutter_event_time
=
std
::
min
(
next_flutter_event_time
,
ProcessFlutterMessages
());
}
}
}
void
RunLoop
::
RegisterFlutterInstance
(
flutter
::
FlutterEngine
*
flutter_instance
)
{
flutter_instances_
.
insert
(
flutter_instance
);
}
void
RunLoop
::
UnregisterFlutterInstance
(
flutter
::
FlutterEngine
*
flutter_instance
)
{
flutter_instances_
.
erase
(
flutter_instance
);
}
RunLoop
::
TimePoint
RunLoop
::
ProcessFlutterMessages
()
{
TimePoint
next_event_time
=
TimePoint
::
max
();
for
(
auto
instance
:
flutter_instances_
)
{
std
::
chrono
::
nanoseconds
wait_duration
=
instance
->
ProcessMessages
();
if
(
wait_duration
!=
std
::
chrono
::
nanoseconds
::
max
())
{
next_event_time
=
std
::
min
(
next_event_time
,
TimePoint
::
clock
::
now
()
+
wait_duration
);
}
}
return
next_event_time
;
}
dev/integration_tests/flutter_gallery/windows/runner/run_loop.h
deleted
100644 → 0
View file @
190a1a4a
// Copyright 2014 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 RUNNER_RUN_LOOP_H_
#define RUNNER_RUN_LOOP_H_
#include <flutter/flutter_engine.h>
#include <chrono>
#include <set>
// A runloop that will service events for Flutter instances as well
// as native messages.
class
RunLoop
{
public
:
RunLoop
();
~
RunLoop
();
// Prevent copying
RunLoop
(
RunLoop
const
&
)
=
delete
;
RunLoop
&
operator
=
(
RunLoop
const
&
)
=
delete
;
// Runs the run loop until the application quits.
void
Run
();
// Registers the given Flutter instance for event servicing.
void
RegisterFlutterInstance
(
flutter
::
FlutterEngine
*
flutter_instance
);
// Unregisters the given Flutter instance from event servicing.
void
UnregisterFlutterInstance
(
flutter
::
FlutterEngine
*
flutter_instance
);
private
:
using
TimePoint
=
std
::
chrono
::
steady_clock
::
time_point
;
// Processes all currently pending messages for registered Flutter instances.
TimePoint
ProcessFlutterMessages
();
std
::
set
<
flutter
::
FlutterEngine
*>
flutter_instances_
;
};
#endif // RUNNER_RUN_LOOP_H_
dev/integration_tests/flutter_gallery/windows/runner/utils.cpp
View file @
b3bde1d9
...
...
@@ -20,3 +20,45 @@ void CreateAndAttachConsole() {
FlutterDesktopResyncOutputStreams
();
}
}
std
::
vector
<
std
::
string
>
GetCommandLineArguments
()
{
// Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
int
argc
;
wchar_t
**
argv
=
::
CommandLineToArgvW
(
::
GetCommandLineW
(),
&
argc
);
if
(
argv
==
nullptr
)
{
return
std
::
vector
<
std
::
string
>
();
}
std
::
vector
<
std
::
string
>
command_line_arguments
;
// Skip the first argument as it's the binary name.
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
command_line_arguments
.
push_back
(
Utf8FromUtf16
(
argv
[
i
]));
}
::
LocalFree
(
argv
);
return
command_line_arguments
;
}
std
::
string
Utf8FromUtf16
(
const
wchar_t
*
utf16_string
)
{
if
(
utf16_string
==
nullptr
)
{
return
std
::
string
();
}
int
target_length
=
::
WideCharToMultiByte
(
CP_UTF8
,
WC_ERR_INVALID_CHARS
,
utf16_string
,
-
1
,
nullptr
,
0
,
nullptr
,
nullptr
);
if
(
target_length
==
0
)
{
return
std
::
string
();
}
std
::
string
utf8_string
;
utf8_string
.
resize
(
target_length
);
int
converted_length
=
::
WideCharToMultiByte
(
CP_UTF8
,
WC_ERR_INVALID_CHARS
,
utf16_string
,
-
1
,
utf8_string
.
data
(),
target_length
,
nullptr
,
nullptr
);
if
(
converted_length
==
0
)
{
return
std
::
string
();
}
return
utf8_string
;
}
dev/integration_tests/flutter_gallery/windows/runner/utils.h
View file @
b3bde1d9
...
...
@@ -5,8 +5,19 @@
#ifndef RUNNER_UTILS_H_
#define RUNNER_UTILS_H_
#include <string>
#include <vector>
// Creates a console for the process, and redirects stdout and stderr to
// it for both the runner and the Flutter library.
void
CreateAndAttachConsole
();
// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
// encoded in UTF-8. Returns an empty std::string on failure.
std
::
string
Utf8FromUtf16
(
const
wchar_t
*
utf16_string
);
// Gets the command line arguments passed in as a std::vector<std::string>,
// encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
std
::
vector
<
std
::
string
>
GetCommandLineArguments
();
#endif // RUNNER_UTILS_H_
dev/integration_tests/flutter_gallery/windows/runner/win32_window.cpp
View file @
b3bde1d9
...
...
@@ -173,7 +173,7 @@ Win32Window::MessageHandler(HWND hwnd,
return
0
;
}
case
WM_SIZE
:
case
WM_SIZE
:
{
RECT
rect
=
GetClientArea
();
if
(
child_content_
!=
nullptr
)
{
// Size and position the child window.
...
...
@@ -181,6 +181,7 @@ Win32Window::MessageHandler(HWND hwnd,
rect
.
bottom
-
rect
.
top
,
TRUE
);
}
return
0
;
}
case
WM_ACTIVATE
:
if
(
child_content_
!=
nullptr
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment