Ejemplo n.º 1
0
Archivo: Effect.cs Proyecto: hughbe/wpf
        // The GeneralTransform returned by Effect is in unit space.  The
        // invocation of GeneralTransform is in world space.  This method
        // returns a GeneralTransform that maps between the two.
        internal GeneralTransform CoerceToUnitSpaceGeneralTransform(GeneralTransform gt,
                                                                    Rect worldBounds)
        {
            GeneralTransform result;

            // First, if the gt is identity, just return it straight away.
            if (gt == Transform.Identity)
            {
                result = Transform.Identity;
            }
            else
            {
                // Maintain an MRU cache of GeneralTransforms with exactly one in
                // it.  May want to extend in the future.  Note that this will
                // thrash if the effect is used on multiple elements with different
                // sizes, but that's not our sweetspot.
                if (_mruWorldBounds != worldBounds || _mruInnerGeneralTransform != gt)
                {
                    _mruWorldBounds                = worldBounds;
                    _mruInnerGeneralTransform      = gt;
                    _mruWorldSpaceGeneralTransform = new UnitSpaceCoercingGeneralTransform(worldBounds, gt);
                }

                result = _mruWorldSpaceGeneralTransform;
            }

            return(result);
        }
Ejemplo n.º 2
0
        // The GeneralTransform returned by Effect is in unit space.  The
        // invocation of GeneralTransform is in world space.  This method
        // returns a GeneralTransform that maps between the two.
        internal GeneralTransform CoerceToUnitSpaceGeneralTransform(GeneralTransform gt,
                                                                    Rect worldBounds)
        {
            GeneralTransform result;
            
            // First, if the gt is identity, just return it straight away.
            if (gt == Transform.Identity)
            {
                result = Transform.Identity;
            }
            else 
            {
                // Maintain an MRU cache of GeneralTransforms with exactly one in
                // it.  May want to extend in the future.  Note that this will
                // thrash if the effect is used on multiple elements with different
                // sizes, but that's not our sweetspot.
                if (_mruWorldBounds != worldBounds || _mruInnerGeneralTransform != gt)
                {
                    _mruWorldBounds = worldBounds;
                    _mruInnerGeneralTransform = gt;
                    _mruWorldSpaceGeneralTransform = new UnitSpaceCoercingGeneralTransform(worldBounds, gt);
                }

                result = _mruWorldSpaceGeneralTransform;
            }

            return result;
        }