diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2022-12-17 10:21:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-17 10:21:50 -0500 |
commit | a3bac5550d144246fb95b12f0fb2b45befcb8035 (patch) | |
tree | 12d14847347c6fe006e5b7dfc4fd11439e48e195 /src/yuzu/bootmanager.cpp | |
parent | 4faea2bbf46bbfc7b69ce2c56cd2eb274be49d70 (diff) | |
parent | 7bf4bec257dffb633d818fb1a7ade6b899ec79a5 (diff) |
Merge pull request #9451 from ameerj/camera-data-array
camera: Use pre-allocated vector for camera data
Diffstat (limited to 'src/yuzu/bootmanager.cpp')
-rw-r--r-- | src/yuzu/bootmanager.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 642f96690..6afbdaf12 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -757,6 +757,7 @@ void GRenderWindow::InitializeCamera() { return; } + camera_data.resize(CAMERA_WIDTH * CAMERA_HEIGHT); camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer); connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, &GRenderWindow::OnCameraCapture); @@ -812,16 +813,13 @@ void GRenderWindow::RequestCameraCapture() { } void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { - constexpr std::size_t camera_width = 320; - constexpr std::size_t camera_height = 240; + // TODO: Capture directly in the format and resolution needed const auto converted = - img.scaled(camera_width, camera_height, Qt::AspectRatioMode::IgnoreAspectRatio, + img.scaled(CAMERA_WIDTH, CAMERA_HEIGHT, Qt::AspectRatioMode::IgnoreAspectRatio, Qt::TransformationMode::SmoothTransformation) .mirrored(false, true); - std::vector<u32> camera_data{}; - camera_data.resize(camera_width * camera_height); - std::memcpy(camera_data.data(), converted.bits(), camera_width * camera_height * sizeof(u32)); - input_subsystem->GetCamera()->SetCameraData(camera_width, camera_height, camera_data); + std::memcpy(camera_data.data(), converted.bits(), CAMERA_WIDTH * CAMERA_HEIGHT * sizeof(u32)); + input_subsystem->GetCamera()->SetCameraData(CAMERA_WIDTH, CAMERA_HEIGHT, camera_data); pending_camera_snapshots = 0; } |