浏览代码

compositing CANVAS => UICANVAS (IN PROGRESS)

/main
xingwei.zhu 5 年前
当前提交
d84d4275
共有 42 个文件被更改,包括 238 次插入158 次删除
  1. 224
      Runtime/ui/utils/renderer/common/base_canvas.cs
  2. 119
      Runtime/ui/utils/renderer/common/draw_cmd.cs
  3. 26
      Runtime/ui/utils/renderer/common/picture.cs
  4. 5
      Runtime/ui/utils/renderer/geometry/offset.cs
  5. 11
      Runtime/ui/utils/renderer/compositeCanvas/compositor_context.cs.meta
  6. 8
      Runtime/ui/utils/renderer/compositeCanvas/flow.meta
  7. 3
      Runtime/flow.meta
  8. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/container_layer.cs.meta
  9. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/layer.cs.meta
  10. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_rect_layer.cs.meta
  11. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/opacity_layer.cs.meta
  12. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/picture_layer.cs.meta
  13. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/transform_layer.cs.meta
  14. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_rrect_layer.cs.meta
  15. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/matrix_decomposition.cs
  16. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/matrix_decomposition.cs.meta
  17. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/raster_cache.cs.meta
  18. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/layer_tree.cs.meta
  19. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_path_layer.cs
  20. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_path_layer.cs.meta
  21. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_rect_layer.cs
  22. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_rrect_layer.cs
  23. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/container_layer.cs
  24. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/transform_layer.cs
  25. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/performance_overlay_layer.cs.meta
  26. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/texture_layer.cs
  27. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/texture_layer.cs.meta
  28. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/physical_shape_layer.cs.meta
  29. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/backdrop_filter_layer.cs
  30. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/backdrop_filter_layer.cs.meta
  31. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/opacity_layer.cs
  32. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/picture_layer.cs
  33. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/physical_shape_layer.cs
  34. 0
      /Runtime/ui/utils/renderer/compositeCanvas/compositor_context.cs
  35. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/instrumentation.cs
  36. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/layer.cs
  37. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/layer_tree.cs
  38. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/performance_overlay_layer.cs
  39. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/instrumentation.cs.meta
  40. 0
      /Runtime/ui/utils/renderer/compositeCanvas/flow/raster_cache.cs

224
Runtime/ui/utils/renderer/common/base_canvas.cs


using UnityEngine;
namespace Unity.UIWidgets.ui {
public class uiRecorderCanvas : PoolItem, Canvas {
public class uiRecorderCanvas : PoolItem {
public uiRecorderCanvas(uiPictureRecorder recorder) {
this._recorder = recorder;
}

public void save() {
this._saveCount++;
this._recorder.addDrawCmd(new uiDrawSave {
});
this._recorder.addDrawCmd(uiDrawSave.create());
this._recorder.addDrawCmd(new uiDrawSaveLayer {
rect = rect,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawSaveLayer.create(
rect : uiRectHelper.fromRect(rect),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawRestore {
});
this._recorder.addDrawCmd(uiDrawRestore.create());
}
public int getSaveCount() {

public void translate(float dx, float dy) {
this._recorder.addDrawCmd(new uiDrawTranslate {
dx = dx,
dy = dy,
});
this._recorder.addDrawCmd(uiDrawTranslate.create(
dx : dx,
dy : dy
));
this._recorder.addDrawCmd(new uiDrawScale {
sx = sx,
sy = sy,
});
this._recorder.addDrawCmd(uiDrawScale.create(
sx : sx,
sy : sy
));
this._recorder.addDrawCmd(new uiDrawRotate {
radians = radians,
offset = offset,
});
this._recorder.addDrawCmd(uiDrawRotate.create(
radians : radians,
offset : uiOffset.fromOffset(offset)
));
this._recorder.addDrawCmd(new uiDrawSkew {
sx = sx,
sy = sy,
});
this._recorder.addDrawCmd(uiDrawSkew.create(
sx : sx,
sy : sy
));
this._recorder.addDrawCmd(new uiDrawConcat {
matrix = matrix,
});
this._recorder.addDrawCmd(uiDrawConcat.create(
matrix : uiMatrix3.fromMatrix3(matrix)
));
public Matrix3 getTotalMatrix() {
public uiMatrix3 getTotalMatrix() {
this._recorder.addDrawCmd(new uiDrawResetMatrix {
});
this._recorder.addDrawCmd(uiDrawResetMatrix.create(
));
this._recorder.addDrawCmd(new uiDrawSetMatrix {
matrix = matrix,
});
this._recorder.addDrawCmd(uiDrawSetMatrix.create(
matrix : uiMatrix3.fromMatrix3(matrix)
));
}
public virtual float getDevicePixelRatio() {

public void clipRect(Rect rect) {
this._recorder.addDrawCmd(new uiDrawClipRect {
rect = rect,
});
this._recorder.addDrawCmd(uiDrawClipRect.create(
rect : uiRectHelper.fromRect(rect)
));
this._recorder.addDrawCmd(new uiDrawClipRRect {
rrect = rrect,
});
this._recorder.addDrawCmd(uiDrawClipRRect.create(
rrect : rrect
));
this._recorder.addDrawCmd(new uiDrawClipPath {
path = path,
});
this._recorder.addDrawCmd(uiDrawClipPath.create(
path : uiPath.fromPath(path)
));
}
public void drawLine(Offset from, Offset to, Paint paint) {

this._recorder.addDrawCmd(new uiDrawPath {
path = path,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawPath.create(
path : uiPath.fromPath(path),
paint : new Paint(paint)
));
}
public void drawShadow(Path path, Color color, float elevation, bool transparentOccluder) {

var path = new Path();
path.addRect(rect);
this._recorder.addDrawCmd(new uiDrawPath {
path = path,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawPath.create(
path : uiPath.fromPath(path),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawPath {
path = path,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawPath.create(
path : uiPath.fromPath(path),
paint : new Paint(paint)
));
}
public void drawDRRect(RRect outer, RRect inner, Paint paint) {

path.winding(PathWinding.clockwise);
this._recorder.addDrawCmd(new uiDrawPath {
path = path,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawPath.create(
path : uiPath.fromPath(path),
paint : new Paint(paint)
));
}
public void drawOval(Rect rect, Paint paint) {

path.addEllipse(rect.left + w, rect.top + h, w, h);
this._recorder.addDrawCmd(new uiDrawPath {
path = path,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawPath.create(
path : uiPath.fromPath(path),
paint : new Paint(paint)
));
}
public void drawCircle(Offset c, float radius, Paint paint) {

this._recorder.addDrawCmd(new uiDrawPath {
path = path,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawPath.create(
path : uiPath.fromPath(path),
paint : new Paint(paint)
));
}
public void drawArc(Rect rect, float startAngle, float sweepAngle, bool useCenter, Paint paint) {

path.close();
}
this._recorder.addDrawCmd(new uiDrawPath {
path = path,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawPath.create(
path : uiPath.fromPath(path),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawPath {
path = path,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawPath.create(
path : uiPath.fromPath(path),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawImage {
image = image,
offset = offset,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawImage.create(
image : image,
offset : uiOffset.fromOffset(offset),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawImageRect {
image = image,
dst = dst,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawImageRect.create(
image : image,
src : null,
dst : uiRectHelper.fromRect(dst),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawImageRect {
image = image,
src = src,
dst = dst,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawImageRect.create(
image : image,
src : uiRectHelper.fromRect(src),
dst : uiRectHelper.fromRect(dst),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawImageNine {
image = image,
center = center,
dst = dst,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawImageNine.create(
image : image,
src : null,
center : uiRectHelper.fromRect(center),
dst : uiRectHelper.fromRect(dst),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawImageNine {
image = image,
src = src,
center = center,
dst = dst,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawImageNine.create(
image : image,
src : uiRectHelper.fromRect(src),
center : uiRectHelper.fromRect(center),
dst : uiRectHelper.fromRect(dst),
paint : new Paint(paint)
));
this._recorder.addDrawCmd(new uiDrawPicture {
picture = picture,
});
this._recorder.addDrawCmd(uiDrawPicture.create(
picture : picture
));
this._recorder.addDrawCmd(new uiDrawTextBlob {
textBlob = textBlob,
offset = offset,
paint = new Paint(paint),
});
this._recorder.addDrawCmd(uiDrawTextBlob.create(
textBlob : textBlob,
offset : uiOffset.fromOffset(offset),
paint : new Paint(paint)
));
}
public void drawParagraph(Paragraph paragraph, Offset offset) {

119
Runtime/ui/utils/renderer/common/draw_cmd.cs


public uiDrawSaveLayer() {
}
public static uiDrawSaveLayer create(Rect rect, Paint paint) {
public static uiDrawSaveLayer create(uiRect? rect, Paint paint) {
public Rect rect;
public override void clear() {
this.rect = null;
this.paint = null;
}
public uiRect? rect;
public Paint paint;
}

}
public static uiDrawRotate create(float radians, Offset offset) {
public static uiDrawRotate create(float radians, uiOffset? offset) {
var drawRotate = ItemPoolManager.alloc<uiDrawRotate>();
drawRotate.radians = radians;
drawRotate.offset = offset;

public override void clear() {
this.offset = null;
}
public Offset offset;
public uiOffset? offset;
}
public class uiDrawSkew : uiDrawCmd {

}
public static uiDrawConcat create(Matrix3 matrix) {
public static uiDrawConcat create(uiMatrix3? matrix) {
public Matrix3 matrix;
public override void clear() {
this.matrix = null;
}
public uiMatrix3? matrix;
}
public class uiDrawResetMatrix : uiDrawCmd {

}
public static uiDrawSetMatrix create(Matrix3 matrix) {
public static uiDrawSetMatrix create(uiMatrix3? matrix) {
public Matrix3 matrix;
public override void clear() {
this.matrix = null;
}
public uiMatrix3? matrix;
}
public class uiDrawClipRect : uiDrawCmd {

public static uiDrawClipRect create(Rect rect) {
public static uiDrawClipRect create(uiRect? rect) {
public Rect rect;
public override void clear() {
this.rect = null;
}
public uiRect? rect;
}
public class uiDrawClipRRect : uiDrawCmd {

return drawClipRRect;
}
public override void clear() {
this.rrect = null;
}
public RRect rrect;
}

}
public static uiDrawClipPath create(Path path) {
public static uiDrawClipPath create(uiPath path) {
public Path path;
public override void clear() {
this.path.dispose();
this.path = null;
}
public uiPath path;
}
public class uiDrawPath : uiDrawCmd {

public static uiDrawPath create(Path path, Paint paint) {
public static uiDrawPath create(uiPath path, Paint paint) {
public Path path;
public override void clear() {
this.path.dispose();
this.path = null;
this.paint = null;
}
public uiPath path;
public Paint paint;
}

}
public static uiDrawImage create(Image image, Offset offset, Paint paint) {
public static uiDrawImage create(Image image, uiOffset? offset, Paint paint) {
var drawImage = ItemPoolManager.alloc<uiDrawImage>();
drawImage.image = image;
drawImage.offset = offset;

public override void clear() {
this.image = null;
this.offset = null;
this.paint = null;
}
public Offset offset;
public uiOffset? offset;
public Paint paint;
}

}
public static uiDrawImageRect create(Image image, Rect src, Rect dst, Paint paint) {
public static uiDrawImageRect create(Image image, uiRect? src, uiRect? dst, Paint paint) {
var drawImageRect = ItemPoolManager.alloc<uiDrawImageRect>();
drawImageRect.image = image;
drawImageRect.src = src;

}
public override void clear() {
this.image = null;
this.src = null;
this.dst = null;
this.paint = null;
}
public Rect src;
public Rect dst;
public uiRect? src;
public uiRect? dst;
public Paint paint;
}

}
public static uiDrawImageNine create(Image image, Rect src, Rect center, Rect dst, Paint paint) {
public static uiDrawImageNine create(Image image, uiRect? src, uiRect? center, uiRect? dst, Paint paint) {
var drawImageNine = ItemPoolManager.alloc<uiDrawImageNine>();
drawImageNine.image = image;
drawImageNine.src = src;

return drawImageNine;
}
public override void clear() {
this.image = null;
this.src = null;
this.center = null;
this.dst = null;
this.paint = null;
}
public Rect src;
public Rect center;
public Rect dst;
public uiRect? src;
public uiRect? center;
public uiRect? dst;
public Paint paint;
}

}
public static uiDrawTextBlob create(TextBlob textBlob, Offset offset, Paint paint) {
public static uiDrawTextBlob create(TextBlob textBlob, uiOffset? offset, Paint paint) {
var drawTextBlob = ItemPoolManager.alloc<uiDrawTextBlob>();
drawTextBlob.textBlob = textBlob;
drawTextBlob.offset = offset;

public override void clear() {
this.textBlob = null;
this.offset = null;
this.paint = null;
public Offset offset;
public uiOffset? offset;
public Paint paint;
}
}

26
Runtime/ui/utils/renderer/common/picture.cs


namespace Unity.UIWidgets.ui {
public class uiPicture {
public uiPicture(List<uiDrawCmd> drawCmds, Rect paintBounds) {
public uiPicture(List<uiDrawCmd> drawCmds, uiRect paintBounds) {
public readonly Rect paintBounds;
public readonly uiRect paintBounds;
}
public class uiPictureRecorder {

return this._states[this._states.Count - 1];
}
public Matrix3 getTotalMatrix() {
public uiMatrix3 getTotalMatrix() {
return this._getState().xform;
}

this._states.Add(new uiCanvasState {
xform = Matrix3.I(),
xform = uiMatrix3.I(),
paintBounds = Rect.zero,
paintBounds = uiRectHelper.zero
});
}

break;
case uiDrawSaveLayer cmd: {
this._states.Add(new uiCanvasState {
xform = Matrix3.I(),
scissor = cmd.rect.shift(-cmd.rect.topLeft),
xform = uiMatrix3.I(),
scissor = cmd.rect.shift(-cmd.rect.Value.topLeft),
layerOffset = cmd.rect.topLeft,
paintBounds = Rect.zero,
layerOffset = cmd.rect.Value.topLeft,
paintBounds = uiRectHelper.zero,
});
break;
}

}
class uiCanvasState {
public Matrix3 xform;
public Rect scissor;
public uiMatrix3 xform;
public uiRect? scissor;
public Offset layerOffset;
public Rect paintBounds;
public uiOffset? layerOffset;
public uiRect paintBounds;
public uiCanvasState copy() {
return new uiCanvasState {

5
Runtime/ui/utils/renderer/geometry/offset.cs


return newOffset;
}
public static uiOffset operator -(uiOffset a) {
return new uiOffset(-a.dx, -a.dy);
}
}
}

11
Runtime/ui/utils/renderer/compositeCanvas/compositor_context.cs.meta


fileFormatVersion: 2
guid: 6069bed57cc6d436984d347d6f49bcfc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Runtime/ui/utils/renderer/compositeCanvas/flow.meta


fileFormatVersion: 2
guid: 7f2f67614422741d3a7668fc776cfa9d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Runtime/flow.meta


fileFormatVersion: 2
guid: e1056a6e2b8247cbaf7db24691b913ec
timeCreated: 1534389920

/Runtime/flow/container_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/container_layer.cs.meta

/Runtime/flow/layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/layer.cs.meta

/Runtime/flow/clip_rect_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_rect_layer.cs.meta

/Runtime/flow/opacity_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/opacity_layer.cs.meta

/Runtime/flow/picture_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/picture_layer.cs.meta

/Runtime/flow/transform_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/transform_layer.cs.meta

/Runtime/flow/clip_rrect_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_rrect_layer.cs.meta

/Runtime/flow/matrix_decomposition.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/matrix_decomposition.cs

/Runtime/flow/matrix_decomposition.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/matrix_decomposition.cs.meta

/Runtime/flow/raster_cache.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/raster_cache.cs.meta

/Runtime/flow/layer_tree.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/layer_tree.cs.meta

/Runtime/flow/clip_path_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_path_layer.cs

/Runtime/flow/clip_path_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_path_layer.cs.meta

/Runtime/flow/clip_rect_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_rect_layer.cs

/Runtime/flow/clip_rrect_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/clip_rrect_layer.cs

/Runtime/flow/container_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/container_layer.cs

/Runtime/flow/transform_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/transform_layer.cs

/Runtime/flow/performance_overlay_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/performance_overlay_layer.cs.meta

/Runtime/flow/texture_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/texture_layer.cs

/Runtime/flow/texture_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/texture_layer.cs.meta

/Runtime/flow/physical_shape_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/physical_shape_layer.cs.meta

/Runtime/flow/backdrop_filter_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/backdrop_filter_layer.cs

/Runtime/flow/backdrop_filter_layer.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/backdrop_filter_layer.cs.meta

/Runtime/flow/opacity_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/opacity_layer.cs

/Runtime/flow/picture_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/picture_layer.cs

/Runtime/flow/physical_shape_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/physical_shape_layer.cs

/Runtime/flow/compositor_context.cs → /Runtime/ui/utils/renderer/compositeCanvas/compositor_context.cs

/Runtime/flow/instrumentation.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/instrumentation.cs

/Runtime/flow/layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/layer.cs

/Runtime/flow/layer_tree.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/layer_tree.cs

/Runtime/flow/performance_overlay_layer.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/performance_overlay_layer.cs

/Runtime/flow/instrumentation.cs.meta → /Runtime/ui/utils/renderer/compositeCanvas/flow/instrumentation.cs.meta

/Runtime/flow/raster_cache.cs → /Runtime/ui/utils/renderer/compositeCanvas/flow/raster_cache.cs

正在加载...
取消
保存