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

Implement GLContextDispatcher trait for NativeGLContexts #432

Merged
merged 1 commit into from Oct 18, 2016

Conversation

@MortimerGoro
Copy link
Contributor

MortimerGoro commented Oct 5, 2016

Implement GLContextDispatcher trait for NativeGLContexts. Required to allow GLContext sharing in some implementations like WGL.

See servo/surfman#69 for more info.


This change is Reviewable

@MortimerGoro MortimerGoro changed the title Implement GLContextDispatcher trait for NativeGLContexts, r=emilio Implement GLContextDispatcher trait for NativeGLContexts Oct 5, 2016
@@ -42,6 +43,7 @@ pub struct RenderBackend {
webgl_contexts: HashMap<WebGLContextId, GLContextWrapper>,
current_bound_webgl_context_id: Option<WebGLContextId>,
enable_recording: bool,
main_thread_dispatcher: Arc<Mutex<Option<Box<RenderDispatcher>>>>

This comment has been minimized.

@emilio

emilio Oct 5, 2016

Member

Probably an option of an arc is a better Idea?

This comment has been minimized.

@MortimerGoro

MortimerGoro Oct 5, 2016

Author Contributor

I used the same type pattern as the one used in RenderNotifier setter

This comment has been minimized.

@emilio

emilio Oct 5, 2016

Member

Hmm... I see why you need this, but it seems unfortunate.

@@ -261,7 +265,10 @@ impl RenderBackend {
}
ApiMsg::RequestWebGLContext(size, attributes, tx) => {
if let Some(ref wrapper) = self.webrender_context_handle {
let result = wrapper.new_context(size, attributes);
let dispatcher = Box::new(WebRenderGLDispatcher {

This comment has been minimized.

@emilio

emilio Oct 5, 2016

Member

Do this only on windows?

This comment has been minimized.

@MortimerGoro

MortimerGoro Oct 5, 2016

Author Contributor

Yeah, I'll add a macro. It will avoid unneeded allocations in the platforms that don't use this.

This comment has been minimized.

@MortimerGoro

MortimerGoro Oct 7, 2016

Author Contributor

Done

@emilio
Copy link
Member

emilio commented Oct 5, 2016

I need to review this really carefully. May you open also a PR with your servo-related changes so it's easy to see the code flow?

@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Oct 5, 2016

Still have to rebase the latest servo master, I'll do tomorrow. In the meantime you can check this: MortimerGoro/servo@64f92be, it will be the same code, just changing Dispatcher name to RenderDispatcher.

P.D.: I created another trait called RenderDispatcher in order to not expose internal types of webrender. I assumed that you want that webrender library users don't need to be aware that offscreen_gl_context is used internally. Servo now uses offscreen_gl_context includes, but I thought that might not be true in the future when webrender is set up as default and skia renderer dropped.

@MortimerGoro MortimerGoro force-pushed the MortimerGoro:dispatcher branch from 80f97b8 to 62aaa20 Oct 7, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Oct 11, 2016

The latest upstream changes (presumably #439) made this pull request unmergeable. Please resolve the merge conflicts.

@MortimerGoro MortimerGoro force-pushed the MortimerGoro:dispatcher branch 2 times, most recently from 3cf4b78 to a189acc Oct 13, 2016
@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Oct 18, 2016

Any news on this?

I have a another idea to implement this. We could create and pass the dispatcher directly from WebGLPaintThred in servo, in this call.

wr_api.request_webgl_context(&size, attrs)

Let me know what you think

@emilio
emilio approved these changes Oct 18, 2016
Copy link
Member

emilio left a comment

Sorry for the huge delay.

The other idea is nice too, but I think one global dispatcher is fine for now. Looks good to me with that nit addressed, and optionally that comment moved.

Thanks, and sorry again it took so long :)

let result = wrapper.new_context(size, attributes);
let dispatcher: Option<Box<GLContextDispatcher>>;
if cfg!(target_os = "windows") {
dispatcher = Some(Box::new(WebRenderGLDispatcher {

This comment has been minimized.

@emilio

emilio Oct 18, 2016

Member

nit:

let dispatcher = if cfg!(target_os = "windows") {
    Some(...)
} else {
    None
};

This comment has been minimized.

@MortimerGoro

MortimerGoro Oct 18, 2016

Author Contributor

I had to specify the type: Option<Box<GLContextDispatcher>> or rust compiler doesn't have enough magic to coerce

/// Sets the new MainThreadDispatcher.
///
/// Used to dispatch functions to the main thread's event loop.
/// Required to allow GLContext sharing in some implementations like WGL.

This comment has been minimized.

@emilio

emilio Oct 18, 2016

Member

probably moving the last part of this comment to the main_thread_dispatcher member definition would make it a bit more helpful.

@MortimerGoro MortimerGoro force-pushed the MortimerGoro:dispatcher branch from a189acc to 027e224 Oct 18, 2016
@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Oct 18, 2016

Done :)

@emilio
Copy link
Member

emilio commented Oct 18, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Oct 18, 2016

📌 Commit 027e224 has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Oct 18, 2016

Testing commit 027e224 with merge b667e13...

bors-servo added a commit that referenced this pull request Oct 18, 2016
Implement GLContextDispatcher trait for NativeGLContexts

Implement GLContextDispatcher trait for NativeGLContexts. Required to allow GLContext sharing in some implementations like WGL.

See servo/surfman#69 for more info.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/432)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Oct 18, 2016

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 027e224 into servo:master Oct 18, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@MortimerGoro MortimerGoro mentioned this pull request Oct 19, 2016
3 of 5 tasks complete
bors-servo added a commit to servo/servo that referenced this pull request Oct 21, 2016
WebGL support on Windows

<!-- Please describe your changes on the following line: -->
This is the final step to provide WebGL support on Windows ;)

Some Related PRs already merged in webrender and offscreen-gl-context:

servo/surfman#64
servo/webrender#432

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13840)
<!-- Reviewable:end -->
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 4, 2017
…render_dispatcher); r=emilio

<!-- Please describe your changes on the following line: -->
This is the final step to provide WebGL support on Windows ;)

Some Related PRs already merged in webrender and offscreen-gl-context:

servo/surfman#64
servo/webrender#432

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

Source-Repo: https://github.com/servo/servo
Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
…render_dispatcher); r=emilio

<!-- Please describe your changes on the following line: -->
This is the final step to provide WebGL support on Windows ;)

Some Related PRs already merged in webrender and offscreen-gl-context:

servo/surfman#64
servo/webrender#432

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

Source-Repo: https://github.com/servo/servo
Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e

UltraBlame original commit: c57538159933d9eb1840437dfa9c9860220dd805
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…render_dispatcher); r=emilio

<!-- Please describe your changes on the following line: -->
This is the final step to provide WebGL support on Windows ;)

Some Related PRs already merged in webrender and offscreen-gl-context:

servo/surfman#64
servo/webrender#432

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

Source-Repo: https://github.com/servo/servo
Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e

UltraBlame original commit: c57538159933d9eb1840437dfa9c9860220dd805
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…render_dispatcher); r=emilio

<!-- Please describe your changes on the following line: -->
This is the final step to provide WebGL support on Windows ;)

Some Related PRs already merged in webrender and offscreen-gl-context:

servo/surfman#64
servo/webrender#432

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

Source-Repo: https://github.com/servo/servo
Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e

UltraBlame original commit: c57538159933d9eb1840437dfa9c9860220dd805
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.