From b94dbca160d7a7d0308d4e8d4ff7613f9e6238b1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 15 Nov 2014 00:11:09 -0500 Subject: [PATCH] Host: Kill off GetRenderWindowSize --- .../dolphinemu/dolphinemu/NativeLibrary.java | 8 --- .../emulation/EmulationActivity.java | 67 +++---------------- Source/Core/Core/Host.h | 1 - Source/Core/DolphinQt/Host.cpp | 8 --- Source/Core/DolphinQt/MainWindow.cpp | 17 ----- Source/Core/DolphinQt/MainWindow.h | 1 - Source/Core/DolphinWX/Frame.cpp | 17 ----- Source/Core/DolphinWX/Frame.h | 1 - Source/Core/DolphinWX/Main.cpp | 5 -- Source/Core/DolphinWX/MainAndroid.cpp | 15 +---- Source/Core/DolphinWX/MainNoGUI.cpp | 8 --- .../OGL/GLInterface/EGLAndroid.cpp | 4 +- Source/UnitTests/TestUtils/StubHost.cpp | 1 - 13 files changed, 12 insertions(+), 141 deletions(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java index 769595c1b4..f3317c9e8c 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -110,14 +110,6 @@ public final class NativeLibrary */ public static native void SetFilename(String filename); - /** - * Sets the dimensions of the rendering window. - * - * @param width The new width of the rendering window (in pixels). - * @param height The new height of the rendering window (in pixels). - */ - public static native void SetDimensions(int width, int height); - /** * Gets the embedded banner within the given ISO/ROM. * diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java index fb96bec559..41c523ed68 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java @@ -15,19 +15,22 @@ import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.preference.PreferenceManager; -import android.util.DisplayMetrics; -import android.view.*; +import android.view.InputDevice; +import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.Window; import android.view.WindowManager.LayoutParams; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.settings.input.InputConfigFragment; -import org.dolphinemu.dolphinemu.utils.EGLHelper; import java.util.List; -import javax.microedition.khronos.opengles.GL10; - /** * This is the activity where all of the emulation handling happens. * This activity is responsible for displaying the SurfaceView that we render to. @@ -36,8 +39,6 @@ public final class EmulationActivity extends Activity { private boolean Running; private boolean IsActionBarHidden = false; - private float screenWidth; - private float screenHeight; private SharedPreferences sharedPrefs; @Override @@ -45,10 +46,7 @@ public final class EmulationActivity extends Activity { super.onCreate(savedInstanceState); - // Retrieve screen dimensions. - DisplayMetrics dm = getResources().getDisplayMetrics(); - this.screenHeight = dm.heightPixels; - this.screenWidth = dm.widthPixels; + sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); // Request window features for the emulation view. getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -60,18 +58,6 @@ public final class EmulationActivity extends Activity actionBarBackground.setAlpha(175); getActionBar().setBackgroundDrawable(actionBarBackground); - // Set the native rendering screen width/height. - // - // Due to a bug in Adreno, it renders the screen rotated 90 degrees when using OpenGL - // Flip the width and height when on Adreno to work around this. - // This bug is fixed in Qualcomm driver v53 - // Mali isn't affected by this bug. - sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); - if (hasBuggedDriverDimensions()) - NativeLibrary.SetDimensions((int)screenHeight, (int)screenWidth); - else - NativeLibrary.SetDimensions((int)screenWidth, (int)screenHeight); - // Get the intent passed from the GameList when the game // was selected. This is so the path of the game can be retrieved // and set on the native side of the code so the emulator can actually @@ -327,39 +313,4 @@ public final class EmulationActivity extends Activity return true; } - - // For handling bugged driver dimensions (applies mainly to Qualcomm devices) - private boolean hasBuggedDriverDimensions() - { - final EGLHelper eglHelper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT); - final String vendor = eglHelper.getGL().glGetString(GL10.GL_VENDOR); - final String version = eglHelper.getGL().glGetString(GL10.GL_VERSION); - final String renderer = eglHelper.getGL().glGetString(GL10.GL_RENDERER); - - if (sharedPrefs.getString("gpuPref", "Software Rendering").equals("OGL") - && eglHelper.supportsGLES3() - && vendor.equals("Qualcomm") - && renderer.equals("Adreno (TM) 3")) - { - final int start = version.indexOf("V@") + 2; - final StringBuilder versionBuilder = new StringBuilder(); - - for (int i = start; i < version.length(); i++) - { - char c = version.charAt(i); - - // End of numeric portion of version string. - if (c == ' ') - break; - - versionBuilder.append(c); - } - - if (Float.parseFloat(versionBuilder.toString()) < 53.0f) - return true; - } - - - return false; - } } diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index 3d232aca8a..3bb2ec76b1 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -26,7 +26,6 @@ bool Host_UIHasFocus(); bool Host_RendererHasFocus(); void Host_ConnectWiimote(int wm_idx, bool connect); -void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height); void Host_Message(int Id); void Host_NotifyMapLoaded(); void Host_RefreshDSPDebuggerWindow(); diff --git a/Source/Core/DolphinQt/Host.cpp b/Source/Core/DolphinQt/Host.cpp index c26df6ea62..1969dad4fd 100644 --- a/Source/Core/DolphinQt/Host.cpp +++ b/Source/Core/DolphinQt/Host.cpp @@ -32,14 +32,6 @@ void* Host_GetRenderHandle() return (void*)(g_main_window->GetRenderWidget()->winId()); } -void Host_GetRenderWindowSize(int& x, int& y, int& w, int& h) -{ - // TODO: Make it more clear what this is supposed to return.. i.e. WX always sets x=y=0 - g_main_window->RenderWidgetSize(x, y, w, h); - x = 0; - y = 0; -} - void Host_RequestRenderWindowSize(int w, int h) { DRenderWidget* render_widget = g_main_window->GetRenderWidget(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 8ad50c2ffa..7fcdfd09b7 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -221,23 +221,6 @@ void DMainWindow::OnCoreStateChanged(Core::EState state) m_ui->actionOpen->setEnabled(is_not_initialized); } -// DRenderWidget -void DMainWindow::RenderWidgetSize(int& x_pos, int& y_pos, int& w, int& h) -{ - if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) - { - x_pos = x(); - y_pos = y(); - } - else - { - x_pos = m_render_widget->x(); - y_pos = m_render_widget->y(); - } - w = m_render_widget->width(); - h = m_render_widget->height(); -} - bool DMainWindow::RenderWidgetHasFocus() { if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index 73817c2f5c..86cc37a0ca 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -26,7 +26,6 @@ public: ~DMainWindow(); // DRenderWidget - void RenderWidgetSize(int& x_pos, int& y_pos, int& w, int& h); bool RenderWidgetHasFocus(); DRenderWidget* GetRenderWidget() { return m_render_widget.get(); } diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index e2e0651cab..104c726ada 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -748,23 +748,6 @@ void CFrame::OnHostMessage(wxCommandEvent& event) } } -void CFrame::GetRenderWindowSize(int& x, int& y, int& width, int& height) -{ -#ifdef __WXGTK__ - if (!wxIsMainThread()) - wxMutexGuiEnter(); -#endif - wxRect client_rect = m_RenderParent->GetClientRect(); - width = client_rect.width; - height = client_rect.height; - x = client_rect.x; - y = client_rect.y; -#ifdef __WXGTK__ - if (!wxIsMainThread()) - wxMutexGuiLeave(); -#endif -} - void CFrame::OnRenderWindowSizeRequest(int width, int height) { if (!Core::IsRunning() || diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index e54acf8dc6..91486f53cc 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -113,7 +113,6 @@ public: void PostEvent(wxCommandEvent& event); void StatusBarMessage(const char * Text, ...); void ClearStatusBar(); - void GetRenderWindowSize(int& x, int& y, int& width, int& height); void OnRenderWindowSizeRequest(int width, int height); void BootGame(const std::string& filename); void OnRenderParentClose(wxCloseEvent& event); diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 8daf811913..28be496fc2 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -506,11 +506,6 @@ void Host_UpdateTitle(const std::string& title) main_frame->GetEventHandler()->AddPendingEvent(event); } -void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) -{ - main_frame->GetRenderWindowSize(x, y, width, height); -} - void Host_RequestRenderWindowSize(int width, int height) { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_WINDOWSIZEREQUEST); diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index 2189fae5db..273b0c4664 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -48,7 +48,6 @@ #include "VideoCommon/VideoBackendBase.h" ANativeWindow* surf; -int g_width, g_height; std::string g_filename; #define DOLPHIN_TAG "Dolphinemu" @@ -77,14 +76,6 @@ void Host_UpdateMainFrame() { } -void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) -{ - x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos; - y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos; - width = g_width; - height = g_height; -} - void Host_RequestRenderWindowSize(int width, int height) {} void Host_RequestFullscreen(bool enable_fullscreen) {} @@ -311,11 +302,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename( { g_filename = GetJString(env, jFile); } -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetDimensions(JNIEnv *env, jobject obj, jint _width, jint _height) -{ - g_width = (int)_width; - g_height = (int)_height; -} JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv *env, jobject obj, jint slot) { @@ -348,6 +334,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_CreateUserFo JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf) { surf = ANativeWindow_fromSurface(env, _surf); + // Install our callbacks OSD::AddCallback(OSD::OSD_INIT, ButtonManager::Init); OSD::AddCallback(OSD::OSD_SHUTDOWN, ButtonManager::Shutdown); diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index 5049351bba..0b8f4b1099 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -72,14 +72,6 @@ void Host_UpdateMainFrame() updateMainFrameEvent.Set(); } -void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) -{ - x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos; - y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos; - width = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth; - height = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight; -} - void Host_RequestRenderWindowSize(int width, int height) {} void Host_RequestFullscreen(bool enable_fullscreen) {} diff --git a/Source/Core/VideoBackends/OGL/GLInterface/EGLAndroid.cpp b/Source/Core/VideoBackends/OGL/GLInterface/EGLAndroid.cpp index f6c567ee6c..922bf965db 100644 --- a/Source/Core/VideoBackends/OGL/GLInterface/EGLAndroid.cpp +++ b/Source/Core/VideoBackends/OGL/GLInterface/EGLAndroid.cpp @@ -16,8 +16,8 @@ EGLNativeWindowType cInterfaceEGLAndroid::InitializePlatform(EGLNativeWindowType eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &format); ANativeWindow_setBuffersGeometry(host_window, 0, 0, format); - int none, width, height; - Host_GetRenderWindowSize(none, none, width, height); + const int width = ANativeWindow_getWidth(host_window); + const int height = ANativeWindow_getHeight(host_window); GLInterface->SetBackBufferDimensions(width, height); return host_window; diff --git a/Source/UnitTests/TestUtils/StubHost.cpp b/Source/UnitTests/TestUtils/StubHost.cpp index a8f6f1cf2f..2e8839ea67 100644 --- a/Source/UnitTests/TestUtils/StubHost.cpp +++ b/Source/UnitTests/TestUtils/StubHost.cpp @@ -17,7 +17,6 @@ void* Host_GetRenderHandle() { return nullptr; } void Host_UpdateTitle(const std::string&) {} void Host_UpdateDisasmDialog() {} void Host_UpdateMainFrame() {} -void Host_GetRenderWindowSize(int&, int&, int&, int&) {} void Host_RequestRenderWindowSize(int, int) {} void Host_RequestFullscreen(bool) {} void Host_SetStartupDebuggingParameters() {}