-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Canvas transparency on iOS (#157)
- Loading branch information
1 parent
62dc18d
commit 1bc7c5b
Showing
7 changed files
with
45 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { checkImage, client, encodeImage } from "./setup"; | ||
|
||
describe("Alpha", () => { | ||
it("Premultiplied Color", async () => { | ||
const result = await client.eval(({ device, ctx, canvas }) => { | ||
const commandEncoder = device.createCommandEncoder(); | ||
const textureView = ctx.getCurrentTexture().createView(); | ||
const alpha = 0.5; | ||
const renderPassDescriptor: GPURenderPassDescriptor = { | ||
colorAttachments: [ | ||
{ | ||
view: textureView, | ||
clearValue: [0.3 * alpha, 0.6 * alpha, 1 * alpha, alpha], | ||
loadOp: "clear", | ||
storeOp: "store", | ||
}, | ||
], | ||
}; | ||
|
||
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); | ||
passEncoder.end(); | ||
device.queue.submit([commandEncoder.finish()]); | ||
return canvas.getImageData(); | ||
}); | ||
const image = encodeImage(result); | ||
checkImage(image, "snapshots/semi-opaque-cyan.png"); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.