private void UpdateTextureData(IFrameVideo videoData) { if (_texture0 == null) { return; } var lockRect = _texture0.LockRectangle(0, D3DLOCK.NONE); try { unsafe { fixed(int *srcPtr = videoData.Buffer) { NativeMethods.CopyStride( (int *)lockRect.pBits, srcPtr, _frameSize.Width, _frameSize.Height, _textureStride); } } } finally { _texture0.UnlockRectangle(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); } }