From 5fa7bb50863050736ae878c6c25d72d1cafa20e8 Mon Sep 17 00:00:00 2001
From: Pluto <lizhiyuan@uniartisan.com>
Date: Fri, 8 Jul 2022 09:44:17 +0000
Subject: [PATCH] =?UTF-8?q?!2=20GPU=20=E9=BB=98=E8=AE=A4=E5=BC=80=E5=90=AF?=
 =?UTF-8?q?=20*=20update:=20translations=20*=20reademe:=20update=20GPU=20i?=
 =?UTF-8?q?nfo=20*=20feature:=20=E9=BB=98=E8=AE=A4=E5=BC=80=E5=90=AFGPU?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 README.md                                     |   1 +
 spark-webapp-runtime/globaldefine.h           |   3 ++-
 spark-webapp-runtime/help/help.html           |   2 ++
 spark-webapp-runtime/main.cpp                 |  20 ++++++++++++++++++
 .../spark-webapp-runtime_zh_CN.qm             | Bin 3064 -> 3188 bytes
 .../spark-webapp-runtime_zh_CN.ts             |  17 +++++++++------
 6 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index ebae08c..a67a8ac 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,7 @@ spark-webapp-runtime 应用标题 目标网址 应用窗口宽度 应用窗口
                   -c, --cfg <cfg>        设置应用的配置文件。
                   -r, --root <root>      设置内置 WebServer 的根路径。
                   -P, --port <port>      设置内置 WebServer 的监听端口号。
+                  -G, --GPU <0/1>        设置启用 GPU 渲染加速,默认开启。
             
 
 需要注意的是, 命令行会覆盖配置文件信息。
diff --git a/spark-webapp-runtime/globaldefine.h b/spark-webapp-runtime/globaldefine.h
index 95b0468..276638f 100644
--- a/spark-webapp-runtime/globaldefine.h
+++ b/spark-webapp-runtime/globaldefine.h
@@ -16,7 +16,8 @@
 
 #define DEFAULT_ROOT QString()
 #define DEFAULT_PORT 0
+#define DEFAULT_GPU 1
 
-#define CURRENT_VER QString("1.6.3")
+#define CURRENT_VER QString("1.6.4")
 
 #endif // GLOBALDEFINE_H
diff --git a/spark-webapp-runtime/help/help.html b/spark-webapp-runtime/help/help.html
index 81730ec..3bfc628 100644
--- a/spark-webapp-runtime/help/help.html
+++ b/spark-webapp-runtime/help/help.html
@@ -37,6 +37,7 @@
                   -c, --cfg <cfg>        设置应用的配置文件。
                   -r, --root <root>      设置内置 WebServer 的根路径。
                   -P, --port <port>      设置内置 WebServer 的监听端口号。
+                  -G, --GPU <0/1>        设置启用 GPU 渲染加速,默认开启。
             </xmp>
             <br/>
             <span style="color: red">需要注意的是, 命令行会覆盖配置文件信息。</span>
@@ -74,6 +75,7 @@
                   -c, --cfg <cfg>        The Configuration file of Application.
                   -r, --root <root>      The root path of the program web service.
                   -P, --port <port>      The port number of the program web service.
+                  -G, --GPU <0/1>        To use GPU instead of CPU to decoding. Default True.
             </xmp>
             <br/>
             <span style="color: red">It should be noticed that the command line parsers will overwrite the configuration from the config file.</span>
diff --git a/spark-webapp-runtime/main.cpp b/spark-webapp-runtime/main.cpp
index 1e6b51d..82c4428 100644
--- a/spark-webapp-runtime/main.cpp
+++ b/spark-webapp-runtime/main.cpp
@@ -177,6 +177,14 @@ int main(int argc, char *argv[])
                                DEFAULT_PORT);
     parser.addOption(optPort);
 
+
+    QCommandLineOption useGPU(QStringList() << "G"
+                                            << "GPU",
+                               QObject::tr("To use GPU instead of CPU to decoding. Default True."),
+                               "GPU",
+                               QString::number(DEFAULT_GPU));
+    parser.addOption(useGPU);
+
 #if SSL_SERVER
     QCommandLineOption optSSLPort(QStringList() << "s"
                                                 << "sslport",
@@ -200,6 +208,7 @@ int main(int argc, char *argv[])
     QString szDesc = DEFAULT_DESC;
     QString szRootPath = DEFAULT_ROOT;
     quint16 u16Port = DEFAULT_PORT;
+    bool toUseGPU = DEFAULT_GPU;
 #if SSL_SERVER
     quint16 u16sslPort = 0;
 #endif
@@ -270,6 +279,17 @@ int main(int argc, char *argv[])
         u16Port = parser.value(optPort).toUInt();
     }
 
+    if (parser.isSet(useGPU)) {
+        toUseGPU = parser.value(useGPU).toUInt();
+    }
+    if (toUseGPU == true){
+        qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--ignore-gpu-blacklist --enable-gpu-rasterization --enable-native-gpu-memory-buffers --enable-accelerated-video-decode");
+        #ifdef __sw_64__
+            qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--ignore-gpu-blacklist --enable-gpu-rasterization --enable-native-gpu-memory-buffers --enable-accelerated-video-decode --no-sandbox");
+        #endif
+        qDebug() << "Setting GPU to True.";
+    }
+
 #if SSL_SERVER
     if (parser.isSet(optSSLPort)) {
         u16sslPort = parser.value(optSSLPort).toUInt();
diff --git a/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.qm b/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.qm
index e8b5034608cb90fb941b1343b4a8d1c0702229a0..b87ba60ec40b8eb72da2c5ae022eb8dca932f144 100644
GIT binary patch
delta 157
zcmew%{zXFGW=D#|srPfHo>i3DpRjQ6-Q^4n46Icd@y>ou3=E706Gc5Zm|c3_F)(oT
zOpKk*_-*1>ZzgVq%}$IHxFV!N^h-4u+!+EGLi3E$FaPJ6ccXhrJVS`S0TTz%7zQ>V
zHVMgBC@oG^a1RJo$jmD)Nli>q$WK#n269XC6;e`@^HVbO()AQvQqvMkb4nCKib_)_
IAK<nC0FYHPsQ>@~

delta 50
zcmV-20L}mO82A?zJh)^S%I}<&%^@7WV4=O;LI3~(D3KpXk#Cm)jFSfeO9BeEvs3|)
I3X@I@CLW9u(*OVf

diff --git a/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.ts b/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.ts
index 58840cc..8849e49 100644
--- a/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.ts
+++ b/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.ts
@@ -165,32 +165,37 @@
         <translation>隐藏控制按钮。默认关闭该此功能。</translation>
     </message>
     <message>
-        <location filename="../main.cpp" line="139"/>
+        <location filename="../main.cpp" line="147"/>
         <source>The ICON of Application.</source>
         <translation>设置应用的图标。</translation>
     </message>
     <message>
-        <location filename="../main.cpp" line="146"/>
+        <location filename="../main.cpp" line="154"/>
         <source>The Description of Application.</source>
         <translation>设置应用的描述信息。</translation>
     </message>
     <message>
-        <location filename="../main.cpp" line="153"/>
+        <location filename="../main.cpp" line="161"/>
         <source>The Configuration file of Application.</source>
         <translation>设置应用的配置文件。</translation>
     </message>
     <message>
-        <location filename="../main.cpp" line="160"/>
+        <location filename="../main.cpp" line="168"/>
         <source>The root path of the program web service.</source>
         <translation>设置内置 WebServer 的根路径。</translation>
     </message>
     <message>
-        <location filename="../main.cpp" line="167"/>
+        <location filename="../main.cpp" line="175"/>
         <source>The port number of the program web service.</source>
         <translation>设置内置 WebServer 的监听端口号。</translation>
     </message>
     <message>
-        <location filename="../main.cpp" line="175"/>
+        <location filename="../main.cpp" line="183"/>
+        <source>To use GPU instead of CPU to decoding. Default True.</source>
+        <translation>启用GPU渲染,默认开启。</translation>
+    </message>
+    <message>
+        <location filename="../main.cpp" line="191"/>
         <source>The ssl port number of the program web service.</source>
         <translation>设置内置 WebServer 的 SSL 协议的监听端口号。</translation>
     </message>