mirror of
https://github.com/wiiu-env/NotificationModule.git
synced 2024-11-23 20:09:15 +01:00
Save Notifications in a queue until the overlay has been initialized
This commit is contained in:
parent
d9da174f4b
commit
1bf259db4b
@ -8,6 +8,8 @@
|
|||||||
void ExportCleanUp() {
|
void ExportCleanUp() {
|
||||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||||
gNotificationList.clear();
|
gNotificationList.clear();
|
||||||
|
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||||
|
gOverlayQueueDuringStartup.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationModuleStatus NMAddStaticNotification(const char *text,
|
NotificationModuleStatus NMAddStaticNotification(const char *text,
|
||||||
@ -18,9 +20,6 @@ NotificationModuleStatus NMAddStaticNotification(const char *text,
|
|||||||
NMColor backgroundColor,
|
NMColor backgroundColor,
|
||||||
void (*finishFunc)(NotificationModuleHandle, void *context),
|
void (*finishFunc)(NotificationModuleHandle, void *context),
|
||||||
void *context) {
|
void *context) {
|
||||||
if (!gOverlayFrame) {
|
|
||||||
return NOTIFICATION_MODULE_RESULT_OVERLAY_NOT_READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationStatus status;
|
NotificationStatus status;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -46,7 +45,14 @@ NotificationModuleStatus NMAddStaticNotification(const char *text,
|
|||||||
return NOTIFICATION_MODULE_RESULT_ALLOCATION_FAILED;
|
return NOTIFICATION_MODULE_RESULT_ALLOCATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
gOverlayFrame->addNotification(notification);
|
{
|
||||||
|
std::lock_guard lock(gOverlayFrameMutex);
|
||||||
|
if (gOverlayFrame) {
|
||||||
|
gOverlayFrame->addNotification(std::move(notification));
|
||||||
|
} else {
|
||||||
|
gOverlayQueueDuringStartup.push_back(std::move(notification));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -70,9 +76,6 @@ NotificationModuleStatus NMAddDynamicNotification(const char *text,
|
|||||||
return NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT;
|
return NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
*outHandle = 0;
|
*outHandle = 0;
|
||||||
if (!gOverlayFrame) {
|
|
||||||
return NOTIFICATION_MODULE_RESULT_OVERLAY_NOT_READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto notification = make_shared_nothrow<Notification>(
|
auto notification = make_shared_nothrow<Notification>(
|
||||||
text,
|
text,
|
||||||
@ -91,8 +94,15 @@ NotificationModuleStatus NMAddDynamicNotification(const char *text,
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||||
*outHandle = notification->getHandle();
|
*outHandle = notification->getHandle();
|
||||||
|
{
|
||||||
|
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||||
|
if (gOverlayFrame) {
|
||||||
gOverlayFrame->addNotification(notification);
|
gOverlayFrame->addNotification(notification);
|
||||||
gNotificationList.push_front(notification);
|
} else {
|
||||||
|
gOverlayQueueDuringStartup.push_back(notification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gNotificationList.push_front(std::move(notification));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
||||||
|
@ -110,12 +110,19 @@ bool drawScreenshotSavedTexture(const GX2ColorBuffer *colorBuffer, GX2ScanTarget
|
|||||||
DECL_FUNCTION(void, GX2Init, uint32_t attributes) {
|
DECL_FUNCTION(void, GX2Init, uint32_t attributes) {
|
||||||
real_GX2Init(attributes);
|
real_GX2Init(attributes);
|
||||||
if (!gOverlayInitDone) {
|
if (!gOverlayInitDone) {
|
||||||
|
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("Init Overlay");
|
DEBUG_FUNCTION_LINE_VERBOSE("Init Overlay");
|
||||||
gOverlayFrame = new (std::nothrow) OverlayFrame(1280.0f, 720.0f);
|
gOverlayFrame = new (std::nothrow) OverlayFrame(1280.0f, 720.0f);
|
||||||
if (!gOverlayFrame) {
|
if (!gOverlayFrame) {
|
||||||
OSFatal("Failed to alloc gOverlayFrame");
|
OSFatal("Failed to alloc gOverlayFrame");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add notification that had been called before the overlay was ready
|
||||||
|
for (const auto ¬ification : gOverlayQueueDuringStartup) {
|
||||||
|
gOverlayFrame->addNotification(notification);
|
||||||
|
}
|
||||||
|
gOverlayQueueDuringStartup.clear();
|
||||||
|
|
||||||
// Allocate shader.
|
// Allocate shader.
|
||||||
ColorShader::instance();
|
ColorShader::instance();
|
||||||
Texture2DShader::instance();
|
Texture2DShader::instance();
|
||||||
|
@ -4,6 +4,8 @@ GX2SurfaceFormat gTVSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
|||||||
GX2SurfaceFormat gDRCSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
GX2SurfaceFormat gDRCSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||||
GX2ContextState *gContextState = nullptr;
|
GX2ContextState *gContextState = nullptr;
|
||||||
GX2ContextState *gOriginalContextState = nullptr;
|
GX2ContextState *gOriginalContextState = nullptr;
|
||||||
|
std::mutex gOverlayFrameMutex = {};
|
||||||
|
std::vector<std::shared_ptr<Notification>> gOverlayQueueDuringStartup = {};
|
||||||
OverlayFrame *gOverlayFrame = nullptr;
|
OverlayFrame *gOverlayFrame = nullptr;
|
||||||
SchriftGX2 *gFontSystem = nullptr;
|
SchriftGX2 *gFontSystem = nullptr;
|
||||||
bool gOverlayInitDone = false;
|
bool gOverlayInitDone = false;
|
||||||
|
@ -7,6 +7,8 @@ extern GX2SurfaceFormat gTVSurfaceFormat;
|
|||||||
extern GX2SurfaceFormat gDRCSurfaceFormat;
|
extern GX2SurfaceFormat gDRCSurfaceFormat;
|
||||||
extern GX2ContextState *gContextState;
|
extern GX2ContextState *gContextState;
|
||||||
extern GX2ContextState *gOriginalContextState;
|
extern GX2ContextState *gOriginalContextState;
|
||||||
|
extern std::mutex gOverlayFrameMutex;
|
||||||
|
extern std::vector<std::shared_ptr<Notification>> gOverlayQueueDuringStartup;
|
||||||
extern OverlayFrame *gOverlayFrame;
|
extern OverlayFrame *gOverlayFrame;
|
||||||
extern SchriftGX2 *gFontSystem;
|
extern SchriftGX2 *gFontSystem;
|
||||||
extern bool gOverlayInitDone;
|
extern bool gOverlayInitDone;
|
||||||
|
Loading…
Reference in New Issue
Block a user