From 4d450b528f2092629f4f6f4a8b8c016b1cc42119 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 10 Mar 2020 20:44:30 -0700 Subject: [PATCH 1/3] UI: Minor cleanups to chat UI code. Just want to avoid crashes and warnings. --- UI/ChatScreen.cpp | 41 ++++++++++++++++++++++------------------- UI/ChatScreen.h | 21 ++++++++++++++------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index e3b5229e27..ba15f03a94 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -14,7 +14,6 @@ #include #include "util/text/utf8.h" - void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; auto n = GetI18NCategory("Networking"); @@ -34,6 +33,7 @@ void ChatMenu::CreatePopupContents(UI::ViewGroup *parent) { } #endif chatEdit_->OnEnter.Handle(this, &ChatMenu::OnSubmit); + #elif PPSSPP_PLATFORM(ANDROID) bottom->Add(new Button(n->T("Chat Here"),new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->OnClick.Handle(this, &ChatMenu::OnSubmit); bottom->Add(new Button(n->T("Send")))->OnClick.Handle(this, &ChatMenu::OnSubmit); @@ -84,26 +84,31 @@ void ChatMenu::CreateViews() { case 5: box_ = new LinearLayout(ORIENT_VERTICAL, new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, NONE, 240, 280, NONE, true)); break; + default: + box_ = nullptr; + break; } - root_->Add(box_); - box_->SetBG(UI::Drawable(0x99303030)); - box_->SetHasDropShadow(false); + if (box_) { + root_->Add(box_); + box_->SetBG(UI::Drawable(0x99303030)); + box_->SetHasDropShadow(false); - View *title = new PopupHeader(n->T("Chat")); - box_->Add(title); + View *title = new PopupHeader(n->T("Chat")); + box_->Add(title); - CreatePopupContents(box_); + CreatePopupContents(box_); #if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) - UI::EnableFocusMovement(true); - root_->SetDefaultFocusView(box_); - box_->SubviewFocused(chatEdit_); - root_->SetFocus(); + UI::EnableFocusMovement(true); + root_->SetDefaultFocusView(box_); + box_->SubviewFocused(chatEdit_); + root_->SetFocus(); #else - //root_->SetDefaultFocusView(box_); - //box_->SubviewFocused(scroll_); - //root_->SetFocus(); + //root_->SetDefaultFocusView(box_); + //box_->SubviewFocused(scroll_); + //root_->SetFocus(); #endif + } chatScreenVisible = true; newChat = 0; @@ -129,7 +134,6 @@ UI::EventReturn ChatMenu::OnSubmit(UI::EventParams &e) { return UI::EVENT_DONE; } - UI::EventReturn ChatMenu::OnQuickChat1(UI::EventParams &e) { sendChat(g_Config.sQuickChat0); return UI::EVENT_DONE; @@ -191,7 +195,7 @@ std::vector Split(const std::string& str) void ChatMenu::UpdateChat() { using namespace UI; - if (chatVert_ != NULL) { + if (chatVert_ != nullptr) { chatVert_->Clear(); //read Access violation is proadhoc.cpp use NULL_->Clear() pointer? std::vector chatLog = getChatLog(); for (auto i : chatLog) { @@ -208,11 +212,10 @@ void ChatMenu::UpdateChat() { namecolor = 0xE53935; } - if (i[displayname.length()] != ':') { + if (i.length() <= displayname.length() || i[displayname.length()] != ':') { TextView *v = chatVert_->Add(new TextView(i, FLAG_DYNAMIC_ASCII, true)); v->SetTextColor(0xFF000000 | infocolor); - } - else { + } else { LinearLayout *line = chatVert_->Add(new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, FILL_PARENT))); TextView *nameView = line->Add(new TextView(displayname, FLAG_DYNAMIC_ASCII, true)); nameView->SetTextColor(0xFF000000 | namecolor); diff --git a/UI/ChatScreen.h b/UI/ChatScreen.h index ecb6d1546e..4470a27acd 100644 --- a/UI/ChatScreen.h +++ b/UI/ChatScreen.h @@ -1,10 +1,12 @@ #pragma once + +#include "ppsspp_config.h" #include "file/file_util.h" #include "ui/ui_screen.h" class ChatMenu : public PopupScreen { public: - ChatMenu() : PopupScreen("Chat") , toBottom_(true) {} + ChatMenu(): PopupScreen("Chat") {} ~ChatMenu(); void CreatePopupContents(UI::ViewGroup *parent) override; void CreateViews() override; @@ -12,7 +14,9 @@ public: bool touch(const TouchInput &touch) override; void update() override; void UpdateChat(); - bool toBottom_; + + bool toBottom_ = true; + private: UI::EventReturn OnSubmit(UI::EventParams &e); UI::EventReturn OnQuickChat1(UI::EventParams &e); @@ -20,8 +24,11 @@ private: UI::EventReturn OnQuickChat3(UI::EventParams &e); UI::EventReturn OnQuickChat4(UI::EventParams &e); UI::EventReturn OnQuickChat5(UI::EventParams &e); - UI::TextEdit *chatEdit_; - UI::ScrollView *scroll_; - UI::LinearLayout *chatVert_; - UI::ViewGroup *box_; -}; \ No newline at end of file + +#if PPSSPP_PLATFORM(WINDOWS) || defined(USING_QT_UI) + UI::TextEdit *chatEdit_ = nullptr; +#endif + UI::ScrollView *scroll_ = nullptr; + UI::LinearLayout *chatVert_ = nullptr; + UI::ViewGroup *box_ = nullptr; +}; From 51b94a9c9ca1a30a167cbc2b713c21a599e35a8d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 10 Mar 2020 21:00:30 -0700 Subject: [PATCH 2/3] Core: Quiet some warnings. --- CMakeLists.txt | 1 + Core/HLE/sceIo.cpp | 2 +- android/jni/app-android.cpp | 34 ++++++++++++++--------------- ext/native/base/display.cpp | 2 -- ext/native/json/json_reader.cpp | 1 + ext/native/thin3d/GLQueueRunner.cpp | 4 ++++ 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f91a430bc..e169448af3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,6 +272,7 @@ if(NOT MSVC) # Disable some warnings add_definitions(-Wno-multichar) add_definitions(-Wno-deprecated-register) + add_definitions(-Wno-tautological-pointer-compare) # Don't compile with strict aliasing, we're not 100% aliasing-safe add_compile_options(-fno-strict-aliasing) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index a27b35e6d1..55e214958c 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -2731,7 +2731,7 @@ static int IoAsyncFinish(int id) { break; default: - ERROR_LOG_REPORT(SCEIO, "Unknown async op %d", params.op); + ERROR_LOG_REPORT(SCEIO, "Unknown async op %d", (int)params.op); us = 0; break; } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 277fd0776d..be07052534 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1043,32 +1043,32 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J return false; } -retry: + auto tryInit = [&]() { + if (graphicsContext->InitFromRenderThread(wnd, desiredBackbufferSizeX, desiredBackbufferSizeY, backbuffer_format, androidVersion)) { + return true; + } - bool vulkan = g_Config.iGPUBackend == (int)GPUBackend::VULKAN; - - int tries = 0; - - if (!graphicsContext->InitFromRenderThread(wnd, desiredBackbufferSizeX, desiredBackbufferSizeY, backbuffer_format, androidVersion)) { ELOG("Failed to initialize graphics context."); + return false; + }; - if (!exitRenderLoop && (vulkan && tries < 2)) { + bool initSuccess = tryInit(); + if (!initSuccess) { + if (!exitRenderLoop && g_Config.iGPUBackend == (int)GPUBackend::VULKAN) { ILOG("Trying again, this time with OpenGL."); - g_Config.iGPUBackend = (int)GPUBackend::OPENGL; - SetGPUBackend((GPUBackend)g_Config.iGPUBackend); - // If we were still supporting EGL for GL: - // tries++; - // goto retry; + SetGPUBackend(GPUBackend::OPENGL); + g_Config.iGPUBackend = (int)GetGPUBackend(); + + // If we were still supporting EGL for GL, we'd retry here: + //initSuccess = tryInit(); + } + + if (!initSuccess) { delete graphicsContext; graphicsContext = nullptr; renderLoopRunning = false; return false; } - - delete graphicsContext; - graphicsContext = nullptr; - renderLoopRunning = false; - return false; } if (!exitRenderLoop) { diff --git a/ext/native/base/display.cpp b/ext/native/base/display.cpp index c673639551..28a482aa06 100644 --- a/ext/native/base/display.cpp +++ b/ext/native/base/display.cpp @@ -30,7 +30,6 @@ void RotateRectToDisplayImpl(DisplayRect &rect, T curRTWidth, T curRTHeight) // Note that curRTWidth_ and curRTHeight_ are "swapped"! T origX = rect.x; T origY = rect.y; - T rtw = curRTHeight; T rth = curRTWidth; rect.x = clamp_value(rth - rect.h - origY, T{}, curRTHeight); rect.y = origX; @@ -43,7 +42,6 @@ void RotateRectToDisplayImpl(DisplayRect &rect, T curRTWidth, T curRTHeight) T origX = rect.x; T origY = rect.y; T rtw = curRTHeight; - T rth = curRTWidth; rect.x = origY; rect.y = clamp_value(rtw - rect.w - origX, T{}, curRTWidth); T temp = rect.w; diff --git a/ext/native/json/json_reader.cpp b/ext/native/json/json_reader.cpp index eaf9d0ae08..1663a915ef 100644 --- a/ext/native/json/json_reader.cpp +++ b/ext/native/json/json_reader.cpp @@ -24,6 +24,7 @@ int JsonGet::numChildren() const { int count = 0; if (value_.getTag() == JSON_OBJECT || value_.getTag() == JSON_ARRAY) { for (auto it : value_) { + (void)it; count++; } } diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index e42101798b..2ea228fcd3 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -569,9 +569,13 @@ void GLQueueRunner::RunSteps(const std::vector &steps, bool skipGLCal } } break; + default: + break; } } break; + default: + break; } delete steps[i]; } From f214b7d4227bc8ee19d807ecaaab406860041d08 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 10 Mar 2020 22:48:10 -0700 Subject: [PATCH 3/3] Camera: Simplify an expression. Make this readable by breaking it up. Like one would sentences. --- Core/HW/Camera.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/HW/Camera.cpp b/Core/HW/Camera.cpp index 3c233d8931..d8490d9d5e 100644 --- a/Core/HW/Camera.cpp +++ b/Core/HW/Camera.cpp @@ -338,10 +338,10 @@ int __v4l_startCapture(int ideal_width, int ideal_height) { frmsize.index++; if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) { INFO_LOG(HLE, "V4L2: frame size supported: %dx%d", frmsize.discrete.width, frmsize.discrete.height); - if (frmsize.discrete.width >= ideal_width && frmsize.discrete.height >= ideal_height - && fmt.fmt.pix.width == 0 && fmt.fmt.pix.height == 0 - || frmsize.discrete.width >= ideal_width && frmsize.discrete.height >= ideal_height - && frmsize.discrete.width < fmt.fmt.pix.width && frmsize.discrete.height < fmt.fmt.pix.height) { + bool matchesIdeal = frmsize.discrete.width >= ideal_width && frmsize.discrete.height >= ideal_height; + bool zeroPix = fmt.fmt.pix.width == 0 && fmt.fmt.pix.height == 0; + bool pixLarger = frmsize.discrete.width < fmt.fmt.pix.width && frmsize.discrete.height < fmt.fmt.pix.height; + if (matchesIdeal && (zeroPix || pixLarger)) { fmt.fmt.pix.width = frmsize.discrete.width; fmt.fmt.pix.height = frmsize.discrete.height; }