mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2025-08-04 20:42:25 -07:00
Merge pull request #9451 from ameerj/camera-data-array
camera: Use pre-allocated vector for camera data
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -247,6 +247,9 @@ private:
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||
std::unique_ptr<QCamera> camera;
|
||||
std::unique_ptr<QCameraImageCapture> camera_capture;
|
||||
static constexpr std::size_t CAMERA_WIDTH = 320;
|
||||
static constexpr std::size_t CAMERA_HEIGHT = 240;
|
||||
std::vector<u32> camera_data;
|
||||
#endif
|
||||
std::unique_ptr<QTimer> camera_timer;
|
||||
|
||||
|
Reference in New Issue
Block a user