Exemple #1
0
        private void UpdateTextureSize(Size size)
        {
            if (_texture0 != null)
            {
                _texture0.Dispose();
                _texture0 = null;
            }
            if (_textureMaskTv != null)
            {
                _textureMaskTv.Dispose();
                _textureMaskTv = null;
            }

            _frameSize = size;
            var maxSize = Math.Max(size.Width, size.Height);
            var potSize = ScaleHelper.GetPotSize(maxSize);

            _texture0 = new Texture(
                Allocator.Device,
                potSize,
                potSize,
                1,
                Usage.None,
                Format.X8R8G8B8,
                Pool.Managed);
            _textureStride = potSize;

            var maskSizeTv = new Size(size.Width, size.Height * MimicTvRatio);
            var maxSizeTv  = Math.Max(maskSizeTv.Width, maskSizeTv.Height);
            var potSizeTv  = ScaleHelper.GetPotSize(maxSizeTv);

            _textureMaskTv = new Texture(
                Allocator.Device,
                potSizeTv,
                potSizeTv,
                1,
                Usage.None, Format.A8R8G8B8, Pool.Managed);
            _textureMaskTvStride = potSizeTv;
            using (var gs = _textureMaskTv.LockRectangle(0, LockFlags.None))
            {
                var pixelColor = 0;
                var gapColor   = MimicTvAlpha << 24;
                unsafe
                {
                    var pdst = (int *)gs.InternalData.ToPointer();
                    for (var y = 0; y < maskSizeTv.Height; y++)
                    {
                        pdst += potSizeTv;
                        var color = (y % MimicTvRatio) != (MimicTvRatio - 1) ? pixelColor : gapColor;
                        for (var x = 0; x < maskSizeTv.Width; x++)
                        {
                            pdst[x] = color;
                        }
                    }
                }
            }
            _textureMaskTv.UnlockRectangle(0);
        }
Exemple #2
0
        protected override void RenderSynchronized(int width, int height)
        {
            var size         = new Size(width, height);
            var visibleIcons = _iconTextures.Values
                               .Where(icon => icon.Visible)
                               .ToArray();

            foreach (var icon in visibleIcons)
            {
                icon.LoadResources(Allocator.Device);
            }
            var potSize    = ScaleHelper.GetPotSize(32);
            var iconSize   = new SizeF(potSize, potSize);
            var iconNumber = 1;

            foreach (var iconTexture in visibleIcons)
            {
                var iconRect = new Rectangle(new Point(0, 0), iconTexture.Size);
                var iconPos  = new PointF(
                    size.Width - iconSize.Width * iconNumber,
                    0);
                _spriteIcon.Begin(D3DXSPRITEFLAG.D3DXSPRITE_ALPHABLEND);
                try
                {
                    D3DXHelper.Draw2D(
                        _spriteIcon,
                        iconTexture.Texture,
                        new RectangleF(iconPos, iconSize),
                        iconTexture.Size);
                }
                finally
                {
                    _spriteIcon.End();
                }
                iconNumber++;
            }
        }
Exemple #3
0
        private void UpdateTextureSize(Size size)
        {
            if (_texture0 != null)
            {
                _texture0.Dispose();
                _texture0 = null;
            }
            if (_textureMaskTv != null)
            {
                _textureMaskTv.Dispose();
                _textureMaskTv = null;
            }

            _frameSize = size;
            var maxSize = Math.Max(size.Width, size.Height);
            var potSize = ScaleHelper.GetPotSize(maxSize);

            _texture0 = Allocator.Device.CreateTexture(
                potSize,
                potSize,
                1,
                D3DUSAGE.NONE,
                D3DFORMAT.D3DFMT_X8R8G8B8,
                D3DPOOL.D3DPOOL_MANAGED);
            _textureStride = potSize;

            var maskSizeTv = new Size(size.Width, size.Height * MimicTvRatio);
            var maxSizeTv  = Math.Max(maskSizeTv.Width, maskSizeTv.Height);
            var potSizeTv  = ScaleHelper.GetPotSize(maxSizeTv);

            _textureMaskTv = Allocator.Device.CreateTexture(
                potSizeTv,
                potSizeTv,
                1,
                D3DUSAGE.NONE,
                D3DFORMAT.D3DFMT_A8R8G8B8,
                D3DPOOL.D3DPOOL_MANAGED);
            _textureMaskTvStride = potSizeTv;
            var lockRect = _textureMaskTv.LockRectangle(0, D3DLOCK.NONE);

            try
            {
                var pixelColor = 0;
                var gapColor   = MimicTvAlpha << 24;
                unsafe
                {
                    var pdst = (int *)lockRect.pBits;
                    for (var y = 0; y < maskSizeTv.Height; y++)
                    {
                        pdst += potSizeTv;
                        var color = (y % MimicTvRatio) != (MimicTvRatio - 1) ? pixelColor : gapColor;
                        for (var x = 0; x < maskSizeTv.Width; x++)
                        {
                            pdst[x] = color;
                        }
                    }
                }
            }
            finally
            {
                _textureMaskTv.UnlockRectangle(0);
            }
        }