-
Notifications
You must be signed in to change notification settings - Fork 33
cocoa: Add a new platform-specific API that allows library consumers to specify that only the corners of a window can be transparent. #94
Conversation
Mostly fine, but seems a bit more hacky than it should be. Is there a way to clean this up?
|
If you don't mind, I'd like to review this too. There's something I'd like to validate first. I'll look at this on Monday. |
Ok - looks fine to me.
I guess we could land this as a temporary solution, but the best thing to do is probably to clip in glutin directly instead or doing that in webrender via CSS border-radius in browserhtml. |
@metajack @paulrouget I'm confused as to what you mean by clipping in Glutin directly or doing it in WR via CSS border radius. The problem is that the Mac OS X window server doesn't know anything about what we do in our OpenGL context: it just composites buffers together. To allow it to perform occlusion culling, we need to tell it something extra, namely the region of the window that is guaranteed to be opaque. It can't work that out on its own just from the contents of the window. This is a bit of an ugly layering violation, but it's how the system works. |
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. src/api/cocoa/mod.rs, line 417 [r1] (raw file):
|
6417fec
to
210f7c5
Compare
Updated per comments |
@bors-servo r+
|
📌 Commit 210f7c5 has been approved by |
…etajack cocoa: Add a new platform-specific API that allows library consumers to specify that only the corners of a window can be transparent. By doing this, we significantly improve performance by allowing the window server to perform occlusion culling under most of the window. This patch relies on the private `CGSRegion` and the private `-[NSCGSWindow setOpaqueRegion:]` APIs. Requires servo/core-graphics-rs#50 and servo/cocoa-rs#129. r? @metajack <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/glutin/94) <!-- Reviewable:end -->
💔 Test failed - travis |
Before, we didn't care about the window border radius, it was supported out of the box. Ideally, we would not have to care about the border radius in both browserhtml and Servo. I understand there are good reasons why we ended up in this situation, but I'm wondering if there would be an easier setup. I don't see any reason why anybody would want windows with no border radius, so maybe, if it's possible (I have honestly no idea), couldn't we just always clip the radius within glutin, with builtin values for the size of the radius, and use these builtin values to set the always-opaque regions? Hope that makes more sense. Also - I'm ok with the current approach. I don't want to block this. It's important. |
Windows windows have no border radius, at least in Windows 10. I suspect that Android and other mobile OSes probably also have square corners. I don't think this invalidates your point as glutin could either do or not do this depending on platform. |
@paulrouget Oh, I see what you're saying. We could get closer to that ideal by having WebRender implicitly add border radii to the display list on the Mac platform so you wouldn't have to do it in browser.html, but that would just move the complexity to Servo without much gain. It'd be more code to do it in Servo vs. one line in the CSS of browser.html (though I guess we could do it with some sort of UA stylesheet or something like that). Still, that isn't the ideal, as we'd have to have that code somewhere in Servo. Unfortunately I just don't know of a well-supported, Apple-approved way to do what we want to do, at least without using Core Animation (which, incidentally, zwarich recently advised us against). The OS is fundamentally designed so that either (a) each app draws the rounded corners; or (b) Core Animation draws the entire UI of the app. Most apps don't have to worry about drawing anything explicitly when following route (a) because the native By the way, the reason we don't want to use Core Animation is that Core Animation is essentially designed to take over all of the GPU-based UI painting for your app. This works fine if you're using the traditional tiled rendering model, like Safari does, but we have to have very fine-grained control over custom shaders and so forth, which is something that CA doesn't support. So it isn't a good option for us. We could technically draw everything into one big in-memory texture and ship that over to CA, which would then blit the texture to the screen with the proper corner mask (which is in fact what would happen if we used |
210f7c5
to
e78b723
Compare
@bors-servo: r=metajack |
📌 Commit e78b723 has been approved by |
…etajack cocoa: Add a new platform-specific API that allows library consumers to specify that only the corners of a window can be transparent. By doing this, we significantly improve performance by allowing the window server to perform occlusion culling under most of the window. This patch relies on the private `CGSRegion` and the private `-[NSCGSWindow setOpaqueRegion:]` APIs. Requires servo/core-graphics-rs#50 and servo/cocoa-rs#129. r? @metajack <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/glutin/94) <!-- Reviewable:end -->
💔 Test failed - travis |
e78b723
to
49573e7
Compare
@bors-servo: r=metajack |
📌 Commit 49573e7 has been approved by |
…etajack cocoa: Add a new platform-specific API that allows library consumers to specify that only the corners of a window can be transparent. By doing this, we significantly improve performance by allowing the window server to perform occlusion culling under most of the window. This patch relies on the private `CGSRegion` and the private `-[NSCGSWindow setOpaqueRegion:]` APIs. Requires servo/core-graphics-rs#50 and servo/cocoa-rs#129. r? @metajack <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/glutin/94) <!-- Reviewable:end -->
specify that only the corners of a window can be transparent. By doing this, we significantly improve performance by allowing the window server to perform occlusion culling under most of the window. This patch relies on the private `CGSRegion` and the private `-[NSCGSWindow setOpaqueRegion:]` APIs. Requires servo/core-graphics-rs#50 and servo/cocoa-rs#129.
☀️ Test successful - travis |
By doing this, we significantly improve performance by allowing the
window server to perform occlusion culling under most of the window.
This patch relies on the private
CGSRegion
and the private-[NSCGSWindow setOpaqueRegion:]
APIs.Requires servo/core-graphics-rs#50 and servo/cocoa-rs#129.
r? @metajack
This change is