Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
2e693b17
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,发现更多精彩内容 >>
提交
2e693b17
编写于
12月 28, 2015
作者:
A
Adam Barth
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove IDL from Shader subclasses
- Gradient - ImageShader
上级
610ab574
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
157 addition
and
119 deletion
+157
-119
sky/engine/bindings/dart_ui.cc
sky/engine/bindings/dart_ui.cc
+6
-2
sky/engine/core/core.gni
sky/engine/core/core.gni
+0
-5
sky/engine/core/dart/painting.dart
sky/engine/core/dart/painting.dart
+73
-0
sky/engine/core/painting/CanvasColor.h
sky/engine/core/painting/CanvasColor.h
+1
-1
sky/engine/core/painting/CanvasGradient.cpp
sky/engine/core/painting/CanvasGradient.cpp
+26
-0
sky/engine/core/painting/CanvasGradient.h
sky/engine/core/painting/CanvasGradient.h
+7
-5
sky/engine/core/painting/Gradient.dart
sky/engine/core/painting/Gradient.dart
+0
-54
sky/engine/core/painting/Gradient.idl
sky/engine/core/painting/Gradient.idl
+0
-14
sky/engine/core/painting/ImageShader.cpp
sky/engine/core/painting/ImageShader.cpp
+32
-0
sky/engine/core/painting/ImageShader.dart
sky/engine/core/painting/ImageShader.dart
+0
-20
sky/engine/core/painting/ImageShader.h
sky/engine/core/painting/ImageShader.h
+3
-0
sky/engine/core/painting/ImageShader.idl
sky/engine/core/painting/ImageShader.idl
+0
-10
sky/engine/core/painting/Point.cpp
sky/engine/core/painting/Point.cpp
+1
-1
sky/engine/core/painting/Point.h
sky/engine/core/painting/Point.h
+6
-1
sky/engine/core/painting/Shader.cpp
sky/engine/core/painting/Shader.cpp
+2
-0
sky/engine/core/painting/Shader.idl
sky/engine/core/painting/Shader.idl
+0
-6
未找到文件。
sky/engine/bindings/dart_ui.cc
浏览文件 @
2e693b17
...
...
@@ -8,10 +8,12 @@
#include "sky/engine/bindings/dart_runtime_hooks.h"
#include "sky/engine/core/compositing/Scene.h"
#include "sky/engine/core/compositing/SceneBuilder.h"
#include "sky/engine/core/painting/CanvasGradient.h"
#include "sky/engine/core/painting/ColorFilter.h"
#include "sky/engine/core/painting/MaskFilter.h"
#include "sky/engine/core/painting/DrawLooperLayerInfo.h"
#include "sky/engine/core/painting/ImageShader.h"
#include "sky/engine/core/painting/LayerDrawLooperBuilder.h"
#include "sky/engine/core/painting/MaskFilter.h"
#include "sky/engine/core/painting/painting.h"
#include "sky/engine/core/text/Paragraph.h"
#include "sky/engine/core/text/ParagraphBuilder.h"
...
...
@@ -45,10 +47,12 @@ const uint8_t* GetSymbol(Dart_NativeFunction native_function) {
void
DartUI
::
InitForIsolate
()
{
if
(
!
g_natives
)
{
g_natives
=
new
DartLibraryNatives
();
CanvasGradient
::
RegisterNatives
(
g_natives
);
ColorFilter
::
RegisterNatives
(
g_natives
);
DartRuntimeHooks
::
RegisterNatives
(
g_natives
);
DrawLooperLayerInfo
::
RegisterNatives
(
g_natives
);
ImageShader
::
RegisterNatives
(
g_natives
);
LayerDrawLooperBuilder
::
RegisterNatives
(
g_natives
);
ColorFilter
::
RegisterNatives
(
g_natives
);
MaskFilter
::
RegisterNatives
(
g_natives
);
Painting
::
RegisterNatives
(
g_natives
);
Paragraph
::
RegisterNatives
(
g_natives
);
...
...
sky/engine/core/core.gni
浏览文件 @
2e693b17
...
...
@@ -235,13 +235,10 @@ sky_core_files = [
core_idl_files = get_path_info([
"painting/Canvas.idl",
"painting/Gradient.idl",
"painting/Image.idl",
"painting/ImageShader.idl",
"painting/Path.idl",
"painting/Picture.idl",
"painting/PictureRecorder.idl",
"painting/Shader.idl",
],
"abspath")
...
...
@@ -256,8 +253,6 @@ core_dart_files = get_path_info([
"dart/window.dart",
"painting/Color.dart",
"painting/FilterQuality.dart",
"painting/Gradient.dart",
"painting/ImageShader.dart",
"painting/Offset.dart",
"painting/OffsetBase.dart",
"painting/Paint.dart",
...
...
sky/engine/core/dart/painting.dart
浏览文件 @
2e693b17
...
...
@@ -83,3 +83,76 @@ class ColorFilter extends NativeFieldWrapperClass2 {
_constructor
(
color
,
transferMode
);
}
}
abstract
class
Shader
extends
NativeFieldWrapperClass2
{
}
/// Defines what happens at the edge of the gradient.
enum
TileMode
{
/// Edge is clamped to the final color.
clamp
,
/// Edge is repeated from first color to last.
repeated
,
/// Edge is mirrored from last color to first.
mirror
}
void
_validateColorStops
(
List
<
Color
>
colors
,
List
<
double
>
colorStops
)
{
if
(
colorStops
!=
null
&&
(
colors
==
null
||
colors
.
length
!=
colorStops
.
length
))
{
throw
new
ArgumentError
(
"[colors] and [colorStops] parameters must be equal length."
);
}
}
class
Gradient
extends
Shader
{
void
_constructor
()
native
"Gradient_constructor"
;
void
_initLinear
(
List
<
Point
>
endPoints
,
List
<
Color
>
colors
,
List
<
double
>
colorStops
,
int
tileMode
)
native
"Gradient_initLinear"
;
void
_initRadial
(
Point
center
,
double
radius
,
List
<
Color
>
colors
,
List
<
double
>
colorStops
,
int
tileMode
)
native
"Gradient_initRadial"
;
/// Creates a linear gradient from [endPoint[0]] to [endPoint[1]]. If
/// [colorStops] is provided, [colorStops[i]] is a number from 0 to 1 that
/// specifies where [color[i]] begins in the gradient.
// TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead?
Gradient
.
linear
(
List
<
Point
>
endPoints
,
List
<
Color
>
colors
,
[
List
<
double
>
colorStops
=
null
,
TileMode
tileMode
=
TileMode
.
clamp
])
{
_constructor
();
if
(
endPoints
==
null
||
endPoints
.
length
!=
2
)
throw
new
ArgumentError
(
"Expected exactly 2 [endPoints]."
);
_validateColorStops
(
colors
,
colorStops
);
_initLinear
(
endPoints
,
colors
,
colorStops
,
tileMode
.
index
);
}
/// Creates a radial gradient centered at [center] that ends at [radius]
/// distance from the center. If [colorStops] is provided, [colorStops[i]] is
/// a number from 0 to 1 that specifies where [color[i]] begins in the
/// gradient.
Gradient
.
radial
(
Point
center
,
double
radius
,
List
<
Color
>
colors
,
[
List
<
double
>
colorStops
=
null
,
TileMode
tileMode
=
TileMode
.
clamp
])
{
_constructor
();
_validateColorStops
(
colors
,
colorStops
);
_initRadial
(
center
,
radius
,
colors
,
colorStops
,
tileMode
.
index
);
}
}
class
ImageShader
extends
Shader
{
void
_constructor
()
native
"ImageShader_constructor"
;
void
_initWithImage
(
Image
image
,
int
tmx
,
int
tmy
,
Float64List
matrix4
)
native
"ImageShader_initWithImage"
;
ImageShader
(
Image
image
,
TileMode
tmx
,
TileMode
tmy
,
Float64List
matrix4
)
{
if
(
image
==
null
)
throw
new
ArgumentError
(
"[image] argument cannot be null"
);
if
(
tmx
==
null
)
throw
new
ArgumentError
(
"[tmx] argument cannot be null"
);
if
(
tmy
==
null
)
throw
new
ArgumentError
(
"[tmy] argument cannot be null"
);
if
(
matrix4
==
null
)
throw
new
ArgumentError
(
"[matrix4] argument cannot be null"
);
_initWithImage
(
image
,
tmx
.
index
,
tmy
.
index
,
matrix4
);
}
}
sky/engine/core/painting/CanvasColor.h
浏览文件 @
2e693b17
...
...
@@ -18,7 +18,7 @@ struct CanvasColor {
CanvasColor
(
SkColor
color
)
:
color
(
color
)
{
}
CanvasColor
()
:
color
()
{
}
operator
SkColor
()
{
return
color
;
}
operator
SkColor
()
const
{
return
color
;
}
};
template
<
>
...
...
sky/engine/core/painting/CanvasGradient.cpp
浏览文件 @
2e693b17
...
...
@@ -4,8 +4,34 @@
#include "sky/engine/core/painting/CanvasGradient.h"
#include "sky/engine/tonic/dart_args.h"
#include "sky/engine/tonic/dart_binding_macros.h"
#include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_library_natives.h"
namespace
blink
{
typedef
CanvasGradient
Gradient
;
// Because the C++ name doesn't match the Dart name.
static
void
Gradient_constructor
(
Dart_NativeArguments
args
)
{
DartCallConstructor
(
&
CanvasGradient
::
create
,
args
);
}
IMPLEMENT_WRAPPERTYPEINFO
(
Gradient
);
#define FOR_EACH_BINDING(V) \
V(Gradient, initLinear) \
V(Gradient, initRadial)
FOR_EACH_BINDING
(
DART_NATIVE_CALLBACK
)
void
CanvasGradient
::
RegisterNatives
(
DartLibraryNatives
*
natives
)
{
natives
->
Register
({
{
"Gradient_constructor"
,
Gradient_constructor
,
1
,
true
},
FOR_EACH_BINDING
(
DART_REGISTER_NATIVE
)
});
}
PassRefPtr
<
CanvasGradient
>
CanvasGradient
::
create
()
{
return
adoptRef
(
new
CanvasGradient
());
}
...
...
sky/engine/core/painting/CanvasGradient.h
浏览文件 @
2e693b17
...
...
@@ -12,16 +12,15 @@
#include "third_party/skia/include/effects/SkGradientShader.h"
namespace
blink
{
class
TileMode
{};
class
DartLibraryNatives
;
template
<
>
struct
DartConverter
<
TileMode
>
:
public
DartConverterEnum
<
SkShader
::
TileMode
>
{};
struct
DartConverter
<
SkShader
::
TileMode
>
:
public
DartConverterInteger
<
SkShader
::
TileMode
>
{};
COMPILE_ASSERT
(
SkShader
::
kTileModeCount
==
3
,
Need_to_update_
Gradient_dart
);
COMPILE_ASSERT
(
SkShader
::
kTileModeCount
==
3
,
Need_to_update_
TileMode_enum
);
class
CanvasGradient
:
public
Shader
{
DEFINE_WRAPPERTYPEINFO
();
DEFINE_WRAPPERTYPEINFO
();
public:
~
CanvasGradient
()
override
;
static
PassRefPtr
<
CanvasGradient
>
create
();
...
...
@@ -30,12 +29,15 @@ class CanvasGradient : public Shader {
const
Vector
<
SkColor
>&
colors
,
const
Vector
<
float
>&
color_stops
,
SkShader
::
TileMode
tile_mode
);
void
initRadial
(
const
Point
&
center
,
double
radius
,
const
Vector
<
SkColor
>&
colors
,
const
Vector
<
float
>&
color_stops
,
SkShader
::
TileMode
tile_mode
);
static
void
RegisterNatives
(
DartLibraryNatives
*
natives
);
private:
CanvasGradient
();
};
...
...
sky/engine/core/painting/Gradient.dart
已删除
100644 → 0
浏览文件 @
610ab574
// 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_ui
;
/// Defines what happens at the edge of the gradient.
enum
TileMode
{
/// Edge is clamped to the final color.
clamp
,
/// Edge is repeated from first color to last.
repeated
,
/// Edge is mirrored from last color to first.
mirror
}
/// Extends the generated _Gradient interface via the PrivateDart attribute.
class
Gradient
extends
_Gradient
{
/// Creates a linear gradient from [endPoint[0]] to [endPoint[1]]. If
/// [colorStops] is provided, [colorStops[i]] is a number from 0 to 1 that
/// specifies where [color[i]] begins in the gradient.
// TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead?
Gradient
.
linear
(
List
<
Point
>
endPoints
,
List
<
Color
>
colors
,
[
List
<
double
>
colorStops
=
null
,
TileMode
tileMode
=
TileMode
.
clamp
])
:
super
()
{
if
(
endPoints
==
null
||
endPoints
.
length
!=
2
)
throw
new
ArgumentError
(
"Expected exactly 2 [endPoints]."
);
validateColorStops
(
colors
,
colorStops
);
this
.
_initLinear
(
endPoints
,
colors
,
colorStops
,
tileMode
);
}
/// Creates a radial gradient centered at [center] that ends at [radius]
/// distance from the center. If [colorStops] is provided, [colorStops[i]] is
/// a number from 0 to 1 that specifies where [color[i]] begins in the
/// gradient.
Gradient
.
radial
(
Point
center
,
double
radius
,
List
<
Color
>
colors
,
[
List
<
double
>
colorStops
=
null
,
TileMode
tileMode
=
TileMode
.
clamp
])
:
super
()
{
validateColorStops
(
colors
,
colorStops
);
this
.
_initRadial
(
center
,
radius
,
colors
,
colorStops
,
tileMode
);
}
void
validateColorStops
(
List
<
Color
>
colors
,
List
<
double
>
colorStops
)
{
if
(
colorStops
!=
null
&&
(
colors
==
null
||
colors
.
length
!=
colorStops
.
length
))
{
throw
new
ArgumentError
(
"[colors] and [colorStops] parameters must be equal length."
);
}
}
}
sky/engine/core/painting/Gradient.idl
已删除
100644 → 0
浏览文件 @
610ab574
//
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
.
[
ImplementedAs
=
CanvasGradient
,
PrivateDart
,
Constructor
()
]
interface
Gradient
:
Shader
{
void
initLinear
(
Point
[]
endPoints
,
Color
[]
colors
,
float
[]
colorStops
,
TileMode
tileMode
)
;
void
initRadial
(
Point
center
,
double
radius
,
Color
[]
colors
,
float
[]
colorStops
,
TileMode
tileMode
)
;
}
;
sky/engine/core/painting/ImageShader.cpp
浏览文件 @
2e693b17
...
...
@@ -4,8 +4,40 @@
#include "sky/engine/core/painting/ImageShader.h"
#include "sky/engine/tonic/dart_args.h"
#include "sky/engine/tonic/dart_binding_macros.h"
#include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_library_natives.h"
namespace
blink
{
static
void
ImageShader_constructor
(
Dart_NativeArguments
args
)
{
DartCallConstructor
(
&
ImageShader
::
create
,
args
);
}
static
void
ImageShader_initWithImage
(
Dart_NativeArguments
args
)
{
DartArgIterator
it
(
args
);
CanvasImage
*
image
=
it
.
GetNext
<
CanvasImage
*>
();
SkShader
::
TileMode
tmx
=
it
.
GetNext
<
SkShader
::
TileMode
>
();
SkShader
::
TileMode
tmy
=
it
.
GetNext
<
SkShader
::
TileMode
>
();
Float64List
matrix4
=
it
.
GetNext
<
Float64List
>
();
if
(
it
.
had_exception
())
return
;
ExceptionState
es
;
GetReceiver
<
ImageShader
>
(
args
)
->
initWithImage
(
image
,
tmx
,
tmy
,
matrix4
,
es
);
if
(
es
.
had_exception
())
Dart_ThrowException
(
es
.
GetDartException
(
args
,
true
));
}
IMPLEMENT_WRAPPERTYPEINFO
(
ImageShader
);
void
ImageShader
::
RegisterNatives
(
DartLibraryNatives
*
natives
)
{
natives
->
Register
({
{
"ImageShader_constructor"
,
ImageShader_constructor
,
1
,
true
},
{
"ImageShader_initWithImage"
,
ImageShader_initWithImage
,
5
,
true
},
});
}
PassRefPtr
<
ImageShader
>
ImageShader
::
create
()
{
return
adoptRef
(
new
ImageShader
());
}
...
...
sky/engine/core/painting/ImageShader.dart
已删除
100644 → 0
浏览文件 @
610ab574
// 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_ui
;
class
ImageShader
extends
_ImageShader
{
ImageShader
(
Image
image
,
TileMode
tmx
,
TileMode
tmy
,
Float64List
matrix4
)
{
if
(
image
==
null
)
throw
new
ArgumentError
(
"[image] argument cannot be null"
);
if
(
tmx
==
null
)
throw
new
ArgumentError
(
"[tmx] argument cannot be null"
);
if
(
tmy
==
null
)
throw
new
ArgumentError
(
"[tmy] argument cannot be null"
);
if
(
matrix4
==
null
)
throw
new
ArgumentError
(
"[matrix4] argument cannot be null"
);
this
.
_initWithImage
(
image
,
tmx
,
tmy
,
matrix4
);
}
}
sky/engine/core/painting/ImageShader.h
浏览文件 @
2e693b17
...
...
@@ -16,6 +16,7 @@
#include "third_party/skia/include/core/SkMatrix.h"
namespace
blink
{
class
DartLibraryNatives
;
class
ImageShader
:
public
Shader
{
DEFINE_WRAPPERTYPEINFO
();
...
...
@@ -29,6 +30,8 @@ class ImageShader : public Shader {
const
Float64List
&
matrix4
,
ExceptionState
&
es
);
static
void
RegisterNatives
(
DartLibraryNatives
*
natives
);
private:
ImageShader
();
};
...
...
sky/engine/core/painting/ImageShader.idl
已删除
100644 → 0
浏览文件 @
610ab574
//
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
.
[
PrivateDart
,
Constructor
()
]
interface
ImageShader
:
Shader
{
[
RaisesException
]
void
initWithImage
(
Image
image
,
TileMode
tmx
,
TileMode
tmy
,
Float64List
matrix4
)
;
}
;
sky/engine/core/painting/Point.cpp
浏览文件 @
2e693b17
...
...
@@ -29,7 +29,7 @@ Point DartConverter<Point>::FromDart(Dart_Handle handle) {
return
result
;
}
Point
DartConverter
<
Point
>::
FromArguments
WithNullCheck
(
Point
DartConverter
<
Point
>::
FromArguments
(
Dart_NativeArguments
args
,
int
index
,
Dart_Handle
&
exception
)
{
...
...
sky/engine/core/painting/Point.h
浏览文件 @
2e693b17
...
...
@@ -20,9 +20,14 @@ class Point {
template
<
>
struct
DartConverter
<
Point
>
{
static
Point
FromDart
(
Dart_Handle
handle
);
static
Point
FromArguments
(
Dart_NativeArguments
args
,
int
index
,
Dart_Handle
&
exception
);
static
Point
FromArgumentsWithNullCheck
(
Dart_NativeArguments
args
,
int
index
,
Dart_Handle
&
exception
);
Dart_Handle
&
exception
)
{
return
FromArguments
(
args
,
index
,
exception
);
}
};
}
// namespace blink
...
...
sky/engine/core/painting/Shader.cpp
浏览文件 @
2e693b17
...
...
@@ -6,6 +6,8 @@
namespace
blink
{
IMPLEMENT_WRAPPERTYPEINFO
(
Shader
);
Shader
::
Shader
(
PassRefPtr
<
SkShader
>
shader
)
:
shader_
(
shader
)
{
}
...
...
sky/engine/core/painting/Shader.idl
已删除
100644 → 0
浏览文件 @
610ab574
//
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
.
interface
Shader
{
}
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录