mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 22:10:21 +00:00
fix(diffs): tighten rendering quality
This commit is contained in:
@@ -122,15 +122,29 @@ export class PlaywrightDiffScreenshotter implements DiffScreenshotter {
|
||||
throw new Error("Diff frame was lost after resizing.");
|
||||
}
|
||||
|
||||
const dpr = await page.evaluate(() => window.devicePixelRatio || 1);
|
||||
|
||||
// Raw clip in CSS px
|
||||
const rawX = Math.max(box.x - padding, 0);
|
||||
const rawY = Math.max(box.y - padding, 0);
|
||||
const rawRight = rawX + clipWidth;
|
||||
const rawBottom = rawY + clipHeight;
|
||||
|
||||
// Snap to device-pixel grid to avoid soft text from sub-pixel crop
|
||||
const x = Math.floor(rawX * dpr) / dpr;
|
||||
const y = Math.floor(rawY * dpr) / dpr;
|
||||
const right = Math.ceil(rawRight * dpr) / dpr;
|
||||
const bottom = Math.ceil(rawBottom * dpr) / dpr;
|
||||
|
||||
await page.screenshot({
|
||||
path: params.outputPath,
|
||||
type: "png",
|
||||
scale: "device",
|
||||
clip: {
|
||||
x: Math.max(box.x - padding, 0),
|
||||
y: Math.max(box.y - padding, 0),
|
||||
width: clipWidth,
|
||||
height: clipHeight,
|
||||
x,
|
||||
y,
|
||||
width: right - x,
|
||||
height: bottom - y,
|
||||
},
|
||||
});
|
||||
return params.outputPath;
|
||||
@@ -233,7 +247,7 @@ async function acquireSharedBrowser(params: {
|
||||
.launch({
|
||||
headless: true,
|
||||
...(executablePath ? { executablePath } : {}),
|
||||
args: ["--disable-dev-shm-usage", "--disable-gpu"],
|
||||
args: ["--disable-dev-shm-usage"],
|
||||
})
|
||||
.then((browser) => {
|
||||
if (sharedBrowserState?.browserPromise === browserPromise) {
|
||||
|
||||
Reference in New Issue
Block a user