Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
ac9142c9
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,发现更多精彩内容 >>
未验证
提交
ac9142c9
编写于
7月 10, 2021
作者:
J
Jim Graham
提交者:
GitHub
7月 10, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
encode DPR for shadows into DisplayList (#27289)
上级
0a892d9e
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
83 addition
and
44 deletion
+83
-44
flow/display_list.cc
flow/display_list.cc
+27
-20
flow/display_list.h
flow/display_list.h
+6
-3
flow/display_list_canvas.cc
flow/display_list_canvas.cc
+3
-2
flow/display_list_canvas.h
flow/display_list_canvas.h
+2
-1
flow/display_list_canvas_unittests.cc
flow/display_list_canvas_unittests.cc
+25
-2
flow/display_list_unittests.cc
flow/display_list_unittests.cc
+6
-5
flow/display_list_utils.cc
flow/display_list_utils.cc
+5
-4
flow/display_list_utils.h
flow/display_list_utils.h
+2
-1
lib/ui/painting/canvas.cc
lib/ui/painting/canvas.cc
+7
-6
未找到文件。
flow/display_list.cc
浏览文件 @
ac9142c9
...
...
@@ -796,24 +796,28 @@ struct DrawTextBlobOp final : DLOp {
};
// 4 byte header + 28 byte payload packs evenly into 32 bytes
struct
DrawShadowOp
final
:
DLOp
{
static
const
auto
kType
=
DisplayListOpType
::
kDrawShadow
;
DrawShadowOp
(
const
SkPath
&
path
,
SkColor
color
,
SkScalar
elevation
,
bool
occludes
)
:
color
(
color
),
elevation
(
elevation
),
occludes
(
occludes
),
path
(
path
)
{}
const
SkColor
color
;
const
SkScalar
elevation
;
const
bool
occludes
;
const
SkPath
path
;
void
dispatch
(
Dispatcher
&
dispatcher
)
const
{
dispatcher
.
drawShadow
(
path
,
color
,
elevation
,
occludes
);
}
};
#define DEFINE_DRAW_SHADOW_OP(name, occludes) \
struct Draw##name##Op final : DLOp { \
static const auto kType = DisplayListOpType::kDraw##name; \
\
Draw##name##Op(const SkPath& path, \
SkColor color, \
SkScalar elevation, \
SkScalar dpr) \
: color(color), elevation(elevation), dpr(dpr), path(path) {} \
\
const SkColor color; \
const SkScalar elevation; \
const SkScalar dpr; \
const SkPath path; \
\
void dispatch(Dispatcher& dispatcher) const { \
dispatcher.drawShadow(path, color, elevation, occludes, dpr); \
} \
};
DEFINE_DRAW_SHADOW_OP
(
Shadow
,
false
)
DEFINE_DRAW_SHADOW_OP
(
ShadowOccludes
,
true
)
#undef DEFINE_DRAW_SHADOW_OP
#pragma pack(pop, DLOp_Alignment)
...
...
@@ -1351,8 +1355,11 @@ void DisplayListBuilder::drawTextBlob(const sk_sp<SkTextBlob> blob,
void
DisplayListBuilder
::
drawShadow
(
const
SkPath
&
path
,
const
SkColor
color
,
const
SkScalar
elevation
,
bool
occludes
)
{
Push
<
DrawShadowOp
>
(
0
,
path
,
color
,
elevation
,
occludes
);
bool
occludes
,
SkScalar
dpr
)
{
occludes
//
?
Push
<
DrawShadowOccludesOp
>
(
0
,
path
,
color
,
elevation
,
dpr
)
:
Push
<
DrawShadowOp
>
(
0
,
path
,
color
,
elevation
,
dpr
);
}
}
// namespace flutter
flow/display_list.h
浏览文件 @
ac9142c9
...
...
@@ -144,7 +144,8 @@ namespace flutter {
V(DrawDisplayList) \
V(DrawTextBlob) \
\
V(DrawShadow)
V(DrawShadow) \
V(DrawShadowOccludes)
#define DL_OP_TO_ENUM_VALUE(name) k##name,
enum
class
DisplayListOpType
{
FOR_EACH_DISPLAY_LIST_OP
(
DL_OP_TO_ENUM_VALUE
)
};
...
...
@@ -318,7 +319,8 @@ class Dispatcher {
virtual
void
drawShadow
(
const
SkPath
&
path
,
const
SkColor
color
,
const
SkScalar
elevation
,
bool
occludes
)
=
0
;
bool
occludes
,
SkScalar
dpr
)
=
0
;
};
// The primary class used to build a display list. The list of methods
...
...
@@ -431,7 +433,8 @@ class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
void
drawShadow
(
const
SkPath
&
path
,
const
SkColor
color
,
const
SkScalar
elevation
,
bool
occludes
)
override
;
bool
occludes
,
SkScalar
dpr
)
override
;
sk_sp
<
DisplayList
>
Build
();
...
...
flow/display_list_canvas.cc
浏览文件 @
ac9142c9
...
...
@@ -176,9 +176,10 @@ void DisplayListCanvasDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob,
void
DisplayListCanvasDispatcher
::
drawShadow
(
const
SkPath
&
path
,
const
SkColor
color
,
const
SkScalar
elevation
,
bool
occludes
)
{
bool
occludes
,
SkScalar
dpr
)
{
flutter
::
PhysicalShapeLayer
::
DrawShadow
(
canvas_
,
path
,
color
,
elevation
,
occludes
,
1.0
);
occludes
,
dpr
);
}
DisplayListCanvasRecorder
::
DisplayListCanvasRecorder
(
const
SkRect
&
bounds
)
...
...
flow/display_list_canvas.h
浏览文件 @
ac9142c9
...
...
@@ -110,7 +110,8 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
void
drawShadow
(
const
SkPath
&
path
,
const
SkColor
color
,
const
SkScalar
elevation
,
bool
occludes
)
override
;
bool
occludes
,
SkScalar
dpr
)
override
;
private:
SkCanvas
*
canvas_
;
...
...
flow/display_list_canvas_unittests.cc
浏览文件 @
ac9142c9
...
...
@@ -1350,7 +1350,7 @@ TEST(DisplayListCanvas, DrawShadow) {
1.0
);
},
[
=
](
DisplayListBuilder
&
builder
)
{
//
builder
.
drawShadow
(
path
,
color
,
elevation
,
false
);
builder
.
drawShadow
(
path
,
color
,
elevation
,
false
,
1.0
);
});
CanvasCompareTester
::
UsingShadows
=
false
;
}
...
...
@@ -1373,7 +1373,30 @@ TEST(DisplayListCanvas, DrawOccludingShadow) {
1.0
);
},
[
=
](
DisplayListBuilder
&
builder
)
{
//
builder
.
drawShadow
(
path
,
color
,
elevation
,
true
);
builder
.
drawShadow
(
path
,
color
,
elevation
,
true
,
1.0
);
});
CanvasCompareTester
::
UsingShadows
=
false
;
}
TEST
(
DisplayListCanvas
,
DrawShadowDpr
)
{
CanvasCompareTester
::
UsingShadows
=
true
;
SkPath
path
;
path
.
moveTo
(
RenderCenterX
,
RenderTop
);
path
.
lineTo
(
RenderRight
,
RenderBottom
);
path
.
lineTo
(
RenderLeft
,
RenderCenterY
);
path
.
lineTo
(
RenderRight
,
RenderCenterY
);
path
.
lineTo
(
RenderLeft
,
RenderBottom
);
path
.
close
();
const
SkColor
color
=
SK_ColorDKGRAY
;
const
SkScalar
elevation
=
10
;
CanvasCompareTester
::
RenderNoAttributes
(
[
=
](
SkCanvas
*
canvas
,
SkPaint
&
paint
)
{
//
PhysicalShapeLayer
::
DrawShadow
(
canvas
,
path
,
color
,
elevation
,
false
,
2.5
);
},
[
=
](
DisplayListBuilder
&
builder
)
{
//
builder
.
drawShadow
(
path
,
color
,
elevation
,
false
,
2.5
);
});
CanvasCompareTester
::
UsingShadows
=
false
;
}
...
...
flow/display_list_unittests.cc
浏览文件 @
ac9142c9
...
...
@@ -663,11 +663,12 @@ std::vector<DisplayListInvocationGroup> allGroups = {
// See: https://bugs.chromium.org/p/skia/issues/detail?id=12125
{
"DrawShadow"
,
{
// cv shadows are turned into an opaque ShadowRec which is not exposed
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorGREEN
,
1.0
,
false
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath2
,
SK_ColorGREEN
,
1.0
,
false
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorBLUE
,
1.0
,
false
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorGREEN
,
2.0
,
false
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorGREEN
,
1.0
,
true
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorGREEN
,
1.0
,
false
,
1.0
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath2
,
SK_ColorGREEN
,
1.0
,
false
,
1.0
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorBLUE
,
1.0
,
false
,
1.0
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorGREEN
,
2.0
,
false
,
1.0
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorGREEN
,
1.0
,
true
,
1.0
);}},
{
1
,
32
,
-
1
,
32
,
[](
DisplayListBuilder
&
b
)
{
b
.
drawShadow
(
TestPath1
,
SK_ColorGREEN
,
1.0
,
false
,
2.5
);}},
}
},
};
...
...
flow/display_list_utils.cc
浏览文件 @
ac9142c9
...
...
@@ -335,7 +335,8 @@ void DisplayListBoundsCalculator::drawTextBlob(const sk_sp<SkTextBlob> blob,
void
DisplayListBoundsCalculator
::
drawShadow
(
const
SkPath
&
path
,
const
SkColor
color
,
const
SkScalar
elevation
,
bool
occludes
)
{
bool
occludes
,
SkScalar
dpr
)
{
// Constants from physical_shape_layer.cc
const
SkScalar
kLightHeight
=
600
;
const
SkScalar
kLightRadius
=
800
;
...
...
@@ -348,9 +349,9 @@ void DisplayListBoundsCalculator::drawShadow(const SkPath& path,
SkScalar
shadow_y
=
bounds
.
top
()
-
600.0
f
;
SkRect
shadow_bounds
;
SkShadowUtils
::
GetLocalBounds
(
matrix
(),
path
,
SkPoint3
::
Make
(
0
,
0
,
elevation
),
SkPoint3
::
Make
(
shadow_x
,
shadow_y
,
kLightHeight
),
kLightRadius
,
flags
,
&
shadow_bounds
);
matrix
(),
path
,
SkPoint3
::
Make
(
0
,
0
,
dpr
*
elevation
),
SkPoint3
::
Make
(
shadow_x
,
shadow_y
,
dpr
*
kLightHeight
)
,
dpr
*
kLightRadius
,
flags
,
&
shadow_bounds
);
accumulateRect
(
shadow_bounds
);
}
...
...
flow/display_list_utils.h
浏览文件 @
ac9142c9
...
...
@@ -308,7 +308,8 @@ class DisplayListBoundsCalculator final
void
drawShadow
(
const
SkPath
&
path
,
const
SkColor
color
,
const
SkScalar
elevation
,
bool
occludes
)
override
;
bool
occludes
,
SkScalar
dpr
)
override
;
SkRect
getBounds
()
{
return
accumulator_
->
getBounds
();
}
...
...
lib/ui/painting/canvas.cc
浏览文件 @
ac9142c9
...
...
@@ -499,6 +499,11 @@ void Canvas::drawShadow(const CanvasPath* path,
ToDart
(
"Canvas.drawShader called with non-genuine Path."
));
return
;
}
SkScalar
dpr
=
UIDartState
::
Current
()
->
platform_configuration
()
->
get_window
(
0
)
->
viewport_metrics
()
.
device_pixel_ratio
;
if
(
display_list_recorder_
)
{
// The DrawShadow mechanism results in non-public operations to be
// performed on the canvas involving an SkDrawShadowRec. Since we
...
...
@@ -507,13 +512,9 @@ void Canvas::drawShadow(const CanvasPath* path,
// that situation we bypass the canvas interface and inject the
// shadow parameters directly into the underlying DisplayList.
// See: https://bugs.chromium.org/p/skia/issues/detail?id=12125
builder
()
->
drawShadow
(
path
->
path
(),
color
,
elevation
,
transparentOccluder
);
builder
()
->
drawShadow
(
path
->
path
(),
color
,
elevation
,
transparentOccluder
,
dpr
);
}
else
{
SkScalar
dpr
=
UIDartState
::
Current
()
->
platform_configuration
()
->
get_window
(
0
)
->
viewport_metrics
()
.
device_pixel_ratio
;
flutter
::
PhysicalShapeLayer
::
DrawShadow
(
canvas_
,
path
->
path
(),
color
,
elevation
,
transparentOccluder
,
dpr
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录