Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
f6162dc7
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f6162dc7
编写于
1月 19, 2021
作者:
K
Kaushik Iska
提交者:
GitHub
1月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[windows] Enable smooth resizing on windows (#23701)
上级
eb031d35
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
124 addition
and
9 deletion
+124
-9
shell/platform/windows/BUILD.gn
shell/platform/windows/BUILD.gn
+2
-0
shell/platform/windows/flutter_windows_engine.cc
shell/platform/windows/flutter_windows_engine.cc
+11
-1
shell/platform/windows/flutter_windows_view.cc
shell/platform/windows/flutter_windows_view.cc
+55
-4
shell/platform/windows/flutter_windows_view.h
shell/platform/windows/flutter_windows_view.h
+40
-2
shell/platform/windows/win32_flutter_window.cc
shell/platform/windows/win32_flutter_window.cc
+7
-0
shell/platform/windows/win32_flutter_window.h
shell/platform/windows/win32_flutter_window.h
+3
-0
shell/platform/windows/window_binding_handler.h
shell/platform/windows/window_binding_handler.h
+3
-0
shell/platform/windows/window_binding_handler_delegate.h
shell/platform/windows/window_binding_handler_delegate.h
+3
-2
未找到文件。
shell/platform/windows/BUILD.gn
浏览文件 @
f6162dc7
...
...
@@ -102,6 +102,8 @@ source_set("flutter_windows_source") {
"win32_window_proc_delegate_manager.cc",
"win32_window_proc_delegate_manager.h",
]
libs = [ "dwmapi.lib" ]
}
configs += [
...
...
shell/platform/windows/flutter_windows_engine.cc
浏览文件 @
f6162dc7
...
...
@@ -50,7 +50,17 @@ FlutterRendererConfig GetRendererConfig() {
}
return
host
->
view
()
->
SwapBuffers
();
};
config
.
open_gl
.
fbo_callback
=
[](
void
*
user_data
)
->
uint32_t
{
return
0
;
};
config
.
open_gl
.
fbo_reset_after_present
=
true
;
config
.
open_gl
.
fbo_with_frame_info_callback
=
[](
void
*
user_data
,
const
FlutterFrameInfo
*
info
)
->
uint32_t
{
auto
host
=
static_cast
<
FlutterWindowsEngine
*>
(
user_data
);
if
(
host
->
view
())
{
return
host
->
view
()
->
GetFrameBufferId
(
info
->
size
.
width
,
info
->
size
.
height
);
}
else
{
return
kWindowFrameBufferID
;
}
};
config
.
open_gl
.
gl_proc_resolver
=
[](
void
*
user_data
,
const
char
*
what
)
->
void
*
{
return
reinterpret_cast
<
void
*>
(
eglGetProcAddress
(
what
));
...
...
shell/platform/windows/flutter_windows_view.cc
浏览文件 @
f6162dc7
...
...
@@ -49,10 +49,41 @@ void FlutterWindowsView::SetEngine(
binding_handler_
->
GetDpiScale
());
}
void
FlutterWindowsView
::
OnWindowSizeChanged
(
size_t
width
,
size_t
height
)
const
{
uint32_t
FlutterWindowsView
::
GetFrameBufferId
(
size_t
width
,
size_t
height
)
{
// Called on an engine-controlled (non-platform) thread.
std
::
unique_lock
<
std
::
mutex
>
lock
(
resize_mutex_
);
if
(
resize_status_
!=
ResizeState
::
kResizeStarted
)
{
return
kWindowFrameBufferID
;
}
if
(
resize_target_width_
==
width
&&
resize_target_height_
==
height
)
{
// Platform thread is blocked for the entire duration until the
// resize_status_ is set to kDone.
surface_manager_
->
ResizeSurface
(
GetRenderTarget
(),
width
,
height
);
surface_manager_
->
MakeCurrent
();
resize_status_
=
ResizeState
::
kFrameGenerated
;
}
return
kWindowFrameBufferID
;
}
void
FlutterWindowsView
::
OnWindowSizeChanged
(
size_t
width
,
size_t
height
)
{
// Called on the platform thread.
std
::
unique_lock
<
std
::
mutex
>
lock
(
resize_mutex_
);
resize_status_
=
ResizeState
::
kResizeStarted
;
resize_target_width_
=
width
;
resize_target_height_
=
height
;
SendWindowMetrics
(
width
,
height
,
binding_handler_
->
GetDpiScale
());
if
(
width
>
0
&&
height
>
0
)
{
// Block the platform thread until:
// 1. GetFrameBufferId is called with the right frame size.
// 2. Any pending SwapBuffers calls have been invoked.
resize_cv_
.
wait
(
lock
,
[
&
resize_status
=
resize_status_
]
{
return
resize_status
==
ResizeState
::
kDone
;
});
}
}
void
FlutterWindowsView
::
OnPointerMove
(
double
x
,
double
y
)
{
...
...
@@ -255,7 +286,27 @@ bool FlutterWindowsView::ClearContext() {
}
bool
FlutterWindowsView
::
SwapBuffers
()
{
// Called on an engine-controlled (non-platform) thread.
std
::
unique_lock
<
std
::
mutex
>
lock
(
resize_mutex_
);
switch
(
resize_status_
)
{
// SwapBuffer requests during resize are ignored until the frame with the
// right dimensions has been generated. This is marked with
// kFrameGenerated resize status.
case
ResizeState
::
kResizeStarted
:
return
false
;
case
ResizeState
::
kFrameGenerated
:
{
bool
swap_buffers_result
=
surface_manager_
->
SwapBuffers
();
resize_status_
=
ResizeState
::
kDone
;
lock
.
unlock
();
resize_cv_
.
notify_all
();
binding_handler_
->
OnWindowResized
();
return
swap_buffers_result
;
}
case
ResizeState
::
kDone
:
default:
return
surface_manager_
->
SwapBuffers
();
}
}
void
FlutterWindowsView
::
CreateRenderSurface
()
{
...
...
shell/platform/windows/flutter_windows_view.h
浏览文件 @
f6162dc7
...
...
@@ -8,6 +8,7 @@
#include <windowsx.h>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
...
...
@@ -27,6 +28,9 @@
namespace
flutter
{
// ID for the window frame buffer.
inline
constexpr
uint32_t
kWindowFrameBufferID
=
0
;
// An OS-windowing neutral abstration for flutter
// view that works with win32 hwnds and Windows::UI::Composition visuals.
class
FlutterWindowsView
:
public
WindowBindingHandlerDelegate
{
...
...
@@ -57,7 +61,8 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate {
// Returns the engine backing this view.
FlutterWindowsEngine
*
GetEngine
();
// Callbacks for clearing context, settings context and swapping buffers.
// Callbacks for clearing context, settings context and swapping buffers,
// these are typically called on an engine-controlled (non-platform) thread.
bool
ClearContext
();
bool
MakeCurrent
();
bool
MakeResourceCurrent
();
...
...
@@ -66,8 +71,11 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate {
// Send initial bounds to embedder. Must occur after engine has initialized.
void
SendInitialBounds
();
// Returns the frame buffer id for the engine to render to.
uint32_t
GetFrameBufferId
(
size_t
width
,
size_t
height
);
// |WindowBindingHandlerDelegate|
void
OnWindowSizeChanged
(
size_t
width
,
size_t
height
)
const
override
;
void
OnWindowSizeChanged
(
size_t
width
,
size_t
height
)
override
;
// |WindowBindingHandlerDelegate|
void
OnPointerMove
(
double
x
,
double
y
)
override
;
...
...
@@ -115,6 +123,19 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate {
uint64_t
buttons
=
0
;
};
// States a resize event can be in.
enum
class
ResizeState
{
// When a resize event has started but is in progress.
kResizeStarted
,
// After a resize event starts and the framework has been notified to
// generate a frame for the right size.
kFrameGenerated
,
// Default state for when no resize is in progress. Also used to indicate
// that during a resize event, a frame with the right size has been rendered
// and the buffers have been swapped.
kDone
,
};
// Sends a window metrics update to the Flutter engine using current window
// dimensions in physical
void
SendWindowMetrics
(
size_t
width
,
size_t
height
,
double
dpiscale
)
const
;
...
...
@@ -206,6 +227,23 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate {
// Currently configured WindowBindingHandler for view.
std
::
unique_ptr
<
flutter
::
WindowBindingHandler
>
binding_handler_
;
// Resize events are synchronized using this mutex and the corresponding
// condition variable.
std
::
mutex
resize_mutex_
;
std
::
condition_variable
resize_cv_
;
// Indicates the state of a window resize event. Platform thread will be
// blocked while this is not done. Guarded by resize_mutex_.
ResizeState
resize_status_
=
ResizeState
::
kDone
;
// Target for the window width. Valid when resize_pending_ is set. Guarded by
// resize_mutex_.
size_t
resize_target_width_
=
0
;
// Target for the window width. Valid when resize_pending_ is set. Guarded by
// resize_mutex_.
size_t
resize_target_height_
=
0
;
};
}
// namespace flutter
...
...
shell/platform/windows/win32_flutter_window.cc
浏览文件 @
f6162dc7
...
...
@@ -4,6 +4,7 @@
#include "flutter/shell/platform/windows/win32_flutter_window.h"
#include <dwmapi.h>
#include <chrono>
#include <map>
...
...
@@ -92,6 +93,12 @@ void Win32FlutterWindow::UpdateFlutterCursor(const std::string& cursor_name) {
current_cursor_
=
GetCursorByName
(
cursor_name
);
}
void
Win32FlutterWindow
::
OnWindowResized
()
{
// Blocking the raster thread until DWM flushes alleviates glitches where
// previous size surface is stretched over current size view.
DwmFlush
();
}
// Translates button codes from Win32 API to FlutterPointerMouseButtons.
static
uint64_t
ConvertWinButtonToFlutterButton
(
UINT
button
)
{
switch
(
button
)
{
...
...
shell/platform/windows/win32_flutter_window.h
浏览文件 @
f6162dc7
...
...
@@ -74,6 +74,9 @@ class Win32FlutterWindow : public Win32Window, public WindowBindingHandler {
// |FlutterWindowBindingHandler|
void
UpdateFlutterCursor
(
const
std
::
string
&
cursor_name
)
override
;
// |FlutterWindowBindingHandler|
void
OnWindowResized
()
override
;
private:
// A pointer to a FlutterWindowsView that can be used to update engine
// windowing and input state.
...
...
shell/platform/windows/window_binding_handler.h
浏览文件 @
f6162dc7
...
...
@@ -45,6 +45,9 @@ class WindowBindingHandler {
// Returns the bounds of the backing window in physical pixels.
virtual
PhysicalWindowBounds
GetPhysicalWindowBounds
()
=
0
;
// Invoked after the window has been resized.
virtual
void
OnWindowResized
()
=
0
;
// Sets the cursor that should be used when the mouse is over the Flutter
// content. See mouse_cursor.dart for the values and meanings of cursor_name.
virtual
void
UpdateFlutterCursor
(
const
std
::
string
&
cursor_name
)
=
0
;
...
...
shell/platform/windows/window_binding_handler_delegate.h
浏览文件 @
f6162dc7
...
...
@@ -12,8 +12,9 @@ namespace flutter {
class
WindowBindingHandlerDelegate
{
public:
// Notifies delegate that backing window size has changed.
// Typically called by currently configured WindowBindingHandler
virtual
void
OnWindowSizeChanged
(
size_t
width
,
size_t
height
)
const
=
0
;
// Typically called by currently configured WindowBindingHandler, this is
// called on the platform thread.
virtual
void
OnWindowSizeChanged
(
size_t
width
,
size_t
height
)
=
0
;
// Notifies delegate that backing window mouse has moved.
// Typically called by currently configured WindowBindingHandler
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录