From e1ed1151c2a4e73f54701820ba1d056c588bf04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=97=AD?= Date: Mon, 27 Nov 2023 14:55:31 +0800 Subject: [PATCH 1/7] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .all-contributorsrc | 2 +- CONTRIBUTING.md | 68 +++++++------- CONTRIBUTING_EN.md | 94 ------------------- CONTRIBUTING_ZH.md | 94 +++++++++++++++++++ README.md | 4 +- README_ZH.md | 4 +- docs/Built-in effects.md | 2 +- ...10\346\236\234\344\273\213\347\273\215.md" | 2 +- 8 files changed, 135 insertions(+), 135 deletions(-) delete mode 100644 CONTRIBUTING_EN.md create mode 100644 CONTRIBUTING_ZH.md diff --git a/.all-contributorsrc b/.all-contributorsrc index b684dae02..e14280bab 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -8,7 +8,7 @@ "contributors": [ { "login": "Blinue", - "name": "刘旭", + "name": "Xu", "avatar_url": "https://avatars.githubusercontent.com/u/34770031?v=4", "profile": "https://github.com/Blinue", "contributions": [ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 81ab34931..ee6a45443 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,47 +1,47 @@ -# 贡献指南 +# Contribution Guide -**首先,感谢你将宝贵的时间花费在本项目上!** +**First of all, thank you for spending your valuable time on this project!** -Magpie 是一个个人项目,最早启发于 IntegerScaler 和 Lossless Scaling,但现在它比前辈们强大的多。开发者的能力和精力有限,因此欢迎任何形式的贡献!Magpie 遵循 [All Contributors](https://github.com/all-contributors/all-contributors) 规范,无论你以何种形式做出贡献,诸如编写代码、撰写文档、用户测试等,只要你的贡献足够,开发者都会把你加入贡献者清单。 +Magpie is a personal project, initially inspired by IntegerScaler and Lossless Scaling. However, the project has become much more powerful than its predecessors. Due to the limited capability and energy of the developers, we welcome any form of contribution to this project! Magpie follows the [All Contributors](https://github.com/all-contributors/all-contributors) protocol. No matter in what form you contributed to the project (e.g. code, document, test, etc.), the developer will add you to the contributors list as long as you contributed enough. -如果你是新手,强烈推荐你读一下[这篇文章](https://opensourceway.community/open-source-guide/how-to-contribute/)。 +If you are new here, we strongly recommend you to read [this article](https://opensourceway.community/open-source-guide/how-to-contribute/) (it's in Chinese). -下面是一些你可能想做的贡献: +Below are some types of contributions you might want to make: -### 我有一个问题 🙏 +### I have a question 🙏 -[FAQ](https://github.com/Blinue/Magpie/wiki/FAQ) 汇总了常见的问题,你也可以搜索 [Issue](https://github.com/Blinue/Magpie/issues) 和 [Discussion](https://github.com/Blinue/Magpie/discussions) 看是否已经有人提出过。如果依然没有得到解答,请在 Discussion 中询问。 +[FAQ](https://github.com/Blinue/Magpie/wiki/FAQ_EN) includes most of the common questions asked. You can also search in [Issue](https://github.com/Blinue/Magpie/issues) and [Discussion](https://github.com/Blinue/Magpie/discussions) to see if anyone has raised the same question before. Feel free to go ahead and ask in Discussion if not. -### 我遇到了一个错误 🐞 +### I encountered an error 🐞 -Magpie 没有广泛的测试过,因此错误不可避免。希望你能向开发者反馈这个错误,这样可以帮助所有和你遇到同样问题的人。 +Magpie hasn't been thoroughly tested, so errors are inevitable. We hope you can let us know about the errors, which helps everyone having the same problems. -首先请在 Issue 和 Discussion 中搜索你遇到的错误,避免和现有 Issue 重复。汇报错误时请发布一个 [Issue(bug report)](https://github.com/Blinue/Magpie/issues/new?assignees=&labels=bug&template=01_bug.yaml),下面是一些有利于开发者快速定位问题的最佳实践: +Please start by searching the errors in Issues and Discussions to avoid duplicate questions. Please publish a [Issue (bug report)](https://github.com/Blinue/Magpie/issues/new?assignees=&labels=bug&template=01_bug.yaml). Here are some best practices to help the developers to quickly locate the error: -1. 选择一个清晰简洁的标题。如 “Windows 11窗口圆角导致游戏窗口超分后左下/右下角模糊” 是一个好标题,而 “应用程序错误” 则意义不明。 -2. 上传日志文件对定位问题特别有帮助,它们位于 logs 文件夹下。**请以附件的形式上传日志,而不是将其中的内容复制到正文中。** -3. 请详细的描述复现步骤,最好提供一些截图。 -4. 还有一些信息可能对开发者有帮助,比如特殊的显示器配置,显卡型号等。 +1. Choose a clear and simple subject. For example, "The rounded corner of windows in Windows 11 causes the top-left and bottom-right corners to be blurry" is an excellent subject. "Application Error," on the other hand, is hard to interpret. +2. It is especially helpful to upload the log files, which are stored in the logs folder. **Please upload the logs as attachments rather than copying their content.** +3. Please specify in details how to replicate the errors. It would be ideal if you also provide us with some screenshots. +4. Additional information may be helpful for the developers. e.g. special display configurations, graphics card models, etc. -### 我有一个功能建议 🚀 +### I have a feature request 🚀 -你可能有一些关于 Magpie 的奇思妙想,请和开发者分享它们!开发者通常只是通过自己的使用经验添加新功能,但你的点子可能会使 Magpie 与众不同。 +Please share any "whimsy" you have with the developers! We merely added the features based on our experience. Your ideas, however, may make a difference! -首先请在 Issue 中搜索你的功能建议,确保不和已有的重复,尤其要查看 [Projects](https://github.com/Blinue/Magpie/projects) 里是否有这个功能。然后提交一个 [Issue (feature request)](https://github.com/Blinue/Magpie/issues/new?assignees=&labels=enhancement&template=03_request.yaml) 详细地描述你的建议,比如是否有其他软件实现了类似的功能。 +Please search in [Issue](https://github.com/Blinue/Magpie/issues) first for your feature requests to make sure they're not duplicate. Please also check [Projects](https://github.com/Blinue/Magpie/projects) (in Chinese) to see if the features have already been implemented. Please submit a [Issue (feature request)](https://github.com/Blinue/Magpie/issues/new?assignees=&labels=enhancement&template=03_request.yaml) with detailed descriptions of your suggestion, for example, if other applications have implemented similar features. -**如果你想建议一个新的效果,请明确说明它的名称,适用场景以及已有的着色器实现(如果有的话),另外强烈建议你附上和现有效果的对比图。** +**If you'd like a new special effect to be added, please specify its name, use cases, and existing shader implementation (if exists). We also strongly recommend you to attach a comparison image with the current special effects.** -### 我想贡献代码 💻 +### I'd like to contribute code 💻 -贡献代码是帮助 Magpie 项目最直接的方式,你可以修复 bug,增加新功能或修正格式错误。不要因为修改太小就羞于贡献,你的每一行修改都很重要。 +Contributing code is the more direct way to help Magpie. You may fix bugs, add new features, or correct formatting issues. You are not limited by the magnitude of the contribution. Every line is important! -和所有开源项目一样,你需要提交 pull request 来向 Magpie 贡献代码。开发者可能会要求你做一些更改,如果你无法及时响应,你的 pull request 可能会被关闭。你应将提交合并到 dev 分支。 +Like all other open source projects, you need to initiate pull requests to contribute codes for Magpie. The developers may ask you to make some modifications. Your pull request may be closed if you fail to respond in a timely manner. You should merge your commits into the dev branch. -**注意:一旦你向 Magpie 贡献代码,便表示你同意将该代码的版权转让给 Magpie 当前的版权所有者。** 这是为了使开发者做出重大决定(如更换许可证)时无需征得每一个贡献者的同意。开发者承诺 Magpie 项目更换许可证的唯一情形是迁移到更新版本的 GPL 协议。如果你想保留版权,只能放弃贡献,将更改保留在自己的 Fork 中。 +**Note: once you contribute code to Magpie, you are agreeing to transfer the copyright of that code to the current copyright owner of Magpie.** This allows developers to make important decisions (like changing the license) without getting consent from every single contributor. The developers promise that the only changes in license will be shifting to newer versions of GPL. If you'd like to keep your copyrights, you will have to quit contributing and to apply the changes only to your forks. -贡献代码时你需要遵守一些准则: +You need to follow the following rules when contributing code: -1. 和现有的代码风格保持一致,包括花括号不换行,tab 缩进,变量、类、源文件等的命名方式,所有源码文件格式均为 UTF-8 without BOM,倾向于使用行注释,git 消息风格等等。格式化 XAML 文件时请安装 [XamlStyler](https://github.com/Xavalon/XamlStyler) 插件。下面是一个代码风格的示例: +1. Keep in the same style as that of the current code, including no change-of-line for curly brackets, using tabs for indentation, the ways to name variables, classes, and source files, using UTF-8 without BOM encoding, preferring single-line comments, and using git-style messages, etc. Please install [XamlStyler](https://github.com/Xavalon/XamlStyler) for formatting XAML files. Here is an example: ``` c++ // ClassName.h @@ -67,7 +67,7 @@ Magpie 没有广泛的测试过,因此错误不可避免。希望你能向开 try { _m1 = std::stoi("123"); } catch (std::exception& e) { - // 错误处理 + // Error Handling } int sum = 0; @@ -76,19 +76,19 @@ Magpie 没有广泛的测试过,因此错误不可避免。希望你能向开 } } ``` -2. 如果你要进行比较大的更改请先查看 [Projects](https://github.com/Blinue/Magpie/projects) 或提交 pull request 和开发者交流,确保和项目当前的方向一致。 -3. 你的分支必须可以通过编译检查。 +2. Check [Projects](https://github.com/Blinue/Magpie/projects) or submit pull requests to communicate with the developers before you make major changes to make sure they align with the road map of the project. +3. Your branch must compile. -### 我想贡献翻译 🌍 +### I'd like to contribute translations 🌍 -我们使用 Weblate 进行本地化工作。如果你想帮助将 Magpie 翻译成更多语言,请前往 https://hosted.weblate.org/projects/magpie 。 +We are using Weblate for localization work. If you'd like to help translate Magpie into more languages, please visit https://hosted.weblate.org/projects/magpie. -### 我想贡献文档 📖 +### I'd like to contribute to the documentations 📖 -因为开发者的懒惰,Magpie 的文档长期处于缺失/过时的状态,因此文档的贡献是非常欢迎的。Magpie 的 wiki 是从 main 分支的 docs 文件夹自动发布的,因此修改文档和[贡献代码](#我想贡献代码-)的方式相同。 +Because of the laziness of the developers, the documentation of Magpie is constantly missing or out of date. Contributions to documentation are more than welcome! The MagPie wiki is automatically published from the docs folder in the `main` branch, so editing the documentation follows the same procedures of contributing code. -如果你想改进已发布功能的文档,请合并到 main 分支,否则请合并到 dev 分支。每次发布版本时,dev 分支的更改都将合并到 main 分支,wiki 也会相应的自动更新。 +Please merge to the `main` branch if you are improving the documentations of existing features. Otherwise merge to the `dev` branch. All changes in the `dev` branch will be merged to the `main` branch when new versions are released, this will also trigger the wiki will to be updated as well. -### 我想资助 Magpie 💰 +### I'd like to fund Magpie 💰 -请点击页面上方的 "Sponsor" 按钮,非常感谢你的支持。如果能从中获益,我便会将更多精力投入开源项目的开发和维护。 +The developers spend a lot of time every week to implement new features without getting paid. Currently there is no way to fund Magpie. Starring, forking, and advertising are the best ways to support us! diff --git a/CONTRIBUTING_EN.md b/CONTRIBUTING_EN.md deleted file mode 100644 index ee6a45443..000000000 --- a/CONTRIBUTING_EN.md +++ /dev/null @@ -1,94 +0,0 @@ -# Contribution Guide - -**First of all, thank you for spending your valuable time on this project!** - -Magpie is a personal project, initially inspired by IntegerScaler and Lossless Scaling. However, the project has become much more powerful than its predecessors. Due to the limited capability and energy of the developers, we welcome any form of contribution to this project! Magpie follows the [All Contributors](https://github.com/all-contributors/all-contributors) protocol. No matter in what form you contributed to the project (e.g. code, document, test, etc.), the developer will add you to the contributors list as long as you contributed enough. - -If you are new here, we strongly recommend you to read [this article](https://opensourceway.community/open-source-guide/how-to-contribute/) (it's in Chinese). - -Below are some types of contributions you might want to make: - -### I have a question 🙏 - -[FAQ](https://github.com/Blinue/Magpie/wiki/FAQ_EN) includes most of the common questions asked. You can also search in [Issue](https://github.com/Blinue/Magpie/issues) and [Discussion](https://github.com/Blinue/Magpie/discussions) to see if anyone has raised the same question before. Feel free to go ahead and ask in Discussion if not. - -### I encountered an error 🐞 - -Magpie hasn't been thoroughly tested, so errors are inevitable. We hope you can let us know about the errors, which helps everyone having the same problems. - -Please start by searching the errors in Issues and Discussions to avoid duplicate questions. Please publish a [Issue (bug report)](https://github.com/Blinue/Magpie/issues/new?assignees=&labels=bug&template=01_bug.yaml). Here are some best practices to help the developers to quickly locate the error: - -1. Choose a clear and simple subject. For example, "The rounded corner of windows in Windows 11 causes the top-left and bottom-right corners to be blurry" is an excellent subject. "Application Error," on the other hand, is hard to interpret. -2. It is especially helpful to upload the log files, which are stored in the logs folder. **Please upload the logs as attachments rather than copying their content.** -3. Please specify in details how to replicate the errors. It would be ideal if you also provide us with some screenshots. -4. Additional information may be helpful for the developers. e.g. special display configurations, graphics card models, etc. - -### I have a feature request 🚀 - -Please share any "whimsy" you have with the developers! We merely added the features based on our experience. Your ideas, however, may make a difference! - -Please search in [Issue](https://github.com/Blinue/Magpie/issues) first for your feature requests to make sure they're not duplicate. Please also check [Projects](https://github.com/Blinue/Magpie/projects) (in Chinese) to see if the features have already been implemented. Please submit a [Issue (feature request)](https://github.com/Blinue/Magpie/issues/new?assignees=&labels=enhancement&template=03_request.yaml) with detailed descriptions of your suggestion, for example, if other applications have implemented similar features. - -**If you'd like a new special effect to be added, please specify its name, use cases, and existing shader implementation (if exists). We also strongly recommend you to attach a comparison image with the current special effects.** - -### I'd like to contribute code 💻 - -Contributing code is the more direct way to help Magpie. You may fix bugs, add new features, or correct formatting issues. You are not limited by the magnitude of the contribution. Every line is important! - -Like all other open source projects, you need to initiate pull requests to contribute codes for Magpie. The developers may ask you to make some modifications. Your pull request may be closed if you fail to respond in a timely manner. You should merge your commits into the dev branch. - -**Note: once you contribute code to Magpie, you are agreeing to transfer the copyright of that code to the current copyright owner of Magpie.** This allows developers to make important decisions (like changing the license) without getting consent from every single contributor. The developers promise that the only changes in license will be shifting to newer versions of GPL. If you'd like to keep your copyrights, you will have to quit contributing and to apply the changes only to your forks. - -You need to follow the following rules when contributing code: - -1. Keep in the same style as that of the current code, including no change-of-line for curly brackets, using tabs for indentation, the ways to name variables, classes, and source files, using UTF-8 without BOM encoding, preferring single-line comments, and using git-style messages, etc. Please install [XamlStyler](https://github.com/Xavalon/XamlStyler) for formatting XAML files. Here is an example: - ``` c++ - // ClassName.h - - class ClassName { - public: - void Test1(); - - private: - void _PrivateTest1(); - - int _m1 = 0; - }; - - // ClassName.cpp - - void ClassName::Test1() { - if (_m1 <= 0) { - ++_m1; - } - } - - void ClassName::_PrivateTest1() { - try { - _m1 = std::stoi("123"); - } catch (std::exception& e) { - // Error Handling - } - - int sum = 0; - for (int i = 0; i < _m1; ++i) { - sum += i; - } - } - ``` -2. Check [Projects](https://github.com/Blinue/Magpie/projects) or submit pull requests to communicate with the developers before you make major changes to make sure they align with the road map of the project. -3. Your branch must compile. - -### I'd like to contribute translations 🌍 - -We are using Weblate for localization work. If you'd like to help translate Magpie into more languages, please visit https://hosted.weblate.org/projects/magpie. - -### I'd like to contribute to the documentations 📖 - -Because of the laziness of the developers, the documentation of Magpie is constantly missing or out of date. Contributions to documentation are more than welcome! The MagPie wiki is automatically published from the docs folder in the `main` branch, so editing the documentation follows the same procedures of contributing code. - -Please merge to the `main` branch if you are improving the documentations of existing features. Otherwise merge to the `dev` branch. All changes in the `dev` branch will be merged to the `main` branch when new versions are released, this will also trigger the wiki will to be updated as well. - -### I'd like to fund Magpie 💰 - -The developers spend a lot of time every week to implement new features without getting paid. Currently there is no way to fund Magpie. Starring, forking, and advertising are the best ways to support us! diff --git a/CONTRIBUTING_ZH.md b/CONTRIBUTING_ZH.md new file mode 100644 index 000000000..81ab34931 --- /dev/null +++ b/CONTRIBUTING_ZH.md @@ -0,0 +1,94 @@ +# 贡献指南 + +**首先,感谢你将宝贵的时间花费在本项目上!** + +Magpie 是一个个人项目,最早启发于 IntegerScaler 和 Lossless Scaling,但现在它比前辈们强大的多。开发者的能力和精力有限,因此欢迎任何形式的贡献!Magpie 遵循 [All Contributors](https://github.com/all-contributors/all-contributors) 规范,无论你以何种形式做出贡献,诸如编写代码、撰写文档、用户测试等,只要你的贡献足够,开发者都会把你加入贡献者清单。 + +如果你是新手,强烈推荐你读一下[这篇文章](https://opensourceway.community/open-source-guide/how-to-contribute/)。 + +下面是一些你可能想做的贡献: + +### 我有一个问题 🙏 + +[FAQ](https://github.com/Blinue/Magpie/wiki/FAQ) 汇总了常见的问题,你也可以搜索 [Issue](https://github.com/Blinue/Magpie/issues) 和 [Discussion](https://github.com/Blinue/Magpie/discussions) 看是否已经有人提出过。如果依然没有得到解答,请在 Discussion 中询问。 + +### 我遇到了一个错误 🐞 + +Magpie 没有广泛的测试过,因此错误不可避免。希望你能向开发者反馈这个错误,这样可以帮助所有和你遇到同样问题的人。 + +首先请在 Issue 和 Discussion 中搜索你遇到的错误,避免和现有 Issue 重复。汇报错误时请发布一个 [Issue(bug report)](https://github.com/Blinue/Magpie/issues/new?assignees=&labels=bug&template=01_bug.yaml),下面是一些有利于开发者快速定位问题的最佳实践: + +1. 选择一个清晰简洁的标题。如 “Windows 11窗口圆角导致游戏窗口超分后左下/右下角模糊” 是一个好标题,而 “应用程序错误” 则意义不明。 +2. 上传日志文件对定位问题特别有帮助,它们位于 logs 文件夹下。**请以附件的形式上传日志,而不是将其中的内容复制到正文中。** +3. 请详细的描述复现步骤,最好提供一些截图。 +4. 还有一些信息可能对开发者有帮助,比如特殊的显示器配置,显卡型号等。 + +### 我有一个功能建议 🚀 + +你可能有一些关于 Magpie 的奇思妙想,请和开发者分享它们!开发者通常只是通过自己的使用经验添加新功能,但你的点子可能会使 Magpie 与众不同。 + +首先请在 Issue 中搜索你的功能建议,确保不和已有的重复,尤其要查看 [Projects](https://github.com/Blinue/Magpie/projects) 里是否有这个功能。然后提交一个 [Issue (feature request)](https://github.com/Blinue/Magpie/issues/new?assignees=&labels=enhancement&template=03_request.yaml) 详细地描述你的建议,比如是否有其他软件实现了类似的功能。 + +**如果你想建议一个新的效果,请明确说明它的名称,适用场景以及已有的着色器实现(如果有的话),另外强烈建议你附上和现有效果的对比图。** + +### 我想贡献代码 💻 + +贡献代码是帮助 Magpie 项目最直接的方式,你可以修复 bug,增加新功能或修正格式错误。不要因为修改太小就羞于贡献,你的每一行修改都很重要。 + +和所有开源项目一样,你需要提交 pull request 来向 Magpie 贡献代码。开发者可能会要求你做一些更改,如果你无法及时响应,你的 pull request 可能会被关闭。你应将提交合并到 dev 分支。 + +**注意:一旦你向 Magpie 贡献代码,便表示你同意将该代码的版权转让给 Magpie 当前的版权所有者。** 这是为了使开发者做出重大决定(如更换许可证)时无需征得每一个贡献者的同意。开发者承诺 Magpie 项目更换许可证的唯一情形是迁移到更新版本的 GPL 协议。如果你想保留版权,只能放弃贡献,将更改保留在自己的 Fork 中。 + +贡献代码时你需要遵守一些准则: + +1. 和现有的代码风格保持一致,包括花括号不换行,tab 缩进,变量、类、源文件等的命名方式,所有源码文件格式均为 UTF-8 without BOM,倾向于使用行注释,git 消息风格等等。格式化 XAML 文件时请安装 [XamlStyler](https://github.com/Xavalon/XamlStyler) 插件。下面是一个代码风格的示例: + ``` c++ + // ClassName.h + + class ClassName { + public: + void Test1(); + + private: + void _PrivateTest1(); + + int _m1 = 0; + }; + + // ClassName.cpp + + void ClassName::Test1() { + if (_m1 <= 0) { + ++_m1; + } + } + + void ClassName::_PrivateTest1() { + try { + _m1 = std::stoi("123"); + } catch (std::exception& e) { + // 错误处理 + } + + int sum = 0; + for (int i = 0; i < _m1; ++i) { + sum += i; + } + } + ``` +2. 如果你要进行比较大的更改请先查看 [Projects](https://github.com/Blinue/Magpie/projects) 或提交 pull request 和开发者交流,确保和项目当前的方向一致。 +3. 你的分支必须可以通过编译检查。 + +### 我想贡献翻译 🌍 + +我们使用 Weblate 进行本地化工作。如果你想帮助将 Magpie 翻译成更多语言,请前往 https://hosted.weblate.org/projects/magpie 。 + +### 我想贡献文档 📖 + +因为开发者的懒惰,Magpie 的文档长期处于缺失/过时的状态,因此文档的贡献是非常欢迎的。Magpie 的 wiki 是从 main 分支的 docs 文件夹自动发布的,因此修改文档和[贡献代码](#我想贡献代码-)的方式相同。 + +如果你想改进已发布功能的文档,请合并到 main 分支,否则请合并到 dev 分支。每次发布版本时,dev 分支的更改都将合并到 main 分支,wiki 也会相应的自动更新。 + +### 我想资助 Magpie 💰 + +请点击页面上方的 "Sponsor" 按钮,非常感谢你的支持。如果能从中获益,我便会将更多精力投入开源项目的开发和维护。 diff --git a/README.md b/README.md index d6a00300d..76baef198 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ We are using [Weblate](https://weblate.org/) for localization work and would app :point_right: [Compilation guide](https://github.com/Blinue/Magpie/wiki/Compilation%20guide) -:point_right: [Contributing](./CONTRIBUTING_EN.md) +:point_right: [Contributing](./CONTRIBUTING.md) ## Features @@ -82,7 +82,7 @@ Thanks go to these wonderful people: - + diff --git a/README_ZH.md b/README_ZH.md index 2a42fe225..3fc1ae7a3 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -29,7 +29,7 @@ Magpie 是一个轻量级的窗口缩放工具,内置了多种高效的缩放 :point_right: [编译指南](https://github.com/Blinue/Magpie/wiki/编译指南) -:point_right: [贡献指南](./CONTRIBUTING.md) +:point_right: [贡献指南](./CONTRIBUTING_ZH.md) ## 功能 @@ -81,7 +81,7 @@ Magpie 是一个轻量级的窗口缩放工具,内置了多种高效的缩放
刘旭
刘旭

🚧 💻 👀 📖 💬
刘旭
Xu

🚧 💻 👀 📖 💬
hooke007
hooke007

📖 💬 📓 💻
Pal Lockheart
Pal Lockheart

📓
Steve Donaghy
Steve Donaghy

💻 🌍
- + diff --git a/docs/Built-in effects.md b/docs/Built-in effects.md index 66d2aa2bb..501957025 100644 --- a/docs/Built-in effects.md +++ b/docs/Built-in effects.md @@ -18,7 +18,7 @@ Magpie ships with a handful of effects that can be used in combinations. Most of * Parameter: * Strength: Denoise magnitude -* Anime4K_Restore_M, Anime4K_Restore_L, and Anime4K_Restore_VL: Algorithms to restore the lines in animations. In increasing order of demand for computing power. +* Anime4K_Restore_S, Anime4K_Restore_M, Anime4K_Restore_L, Anime4K_Restore_VL, Anime4K_Restore_UL, Anime4K_Restore_Soft_S, Anime4K_Restore_Soft_M, Anime4K_Restore_Soft_L, Anime4K_Restore_Soft_VL, Anime4K_Restore_Soft_UL: Algorithms to restore the lines in animations. In increasing order of demand for computing power. The Soft variants are more conservative in sharpening. * Output size: the same as the input * Anime4K_Thin_HQ: Algorithm to clarify lines in animations provided by Anime4K. diff --git "a/docs/\345\206\205\347\275\256\346\225\210\346\236\234\344\273\213\347\273\215.md" "b/docs/\345\206\205\347\275\256\346\225\210\346\236\234\344\273\213\347\273\215.md" index 72c3bf21b..7724a5a19 100644 --- "a/docs/\345\206\205\347\275\256\346\225\210\346\236\234\344\273\213\347\273\215.md" +++ "b/docs/\345\206\205\347\275\256\346\225\210\346\236\234\344\273\213\347\273\215.md" @@ -18,7 +18,7 @@ Magpie 内置了大量效果供组合使用,大部分提供了参数选项以 * 参数 * Strength:降噪强度 -* Anime4K_Restore_M、Anime4K_Restore_L、Anime4K_Restore_VL、Anime4K_Restore_Soft_M 和 Anime4K_Restore_Soft_L、:Anime4K 提供的用于还原动漫画面线条的算法,M->L->VL 对性能的需求依次提高,Soft 变体效果稍弱 +* Anime4K_Restore_S、Anime4K_Restore_M、Anime4K_Restore_L、Anime4K_Restore_VL、Anime4K_Restore_UL、Anime4K_Restore_Soft_S、Anime4K_Restore_Soft_M、Anime4K_Restore_Soft_L、Anime4K_Restore_Soft_VL 和 Anime4K_Restore_Soft_UL:Anime4K 提供的用于还原动漫画面线条的算法,S->M->L->VL->UL 对性能的需求依次提高,Soft 变体效果稍弱 * 输出尺寸:和输入相同 * Anime4K_Thin_HQ:Anime4K 提供的用于细化动漫画面线条的算法 From e76d6beb1d462b9518c77152ab552f7b3c7083fd Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Mon, 27 Nov 2023 18:02:34 +0800 Subject: [PATCH 2/7] =?UTF-8?q?chore:=20=E5=BE=AE=E5=B0=8F=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Directory.Build.props | 12 ++++++------ Magpie.sln | 6 +++--- src/Common.Post.props | 2 +- src/Magpie.App/UpdateService.cpp | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6f73dc610..d15d60edc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,12 +15,12 @@ Level44251 - - - - - - + + + + + + %(AdditionalOptions) /await:strict /utf-8 /Zc:__cplusplus /volatile:iso /fp:contract diff --git a/Magpie.sln b/Magpie.sln index 816f238ce..c311fc39e 100644 --- a/Magpie.sln +++ b/Magpie.sln @@ -20,12 +20,12 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{00AB63C3-0CD3-4944-B8E6-58C86138618D}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - Directory.Build.props = Directory.Build.props - src\Common.Pre.props = src\Common.Pre.props src\Common.Post.props = src\Common.Post.props + src\Common.Pre.props = src\Common.Pre.props + Directory.Build.props = Directory.Build.props src\extract_winui_runtime.py = src\extract_winui_runtime.py src\fix_resfiles.py = src\fix_resfiles.py - HybridCRT.props = HybridCRT.props + src\HybridCRT.props = src\HybridCRT.props src\WinUI.props = src\WinUI.props EndProjectSection EndProject diff --git a/src/Common.Post.props b/src/Common.Post.props index 7a9ed7b6d..085fc6495 100644 --- a/src/Common.Post.props +++ b/src/Common.Post.props @@ -50,7 +50,7 @@ truetrue - + NDEBUG;WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions) diff --git a/src/Magpie.App/UpdateService.cpp b/src/Magpie.App/UpdateService.cpp index a19c26182..03eec63e1 100644 --- a/src/Magpie.App/UpdateService.cpp +++ b/src/Magpie.App/UpdateService.cpp @@ -313,7 +313,8 @@ fire_and_forget UpdateService::DownloadAndInstall() { CoreDispatcher dispatcher = CoreWindow::GetForCurrentThread().Dispatcher(); co_await resume_background(); - std::wstring updatePkg = CommonSharedConstants::UPDATE_DIR + L"\\update.zip"s; + std::wstring updatePkg = CommonSharedConstants::UPDATE_DIR + L"update.zip"s; + // kuba-zip 内部使用 UTF-8 编码 int ec = zip_extract( StrUtils::UTF16ToUTF8(updatePkg).c_str(), StrUtils::UTF16ToUTF8(CommonSharedConstants::UPDATE_DIR).c_str(), From fa8e5ba6b6ead604d3a697e2400e9dfa20e2194e Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Mon, 27 Nov 2023 18:31:59 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=E5=A6=82=E6=9E=9C=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E4=B8=AD=E5=BF=83=E7=82=B9=E4=B8=8D=E5=9C=A8=E4=BB=BB?= =?UTF-8?q?=E4=BD=95=E5=B1=8F=E5=B9=95=E4=B8=8A=EF=BC=8C=E5=88=99=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E6=9C=80=E8=BF=91=E7=9A=84=E5=B1=8F=E5=B9=95=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E5=9C=A8=E9=BB=98=E8=AE=A4=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=20=E8=BF=99=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=8F=AF?= =?UTF-8?q?=E9=A2=84=E6=B5=8B=E6=80=A7=EF=BC=8C=E5=92=8C=20UWP=20=E7=9A=84?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Magpie/MainWindow.cpp | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Magpie/MainWindow.cpp b/src/Magpie/MainWindow.cpp index 344168d1a..329487b1e 100644 --- a/src/Magpie/MainWindow.cpp +++ b/src/Magpie/MainWindow.cpp @@ -229,39 +229,39 @@ std::pair MainWindow::_CreateWindow(HINSTANCE hInstance, winrt::Poi // windowSizeInDips 小于零表示默认位置和尺寸 if (windowSizeInDips.Width > 0) { // 检查窗口中心点的 DPI,根据我的测试,创建窗口时 Windows 使用窗口中心点确定 DPI。 - // 如果窗口中心点不在任何屏幕上,则在默认位置启动,让调用者设置窗口尺寸。 + // 如果窗口中心点不在任何屏幕上,则查找最近的屏幕。如果窗口尺寸太大无法被屏幕容纳, + // 则还原为默认位置和尺寸。 const HMONITOR hMon = MonitorFromPoint( { std::lroundf(windowCenter.X),std::lroundf(windowCenter.Y) }, - MONITOR_DEFAULTTONULL + MONITOR_DEFAULTTONEAREST ); - if (hMon) { - UINT dpi = USER_DEFAULT_SCREEN_DPI; - GetDpiForMonitor(hMon, MDT_EFFECTIVE_DPI, &dpi, &dpi); - - const float dpiFactor = dpi / float(USER_DEFAULT_SCREEN_DPI); - const winrt::Size windowSizeInPixels = { - windowSizeInDips.Width * dpiFactor, - windowSizeInDips.Height * dpiFactor - }; - windowSize.cx = std::lroundf(windowSizeInPixels.Width); - windowSize.cy = std::lroundf(windowSizeInPixels.Height); + UINT dpi = USER_DEFAULT_SCREEN_DPI; + GetDpiForMonitor(hMon, MDT_EFFECTIVE_DPI, &dpi, &dpi); - MONITORINFO mi{ sizeof(mi) }; - GetMonitorInfo(hMon, &mi); + const float dpiFactor = dpi / float(USER_DEFAULT_SCREEN_DPI); + const winrt::Size windowSizeInPixels = { + windowSizeInDips.Width * dpiFactor, + windowSizeInDips.Height * dpiFactor + }; - // 确保启动位置在屏幕工作区内。不允许启动时跨越多个屏幕。 - if (windowSize.cx <= mi.rcWork.right - mi.rcWork.left && windowSize.cy <= mi.rcWork.bottom - mi.rcWork.top) { - windowPos.x = std::lroundf(windowCenter.X - windowSizeInPixels.Width / 2); - windowPos.x = std::clamp(windowPos.x, mi.rcWork.left, mi.rcWork.right - windowSize.cx); + windowSize.cx = std::lroundf(windowSizeInPixels.Width); + windowSize.cy = std::lroundf(windowSizeInPixels.Height); - windowPos.y = std::lroundf(windowCenter.Y - windowSizeInPixels.Height / 2); - windowPos.y = std::clamp(windowPos.y, mi.rcWork.top, mi.rcWork.bottom - windowSize.cy); - } else { - // 屏幕工作区无法容纳窗口则使用默认窗口尺寸 - windowSize = {}; - windowSizeInDips.Width = -1.0f; - } + MONITORINFO mi{ sizeof(mi) }; + GetMonitorInfo(hMon, &mi); + + // 确保启动位置在屏幕工作区内。不允许启动时跨越多个屏幕。 + if (windowSize.cx <= mi.rcWork.right - mi.rcWork.left && windowSize.cy <= mi.rcWork.bottom - mi.rcWork.top) { + windowPos.x = std::lroundf(windowCenter.X - windowSizeInPixels.Width / 2); + windowPos.x = std::clamp(windowPos.x, mi.rcWork.left, mi.rcWork.right - windowSize.cx); + + windowPos.y = std::lroundf(windowCenter.Y - windowSizeInPixels.Height / 2); + windowPos.y = std::clamp(windowPos.y, mi.rcWork.top, mi.rcWork.bottom - windowSize.cy); + } else { + // 屏幕工作区无法容纳窗口则使用默认窗口尺寸 + windowSize = {}; + windowSizeInDips.Width = -1.0f; } } From afa5ae632ec2da61651e10fbf569630377ff1d53 Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Mon, 27 Nov 2023 18:50:06 +0800 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20Updater=20=E9=80=82=E9=85=8D=20v0.1?= =?UTF-8?q?0.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Updater/PackageFiles.h | 95 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 5 deletions(-) diff --git a/src/Updater/PackageFiles.h b/src/Updater/PackageFiles.h index 3e7c38d64..99c4e8bea 100644 --- a/src/Updater/PackageFiles.h +++ b/src/Updater/PackageFiles.h @@ -116,8 +116,6 @@ static constexpr const wchar_t* V0_10_3_FILES[] = { L"effects\\Anime4K\\Anime4K_Restore_Soft_VL.hlsl", L"effects\\Anime4K\\Anime4K_Restore_UL.hlsl", L"effects\\Anime4K\\Anime4K_Restore_VL.hlsl", - L"effects\\Anime4K\\Anime4K_Restore_S.hlsl", - L"effects\\Anime4K\\Anime4K_Restore_Soft_S.hlsl", L"effects\\Anime4K\\Anime4K_Thin_HQ.hlsl", L"effects\\Anime4K\\Anime4K_Upscale_Denoise_L.hlsl", L"effects\\Anime4K\\Anime4K_Upscale_Denoise_S.hlsl", @@ -205,15 +203,102 @@ static constexpr const wchar_t* V0_10_3_FOLDERS[] = { L"effects" }; +static constexpr const wchar_t* V0_10_4_FILES[] = { + L"effects\\Anime4K\\Anime4K_3D_AA_Upscale_US.hlsl", + L"effects\\Anime4K\\Anime4K_3D_Upscale_US.hlsl", + L"effects\\Anime4K\\Anime4K_Denoise_Bilateral_Mean.hlsl", + L"effects\\Anime4K\\Anime4K_Denoise_Bilateral_Median.hlsl", + L"effects\\Anime4K\\Anime4K_Denoise_Bilateral_Mode.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_L.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_M.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_S.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_Soft_L.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_Soft_M.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_Soft_S.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_Soft_UL.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_Soft_VL.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_UL.hlsl", + L"effects\\Anime4K\\Anime4K_Restore_VL.hlsl", + L"effects\\Anime4K\\Anime4K_Thin_HQ.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_Denoise_L.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_Denoise_S.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_Denoise_UL.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_Denoise_VL.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_GAN_x2_S.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_L.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_S.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_UL.hlsl", + L"effects\\Anime4K\\Anime4K_Upscale_VL.hlsl", + L"effects\\CAS\\CAS.hlsl", + L"effects\\CAS\\CAS_Scaling.hlsl", + L"effects\\CRT\\CRT_Easymode.hlsl", + L"effects\\CRT\\CRT_Geom.hlsl", + L"effects\\CRT\\CRT_Hyllian.hlsl", + L"effects\\CRT\\CRT_Lottes.hlsl", + L"effects\\CRT\\GTU_v050.hlsl", + L"effects\\FSR\\FSR_EASU.hlsl", + L"effects\\FSR\\FSR_RCAS.hlsl", + L"effects\\FSRCNNX\\FSRCNNX.hlsl", + L"effects\\FSRCNNX\\FSRCNNX_LineArt.hlsl", + L"effects\\FXAA\\FXAA.hlsli", + L"effects\\FXAA\\FXAA_High.hlsl", + L"effects\\FXAA\\FXAA_Medium.hlsl", + L"effects\\FXAA\\FXAA_Ultra.hlsl", + L"effects\\NIS\\Coef_Scale.dds", + L"effects\\NIS\\Coef_USM.dds", + L"effects\\NIS\\NIS.hlsl", + L"effects\\NIS\\NVSharpen.hlsl", + L"effects\\NNEDI3\\NNEDI3_nns16_win8x4.hlsl", + L"effects\\NNEDI3\\NNEDI3_nns64_win8x6.hlsl", + L"effects\\Pixel Art\\MMPX.hlsl", + L"effects\\Pixel Art\\Pixellate.hlsl", + L"effects\\Pixel Art\\SharpBilinear.hlsl", + L"effects\\RAVU\\RAVU_Lite_R3.hlsl", + L"effects\\RAVU\\RAVU_Lite_R3_Weights.dds", + L"effects\\RAVU\\RAVU_Zoom_R3.hlsl", + L"effects\\RAVU\\RAVU_Zoom_R3_Weights.dds", + L"effects\\Sharpen\\AdaptiveSharpen.hlsl", + L"effects\\Sharpen\\FineSharp.hlsl", + L"effects\\Sharpen\\LCAS.hlsl", + L"effects\\Sharpen\\LumaSharpen.hlsl", + L"effects\\SMAA\\AreaTex.dds", + L"effects\\SMAA\\SearchTex.dds", + L"effects\\SMAA\\SMAA.hlsli", + L"effects\\SMAA\\SMAA_High.hlsl", + L"effects\\SMAA\\SMAA_Low.hlsl", + L"effects\\SMAA\\SMAA_Medium.hlsl", + L"effects\\SMAA\\SMAA_Ultra.hlsl", + L"effects\\xBRZ\\xBRZ_2x.hlsl", + L"effects\\xBRZ\\xBRZ_3x.hlsl", + L"effects\\xBRZ\\xBRZ_4x.hlsl", + L"effects\\xBRZ\\xBRZ_5x.hlsl", + L"effects\\xBRZ\\xBRZ_6x.hlsl", + L"effects\\xBRZ\\xBRZ_Freescale.hlsl", + L"effects\\ACNet.hlsl", + L"effects\\Bicubic.hlsl", + L"effects\\Bilinear.hlsl", + L"effects\\Deband.hlsl", + L"effects\\ImageAdjustment.hlsl", + L"effects\\Jinc.hlsl", + L"effects\\Lanczos.hlsl", + L"effects\\Nearest.hlsl", + L"effects\\SSimDownscaler.hlsl", + L"Magpie.App.dll", + L"Microsoft.UI.Xaml.dll", + L"resources.pri" +}; + struct PackageFiles { const std::span files; const std::span folders; static std::optional Get(const Version& version) { - if (version < Version(0, 10, 3)) { - return PackageFiles{ _ToSpan(V0_9_101_FILES), _ToSpan(V0_9_101_FOLDERS)}; - } else { + if (version >= Version(0, 10, 4)) { + return PackageFiles{ _ToSpan(V0_10_4_FILES), _ToSpan(V0_10_3_FOLDERS) }; + } else if (version >= Version(0, 10, 3)) { return PackageFiles{ _ToSpan(V0_10_3_FILES), _ToSpan(V0_10_3_FOLDERS) }; + } else { + return PackageFiles{ _ToSpan(V0_9_101_FILES), _ToSpan(V0_9_101_FOLDERS) }; } } From c296c25520fe7eb67a2cc47844effa481a6f1369 Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Tue, 28 Nov 2023 20:24:01 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=20(#766)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复发布版本时 zip 损坏的问题 * chore: 支持发布预览版和生成默认发行说明 --- .github/workflows/release.yml | 5 +++ publish.py | 79 ++++++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03169280e..4153c3219 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,10 @@ on: description: 'Tag' required: false type: string + prerelease: + description: 'Prerelease' + required: true + type: boolean jobs: release: runs-on: windows-latest @@ -46,4 +50,5 @@ jobs: MINOR: ${{ inputs.minor }} PATCH: ${{ inputs.patch }} TAG: ${{ inputs.tag }} + PRERELEASE: ${{ inputs.prerelease }} ACCESS_TOKEN: ${{ secrets.CONTENTS_ACCESS_TOKEN }} diff --git a/publish.py b/publish.py index 4d476972e..9831aeb6b 100644 --- a/publish.py +++ b/publish.py @@ -38,6 +38,8 @@ if tag == "": tag = f"v{majorVersion}.{minorVersion}.{patchVersion}" + isPrerelease = os.environ["PRERELEASE"].lower() == "true" + githubAccessToken = os.environ["ACCESS_TOKEN"] repo = os.environ["GITHUB_REPOSITORY"] actor = os.environ["GITHUB_ACTOR"] @@ -133,7 +135,7 @@ def remove_file(file): for folder in ["Microsoft.UI.Xaml", "Magpie.App"]: shutil.rmtree(folder, ignore_errors=True) - + for pattern in ["*.pdb", "*.lib", "*.exp", "*.winmd", "*.xml", "*.xbf", "dummy.*"]: for file in glob.glob(pattern): remove_file(file) @@ -184,6 +186,7 @@ def remove_file(file): break xmlTree.write("resources.pri.xml", encoding="utf-8") +xmlTree = None with open("priconfig.xml", "w", encoding="utf-8") as f: print( @@ -253,18 +256,50 @@ def remove_file(file): shutil.make_archive(pkgName, "zip", "publish") pkgName += ".zip" - # 发布 release headers = { "Accept": "application/vnd.github+json", "Authorization": "Bearer " + githubAccessToken, "X-GitHub-Api-Version": "2022-11-28", } + + # 获取前一个发布版本来生成默认发行说明 + prevReleaseTag = None + try: + if isPrerelease: + # 发布预发行版与最新的版本(无论是正式版还是预发行版)对比 + response = requests.get( + f"https://api.github.com/repos/{repo}/releases", + json={ + "per_page": 1 + }, + headers=headers + ) + if response.ok: + prevReleaseTag = response.json()[0]["tag_name"] + else: + # 发布正式版则与最新的正式版对比 + # 由于可以自己选择最新版本,此接口可能不会返回时间上最新发布的版本,不是大问题 + response = requests.get(f"https://api.github.com/repos/{repo}/releases/latest", headers=headers) + if response.ok: + prevReleaseTag = response.json()["tag_name"] + except: + # 忽略错误 + pass + + # 发布 release + if prevReleaseTag == None: + body = "" + else: + # 默认发行说明为比较两个 tag + body = f"https://github.com/{repo}/compare/{prevReleaseTag}...{tag}" + response = requests.post( f"https://api.github.com/repos/{repo}/releases", json={ "tag_name": tag, "name": tag, - "generate_release_notes": True, + "prerelease": isPrerelease, + "body": body, "discussion_category_name": "Announcements", }, headers=headers, @@ -276,34 +311,30 @@ def remove_file(file): upload_url = upload_url[: upload_url.find("{")] + "?name=" + pkgName # 上传资产 - response = requests.post( - upload_url, - files={pkgName: open(pkgName, "rb")}, - headers=headers, - ) - if not response.ok: - raise Exception("上传失败") + with open(pkgName, "rb") as f: + # 流式上传 + # https://requests.readthedocs.io/en/latest/user/advanced/#streaming-uploads + response = requests.post( + upload_url, + data=f, + headers={**headers, "Content-Type": "application/zip"}, + ) - print("已发布 " + tag, flush=True) + if not response.ok: + raise Exception("上传失败") - # 更新 version.json - # 此步应在发布版本之后,因为程序使用 version.json 检查更新 + # 计算哈希 + f.seek(0, os.SEEK_SET) + md5 = hashlib.file_digest(f, hashlib.md5).hexdigest() - # 资产上传后会被 Github 修改,我们应计算修改后的哈希值 - response = requests.get( - response.json()["browser_download_url"], - ) - if not response.ok: - raise Exception("下载失败") - - hasher = hashlib.md5() - for chunk in response.iter_content(chunk_size=8192): - hasher.update(chunk) + print("已发布 " + tag, flush=True) # 丢弃当前修改并更新到最新,防止编译时有新的提交 subprocess.run("git checkout -f") subprocess.run("git pull") + # 更新 version.json + # 此步应在发布版本之后,因为程序使用 version.json 检查更新 with open("version.json", "w", encoding="utf-8") as f: json.dump( { @@ -312,7 +343,7 @@ def remove_file(file): "binary": { "x64": { "url": f"https://github.com/{repo}/releases/download/{tag}/{pkgName}", - "hash": hasher.hexdigest(), + "hash": md5, } }, }, From f04ae49f6a70bd902e050870683d057af0e4e93d Mon Sep 17 00:00:00 2001 From: "Weblate (bot)" Date: Wed, 29 Nov 2023 01:28:57 +0100 Subject: [PATCH 6/7] Translations update from Hosted Weblate (#767) * Translated using Weblate (Russian) Currently translated at 100.0% (244 of 244 strings) Translation: Magpie/UI Translate-URL: https://hosted.weblate.org/projects/magpie/ui/ru/ * Translated using Weblate (Turkish) Currently translated at 100.0% (244 of 244 strings) Translation: Magpie/UI Translate-URL: https://hosted.weblate.org/projects/magpie/ui/tr/ * Translated using Weblate (Spanish) Currently translated at 100.0% (244 of 244 strings) Translation: Magpie/UI Translate-URL: https://hosted.weblate.org/projects/magpie/ui/es/ --------- Co-authored-by: Tepaher Co-authored-by: xe1st Co-authored-by: Andrus Diaz German --- src/Magpie.App/Resources.language-es.resw | 6 ++++++ src/Magpie.App/Resources.language-ru.resw | 3 +++ src/Magpie.App/Resources.language-tr.resw | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/src/Magpie.App/Resources.language-es.resw b/src/Magpie.App/Resources.language-es.resw index 668cfcdd6..2c19c871a 100644 --- a/src/Magpie.App/Resources.language-es.resw +++ b/src/Magpie.App/Resources.language-es.resw @@ -844,4 +844,10 @@ Escale la ventana de primer plano o deje de escalar + + El modo de desarrollador está habilitado. + + + Confirmación + \ No newline at end of file diff --git a/src/Magpie.App/Resources.language-ru.resw b/src/Magpie.App/Resources.language-ru.resw index 38c8daa83..c5873e3e6 100644 --- a/src/Magpie.App/Resources.language-ru.resw +++ b/src/Magpie.App/Resources.language-ru.resw @@ -847,4 +847,7 @@ Зафиксировать + + Включен режим разработчика. + \ No newline at end of file diff --git a/src/Magpie.App/Resources.language-tr.resw b/src/Magpie.App/Resources.language-tr.resw index 059f9ac47..aee7b828a 100644 --- a/src/Magpie.App/Resources.language-tr.resw +++ b/src/Magpie.App/Resources.language-tr.resw @@ -844,4 +844,10 @@ Ön plan penceresini ölçeklendir veya durdur + + Geliştirici modu etkin. + + + Commit + \ No newline at end of file From 3f1d44bb57b0237580d40738f43c1f2540e99f32 Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Wed, 29 Nov 2023 21:52:58 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8E=9F=E5=AD=90?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E7=9A=84=E6=80=A7=E8=83=BD=20(#768)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: 优化部分原子操作 * perf: 优化 MagRuntime 的性能 * fix: 修复立即退出缩放不会触发 IsRunningChangedEvent * perf: 优化原子操作 * perf: 优化更多原子操作 --- src/Magpie.App/EffectsService.cpp | 4 +-- src/Magpie.App/MagService.cpp | 25 +++++++++++-------- .../DesktopDuplicationFrameSource.cpp | 15 +++++------ src/Magpie.Core/ImGuiImpl.h | 1 - src/Magpie.Core/MagRuntime.cpp | 24 ++++++++---------- src/Magpie.Core/MagRuntime.h | 8 +++--- src/Magpie.Core/Renderer.cpp | 10 ++++---- src/Shared/Win32Utils.cpp | 2 +- 8 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/Magpie.App/EffectsService.cpp b/src/Magpie.App/EffectsService.cpp index 9f21b08f9..509946633 100644 --- a/src/Magpie.App/EffectsService.cpp +++ b/src/Magpie.App/EffectsService.cpp @@ -99,11 +99,11 @@ fire_and_forget EffectsService::StartInitialize() { _effectsMap.emplace(effect.name, (uint32_t)_effects.size() - 1); } - _initialized = true; + _initialized.store(true, std::memory_order_release); } void EffectsService::WaitForInitialize() { - while (!_initialized) { + while (!_initialized.load(std::memory_order_acquire)) { Sleep(0); } } diff --git a/src/Magpie.App/MagService.cpp b/src/Magpie.App/MagService.cpp index 502da8012..51d8caa8f 100644 --- a/src/Magpie.App/MagService.cpp +++ b/src/Magpie.App/MagService.cpp @@ -21,11 +21,6 @@ void MagService::Initialize() { _countDownTimer.Interval(25ms); _countDownTimer.Tick({ this, &MagService::_CountDownTimer_Tick }); - _checkForegroundTimer = ThreadPoolTimer::CreatePeriodicTimer( - { this, &MagService::_CheckForegroundTimer_Tick }, - 50ms - ); - AppSettings::Get().IsAutoRestoreChanged({ this, &MagService::_Settings_IsAutoRestoreChanged }); _magRuntime.emplace(); _magRuntime->IsRunningChanged({ this, &MagService::_MagRuntime_IsRunningChanged }); @@ -34,6 +29,11 @@ void MagService::Initialize() { { this, &MagService::_ShortcutService_ShortcutPressed } ); + _checkForegroundTimer = ThreadPoolTimer::CreatePeriodicTimer( + { this, &MagService::_CheckForegroundTimer_Tick }, + 50ms + ); + // 立即检查前台窗口 _CheckForegroundTimer_Tick(nullptr); } @@ -83,7 +83,7 @@ void MagService::ClearWndToRestore() { } void MagService::CheckForeground() { - _hwndChecked = NULL; + _hwndChecked.store(NULL, std::memory_order_relaxed); _CheckForegroundTimer_Tick(nullptr); } @@ -139,15 +139,17 @@ void MagService::_CountDownTimer_Tick(IInspectable const&, IInspectable const&) } fire_and_forget MagService::_CheckForegroundTimer_Tick(ThreadPoolTimer const& timer) { + // _magRuntime 不会改变,无需同步措施 if (!_magRuntime || _magRuntime->IsRunning()) { co_return; } - HWND hwndFore = GetForegroundWindow(); - if (hwndFore == _hwndChecked) { + const HWND hwndFore = GetForegroundWindow(); + // 没有对其他变量的访问,因此不需要限制内存定序 + if (hwndFore == _hwndChecked.load(std::memory_order_relaxed)) { co_return; } - _hwndChecked = NULL; + _hwndChecked.store(NULL, std::memory_order_relaxed); if (timer) { // ThreadPoolTimer 在后台线程触发 @@ -182,7 +184,7 @@ fire_and_forget MagService::_CheckForegroundTimer_Tick(ThreadPoolTimer const& ti } // 避免重复检查 - _hwndChecked = hwndFore; + _hwndChecked.store(hwndFore, std::memory_order_relaxed); } void MagService::_Settings_IsAutoRestoreChanged(bool) { @@ -224,8 +226,9 @@ fire_and_forget MagService::_MagRuntime_IsRunningChanged(bool isRunning) { if (GetForegroundWindow() == curSrcWnd) { // 退出全屏后如果前台窗口不变视为通过热键退出 - _hwndChecked = curSrcWnd; + _hwndChecked.store(curSrcWnd, std::memory_order_relaxed); } else if (!_isAutoScaling && AppSettings::Get().IsAutoRestore()) { + // 自动缩放窗口时切换窗口无需记录到自动恢复 if (_CheckSrcWnd(curSrcWnd)) { _WndToRestore(curSrcWnd); } diff --git a/src/Magpie.Core/DesktopDuplicationFrameSource.cpp b/src/Magpie.Core/DesktopDuplicationFrameSource.cpp index cf1f29351..888285e45 100644 --- a/src/Magpie.Core/DesktopDuplicationFrameSource.cpp +++ b/src/Magpie.Core/DesktopDuplicationFrameSource.cpp @@ -69,7 +69,7 @@ static winrt::com_ptr GetDXGIOutput(HMONITOR hMonitor) { } DesktopDuplicationFrameSource::~DesktopDuplicationFrameSource() { - _exiting = true; + _exiting.store(true, std::memory_order_release); WaitForSingleObject(_hDDPThread, 1000); } @@ -208,7 +208,7 @@ bool DesktopDuplicationFrameSource::Initialize() { FrameSourceBase::UpdateState DesktopDuplicationFrameSource::Update() { - UINT newFrameState = _newFrameState.load(); + const UINT newFrameState = _newFrameState.load(std::memory_order_acquire); if (newFrameState == 2) { // 第一帧之前不渲染 return UpdateState::Waiting; @@ -216,7 +216,7 @@ FrameSourceBase::UpdateState DesktopDuplicationFrameSource::Update() { return UpdateState::NoUpdate; } - // 不必等待,当 newFrameState 变化时 DDP 线程已将锁释放 + // 不必等待,当 newFrameState 变化时捕获线程已将锁释放 HRESULT hr = _sharedTexMutex->AcquireSync(1, 0); if (hr == static_cast(WAIT_TIMEOUT)) { return UpdateState::Waiting; @@ -227,7 +227,8 @@ FrameSourceBase::UpdateState DesktopDuplicationFrameSource::Update() { return UpdateState::Error; } - _newFrameState.store(0); + // 不需要对捕获线程可见 + _newFrameState.store(0, std::memory_order_relaxed); MagApp::Get().GetDeviceResources().GetD3DDC()->CopyResource(_output.get(), _sharedTex.get()); @@ -291,7 +292,7 @@ DWORD WINAPI DesktopDuplicationFrameSource::_DDPThreadProc(LPVOID lpThreadParame winrt::com_ptr dxgiRes; SmallVector dupMetaData; - while (!that._exiting.load()) { + while (!that._exiting.load(std::memory_order_acquire)) { if (dxgiRes) { that._outputDup->ReleaseFrame(); } @@ -365,7 +366,7 @@ DWORD WINAPI DesktopDuplicationFrameSource::_DDPThreadProc(LPVOID lpThreadParame hr = that._ddpSharedTexMutex->AcquireSync(0, 100); while (hr == static_cast(WAIT_TIMEOUT)) { - if (that._exiting.load()) { + if (that._exiting.load(std::memory_order_acquire)) { return 0; } @@ -380,7 +381,7 @@ DWORD WINAPI DesktopDuplicationFrameSource::_DDPThreadProc(LPVOID lpThreadParame that._ddpD3dDC->CopySubresourceRegion(that._ddpSharedTex.get(), 0, 0, 0, 0, d3dRes.get(), 0, &that._frameInMonitor); that._ddpSharedTexMutex->ReleaseSync(1); - that._newFrameState.store(1); + that._newFrameState.store(1, std::memory_order_release); } return 0; diff --git a/src/Magpie.Core/ImGuiImpl.h b/src/Magpie.Core/ImGuiImpl.h index 213dd3e69..d4e55d1af 100644 --- a/src/Magpie.Core/ImGuiImpl.h +++ b/src/Magpie.Core/ImGuiImpl.h @@ -30,7 +30,6 @@ class ImGuiImpl { HANDLE _hHookThread = NULL; DWORD _hookThreadId = 0; - std::atomic _wheelData = 0; }; } diff --git a/src/Magpie.Core/MagRuntime.cpp b/src/Magpie.Core/MagRuntime.cpp index 7a534d652..926ca7402 100644 --- a/src/Magpie.Core/MagRuntime.cpp +++ b/src/Magpie.Core/MagRuntime.cpp @@ -14,32 +14,31 @@ MagRuntime::~MagRuntime() { Stop(); if (_magWindThread.joinable()) { - DWORD magWndThreadId = GetThreadId(_magWindThread.native_handle()); - // 持续尝试直到 _magWindThread 创建了消息队列 + const DWORD magWndThreadId = GetThreadId(_magWindThread.native_handle()); + // 持续尝试直到 _magWndThread 创建了消息队列 while (!PostThreadMessage(magWndThreadId, WM_QUIT, 0, 0)) { - Sleep(1); + Sleep(0); } _magWindThread.join(); } } void MagRuntime::Run(HWND hwndSrc, const MagOptions& options) { - if (_running) { + HWND expected = NULL; + if (!_hwndSrc.compare_exchange_strong(expected, hwndSrc, std::memory_order_relaxed)) { return; } - _hwndSrc = hwndSrc; - _running = true; _isRunningChangedEvent(true); _EnsureDispatcherQueue(); - _dqc.DispatcherQueue().TryEnqueue([this, hwndSrc, options(options)]() mutable { + _dqc.DispatcherQueue().TryEnqueue([hwndSrc, options(options)]() mutable { MagApp::Get().Start(hwndSrc, std::move(options)); }); } void MagRuntime::ToggleOverlay() { - if (!_running) { + if (!IsRunning()) { return; } @@ -50,7 +49,7 @@ void MagRuntime::ToggleOverlay() { } void MagRuntime::Stop() { - if (!_running) { + if (!IsRunning()) { return; } @@ -83,16 +82,15 @@ void MagRuntime::_MagWindThreadProc() noexcept { // 缩放时使用不同的消息循环 bool quiting = !app.MessageLoop(); - _running = false; + _hwndSrc.store(NULL, std::memory_order_relaxed); _isRunningChangedEvent(false); if (quiting) { return; } } else { - if (_running) { - // 缩放失败 - _running = false; + if (_hwndSrc.exchange(NULL, std::memory_order_relaxed)) { + // 缩放失败或立即退出缩放 _isRunningChangedEvent(false); } diff --git a/src/Magpie.Core/MagRuntime.h b/src/Magpie.Core/MagRuntime.h index ebc56096b..9ec780f4b 100644 --- a/src/Magpie.Core/MagRuntime.h +++ b/src/Magpie.Core/MagRuntime.h @@ -14,7 +14,7 @@ class MagRuntime { ~MagRuntime(); HWND HwndSrc() const { - return _running ? _hwndSrc : 0; + return _hwndSrc.load(std::memory_order_relaxed); } void Run(HWND hwndSrc, const MagOptions& options); @@ -24,7 +24,7 @@ class MagRuntime { void Stop(); bool IsRunning() const { - return _running; + return HwndSrc(); } // 调用者应处理线程同步 @@ -50,8 +50,8 @@ class MagRuntime { void _EnsureDispatcherQueue() const noexcept; std::thread _magWindThread; - std::atomic _running = false; - HWND _hwndSrc = 0; + // 主线程使用 DispatcherQueue 和缩放线程沟通,因此无需约束内存定序,只需确保原子性即可 + std::atomic _hwndSrc; winrt::Windows::System::DispatcherQueueController _dqc{ nullptr }; winrt::event> _isRunningChangedEvent; diff --git a/src/Magpie.Core/Renderer.cpp b/src/Magpie.Core/Renderer.cpp index 98d7c4cea..cd18aa00f 100644 --- a/src/Magpie.Core/Renderer.cpp +++ b/src/Magpie.Core/Renderer.cpp @@ -327,17 +327,17 @@ bool Renderer::_BuildEffects() { // 并行编译所有效果 std::vector effectDescs(effectsOption.size()); - std::atomic allSuccess = true; + std::atomic anyFailure; int duration = Utils::Measure([&]() { Win32Utils::RunParallel([&](uint32_t id) { if (!CompileEffect(id == effectCount - 1, effectsOption[id], effectDescs[id])) { - allSuccess = false; + anyFailure.store(true, std::memory_order_relaxed); } }, effectCount); }); - if (!allSuccess) { + if (anyFailure.load(std::memory_order_relaxed)) { return false; } @@ -390,12 +390,12 @@ bool Renderer::_BuildEffects() { id == 0 ? effectsOption.back() : downscalingEffectOption, id == 0 ? effectDescs.back() : downscalingEffectDesc )) { - allSuccess = false; + anyFailure.store(true, std::memory_order_relaxed); } }, 2); }); - if (!allSuccess) { + if (anyFailure.load(std::memory_order_relaxed)) { return false; } diff --git a/src/Shared/Win32Utils.cpp b/src/Shared/Win32Utils.cpp index 9c3108808..6448c978b 100644 --- a/src/Shared/Win32Utils.cpp +++ b/src/Shared/Win32Utils.cpp @@ -265,7 +265,7 @@ struct TPContext { static void CALLBACK TPCallback(PTP_CALLBACK_INSTANCE, PVOID context, PTP_WORK) { TPContext* ctxt = (TPContext*)context; - uint32_t id = ++ctxt->id; + const uint32_t id = ctxt->id.fetch_add(1, std::memory_order_relaxed) + 1; ctxt->func(id); }
刘旭
刘旭

🚧 💻 👀 📖 💬
刘旭
Xu

🚧 💻 👀 📖 💬
hooke007
hooke007

📖 💬 📓 💻
Pal Lockheart
Pal Lockheart

📓
Steve Donaghy
Steve Donaghy

💻 🌍