Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
9eaedb06
E
engine
项目概览
liujiuri
/
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,发现更多精彩内容 >>
提交
9eaedb06
编写于
10月 27, 2016
作者:
A
Adam Barth
提交者:
GitHub
10月 27, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Migrate ViewportMetrics away from Mojo (#3180)
Now we just pass the data directly.
上级
5be8ae80
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
169 addition
and
91 deletion
+169
-91
content_handler/runtime_holder.cc
content_handler/runtime_holder.cc
+6
-7
content_handler/runtime_holder.h
content_handler/runtime_holder.h
+2
-2
lib/ui/BUILD.gn
lib/ui/BUILD.gn
+1
-0
lib/ui/window/viewport_metrics.h
lib/ui/window/viewport_metrics.h
+24
-0
lib/ui/window/window.cc
lib/ui/window/window.cc
+8
-8
lib/ui/window/window.h
lib/ui/window/window.h
+2
-2
runtime/runtime_controller.cc
runtime/runtime_controller.cc
+4
-11
runtime/runtime_controller.h
runtime/runtime_controller.h
+2
-2
services/engine/sky_engine.mojom
services/engine/sky_engine.mojom
+0
-13
shell/common/engine.cc
shell/common/engine.cc
+4
-7
shell/common/engine.h
shell/common/engine.h
+3
-2
shell/platform/android/io/flutter/view/FlutterView.java
shell/platform/android/io/flutter/view/FlutterView.java
+31
-3
shell/platform/android/platform_view_android.cc
shell/platform/android/platform_view_android.cc
+24
-0
shell/platform/android/platform_view_android.h
shell/platform/android/platform_view_android.h
+10
-0
shell/platform/darwin/desktop/sky_window.mm
shell/platform/darwin/desktop/sky_window.mm
+9
-5
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
...form/darwin/ios/framework/Source/FlutterViewController.mm
+19
-15
shell/platform/linux/platform_view_glfw.cc
shell/platform/linux/platform_view_glfw.cc
+8
-5
shell/testing/BUILD.gn
shell/testing/BUILD.gn
+2
-1
shell/testing/test_runner.cc
shell/testing/test_runner.cc
+9
-7
shell/testing/test_runner.h
shell/testing/test_runner.h
+1
-1
未找到文件。
content_handler/runtime_holder.cc
浏览文件 @
9eaedb06
...
...
@@ -51,8 +51,7 @@ blink::PointerData::Change GetChangeFromEventType(mozart::EventType type) {
}
// namespace
RuntimeHolder
::
RuntimeHolder
()
:
viewport_metrics_
(
sky
::
ViewportMetrics
::
New
()),
view_listener_binding_
(
this
),
:
view_listener_binding_
(
this
),
input_listener_binding_
(
this
),
weak_factory_
(
this
)
{}
...
...
@@ -130,8 +129,8 @@ void RuntimeHolder::Render(std::unique_ptr<flow::LayerTree> layer_tree) {
return
;
// Only draw once per frame.
is_ready_to_draw_
=
false
;
layer_tree
->
set_frame_size
(
SkISize
::
Make
(
viewport_metrics_
->
physical_width
,
viewport_metrics_
->
physical_height
));
layer_tree
->
set_frame_size
(
SkISize
::
Make
(
viewport_metrics_
.
physical_width
,
viewport_metrics_
.
physical_height
));
layer_tree
->
set_scene_version
(
scene_version_
);
blink
::
Threads
::
Gpu
()
->
PostTask
(
ftl
::
MakeCopyable
([
...
...
@@ -224,11 +223,11 @@ void RuntimeHolder::OnInvalidation(mozart::ViewInvalidationPtr invalidation,
// Apply view property changes.
if
(
invalidation
->
properties
)
{
view_properties_
=
std
::
move
(
invalidation
->
properties
);
viewport_metrics_
->
physical_width
=
viewport_metrics_
.
physical_width
=
view_properties_
->
view_layout
->
size
->
width
;
viewport_metrics_
->
physical_height
=
viewport_metrics_
.
physical_height
=
view_properties_
->
view_layout
->
size
->
height
;
viewport_metrics_
->
device_pixel_ratio
=
2.0
;
viewport_metrics_
.
device_pixel_ratio
=
2.0
;
// TODO(abarth): Use view_properties_->display_metrics->device_pixel_ratio
// once that's reasonable.
runtime_
->
SetViewportMetrics
(
viewport_metrics_
);
...
...
content_handler/runtime_holder.h
浏览文件 @
9eaedb06
...
...
@@ -10,9 +10,9 @@
#include "flutter/assets/unzipper_provider.h"
#include "flutter/assets/zip_asset_store.h"
#include "flutter/flow/layers/layer_tree.h"
#include "flutter/lib/ui/window/viewport_metrics.h"
#include "flutter/runtime/runtime_controller.h"
#include "flutter/runtime/runtime_delegate.h"
#include "flutter/services/engine/sky_engine.mojom.h"
#include "lib/ftl/functional/closure.h"
#include "lib/ftl/macros.h"
#include "lib/ftl/memory/weak_ptr.h"
...
...
@@ -66,7 +66,7 @@ class RuntimeHolder : public blink::RuntimeDelegate,
std
::
unique_ptr
<
Rasterizer
>
rasterizer_
;
std
::
unique_ptr
<
blink
::
RuntimeController
>
runtime_
;
sky
::
ViewportMetricsPtr
viewport_metrics_
;
blink
::
ViewportMetrics
viewport_metrics_
;
mozart
::
ViewManagerPtr
view_manager_
;
mojo
::
Binding
<
mozart
::
ViewListener
>
view_listener_binding_
;
...
...
lib/ui/BUILD.gn
浏览文件 @
9eaedb06
...
...
@@ -66,6 +66,7 @@ source_set("ui") {
"window/pointer_data.h",
"window/pointer_data_packet.cc",
"window/pointer_data_packet.h",
"window/viewport_metrics.h",
"window/window.cc",
"window/window.h",
]
...
...
lib/ui/window/viewport_metrics.h
0 → 100644
浏览文件 @
9eaedb06
// Copyright 2016 The Chromium 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 FLUTTER_LIB_UI_WINDOW_VIEWPORT_METRICS_H_
#define FLUTTER_LIB_UI_WINDOW_VIEWPORT_METRICS_H_
#include <stdint.h>
namespace
blink
{
struct
ViewportMetrics
{
float
device_pixel_ratio
=
1.0
;
int32_t
physical_width
=
0
;
int32_t
physical_height
=
0
;
int32_t
physical_padding_top
=
0
;
int32_t
physical_padding_right
=
0
;
int32_t
physical_padding_bottom
=
0
;
int32_t
physical_padding_left
=
0
;
};
}
// namespace blink
#endif // FLUTTER_LIB_UI_WINDOW_VIEWPORT_METRICS_H_
lib/ui/window/window.cc
浏览文件 @
9eaedb06
...
...
@@ -115,7 +115,7 @@ void Window::DidCreateIsolate() {
library_
.
Set
(
DartState
::
Current
(),
Dart_LookupLibrary
(
ToDart
(
"dart:ui"
)));
}
void
Window
::
UpdateWindowMetrics
(
const
sky
::
ViewportMetricsPtr
&
metrics
)
{
void
Window
::
UpdateWindowMetrics
(
const
ViewportMetrics
&
metrics
)
{
tonic
::
DartState
*
dart_state
=
library_
.
dart_state
().
get
();
if
(
!
dart_state
)
return
;
...
...
@@ -123,13 +123,13 @@ void Window::UpdateWindowMetrics(const sky::ViewportMetricsPtr& metrics) {
DartInvokeField
(
library_
.
value
(),
"_updateWindowMetrics"
,
{
ToDart
(
metrics
->
device_pixel_ratio
),
ToDart
(
static_cast
<
double
>
(
metrics
->
physical_width
)),
ToDart
(
static_cast
<
double
>
(
metrics
->
physical_height
)),
ToDart
(
static_cast
<
double
>
(
metrics
->
physical_padding_top
)),
ToDart
(
static_cast
<
double
>
(
metrics
->
physical_padding_right
)),
ToDart
(
static_cast
<
double
>
(
metrics
->
physical_padding_bottom
)),
ToDart
(
static_cast
<
double
>
(
metrics
->
physical_padding_left
)),
ToDart
(
metrics
.
device_pixel_ratio
),
ToDart
(
static_cast
<
double
>
(
metrics
.
physical_width
)),
ToDart
(
static_cast
<
double
>
(
metrics
.
physical_height
)),
ToDart
(
static_cast
<
double
>
(
metrics
.
physical_padding_top
)),
ToDart
(
static_cast
<
double
>
(
metrics
.
physical_padding_right
)),
ToDart
(
static_cast
<
double
>
(
metrics
.
physical_padding_bottom
)),
ToDart
(
static_cast
<
double
>
(
metrics
.
physical_padding_left
)),
});
}
...
...
lib/ui/window/window.h
浏览文件 @
9eaedb06
...
...
@@ -10,7 +10,7 @@
#include "flutter/lib/ui/semantics/semantics_update.h"
#include "flutter/lib/ui/window/platform_message.h"
#include "flutter/lib/ui/window/pointer_data_packet.h"
#include "flutter/
services/engine/sky_engine.mojom
.h"
#include "flutter/
lib/ui/window/viewport_metrics
.h"
#include "lib/ftl/time/time_point.h"
#include "lib/tonic/dart_persistent_value.h"
...
...
@@ -40,7 +40,7 @@ class Window {
WindowClient
*
client
()
const
{
return
client_
;
}
void
DidCreateIsolate
();
void
UpdateWindowMetrics
(
const
sky
::
ViewportMetricsPtr
&
metrics
);
void
UpdateWindowMetrics
(
const
ViewportMetrics
&
metrics
);
void
UpdateLocale
(
const
std
::
string
&
language_code
,
const
std
::
string
&
country_code
);
void
UpdateSemanticsEnabled
(
bool
enabled
);
...
...
runtime/runtime_controller.cc
浏览文件 @
9eaedb06
...
...
@@ -40,23 +40,16 @@ void RuntimeController::CreateDartController(const std::string& script_uri) {
Window
*
window
=
GetWindow
();
if
(
viewport_metrics_
)
window
->
UpdateWindowMetrics
(
viewport_metrics_
);
window
->
UpdateWindowMetrics
(
viewport_metrics_
);
window
->
UpdateLocale
(
language_code_
,
country_code_
);
if
(
semantics_enabled_
)
window
->
UpdateSemanticsEnabled
(
semantics_enabled_
);
}
void
RuntimeController
::
SetViewportMetrics
(
const
sky
::
ViewportMetricsPtr
&
metrics
)
{
if
(
metrics
)
{
viewport_metrics_
=
metrics
->
Clone
();
GetWindow
()
->
UpdateWindowMetrics
(
viewport_metrics_
);
}
else
{
viewport_metrics_
=
nullptr
;
}
void
RuntimeController
::
SetViewportMetrics
(
const
ViewportMetrics
&
metrics
)
{
viewport_metrics_
=
metrics
;
GetWindow
()
->
UpdateWindowMetrics
(
viewport_metrics_
);
}
void
RuntimeController
::
SetLocale
(
const
std
::
string
&
language_code
,
...
...
runtime/runtime_controller.h
浏览文件 @
9eaedb06
...
...
@@ -30,7 +30,7 @@ class RuntimeController : public WindowClient, public IsolateClient {
void
CreateDartController
(
const
std
::
string
&
script_uri
);
DartController
*
dart_controller
()
const
{
return
dart_controller_
.
get
();
}
void
SetViewportMetrics
(
const
sky
::
ViewportMetricsPtr
&
metrics
);
void
SetViewportMetrics
(
const
ViewportMetrics
&
metrics
);
void
SetLocale
(
const
std
::
string
&
language_code
,
const
std
::
string
&
country_code
);
void
SetSemanticsEnabled
(
bool
enabled
);
...
...
@@ -58,7 +58,7 @@ class RuntimeController : public WindowClient, public IsolateClient {
void
DidCreateSecondaryIsolate
(
Dart_Isolate
isolate
)
override
;
RuntimeDelegate
*
client_
;
sky
::
ViewportMetricsPtr
viewport_metrics_
;
ViewportMetrics
viewport_metrics_
;
std
::
string
language_code_
;
std
::
string
country_code_
;
bool
semantics_enabled_
=
false
;
...
...
services/engine/sky_engine.mojom
浏览文件 @
9eaedb06
...
...
@@ -4,21 +4,8 @@
module sky;
struct ViewportMetrics {
float device_pixel_ratio = 1.0;
int32 physical_width;
int32 physical_height;
int32 physical_padding_top;
int32 physical_padding_right;
int32 physical_padding_bottom;
int32 physical_padding_left;
uint32 scene_version;
};
[ServiceName="sky::SkyEngine"]
interface SkyEngine {
OnViewportMetricsChanged(ViewportMetrics metrics);
RunFromFile(string main, string packages, string bundle_path);
RunFromPrecompiledSnapshot(string bundle_path);
RunFromBundle(string script_uri, string bundle_path);
...
...
shell/common/engine.cc
浏览文件 @
9eaedb06
...
...
@@ -125,8 +125,8 @@ void Engine::OnOutputSurfaceDestroyed(const ftl::Closure& gpu_continuation) {
blink
::
Threads
::
Gpu
()
->
PostTask
(
gpu_continuation
);
}
void
Engine
::
OnViewportMetricsChanged
(
sky
::
ViewportMetricsPtr
metrics
)
{
viewport_metrics_
=
metrics
.
Pass
()
;
void
Engine
::
SetViewportMetrics
(
const
blink
::
ViewportMetrics
&
metrics
)
{
viewport_metrics_
=
metrics
;
if
(
runtime_
)
runtime_
->
SetViewportMetrics
(
viewport_metrics_
);
}
...
...
@@ -341,15 +341,12 @@ void Engine::ScheduleFrame() {
void
Engine
::
Render
(
std
::
unique_ptr
<
flow
::
LayerTree
>
layer_tree
)
{
if
(
!
layer_tree
)
return
;
if
(
!
viewport_metrics_
)
return
;
SkISize
frame_size
=
SkISize
::
Make
(
viewport_metrics_
->
physical_width
,
viewport_metrics_
->
physical_height
);
SkISize
frame_size
=
SkISize
::
Make
(
viewport_metrics_
.
physical_width
,
viewport_metrics_
.
physical_height
);
if
(
frame_size
.
isEmpty
())
return
;
layer_tree
->
set_scene_version
(
viewport_metrics_
->
scene_version
);
layer_tree
->
set_frame_size
(
frame_size
);
animator_
->
Render
(
std
::
move
(
layer_tree
));
}
...
...
shell/common/engine.h
浏览文件 @
9eaedb06
...
...
@@ -8,6 +8,7 @@
#include "flutter/assets/zip_asset_store.h"
#include "flutter/glue/drain_data_pipe_job.h"
#include "flutter/lib/ui/window/platform_message.h"
#include "flutter/lib/ui/window/viewport_metrics.h"
#include "flutter/runtime/runtime_controller.h"
#include "flutter/runtime/runtime_delegate.h"
#include "flutter/services/engine/sky_engine.mojom.h"
...
...
@@ -56,6 +57,7 @@ class Engine : public sky::SkyEngine, public blink::RuntimeDelegate {
void
ConnectToEngine
(
mojo
::
InterfaceRequest
<
SkyEngine
>
request
);
void
OnOutputSurfaceCreated
(
const
ftl
::
Closure
&
gpu_continuation
);
void
OnOutputSurfaceDestroyed
(
const
ftl
::
Closure
&
gpu_continuation
);
void
SetViewportMetrics
(
const
blink
::
ViewportMetrics
&
metrics
);
void
DispatchPlatformMessage
(
ftl
::
RefPtr
<
blink
::
PlatformMessage
>
message
);
void
DispatchPointerDataPacket
(
const
PointerDataPacket
&
packet
);
void
DispatchSemanticsAction
(
int
id
,
blink
::
SemanticsAction
action
);
...
...
@@ -63,7 +65,6 @@ class Engine : public sky::SkyEngine, public blink::RuntimeDelegate {
private:
// SkyEngine implementation:
void
OnViewportMetricsChanged
(
sky
::
ViewportMetricsPtr
metrics
)
override
;
void
RunFromFile
(
const
mojo
::
String
&
main
,
const
mojo
::
String
&
packages
,
const
mojo
::
String
&
bundle
)
override
;
...
...
@@ -109,7 +110,7 @@ class Engine : public sky::SkyEngine, public blink::RuntimeDelegate {
std
::
unique_ptr
<
glue
::
DrainDataPipeJob
>
snapshot_drainer_
;
ftl
::
RefPtr
<
blink
::
PlatformMessage
>
pending_push_route_message_
;
sky
::
ViewportMetricsPtr
viewport_metrics_
;
blink
::
ViewportMetrics
viewport_metrics_
;
std
::
string
language_code_
;
std
::
string
country_code_
;
bool
semantics_enabled_
=
false
;
...
...
shell/platform/android/io/flutter/view/FlutterView.java
浏览文件 @
9eaedb06
...
...
@@ -44,7 +44,6 @@ import org.chromium.mojo.system.MojoException;
import
org.chromium.mojo.system.Pair
;
import
org.chromium.mojo.system.impl.CoreImpl
;
import
org.chromium.mojom.sky.SkyEngine
;
import
org.chromium.mojom.sky.ViewportMetrics
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteOrder
;
...
...
@@ -69,6 +68,16 @@ public class FlutterView extends SurfaceView
private
static
final
String
ACTION_DISCOVER
=
"io.flutter.view.DISCOVER"
;
class
ViewportMetrics
{
float
devicePixelRatio
=
1.0f
;
int
physicalWidth
=
0
;
int
physicalHeight
=
0
;
int
physicalPaddingTop
=
0
;
int
physicalPaddingRight
=
0
;
int
physicalPaddingBottom
=
0
;
int
physicalPaddingLeft
=
0
;
}
private
long
mNativePlatformView
;
private
TextInputPlugin
mTextInputPlugin
;
...
...
@@ -433,7 +442,7 @@ public class FlutterView extends SurfaceView
protected
void
onSizeChanged
(
int
width
,
int
height
,
int
oldWidth
,
int
oldHeight
)
{
mMetrics
.
physicalWidth
=
width
;
mMetrics
.
physicalHeight
=
height
;
mSkyEngine
.
onViewportMetricsChanged
(
mMetrics
);
updateViewportMetrics
(
);
super
.
onSizeChanged
(
width
,
height
,
oldWidth
,
oldHeight
);
}
...
...
@@ -443,7 +452,7 @@ public class FlutterView extends SurfaceView
mMetrics
.
physicalPaddingRight
=
insets
.
getSystemWindowInsetRight
();
mMetrics
.
physicalPaddingBottom
=
insets
.
getSystemWindowInsetBottom
();
mMetrics
.
physicalPaddingLeft
=
insets
.
getSystemWindowInsetLeft
();
mSkyEngine
.
onViewportMetricsChanged
(
mMetrics
);
updateViewportMetrics
(
);
return
super
.
onApplyWindowInsets
(
insets
);
}
...
...
@@ -525,6 +534,14 @@ public class FlutterView extends SurfaceView
int
width
,
int
height
);
private
static
native
void
nativeSurfaceDestroyed
(
long
nativePlatformViewAndroid
);
private
static
native
void
nativeSetViewportMetrics
(
long
nativePlatformViewAndroid
,
float
devicePixelRatio
,
int
physicalWidth
,
int
physicalHeight
,
int
physicalPaddingTop
,
int
physicalPaddingRight
,
int
physicalPaddingBottom
,
int
physicalPaddingLeft
);
private
static
native
Bitmap
nativeGetBitmap
(
long
nativePlatformViewAndroid
);
// Send a platform message to Dart.
...
...
@@ -536,6 +553,17 @@ public class FlutterView extends SurfaceView
// Send a response to a platform message received from Dart.
private
static
native
void
nativeInvokePlatformMessageResponseCallback
(
long
nativePlatformViewAndroid
,
int
responseId
,
String
message
);
private
void
updateViewportMetrics
()
{
nativeSetViewportMetrics
(
mNativePlatformView
,
mMetrics
.
devicePixelRatio
,
mMetrics
.
physicalWidth
,
mMetrics
.
physicalHeight
,
mMetrics
.
physicalPaddingTop
,
mMetrics
.
physicalPaddingRight
,
mMetrics
.
physicalPaddingBottom
,
mMetrics
.
physicalPaddingLeft
);
}
// Called by native to send us a platform message.
@CalledByNative
private
void
handlePlatformMessage
(
String
channel
,
String
message
,
final
int
responseId
)
{
...
...
shell/platform/android/platform_view_android.cc
浏览文件 @
9eaedb06
...
...
@@ -138,6 +138,30 @@ void PlatformViewAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) {
ReleaseSurface
();
}
void
PlatformViewAndroid
::
SetViewportMetrics
(
JNIEnv
*
env
,
jobject
obj
,
jfloat
device_pixel_ratio
,
jint
physical_width
,
jint
physical_height
,
jint
physical_padding_top
,
jint
physical_padding_right
,
jint
physical_padding_bottom
,
jint
physical_padding_left
)
{
blink
::
ViewportMetrics
metrics
;
metrics
.
device_pixel_ratio
=
device_pixel_ratio
;
metrics
.
physical_width
=
physical_width
;
metrics
.
physical_height
=
physical_height
;
metrics
.
physical_padding_top
=
physical_padding_top
;
metrics
.
physical_padding_right
=
physical_padding_right
;
metrics
.
physical_padding_bottom
=
physical_padding_bottom
;
metrics
.
physical_padding_left
=
physical_padding_left
;
blink
::
Threads
::
UI
()
->
PostTask
([
engine
=
engine_
->
GetWeakPtr
(),
metrics
]
{
if
(
engine
.
get
())
engine
->
SetViewportMetrics
(
metrics
);
});
}
void
PlatformViewAndroid
::
DispatchPlatformMessage
(
JNIEnv
*
env
,
jobject
obj
,
jstring
java_name
,
...
...
shell/platform/android/platform_view_android.h
浏览文件 @
9eaedb06
...
...
@@ -37,6 +37,16 @@ class PlatformViewAndroid : public PlatformView {
void
SurfaceDestroyed
(
JNIEnv
*
env
,
jobject
obj
);
void
SetViewportMetrics
(
JNIEnv
*
env
,
jobject
obj
,
jfloat
device_pixel_ratio
,
jint
physical_width
,
jint
physical_height
,
jint
physical_padding_top
,
jint
physical_padding_right
,
jint
physical_padding_bottom
,
jint
physical_padding_left
);
void
DispatchPlatformMessage
(
JNIEnv
*
env
,
jobject
obj
,
jstring
name
,
...
...
shell/platform/darwin/desktop/sky_window.mm
浏览文件 @
9eaedb06
...
...
@@ -75,13 +75,17 @@ static inline blink::PointerData::Change PointerChangeFromNSEventPhase(
-
(
void
)
updateWindowSize
{
[
self
setupSurfaceIfNecessary
];
auto
metrics
=
sky
::
ViewportMetrics
::
New
()
;
blink
::
ViewportMetrics
metrics
;
auto
size
=
self
.
renderSurface
.
frame
.
size
;
metrics
->
physical_width
=
size
.
width
;
metrics
->
physical_height
=
size
.
height
;
metrics
->
device_pixel_ratio
=
1.0
;
metrics
.
physical_width
=
size
.
width
;
metrics
.
physical_height
=
size
.
height
;
_platformView
->
engineProxy
()
->
OnViewportMetricsChanged
(
metrics
.
Pass
());
blink
::
Threads
::
UI
()
->
PostTask
(
[
engine
=
_platformView
->
engine
().
GetWeakPtr
(),
metrics
]
{
if
(
engine
.
get
())
{
engine
->
SetViewportMetrics
(
metrics
);
}
});
}
-
(
void
)
setupSurfaceIfNecessary
{
...
...
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
浏览文件 @
9eaedb06
...
...
@@ -65,7 +65,7 @@ void FlutterInit(int argc, const char* argv[]) {
base
::
scoped_nsprotocol
<
FlutterDartProject
*>
_dartProject
;
UIInterfaceOrientationMask
_orientationPreferences
;
UIStatusBarStyle
_statusBarStyle
;
sky
::
ViewportMetricsPtr
_viewportMetrics
;
blink
::
ViewportMetrics
_viewportMetrics
;
shell
::
TouchMapper
_touchMapper
;
std
::
unique_ptr
<
shell
::
PlatformViewIOS
>
_platformView
;
base
::
scoped_nsprotocol
<
FlutterPlatformPlugin
*>
_platformPlugin
;
...
...
@@ -112,7 +112,6 @@ void FlutterInit(int argc, const char* argv[]) {
_orientationPreferences
=
UIInterfaceOrientationMaskAll
;
_statusBarStyle
=
UIStatusBarStyleDefault
;
_viewportMetrics
=
sky
::
ViewportMetrics
::
New
();
_platformView
=
std
::
make_unique
<
shell
::
PlatformViewIOS
>
(
reinterpret_cast
<
CAEAGLLayer
*>
(
self
.
view
.
layer
));
_platformView
->
SetupResourceContextOnIOThread
();
...
...
@@ -329,18 +328,25 @@ static inline PointerChangeMapperPhase PointerChangePhaseFromUITouchPhase(
#pragma mark - Handle view resizing
-
(
void
)
updateViewportMetrics
{
blink
::
Threads
::
UI
()
->
PostTask
([
engine
=
_platformView
->
engine
().
GetWeakPtr
(),
metrics
=
_viewportMetrics
]
{
if
(
engine
.
get
())
engine
->
SetViewportMetrics
(
metrics
);
});
}
-
(
void
)
viewDidLayoutSubviews
{
CGSize
size
=
self
.
view
.
bounds
.
size
;
CGFloat
scale
=
[
UIScreen
mainScreen
].
scale
;
_viewportMetrics
->
device_pixel_ratio
=
scale
;
_viewportMetrics
->
physical_width
=
size
.
width
*
scale
;
_viewportMetrics
->
physical_height
=
size
.
height
*
scale
;
_viewportMetrics
->
physical_padding_top
=
_viewportMetrics
.
device_pixel_ratio
=
scale
;
_viewportMetrics
.
physical_width
=
size
.
width
*
scale
;
_viewportMetrics
.
physical_height
=
size
.
height
*
scale
;
_viewportMetrics
.
physical_padding_top
=
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
.
height
*
scale
;
_platformView
->
engineProxy
()
->
OnViewportMetricsChanged
(
_viewportMetrics
.
Clone
());
[
self
updateViewportMetrics
];
}
#pragma mark - Keyboard events
...
...
@@ -350,15 +356,13 @@ static inline PointerChangeMapperPhase PointerChangePhaseFromUITouchPhase(
CGFloat
bottom
=
CGRectGetHeight
(
[[
info
objectForKey
:
UIKeyboardFrameBeginUserInfoKey
]
CGRectValue
]);
CGFloat
scale
=
[
UIScreen
mainScreen
].
scale
;
_viewportMetrics
->
physical_padding_bottom
=
bottom
*
scale
;
_platformView
->
engineProxy
()
->
OnViewportMetricsChanged
(
_viewportMetrics
.
Clone
());
_viewportMetrics
.
physical_padding_bottom
=
bottom
*
scale
;
[
self
updateViewportMetrics
];
}
-
(
void
)
keyboardWillBeHidden
:(
NSNotification
*
)
notification
{
_viewportMetrics
->
physical_padding_bottom
=
0.0
;
_platformView
->
engineProxy
()
->
OnViewportMetricsChanged
(
_viewportMetrics
.
Clone
());
_viewportMetrics
.
physical_padding_bottom
=
0
;
[
self
updateViewportMetrics
];
}
#pragma mark - Text input delegate
...
...
shell/platform/linux/platform_view_glfw.cc
浏览文件 @
9eaedb06
...
...
@@ -102,11 +102,14 @@ void PlatformViewGLFW::RunFromSource(const std::string& main,
const
std
::
string
&
assets_directory
)
{}
void
PlatformViewGLFW
::
OnWindowSizeChanged
(
int
width
,
int
height
)
{
auto
metrics
=
sky
::
ViewportMetrics
::
New
();
metrics
->
physical_width
=
width
;
metrics
->
physical_height
=
height
;
metrics
->
device_pixel_ratio
=
1.0
;
engine_
->
OnViewportMetricsChanged
(
metrics
.
Pass
());
blink
::
ViewportMetrics
metrics
;
metrics
.
physical_width
=
width
;
metrics
.
physical_height
=
height
;
blink
::
Threads
::
UI
()
->
PostTask
([
engine
=
engine
().
GetWeakPtr
(),
metrics
]
{
if
(
engine
.
get
())
engine
->
SetViewportMetrics
(
metrics
);
});
}
void
PlatformViewGLFW
::
OnMouseButtonChanged
(
int
button
,
int
action
,
int
mods
)
{
...
...
shell/testing/BUILD.gn
浏览文件 @
9eaedb06
...
...
@@ -13,9 +13,10 @@ source_set("testing") {
]
deps = [
"../common",
"//base",
"//flutter/common",
"//flutter/services/engine:interfaces",
"//flutter/shell/common",
"//flutter/skia",
"//lib/ftl",
"//mojo/public/cpp/bindings",
...
...
shell/testing/test_runner.cc
浏览文件 @
9eaedb06
...
...
@@ -6,8 +6,7 @@
#include <iostream>
#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
#include "flutter/common/threads.h"
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/testing/platform_view_test.h"
...
...
@@ -18,12 +17,15 @@ TestRunner::TestRunner()
:
platform_view_
(
new
PlatformViewTest
()),
weak_ptr_factory_
(
this
)
{
platform_view_
->
ConnectToEngine
(
GetProxy
(
&
sky_engine_
));
sky
::
ViewportMetricsPtr
metrics
=
sky
::
ViewportMetrics
::
New
();
blink
::
ViewportMetrics
metrics
;
metrics
.
physical_width
=
800
;
metrics
.
physical_height
=
600
;
metrics
->
physical_width
=
800
;
metrics
->
physical_height
=
600
;
sky_engine_
->
OnViewportMetricsChanged
(
metrics
.
Pass
());
blink
::
Threads
::
UI
()
->
PostTask
(
[
engine
=
platform_view_
->
engine
().
GetWeakPtr
(),
metrics
]
{
if
(
engine
.
get
())
engine
->
SetViewportMetrics
(
metrics
);
});
}
TestRunner
::~
TestRunner
()
=
default
;
...
...
shell/testing/test_runner.h
浏览文件 @
9eaedb06
...
...
@@ -11,7 +11,6 @@
#include "flutter/services/engine/sky_engine.mojom.h"
#include "lib/ftl/macros.h"
#include "lib/ftl/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/binding_set.h"
namespace
shell
{
...
...
@@ -34,6 +33,7 @@ class TestRunner {
std
::
unique_ptr
<
PlatformView
>
platform_view_
;
sky
::
SkyEnginePtr
sky_engine_
;
ftl
::
WeakPtrFactory
<
TestRunner
>
weak_ptr_factory_
;
FTL_DISALLOW_COPY_AND_ASSIGN
(
TestRunner
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录