WO2024051433A9 - 一种pdf页面渲染缓存的方法 - Google Patents

一种pdf页面渲染缓存的方法 Download PDF

Info

Publication number
WO2024051433A9
WO2024051433A9 PCT/CN2023/111980 CN2023111980W WO2024051433A9 WO 2024051433 A9 WO2024051433 A9 WO 2024051433A9 CN 2023111980 W CN2023111980 W CN 2023111980W WO 2024051433 A9 WO2024051433 A9 WO 2024051433A9
Authority
WO
WIPO (PCT)
Prior art keywords
area
rendering
fixed block
rendered
cache
Prior art date
Application number
PCT/CN2023/111980
Other languages
English (en)
French (fr)
Other versions
WO2024051433A1 (zh
Inventor
梁俊义
Original Assignee
福建福昕软件开发股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 福建福昕软件开发股份有限公司 filed Critical 福建福昕软件开发股份有限公司
Publication of WO2024051433A1 publication Critical patent/WO2024051433A1/zh
Publication of WO2024051433A9 publication Critical patent/WO2024051433A9/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/14Digital output to display device ; Cooperation and interconnection of the display device with other functional units
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present invention relates to the technical field of PDF page rendering cache, and in particular to a method for PDF page rendering cache.
  • the Adobe Acrobat application (a PDF (Portable Document Format) editing software developed by Adobe) is also slow when rendering for the first time, so it caches the results of the rendered area. The rate will increase when the area is displayed again, but too much cache will also affect the efficiency of re-rendering. How to render and cache PDF pages to improve the refresh efficiency when browsing PDF pages and reduce the occurrence of freezes is a problem that technical personnel in this field want to solve.
  • the present invention provides a method for PDF page rendering caching, which evaluates whether the result of PDF page rendering needs to be cached. If the pictures of the corresponding area are cached, the cached images can be used for automatic splicing during the subsequent screen refresh process, so as to greatly improve the screen refresh speed when the rendered content is displayed again.
  • the present invention provides a method for PDF page rendering cache, which comprises:
  • Step S1 evenly divide the entire PDF page into multiple fixed blocks
  • Step S2 When the page is first loaded, the portion to be displayed is rendered for the first time, and the rendering result area is compared with each fixed block that can intersect. If the width of the intersection of the rendering result area and any fixed block is equal to the width of the corresponding fixed block, the rendering result in the fixed block is added to the cache list of the fixed block;
  • Step S3 When the page needs to be rendered again, the cache list stored in each fixed block is traversed and checked. If the area to be rendered intersects with the cached area, the render function is called to render the area outside the intersecting area, and the area rendered this time is concatenated with the intersecting area to output the rendering result this time;
  • Step S4 Check the area rendered in step S3 and each fixed block that can intersect. If the width of the area rendered in step S3 intersecting with any fixed block is equal to the width of the corresponding fixed block, add the rendering result in the fixed block to the cache list of the fixed block.
  • Step S5 Repeat steps S3 and S4 until the rendering is completed.
  • the step S2 of splicing the currently rendered area with the intersecting area is specifically performed by using a bitmap Transform method.
  • the update logic of the cache list is specifically as follows:
  • the "resolution + rotation angle” in all cached rendered areas is used as the grouping identifier of the first dimension, and the “rendering time” is used as the grouping identifier of the second dimension in a group of cached data with the same resolution and rotation angle;
  • a threshold is set in the cache pool.
  • the size of the overall data in the cache pool reaches the threshold or the application layer needs to release the cache of a specified size, it is first released according to the grouping identifier of the first dimension combined with the LRU principle. If the rendered areas of the current cache all have the same resolution and rotation angle, the rendered areas with a smaller rendering time are released first based on the rendering time of each rendered area, where the rendering time is the time taken for this area to be rendered from the beginning to the completion.
  • the plurality of fixed blocks are nine fixed blocks distributed in a nine-square grid format.
  • the PDF page rendering caching method provided by the present invention can improve the rendering efficiency of the PDF page when browsing the PDF page by determining the rendering area that needs to be cached for each fixed block to reduce the size of the page area that needs to be rendered subsequently, thereby reducing the occurrence of freezes when browsing the PDF page.
  • FIGS. 1A to 1C are schematic diagrams of an initial solution of an embodiment of the present invention.
  • FIG2 is a schematic diagram of an improved solution of an embodiment of the present invention.
  • FIG. 3 is a flow chart of an embodiment of the present invention.
  • FIGS 1A to 1C are schematic diagrams of the initial scheme of an embodiment of the present invention.
  • the initial scheme of this embodiment provides a method for PDF page rendering cache, which first does not divide the cache area in a fixed manner. After each PDF page rendering is completed, the rendering result on the client (device) is compared with the result in the cache and multiple intersecting areas are obtained. The non-intersecting areas are used as new rendering areas, and the remaining areas use the results saved in the cache.
  • the final display result to be rendered is spliced through the bitmap (Bitmap) Transform method (a function that changes the final display result of the original resource image on the client). Among them, the newly rendered bitmap (Bitmap) needs to be divided and sorted, and then added to the cache list as a new cache object, which specifically includes the following process:
  • S1 Render the PDF page for the first time when the cache is empty. Since the cache is empty before the first rendering, it is only necessary to add the rendering result to the cache by region, that is, add region A of the first rendering in FIG. 1A to the cache.
  • the second rendering After scrolling the page, the second rendering is performed. Since the area A rendered for the first time is already in the cache at this time, the area to be rendered for the second time is different from the area rendered for the first time.
  • the area to be rendered for the second time is the area B in Figure 1B. As shown in Figure 1B, the area A rendered for the first time and the area B to be rendered for the second time have an intersection, that is, area No. 3 in the figure. Therefore, when performing the second rendering, it is necessary to first find the intersection area (area No.
  • S3 Rearrange and divide the area for the second rendering (areas 1 and 2) into regular rectangular parts (areas 1 and 2), and add each rectangular part after division as an element to the cache list;
  • the third rendering is performed.
  • the cache already has area A of the first rendering and areas 1 and 2 of area B of the second rendering, and the area of the second rendering has been divided into two rectangular parts (Regions 1 and 2) are saved in the cache list, and the third rendering is for region C in Figure 1C. Therefore, it is necessary to first find the intersection region (regions 1, 2, and 3) between the entire region C and all cached regions (regions A and B) in the cache, and then take out the intersection regions (regions 1, 2, and 3) from the cache respectively, and render the non-intersecting parts of the entire region C for the third time. Finally, the rendering result is spliced with the intersection region (regions 1, 2, and 3) as the third rendering result, that is, the entire region C.
  • steps S4 to S5 are repeated to continue rendering and caching the page.
  • the update logic of the cache list is specifically as follows:
  • the "resolution + rotation angle" in all cached rendered areas is used as the first dimension grouping identifier, and the “rendering time” is used as the second dimension grouping identifier for a group of cached data with the same resolution and rotation angle.
  • “resolution + rotation angle” is mainly used to index cached images. For example, for the same page, the image displayed by 100% cache and the image displayed by 150% cache are different. The cached images displayed by pages with different rotation angles are also different.
  • a threshold is set in the cache pool.
  • the size of the overall data in the cache pool reaches the threshold or the application layer needs to release the cache of a specified size, it is released first based on the grouping identifier of the first dimension, i.e., "resolution + rotation angle" combined with the LRU principle (Least Recently Used). If the rendered areas of the current cache have the same resolution and rotation angle, the rendered areas with a smaller rendering time are released first based on the rendering time of each rendered area, where the rendering time is the time taken for this area to be rendered from the beginning to the completion.
  • the division process is relatively complicated, and it is easy to divide out very small area blocks, so the implementation process will be relatively complicated and affect the efficiency of the overall rendering and caching;
  • the aforementioned initial solution is improved to obtain the final solution of this implementation, that is, firstly the entire page is divided into multiple fixed blocks (such as a nine-square grid), and then each fixed block is used as a minimum unit of cache management.
  • each fixed block is used as a minimum unit of cache management.
  • FIG. 2 is a schematic diagram of an improved solution of an embodiment of the present invention
  • FIG. 3 is a flow chart of an embodiment of the present invention.
  • this embodiment provides a method for PDF page rendering cache, specifically comprising:
  • Step S1 evenly divide the entire PDF page into multiple fixed blocks
  • the plurality of fixed blocks are nine fixed blocks, which are arranged in a nine-square grid.
  • six fixed blocks, eight fixed blocks, etc. may be evenly divided, and the present invention does not limit the number of evenly divided fixed blocks.
  • Step S2 When the page is first loaded, the portion to be displayed is rendered for the first time, and the rendering result area is compared with each fixed block that can intersect. If the width of the intersection of the rendering result area and any fixed block is equal to the width of the corresponding fixed block, the rendering result in the fixed block is added to the cache list of the fixed block;
  • the area for the first rendering is the area in the light gray box in FIG. 2 , which corresponds to the nine fixed blocks divided according to the nine-square grid.
  • the width of the area for the first rendering intersecting with the fixed block in the first row and first column (area 1) is equal to the width of the fixed block
  • the width of the area for the first rendering intersecting with the fixed block in the second row and first column (area 2) is also equal to the width of the fixed block, that is, area 1 and area 2 are filled in the entire row, then area 1 and area 2 are added to the cache list of the fixed blocks to which they belong (the fixed block in the first row and first column and the fixed block in the second row and first column);
  • Step S3 When the page needs to be rendered again, the cache list stored in each fixed block is traversed and checked. If the area to be rendered intersects with the cached area, the render function is called to render the area outside the intersecting area, and the intersecting area is taken from the corresponding cache list. The rendered area is concatenated with the intersecting area to output the rendering result for display in the application.
  • the splicing of the currently rendered area and the intersecting area in step S2 is specifically performed by using a bitmap Transform (a function that changes the final display result of the original resource image on the client).
  • Step S4 Check the area rendered in step S3 and each fixed block that can intersect. If the width of the area rendered in step S3 intersecting with any fixed block is equal to the width of the corresponding fixed block, add the rendering result in the fixed block to the cache list of the fixed block.
  • the area rendered for the second time intersects with the fixed blocks in the first row and second column, the fixed blocks in the second row and second column, and the fixed blocks in the third row and second column, respectively, and the widths of the intersecting areas 5, 6, and 7 are equal to the widths of the corresponding fixed blocks. Therefore, the rendering results of areas 5, 6, and 7 during the second rendering are added to the cache lists of the corresponding fixed blocks (the fixed blocks in the first row and second column, the fixed blocks in the second row and second column, and the fixed blocks in the third row and second column) for subsequent rendering.
  • Step S5 Repeat steps S3 and S4 until the rendering is completed.
  • the update logic of the cache list can be the same as the initial solution, that is, specifically:
  • the "resolution + rotation angle” in all cached rendered areas is used as the grouping identifier of the first dimension, and the “rendering time” is used as the grouping identifier of the second dimension in a group of cached data with the same resolution and rotation angle;
  • a threshold is set in the cache pool.
  • the size of the overall data in the cache pool reaches the threshold or the application layer needs to release the cache of a specified size, it is first released according to the grouping identifier of the first dimension combined with the LRU principle. If the rendered areas of the current cache all have the same resolution and rotation angle, the rendered areas with a smaller rendering time are released first based on the rendering time of each rendered area, where the rendering time is the time taken for this area to be rendered from the beginning to the completion.
  • the improved solution of this embodiment does not require complicated processing when updating irregular areas to the cache list, and because each fixed block is required to fill the entire row (that is, the width of the intersection of the rendering area is equal to the width of the fixed block) before caching, the cache management of each fixed block is relatively simple.
  • the PDF page rendering caching method provided by the present invention can improve the rendering efficiency of the PDF page when browsing the PDF page by determining the rendering area that needs to be cached for each fixed block to reduce the size of the page area that needs to be rendered subsequently, thereby reducing the occurrence of freezes when browsing the PDF page.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Image Generation (AREA)

Abstract

本发明公开一种PDF页面渲染缓存的方法,其包括:S1:将整个PDF页面均匀划分为多个固定区块;S2:在首次加载页面时对待显示部分进行第一次渲染,若渲染结果区域与任一固定区块相交的宽度等于对应固定区块的宽度,则将此固定区块内的渲染结果添加到该固定区块的缓存列表中;S3:当页面需要进行再次渲染时,遍历检查存储在每个固定区块的缓存列表,若与已经缓存的区域存在相交区域则对相交区域以外的区域进行渲染,并将本次渲染的区域与相交区域拼接输出本次渲染结果;S4:若在S3中渲染的区域与任一固定区块相交的宽度等于对应固定区块宽度,则将此固定区块内的渲染结果添加到该固定区块的缓存列表中;S5:重复S3和S4直至渲染结束。

Description

一种PDF页面渲染缓存的方法 技术领域
本发明涉及PDF页面渲染缓存技术领域,具体而言,涉及一种PDF页面渲染缓存的方法。
背景技术
在很多上层应用中对于诸如设计图、工程图文档存在渲染慢的现象,对于已经渲染过的区域再次进行显示时还需要重新渲染,从而导致重复耗时。例如在浏览PDF页面时,如果页面的显示内容大于窗口的显示区域,为了能看到其他的内容,就需要通过滚动条来移动页面查看PDF页面的内容,这个时候PDF浏览应用就需要调用render(渲染函数)来重新渲染在窗口中的部分PDF的对象,而对于某些文件,其PDF对象比较复杂,渲染复杂PDF对象需要花费比较多的时间,因而在浏览PDF页面时会出现显示不流畅、有卡顿的现象。
Adobe Acrobat应用(由Adobe公司开发的一款PDF(Portable Document Format,便携式文档格式)编辑软件)在第一次渲染时也存在较慢的现象,因而其会将渲染过的区域结果缓存,再次显示该区域时速率会提高,但是缓存过多也会影响再次渲染的效率,如何将PDF页面进行渲染缓存以提高浏览PDF页面时的刷新效率并减少卡顿情况的出现,是本领域技术人员所欲解决的问题。
发明内容
为了解决上述问题,本发明提供一种PDF页面渲染缓存的方法,通过评估PDF页面渲染的结果是否需要缓存,如果缓存了对应区域的图片,在后续屏幕刷新的过程中,就可以利用缓存的图像进行自动拼接,以大幅提高已经渲染过的内容再次显示时屏幕刷新速度。
为了达到上述目的,本发明提供了一种PDF页面渲染缓存的方法,其包括:
步骤S1:将整个PDF页面均匀划分为多个固定区块;
步骤S2:在首次加载页面时对待显示部分进行第一次渲染,并将渲染结果区域与能够相交的每一固定区块进行比对,若渲染结果区域与任一固定区块相交的宽度等于对应固定区块的宽度,则将此固定区块内的渲染结果添加到该固定区块的缓存列表中;
步骤S3:当页面需要进行再次渲染时,遍历检查存储在每个固定区块的缓存列表,若需要进行渲染的区域与已经缓存的区域存在相交区域,则调用render函数对相交区域以外的区域进行渲染,并将本次渲染的区域与相交区域拼接输出本次渲染结果;
步骤S4:检查在步骤S3中渲染的区域与能够相交的每一固定区块,若在步骤S3中渲染的区域与任一固定区块相交的宽度等于对应固定区块宽度,则将此固定区块内的渲染结果添加到该固定区块的缓存列表中;
步骤S5:重复步骤S3和S4直至渲染结束。
在本发明一实施例中,其中,步骤S2中将本次渲染的区域与相交区域拼接具体为采用位图的Transform方法。
在本发明一实施例中,其中,缓存列表的更新逻辑具体为:
将所有缓存的已渲染区域中的“分辨率+旋转角度”作为第一个维度的分组标识,对相同分辨率和旋转角度的一组缓存数据中再将“渲染时间”作为第二维度的分组标识;
且在缓存池设置阈值,当缓存池整体数据的大小达到阈值或者在应用层设置需要释放指定大小缓存的情况下,先根据第一维度的分组标识结合LRU原则进行释放,若当前缓存的已渲染区域均为相同的分辨率和旋转角度,则根据每块已渲染区域的渲染耗时优先释放耗时小的已渲染区域,其中,渲染耗时为此区域从开始进行渲染到渲染完成所用的时间。
在本发明一实施例中,其中,多个固定区块为九个固定区块,分布为九宫格形式。
本发明提供的PDF页面渲染缓存的方法,与现有技术相比,在浏览PDF页面时,通过判断每个固定区块需要缓存的渲染区域以减小后续需要渲染的页面区域的大小,能够提高PDF页面的渲染效率,从而减少浏览PDF页面时卡顿情况的发生。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1A~图1C为本发明一实施例的初始方案示意图;
图2为本发明一实施例的改进方案示意图;
图3为本发明一实施例的流程图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有付出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
图1A~图1C为本发明一实施例的初始方案示意图,如图1A~图1C,本实施例初始方案提供一种PDF页面渲染缓存的方法,其首先不固定划分缓存区域,每次对PDF页面渲染结束后,将客户端(device)上的渲染结果与缓存中的结果进行比并对求出多个相交区域,对于未相交的区域作为新渲染(render)区域,其余区域使用缓存中已保存的结果,通过位图(Bitmap)的Transform(改变原始资源图片在客户端上最终的展现结果的函数)的方法拼接出当前要渲染的最终显示结果。其中,本次新渲染出的位图(Bitmap)还需要分割整理,然后作为新缓存对象添加到缓存列表中,其具体包括以下过程:
S1:在缓存为空时对PDF页面进行第一次渲染,由于进行首次渲染之前,缓存为空,因此只需将渲染结果按一个区域添加到缓存中,即将图1A中的第一次渲染的A区域添加到缓存中;
S2:滚动页面后进行第二次渲染,由于此时的缓存中已有第一次渲染的A区域,第二次需要渲染的区域不同于第一渲染的区域,第二次需要渲染的是图1B中的B区域,如图1B所示,第一次渲染的A区域与第二次需要渲染的B区域存在相交部分,即图中的3号区域,因此在进行第二次渲染时,需要先求出第二次需要渲染的区域(B区域)与第一次渲染的区域(A区域)的相交区域(3号区域),并从缓存中取出相交区域(此部分不需要再次渲染,直接读取即可),对没有相交的区域进行第二次渲染(1、2号区域),然后将本次渲染的结果与取出的相交区域拼接为第二次渲染结果,即整个B区域;
S3:将进行第二次渲染的区域(1、2号区域)重新整理划分为规则的矩形部分(1、2号两个区域),并将划分后的每个矩形部分作为一个元素添加到缓存列表中;
S4:页面滚动后进行第三次渲染,此时缓存中已有第一次渲染的A区域和第二次渲染的B区域中的1、2号区域,且第二次渲染的区域已被划分为两个矩形部分 (1、2号两个区域)保存在缓存列表,而第三次需要渲染的是图1C中的C区域,因此需要先求出整个C区域与缓存中的所有已缓存区域(A区域与B区域)存在的相交区域(1、2、3号区域),再分别从缓存中取出相交区域(1、2、3号区域),并对整个C区域中没有相交部分进行第三次渲染,最后将渲染的结果与相交区域(1、2、3号区域)拼接为第三次渲染结果,即整个C区域;
S5:将第三次渲染的区域重新整理后,规则划分为几个矩形部分(4、5号两个区域),并分别添加到缓存列表中;
S6:在页面滚动后重复步骤S4~S5对页面继续进行渲染与缓存。
由于通常缓存池是有大小限制的,在不断渲染并缓存已渲染区域的过程中可能会出现缓存池满的情况,因此缓存列表需要更新,在本实施例中,其中,缓存列表的更新逻辑具体为:
将所有缓存的已渲染区域中的“分辨率+旋转角度”作为第一个维度的分组标识,对相同分辨率和旋转角度的一组缓存数据中再将“渲染时间”作为第二维度的分组标识,其中,“分辨率+旋转角度”主要是用来进行缓存图像的索引,例如同一个页面,100%显示缓存的图像和150%显示缓存的图像是不同的,页面是否旋转角度或旋转角度不同的页面显示缓存的图像也是不同的;
且在缓存池设置阈值,当缓存池整体数据的大小达到阈值或者在应用层设置需要释放指定大小缓存的情况下,优先根据第一维度的分组标识即“分辨率+旋转角度”结合LRU原则(Least Recently Used,即最近最久未使用的)进行释放,若当前缓存的已渲染区域均为相同的分辨率和旋转角度,则根据每块已渲染区域的渲染耗时优先释放耗时小的已渲染区域,其中,渲染耗时为此区域从开始进行渲染到渲染完成所用的时间。
前述初始方案中由于缓存列表更适用于存放矩形区域以方便后续缓存的使用,所以当需要进行新渲染的区域存在不规则的情况时,则需要将不规则的区域整理划分为规则的矩形,而这种划分整理的处理过程存在以下两方面的问题:
一方面当需要划分的区域为比较复杂的不规则形状,划分过程较为复杂,且很容易划分出特别小的区域块,因此会出现实现的过程较为复杂且影响整体渲染与缓存的效率的问题;
另一方面,由于需要每次进行新渲染的区域只需进行一次渲染(render),而对不规则区域进行划分时可能难以精准的获取每个小区域的对应区域渲染的耗时,因此在实现上述的缓存更新逻辑时可能会存在不易实现的障碍或耗时不准确影响 缓存列表的更新;
因此,针对前述初始方案进行改进以得到本实施的最终方案,即首先将整个页面划分为多个固定区块(如:九宫格形式),再将每个固定区块作为一个缓存管理的最小单元,在更新这个固定区块的缓存列表时,仅针对与这个固定区块相交且相交区域的宽度与固定区块宽度相同的情况下再进行保存。
图2为本发明一实施例的改进方案示意图,图3为本发明一实施例的流程图,如图2和图3所示,本实施例提供一种PDF页面渲染缓存的方法,具体包括:
步骤S1:将整个PDF页面均匀划分为多个固定区块;
在本实施例中,其中,多个固定区块为九个固定区块,分布为九宫格形式。在其他实施例中,也可以均匀划分六个固定区块、八个固定区块等,本发明不对其均匀划分固定区块的数量进行限定。
步骤S2:在首次加载页面时对待显示部分进行第一次渲染,并将渲染结果区域与能够相交的每一固定区块进行比对,若渲染结果区域与任一固定区块相交的宽度等于对应固定区块的宽度,则将此固定区块内的渲染结果添加到该固定区块的缓存列表中;
如图2所示,进行第一次渲染的区域为图2中浅灰色框的区域,对应按照九宫格划分的九个固定区块,第一次渲染的区域与第一行第一列的固定区块相交(区域1)的宽度等于该固定区块宽度,第一次渲染的区域与第二行第一列的固定区块相交(区域2)的宽度也等于该固定区块宽度,即区域1和区域2为整行填充,则将区域1和区域2添加到各自所属固定区块(第一行第一列的固定区块和第二行第一列的固定区块)的缓存列表中;
步骤S3:当页面需要进行再次渲染时,遍历检查存储在每个固定区块的缓存列表,若需要进行渲染的区域与已经缓存的区域存在相交区域,则调用render函数对相交区域以外的区域进行渲染,从对应缓存列表中取出相交区域,并将本次渲染的区域与相交区域拼接输出本次渲染结果,用于在应用中显示;
如图2所示,若需要进行第二次渲染(深灰色框的区域),先遍历检查存储在各个固定区块的缓存列表,可以发现本次需要渲染的区域(深灰色框的区域)与已经缓存的区域(第一行第一列的固定区块和第二行第一列的固定区块)存在相交区域(区域3和4),则调用一次render函数渲染出除相交区域(区域3和4)以外的区域,此时区域3和4的数据能够很快从1和2缓存的数据中获取,然后将新渲染的区域与相交区域(区域3和4)拼接出第二次渲染结果,这样就可以提高第二 次渲染的效率。
在本实施例中,其中,步骤S2中将本次渲染的区域与相交区域拼接具体为采用位图(Bitmap)的Transform(改变原始资源图片在客户端上最终的展现结果的函数)的方法。
步骤S4:检查在步骤S3中渲染的区域与能够相交的每一固定区块,若在步骤S3中渲染的区域与任一固定区块相交的宽度等于对应固定区块宽度,则将此固定区块内的渲染结果添加到该固定区块的缓存列表中;
如图2所示,第二次渲染的区域分别与第一行第二列的固定区块、第二行第二列的固定区块及第三行第二列的固定区块相交,且相交的区域5、6和7的宽度与对应固定区块的宽度相等,因此,分别将区域5、6和7在第二次渲染时的渲染结果添加到所属固定区块(第一行第二列的固定区块、第二行第二列的固定区块及第三行第二列的固定区块)的缓存列表中,以用于后续渲染。
步骤S5:重复步骤S3和S4直至渲染结束。
由于通常缓存池是有大小限制的,在不断渲染并缓存已渲染区域的过程中可能会出现缓存池满的情况,因此缓存列表需要更新,在本实施例中,其中,缓存列表的更新逻辑可以与初始方案相同,即具体为:
将所有缓存的已渲染区域中的“分辨率+旋转角度”作为第一个维度的分组标识,对相同分辨率和旋转角度的一组缓存数据中再将“渲染时间”作为第二维度的分组标识;
且在缓存池设置阈值,当缓存池整体数据的大小达到阈值或者在应用层设置需要释放指定大小缓存的情况下,先根据第一维度的分组标识结合LRU原则进行释放,若当前缓存的已渲染区域均为相同的分辨率和旋转角度,则根据每块已渲染区域的渲染耗时优先释放耗时小的已渲染区域,其中,渲染耗时为此区域从开始进行渲染到渲染完成所用的时间。
本实施例的改进方案相比于初始方案,不需要在执行更新不规则区域到缓存列表时的复杂处理过程,且由于每个固定区块都要求填充满整行(即渲染区域相交的宽度与固定区块的宽度相等)才进行缓存,因此每个固定区块的缓存管理较为简单。
本发明提供的PDF页面渲染缓存的方法,与现有技术相比,在浏览PDF页面时,通过判断每个固定区块需要缓存的渲染区域以减小后续需要渲染的页面区域的大小,能够提高PDF页面的渲染效率,从而减少浏览PDF页面时卡顿情况的发生。
本领域普通技术人员可以理解:附图只是一个实施例的示意图,附图中的模块 或流程并不一定是实施本发明所必须的。
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明实施例技术方案的精神和范围。

Claims (4)

  1. 一种PDF页面渲染缓存的方法,其特征在于,包括:
    步骤S1:将整个PDF页面均匀划分为多个固定区块;
    步骤S2:在首次加载页面时对待显示部分进行第一次渲染,并将渲染结果区域与能够相交的每一固定区块进行比对,若渲染结果区域与任一固定区块相交的宽度等于对应固定区块的宽度,则将此固定区块内的渲染结果添加到该固定区块的缓存列表中;
    步骤S3:当页面需要进行再次渲染时,遍历检查存储在每个固定区块的缓存列表,若需要进行渲染的区域与已经缓存的区域存在相交区域,则调用render函数对相交区域以外的区域进行渲染,并将本次渲染的区域与相交区域拼接输出本次渲染结果;
    步骤S4:检查在步骤S3中渲染的区域与能够相交的每一固定区块,若在步骤S3中渲染的区域与任一固定区块相交的宽度等于对应固定区块宽度,则将此固定区块内的渲染结果添加到该固定区块的缓存列表中;
    步骤S5:重复步骤S3和S4直至渲染结束。
  2. 根据权利要求1所述的PDF页面渲染缓存的方法,其特征在于,步骤S2中将本次渲染的区域与相交区域拼接具体为采用位图的Transform方法。
  3. 根据权利要求1所述的PDF页面渲染缓存的方法,其特征在于,缓存列表的更新逻辑具体为:
    将所有缓存的已渲染区域中的“分辨率+旋转角度”作为第一个维度的分组标识,对相同分辨率和旋转角度的一组缓存数据中再将“渲染时间”作为第二维度的分组标识;
    且在缓存池设置阈值,当缓存池整体数据的大小达到阈值或者在应用层设置需要释放指定大小缓存的情况下,先根据第一维度的分组标识结合LRU原则进行释放,若当前缓存的已渲染区域均为相同的分辨率和旋转角度,则根据每块已渲染区域的渲染耗时优先释放耗时小的已渲染区域,其中,渲染耗时为此区域从开始进行渲染到渲染完成所用的时间。
  4. 根据权利要求1所述的PDF页面渲染缓存的方法,其特征在于,多个固定区块为九个固定区块,分布为九宫格形式。
PCT/CN2023/111980 2022-09-06 2023-08-09 一种pdf页面渲染缓存的方法 WO2024051433A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211085881.2A CN117709296A (zh) 2022-09-06 2022-09-06 一种pdf页面渲染缓存的方法
CN202211085881.2 2022-09-06

Publications (2)

Publication Number Publication Date
WO2024051433A1 WO2024051433A1 (zh) 2024-03-14
WO2024051433A9 true WO2024051433A9 (zh) 2024-06-06

Family

ID=90159341

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/111980 WO2024051433A1 (zh) 2022-09-06 2023-08-09 一种pdf页面渲染缓存的方法

Country Status (2)

Country Link
CN (1) CN117709296A (zh)
WO (1) WO2024051433A1 (zh)

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104519081A (zh) * 2013-09-27 2015-04-15 阿里巴巴集团控股有限公司 一种页面访问的方法和装置
CN105335364B (zh) * 2014-05-29 2017-03-08 优视科技有限公司 一种实现视图滑动显示加速的方法及装置
US10095669B1 (en) * 2015-12-22 2018-10-09 Amazon Technologies, Inc. Virtualized rendering
CN112784188B (zh) * 2019-11-07 2022-09-13 武汉金山办公软件有限公司 一种页面渲染方法及装置
CN112836152B (zh) * 2019-11-22 2023-03-10 上海哔哩哔哩科技有限公司 页面渲染方法、系统、计算机设备及计算机可读存储介质
CN114356479B (zh) * 2021-12-27 2024-03-08 珠海豹趣科技有限公司 一种页面渲染方法及装置

Also Published As

Publication number Publication date
CN117709296A (zh) 2024-03-15
WO2024051433A1 (zh) 2024-03-14

Similar Documents

Publication Publication Date Title
WO2021248705A1 (zh) 图像渲染方法、装置、计算机程序和可读介质
JP7201802B2 (ja) 3次元画像処理におけるデータの読み書き方法とシステム、記憶媒体及び端末
DE102020112826A1 (de) Verfahren zur effizienten durchführung von datenreduktionen in parallelverarbeitungseinheiten
CN105550246A (zh) Android平台下加载网络图片的系统及方法
EP4172860A1 (en) Systems and methods for automatic alignment of drawings
WO2024051433A9 (zh) 一种pdf页面渲染缓存的方法
CN114021394B (zh) 一种倾斜摄影模型优化方法及装置
US20240004615A1 (en) Convolution operation method and apparatus, matrix decompression device, and graphics processor
CN113392246A (zh) 一种图纸显示方法、装置、存储介质和电子设备
EP4084491B1 (en) Dividing an astc texture to a set of sub-images
CN112784188B (zh) 一种页面渲染方法及装置
KR100853912B1 (ko) 초기 메모리에 저장된 화상 데이타를 처리하는 방법, 컴퓨터 판독가능 기록매체 및 장치
US9715715B2 (en) Efficient cache preloading
DE102021105247A1 (de) Techniken zum effizienten organisieren und zugreifen auf komprimierbare daten
CN111192339B (zh) 地理位置数据的渲染方法及装置
CN113608724A (zh) 一种基于模型缓存实现的离线仓库实时交互方法与系统
CN117576249B (zh) 一种芯片版图数据处理方法及装置
US20230137502A1 (en) Method, device for processing feature image and storage medium
US20240127524A1 (en) Method and system for processing graphics in tile-based rendering mode
CN115952139B (zh) 一种移动设备多帧三维图像处理方法及系统
CN118115350A (zh) 椭圆弧实时平滑绘制优化方法、装置、电子设备及介质
CN116861867A (zh) React Native组件构建复杂表格的优化方法和装置
CN118193875A (zh) 页面加载方法、装置、电子设备及存储介质
CN117830502A (zh) 一种三维模型的构建方法和装置
CN117671109A (zh) 一种渲染优化方法、装置、设备以及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23862131

Country of ref document: EP

Kind code of ref document: A1