Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AzeExMachina
Copy link

No description provided.

@AzeExMachina AzeExMachina changed the title sample using accelerated renderer on offscreen environment sample using accelerated renderer in offscreen environment Oct 24, 2025
Copy link
Member

@amaitland amaitland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR 👍 Very cool.

Few comments inline, I think changing the way the cleanup is handled is probably worth actioning.

Doesn't look like the browser would handle any sort of resize, is that correct?


public D3D11Renderer(int windowWidth, int windowHeight)
{
Cef.ShutdownStarted += (_, _) => Destroy();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given D3D11Renderer appears create an instance per ChromiumWebBrowser instance would it be better if this class implemented IDisposable and was disposed with the ChromiumWebBrowser instance? (Should be able to override Dispose on the OffscreenBrowser class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point. I'll change this right away

# JetBrains Rider
*.sln.iml
/CefSharp.WinForms.Direct3D.Example/obj.netcore
.idea/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a rider folder containing project specific settings files, it's not mandatory since I simply can avoid to commit that folder. It was just to make it easier when committing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick response, should be fine to leave.

var windowInfo = new WindowInfo {WindowlessRenderingEnabled = true, Width = width, Height = height};
windowInfo.SharedTextureEnabled = true;
windowInfo.SetAsWindowless(IntPtr.Zero);
CreateBrowser(windowInfo, cefBrowserSettings);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a general comment I don't recommend calling CreateBrowser in the constructor (was probably a mistake that it ever did). Makes it very difficult to reliably attach event handlers, due to the browser being created async, it's possible to attach them after the browser has been created.

For the example it's probably fine, just pointing it out.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out!

@AzeExMachina
Copy link
Author

Doesn't look like the browser would handle any sort of resize, is that correct?

You mean for the ResizeWindow method that I wrote in the D3DRenderer class? I wrote that just to show how you can do that if needed. If you think that it's a bit confusing I'll remove it to make it as simple as possible

@amaitland
Copy link
Member

You mean for the ResizeWindow method that I wrote in the D3DRenderer class? I wrote that just to show how you can do that if needed. If you think that it's a bit confusing I'll remove it to make it as simple as possible

If you were to change the ChromiumWebBrowser.Size of the browser, it didn't look like the render handler would deal with the size change. I haven't debugged the code to confirm this, so I could be mistaken.

@AzeExMachina
Copy link
Author

You mean for the ResizeWindow method that I wrote in the D3DRenderer class? I wrote that just to show how you can do that if needed. If you think that it's a bit confusing I'll remove it to make it as simple as possible

If you were to change the ChromiumWebBrowser.Size of the browser, it didn't look like the render handler would deal with the size change. I haven't debugged the code to confirm this, so I could be mistaken.

As of now I didn't put any resizing in the code, but the ChromiumWebBrowser.Size is only getting changed once before creating the AcceleratedRenderHandler. I'll clarify by putting a Resize flow that also changes the D3DRenderer target to avoid confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants