From f563d76d75128c72ff7275fd8534b54b736dffc8 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Sat, 29 Feb 2020 12:33:55 +0800 Subject: [PATCH] Dev (#93) * feat: change selection-background-color * feat: mac need more width * feat: mac enable keymap * fix: mac full screen * fix: tool from move bug Close #78 * fix: fullscreen bug on ubuntu * feat: load keymap on ubuntu * chore: add linux build script * chore: add ubuntu build script * chore: fix build on ubuntu * fix: opengl set on application before * feat: set opengl version 2.0 * fix: build on ubuntu * chore: update workflows * feat: change covert yuv to rgb param Close #46 * docs: update todo --- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 5 +- .github/workflows/windows.yml | 2 +- QtScrcpy/device/render/qyuvopenglwidget.cpp | 10 ++- QtScrcpy/main.cpp | 70 +++++++++++++-------- QtScrcpy/util/config.cpp | 3 +- docs/TODO.md | 3 - 7 files changed, 57 insertions(+), 38 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index bfe81ec..27cf8ba 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -4,7 +4,7 @@ on: paths: - 'QtScrcpy/**' - '!QtScrcpy/res/**' - - '.github/workflows/**' + - '.github/workflows/macos.yml' pull_request: paths: - 'QtScrcpy/**' diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9058610..3215bb1 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -5,11 +5,12 @@ on: paths: - 'QtScrcpy/**' - '!QtScrcpy/res/**' - - '.github/workflows/**' + - '.github/workflows/ubuntu.yml' pull_request: paths: - 'QtScrcpy/**' - '!QtScrcpy/res/**' + - '.github/workflows/ubuntu.yml' jobs: build: name: Build @@ -47,5 +48,5 @@ jobs: fetch-depth: 1 - name: Build Ubuntu run: | - export ENV_QT_GCC=${{env.Qt5_Dir}} + export ENV_QT_GCC=$(pwd)/${{env.Qt5_Dir}} ci/linux/build_for_ubuntu.sh release diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 4d0b0e8..affbbd6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -5,7 +5,7 @@ on: paths: - 'QtScrcpy/**' - '!QtScrcpy/res/**' - - '.github/workflows/**' + - '.github/workflows/windows.yml' # pull_request时触发workflow pull_request: paths: diff --git a/QtScrcpy/device/render/qyuvopenglwidget.cpp b/QtScrcpy/device/render/qyuvopenglwidget.cpp index c8fdf70..232c523 100644 --- a/QtScrcpy/device/render/qyuvopenglwidget.cpp +++ b/QtScrcpy/device/render/qyuvopenglwidget.cpp @@ -50,14 +50,18 @@ static QString s_fragShader = R"( { vec3 yuv; vec3 rgb; + // SDL2-2.0.10\src\render\opengl\SDL_shaders_gl.c BT709_SHADER_CONSTANTS + const vec3 Rcoeff = vec3(1.1644, 0.000, 1.7927); + const vec3 Gcoeff = vec3(1.1644, -0.2132, -0.5329); + const vec3 Bcoeff = vec3(1.1644, 2.1124, 0.000); // 根据指定的纹理textureY和坐标textureOut来采样 yuv.x = texture2D(textureY, textureOut).r; yuv.y = texture2D(textureU, textureOut).r - 0.5; yuv.z = texture2D(textureV, textureOut).r - 0.5; // 采样完转为rgb - rgb = mat3(1.0, 1.0, 1.0, - 0.0, -0.39465, 2.03211, - 1.13983, -0.58060, 0.0) * yuv; + rgb.r = dot(yuv, Rcoeff); + rgb.g = dot(yuv, Gcoeff); + rgb.b = dot(yuv, Bcoeff); // 输出颜色值 gl_FragColor = vec4(rgb, 1.0); } diff --git a/QtScrcpy/main.cpp b/QtScrcpy/main.cpp index b80156b..db8b2ba 100644 --- a/QtScrcpy/main.cpp +++ b/QtScrcpy/main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "dialog.h" #include "stream.h" @@ -18,8 +19,50 @@ void installTranslator(); int main(int argc, char *argv[]) { + // set env +#ifdef Q_OS_WIN32 + qputenv("QTSCRCPY_ADB_PATH", "../../../../third_party/adb/win/adb.exe"); + qputenv("QTSCRCPY_SERVER_PATH", "../../../../third_party/scrcpy-server"); + qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../keymap"); + qputenv("QTSCRCPY_CONFIG_PATH", "../../../../config"); +#endif + +#ifdef Q_OS_OSX + qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../../../keymap"); +#endif + +#ifdef Q_OS_LINUX + qputenv("QTSCRCPY_ADB_PATH", "../../../third_party/adb/linux/adb"); + qputenv("QTSCRCPY_SERVER_PATH", "../../../third_party/scrcpy-server"); + qputenv("QTSCRCPY_CONFIG_PATH", "../../../config"); + qputenv("QTSCRCPY_KEYMAP_PATH", "../../../keymap"); +#endif + + // set on QApplication before + int opengl = Config::getInstance().getDesktopOpenGL(); + if (0 == opengl) { + QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL); + } else if (1 == opengl){ + QApplication::setAttribute(Qt::AA_UseOpenGLES); + } else if (2 == opengl) { + QApplication::setAttribute(Qt::AA_UseDesktopOpenGL); + } + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QSurfaceFormat varFormat = QSurfaceFormat::defaultFormat(); + varFormat.setVersion(2, 0); + varFormat.setProfile(QSurfaceFormat::NoProfile); + /* + varFormat.setSamples(4); + varFormat.setAlphaBufferSize(8); + varFormat.setBlueBufferSize(8); + varFormat.setRedBufferSize(8); + varFormat.setGreenBufferSize(8); + varFormat.setDepthBufferSize(24); + */ + QSurfaceFormat::setDefaultFormat(varFormat); + g_oldMessageHandler = qInstallMessageHandler(myMessageOutput); Stream::init(); QApplication a(argc, argv); @@ -41,24 +84,6 @@ int main(int argc, char *argv[]) MouseTap::getInstance()->initMouseEventTap(); #endif -#ifdef Q_OS_WIN32 - qputenv("QTSCRCPY_ADB_PATH", "../../../../third_party/adb/win/adb.exe"); - qputenv("QTSCRCPY_SERVER_PATH", "../../../../third_party/scrcpy-server"); - qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../keymap"); - qputenv("QTSCRCPY_CONFIG_PATH", "../../../../config"); -#endif - -#ifdef Q_OS_OSX - qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../../../keymap"); -#endif - -#ifdef Q_OS_LINUX - qputenv("QTSCRCPY_ADB_PATH", "../../../third_party/adb/linux/adb"); - qputenv("QTSCRCPY_SERVER_PATH", "../../../third_party/scrcpy-server"); - qputenv("QTSCRCPY_CONFIG_PATH", "../../../config"); - qputenv("QTSCRCPY_KEYMAP_PATH", "../../../keymap"); -#endif - //加载样式表 QFile file(":/qss/psblack.css"); if (file.open(QFile::ReadOnly)) { @@ -69,15 +94,6 @@ int main(int argc, char *argv[]) file.close(); } - int opengl = Config::getInstance().getDesktopOpenGL(); - if (0 == opengl) { - QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL); - } else if (1 == opengl){ - QApplication::setAttribute(Qt::AA_UseOpenGLES); - } else if (2 == opengl) { - QApplication::setAttribute(Qt::AA_UseDesktopOpenGL); - } - g_mainDlg = new Dialog; g_mainDlg->setWindowTitle(Config::getInstance().getTitle()); g_mainDlg->show(); diff --git a/QtScrcpy/util/config.cpp b/QtScrcpy/util/config.cpp index 9050461..6fb2e52 100644 --- a/QtScrcpy/util/config.cpp +++ b/QtScrcpy/util/config.cpp @@ -69,7 +69,8 @@ const QString& Config::getConfigPath() s_configPath = QString::fromLocal8Bit(qgetenv("QTSCRCPY_CONFIG_PATH")); QFileInfo fileInfo(s_configPath); if (s_configPath.isEmpty() || !fileInfo.isDir()) { - s_configPath = QCoreApplication::applicationDirPath() + "/config"; + // default application dir + s_configPath = "config"; } } return s_configPath; diff --git a/docs/TODO.md b/docs/TODO.md index 471fc47..e3bf217 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -7,14 +7,11 @@ - text转换 https://github.com/Genymobile/scrcpy/commit/c916af0984f72a60301d13fa8ef9a85112f54202?tdsourcetag=s_pctim_aiomsg ## 中优先级 -- mac自动打包脚本 - 脚本 - 群控 - 竖屏全屏不拉伸画面 - 软解 - opengles 3.0 -- github action -- 打包版本截图无效? ## 高优先级 - linux打包以及版本号