caps_ss.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/logging/log.h"
  4. #include "core/hle/service/caps/caps_manager.h"
  5. #include "core/hle/service/caps/caps_ss.h"
  6. #include "core/hle/service/cmif_serialization.h"
  7. #include "core/hle/service/ipc_helpers.h"
  8. namespace Service::Capture {
  9. IScreenShotService::IScreenShotService(Core::System& system_,
  10. std::shared_ptr<AlbumManager> album_manager)
  11. : ServiceFramework{system_, "caps:ss"}, manager{album_manager} {
  12. // clang-format off
  13. static const FunctionInfo functions[] = {
  14. {201, nullptr, "SaveScreenShot"},
  15. {202, nullptr, "SaveEditedScreenShot"},
  16. {203, C<&IScreenShotService::SaveScreenShotEx0>, "SaveScreenShotEx0"},
  17. {204, nullptr, "SaveEditedScreenShotEx0"},
  18. {206, C<&IScreenShotService::SaveEditedScreenShotEx1>, "SaveEditedScreenShotEx1"},
  19. {208, nullptr, "SaveScreenShotOfMovieEx1"},
  20. {1000, nullptr, "Unknown1000"},
  21. };
  22. // clang-format on
  23. RegisterHandlers(functions);
  24. }
  25. IScreenShotService::~IScreenShotService() = default;
  26. Result IScreenShotService::SaveScreenShotEx0(
  27. Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
  28. AlbumReportOption report_option, ClientAppletResourceUserId aruid,
  29. InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
  30. image_data_buffer) {
  31. LOG_INFO(Service_Capture,
  32. "called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
  33. report_option, image_data_buffer.size(), aruid.pid);
  34. manager->FlipVerticallyOnWrite(false);
  35. R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, image_data_buffer,
  36. aruid.pid));
  37. }
  38. Result IScreenShotService::SaveEditedScreenShotEx1(
  39. Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute, u64 width,
  40. u64 height, u64 thumbnail_width, u64 thumbnail_height, const AlbumFileId& file_id,
  41. const InLargeData<std::array<u8, 0x400>, BufferAttr_HipcMapAlias> application_data_buffer,
  42. const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
  43. image_data_buffer,
  44. const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
  45. thumbnail_image_data_buffer) {
  46. LOG_INFO(Service_Capture,
  47. "called, width={}, height={}, thumbnail_width={}, thumbnail_height={}, "
  48. "application_id={:016x}, storage={}, type={}, "
  49. "image_data_buffer_size={}, thumbnail_image_buffer_size={}",
  50. width, height, thumbnail_width, thumbnail_height, file_id.application_id,
  51. file_id.storage, file_id.type, image_data_buffer.size(),
  52. thumbnail_image_data_buffer.size());
  53. manager->FlipVerticallyOnWrite(false);
  54. R_RETURN(manager->SaveEditedScreenShot(*out_entry, attribute, file_id, image_data_buffer));
  55. }
  56. } // namespace Service::Capture