Skip to content

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Dec 17, 2025

pick v20 to v25

fit the screen window layer in 1070, 1060 and 1050

pick from:c07f9d7066a1e320896bd13709b00e71ebdf126d

Log: fit the screen window layer in 1070, 1060 and 1050
Bug: https://pms.uniontech.com/bug-view-275661.html
The screenshot defaults to launching in 'shot' mode, changing from the
previous default 'record' mode. The 'shot' mode utilizes OpenGL
rendering, which offers higher performance compared to image rendering.

Log: reduce stuttering during corner marker movement.
Bug: https://pms.uniontech.com//bug-view-323453.html
Fixed an issue with Wayland window screenshots capturing the active
window. Previously, it rigidly used the second-to-last layer method
(which could capture input methods, notifications, or remote assistance
windows). Now it references dde-dock's layer level and captures the
window one layer above dde-dock.

pick from: 39e2146

Log: Fix active window detection in Wayland screenshots
Bug: https://pms.uniontech.com/bug-view-322949.html
Added dynamic wait time calculation function that adjusts clipboard
save timeout according to image resolution, improving performance
for small images while ensuring sufficient time for large images

pick from: 3596abf

Log: Implement adaptive clipboard wait time based on image size
Bug: https://pms.uniontech.com/bug-view-326039.html
Improved local image saving speed on LoongArch64 architecture by
configuring pixmap quality settings. Testing shows quality=60 provides
optimal balance between speed and image fidelity.

pick from: 023cf20

Log: Enhance LoongArch64 image save performance
Bug: https://pms.uniontech.com/bug-view-326039.html
Improved local image saving speed on LoongArch64 architecture by
configuring pixmap quality settings. Testing shows quality=60 provides
optimal balance between speed and image fidelity.

pick from: 953d402

Log: Enhance LoongArch64 image save performance
Bug: https://pms.uniontech.com/bug-view-326039.html
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这段代码变更进行审查:

  1. 语法逻辑方面:
  • 代码整体语法正确,没有明显的语法错误
  • 函数参数修改合理,如 start_encoder_thread() 改为 start_encoder_thread(void *) 更符合函数使用场景
  • 版本兼容性处理(#if LIBAVFORMAT_VERSION_MAJOR < 61)使用恰当
  1. 代码质量方面:
  • 增加了详细的日志输出,有助于调试
  • 添加了新的函数 getWaitTimeByImageSize() 并提供了完整的注释
  • 对不同架构(如 loongarch64)做了特殊处理,提高了代码的可移植性
  1. 代码性能方面:
  • getWaitTimeByImageSize() 函数根据图片大小动态计算等待时间,避免了固定等待时间的资源浪费
  • 对图片质量做了优化,在 loongarch64 架构下使用较低的质量设置
  • 使用了对数增长的方式计算超大图片的等待时间,避免了过长的等待
  1. 代码安全方面:
  • 添加了空指针检查,如 getWaitTimeByImageSize() 中对 pix.isNull() 的检查
  • 对等待时间设置了上限(15秒),防止过长等待
  • 对窗口层级做了版本兼容处理,提高了稳定性

改进建议:

  1. main_window.cpp 中的 getWaitTimeByImageSize() 函数:
int MainWindow::getWaitTimeByImageSize(const QPixmap &pix)
{
    // 建议将常量值定义为宏或常量变量,便于维护
    static const int DEFAULT_WAIT_TIME = 2;
    static const int MAX_WAIT_TIME = 15;
    static const qint64 BASE_PIXELS = 921600; // 720p基准像素数
    
    if (pix.isNull()) {
        qWarning() << __FUNCTION__ << "Empty pixmap, using default wait time";
        return DEFAULT_WAIT_TIME;
    }
    
    qint64 totalPixels = static_cast<qint64>(pix.width()) * pix.height();
    int waitTime = DEFAULT_WAIT_TIME;
    
    // 建议使用switch-case结构,更清晰
    if (totalPixels <= BASE_PIXELS) {
        waitTime = 2;
    } else if (totalPixels <= 2073600) {
        waitTime = 4;
    } else if (totalPixels <= 3686400) {
        waitTime = 6;
    } else if (totalPixels <= 8294400) {
        waitTime = 8;
    } else if (totalPixels <= 33177600) {
        waitTime = 10;
    } else {
        double pixelRatio = static_cast<double>(totalPixels) / BASE_PIXELS;
        waitTime = static_cast<int>(DEFAULT_WAIT_TIME + log2(pixelRatio) * 2);
        waitTime = qMin(waitTime, MAX_WAIT_TIME);
    }
    
    return waitTime;
}
  1. main_window.cpp 中的 save2Clipboard() 函数:
void MainWindow::save2Clipboard(const QPixmap &pix)
{
    if (pix.isNull()) {
        qWarning() << __FUNCTION__ << "Copy Null Pix To Clipboard!";
        return;
    }
    
    // 建议将质量参数定义为常量
    static const int DEFAULT_QUALITY = -1;
    static const int LOONGARCH_QUALITY = 60;
    
    int quality = QSysInfo::currentCpuArchitecture().startsWith("loongarch64") 
                 ? LOONGARCH_QUALITY 
                 : DEFAULT_QUALITY;
    
    // 其余代码保持不变...
}
  1. 建议在 camview.h 中为 start_encoder_thread 函数添加更详细的参数说明:
/**
 * @brief 启动编码器线程
 * @param data 传递给编码器线程的数据指针
 * @return 错误代码
 */
int start_encoder_thread(void *data);
  1. 建议在 audio_codecs.c 中添加版本检查的注释说明:
/*
 * FFmpeg profile definitions compatibility layer
 * These macros provide backward compatibility with older FFmpeg versions
 */
#ifndef FF_PROFILE_UNKNOWN
#define FF_PROFILE_UNKNOWN AV_PROFILE_UNKNOWN
// ... 其他宏定义
#endif
  1. main_window.h 中建议将 m_functionType 的默认值改为枚举类型:
// 定义功能类型枚举
enum FunctionType {
    RECORD = 0,
    SHOT = 1,
    SCROLLSHOT = 2,
    OCR = 3,
    PINSCREENSHOTS = 4
};

// 使用枚举类型
FunctionType m_functionType = FunctionType::SHOT;

这些改进建议主要针对代码的可维护性和可读性,不会影响代码的功能和性能。

Copy link
Contributor

@lzwind lzwind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要处理错误

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

* feat: Support ffmepg 7

Log: Fix build on ffmepg 7

* fix:(libcam_encoder) Add fallback definitions for FF_PROFILE_* macros

Some older FFmpeg or libav versions do not define FF_PROFILE_* macros.
Add conditional definitions to ensure compatibility with AV_PROFILE_*
constants, fixing build errors on systems with outdated headers.

Log:

* fix: update function signature for GCC 15 compatibility

The function 'v4l2core_check_device_list_events' signature was updated
to accept 'v4l2_dev_t *' parameter instead of having no parameters.

Log: This change addresses a breaking compatibility issue introduced in GCC 15,
which enforces stricter type checking on function declarations and definitions.

Previously, GCC allowed mismatched function declarations and definitions
when parameter types differ but ultimately point to the same struct type,
such as between 'struct _v4l2_dev_t *' and 'v4l2_dev_t *'.

GCC 15's change (see GCC 15 release notes) now treats such mismatches as errors,
requiring declarations and definitions to exactly match in parameter types.

This patch aligns the declaration with the definition to fix the
'conflicting types' compilation error when building with GCC 15
@add-uos
Copy link
Contributor Author

add-uos commented Dec 17, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 17, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 2293663 into linuxdeepin:develop/snipe Dec 17, 2025
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants