示例#1
0
        void _establishTransform()
        {
            D.assert(this.link != null);
            this._lastTransform = null;
            if (this.link._leader == null)
            {
                return;
            }

            D.assert(this.link.leader.owner == this.owner,
                     "Linked LeaderLayer anchor is not in the same layer tree as the FollowerLayer.");
            D.assert(this.link.leader._lastOffset != null,
                     "LeaderLayer anchor must come before FollowerLayer in paint order, but the reverse was true.");

            HashSet <Layer> ancestors = new HashSet <Layer>();
            Layer           ancestor  = this.parent;

            while (ancestor != null)
            {
                ancestors.Add(ancestor);
                ancestor = ancestor.parent;
            }

            ContainerLayer        layer         = this.link.leader;
            List <ContainerLayer> forwardLayers = new List <ContainerLayer> {
                null, layer
            };

            do
            {
                layer = layer.parent;
                forwardLayers.Add(layer);
            } while (!ancestors.Contains(layer));

            ancestor = layer;

            layer = this;
            List <ContainerLayer> inverseLayers = new List <ContainerLayer>();

            do
            {
                layer = layer.parent;
                inverseLayers.Add(layer);
            } while (layer != ancestor);

            Matrix3 forwardTransform = this._collectTransformForLayerChain(forwardLayers);
            Matrix3 inverseTransform = this._collectTransformForLayerChain(inverseLayers);
            var     inverse          = Matrix3.I();
            var     invertible       = inverseTransform.invert(inverseTransform);

            if (!invertible)
            {
                return;
            }

            inverseTransform = inverse;
            inverseTransform.preConcat(forwardTransform);
            inverseTransform.preTranslate((float)this.linkedOffset.dx, (float)this.linkedOffset.dy);
            this._lastTransform = inverseTransform;
        }
示例#2
0
        void _establishTransform()
        {
            D.assert(this.link != null);
            this._lastTransform = null;
            if (this.link._leader == null)
            {
                return;
            }

            D.assert(this.link.leader.owner == this.owner,
                     () => "Linked LeaderLayer anchor is not in the same layer tree as the FollowerLayer.");
            D.assert(this.link.leader._lastOffset != null,
                     () => "LeaderLayer anchor must come before FollowerLayer in paint order, but the reverse was true.");

            HashSet <Layer> ancestors = new HashSet <Layer>();
            Layer           ancestor  = this.parent;

            while (ancestor != null)
            {
                ancestors.Add(ancestor);
                ancestor = ancestor.parent;
            }

            ContainerLayer        layer         = this.link.leader;
            List <ContainerLayer> forwardLayers = new List <ContainerLayer> {
                null, layer
            };

            do
            {
                layer = layer.parent;
                forwardLayers.Add(layer);
            } while (!ancestors.Contains(layer));

            ancestor = layer;

            layer = this;
            List <ContainerLayer> inverseLayers = new List <ContainerLayer> {
                layer
            };

            do
            {
                layer = layer.parent;
                inverseLayers.Add(layer);
            } while (layer != ancestor);

            Matrix4 forwardTransform = this._collectTransformForLayerChain(forwardLayers);
            Matrix4 inverseTransform = this._collectTransformForLayerChain(inverseLayers);

            if (inverseTransform.invert() == 0)
            {
                return;
            }

            inverseTransform.multiply(forwardTransform);
            inverseTransform.translate(this.linkedOffset.dx, this.linkedOffset.dy);
            this._lastTransform = inverseTransform;
            this._inverseDirty  = true;
        }