Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
e687626a
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,发现更多精彩内容 >>
提交
e687626a
编写于
7月 24, 2017
作者:
J
Jason Simmons
提交者:
GitHub
7月 24, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Incorporate the device pixel ratio when drawing shadows (#3919)
上级
193de2f4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
26 addition
and
12 deletion
+26
-12
flow/layers/physical_model_layer.cc
flow/layers/physical_model_layer.cc
+7
-6
flow/layers/physical_model_layer.h
flow/layers/physical_model_layer.h
+4
-1
lib/ui/compositing/scene_builder.cc
lib/ui/compositing/scene_builder.cc
+5
-0
lib/ui/painting/canvas.cc
lib/ui/painting/canvas.cc
+5
-1
lib/ui/window/window.cc
lib/ui/window/window.cc
+2
-0
lib/ui/window/window.h
lib/ui/window/window.h
+2
-0
runtime/runtime_controller.cc
runtime/runtime_controller.cc
+1
-3
runtime/runtime_controller.h
runtime/runtime_controller.h
+0
-1
未找到文件。
flow/layers/physical_model_layer.cc
浏览文件 @
e687626a
...
...
@@ -9,7 +9,7 @@
namespace
flow
{
PhysicalModelLayer
::
PhysicalModelLayer
()
:
rrect_
(
SkRRect
::
MakeEmpty
())
{}
PhysicalModelLayer
::
PhysicalModelLayer
()
=
default
;
PhysicalModelLayer
::~
PhysicalModelLayer
()
=
default
;
...
...
@@ -70,7 +70,7 @@ void PhysicalModelLayer::Paint(PaintContext& context) {
if
(
elevation_
!=
0
)
{
DrawShadow
(
&
context
.
canvas
,
path
,
SK_ColorBLACK
,
elevation_
,
SkColorGetA
(
color_
)
!=
0xff
);
SkColorGetA
(
color_
)
!=
0xff
,
device_pixel_ratio_
);
}
SkPaint
paint
;
...
...
@@ -93,16 +93,17 @@ void PhysicalModelLayer::DrawShadow(SkCanvas* canvas,
const
SkPath
&
path
,
SkColor
color
,
float
elevation
,
bool
transparentOccluder
)
{
bool
transparentOccluder
,
SkScalar
dpr
)
{
SkShadowFlags
flags
=
transparentOccluder
?
SkShadowFlags
::
kTransparentOccluder_ShadowFlag
:
SkShadowFlags
::
kNone_ShadowFlag
;
const
SkRect
&
bounds
=
path
.
getBounds
();
SkScalar
shadow_x
=
(
bounds
.
left
()
+
bounds
.
right
())
/
2
;
SkScalar
shadow_y
=
bounds
.
top
()
-
600.0
f
;
SkShadowUtils
::
DrawShadow
(
canvas
,
path
,
elevation
,
SkPoint3
::
Make
(
shadow_x
,
shadow_y
,
600.0
f
),
800.0
f
,
0.039
f
,
0.25
f
,
color
,
flags
);
SkShadowUtils
::
DrawShadow
(
canvas
,
path
,
dpr
*
elevation
,
SkPoint3
::
Make
(
shadow_x
,
shadow_y
,
dpr
*
600.0
f
)
,
dpr
*
800.0
f
,
0.039
f
,
0.25
f
,
color
,
flags
);
}
}
// namespace flow
flow/layers/physical_model_layer.h
浏览文件 @
e687626a
...
...
@@ -17,12 +17,14 @@ class PhysicalModelLayer : public ContainerLayer {
void
set_rrect
(
const
SkRRect
&
rrect
)
{
rrect_
=
rrect
;
}
void
set_elevation
(
float
elevation
)
{
elevation_
=
elevation
;
}
void
set_color
(
SkColor
color
)
{
color_
=
color
;
}
void
set_device_pixel_ratio
(
SkScalar
dpr
)
{
device_pixel_ratio_
=
dpr
;
}
static
void
DrawShadow
(
SkCanvas
*
canvas
,
const
SkPath
&
path
,
SkColor
color
,
float
elevation
,
bool
transparentOccluder
);
bool
transparentOccluder
,
SkScalar
dpr
);
void
Preroll
(
PrerollContext
*
context
,
const
SkMatrix
&
matrix
)
override
;
void
Paint
(
PaintContext
&
context
)
override
;
...
...
@@ -35,6 +37,7 @@ class PhysicalModelLayer : public ContainerLayer {
SkRRect
rrect_
;
float
elevation_
;
SkColor
color_
;
SkScalar
device_pixel_ratio_
;
#if defined(OS_FUCHSIA)
SkScalar
scale_x_
;
...
...
lib/ui/compositing/scene_builder.cc
浏览文件 @
e687626a
...
...
@@ -16,8 +16,10 @@
#include "flutter/flow/layers/picture_layer.h"
#include "flutter/flow/layers/shader_mask_layer.h"
#include "flutter/flow/layers/transform_layer.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/lib/ui/painting/shader.h"
#include "flutter/lib/ui/window/window.h"
#include "lib/ftl/build_config.h"
#include "lib/tonic/converter/dart_converter.h"
#include "lib/tonic/dart_args.h"
...
...
@@ -163,11 +165,14 @@ void SceneBuilder::pushPhysicalModel(const RRect& rrect,
if
(
!
cullRect
.
intersect
(
rrect
.
sk_rrect
.
rect
(),
m_cullRects
.
top
()))
cullRect
=
SkRect
::
MakeEmpty
();
SkScalar
dpr
=
UIDartState
::
Current
()
->
window
()
->
viewport_metrics
().
device_pixel_ratio
;
std
::
unique_ptr
<
flow
::
PhysicalModelLayer
>
layer
(
new
flow
::
PhysicalModelLayer
());
layer
->
set_rrect
(
rrect
.
sk_rrect
);
layer
->
set_elevation
(
elevation
);
layer
->
set_color
(
color
);
layer
->
set_device_pixel_ratio
(
dpr
);
addLayer
(
std
::
move
(
layer
),
cullRect
);
}
...
...
lib/ui/painting/canvas.cc
浏览文件 @
e687626a
...
...
@@ -7,8 +7,10 @@
#include <math.h>
#include "flutter/flow/layers/physical_model_layer.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/lib/ui/painting/image.h"
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/lib/ui/window/window.h"
#include "lib/tonic/converter/dart_converter.h"
#include "lib/tonic/dart_args.h"
#include "lib/tonic/dart_binding_macros.h"
...
...
@@ -399,11 +401,13 @@ void Canvas::drawShadow(const CanvasPath* path,
bool
transparentOccluder
)
{
if
(
!
path
)
Dart_ThrowException
(
ToDart
(
"Canvas.drawShader called with non-genuine Path."
));
SkScalar
dpr
=
UIDartState
::
Current
()
->
window
()
->
viewport_metrics
().
device_pixel_ratio
;
flow
::
PhysicalModelLayer
::
DrawShadow
(
canvas_
,
path
->
path
(),
color
,
elevation
,
transparentOccluder
);
transparentOccluder
,
dpr
);
}
void
Canvas
::
Clear
()
{
...
...
lib/ui/window/window.cc
浏览文件 @
e687626a
...
...
@@ -129,6 +129,8 @@ void Window::DidCreateIsolate() {
}
void
Window
::
UpdateWindowMetrics
(
const
ViewportMetrics
&
metrics
)
{
viewport_metrics_
=
metrics
;
tonic
::
DartState
*
dart_state
=
library_
.
dart_state
().
get
();
if
(
!
dart_state
)
return
;
...
...
lib/ui/window/window.h
浏览文件 @
e687626a
...
...
@@ -39,6 +39,7 @@ class Window {
~
Window
();
WindowClient
*
client
()
const
{
return
client_
;
}
const
ViewportMetrics
&
viewport_metrics
()
{
return
viewport_metrics_
;
}
void
DidCreateIsolate
();
void
UpdateWindowMetrics
(
const
ViewportMetrics
&
metrics
);
...
...
@@ -59,6 +60,7 @@ class Window {
private:
WindowClient
*
client_
;
tonic
::
DartPersistentValue
library_
;
ViewportMetrics
viewport_metrics_
;
// We use id 0 to mean that no response is expected.
int
next_response_id_
=
1
;
...
...
runtime/runtime_controller.cc
浏览文件 @
e687626a
...
...
@@ -45,7 +45,6 @@ void RuntimeController::CreateDartController(
Window
*
window
=
GetWindow
();
window
->
UpdateWindowMetrics
(
viewport_metrics_
);
window
->
UpdateLocale
(
language_code_
,
country_code_
);
if
(
semantics_enabled_
)
...
...
@@ -53,8 +52,7 @@ void RuntimeController::CreateDartController(
}
void
RuntimeController
::
SetViewportMetrics
(
const
ViewportMetrics
&
metrics
)
{
viewport_metrics_
=
metrics
;
GetWindow
()
->
UpdateWindowMetrics
(
viewport_metrics_
);
GetWindow
()
->
UpdateWindowMetrics
(
metrics
);
}
void
RuntimeController
::
SetLocale
(
const
std
::
string
&
language_code
,
...
...
runtime/runtime_controller.h
浏览文件 @
e687626a
...
...
@@ -62,7 +62,6 @@ class RuntimeController : public WindowClient, public IsolateClient {
void
DidCreateSecondaryIsolate
(
Dart_Isolate
isolate
)
override
;
RuntimeDelegate
*
client_
;
ViewportMetrics
viewport_metrics_
;
std
::
string
language_code_
;
std
::
string
country_code_
;
bool
semantics_enabled_
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录