Skip to content

Commit

Permalink
Implement AcceleratedPaintInfo (#4796)
Browse files Browse the repository at this point in the history
* Implement AcceleratedPaintInfo so the shared texture can be used for accelerated rendering in a custom IRenderHandler.

* Make AcceleratedPaintInfo members get-only properties, set via constructor.
Add XML comments, based on CEF.

---------

Co-authored-by: Dennis de Bruijn <d.de.bruijn@tss.nl>
  • Loading branch information
2 people authored and amaitland committed May 8, 2024
1 parent 1790188 commit 4ae2b5f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CefSharp.Core.Runtime/Internals/RenderClientAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ namespace CefSharp
virtual DECL void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects, const CefAcceleratedPaintInfo& info) override
{
CefRect r = dirtyRects.front();
_renderWebBrowser->OnAcceleratedPaint((CefSharp::PaintElementType)type, CefSharp::Structs::Rect(r.x, r.y, r.width, r.height), nullptr);
AcceleratedPaintInfo^ api = gcnew AcceleratedPaintInfo((IntPtr)info.shared_texture_handle, (ColorType)info.format);
_renderWebBrowser->OnAcceleratedPaint((CefSharp::PaintElementType)type, CefSharp::Structs::Rect(r.x, r.y, r.width, r.height), api);
}

virtual DECL void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects,
Expand Down
26 changes: 25 additions & 1 deletion CefSharp/AcceleratedPaintInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,36 @@
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

using System;
using CefSharp.Enums;

namespace CefSharp
{
/// <summary>
/// AcceleratedPaintInfo
/// Class representing accelerated paint info.
/// </summary>
public sealed class AcceleratedPaintInfo
{
/// <summary>
/// Handle for the shared texture. The shared texture is instantiated
/// without a keyed mutex.
/// </summary>
public IntPtr SharedTextureHandle { get; }

/// <summary>
/// The pixel format of the texture.
/// </summary>
public ColorType Format { get; }

/// <summary>
/// AcceleratedPaintInfo
/// </summary>
/// <param name="sharedTextureHandle">Handle to the shared texture resource</param>
/// <param name="format">The pixel format of the shared texture resource</param>
public AcceleratedPaintInfo(IntPtr sharedTextureHandle, ColorType format)
{
SharedTextureHandle = sharedTextureHandle;
Format = format;
}
}
}

0 comments on commit 4ae2b5f

Please sign in to comment.