private static unsafe int MapOutputRectToInputRects(IntPtr thisObject, RawRect *outputRect, RawRect *pInputRects, int inputRectsCount)
            {
                try
                {
                    var inputRects = new RawRect[inputRectsCount];
                    Unsafe.CopyBlock(
                        Unsafe.AsPointer(ref inputRects[0]),
                        pInputRects,
                        (uint)(sizeof(RawRect) * inputRectsCount));

                    ID2D1Transform @this = (ID2D1Transform)ToShadow <ID2D1TransformShadow>(thisObject).Callback;
                    @this.MapOutputRectToInputRects(*outputRect, inputRects);

                    Unsafe.CopyBlock(
                        pInputRects,
                        Unsafe.AsPointer(ref inputRects[0]),
                        (uint)(sizeof(RawRect) * inputRectsCount));

                    return(Result.Ok.Code);
                }
                catch (Exception __exception__)
                {
                    return(Result.GetResultFromException(__exception__).Code);
                }
            }
            /// <summary>
            /// Retrieves the moved and dirty regions of the currently duplicated frame, populating the specified desktop frame.
            /// </summary>
            /// <param name="frame"></param>
            /// <param name="frameInfo"></param>
            public void RetrieveFrameMetadata(DesktopFrame frame, OutduplFrameInfo frameInfo)
            {
                if (frameInfo.TotalMetadataBufferSize > 0)
                {
                    var movedRectangles = new OutduplMoveRect[frameInfo.TotalMetadataBufferSize];

                    // Get moved regions
                    _outputDuplication.GetFrameMoveRects(movedRectangles.Length, movedRectangles, out int movedRegionsLength);
                    var movedRegions = new MovedRegion[movedRegionsLength / Marshal.SizeOf(typeof(OutduplMoveRect))];
                    for (int i = 0; i < movedRegions.Length; i++)
                    {
                        movedRegions[i] = new MovedRegion()
                        {
                            Source      = new Point(movedRectangles[i].SourcePoint.X, movedRectangles[i].SourcePoint.Y),
                            Destination = new Rectangle(movedRectangles[i].DestinationRect.Left, movedRectangles[i].DestinationRect.Top, movedRectangles[i].DestinationRect.Right, movedRectangles[i].DestinationRect.Bottom)
                        };
                    }
                    frame.MovedRegions = movedRegions;

                    // Get dirty regions
                    var dirtyRectangles = new RawRect[frameInfo.TotalMetadataBufferSize];
                    _outputDuplication.GetFrameDirtyRects(dirtyRectangles.Length, dirtyRectangles, out int dirtyRegionsLength);
                    var updatedRegions = new Rectangle[dirtyRegionsLength / Marshal.SizeOf(typeof(Rectangle))];
                    for (int i = 0; i < updatedRegions.Length; i++)
                    {
                        updatedRegions[i] = new Rectangle(dirtyRectangles[i].Left, dirtyRectangles[i].Top, dirtyRectangles[i].Right, dirtyRectangles[i].Bottom);
                    }
                    frame.UpdatedRegions = updatedRegions;
                }
                else
                {
                    frame.MovedRegions   = Array.Empty <MovedRegion>();
                    frame.UpdatedRegions = Array.Empty <Rectangle>();
                }
            }
            private static unsafe int MapInputRectsToOutputRect(IntPtr thisObject, void *pInputRects, void *pInputOpaqueSubRects, int inputRectCount, RawRect *outputRect, RawRect *outputOpaqueSubRect)
            {
                try
                {
                    var inputRects = new RawRect[inputRectCount];
                    fixed(void *rectsPtr = &inputRects[0])
                    {
                        Unsafe.CopyBlock(
                            rectsPtr,
                            pInputRects,
                            (uint)(sizeof(RawRect) * inputRectCount));

                        var inputOpaqueSubRects = new RawRect[inputRectCount];

                        fixed(void *opaqueSubRectsPtr = &inputOpaqueSubRects[0])
                        {
                            Unsafe.CopyBlock(
                                opaqueSubRectsPtr,
                                pInputOpaqueSubRects,
                                (uint)(sizeof(RawRect) * inputRectCount));

                            ID2D1Transform @this = (ID2D1Transform)ToShadow <ID2D1TransformShadow>(thisObject).Callback;

                            @this.MapInputRectsToOutputRect(inputRects, inputOpaqueSubRects, out *outputRect, out *outputOpaqueSubRect);

                            return(Result.Ok.Code);
                        }
                    }
                }
                catch (Exception __exception__)
                {
                    return(Result.GetResultFromException(__exception__).Code);
                }
            }
    /// <summary>
    /// Presents the contents of the next buffer in the sequence of back buffers to the screen.
    /// </summary>
    /// <param name="presentFlags">The present flags.</param>
    /// <param name="sourceRectangle">The area of the back buffer that should be presented.</param>
    /// <param name="destinationRectangle">The area of the front buffer that should receive the result of the presentation.</param>
    /// <param name="windowOverride">The destination window whose client area is taken as the target for this presentation.</param>
    /// <unmanaged>HRESULT IDirect3DSwapChain9::Present([In, Optional] const void* pSourceRect,[InOut, Optional] const void* pDestRect,[In] HWND hDestWindowOverride,[In] const RGNDATA* pDirtyRegion,[In] unsigned int dwFlags)</unmanaged>
    public void Present(RectI sourceRectangle, RectI destinationRectangle, IntPtr windowOverride, Present presentFlags)
    {
        RawRect sourceRect = sourceRectangle;
        RawRect destRect   = destinationRectangle;

        Present(&sourceRect, &destRect, windowOverride, null, (int)presentFlags);
    }
    /// <summary>
    /// Copies the specified region from memory into the current bitmap.
    /// </summary>
    /// <param name="destinationRect">In the current bitmap, the rectangle to which the region specified by srcRect is copied.</param>
    /// <param name="data">The data to copy.</param>
    /// <param name="pitch">The stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory).</param>
    /// <returns>The result of the operation.</returns>
    public Result CopyFromMemory(RectI destinationRect, byte[] data, int pitch)
    {
        RawRect dstRect = destinationRect;

        fixed(byte *dataPtr = data)
        {
            return(CopyFromMemory(&dstRect, dataPtr, pitch));
        }
    }
示例#6
0
    public unsafe void CopyFromMemory <T>(Rectangle destinationArea, T[] data, int pitch) where T : unmanaged
    {
        fixed(void *dataPtr = data)
        {
            RawRect rawDestinationArea = destinationArea;

            CopyFromMemory(destinationArea, (IntPtr)dataPtr, pitch);
        }
    }
示例#7
0
    public unsafe void CopyFromMemory <T>(Rectangle destinationArea, Span <T> data, int pitch) where T : unmanaged
    {
        fixed(void *dataPtr = data)
        {
            RawRect rawDestinationArea = destinationArea;

            CopyFromMemory(rawDestinationArea, new IntPtr(dataPtr), pitch);
        }
    }
示例#8
0
    public unsafe void CopyFromMemory(Rectangle destinationArea, byte[] data, int pitch)
    {
        fixed(void *dataPtr = &data[0])
        {
            RawRect rawDestinationArea = destinationArea;

            CopyFromMemory(rawDestinationArea, new IntPtr(dataPtr), pitch);
        }
    }
示例#9
0
        private unsafe void GetVisibleBounds(out RawRect bounds)
        {
            bounds = default;
            Result result;

            fixed(void *bounds_ = &bounds)
            {
                result = LocalInterop.CalliStdCallint(_nativePointer, bounds_, (*(void ***)_nativePointer)[9]);
            }

            result.CheckError();
        }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderPassEndingAccessResolveSubresourceParameters"/> struct.
 /// </summary>
 /// <param name="srcSubresource">The source subresource.</param>
 /// <param name="dstSubresource">The destination subresource.</param>
 /// <param name="dstX">The x coordinate within the destination subresource.</param>
 /// <param name="dstY">The y coordinate within the destination subresource.</param>
 /// <param name="srcRect">The <see cref="RawRect"/> within the source subresource.</param>
 public RenderPassEndingAccessResolveSubresourceParameters(
     int srcSubresource,
     int dstSubresource,
     int dstX,
     int dstY,
     RawRect srcRect)
 {
     SrcSubresource = srcSubresource;
     DstSubresource = dstSubresource;
     DstX           = dstX;
     DstY           = dstY;
     SrcRect        = srcRect;
 }
    public Result CopyFromMemory <T>(RectI destinationRect, ref T source, int pitch = 0) where T : unmanaged
    {
        RawRect dstRect = destinationRect;

        if (pitch == 0)
        {
            pitch = PixelSize.Width * sizeof(T);
        }

        fixed(void *sourcePointer = &source)
        {
            return(CopyFromMemory(&dstRect, sourcePointer, pitch));
        }
    }
 /// <summary>
 /// Copy a region of a multisampled or compressed resource into a non-multisampled or non-compressed resource.
 /// </summary>
 /// <param name="dstResource">Destination resource.</param>
 /// <param name="dstSubresource">A zero-based index that identifies the destination subresource. Use <see cref="ID3D12Resource.CalculateSubResourceIndex(int, int, int, int, int)"/> to calculate the subresource index if the parent resource is complex.</param>
 /// <param name="dstX">The X coordinate of the left-most edge of the destination region. The width of the destination region is the same as the width of the source rect.</param>
 /// <param name="dstY">The Y coordinate of the top-most edge of the destination region. The height of the destination region is the same as the height of the source rect.</param>
 /// <param name="srcResource">Source resource. Must be multisampled or compressed.</param>
 /// <param name="srcSubresource">A zero-based index that identifies the source subresource.</param>
 /// <param name="srcRect">Specifies the rectangular region of the source resource to be resolved.</param>
 /// <param name="format">A <see cref="Format"/> that specifies how the source and destination resource formats are consolidated.</param>
 /// <param name="resolveMode">Specifies the operation used to resolve the source samples.</param>
 public void ResolveSubresourceRegion(
     ID3D12Resource dstResource,
     int dstSubresource,
     int dstX, int dstY,
     ID3D12Resource srcResource,
     int srcSubresource,
     RawRect srcRect,
     Format format,
     ResolveMode resolveMode = ResolveMode.Decompress)
 {
     ResolveSubresourceRegion_(
         dstResource, dstSubresource, dstX, dstY,
         srcResource, srcSubresource, srcRect,
         format, resolveMode);
 }
        private unsafe Result BeginDraw(RawRect?updateRect, Guid iid, out IntPtr updateObject, out Point offset)
        {
            RawRect updateRectCall = updateRect.GetValueOrDefault();

            offset = default;
            Result result;

            fixed(void *offset_ = &offset)
            {
                fixed(void *updateObject_ = &updateObject)
                {
                    result = LocalInterop.CalliStdCallint(_nativePointer, updateRect.HasValue ? &updateRectCall : (void *)0, &iid, updateObject_, offset_, (*(void ***)_nativePointer)[4]);
                }
            }

            return(result);
        }
示例#14
0
        public unsafe Result BeginDraw(RawRect updateRect, out IDXGISurface surface, out Point offset)
        {
            IntPtr surfacePtr = IntPtr.Zero;
            Result result;

            fixed(void *offset_ = &offset)
            {
                result = LocalInterop.CalliStdCallint0(_nativePointer, updateRect, &surfacePtr, offset_, (*(void ***)_nativePointer)[4]);
            }

            if (result.Failure)
            {
                surface = default;
                offset  = default;
                return(result);
            }

            surface = new IDXGISurface(surfacePtr);
            return(result);
        }
示例#15
0
    public void CopyFromBitmap(Point destinationPoint, ID2D1Bitmap sourceBitmap, Rectangle sourceArea)
    {
        RawRect rawSourceArea = sourceArea;

        CopyFromBitmap(destinationPoint, sourceBitmap, rawSourceArea);
    }
 public void MapOutputRectToInputRects(RawRect outputRect, RawRect[] inputRects) => MapOutputRectToInputRects_(outputRect, inputRects);
 public void MapInputRectsToOutputRect(RawRect[] inputRects, RawRect[] inputOpaqueSubRects, out RawRect outputRect, out RawRect outputOpaqueSubRect) => MapInputRectsToOutputRect_(inputRects, inputOpaqueSubRects, out outputRect, out outputOpaqueSubRect);
示例#18
0
        //private readonly WindowStyles _windowFullscreenStyle = WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_GROUP | WindowStyles.WS_TABSTOP;

        public unsafe Window(string title, int width, int height, WindowFlags flags = WindowFlags.None)
        {
            Title = title;

            int  x         = CW_USEDEFAULT;
            int  y         = CW_USEDEFAULT;
            bool resizable = (flags & WindowFlags.Resizable) != WindowFlags.None;

            _windowWindowedStyle = WindowStyles.WS_CAPTION | WindowStyles.WS_SYSMENU | WindowStyles.WS_MINIMIZEBOX | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_BORDER | WindowStyles.WS_DLGFRAME | WindowStyles.WS_THICKFRAME | WindowStyles.WS_GROUP | WindowStyles.WS_TABSTOP;

            if (resizable)
            {
                _windowWindowedStyle |= WindowStyles.WS_SIZEBOX | WindowStyles.WS_MAXIMIZEBOX;
            }

            _windowStyle = _windowWindowedStyle;

            RawRect windowRect = new RawRect(0, 0, width, height);

            // Adjust according to window styles
            AdjustWindowRectEx(ref windowRect, _windowStyle, false, WindowExStyles.WS_EX_OVERLAPPEDWINDOW);

            int windowWidth  = windowRect.Right - windowRect.Left;
            int windowHeight = windowRect.Bottom - windowRect.Top;

            bool centerWindow = true;

            if (centerWindow)
            {
                if (windowWidth > 0 && windowHeight > 0)
                {
                    int screenWidth  = GetSystemMetrics(SystemMetrics.SM_CXSCREEN);
                    int screenHeight = GetSystemMetrics(SystemMetrics.SM_CYSCREEN);

                    // Place the window in the middle of the screen.WS_EX_APPWINDOW
                    x = (screenWidth - windowWidth) / 2;
                    y = (screenHeight - windowHeight) / 2;
                }
            }

            IntPtr hwnd;

            fixed(char *lpWndClassName = WndClassName)
            {
                fixed(char *lpWindowName = Title)
                {
                    hwnd = CreateWindowExW(
                        (uint)WindowExStyles.WS_EX_OVERLAPPEDWINDOW,
                        (ushort *)lpWndClassName,
                        (ushort *)lpWindowName,
                        (uint)_windowStyle,
                        x,
                        y,
                        windowWidth,
                        windowHeight,
                        IntPtr.Zero,
                        IntPtr.Zero,
                        IntPtr.Zero,
                        null);
                }
            }

            if (hwnd == IntPtr.Zero)
            {
                return;
            }

            ShowWindow(hwnd, ShowWindowCommand.Normal);
            Handle = hwnd;

            GetClientRect(hwnd, out windowRect);
            Extent = new VkExtent2D(windowRect.Right - windowRect.Left, windowRect.Bottom - windowRect.Top);
        }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VideoProcessTransform"/> struct.
 /// </summary>
 /// <param name="sourceRectangle">
 /// Specifies the source rectangle of the transform.
 /// This is the portion of the input surface that is blitted to the destination surface.
 /// The source rectangle is given in pixel coordinates, relative to the input surface.
 /// </param>
 /// <param name="destinationRectangle">
 /// Specifies the destination rectangle of the transform.
 /// This is the portion of the output surface that receives the blit for this stream.
 /// The destination rectangle is given in pixel coordinates, relative to the output surface.
 /// </param>
 /// <param name="orientation">
 /// The rotation and flip operation to apply to the source. Source and Destination rectangles are specified in post orientation coordinates.
 /// </param>
 public VideoProcessTransform(RawRect sourceRectangle, RawRect destinationRectangle, VideoProcessOrientation orientation)
 {
     SourceRectangle      = sourceRectangle;
     DestinationRectangle = destinationRectangle;
     Orientation          = orientation;
 }
示例#20
0
 public unsafe Result Invalidate(RawRect updateRect)
 {
     return(LocalInterop.CalliStdCallint0(_nativePointer, updateRect, (*(void ***)_nativePointer)[6]));
 }
示例#21
0
 public unsafe void PresentEx(Present flags, RawRect sourceRectangle, RawRect destinationRectangle, IntPtr windowOverride, IntPtr dirtyRegionRGNData)
 {
     PresentEx(&sourceRectangle, &destinationRectangle, windowOverride, dirtyRegionRGNData.ToPointer(), (int)flags);
 }
示例#22
0
 public void PresentEx(Present flags, RawRect sourceRectangle, RawRect destinationRectangle)
 {
     PresentEx(flags, sourceRectangle, destinationRectangle, IntPtr.Zero);
 }
示例#23
0
 public unsafe void PresentEx(Present flags, RawRect sourceRectangle, RawRect destinationRectangle, IntPtr windowOverride)
 {
     PresentEx(&sourceRectangle, &destinationRectangle, windowOverride, null, (int)flags);
 }
    /// <summary>
    /// Copies the specified region from the specified render target into the current bitmap.
    /// </summary>
    /// <param name="destinationPoint">In the current bitmap, the upper-left corner of the area to which the region specified by sourceRectangle is copied.</param>
    /// <param name="renderTarget">The render target that contains the region to copy.</param>
    /// <param name="sourceRectangle">The area of renderTarget to copy.</param>
    /// <returns>The result of the operation.</returns>
    public Result CopyFromRenderTarget(Int2 destinationPoint, ID2D1RenderTarget renderTarget, RectI sourceRectangle)
    {
        RawRect sourceRect = sourceRectangle;

        return(CopyFromRenderTarget(&destinationPoint, renderTarget, &sourceRect));
    }
    /// <summary>
    /// Copies the specified region from the specified bitmap into the current bitmap.
    /// </summary>
    /// <param name="destinationPoint">
    /// In the current bitmap, the upper-left corner of the area to which the region specified by sourceRectangle is copied.</param>
    /// <param name="sourceBitmap">The bitmap to copy from.</param>
    /// <param name="sourceRectangle">The area of bitmap to copy.</param>
    /// <returns>The result of the operation.</returns>
    public Result CopyFromBitmap(Int2 destinationPoint, ID2D1Bitmap sourceBitmap, RectI sourceRectangle)
    {
        RawRect sourceRect = sourceRectangle;

        return(CopyFromBitmap(&destinationPoint, sourceBitmap, &sourceRect));
    }
示例#26
0
 static extern void SetViewPortScissorRect(int _instanceID, ViewPort _viewPort, RawRect _rawRect);
 public void MapInvalidRect(int inputIndex, RawRect invalidInputRect, out RawRect invalidOutputRect) => MapInvalidRect_(inputIndex, invalidInputRect, out invalidOutputRect);
示例#28
0
    public void CopyFromRenderTarget(Point destinationPoint, ID2D1RenderTarget renderTarget, Rectangle sourceArea)
    {
        RawRect rawSourceArea = sourceArea;

        CopyFromRenderTarget(destinationPoint, renderTarget, rawSourceArea);
    }