Skip to content

Commit d3979f0

Browse files
committed
Enable GPU and set default scale to 1 in screencast
1 parent c7daf66 commit d3979f0

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function handleRender(source, options) {
1717
options.type = type;
1818
options.delay = readTime(options.delay, { max: 30 * 1000 }) || 0;
1919
options.time = readTime(options.time, { max: 60 * 1000 }) || 0;
20-
options.scale = Number(options.scale) || 2;
20+
options.scale = Number(options.scale) || (options.time ? 1 : 2);
2121
options.selector ??= 'css-doodle';
2222

2323
let title = options.time ? 'record' : 'image';

lib/render/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export async function render(code, options = {}) {
5959
if (/^(css|cssd|stdin)$/.test(options.type)) {
6060
tag = await page.$eval('css-doodle', el => el.seed);
6161
}
62-
options.output = `${options.title || 'screenshot'}-${tag}.png`;
62+
let ext = options.time ? 'webm' : 'png';
63+
options.output = `${options.title}-${tag}.${ext}`;
6364
}
6465

6566
if (options.delay) {

lib/render/screencast.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ const defaultWidth = 1600;
44
const defaultHeight = 900;
55

66
export async function screencast(page, options) {
7-
let { scale, output, selector } = options;
7+
const { scale, output, selector } = options;
88

99
await page.setViewport({
1010
width: defaultWidth,
1111
height: defaultHeight,
12-
deviceScaleFactor: scale
1312
});
1413

1514
const clip = await page.evaluate(selector => {
@@ -34,14 +33,12 @@ export async function screencast(page, options) {
3433
await page.setViewport({
3534
width: Math.ceil(clip.width) || defaultWidth,
3635
height: Math.ceil(clip.height) || defaultHeight,
37-
deviceScaleFactor: scale
3836
});
3937

40-
output = options.output.replace(/\.png$/, '.webm');
4138
const recorder = await page.screencast({
4239
path: output,
43-
scale: scale,
44-
clip
40+
scale,
41+
clip,
4542
});
4643

4744
await setTimeout(options.time);

lib/static.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ function getDefaultAppArgs() {
3737
'--enable-composited-animations',
3838
'--enable-optimized-css',
3939
'--enable-accelerated-2d-canvas',
40+
'--enable-gpu',
41+
'--use-angle',
4042
];
4143

4244
if (isLinux) {

0 commit comments

Comments
 (0)