浏览代码

Add isDynamic to picture.

/main
Yuncong Zhang 5 年前
当前提交
78e9d51e
共有 2 个文件被更改,包括 67 次插入39 次删除
  1. 28
      Runtime/flow/raster_cache.cs
  2. 78
      Runtime/ui/painting/picture.cs

28
Runtime/flow/raster_cache.cs


return false;
}
foreach (DrawCmd drawCmd in picture.drawCmds) {
switch (drawCmd) {
case DrawImage cmd: {
if (cmd.image.isDynamic) {
return false;
}
break;
}
case DrawImageNine cmd: {
if (cmd.image.isDynamic) {
return false;
}
break;
}
case DrawImageRect cmd: {
if (cmd.image.isDynamic) {
return false;
}
break;
}
}
if (picture.isDynamic) {
return false;
}
return true;

78
Runtime/ui/painting/picture.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using UnityEngine;
public Picture(List<DrawCmd> drawCmds, Rect paintBounds) {
public Picture(List<DrawCmd> drawCmds, Rect paintBounds, bool isDynamic = false) {
this._isDynamic = isDynamic;
public bool isDynamic {
get { return this._isDynamic; }
}
bool _isDynamic;
}
public class PictureRecorder {

bool _isDynamic;
public PictureRecorder() {
this.reset();
}

public void reset() {
this._drawCmds.Clear();
this._isDynamic = false;
this._states.Clear();
this._states.Add(new CanvasState {
xform = Matrix3.I(),

throw new Exception("unmatched save/restore commands");
}
var state = this._getState();
return new Picture(new List<DrawCmd>(this._drawCmds), state.paintBounds);
var state = this._getState();
return new Picture(new List<DrawCmd>(this._drawCmds), state.paintBounds, this._isDynamic);
}
public void addDrawCmd(DrawCmd drawCmd) {

});
break;
}
case DrawRestore _: {
var stateToRestore = this._getState();
this._states.RemoveAt(this._states.Count - 1);

state.paintBounds = stateToRestore.paintBounds;
} else {
}
else {
case DrawTranslate cmd: {
var state = this._getState();
state.xform = new Matrix3(state.xform);

case DrawScale cmd: {
var state = this._getState();
state.xform = new Matrix3(state.xform);

} else {
}
else {
case DrawSkew cmd: {
var state = this._getState();
state.xform = new Matrix3(state.xform);

case DrawConcat cmd: {
var state = this._getState();
state.xform = new Matrix3(state.xform);

case DrawClipRect cmd: {
var state = this._getState();

}
case DrawClipRRect cmd: {
var state = this._getState();

}
case DrawClipPath cmd: {
var state = this._getState();
var scale = XformUtils.getScale(state.xform);

state.scissor = state.scissor == null ? rect : state.scissor.intersect(rect);
break;
}
case DrawPath cmd: {
var state = this._getState();
var scale = XformUtils.getScale(state.xform);

if (paint.style == PaintingStyle.fill) {
var cache = path.flatten(scale * devicePixelRatio);
mesh = cache.getFillMesh(out _).transform(state.xform);
} else {
}
else {
float strokeWidth = (paint.strokeWidth * scale).clamp(0, 200.0f);
float fringeWidth = 1 / devicePixelRatio;

paint.strokeJoin,
paint.strokeMiterLimit).transform(state.xform);
}
} else {
}
else {
case DrawImage cmd: {
var state = this._getState();
var rect = Rect.fromLTWH(cmd.offset.dx, cmd.offset.dy,

if (cmd.image.isDynamic) {
this._isDynamic = true;
}
if (cmd.image.isDynamic) {
this._isDynamic = true;
}
if (cmd.image.isDynamic) {
this._isDynamic = true;
}
if (cmd.picture.isDynamic) {
this._isDynamic = true;
}
} else {
}
else {
default:
throw new Exception("unknown drawCmd: " + drawCmd);
}

if (state.paintBounds.isEmpty) {
state.paintBounds = paintBounds;
} else {
}
else {
state.paintBounds = state.paintBounds.expandToInclude(paintBounds);
}
}

正在加载...
取消
保存