Repository navigation
fix: use display-aware resolution for sidebar thumbnails - #439
Draft
GongHeng2017 wants to merge 1 commit into
Draft
GongHeng2017 wants to merge 1 commit into
GongHeng2017 wants to merge 1 commit into
Conversation
1. Root cause: PageRenderThread hardcoded 174x174 render resolution while display side draws at 174*pixScale*dpr, causing Qt upscaling blur when sidebar is widened or on HiDPI displays 2. Fix: add pixScale field to DocPageThumbnailTask, set it from adaptScale property at both task creation sites, compute render size as 174*pixScale*dpr in execNextDocPageThumbnailTask 3. Impact: thumbnails now render at display-matched resolution; default pixScale=1.0 and dpr=1.0 preserves existing behavior Log: Fix blurred sidebar thumbnails in document viewer Influence: 1. Test thumbnail clarity at default sidebar width (266px) 2. Test thumbnail clarity after widening sidebar (125%-200%) 3. Test thumbnail clarity on HiDPI 2x displays 4. Verify dark-theme thumbnail inversion still works 5. Verify XPS document thumbnail performance unaffected fix: 修复侧边栏缩略图模糊问题 1. 根因:PageRenderThread 渲染缩略图时硬编码 174x174 分辨率,而显示侧 按 174*pixScale*dpr 绘制,侧边栏变宽或 HiDPI 设备上 Qt 放大导致模糊 2. 方案:DocPageThumbnailTask 新增 pixScale 字段,两个 task 创建点从 adaptScale 属性读取赋值,渲染时按 174*pixScale*dpr 计算实际渲染尺寸 3. 影响:缩略图按显示匹配分辨率渲染;pixScale=1.0 且 dpr=1.0 时行为不变 Log: 修复文档查看器侧边栏缩略图模糊问题 Influence: 1. 测试默认侧边栏宽度(266px)下缩略图清晰度 2. 测试拖宽侧边栏后(125%-200%)缩略图清晰度 3. 测试 HiDPI 2x 屏幕下缩略图清晰度 4. 验证深色主题缩略图反色功能不受影响 5. 验证 XPS 文档缩略图性能不受影响 PMS: BUG-173857
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes blurry sidebar thumbnails by carrying the UI's Sequence diagram for display-aware sidebar thumbnail renderingsequenceDiagram
participant UI as SideBarImageViewModel
participant Queue as PageRenderThread
participant Renderer as DocumentRenderer
participant View as ThumbnailDelegate
UI->>UI: property(adaptScale)
UI->>Queue: appendTask(DocPageThumbnailTask.pixScale)
Queue->>Queue: execNextDocPageThumbnailTask()
Queue->>Queue: compute renderSize = 174 * pixScale * devicePixelRatio()
Queue->>Renderer: getImage(index, renderSize, renderSize)
Queue->>Renderer: getImageObjectRects(index, renderSize, renderSize)
Renderer-->>Queue: image and imageRects
Queue-->>View: sigDocPageThumbnailTaskFinished()
View->>View: paint at 174 * pixScale * dpr
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
GongHeng2017
marked this pull request as draft
October 29, 2026 20:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause Analysis
The sidebar thumbnail rendering pipeline has a resolution mismatch:
PageRenderThread::execNextDocPageThumbnailTask()(PageRenderThread.cpp:817) hardcoded the render resolution at 174×174, while the display side (ThumbnailDelegate::paint()) draws the thumbnail at174 * pixScale * dpr. When the sidebar is widened (pixScale > 1.0) or on HiDPI displays (dpr > 1.0), Qt upscales the 174px source image, causing visible blur. The root cause is that thepixScalefactor — already available on the display side via theadaptScaleproperty — was never propagated to the render side.Fix Approach
Added a
pixScalefield toDocPageThumbnailTask(default 1.0 for backward compatibility). Both task creation sites inSideBarImageViewModelnow readadaptScalefrom the parent widget and assign it to the task. The render call inexecNextDocPageThumbnailTask()computes the actual render size as174 * pixScale * dpr, matching the display-side drawing dimensions and eliminating upscaling.Change Safety Assessment
Code Safety
pixScaleon the display side but did not propagate it to the render side; this change supplements rather than reverts that fixDocPageThumbnailTaskis an internal struct (not public API); the newpixScalefield defaults to 1.0, preserving existing behavior when unsetBusiness Impact Scope
SideBarImageViewModel::data()andSideBarImageViewModel::onUpdateImage()(task creation),PageRenderThread::execNextDocPageThumbnailTask()(render execution)Verification Suggestion
Focus regression testing on thumbnail clarity at various sidebar widths and system zoom levels (100%, 125%, 150%, 200%), plus HiDPI 2x displays. Verify dark-theme thumbnail inversion and XPS document thumbnail performance are unaffected.
根因分析
侧边栏缩略图渲染管线存在分辨率不匹配问题:
PageRenderThread::execNextDocPageThumbnailTask()(PageRenderThread.cpp:817)硬编码渲染分辨率为 174×174,而显示侧(ThumbnailDelegate::paint())按174 * pixScale * dpr绘制。当侧边栏变宽(pixScale > 1.0)或在 HiDPI 显示器上(dpr > 1.0)时,Qt 将 174px 源图像放大,导致明显模糊。根因是显示侧已通过adaptScale属性获取的pixScale因子从未传递到渲染侧。修复方案
在
DocPageThumbnailTask中新增pixScale字段(默认 1.0,保证向后兼容)。SideBarImageViewModel的两个 task 创建点从父组件的adaptScale属性读取并赋值。execNextDocPageThumbnailTask()中的渲染调用按174 * pixScale * dpr计算实际渲染尺寸,与显示侧绘制尺寸匹配,消除放大模糊。改动安全评估
代码安全评估
pixScale缩放但未同步到渲染侧;本次改动补充而非撤销该修复DocPageThumbnailTask是内部结构体(非公开 API);新增pixScale字段默认 1.0,未赋值时行为不变业务影响范围
SideBarImageViewModel::data()和SideBarImageViewModel::onUpdateImage()(task 创建),PageRenderThread::execNextDocPageThumbnailTask()(渲染执行)验证建议
回归测试重点:不同侧边栏宽度和系统缩放比例(100%、125%、150%、200%)下的缩略图清晰度,以及 HiDPI 2x 显示器上的表现。验证深色主题缩略图反色和 XPS 文档缩略图性能不受影响。
Summary by Sourcery
Match sidebar thumbnail rendering resolution to its display size so thumbnails remain sharp across sidebar widths and HiDPI displays.
Bug Fixes:
Enhancements: