Skip to content

Commit 8d191d1

Browse files
committed
Make the desktop no longer show through when alpha blending is involved
for borderless windows on the Mac. This was because the blend function was `GL_SRC_ALPHA`/`GL_ONE_MINUS_SRC_ALPHA` for both RGB and alpha, and that was incorrect for alpha, since a destination alpha of 1.0 and a source alpha < 1.0 should result in an alpha of 1.0.
1 parent 9309d52 commit 8d191d1

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/debug_render.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ impl DebugRenderer {
168168
gl::disable(gl::DEPTH_TEST);
169169
gl::enable(gl::BLEND);
170170
gl::blend_equation(gl::FUNC_ADD);
171-
gl::blend_func(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
171+
gl::blend_func_separate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA,
172+
gl::ONE, gl::ONE);
172173

173174
let projection = Matrix4::ortho(0.0,
174175
viewport_size.width as f32,

src/renderer.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ impl Renderer {
12041204
gl::disable(gl::BLEND);
12051205
} else {
12061206
gl::enable(gl::BLEND);
1207-
gl::blend_func(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
1207+
gl::blend_func_separate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA,
1208+
gl::ONE, gl::ONE);
12081209
gl::blend_equation(gl::FUNC_ADD);
12091210
}
12101211

@@ -1417,8 +1418,8 @@ impl Renderer {
14171418
program = self.blit_program_id;
14181419
}
14191420
CompositionOp::Filter(LowLevelFilterOp::Opacity(amount)) => {
1420-
gl::blend_func(gl::SRC_ALPHA,
1421-
gl::ONE_MINUS_SRC_ALPHA);
1421+
gl::blend_func_separate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA,
1422+
gl::ONE, gl::ONE);
14221423
gl::blend_equation(gl::FUNC_ADD);
14231424
alpha = amount.to_f32_px();
14241425
program = self.blit_program_id;
@@ -1430,15 +1431,21 @@ impl Renderer {
14301431
let (opcode, amount, param0, param1) = match filter_op {
14311432
LowLevelFilterOp::Blur(radius,
14321433
AxisDirection::Horizontal) => {
1433-
gl::blend_func(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
1434+
gl::blend_func_separate(gl::SRC_ALPHA,
1435+
gl::ONE_MINUS_SRC_ALPHA,
1436+
gl::ONE,
1437+
gl::ONE);
14341438
(0.0,
14351439
radius.to_f32_px() * self.device_pixel_ratio,
14361440
1.0,
14371441
0.0)
14381442
}
14391443
LowLevelFilterOp::Blur(radius,
14401444
AxisDirection::Vertical) => {
1441-
gl::blend_func(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
1445+
gl::blend_func_separate(gl::SRC_ALPHA,
1446+
gl::ONE_MINUS_SRC_ALPHA,
1447+
gl::ONE,
1448+
gl::ONE);
14421449
(0.0,
14431450
radius.to_f32_px() * self.device_pixel_ratio,
14441451
0.0,

0 commit comments

Comments
 (0)