Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offscreen invalidate and sizing fix #7062

Merged
merged 5 commits into from
Sep 19, 2016
Merged

Conversation

gerhardberger
Copy link
Contributor

This PR adds an invalidate method to webContents to manually request a new frame in offscreen mode.

And also fixes the issue that a browser did not resize properly in offscreen mode.

@zeke
Copy link
Contributor

zeke commented Sep 2, 2016

Hi @gerhardberger. What is the use case for this new method?

@gerhardberger
Copy link
Contributor Author

@zeke, it generates a 'paint' event on-demand with the current frame. This can be used when you need the latest frame but no change happens on the page, e.g. you start rendering to a new place and you want an initial frame.


// In offscreen mode call RenderWidgetHostView's SetSize explicitly
const auto view = web_contents()->GetRenderWidgetHostView();
if (view) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IsOffScreen should be checked here.

Copy link
Contributor Author

@gerhardberger gerhardberger Sep 16, 2016

Choose a reason for hiding this comment

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

I thought about that, but couldn't come up with a proper way to get the atom::api::WebContents in NativeWindow.

But this SetSize call only happens in OSR mode, because in a normal rendering mode having a different size other than the one we wanted to set after we set it should not happen.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about subscribing to window resize events in RenderWidgetHostView? It is provided by NativeWindowObserver.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great I didn't notice that, thanks! I moved the call to OffscreenRenderWidgetHostView.

@danburzo
Copy link
Contributor

This is great! I was doing a stopPainting()/startPainting() combo to force a paint event.

The use-case (for me, at least) is you want to grab a PNG representation of the page after a certain client event is emitted, and since the Buffer is volatile, I'm not sure how you'd have done it previously (other than triggering a paint event).

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.

4 participants