Exemplo n.º 1
0
        internal uiPathCache flatten(float scale)
        {
            scale = Mathf.Round(scale * 2.0f) / 2.0f; // round to 0.5f

            if (this._cache != null && this._cache.canReuse(scale))
            {
                return(this._cache);
            }

            var _cache = uiPathCache.create(scale);

            var i = 0;

            while (i < this._commands.Count)
            {
                var cmd = (uiPathCommand)this._commands[i];
                switch (cmd)
                {
                case uiPathCommand.moveTo:
                    _cache.addPath();
                    _cache.addPoint(this._commands[i + 1], this._commands[i + 2], uiPointFlags.corner);
                    i += 3;
                    break;

                case uiPathCommand.lineTo:
                    _cache.addPoint(this._commands[i + 1], this._commands[i + 2], uiPointFlags.corner);
                    i += 3;
                    break;

                case uiPathCommand.bezierTo:
                    _cache.tessellateBezier(
                        this._commands[i + 1], this._commands[i + 2],
                        this._commands[i + 3], this._commands[i + 4],
                        this._commands[i + 5], this._commands[i + 6], uiPointFlags.corner);
                    i += 7;
                    break;

                case uiPathCommand.close:
                    _cache.closePath();
                    i++;
                    break;

                case uiPathCommand.winding:
                    _cache.pathWinding((uiPathWinding)this._commands[i + 1]);
                    i += 2;
                    break;

                default:
                    D.assert(false, () => "unknown cmd: " + cmd);
                    break;
                }
            }

            _cache.normalize();
            ObjectPool <uiPathCache> .release(this._cache);

            this._cache = _cache;
            return(_cache);
        }
Exemplo n.º 2
0
        void _appendClose()
        {
            this._commands.Add((float)uiPathCommand.close);

            ObjectPool <uiPathCache> .release(this._cache);

            this._cache = null;
        }
Exemplo n.º 3
0
        void _appendWinding(float winding)
        {
            this._commands.Add((float)uiPathCommand.winding);
            this._commands.Add(winding);

            ObjectPool <uiPathCache> .release(this._cache);

            this._cache = null;
        }
Exemplo n.º 4
0
        public static uiPathCache create(float scale)
        {
            uiPathCache newPathCache = ObjectPool <uiPathCache> .alloc();

            newPathCache._distTol = 0.01f / scale;
            newPathCache._tessTol = 0.25f / scale;
            newPathCache._scale   = scale;
            return(newPathCache);
        }
Exemplo n.º 5
0
        public override void clear()
        {
            ObjectPool <uiList <float> > .release(this._commands);

            ObjectPool <uiPathCache> .release(this._cache);

            this._cache    = null;
            this._commands = null;

            this.needCache = false;
            this.pathKey   = 0;
        }
Exemplo n.º 6
0
        void _appendMoveTo(float x, float y)
        {
            this._commands.Add((float)uiPathCommand.moveTo);
            this._commands.Add(x);
            this._commands.Add(y);

            this._commandx = x;
            this._commandy = y;

            ObjectPool <uiPathCache> .release(this._cache);

            this._cache = null;
        }
Exemplo n.º 7
0
        void _reset()
        {
            this._commands = ObjectPool <uiList <float> > .alloc();

            this._commandx = 0;
            this._commandy = 0;
            this._minX     = float.MaxValue;
            this._minY     = float.MaxValue;
            this._maxX     = float.MinValue;
            this._maxY     = float.MinValue;
            ObjectPool <uiPathCache> .release(this._cache);

            this._cache = null;
        }
Exemplo n.º 8
0
        public override void clear()
        {
            ObjectPool <uiList <float> > .release(this._commands);

            ObjectPool <uiPathCache> .release(this._cache);

            this._cache    = null;
            this._commands = null;

            this.needCache     = false;
            this.pathKey       = 0;
            this._isNaiveRRect = false;
            this._shapeHint    = uiPathShapeHint.Other;
            this._rRectCorner  = 0;
        }
Exemplo n.º 9
0
        void _appendLineTo(float x, float y)
        {
            this._expandBounds(this._commandx, this._commandy);
            this._expandBounds(x, y);

            this._commands.Add((float)uiPathCommand.lineTo);
            this._commands.Add(x);
            this._commands.Add(y);

            this._commandx = x;
            this._commandy = y;

            ObjectPool <uiPathCache> .release(this._cache);

            this._cache = null;
        }
Exemplo n.º 10
0
        void _appendBezierTo(float x1, float y1, float x2, float y2, float x3, float y3)
        {
            this._expandBounds(this._commandx, this._commandy);
            this._expandBounds(x1, y1);
            this._expandBounds(x2, y2);
            this._expandBounds(x3, y3);

            this._commands.Add((float)uiPathCommand.bezierTo);
            this._commands.Add(x1);
            this._commands.Add(y1);
            this._commands.Add(x2);
            this._commands.Add(y2);
            this._commands.Add(x3);
            this._commands.Add(y3);

            this._commandx = x3;
            this._commandy = y3;

            ObjectPool <uiPathCache> .release(this._cache);

            this._cache = null;
        }