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,14 +459,36 @@ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer {
(captureR, r) => (r[0] > captureR[0] ? r : captureR), [0, -1]);
}
const filterByScreenSize = ([w, h], index, arr) =>
index == arr.length - 1 ||
(w <= window.screen.width && h <= window.screen.height);
const candidates = [...previewRs]
.sort(([w, h], [w2, h2]) => w2 - w)
.filter(filterByScreenSize)
.map(([width, height]) => ({
/**
* @param {!ResolList} rs
* @return {!ResolList}
*/
const sortPreview = (rs) => {
if (rs.length == 0) {
return [];
}
rs = [...rs].sort(([w, h], [w2, h2]) => w2 - w);
// Promote resolution slightly larget than screen size to the first.
const screenW =
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},
......
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