Commit 120f9c12 authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

[CCA] Promote photo preview resolution slightly larger than screen.

Bug: 1017570
Test: Verify, on HALv3 device, the the photo mode preview resolution
slightly larger than screen size is selected.

Change-Id: Ibd6afd65d63c80990b92972e78310f32287c13c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1877334Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Shik Chen <shik@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708984}
parent 042056be
...@@ -459,21 +459,43 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer { ...@@ -459,21 +459,43 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer {
(captureR, r) => (r[0] > captureR[0] ? r : captureR), [0, -1]); (captureR, r) => (r[0] > captureR[0] ? r : captureR), [0, -1]);
} }
const filterByScreenSize = ([w, h], index, arr) => /**
index == arr.length - 1 || * @param {!ResolList} rs
(w <= window.screen.width && h <= window.screen.height); * @return {!ResolList}
*/
const candidates = [...previewRs] const sortPreview = (rs) => {
.sort(([w, h], [w2, h2]) => w2 - w) if (rs.length == 0) {
.filter(filterByScreenSize) return [];
.map(([width, height]) => ({ }
audio: false, rs = [...rs].sort(([w, h], [w2, h2]) => w2 - w);
video: {
deviceId: {exact: deviceId}, // Promote resolution slightly larget than screen size to the first.
width, const screenW =
height, Math.floor(window.screen.width * window.devicePixelRatio);
}, const screenH =
})); Math.floor(window.screen.height * window.devicePixelRatio);
let minIdx = null;
rs.forEach(([w, h], idx) => {
if (w >= screenW && h >= screenH) {
minIdx = idx;
}
});
if (minIdx !== null) {
rs.unshift(...rs.splice(minIdx, 1));
}
return rs;
};
const candidates =
sortPreview(previewRs).map(([width, height]) => ({
audio: false,
video: {
deviceId: {exact: deviceId},
width,
height,
},
}));
// Format of map result: // Format of map result:
// [ // [
// [[CaptureW 1, CaptureH 1], [CaptureW 2, CaptureH 2], ...], // [[CaptureW 1, CaptureH 1], [CaptureW 2, CaptureH 2], ...],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment