Search

CN-122023630-A - Flutter cross-platform picture rendering method, device and system based on FFI and external texture fusion

CN122023630ACN 122023630 ACN122023630 ACN 122023630ACN-122023630-A

Abstract

The invention relates to the technical field of picture rendering and discloses a Flutter cross-platform picture rendering method, device and system based on FFI and external texture fusion, wherein the method comprises the steps of obtaining request parameters of a picture to be rendered through a preset Flutter user interaction layer; determining a rendering path matched with a picture to be rendered according to a request parameter, sending a rendering data request to a native layer corresponding to the picture to be rendered through a preset cross-platform communication layer, enabling a Flutter user interaction layer to acquire the picture to be rendered, returning image rendering data of the picture to be rendered to a Flutter user interaction layer through the native layer and the rendering path, and rendering the picture to be rendered according to the image rendering data through a Flutter user interaction layer to obtain a rendered picture. Therefore, the method and the device can integrate the original network picture library, effectively improve the picture rendering and loading speed in a weak network environment, and simultaneously, effectively save the flow and reduce the server pressure by utilizing the multi-level cache strategy of the original picture library.

Inventors

  • LIU BIN
  • Yi Qibang
  • LV XUMING
  • LI YUNXIN

Assignees

  • 深圳市绿联科技股份有限公司

Dates

Publication Date
20260512
Application Date
20251212

Claims (11)

  1. 1. The Flutter cross-platform picture rendering method based on FFI and external texture fusion is applied to terminal equipment provided with Flutter user interaction layers and can be in communication connection with network additional storage equipment, and is characterized by comprising the following steps: Acquiring request parameters of a picture to be rendered through the Flutter user interaction layer, wherein the request parameters comprise position identification parameters, configuration parameters and rendering requirement parameters; determining a rendering path matched with the picture to be rendered according to the request parameter, wherein the rendering path comprises an FFI rendering path or an external texture rendering path; Sending a rendering data request to a native layer corresponding to the picture to be rendered through a preset cross-platform communication layer, so that the Flutter user interaction layer obtains the picture to be rendered, and returning image rendering data of the picture to be rendered to the Flutter user interaction layer through the native layer and the rendering path; and rendering the picture to be rendered according to the image rendering data through the Flutter user interaction layer to obtain a rendered picture.
  2. 2. The Flutter cross-platform picture rendering method based on the FFI and external texture fusion according to claim 1, wherein the sending, by a preset cross-platform communication layer, a rendering data request to a native layer corresponding to the picture to be rendered, so that the Flutter user interaction layer obtains the picture to be rendered includes: Sending a rendering data request to a native layer corresponding to the picture to be rendered through a preset cross-platform communication layer; Performing storage detection operation on a target native picture loading library by the native layer according to the rendering data request to obtain a storage detection result of the picture to be rendered; when the storage detection result indicates that the picture to be rendered does not exist in the target original picture loading library, downloading the picture to be rendered by the original layer according to the position identification parameter, and caching the picture to be rendered into the target original picture loading library, so that the Flutter user interaction layer accesses the target original picture loading library to acquire the picture to be rendered; when the storage detection result indicates that the picture to be rendered exists in the target original picture loading library, the Flutter user interaction layer directly accesses the target original picture loading library to obtain the picture to be rendered.
  3. 3. The Flutter cross-platform picture rendering method based on the FFI and external texture fusion according to claim 2, wherein the performing, by the native layer, a storage detection operation on a target native picture loading library according to the rendering data request to obtain a storage detection result of the picture to be rendered includes: when the native operating system of the native layer is an iOS operating system, performing storage detection operation on a first memory cache space and a first disk cache space corresponding to an iOS native picture loading library by the native layer according to the rendering data request to obtain a storage detection result of the picture to be rendered; When the native operating system of the native layer is an Android operating system, the native layer performs storage detection operation on the active resource storage space, the second memory cache space and the second disk cache space corresponding to the Android native picture loading library according to the rendering data request, and a storage detection result of the picture to be rendered is obtained.
  4. 4. A method of Flutter cross-platform picture rendering based on FFI and external texture fusion as claimed in any one of claims 1 to 3, wherein the returning image rendering data of the picture to be rendered to the Flutter user interaction layer through the native layer and the rendering path includes: When the rendering path comprises the FFI rendering path, acquiring a memory address and picture meta information of the picture to be rendered by the native layer, and returning the memory address and the picture meta information of the picture to be rendered to the Flutter user interaction layer through the cross-platform communication layer, wherein the picture meta information comprises at least one of memory length information, line byte number information and pixel format information; When the rendering path comprises the external texture rendering path, determining target texture parameters matched with the picture to be rendered from a preset texture processing library by the native layer, and determining basic information of the picture to be rendered so as to return the target texture parameters and the basic information to the Flutter user interaction layer, wherein the basic information comprises at least one of size information, color information and shape information.
  5. 5. A Flutter cross-platform picture rendering method based on FFI and circumscribed texture fusion as claimed in claim 2 or 3, the method further comprising: Monitoring a release event of a picture cache space corresponding to the Flutter user interaction layer through a preset cache expansion assembly; when the release event is monitored, a resource release instruction is sent to the original layer through the cross-platform communication layer, wherein the resource release instruction carries a position identification parameter of a picture to be released, which is associated with the release event; And releasing target resources corresponding to the pictures to be released in the target original picture loading library by the original layer according to the resource release instruction, wherein the target resources comprise picture cache resources and picture texture resources.
  6. 6. A Flutter cross-platform picture rendering method based on FFI and circumscribed texture fusion as claimed in any one of claims 1 to 3, the method further comprising: Determining definition parameters of a non-standard picture type corresponding to the native layer, so that the native layer registers a custom loader matched with the definition parameters of the non-standard picture type into a unified loading manager according to the definition parameters of the non-standard picture type; And sending a loading parameter of the picture to be loaded to the native layer through the Flutter user interaction layer, so that the native layer determines a target custom loader matched with the loading parameter from the unified loading manager according to the loading parameter, loading the picture to be loaded through the target custom loader, and returning the picture to be loaded to the Flutter user interaction layer, wherein the loading parameter comprises a loading identification parameter.
  7. 7. A method for rendering Flutter cross-platform pictures based on FFI and external texture fusion according to any one of claims 1-3, wherein determining a rendering path matching the picture to be rendered according to the request parameters includes: determining display scene parameters corresponding to the picture to be rendered; Determining the processing mode parameters of the picture to be rendered according to the request parameters and the display scene parameters; determining the processing type of the picture to be rendered according to the processing mode parameters, and judging whether the processing type is a preset special processing type or not; When the judgment result is yes, determining that the rendering path matched with the picture to be rendered comprises an FFI rendering path; and when the judging result is negative, determining that the rendering path matched with the picture to be rendered comprises an external texture rendering path.
  8. 8. Flutter cross-platform picture rendering device based on FFI and external texture fusion, wherein the device is applied to terminal equipment provided with Flutter user interaction layers and can be in communication connection with network additional storage equipment, and the device is characterized by comprising: the parameter acquisition module is used for acquiring request parameters of the picture to be rendered through the Flutter user interaction layer, wherein the request parameters comprise position identification parameters, configuration parameters and rendering requirement parameters; the determining module is used for determining a rendering path matched with the picture to be rendered according to the request parameter, wherein the rendering path comprises an FFI rendering path or an external texture rendering path; The data acquisition module is used for sending a rendering data request to a native layer corresponding to the picture to be rendered through a preset cross-platform communication layer, so that the Flutter user interaction layer acquires the picture to be rendered, and returning image rendering data of the picture to be rendered to the Flutter user interaction layer through the native layer and the rendering path; And the rendering module is used for rendering the picture to be rendered according to the Flutter user interaction layers and the image rendering data to obtain a rendered picture.
  9. 9. A terminal device, characterized in that the terminal device comprises: a memory storing executable program code; a processor coupled to the memory; The processor invokes the executable program code stored in the memory to perform the Flutter cross-platform picture rendering method based on FFI and external texture fusion as claimed in any one of claims 1-7.
  10. 10. A computer storage medium storing computer instructions for performing the FFI and external texture fusion-based Flutter cross-platform picture rendering method as claimed in any one of claims 1 to 7 when invoked.
  11. 11. A Flutter cross-platform picture rendering system based on FFI and external texture fusion is characterized in that the system comprises a Flutter cross-platform picture rendering device based on FFI and external texture fusion as set forth in claim 8 and a network additional storage device in communication connection with the device, or The system comprises a terminal device as claimed in claim 9, and a network attached storage device in communicative connection with the terminal device.

Description

Flutter cross-platform picture rendering method, device and system based on FFI and external texture fusion Technical Field The invention relates to the technical field of picture rendering, in particular to a Flutter cross-platform picture rendering method, device and system based on FFI and external texture fusion. Background In mobile application development, flutter frames are widely used for picture presentation scenes due to cross-platform consistency and efficient rendering characteristics. The original picture loading scheme takes NetworkImage as a core, realizes network picture loading through the HttpClient of Dart, and completes basic functions in cooperation with cached_network_image assistance. However, in a high concurrency picture loading scene, the scheme has obvious defects that firstly, network request performance is insufficient, the scheme depends on DARTHTTPCLIENT, high-level optimization such as HTTP/2 multiplexing and the like is lacked, loading is slow and success rate is low under a weak network or high concurrency scene, network capability is far less than AndroidGlide, iOSKingfisher, secondly, decoding and memory problems are outstanding, a Flutter built-in Skia decoder cannot be used, CPU occupation is high and memory peak value is large when large-scale or high-frequency decoding is carried out, thirdly, a buffer strategy is single, IMAGECACHE only supports LRU memory buffer, intelligent strategies such as no disk buffer and network state adaptation are provided, buffer hit rate is low, and flow and time are wasted through repeated downloading. Therefore, an efficient picture loading solution is needed. Disclosure of Invention The invention provides a Flutter cross-platform picture rendering method, device and system based on FFI and external texture fusion, which can integrate a primary network picture library, effectively improve picture rendering and loading speeds in a weak network environment, and simultaneously effectively save flow and reduce server pressure by utilizing a multi-level cache strategy of the primary picture library. In order to solve the technical problem, the first aspect of the present invention discloses a Flutter cross-platform picture rendering method based on the fusion of an FFI and an external texture, the method is applied to a terminal device installed with Flutter user interaction layer, and the terminal device can be in communication connection with a network additional storage device, wherein the method comprises: Acquiring request parameters of a picture to be rendered through the Flutter user interaction layer, wherein the request parameters comprise position identification parameters, configuration parameters and rendering requirement parameters; determining a rendering path matched with the picture to be rendered according to the request parameter, wherein the rendering path comprises an FFI rendering path or an external texture rendering path; Sending a rendering data request to a native layer corresponding to the picture to be rendered through a preset cross-platform communication layer, so that the Flutter user interaction layer obtains the picture to be rendered, and returning image rendering data of the picture to be rendered to the Flutter user interaction layer through the native layer and the rendering path; and rendering the picture to be rendered according to the image rendering data through the Flutter user interaction layer to obtain a rendered picture. In an optional implementation manner, in a first aspect of the present invention, the sending, by a preset cross-platform communication layer, a request for rendering data to a native layer corresponding to the picture to be rendered, so that the Flutter user interaction layer obtains the picture to be rendered includes: Sending a rendering data request to a native layer corresponding to the picture to be rendered through a preset cross-platform communication layer; Performing storage detection operation on a target native picture loading library by the native layer according to the rendering data request to obtain a storage detection result of the picture to be rendered; when the storage detection result indicates that the picture to be rendered does not exist in the target original picture loading library, downloading the picture to be rendered by the original layer according to the position identification parameter, and caching the picture to be rendered into the target original picture loading library, so that the Flutter user interaction layer accesses the target original picture loading library to acquire the picture to be rendered; when the storage detection result indicates that the picture to be rendered exists in the target original picture loading library, the Flutter user interaction layer directly accesses the target original picture loading library to obtain the picture to be rendered. In an optional implementation manner, in a first aspect of the present invention,