|
|
|
|
|
|
} |
|
|
|
|
|
|
|
class _RasterCacheKey : IEquatable<_RasterCacheKey> { |
|
|
|
internal _RasterCacheKey(Picture picture, Matrix3 matrix, float devicePixelRatio) { |
|
|
|
internal _RasterCacheKey(Picture picture, Matrix3 matrix, float devicePixelRatio, int antiAliasing) { |
|
|
|
D.assert(picture != null); |
|
|
|
D.assert(matrix != null); |
|
|
|
this.picture = picture; |
|
|
|
|
|
|
this.matrix[2] = 0.0f; |
|
|
|
this.matrix[5] = 0.0f; |
|
|
|
this.devicePixelRatio = devicePixelRatio; |
|
|
|
this.antiAliasing = antiAliasing; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly Picture picture; |
|
|
|
|
|
|
public readonly float devicePixelRatio; |
|
|
|
|
|
|
|
public readonly int antiAliasing; |
|
|
|
|
|
|
|
public bool Equals(_RasterCacheKey other) { |
|
|
|
if (ReferenceEquals(null, other)) { |
|
|
|
|
|
|
|
|
|
|
return Equals(this.picture, other.picture) && |
|
|
|
Equals(this.matrix, other.matrix) && |
|
|
|
this.devicePixelRatio.Equals(other.devicePixelRatio); |
|
|
|
this.devicePixelRatio.Equals(other.devicePixelRatio) && |
|
|
|
this.antiAliasing.Equals(other.antiAliasing); |
|
|
|
} |
|
|
|
|
|
|
|
public override bool Equals(object obj) { |
|
|
|
|
|
|
var hashCode = (this.picture != null ? this.picture.GetHashCode() : 0); |
|
|
|
hashCode = (hashCode * 397) ^ (this.matrix != null ? this.matrix.GetHashCode() : 0); |
|
|
|
hashCode = (hashCode * 397) ^ this.devicePixelRatio.GetHashCode(); |
|
|
|
hashCode = (hashCode * 397) ^ this.antiAliasing.GetHashCode(); |
|
|
|
return hashCode; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public RasterCacheResult getPrerolledImage( |
|
|
|
Picture picture, Matrix3 transform, float devicePixelRatio, bool isComplex, |
|
|
|
Picture picture, Matrix3 transform, float devicePixelRatio, int antiAliasing, bool isComplex, |
|
|
|
bool willChange) { |
|
|
|
if (this.threshold == 0) { |
|
|
|
return null; |
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
_RasterCacheKey cacheKey = new _RasterCacheKey(picture, transform, devicePixelRatio); |
|
|
|
_RasterCacheKey cacheKey = new _RasterCacheKey(picture, transform, devicePixelRatio, antiAliasing); |
|
|
|
|
|
|
|
var entry = this._cache.putIfAbsent(cacheKey, () => new _RasterCacheEntry()); |
|
|
|
|
|
|
|
|
|
|
if (entry.image == null) { |
|
|
|
D.assert(this._meshPool != null); |
|
|
|
entry.image = |
|
|
|
this._rasterizePicture(picture, transform, devicePixelRatio, this._meshPool); |
|
|
|
this._rasterizePicture(picture, transform, devicePixelRatio, antiAliasing, this._meshPool); |
|
|
|
} |
|
|
|
|
|
|
|
return entry.image; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
RasterCacheResult _rasterizePicture(Picture picture, Matrix3 transform, float devicePixelRatio, |
|
|
|
MeshPool meshPool) { |
|
|
|
int antiAliasing, MeshPool meshPool) { |
|
|
|
var bounds = transform.mapRect(picture.paintBounds).roundOut(devicePixelRatio); |
|
|
|
|
|
|
|
var desc = new RenderTextureDescriptor( |
|
|
|
|
|
|
useMipMap = false, |
|
|
|
autoGenerateMips = false, |
|
|
|
}; |
|
|
|
|
|
|
|
if (antiAliasing != 0) { |
|
|
|
desc.msaaSamples = antiAliasing; |
|
|
|
} |
|
|
|
|
|
|
|
var renderTexture = new RenderTexture(desc); |
|
|
|
renderTexture.hideFlags = HideFlags.HideAndDontSave; |
|
|
|