-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAcceleratedRenderHandler.cs
More file actions
42 lines (36 loc) · 1.34 KB
/
AcceleratedRenderHandler.cs
File metadata and controls
42 lines (36 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using CefSharp.OffScreen;
using CefSharp.Structs;
namespace CefSharp.Offscreen.Direct3D.Example;
public class AcceleratedRenderHandler(ChromiumWebBrowser browser, int windowWidth, int windowHeight) : DefaultRenderHandler(browser)
{
private D3D11Renderer _renderer = null!;
public override void OnAcceleratedPaint(PaintElementType type, Rect dirtyRect, AcceleratedPaintInfo acceleratedPaintInfo)
{
base.OnAcceleratedPaint(type, dirtyRect, acceleratedPaintInfo);
_renderer ??= new D3D11Renderer(windowWidth, windowHeight);
switch (type)
{
case PaintElementType.View:
_renderer?.OnAcceleratedPaint(acceleratedPaintInfo.SharedTextureHandle, PopupOpen);
break;
case PaintElementType.Popup:
_renderer?.CreatePopupLayer(acceleratedPaintInfo.SharedTextureHandle, new Rect(PopupPosition.X, PopupPosition.Y, PopupSize.Width, PopupSize.Height));
break;
}
}
public void BrowserWasResized(int width, int height)
{
_renderer?.ResizeWindow(width, height);
}
public override void OnPopupShow(bool show)
{
base.OnPopupShow(show);
if(show) return;
_renderer?.RemovePopupLayer();
}
public new void Dispose()
{
base.Dispose();
_renderer?.Dispose();
}
}