diff options
| author | 2019-04-05 19:32:58 -0400 | |
|---|---|---|
| committer | 2019-04-05 19:33:00 -0400 | |
| commit | 845607481c3b4a25125df2052c4416fcc2badbb7 (patch) | |
| tree | 8ad7a9bf7fe2393692218ad4a1d5774ef0c74a48 | |
| parent | yuzu/debugger/graphics_surface: Clean up connection overload deduction (diff) | |
| download | yuzu-845607481c3b4a25125df2052c4416fcc2badbb7.tar.gz yuzu-845607481c3b4a25125df2052c4416fcc2badbb7.tar.xz yuzu-845607481c3b4a25125df2052c4416fcc2badbb7.zip | |
yuzu/debugger/graphics_surface: Tidy up SaveSurface
- Use QStringLiteral where applicable.
- Use const where applicable
- Remove unnecessary precondition check (we already assert the pixbuf
being non null)
| -rw-r--r-- | src/yuzu/debugger/graphics/graphics_surface.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/yuzu/debugger/graphics/graphics_surface.cpp b/src/yuzu/debugger/graphics/graphics_surface.cpp index 886da9587..31d412ff5 100644 --- a/src/yuzu/debugger/graphics/graphics_surface.cpp +++ b/src/yuzu/debugger/graphics/graphics_surface.cpp | |||
| @@ -459,39 +459,38 @@ void GraphicsSurfaceWidget::OnUpdate() { | |||
| 459 | } | 459 | } |
| 460 | 460 | ||
| 461 | void GraphicsSurfaceWidget::SaveSurface() { | 461 | void GraphicsSurfaceWidget::SaveSurface() { |
| 462 | QString png_filter = tr("Portable Network Graphic (*.png)"); | 462 | const QString png_filter = tr("Portable Network Graphic (*.png)"); |
| 463 | QString bin_filter = tr("Binary data (*.bin)"); | 463 | const QString bin_filter = tr("Binary data (*.bin)"); |
| 464 | 464 | ||
| 465 | QString selectedFilter; | 465 | QString selected_filter; |
| 466 | QString filename = QFileDialog::getSaveFileName( | 466 | const QString filename = QFileDialog::getSaveFileName( |
| 467 | this, tr("Save Surface"), | 467 | this, tr("Save Surface"), |
| 468 | QString("texture-0x%1.png").arg(QString::number(surface_address, 16)), | 468 | QStringLiteral("texture-0x%1.png").arg(QString::number(surface_address, 16)), |
| 469 | QString("%1;;%2").arg(png_filter, bin_filter), &selectedFilter); | 469 | QStringLiteral("%1;;%2").arg(png_filter, bin_filter), &selected_filter); |
| 470 | 470 | ||
| 471 | if (filename.isEmpty()) { | 471 | if (filename.isEmpty()) { |
| 472 | // If the user canceled the dialog, don't save anything. | 472 | // If the user canceled the dialog, don't save anything. |
| 473 | return; | 473 | return; |
| 474 | } | 474 | } |
| 475 | 475 | ||
| 476 | if (selectedFilter == png_filter) { | 476 | if (selected_filter == png_filter) { |
| 477 | const QPixmap* pixmap = surface_picture_label->pixmap(); | 477 | const QPixmap* const pixmap = surface_picture_label->pixmap(); |
| 478 | ASSERT_MSG(pixmap != nullptr, "No pixmap set"); | 478 | ASSERT_MSG(pixmap != nullptr, "No pixmap set"); |
| 479 | 479 | ||
| 480 | QFile file(filename); | 480 | QFile file(filename); |
| 481 | file.open(QIODevice::WriteOnly); | 481 | file.open(QIODevice::WriteOnly); |
| 482 | if (pixmap) | 482 | pixmap->save(&file, "PNG"); |
| 483 | pixmap->save(&file, "PNG"); | 483 | } else if (selected_filter == bin_filter) { |
| 484 | } else if (selectedFilter == bin_filter) { | ||
| 485 | auto& gpu = Core::System::GetInstance().GPU(); | 484 | auto& gpu = Core::System::GetInstance().GPU(); |
| 486 | std::optional<VAddr> address = gpu.MemoryManager().GpuToCpuAddress(surface_address); | 485 | const std::optional<VAddr> address = gpu.MemoryManager().GpuToCpuAddress(surface_address); |
| 487 | 486 | ||
| 488 | const u8* buffer = Memory::GetPointer(*address); | 487 | const u8* const buffer = Memory::GetPointer(*address); |
| 489 | ASSERT_MSG(buffer != nullptr, "Memory not accessible"); | 488 | ASSERT_MSG(buffer != nullptr, "Memory not accessible"); |
| 490 | 489 | ||
| 491 | QFile file(filename); | 490 | QFile file(filename); |
| 492 | file.open(QIODevice::WriteOnly); | 491 | file.open(QIODevice::WriteOnly); |
| 493 | int size = surface_width * surface_height * Tegra::Texture::BytesPerPixel(surface_format); | 492 | const int size = surface_width * surface_height * Tegra::Texture::BytesPerPixel(surface_format); |
| 494 | QByteArray data(reinterpret_cast<const char*>(buffer), size); | 493 | const QByteArray data(reinterpret_cast<const char*>(buffer), size); |
| 495 | file.write(data); | 494 | file.write(data); |
| 496 | } else { | 495 | } else { |
| 497 | UNREACHABLE_MSG("Unhandled filter selected"); | 496 | UNREACHABLE_MSG("Unhandled filter selected"); |