Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
da82361d
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
未验证
提交
da82361d
编写于
6月 25, 2019
作者:
D
Dan Field
提交者:
GitHub
6月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Purge caches on low memory on iOS (#9491)
上级
3122ecc6
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
55 addition
and
11 deletion
+55
-11
shell/common/rasterizer.cc
shell/common/rasterizer.cc
+13
-0
shell/common/rasterizer.h
shell/common/rasterizer.h
+5
-0
shell/common/shell.cc
shell/common/shell.cc
+11
-0
shell/common/shell.h
shell/common/shell.h
+7
-0
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
+19
-0
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
...form/darwin/ios/framework/Source/FlutterViewController.mm
+0
-11
未找到文件。
shell/common/rasterizer.cc
浏览文件 @
da82361d
...
...
@@ -68,6 +68,19 @@ void Rasterizer::Teardown() {
last_layer_tree_
.
reset
();
}
void
Rasterizer
::
NotifyLowMemoryWarning
()
const
{
if
(
!
surface_
)
{
FML_DLOG
(
INFO
)
<<
"Rasterizer::PurgeCaches called with no surface."
;
return
;
}
auto
context
=
surface_
->
GetContext
();
if
(
!
context
)
{
FML_DLOG
(
INFO
)
<<
"Rasterizer::PurgeCaches called with no GrContext."
;
return
;
}
context
->
freeGpuResources
();
}
flutter
::
TextureRegistry
*
Rasterizer
::
GetTextureRegistry
()
{
return
&
compositor_context_
->
texture_registry
();
}
...
...
shell/common/rasterizer.h
浏览文件 @
da82361d
...
...
@@ -46,6 +46,11 @@ class Rasterizer final : public SnapshotDelegate {
void
Teardown
();
// Frees up Skia GPU resources.
//
// This method must be called from the GPU task runner.
void
NotifyLowMemoryWarning
()
const
;
fml
::
WeakPtr
<
Rasterizer
>
GetWeakPtr
()
const
;
fml
::
WeakPtr
<
SnapshotDelegate
>
GetSnapshotDelegate
()
const
;
...
...
shell/common/shell.cc
浏览文件 @
da82361d
...
...
@@ -369,6 +369,17 @@ Shell::~Shell() {
platform_latch
.
Wait
();
}
void
Shell
::
NotifyLowMemoryWarning
()
const
{
task_runners_
.
GetGPUTaskRunner
()
->
PostTask
(
[
rasterizer
=
rasterizer_
->
GetWeakPtr
()]()
{
if
(
rasterizer
)
{
rasterizer
->
NotifyLowMemoryWarning
();
}
});
// The IO Manager uses resource cache limits of 0, so it is not necessary
// to purge them.
}
bool
Shell
::
IsSetup
()
const
{
return
is_setup_
;
}
...
...
shell/common/shell.h
浏览文件 @
da82361d
...
...
@@ -78,6 +78,13 @@ class Shell final : public PlatformView::Delegate,
DartVM
*
GetDartVM
();
// Embedders should call this under low memory conditions to free up
// internal caches used.
//
// This method posts a task to the GPU threads to signal the Rasterizer to
// free resources.
void
NotifyLowMemoryWarning
()
const
;
bool
IsSetup
()
const
;
Rasterizer
::
Screenshot
Screenshot
(
Rasterizer
::
ScreenshotType
type
,
...
...
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
浏览文件 @
da82361d
...
...
@@ -93,11 +93,21 @@
[
self
setupChannels
];
NSNotificationCenter
*
center
=
[
NSNotificationCenter
defaultCenter
];
[
center
addObserver
:
self
selector:
@selector
(
onMemoryWarning
:)
name:
UIApplicationDidReceiveMemoryWarningNotification
object:
nil
];
return
self
;
}
-
(
void
)
dealloc
{
[
_pluginPublications
release
];
NSNotificationCenter
*
center
=
[
NSNotificationCenter
defaultCenter
];
[
center
removeObserver
:
self
name
:
UIApplicationDidReceiveMemoryWarningNotification
object
:
nil
];
[
super
dealloc
];
}
...
...
@@ -574,6 +584,15 @@
return
_pluginPublications
[
pluginKey
];
}
#pragma mark - Memory Notifications
-
(
void
)
onMemoryWarning
:(
NSNotification
*
)
notification
{
if
(
_shell
)
{
_shell
->
NotifyLowMemoryWarning
();
}
[
_systemChannel
sendMessage
:@{
@"type"
:
@"memoryPressure"
}];
}
@end
@implementation
FlutterEngineRegistrar
{
...
...
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
浏览文件 @
da82361d
...
...
@@ -208,11 +208,6 @@ NSNotificationName const FlutterSemanticsUpdateNotification = @"FlutterSemantics
name:
UIAccessibilityBoldTextStatusDidChangeNotification
object:
nil
];
[
center
addObserver
:
self
selector:
@selector
(
onMemoryWarning
:)
name:
UIApplicationDidReceiveMemoryWarningNotification
object:
nil
];
[
center
addObserver
:
self
selector:
@selector
(
onUserSettingsChanged
:)
name:
UIContentSizeCategoryDidChangeNotification
...
...
@@ -794,12 +789,6 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch)
#endif
}
#pragma mark - Memory Notifications
-
(
void
)
onMemoryWarning
:(
NSNotification
*
)
notification
{
[[
_engine
.
get
()
systemChannel
]
sendMessage
:@{
@"type"
:
@"memoryPressure"
}];
}
#pragma mark - Locale updates
-
(
void
)
onLocaleUpdated
:(
NSNotification
*
)
notification
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录