提交 6c205c6a 编写于 作者: C Collin Jackson

Implement ClipRRect

R=abarth@chromium.org, abarth

Review URL: https://codereview.chromium.org/1206373002.
上级 75b4ffb1
......@@ -63,3 +63,16 @@ Here is a diagram summarising all this:
+-----------------------------+ -------
TODO(ianh): document dart:sky and the Host APIs somewhere
Sky Engine API
--------------
The Sky engine API provides efficient, immutable wrappers
for common Skia C++ types, notably Color, Point, and Rect.
Because these wrappers are immutable, they are suitable
for storage in final member variables of widget classes.
More complex Skia wrappers such as Paint and RRect are
mutable, to more closely match the Skia APIs. We recommend
constructing wrappers for complex Skia classes dynamically
during the painting phase based on the underlying state of
the widget.
......@@ -589,6 +589,45 @@ class RenderClipRect extends RenderProxyBox {
}
}
class RenderClipRRect extends RenderProxyBox {
RenderClipRRect({ RenderBox child, double xRadius, double yRadius })
: _xRadius = xRadius, _yRadius = yRadius, super(child) {
assert(_xRadius != null);
assert(_yRadius != null);
}
double _xRadius;
double get xRadius => _xRadius;
void set xRadius (double value) {
assert(value != null);
if (_xRadius == value)
return;
_xRadius = value;
markNeedsPaint();
}
double _yRadius;
double get yRadius => _yRadius;
void set yRadius (double value) {
assert(value != null);
if (_yRadius == value)
return;
_yRadius = value;
markNeedsPaint();
}
void paint(RenderCanvas canvas) {
if (child != null) {
Rect rect = new Rect.fromSize(size);
canvas.saveLayer(rect, new Paint());
sky.RRect rrect = new sky.RRect()..setRectXY(rect, xRadius, yRadius);
canvas.clipRRect(rrect);
child.paint(canvas);
canvas.restore();
}
}
}
class RenderClipOval extends RenderProxyBox {
RenderClipOval({ RenderBox child }) : super(child);
......
......@@ -104,6 +104,24 @@ class ClipRect extends OneChildRenderObjectWrapper {
RenderClipRect get root => super.root;
RenderClipRect createNode() => new RenderClipRect();
// Nothing to sync, so we don't implement syncRenderObject()
}
class ClipRRect extends OneChildRenderObjectWrapper {
final double xRadius;
final double yRadius;
ClipRRect({ String key, Widget child, this.xRadius, this.yRadius })
: super(key: key, child: child);
RenderClipRRect get root => super.root;
RenderClipRRect createNode() => new RenderClipRRect(xRadius: xRadius, yRadius: yRadius);
void syncRenderObject(ClipRRect old) {
super.syncRenderObject(old);
root.xRadius = xRadius;
root.yRadius = yRadius;
}
}
class ClipOval extends OneChildRenderObjectWrapper {
......@@ -112,8 +130,9 @@ class ClipOval extends OneChildRenderObjectWrapper {
RenderClipOval get root => super.root;
RenderClipOval createNode() => new RenderClipOval();
}
// Nothing to sync, so we don't implement syncRenderObject()
}
// POSITIONING AND SIZING NODES
......@@ -157,6 +176,8 @@ class Center extends OneChildRenderObjectWrapper {
RenderPositionedBox get root => super.root;
RenderPositionedBox createNode() => new RenderPositionedBox();
// Nothing to sync, so we don't implement syncRenderObject()
}
class SizedBox extends OneChildRenderObjectWrapper {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册