[0129] 优化 PDF 缩放性能:页面缓存、可见性裁剪与防抖#3371
Merged
Merged
Conversation
参考 Okular Tile-based 渲染架构,引入以下优化: - 页面渲染缓存:以 (pageNumber, targetWidth) 为键缓存 QPixmap - 可见性裁剪:rebuildPages 只渲染视口 ±200px 范围内的页面 - 缩放防抖:Ctrl+滚轮缩放后 200ms 防抖,避免连续触发重渲染 - Resize 防抖:窗口大小调整 300ms 防抖后统一重建 - 滚动按需渲染:垂直滚动时自动触发新进入视口页面的渲染 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
PDFReaderWidget进行缩放性能优化核心改动
PdfPageCacheKey+QHash):以(pageNumber, targetWidth)为键缓存QPixmap,相同尺寸页面直接命中,跳过 MuPDF 光栅化rebuildPages()只渲染视口 ±200px 范围内的页面;不可见页面若缓存存在则显示降级缩放图zoomDebounceTimer_, 200ms):Ctrl+滚轮连续缩放时只渲染最终状态resizeDebounceTimer_, 300ms):窗口大小调整后防抖统一重建valueChanged连接rebuildPages(),新进入视口的页面自动渲染loadFromFile()时一次性读取所有页面的宽高比,避免重复打开文档Test plan
xmake build stem通过xmake run qt_pdf_reader_widget_test10 passed, 0 failed🤖 Generated with Claude Code