citra-emu
/
citra-canary
Archived
1
0
Fork 0

Merge pull request #1761 from Subv/applets_fb

HLE/Applets: Use the correct size for the framebuffer SharedMemory
This commit is contained in:
bunnei 2016-05-07 17:21:48 -04:00
commit 8e9b33a34a
5 changed files with 44 additions and 23 deletions

View File

@ -21,13 +21,6 @@
namespace HLE { namespace HLE {
namespace Applets { namespace Applets {
MiiSelector::MiiSelector(Service::APT::AppletId id) : Applet(id), started(false) {
// Create the SharedMemory that will hold the framebuffer data
// TODO(Subv): What size should we use here?
using Kernel::MemoryPermission;
framebuffer_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite, "MiiSelector Memory");
}
ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& parameter) { ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) { if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) {
LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal); LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
@ -36,8 +29,18 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
return ResultCode(-1); return ResultCode(-1);
} }
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
// Create the SharedMemory that will hold the framebuffer data
Service::APT::CaptureBufferInfo capture_info;
ASSERT(sizeof(capture_info) == parameter.buffer_size);
memcpy(&capture_info, parameter.data, sizeof(capture_info));
using Kernel::MemoryPermission;
framebuffer_memory = Kernel::SharedMemory::Create(capture_info.size, MemoryPermission::ReadWrite,
MemoryPermission::ReadWrite, "MiiSelector Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result; Service::APT::MessageParameter result;
// The buffer passed in parameter contains the data returned by GSPGPU::ImportDisplayCaptureInfo
result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished); result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
result.data = nullptr; result.data = nullptr;
result.buffer_size = 0; result.buffer_size = 0;

View File

@ -62,15 +62,15 @@ ASSERT_REG_POSITION(unk_6C, 0x6C);
class MiiSelector final : public Applet { class MiiSelector final : public Applet {
public: public:
MiiSelector(Service::APT::AppletId id); MiiSelector(Service::APT::AppletId id) : Applet(id), started(false) { }
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
void Update() override; void Update() override;
bool IsRunning() const override { return started; } bool IsRunning() const override { return started; }
/// TODO(Subv): Find out what this is actually used for. /// This SharedMemory will be created when we receive the LibAppJustStarted message.
/// It is believed that the application stores the current screen image here. /// It holds the framebuffer info retrieved by the application with GSPGPU::ImportDisplayCaptureInfo
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory; Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
/// Whether this applet is currently running instead of the host application or not. /// Whether this applet is currently running instead of the host application or not.

View File

@ -24,13 +24,6 @@
namespace HLE { namespace HLE {
namespace Applets { namespace Applets {
SoftwareKeyboard::SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) {
// Create the SharedMemory that will hold the framebuffer data
// TODO(Subv): What size should we use here?
using Kernel::MemoryPermission;
framebuffer_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, MemoryPermission::ReadWrite, "SoftwareKeyboard Memory");
}
ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter const& parameter) { ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter const& parameter) {
if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) { if (parameter.signal != static_cast<u32>(Service::APT::SignalType::LibAppJustStarted)) {
LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal); LOG_ERROR(Service_APT, "unsupported signal %u", parameter.signal);
@ -39,8 +32,19 @@ ResultCode SoftwareKeyboard::ReceiveParameter(Service::APT::MessageParameter con
return ResultCode(-1); return ResultCode(-1);
} }
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared memory.
// Create the SharedMemory that will hold the framebuffer data
Service::APT::CaptureBufferInfo capture_info;
ASSERT(sizeof(capture_info) == parameter.buffer_size);
memcpy(&capture_info, parameter.data, sizeof(capture_info));
using Kernel::MemoryPermission;
framebuffer_memory = Kernel::SharedMemory::Create(capture_info.size, MemoryPermission::ReadWrite,
MemoryPermission::ReadWrite, "SoftwareKeyboard Memory");
// Send the response message with the newly created SharedMemory
Service::APT::MessageParameter result; Service::APT::MessageParameter result;
// The buffer passed in parameter contains the data returned by GSPGPU::ImportDisplayCaptureInfo
result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished); result.signal = static_cast<u32>(Service::APT::SignalType::LibAppFinished);
result.data = nullptr; result.data = nullptr;
result.buffer_size = 0; result.buffer_size = 0;

View File

@ -53,8 +53,7 @@ static_assert(sizeof(SoftwareKeyboardConfig) == 0x400, "Software Keyboard Config
class SoftwareKeyboard final : public Applet { class SoftwareKeyboard final : public Applet {
public: public:
SoftwareKeyboard(Service::APT::AppletId id); SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) { }
~SoftwareKeyboard() {}
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override; ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter) override;
ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override; ResultCode StartImpl(const Service::APT::AppletStartupParameter& parameter) override;
@ -72,8 +71,8 @@ public:
*/ */
void Finalize(); void Finalize();
/// TODO(Subv): Find out what this is actually used for. /// This SharedMemory will be created when we receive the LibAppJustStarted message.
/// It is believed that the application stores the current screen image here. /// It holds the framebuffer info retrieved by the application with GSPGPU::ImportDisplayCaptureInfo
Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory; Kernel::SharedPtr<Kernel::SharedMemory> framebuffer_memory;
/// SharedMemory where the output text will be stored /// SharedMemory where the output text will be stored

View File

@ -5,6 +5,7 @@
#pragma once #pragma once
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
@ -31,6 +32,20 @@ struct AppletStartupParameter {
u8* data = nullptr; u8* data = nullptr;
}; };
/// Used by the application to pass information about the current framebuffer to applets.
struct CaptureBufferInfo {
u32_le size;
u8 is_3d;
INSERT_PADDING_BYTES(0x3); // Padding for alignment
u32_le top_screen_left_offset;
u32_le top_screen_right_offset;
u32_le top_screen_format;
u32_le bottom_screen_left_offset;
u32_le bottom_screen_right_offset;
u32_le bottom_screen_format;
};
static_assert(sizeof(CaptureBufferInfo) == 0x20, "CaptureBufferInfo struct has incorrect size");
/// Signals used by APT functions /// Signals used by APT functions
enum class SignalType : u32 { enum class SignalType : u32 {
None = 0x0, None = 0x0,