Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
15556f73
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,体验更适合开发者的 AI 搜索 >>
提交
15556f73
编写于
8月 11, 2015
作者:
A
Adam Barth
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #551 from abarth/rm_weak_paint
Remove weak handle from sky.Paint
上级
e2bc694a
a1807a1b
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
233 addition
and
246 deletion
+233
-246
examples/raw/painting.dart
examples/raw/painting.dart
+16
-21
examples/raw/shadow.dart
examples/raw/shadow.dart
+1
-1
sky/engine/bindings/scripts/dart_types.py
sky/engine/bindings/scripts/dart_types.py
+2
-0
sky/engine/core/core.gni
sky/engine/core/core.gni
+2
-5
sky/engine/core/painting/Canvas.cpp
sky/engine/core/painting/Canvas.cpp
+24
-32
sky/engine/core/painting/Canvas.h
sky/engine/core/painting/Canvas.h
+12
-12
sky/engine/core/painting/DrawLooperAddLayerCallback.cpp
sky/engine/core/painting/DrawLooperAddLayerCallback.cpp
+0
-12
sky/engine/core/painting/DrawLooperAddLayerCallback.h
sky/engine/core/painting/DrawLooperAddLayerCallback.h
+0
-19
sky/engine/core/painting/DrawLooperAddLayerCallback.idl
sky/engine/core/painting/DrawLooperAddLayerCallback.idl
+0
-7
sky/engine/core/painting/LayerDrawLooperBuilder.cpp
sky/engine/core/painting/LayerDrawLooperBuilder.cpp
+3
-8
sky/engine/core/painting/LayerDrawLooperBuilder.h
sky/engine/core/painting/LayerDrawLooperBuilder.h
+2
-3
sky/engine/core/painting/LayerDrawLooperBuilder.idl
sky/engine/core/painting/LayerDrawLooperBuilder.idl
+1
-1
sky/engine/core/painting/Paint.cpp
sky/engine/core/painting/Paint.cpp
+71
-64
sky/engine/core/painting/Paint.dart
sky/engine/core/painting/Paint.dart
+77
-0
sky/engine/core/painting/Paint.h
sky/engine/core/painting/Paint.h
+11
-31
sky/engine/core/painting/Paint.idl
sky/engine/core/painting/Paint.idl
+0
-21
sky/engine/tonic/dart_converter.h
sky/engine/tonic/dart_converter.h
+5
-2
sky/packages/sky/lib/painting/shadows.dart
sky/packages/sky/lib/painting/shadows.dart
+4
-6
sky/tests/painting/canvas.dart
sky/tests/painting/canvas.dart
+1
-0
sky/tests/raw/render_box-expected.txt
sky/tests/raw/render_box-expected.txt
+1
-1
未找到文件。
examples/raw/painting.dart
浏览文件 @
15556f73
...
...
@@ -55,34 +55,29 @@ void beginFrame(double timeStamp) {
..
setOffset
(
const
sky
.
Offset
(
150.0
,
0.0
))
..
setColorMode
(
sky
.
TransferMode
.
src
)
..
setPaintBits
(
sky
.
PaintBits
.
all
),
(
sky
.
Paint
layerPaint
)
{
layerPaint
.
color
=
const
sky
.
Color
.
fromARGB
(
128
,
255
,
255
,
0
);
layerPaint
.
setColorFilter
(
new
sky
.
ColorFilter
.
mode
(
const
sky
.
Color
.
fromARGB
(
128
,
0
,
0
,
255
),
sky
.
TransferMode
.
srcIn
));
layerPaint
.
setMaskFilter
(
new
sky
.
MaskFilter
.
blur
(
sky
.
BlurStyle
.
normal
,
3.0
,
highQuality:
true
));
})
new
sky
.
Paint
()
..
color
=
const
sky
.
Color
.
fromARGB
(
128
,
255
,
255
,
0
)
..
setColorFilter
(
new
sky
.
ColorFilter
.
mode
(
const
sky
.
Color
.
fromARGB
(
128
,
0
,
0
,
255
),
sky
.
TransferMode
.
srcIn
))
..
setMaskFilter
(
new
sky
.
MaskFilter
.
blur
(
sky
.
BlurStyle
.
normal
,
3.0
,
highQuality:
true
)))
..
addLayerOnTop
(
new
sky
.
DrawLooperLayerInfo
()
..
setOffset
(
const
sky
.
Offset
(
75.0
,
75.0
))
..
setColorMode
(
sky
.
TransferMode
.
src
)
..
setPaintBits
(
sky
.
PaintBits
.
shader
),
(
sky
.
Paint
layerPaint
)
{
sky
.
Gradient
redYellow
=
new
sky
.
Gradient
.
radial
(
new
sky
.
Point
(
0.0
,
0.0
),
radius
/
3.0
,
[
const
sky
.
Color
(
0xFFFFFF00
),
const
sky
.
Color
(
0xFFFF0000
)],
null
,
sky
.
TileMode
.
mirror
);
layerPaint
.
setShader
(
redYellow
);
// Since we're don't set sky.PaintBits.maskFilter, this has no effect.
layerPaint
.
setMaskFilter
(
new
sky
.
MaskFilter
.
blur
(
sky
.
BlurStyle
.
normal
,
50.0
,
highQuality:
true
));
})
new
sky
.
Paint
()
..
setShader
(
new
sky
.
Gradient
.
radial
(
new
sky
.
Point
(
0.0
,
0.0
),
radius
/
3.0
,
[
const
sky
.
Color
(
0xFFFFFF00
),
const
sky
.
Color
(
0xFFFF0000
)],
null
,
sky
.
TileMode
.
mirror
))
// Since we're don't set sky.PaintBits.maskFilter, this has no effect.
..
setMaskFilter
(
new
sky
.
MaskFilter
.
blur
(
sky
.
BlurStyle
.
normal
,
50.0
,
highQuality:
true
)))
..
addLayerOnTop
(
new
sky
.
DrawLooperLayerInfo
()..
setOffset
(
const
sky
.
Offset
(
225.0
,
75.0
)),
(
sky
.
Paint
layerPaint
)
{
// Since this layer uses a DST color mode, this has no effect.
layerPaint
.
color
=
const
sky
.
Color
.
fromARGB
(
128
,
255
,
0
,
0
);
});
// Since this layer uses a DST color mode, this has no effect.
new
sky
.
Paint
()..
color
=
const
sky
.
Color
.
fromARGB
(
128
,
255
,
0
,
0
));
paint
.
setDrawLooper
(
builder
.
build
());
canvas
.
drawCircle
(
sky
.
Point
.
origin
,
radius
,
paint
);
...
...
examples/raw/shadow.dart
浏览文件 @
15556f73
...
...
@@ -27,7 +27,7 @@ void beginFrame(double timeStamp) {
new
MaskFilter
.
blur
(
BlurStyle
.
normal
,
5.0
,
highQuality:
true
));
})
// Main layer.
..
addLayerOnTop
(
new
DrawLooperLayerInfo
(),
(
Paint
)
{}
);
..
addLayerOnTop
(
new
DrawLooperLayerInfo
(),
new
Paint
()
);
paint
.
setDrawLooper
(
builder
.
build
());
canvas
.
drawPaint
(
...
...
sky/engine/bindings/scripts/dart_types.py
浏览文件 @
15556f73
...
...
@@ -119,6 +119,7 @@ CPP_SPECIAL_CONVERSION_RULES = {
# instead of calling cpp_type.
'Float32List'
:
'Float32List'
,
'Offset'
:
'Offset'
,
'Paint'
:
'Paint'
,
'Point'
:
'Point'
,
'Rect'
:
'Rect'
,
'Size'
:
'Size'
,
...
...
@@ -371,6 +372,7 @@ DART_TO_CPP_VALUE = {
'Color'
:
pass_by_value_format
(
'CanvasColor'
),
'Float32List'
:
pass_by_value_format
(
'Float32List'
),
'Offset'
:
pass_by_value_format
(
'Offset'
),
'Paint'
:
pass_by_value_format
(
'Paint'
),
'Point'
:
pass_by_value_format
(
'Point'
),
'RSTransform'
:
pass_by_value_format
(
'RSTransform'
),
'Rect'
:
pass_by_value_format
(
'Rect'
),
...
...
sky/engine/core/core.gni
浏览文件 @
15556f73
...
...
@@ -425,8 +425,6 @@ sky_core_files = [
"painting/Drawable.h",
"painting/DrawLooper.cpp",
"painting/DrawLooper.h",
"painting/DrawLooperAddLayerCallback.cpp",
"painting/DrawLooperAddLayerCallback.h",
"painting/DrawLooperLayerInfo.cpp",
"painting/DrawLooperLayerInfo.h",
"painting/FilterQuality.h",
...
...
@@ -672,14 +670,12 @@ core_idl_files = get_path_info([
"painting/ColorFilter.idl",
"painting/Drawable.idl",
"painting/DrawLooper.idl",
"painting/DrawLooperAddLayerCallback.idl",
"painting/DrawLooperLayerInfo.idl",
"painting/Gradient.idl",
"painting/Image.idl",
"painting/LayerDrawLooperBuilder.idl",
"painting/LayoutRoot.idl",
"painting/MaskFilter.idl",
"painting/Paint.idl",
"painting/PaintingNode.idl",
"painting/Path.idl",
"painting/Picture.idl",
...
...
@@ -701,10 +697,11 @@ core_dart_files = get_path_info([
"painting/MaskFilter.dart",
"painting/Offset.dart",
"painting/OffsetBase.dart",
"painting/Paint.dart",
"painting/PaintingStyle.dart",
"painting/Point.dart",
"painting/RSTransform.dart",
"painting/Rect.dart",
"painting/RSTransform.dart",
"painting/Size.dart",
"painting/TransferMode.dart",
],
...
...
sky/engine/core/painting/Canvas.cpp
浏览文件 @
15556f73
...
...
@@ -32,12 +32,12 @@ void Canvas::save()
m_canvas
->
save
();
}
void
Canvas
::
saveLayer
(
const
Rect
&
bounds
,
const
Paint
*
paint
)
void
Canvas
::
saveLayer
(
const
Rect
&
bounds
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
m_canvas
->
saveLayer
(
!
bounds
.
is_null
?
&
bounds
.
sk_rect
:
nullptr
,
paint
?
&
paint
->
paint
()
:
nullptr
);
paint
.
paint
()
);
}
void
Canvas
::
restore
()
...
...
@@ -164,86 +164,78 @@ void Canvas::drawColor(SkColor color, SkXfermode::Mode transferMode)
m_canvas
->
drawColor
(
color
,
transferMode
);
}
void
Canvas
::
drawLine
(
const
Point
&
p1
,
const
Point
&
p2
,
const
Paint
*
paint
)
void
Canvas
::
drawLine
(
const
Point
&
p1
,
const
Point
&
p2
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
paint
);
m_canvas
->
drawLine
(
p1
.
sk_point
.
x
(),
p1
.
sk_point
.
y
(),
p2
.
sk_point
.
x
(),
p2
.
sk_point
.
y
(),
paint
->
paint
());
m_canvas
->
drawLine
(
p1
.
sk_point
.
x
(),
p1
.
sk_point
.
y
(),
p2
.
sk_point
.
x
(),
p2
.
sk_point
.
y
(),
paint
.
sk_paint
);
}
void
Canvas
::
drawPaint
(
const
Paint
*
paint
)
void
Canvas
::
drawPaint
(
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
paint
);
m_canvas
->
drawPaint
(
paint
->
paint
());
m_canvas
->
drawPaint
(
paint
.
sk_paint
);
}
void
Canvas
::
drawRect
(
const
Rect
&
rect
,
const
Paint
*
paint
)
void
Canvas
::
drawRect
(
const
Rect
&
rect
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
paint
);
m_canvas
->
drawRect
(
rect
.
sk_rect
,
paint
->
paint
());
m_canvas
->
drawRect
(
rect
.
sk_rect
,
paint
.
sk_paint
);
}
void
Canvas
::
drawRRect
(
const
RRect
*
rrect
,
const
Paint
*
paint
)
void
Canvas
::
drawRRect
(
const
RRect
*
rrect
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
rrect
);
ASSERT
(
paint
);
m_canvas
->
drawRRect
(
rrect
->
rrect
(),
paint
->
paint
());
m_canvas
->
drawRRect
(
rrect
->
rrect
(),
paint
.
sk_paint
);
}
void
Canvas
::
drawDRRect
(
const
RRect
*
outer
,
const
RRect
*
inner
,
const
Paint
*
paint
)
void
Canvas
::
drawDRRect
(
const
RRect
*
outer
,
const
RRect
*
inner
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
outer
);
ASSERT
(
inner
);
ASSERT
(
paint
);
m_canvas
->
drawDRRect
(
outer
->
rrect
(),
inner
->
rrect
(),
paint
->
paint
());
m_canvas
->
drawDRRect
(
outer
->
rrect
(),
inner
->
rrect
(),
paint
.
sk_paint
);
}
void
Canvas
::
drawOval
(
const
Rect
&
rect
,
const
Paint
*
paint
)
void
Canvas
::
drawOval
(
const
Rect
&
rect
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
paint
);
m_canvas
->
drawOval
(
rect
.
sk_rect
,
paint
->
paint
());
m_canvas
->
drawOval
(
rect
.
sk_rect
,
paint
.
sk_paint
);
}
void
Canvas
::
drawCircle
(
const
Point
&
c
,
float
radius
,
const
Paint
*
paint
)
void
Canvas
::
drawCircle
(
const
Point
&
c
,
float
radius
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
paint
);
m_canvas
->
drawCircle
(
c
.
sk_point
.
x
(),
c
.
sk_point
.
y
(),
radius
,
paint
->
paint
());
m_canvas
->
drawCircle
(
c
.
sk_point
.
x
(),
c
.
sk_point
.
y
(),
radius
,
paint
.
sk_paint
);
}
void
Canvas
::
drawPath
(
const
CanvasPath
*
path
,
const
Paint
*
paint
)
void
Canvas
::
drawPath
(
const
CanvasPath
*
path
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
path
);
ASSERT
(
paint
);
m_canvas
->
drawPath
(
path
->
path
(),
paint
->
paint
());
m_canvas
->
drawPath
(
path
->
path
(),
paint
.
sk_paint
);
}
void
Canvas
::
drawImage
(
const
CanvasImage
*
image
,
const
Point
&
p
,
const
Paint
*
paint
)
{
void
Canvas
::
drawImage
(
const
CanvasImage
*
image
,
const
Point
&
p
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
image
);
m_canvas
->
drawImage
(
image
->
image
(),
p
.
sk_point
.
x
(),
p
.
sk_point
.
y
(),
&
paint
->
paint
());
m_canvas
->
drawImage
(
image
->
image
(),
p
.
sk_point
.
x
(),
p
.
sk_point
.
y
(),
paint
.
paint
());
}
void
Canvas
::
drawImageRect
(
const
CanvasImage
*
image
,
Rect
&
src
,
Rect
&
dst
,
Paint
*
paint
)
{
void
Canvas
::
drawImageRect
(
const
CanvasImage
*
image
,
Rect
&
src
,
Rect
&
dst
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
image
);
m_canvas
->
drawImageRect
(
image
->
image
(),
&
src
.
sk_rect
,
dst
.
sk_rect
,
&
paint
->
paint
());
m_canvas
->
drawImageRect
(
image
->
image
(),
&
src
.
sk_rect
,
dst
.
sk_rect
,
paint
.
paint
());
}
void
Canvas
::
drawPicture
(
Picture
*
picture
)
...
...
@@ -275,7 +267,7 @@ void Canvas::drawPaintingNode(PaintingNode* paintingNode, const Point& p)
void
Canvas
::
drawAtlas
(
CanvasImage
*
atlas
,
const
Vector
<
RSTransform
>&
transforms
,
const
Vector
<
Rect
>&
rects
,
const
Vector
<
SkColor
>&
colors
,
SkXfermode
::
Mode
mode
,
const
Rect
&
cullRect
,
Paint
*
paint
,
ExceptionState
&
es
)
const
Rect
&
cullRect
,
const
Paint
&
paint
,
ExceptionState
&
es
)
{
if
(
!
m_canvas
)
return
;
...
...
@@ -309,7 +301,7 @@ void Canvas::drawAtlas(CanvasImage* atlas,
skXForms
.
size
(),
mode
,
cullRect
.
is_null
?
nullptr
:
&
cullRect
.
sk_rect
,
paint
?
&
paint
->
paint
()
:
nullptr
paint
.
paint
()
);
}
...
...
sky/engine/core/painting/Canvas.h
浏览文件 @
15556f73
...
...
@@ -61,7 +61,7 @@ public:
~
Canvas
()
override
;
void
save
();
void
saveLayer
(
const
Rect
&
bounds
,
const
Paint
*
paint
=
nullptr
);
void
saveLayer
(
const
Rect
&
bounds
,
const
Paint
&
paint
);
void
restore
();
void
translate
(
float
dx
,
float
dy
);
...
...
@@ -78,16 +78,16 @@ public:
void
clipPath
(
const
CanvasPath
*
path
);
void
drawColor
(
SkColor
color
,
SkXfermode
::
Mode
transferMode
);
void
drawLine
(
const
Point
&
p1
,
const
Point
&
p2
,
const
Paint
*
paint
);
void
drawPaint
(
const
Paint
*
paint
);
void
drawRect
(
const
Rect
&
rect
,
const
Paint
*
paint
);
void
drawRRect
(
const
RRect
*
rrect
,
const
Paint
*
paint
);
void
drawDRRect
(
const
RRect
*
outer
,
const
RRect
*
inner
,
const
Paint
*
paint
);
void
drawOval
(
const
Rect
&
rect
,
const
Paint
*
paint
);
void
drawCircle
(
const
Point
&
c
,
float
radius
,
const
Paint
*
paint
);
void
drawPath
(
const
CanvasPath
*
path
,
const
Paint
*
paint
);
void
drawImage
(
const
CanvasImage
*
image
,
const
Point
&
p
,
const
Paint
*
paint
);
void
drawImageRect
(
const
CanvasImage
*
image
,
Rect
&
src
,
Rect
&
dst
,
Paint
*
paint
);
void
drawLine
(
const
Point
&
p1
,
const
Point
&
p2
,
const
Paint
&
paint
);
void
drawPaint
(
const
Paint
&
paint
);
void
drawRect
(
const
Rect
&
rect
,
const
Paint
&
paint
);
void
drawRRect
(
const
RRect
*
rrect
,
const
Paint
&
paint
);
void
drawDRRect
(
const
RRect
*
outer
,
const
RRect
*
inner
,
const
Paint
&
paint
);
void
drawOval
(
const
Rect
&
rect
,
const
Paint
&
paint
);
void
drawCircle
(
const
Point
&
c
,
float
radius
,
const
Paint
&
paint
);
void
drawPath
(
const
CanvasPath
*
path
,
const
Paint
&
paint
);
void
drawImage
(
const
CanvasImage
*
image
,
const
Point
&
p
,
const
Paint
&
paint
);
void
drawImageRect
(
const
CanvasImage
*
image
,
Rect
&
src
,
Rect
&
dst
,
const
Paint
&
paint
);
void
drawPicture
(
Picture
*
picture
);
void
drawDrawable
(
Drawable
*
drawable
);
void
drawPaintingNode
(
PaintingNode
*
paintingNode
,
const
Point
&
p
);
...
...
@@ -95,7 +95,7 @@ public:
void
drawAtlas
(
CanvasImage
*
atlas
,
const
Vector
<
RSTransform
>&
transforms
,
const
Vector
<
Rect
>&
rects
,
const
Vector
<
SkColor
>&
colors
,
SkXfermode
::
Mode
mode
,
const
Rect
&
cullRect
,
Paint
*
paint
,
ExceptionState
&
);
const
Rect
&
cullRect
,
const
Paint
&
paint
,
ExceptionState
&
);
SkCanvas
*
skCanvas
()
{
return
m_canvas
;
}
void
clearSkCanvas
()
{
m_canvas
=
nullptr
;
}
...
...
sky/engine/core/painting/DrawLooperAddLayerCallback.cpp
已删除
100644 → 0
浏览文件 @
e2bc694a
// Copyright 2015 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.
#include "sky/engine/core/painting/DrawLooperAddLayerCallback.h"
namespace
blink
{
DrawLooperAddLayerCallback
::~
DrawLooperAddLayerCallback
()
{
}
}
// namespace blink
sky/engine/core/painting/DrawLooperAddLayerCallback.h
已删除
100644 → 0
浏览文件 @
e2bc694a
// Copyright 2015 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 SKY_ENGINE_CORE_PAINTING_DRAWLOOPERADDLAYERCALLBACK_H_
#define SKY_ENGINE_CORE_PAINTING_DRAWLOOPERADDLAYERCALLBACK_H_
namespace
blink
{
class
Paint
;
class
DrawLooperAddLayerCallback
{
public:
virtual
~
DrawLooperAddLayerCallback
();
virtual
void
handleEvent
(
Paint
*
context
)
=
0
;
};
}
// namespace blink
#endif // SKY_ENGINE_CORE_PAINTING_DRAWLOOPERADDLAYERCALLBACK_H_
sky/engine/core/painting/DrawLooperAddLayerCallback.idl
已删除
100644 → 0
浏览文件 @
e2bc694a
//
Copyright
2015
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
.
callback
interface
DrawLooperAddLayerCallback
{
void
handleEvent
(
Paint
paint
)
;
}
;
sky/engine/core/painting/LayerDrawLooperBuilder.cpp
浏览文件 @
15556f73
...
...
@@ -5,7 +5,6 @@
#include "sky/engine/core/painting/LayerDrawLooperBuilder.h"
#include "sky/engine/core/painting/DrawLooper.h"
#include "sky/engine/core/painting/DrawLooperAddLayerCallback.h"
#include "sky/engine/core/painting/DrawLooperLayerInfo.h"
#include "sky/engine/core/painting/Paint.h"
#include "third_party/skia/include/core/SkColorFilter.h"
...
...
@@ -23,15 +22,11 @@ PassRefPtr<DrawLooper> LayerDrawLooperBuilder::build() {
}
void
LayerDrawLooperBuilder
::
addLayerOnTop
(
DrawLooperLayerInfo
*
layer_info
,
PassOwnPtr
<
DrawLooperAddLayerCallback
>
callback
)
{
DrawLooperLayerInfo
*
layer_info
,
const
Paint
&
paint
)
{
SkPaint
*
sk_paint
=
draw_looper_builder_
.
addLayerOnTop
(
layer_info
->
layer_info
());
RefPtr
<
Paint
>
paint
=
Paint
::
create
();
paint
->
setPaint
(
*
sk_paint
);
callback
->
handleEvent
(
paint
.
get
());
*
sk_paint
=
paint
->
paint
();
if
(
!
paint
.
is_null
)
*
sk_paint
=
paint
.
sk_paint
;
}
}
// namespace blink
sky/engine/core/painting/LayerDrawLooperBuilder.h
浏览文件 @
15556f73
...
...
@@ -5,6 +5,7 @@
#ifndef SKY_ENGINE_CORE_PAINTING_LAYERDRAWLOOPERBUILDER_H_
#define SKY_ENGINE_CORE_PAINTING_LAYERDRAWLOOPERBUILDER_H_
#include "sky/engine/core/painting/Paint.h"
#include "sky/engine/tonic/dart_wrappable.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/RefCounted.h"
...
...
@@ -13,7 +14,6 @@
namespace
blink
{
class
DrawLooper
;
class
DrawLooperAddLayerCallback
;
class
DrawLooperLayerInfo
;
class
LayerDrawLooperBuilder
:
public
RefCounted
<
LayerDrawLooperBuilder
>
,
...
...
@@ -26,8 +26,7 @@ class LayerDrawLooperBuilder : public RefCounted<LayerDrawLooperBuilder>,
}
PassRefPtr
<
DrawLooper
>
build
();
void
addLayerOnTop
(
DrawLooperLayerInfo
*
layer_info
,
PassOwnPtr
<
DrawLooperAddLayerCallback
>
);
void
addLayerOnTop
(
DrawLooperLayerInfo
*
layer_info
,
const
Paint
&
paint
);
private:
LayerDrawLooperBuilder
();
...
...
sky/engine/core/painting/LayerDrawLooperBuilder.idl
浏览文件 @
15556f73
...
...
@@ -8,5 +8,5 @@
//
builder
back
to
a
default
state
.
DrawLooper
build
()
;
void
addLayerOnTop
(
DrawLooperLayerInfo
info
,
DrawLooperAddLayerCallback
callback
)
;
void
addLayerOnTop
(
DrawLooperLayerInfo
info
,
Paint
paint
)
;
}
;
sky/engine/core/painting/Paint.cpp
浏览文件 @
15556f73
...
...
@@ -4,88 +4,95 @@
#include "sky/engine/core/painting/Paint.h"
#include "sky/engine/core/painting/CanvasColor.h"
#include "sky/engine/core/painting/ColorFilter.h"
#include "sky/engine/core/painting/DrawLooper.h"
#include "sky/engine/core/painting/FilterQuality.h"
#include "sky/engine/core/painting/MaskFilter.h"
#include "sky/engine/core/painting/PaintingStyle.h"
#include "sky/engine/core/painting/Shader.h"
#include "sky/engine/core/painting/TransferMode.h"
#include "sky/engine/core/script/dom_dart_state.h"
#include "sky/engine/wtf/text/StringBuilder.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkMaskFilter.h"
#include "third_party/skia/include/core/SkShader.h"
#include "third_party/skia/include/core/SkString.h"
namespace
blink
{
#include <iostream>
namespace
blink
{
namespace
{
template
<
typename
T
>
void
SkToString
(
const
char
*
title
,
const
T
*
sk_object
,
StringBuilder
*
result
)
{
if
(
!
sk_object
)
return
;
SkString
string
;
sk_object
->
toString
(
&
string
);
result
->
append
(
String
::
format
(
", %s: %s"
,
title
,
string
.
c_str
()));
}
}
Paint
::
Paint
()
{
setIsAntiAlias
(
true
);
}
Paint
::~
Paint
()
{
}
void
Paint
::
setDrawLooper
(
DrawLooper
*
looper
)
{
ASSERT
(
looper
);
paint_
.
setLooper
(
looper
->
looper
());
}
void
Paint
::
setColorFilter
(
ColorFilter
*
filter
)
{
ASSERT
(
filter
);
paint_
.
setColorFilter
(
filter
->
filter
());
}
void
Paint
::
setMaskFilter
(
MaskFilter
*
filter
)
{
ASSERT
(
filter
);
paint_
.
setMaskFilter
(
filter
->
filter
());
}
void
Paint
::
setShader
(
Shader
*
shader
)
{
ASSERT
(
shader
);
paint_
.
setShader
(
shader
->
shader
());
}
void
Paint
::
setStyle
(
SkPaint
::
Style
style
)
{
paint_
.
setStyle
(
style
);
}
enum
PaintFields
{
kStrokeWidth
,
kIsAntiAlias
,
kColor
,
kColorFilter
,
kDrawLooper
,
kFilterQuality
,
kMaskFilter
,
kShader
,
kStyle
,
kTransferMode
,
// kNumberOfPaintFields must be last.
kNumberOfPaintFields
,
};
void
Paint
::
setTransferMode
(
SkXfermode
::
Mode
transfer_mode
)
{
paint_
.
setXfermodeMode
(
transfer_mode
);
}
void
Paint
::
setFilterQuality
(
SkFilterQuality
filter_quality
)
{
paint_
.
setFilterQuality
(
filter_quality
);
Paint
DartConverter
<
Paint
>::
FromDart
(
Dart_Handle
dart_paint
)
{
Paint
result
;
result
.
is_null
=
true
;
if
(
Dart_IsNull
(
dart_paint
))
return
result
;
Dart_Handle
value_handle
=
DOMDartState
::
Current
()
->
value_handle
();
Dart_Handle
data
=
Dart_GetField
(
dart_paint
,
value_handle
);
DCHECK
(
Dart_IsList
(
data
));
intptr_t
length
;
Dart_ListLength
(
data
,
&
length
);
CHECK_EQ
(
length
,
kNumberOfPaintFields
);
Dart_Handle
values
[
kNumberOfPaintFields
];
for
(
int
i
=
0
;
i
<
kNumberOfPaintFields
;
++
i
)
values
[
i
]
=
Dart_ListGetAt
(
data
,
i
);
SkPaint
&
paint
=
result
.
sk_paint
;
if
(
!
Dart_IsNull
(
values
[
kStrokeWidth
]))
paint
.
setStrokeWidth
(
DartConverter
<
SkScalar
>::
FromDart
(
values
[
kStrokeWidth
]));
if
(
!
Dart_IsNull
(
values
[
kIsAntiAlias
]))
paint
.
setAntiAlias
(
DartConverter
<
bool
>::
FromDart
(
values
[
kIsAntiAlias
]));
if
(
!
Dart_IsNull
(
values
[
kColor
]))
paint
.
setColor
(
DartConverter
<
CanvasColor
>::
FromDart
(
values
[
kColor
]));
if
(
!
Dart_IsNull
(
values
[
kColorFilter
]))
paint
.
setColorFilter
(
DartConverter
<
ColorFilter
*>::
FromDart
(
values
[
kColorFilter
])
->
filter
());
if
(
!
Dart_IsNull
(
values
[
kDrawLooper
]))
paint
.
setLooper
(
DartConverter
<
DrawLooper
*>::
FromDart
(
values
[
kDrawLooper
])
->
looper
());
if
(
!
Dart_IsNull
(
values
[
kFilterQuality
]))
paint
.
setFilterQuality
(
DartConverter
<
FilterQuality
>::
FromDart
(
values
[
kFilterQuality
]));
if
(
!
Dart_IsNull
(
values
[
kMaskFilter
]))
paint
.
setMaskFilter
(
DartConverter
<
MaskFilter
*>::
FromDart
(
values
[
kMaskFilter
])
->
filter
());
if
(
!
Dart_IsNull
(
values
[
kShader
]))
paint
.
setShader
(
DartConverter
<
Shader
*>::
FromDart
(
values
[
kShader
])
->
shader
());
if
(
!
Dart_IsNull
(
values
[
kStyle
]))
paint
.
setStyle
(
DartConverter
<
PaintingStyle
>::
FromDart
(
values
[
kStyle
]));
if
(
!
Dart_IsNull
(
values
[
kTransferMode
]))
paint
.
setXfermodeMode
(
DartConverter
<
TransferMode
>::
FromDart
(
values
[
kTransferMode
]));
result
.
is_null
=
false
;
return
result
;
}
String
Paint
::
toString
()
const
{
StringBuilder
result
;
result
.
append
(
"Paint("
);
result
.
append
(
String
::
format
(
"color:Color(0x%.8x)"
,
paint_
.
getColor
()));
SkToString
(
"shader"
,
paint_
.
getShader
(),
&
result
);
SkToString
(
"colorFilter"
,
paint_
.
getColorFilter
(),
&
result
);
SkToString
(
"maskFilter"
,
paint_
.
getMaskFilter
(),
&
result
);
if
(
paint_
.
getLooper
())
{
// TODO(mpcomplete): Figure out how to show a drawLooper.
result
.
append
(
", drawLooper:true"
);
}
result
.
append
(
")"
);
return
result
.
toString
();
Paint
DartConverter
<
Paint
>::
FromArgumentsWithNullCheck
(
Dart_NativeArguments
args
,
int
index
,
Dart_Handle
&
exception
)
{
Dart_Handle
dart_rect
=
Dart_GetNativeArgument
(
args
,
index
);
DCHECK
(
!
LogIfError
(
dart_rect
));
return
FromDart
(
dart_rect
);
}
}
// namespace blink
sky/engine/core/painting/Paint.dart
0 → 100644
浏览文件 @
15556f73
// Copyright 2015 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.
part of
dart
.
sky
;
class
Paint
{
void
setColorFilter
(
ColorFilter
colorFilter
)
{
_colorFilter
=
colorFilter
;
}
void
setDrawLooper
(
DrawLooper
drawLooper
)
{
_drawLooper
=
drawLooper
;
}
void
setFilterQuality
(
FilterQuality
filterQuality
)
{
_filterQuality
=
filterQuality
;
}
void
setMaskFilter
(
MaskFilter
maskFilter
)
{
_maskFilter
=
maskFilter
;
}
void
setStyle
(
PaintingStyle
style
)
{
_style
=
style
;
}
void
setShader
(
Shader
shader
)
{
_shader
=
shader
;
}
void
setTransferMode
(
TransferMode
transferMode
)
{
_transferMode
=
transferMode
;
}
double
strokeWidth
;
bool
isAntiAlias
=
true
;
Color
color
=
const
Color
(
0xFF000000
);
ColorFilter
_colorFilter
;
DrawLooper
_drawLooper
;
FilterQuality
_filterQuality
;
MaskFilter
_maskFilter
;
Shader
_shader
;
PaintingStyle
_style
;
TransferMode
_transferMode
;
// Must match PaintFields enum in Paint.cpp.
List
<
dynamic
>
get
_value
{
return
[
strokeWidth
,
isAntiAlias
,
color
,
_colorFilter
,
_drawLooper
,
_filterQuality
,
_maskFilter
,
_shader
,
_style
,
_transferMode
,
];
}
String
toString
()
{
String
result
=
'Paint(color:
$color
'
;
if
(
_shader
!=
null
)
result
+=
', shader:
$_shader
'
;
if
(
_colorFilter
!=
null
)
result
+=
', colorFilter:
$_colorFilter
'
;
if
(
_maskFilter
!=
null
)
result
+=
', maskFilter:
$_maskFilter
'
;
// TODO(mpcomplete): Figure out how to show a drawLooper.
if
(
_drawLooper
!=
null
)
result
+=
', drawLooper:true'
;
result
+=
')'
;
return
result
;
}
}
sky/engine/core/painting/Paint.h
浏览文件 @
15556f73
...
...
@@ -22,40 +22,20 @@ class ColorFilter;
class
MaskFilter
;
class
Shader
;
class
Paint
:
public
RefCounted
<
Paint
>
,
public
DartWrappable
{
DEFINE_WRAPPERTYPEINFO
();
class
Paint
{
public:
~
Paint
()
override
;
static
PassRefPtr
<
Paint
>
create
()
{
return
adoptRef
(
new
Paint
);
}
SkPaint
sk_paint
;
bool
is_null
;
bool
isAntiAlias
()
const
{
return
paint_
.
isAntiAlias
();
}
void
setIsAntiAlias
(
bool
value
)
{
paint_
.
setAntiAlias
(
value
);
}
SkColor
color
()
const
{
return
paint_
.
getColor
();
}
void
setColor
(
SkColor
color
)
{
paint_
.
setColor
(
color
);
}
SkScalar
strokeWidth
()
const
{
return
paint_
.
getStrokeWidth
();
}
void
setStrokeWidth
(
SkScalar
strokeWidth
)
{
paint_
.
setStrokeWidth
(
strokeWidth
);
}
void
setDrawLooper
(
DrawLooper
*
looper
);
void
setColorFilter
(
ColorFilter
*
filter
);
void
setMaskFilter
(
MaskFilter
*
filter
);
void
setShader
(
Shader
*
shader
);
void
setStyle
(
SkPaint
::
Style
style
);
void
setTransferMode
(
SkXfermode
::
Mode
transfer_mode
);
void
setFilterQuality
(
SkFilterQuality
filter_quality
);
const
SkPaint
&
paint
()
const
{
return
paint_
;
}
void
setPaint
(
const
SkPaint
&
paint
)
{
paint_
=
paint
;
}
String
toString
()
const
;
private:
Paint
();
const
SkPaint
*
paint
()
const
{
return
is_null
?
nullptr
:
&
sk_paint
;
}
};
SkPaint
paint_
;
template
<
>
struct
DartConverter
<
Paint
>
{
static
Paint
FromDart
(
Dart_Handle
handle
);
static
Paint
FromArgumentsWithNullCheck
(
Dart_NativeArguments
args
,
int
index
,
Dart_Handle
&
exception
);
};
}
// namespace blink
...
...
sky/engine/core/painting/Paint.idl
已删除
100644 → 0
浏览文件 @
e2bc694a
//
Copyright
2015
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
.
[
Constructor
(),
]
interface
Paint
{
attribute
float
strokeWidth
;
attribute
boolean
isAntiAlias
;
attribute
Color
color
;
void
setDrawLooper
(
DrawLooper
looper
)
;
void
setColorFilter
(
ColorFilter
filter
)
;
void
setMaskFilter
(
MaskFilter
filter
)
;
void
setShader
(
Shader
shader
)
;
void
setStyle
(
PaintingStyle
style
)
;
void
setTransferMode
(
TransferMode
transferMode
)
;
void
setFilterQuality
(
FilterQuality
filterQuality
)
;
DOMString
toString
()
;
}
;
sky/engine/tonic/dart_converter.h
浏览文件 @
15556f73
...
...
@@ -166,9 +166,12 @@ struct DartConverterEnum {
static
T
FromArguments
(
Dart_NativeArguments
args
,
int
index
,
Dart_Handle
&
exception
)
{
Dart_Handle
enum_handle
=
Dart_GetNativeArgument
(
args
,
index
);
return
FromDart
(
Dart_GetNativeArgument
(
args
,
index
));
}
static
T
FromDart
(
Dart_Handle
handle
)
{
Dart_Handle
index_handle
=
Dart_GetField
(
enum_
handle
,
DartState
::
Current
()
->
index_handle
());
Dart_GetField
(
handle
,
DartState
::
Current
()
->
index_handle
());
uint64_t
enum_index
=
0
;
Dart_IntegerToUint64
(
index_handle
,
&
enum_index
);
...
...
sky/packages/sky/lib/painting/shadows.dart
浏览文件 @
15556f73
...
...
@@ -15,15 +15,13 @@ class ShadowDrawLooperBuilder {
..
setPaintBits
(
sky
.
PaintBits
.
all
)
..
setOffset
(
offset
)
..
setColorMode
(
sky
.
TransferMode
.
src
),
(
sky
.
Paint
layerPaint
)
{
layerPaint
.
color
=
color
;
layerPaint
.
setMaskFilter
(
new
sky
.
MaskFilter
.
blur
(
sky
.
BlurStyle
.
normal
,
blur
));
});
new
sky
.
Paint
()
..
color
=
color
..
setMaskFilter
(
new
sky
.
MaskFilter
.
blur
(
sky
.
BlurStyle
.
normal
,
blur
)));
}
sky
.
DrawLooper
build
()
{
builder_
.
addLayerOnTop
(
new
sky
.
DrawLooperLayerInfo
(),
(
_
)
{}
);
builder_
.
addLayerOnTop
(
new
sky
.
DrawLooperLayerInfo
(),
new
sky
.
Paint
()
);
return
builder_
.
build
();
}
}
sky/tests/painting/canvas.dart
浏览文件 @
15556f73
...
...
@@ -20,6 +20,7 @@ void main() {
// So only scale to 1x in the z direction.
matrix
.
scale
(
2.0
,
2.0
,
1.0
);
canvas
.
setMatrix
(
matrix
.
storage
);
canvas
.
drawPaint
(
new
Paint
()..
color
=
const
Color
(
0xFF00FF00
));
expect
(
canvas
.
getTotalMatrix
(),
equals
(
matrix
.
storage
));
});
...
...
sky/tests/raw/render_box-expected.txt
浏览文件 @
15556f73
...
...
@@ -5,7 +5,7 @@ PAINT FOR FRAME #1 ----------------------------------------------
1 | TestPaintingCanvas() constructor: 800.0 x 600.0
1 | paintChild RenderDecoratedBox at Point(0.0, 0.0)
1 | | TestPaintingCanvas() constructor: 800.0 x 600.0
1 | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), Paint(color:Color(0xff00ff00), shader:
SkRadialGradient: (center: (0, 0) radius: 500 2 colors: FFFFEB3B, FF2196F3 clamp)
, drawLooper:true))
1 | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), Paint(color:Color(0xff00ff00), shader:
Instance of 'Gradient'
, drawLooper:true))
------------------------------------------------------------------------
PASS: should size to render view
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录