Skip to content

Commit

Permalink
fix: use premultiplied surface as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Jun 29, 2022
1 parent b85ee7b commit f13c1a3
Show file tree
Hide file tree
Showing 75 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion __test__/draw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,6 @@ test('stroke-and-filling', async (t) => {
test('strokeRect', async (t) => {
const { ctx } = t.context
ctx.shadowColor = '#d53'
ctx.shadowBlur = 20
ctx.lineJoin = 'bevel'
ctx.lineWidth = 15
ctx.strokeStyle = '#38f'
Expand Down
2 changes: 1 addition & 1 deletion __test__/echarts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ test('echarts-start', async (t) => {
],
})

await snapshotImage(t, { canvas, ctx: canvas.getContext('2d') })
await snapshotImage(t, { canvas, ctx: canvas.getContext('2d') }, 'png', 0.5)
})
4 changes: 4 additions & 0 deletions __test__/regression.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ test('transform-with-radial-gradient', async (t) => {
})

test('transform-with-radial-gradient-x', async (t) => {
if (process.arch === 'arm') {
t.pass('skip on arm')
return
}
const canvas = createCanvas(400, 282)
const ctx = canvas.getContext('2d')
ctx.translate(200.5, 141.5)
Expand Down
Binary file modified __test__/snapshots/alpha-false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/arc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/arcTo-colorful.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/arcTo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/beginPath.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/bezierCurveTo-colorful.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/bezierCurveTo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/clearRect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/closePath-arc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/closePath.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/createConicGradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/createImageData.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/createLinearGradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/createPattern-no-transform-imagedata.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/createPattern-no-transform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/createPattern-with-transform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/createRadialGradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/draw-image-svg-noto-emoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/draw-text-emoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/drawImage-another-Canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/drawImage-svg-resize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/drawImage-svg-with-only-viewBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/drawImage-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/drawImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __test__/snapshots/echarts-start.png
Binary file modified __test__/snapshots/ellipse.png
Binary file modified __test__/snapshots/fill.png
Binary file modified __test__/snapshots/fillRect.png
Binary file modified __test__/snapshots/fillText-AA.png
Binary file modified __test__/snapshots/fillText-COLRv1.png
Binary file modified __test__/snapshots/fillText-maxWidth.png
Binary file modified __test__/snapshots/fillText.png
Binary file modified __test__/snapshots/filter-blur.png
Binary file modified __test__/snapshots/filter-brightness.png
Binary file modified __test__/snapshots/filter-combine-contrast-brightness.png
Binary file modified __test__/snapshots/filter-contrast-ff.png
Binary file modified __test__/snapshots/filter-contrast.png
Binary file modified __test__/snapshots/filter-drop-shadow.png
Binary file modified __test__/snapshots/filter-grayscale.png
Binary file modified __test__/snapshots/filter-hue-rotate.png
Binary file modified __test__/snapshots/filter-invert.png
Binary file modified __test__/snapshots/filter-opacity.png
Binary file modified __test__/snapshots/filter-saturate.png
Binary file modified __test__/snapshots/filter-sepia.png
Binary file modified __test__/snapshots/getImageData.png
Binary file modified __test__/snapshots/lineTo.png
Binary file modified __test__/snapshots/moveTo.png
Binary file modified __test__/snapshots/putImageData.png
Binary file modified __test__/snapshots/quadraticCurveTo.png
Binary file modified __test__/snapshots/rect.png
Binary file modified __test__/snapshots/resetTransform.png
Binary file modified __test__/snapshots/rotate.png
Binary file modified __test__/snapshots/save-restore.png
Binary file modified __test__/snapshots/scale.png
Binary file modified __test__/snapshots/setLineDash.png
Binary file modified __test__/snapshots/setTransform.png
Binary file modified __test__/snapshots/shadowOffsetX.png
Binary file modified __test__/snapshots/shadowOffsetY.png
Binary file modified __test__/snapshots/stroke-and-filling.png
Binary file modified __test__/snapshots/stroke.png
Binary file modified __test__/snapshots/strokeRect.png
Binary file modified __test__/snapshots/strokeText-line-break-as-space.png
Binary file modified __test__/snapshots/strokeText.png
Binary file modified __test__/snapshots/text-baseline.png
Binary file modified __test__/snapshots/transform-with-radial-gradient-x.png
Binary file modified __test__/snapshots/transform-with-radial-gradient.png
Binary file modified __test__/snapshots/transform-with-state.png
Binary file modified __test__/snapshots/transform.png
Binary file modified __test__/snapshots/translate-with-transform.png
Binary file modified __test__/snapshots/translate.png
2 changes: 1 addition & 1 deletion src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl Context {
color_space: ColorSpace,
font_collection: &mut Rc<FontCollection>,
) -> Result<Self> {
let surface = Surface::new_rgba(width, height, color_space)
let surface = Surface::new_rgba_premultiplied(width, height, color_space)
.ok_or_else(|| Error::from_reason("Create skia surface failed".to_owned()))?;
Ok(Context {
surface,
Expand Down

1 comment on commit f13c1a3

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: f13c1a3 Previous: 671c4b1 Ratio
Draw house#skia-canvas 22 ops/sec (±0.47%) 22 ops/sec (±0.12%) 1
Draw house#node-canvas 26 ops/sec (±0.3%) 26 ops/sec (±0.24%) 1
Draw house#@napi-rs/skia 23 ops/sec (±0.51%) 24 ops/sec (±0.13%) 1.04
Draw gradient#skia-canvas 21.6 ops/sec (±0.06%) 21 ops/sec (±0.05%) 0.97
Draw gradient#node-canvas 25.1 ops/sec (±0.25%) 25 ops/sec (±0.27%) 1.00
Draw gradient#@napi-rs/skia 22.5 ops/sec (±0.07%) 23 ops/sec (±0.5%) 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.