Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
6b9eda4a
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,发现更多精彩内容 >>
提交
6b9eda4a
编写于
3月 20, 2017
作者:
J
Jason Simmons
提交者:
GitHub
3月 20, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Canvas.drawShadow API based on SkShadowUtils::drawShadow (#3486)
上级
26a6615d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
11 deletion
+52
-11
flow/layers/physical_model_layer.cc
flow/layers/physical_model_layer.cc
+17
-10
flow/layers/physical_model_layer.h
flow/layers/physical_model_layer.h
+3
-0
lib/ui/painting.dart
lib/ui/painting.dart
+12
-0
lib/ui/painting/canvas.cc
lib/ui/painting/canvas.cc
+14
-1
lib/ui/painting/canvas.h
lib/ui/painting/canvas.h
+6
-0
未找到文件。
flow/layers/physical_model_layer.cc
浏览文件 @
6b9eda4a
...
...
@@ -50,16 +50,8 @@ void PhysicalModelLayer::Paint(PaintContext& context) {
path
.
addRRect
(
rrect_
);
if
(
elevation_
!=
0
)
{
SkShadowFlags
flags
=
SkColorGetA
(
color_
)
==
0xff
?
SkShadowFlags
::
kNone_ShadowFlag
:
SkShadowFlags
::
kTransparentOccluder_ShadowFlag
;
SkShadowUtils
::
DrawShadow
(
&
context
.
canvas
,
path
,
elevation_
*
4
,
SkPoint3
::
Make
(
0.0
f
,
-
700.0
f
,
2800.0
f
),
2800.0
f
,
0.25
f
,
0.25
f
,
SK_ColorBLACK
,
flags
);
DrawShadow
(
&
context
.
canvas
,
path
,
SK_ColorBLACK
,
elevation_
,
SkColorGetA
(
color_
)
!=
0xff
);
}
if
(
needs_system_composite
())
...
...
@@ -79,4 +71,19 @@ void PhysicalModelLayer::Paint(PaintContext& context) {
PaintChildren
(
context
);
}
void
PhysicalModelLayer
::
DrawShadow
(
SkCanvas
*
canvas
,
const
SkPath
&
path
,
SkColor
color
,
int
elevation
,
bool
transparentOccluder
)
{
SkShadowFlags
flags
=
transparentOccluder
?
SkShadowFlags
::
kTransparentOccluder_ShadowFlag
:
SkShadowFlags
::
kNone_ShadowFlag
;
SkShadowUtils
::
DrawShadow
(
canvas
,
path
,
elevation
*
4
,
SkPoint3
::
Make
(
0.0
f
,
-
700.0
f
,
2800.0
f
),
2800.0
f
,
0.25
f
,
0.25
f
,
color
,
flags
);
}
}
// namespace flow
flow/layers/physical_model_layer.h
浏览文件 @
6b9eda4a
...
...
@@ -18,6 +18,9 @@ class PhysicalModelLayer : public ContainerLayer {
void
set_elevation
(
int
elevation
)
{
elevation_
=
elevation
;
}
void
set_color
(
SkColor
color
)
{
color_
=
color
;
}
static
void
DrawShadow
(
SkCanvas
*
canvas
,
const
SkPath
&
path
,
SkColor
color
,
int
elevation
,
bool
transparentOccluder
);
protected:
void
Preroll
(
PrerollContext
*
context
,
const
SkMatrix
&
matrix
)
override
;
void
Paint
(
PaintContext
&
context
)
override
;
...
...
lib/ui/painting.dart
浏览文件 @
6b9eda4a
...
...
@@ -1548,6 +1548,18 @@ class Canvas extends NativeFieldWrapperClass2 {
Int32List
colors
,
int
blendMode
,
Float32List
cullRect
)
native
"Canvas_drawAtlas"
;
/// Draws a shadow for a [Path] representing the given material elevation.
///
/// transparentOccluder should be true if the occluding object is not opaque.
void
drawShadow
(
Path
path
,
Color
color
,
int
elevation
,
bool
transparentOccluder
)
{
_drawShadow
(
path
,
color
.
value
,
elevation
,
transparentOccluder
);
}
void
_drawShadow
(
Path
path
,
int
color
,
int
elevation
,
bool
transparentOccluder
)
native
"Canvas_drawShadow"
;
}
/// An object representing a sequence of recorded graphical operations.
...
...
lib/ui/painting/canvas.cc
浏览文件 @
6b9eda4a
...
...
@@ -6,6 +6,7 @@
#include <math.h>
#include "flutter/flow/layers/physical_model_layer.h"
#include "flutter/lib/ui/painting/image.h"
#include "flutter/lib/ui/painting/matrix.h"
#include "lib/tonic/converter/dart_converter.h"
...
...
@@ -53,7 +54,8 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Canvas);
V(Canvas, drawPicture) \
V(Canvas, drawPoints) \
V(Canvas, drawVertices) \
V(Canvas, drawAtlas)
V(Canvas, drawAtlas) \
V(Canvas, drawShadow)
FOR_EACH_BINDING
(
DART_NATIVE_CALLBACK
)
...
...
@@ -395,6 +397,17 @@ void Canvas::drawAtlas(const Paint& paint,
paint
.
paint
());
}
void
Canvas
::
drawShadow
(
const
CanvasPath
*
path
,
SkColor
color
,
int
elevation
,
bool
transparentOccluder
)
{
flow
::
PhysicalModelLayer
::
DrawShadow
(
canvas_
,
path
->
path
(),
color
,
elevation
,
transparentOccluder
);
}
void
Canvas
::
Clear
()
{
canvas_
=
nullptr
;
}
...
...
lib/ui/painting/canvas.h
浏览文件 @
6b9eda4a
...
...
@@ -15,6 +15,7 @@
#include "lib/tonic/typed_data/float64_list.h"
#include "lib/tonic/typed_data/int32_list.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/utils/SkShadowUtils.h"
namespace
tonic
{
class
DartLibraryNatives
;
...
...
@@ -159,6 +160,11 @@ class Canvas : public ftl::RefCountedThreadSafe<Canvas>,
SkBlendMode
blend_mode
,
const
tonic
::
Float32List
&
cull_rect
);
void
drawShadow
(
const
CanvasPath
*
path
,
SkColor
color
,
int
elevation
,
bool
transparentOccluder
);
SkCanvas
*
canvas
()
const
{
return
canvas_
;
}
void
Clear
();
bool
IsRecording
()
const
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录