// Copyright © 2018 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using System; using System.Windows.Controls; using CefSharp.Structs; namespace CefSharp.Wpf { /// /// Implement this interface to handle Offscreen Rendering (OSR). /// NOTE: Currently only OnPaint is implemented, at some point expand the API to include all /// of CefRenderHandler methods http://magpcss.org/ceforum/apidocs3/projects/(default)/CefRenderHandler.html /// public interface IRenderHandler : IDisposable { /// /// Called when an element has been rendered to the shared texture handle. /// This method is only called when is set to true /// /// The underlying implementation uses a pool to deliver frames. As a result, /// the handle may differ every frame depending on how many frames are /// in-progress. The handle's resource cannot be cached and cannot be accessed /// outside of this callback. It should be reopened each time this callback is /// executed and the contents should be copied to a texture owned by the /// client application. The contents of acceleratedPaintInfo /// will be released back to the pool after this callback returns. /// /// indicates whether the element is the view or the popup widget. /// contains the set of rectangles in pixel coordinates that need to be repainted /// contains the shared handle; on Windows it is a /// HANDLE to a texture that can be opened with D3D11 OpenSharedResource. void OnAcceleratedPaint(bool isPopup, Rect dirtyRect, AcceleratedPaintInfo acceleratedPaintInfo); /// /// Called when an element should be painted. (Invoked from CefRenderHandler.OnPaint) /// This method is only called when is set to false. /// /// indicates whether the element is the view or the popup widget. /// contains the set of rectangles in pixel coordinates that need to be repainted /// The bitmap will be will be width * height *4 bytes in size and represents a BGRA image with an upper-left origin /// width /// height /// image used as parent for rendered bitmap void OnPaint(bool isPopup, Rect dirtyRect, IntPtr buffer, int width, int height, Image image); } }