应用程序配置参考¶
您可以配置您的 Kanzi 应用程序:
在 C++ 应用程序中,重写应用程序类的
Application::onConfigure函数。Kanzi 在应用程序初始化的一部分中调用此函数,先于读取application.cfg和初始化图形子系统。使用此函数配置应用程序属性。在
application.cfg中,通过设置 Kanzi Studio 项目的参数,无需重新编译您的应用程序,甚至无需 C++ 应用程序。
您在 application.cfg 中指定的配置会覆盖您在 Application::onConfigure 中指定的配置。
设置要使用的 application.cfg¶
当您在一个目录中有多个 Kanzi 应用程序可执行文件时,您可以为每个可执行文件设置一个单独的配置文件。
要设置从命令行运行您的 Kanzi 应用程序时要使用的 application.cfg,请输入应用程序可执行文件的名称,后跟 -config 选项和配置文件的名称。
例如,要运行名为 MyApplication 的 Kanzi 应用程序并使用 myConfiguration.cfg 文件,使用
MyApplication.exe -config=myConfiguration.cfg
使用 application.cfg¶
要使用 application.cfg 配置您的 Kanzi 应用程序,请创建一个 application.cfg 文件,其中包含参数名称及其值。
如果您有一个没有 C++ 应用程序的 Kanzi Studio 项目,请参阅
<ProjectName>/Application Player。如果您有一个带有 C++ 应用程序的 Kanzi Studio 项目,请联系
<ProjectName>/Application/bin。
当您启动 Kanzi 应用程序时,应用程序使用 application.cfg 中的参数来配置您的应用程序。
application.cfg 的错误处理¶
如果 application.cfg 丢失或损坏,Kanzi 应用程序会记录相应的错误消息,并继续以默认设置运行。
如果您想实现自己的 application.cfg 错误处理,可以创建一个自定义记录器来检测此类错误。请参阅 创建自定义记录器。
在不读取 application.cfg 的情况下运行应用程序。¶
在某些嵌入式平台上,读取 application.cfg 文件可能会对性能产生影响。
要在不读取 application.cfg 文件的情况下运行应用程序,请在命令行中使用 -config="" 选项启动您的 Kanzi 应用程序。
例如,要运行名为 MyApplication 的 Kanzi 应用程序而不读取 application.cfg 文件,请使用
MyApplication.exe -config=""
加载¶
BinaryName¶
您可以设置当您启动 Kanzi 应用程序时,Kanzi 应用程序加载哪个 kzb 文件或 kzb 配置文件。
请参阅 kzb 文件。
在 |
|
||
|
|||
值 (Value) |
|
||
|
# Loads the kzb file named my_application.kzb.
BinaryName = "my_application.kzb"
# Loads the kzb configuration file my_application.kzb.cfg that lists
# all the kzb files that your Kanzi application loads.
BinaryName = "my_application.kzb.cfg"
|
||
// Loads the kzb file named my_application.kzb.
configuration.binaryName = "my_application.kzb";
// Loads the kzb configuration file my_application.kzb.cfg that lists
// all the kzb files that your Kanzi application loads.
configuration.binaryName = "my_application.kzb.cfg";
|
FontEngine¶
Kanzi 支持两种字体渲染后端:
FreeType 是 Kanzi 附带的基于开源软件的字体引擎。它适用于大多数常规用例,并支持多种字体格式。它使用 FreeType 光栅化器、HarfBuzz 字形整形器、ICU 双向库以及用于换行的 libunibreak。这是默认字体引擎。
iType 是基于商业软件的字体引擎,需要从 Monotype 单独获取许可证。它提供高级字体渲染功能和优化。它使用 Monotype iType 光栅化器,并使用 WorldType® Shaper™ 进行字形整形。请参阅 安装 iType 字体引擎。
您可以设置在应用程序启动时加载哪个字体引擎,用于渲染应用程序中的文本。您可以使用:
FreeType 使用 FreeType 字体引擎。
iType 使用 iType 字体引擎。
None 不加载字体引擎。当您不加载字体引擎时,Kanzi 不会在您的应用程序中渲染文本。
当加载字体引擎时,请记住:
在静态构建中,您必须将要加载的字体引擎静态链接到应用程序。
在动态构建中,Kanzi 加载字体引擎库。
您还可以设置要使用哪个字体引擎来渲染文本的 Kanzi Studio Preview。请参阅 为 Preview 设置字体引擎。
备注
iType 和 FreeType 字体引擎使用不同的渲染和字形整形算法。因此,文本渲染和布局可能会存在一些差异。在某些情况下,这些字体引擎还可能解析字体文件的不同部分。
如果您从一种 Font Engine 切换到另一种,可能需要更新或调整字体文件本身,以尽量减少或消除这些差异。
在 |
|
||
|
|||
值 |
|
||
|
# Load the iType font engine at application startup.
FontEngine = IType
|
||
// Load the iType font engine at application startup.
configuration.fontEngine = ApplicationProperties::FontEngine::IType;
|
字体引擎字典¶
您可以通过设置要使用的泰语词典来自定义 Kanzi iType 字体引擎在泰语文本中如何换行,而不是使用内置于 iType 字体引擎中的词典。
请参阅 使用 iType 字体引擎自定义泰文文本中的自动换行功能。。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Set additional backend dictionaries.
ITypeDictionaryUrls = file:///usr/share/itype/thai-dictionary.wtd
|
||||
// Set additional backend dictionaries.
configuration.fontEngineDictionaryUrls[ApplicationProperties::FontEngine::IType] = "file:///usr/share/itype/thai-dictionary.wtd";
|
ModuleNames¶
当您启动 Kanzi 应用程序时,您可以设置 Kanzi 应用程序加载哪些插件。
在 |
|
||
|
|||
值 |
|
||
|
# Loads the plugin DLL files MyPlugin1.dll and MyPlugin2.dll.
ModuleNames = "MyPlugin1; MyPlugin2"
|
||
// Loads the plugin DLL files MyPlugin1.dll and MyPlugin2.dll.
configuration.moduleNames = {"MyPlugin1", "MyPlugin2"};
|
DeploymentQueueBudget¶
Kanzi 保持一个在 UI 线程上部署的资源队列。使用 DeploymentQueueBudget 来控制 Kanzi 每帧花费的时间以部署资源。当部署队列中有许多小资源时,时间预算大于 0 可以显著减少加载应用程序资源的时间。
时间预算并未对每帧资源部署所花费的总时间设置硬性限制。一个长时间运行的部署任务可能会超过分配的时间。
当设置为默认值 0 毫秒时,Kanzi 每帧仅从资源部署队列中部署一个资源。
请参阅 在 UI 响应性和资源加载之间取得平衡。
在 |
|
||
|
|||
值 |
|
||
|
# Each frame Kanzi spends up to 2 milliseconds to deploy resources.
# Kanzi keeps deploying resources until it spends the allocated time budget
# for that frame.
DeploymentQueueBudget = 2
|
||
// Each frame Kanzi spends up to 2 milliseconds to deploy resources.
// Kanzi keeps deploying resources until it spends the allocated time budget
// for that frame.
configuration.deploymentQueueBudget = 2;
|
LoadingThreadCount¶
当用户在具有多核处理器的环境中运行您的 Kanzi 应用程序时,Kanzi 会自动使用多个 CPU 核心将 kzb 文件中的 GPU 资源加载到 RAM 中。
请参阅 并行加载资源。
Kanzi 并行加载的 GPU 资源包括所有类型的纹理、着色器和网格。要将这些资源从 RAM 部署到 GPU 内存并加载预设模板,Kanzi 始终使用主线程。请参阅 图像和纹理最佳实践、着色器最佳实践、网格最佳实践。
在 |
|
||
|
|||
值 |
|
||
|
# Switches off the use of multiple cores for loading your application.
# Loads your application resources using the main thread.
LoadingThreadCount = 0
# Uses six threads to load your application.
LoadingThreadCount = 5
|
||
// Switches off the use of multiple cores for loading your application.
// Loads your application resources using the main thread.
configuration.loadingThreadCount = 0;
// Uses six threads to load your application.
configuration.loadingThreadCount = 5;
|
MaxPendingResources¶
您可以设置加载线程同时处理的最大资源数量。通过增加资源数量,您可以加快加载速度,但同时也会增加加载期间的内存峰值使用量,因为您可以在将资源部署到GPU之前将更多资源加载到内存中。
在 |
|
||
|
|||
值 |
|
||
|
# Sets the maximum number of resources processed by the loading
# threads to the number of loading threads + 1. This is the default value.
MaxPendingResources = 0
# Sets the maximum number of resources processed by the loading
# threads to 20 resources.
MaxPendingResources = 20
|
||
// Sets the maximum number of resources processed by the loading
// threads to the number of loading threads + 1. This is the default value.
configuration.maxPendingResources = 0;
// Sets the maximum number of resources processed by the loading
// threads to 20 resources.
configuration.maxPendingResources = 20;
|
性能¶
ApplicationIdleState¶
Kanzi 在没有输入、任务、计时器、动画,或应用程序中没有任何更新渲染的内容时暂停主循环。
请参阅 应用程序空闲状态。
当使用应用程序空闲状态时,请考虑:
如果您的 Kanzi 应用程序正在显示动画,Kanzi 默认情况下将 CPU 节流到最大 FPS。如果没有动画,Kanzi 会将应用程序设置为空闲状态。出于这个原因,为了节省 CPU 和电力,Kanzi 默认情况下将最大帧率限制为每秒 60 帧。使用应用程序配置来设置应用程序的最大帧率。
请参阅 MaximumFPS。
如果您的应用程序依赖于持续执行某些主循环任务,例如您添加到主循环
UserStage的功能,请禁用空闲状态。当您的应用程序处于空闲状态并且应用程序对渲染通道树进行更改时,Kanzi 不会触发渲染来呈现更改。要在这种情况下渲染更改,您必须通过在任何节点上调用
Node::invalidateDraw函数手动触发渲染。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Disables the application idle state.
ApplicationIdleState = 0
|
||||
// Disables the application idle state.
configuration.applicationIdleStateEnabled = 0;
|
MaximumFPS¶
您可以设置最高帧速率,以限制每秒渲染帧数。
如果您的 Kanzi 应用程序正在显示动画,Kanzi 默认情况下将 CPU 节流到最大 FPS。如果没有动画,Kanzi 会将应用程序设置为空闲状态。出于这个原因,为了节省 CPU 和电力,Kanzi 默认情况下将最大帧率限制为每秒 60 帧。使用应用程序配置来设置应用程序的最大帧率。
请参阅 PerformanceInfoLevel。
在 |
|
||
|
|||
值 (Value) |
|
||
|
# Sets the maximum application frame rate to 32 frames per second.
MaximumFPS = 32
# Disables the limit.
MaximumFPS = 0
|
||
// Sets the maximum application frame rate to 32 frames per second.
configuration.frameRateLimit = 32;
// Disables the limit.
configuration.frameRateLimit = 0;
|
PerformanceInfoLevel¶
您可以启用显示 Performance HUD 的功能,以显示您的 Kanzi 应用程序的性能信息。使用 Performance HUD 查看您的应用程序在目标设备上的性能表现,并找出性能瓶颈。
Performance HUD 显示了您的 Kanzi 应用程序的此性能信息:
FPS 显示每秒渲染的帧数。
Last Frame 显示了上一帧的此信息:
Main Loop Counter 显示了 Kanzi 主循环运行的次数。
Time 显示渲染帧所需的时间(以毫秒为单位)。
Batch Count 显示了执行了多少个单独的绘制调用(
glDrawElements和glDrawArrays)。您可以通过调用
Renderer::getBatchCount使用 Kanzi Engine API 访问批处理计数。Triangle Count 显示在一帧中总共绘制了多少个独立的三角形。
您可以通过调用
Renderer::getTriangleCount在 Kanzi Engine API 中访问三角形计数。Texture Switches 显示了新纹理绑定到 GPU 的次数。
您可以通过调用
Renderer::getTextureSwitchCount在 Kanzi Engine API 中访问纹理切换计数。FBO Switches 显示绑定到 GPU 的帧缓冲对象的数量。请参阅 渲染最佳实践。
您可以通过调用
Renderer::getFramebufferSwitchCount在 Kanzi Engine API 中访问缓冲区切换计数。Timeline Clock 显示了执行应用程序中所有动画所花费的时间(以毫秒为单位)。
Shader 显示了为新应用的批次绑定新着色器的次数以及为上一帧发送的单个着色器统一变量的数量。请参阅 减少着色器切换。
您可以通过调用
Renderer::getShaderSwitchCount在 Kanzi Engine API 中访问着色器切换计数。您可以通过调用
Renderer::getUniformSendCount来访问在 Kanzi Engine API 中发送的 uniforms。Resource Memory Use 显示您的 Kanzi 应用程序使用的本地 GPU 内存 (VRAM) 和非本地 GPU 内存 (RAM) 的估计量。
Performance HUD 在 Kanzi Studio Preview 中显示的值与您在目标设备上运行 Kanzi 应用程序时的值不同,因为 Kanzi Studio 会加载并在内存中保留应用程序中的所有资源。
Timer subscriptions 显示了
MessageDispatcher中注册的计时器处理程序的数量。过多的计时器处理程序可能会降低应用程序的性能。您可以通过调用
getSubscriptionCount()在 Kanzi Engine API 中访问计时器订阅的数量。Animations 显示了您的 Kanzi 应用程序中活动动画和所有动画的数量。
您可以在 Kanzi Engine API 中访问动画的数量:
要获取活动中的动画数量,请使用
getActiveTimelinePlaybackCount()。要获取所有动画数量,请使用
getTimelinePlaybackCount()。
您可以在 Kanzi 应用程序的窗口内设置 Performance HUD 的位置。请参阅 性能信息位置。
请参阅 最佳实践。
在 |
|
||
|
|||
值 |
|
||
|
# Enables the full Performance HUD in a Kanzi application.
PerformanceInfoLevel = 2
|
||
// Enables the full Performance HUD in a Kanzi application.
configuration.performanceInfoLevel = ApplicationProperties::PerformanceInfoLevelFull;
|
性能信息位置¶
您可以在 Kanzi 应用程序的窗口内设置 Performance HUD 的位置。要在 Kanzi 应用程序的窗口中查看 Performance HUD,您必须启用它。请参阅 PerformanceInfoLevel。
在 |
|
||||
|
|||||
值 (Value) |
|
||||
|
# Position the Performance HUD 100 pixels from the left side and
# 20 pixels from the top of the Kanzi application window.
PerformanceInfoPositionX = 100
PerformanceInfoPositionY = 20
|
||||
// Position the Performance HUD 100 pixels from the left side and
// 20 pixels from the top of the Kanzi application window.
configuration.performanceInfoProperties.positionX = 100;
configuration.performanceInfoProperties.positionY = 20;
|
PerformanceInfoFontSize¶
您可以为 Performance HUD 设置字号。
在 |
|
||
|
|||
值 (Value) |
|
||
|
# The font size of the Performance HUD is 20
PerformanceInfoFontSize = 20
|
||
// The font size of the Performance HUD is 20
configuration.performanceInfoProperties.fontSize = 20;
|
PerformanceInfoGraphFilter¶
您可以选择要在 Performance HUD 中显示为图表的主循环任务。在 application.hpp 中,默认主循环任务的名称请参阅 Application::initializeMainLoopTasks() 的实现。要在 Kanzi 应用程序的窗口中查看 Performance HUD,您必须启用它。请参阅 PerformanceInfoLevel。
在 |
|
||
|
|||
值 (Value) |
|
||
|
# Enables graphs for tasks Render and MyCustomTask.
PerformanceInfoGraphFilter="Render;MyCustomTask"
|
||
// Enables graphs for tasks Render and MyCustomTask.
configuration.performanceInfoProperties.graphFilter="Render;MyCustomTask"
|
ProfilingCategoryFilter¶
您可以控制性能剖析类别的状态,它可用于对性能剖析程序进行分组。请参阅 测量应用程序性能 和 测量资源的加载和部署时间。
在 |
|
||||||||
|
|||||||||
值 |
用分号分隔类别状态对 (;)。 |
||||||||
|
# Enables the MyProfiler category and disables the MainLoopRendering category.
ProfilingCategoryFilter="MyProfiler=on;MainLoopRendering=off"
# Enables all performance profiling categories.
ProfilingCategoryFilter="*=on"
# Enables categories Generic and MyProfilingCategory.
ProfilingCategoryFilter="Generic|MyProfilingCategory=on"
# Enables resource profiling.
ProfilingCategoryFilter="ResourceLoading=on"
|
||||||||
# Enables the MyProfiler category and disables the MainLoopRendering category.
configuration.profilingCategoryFilter="MyProfiler=on;MainLoopRendering=off"
// Enables all performance profiling categories.
configuration.profilingCategoryFilter = "*=on";
// Enables categories Generic and MyProfilingCategory.
configuration.profilingCategoryFilter = "Generic|MyProfilingCategory=on";
// Enables resource profiling.
configuration.profilingCategoryFilter = "ResourceLoading=on";
|
此表列出了 Kanzi 启动性能分析类别和包含在 Profiling build 中的分析器。
类别 |
配置名称 |
剖析程序 |
|---|---|---|
应用程序初始化 |
|
|
默认资源注册 |
|
|
图像初始化 |
|
|
GL 子系统初始化 |
|
|
启动 kzb 文件打开 |
|
|
加载线程初始化 |
|
|
元数据注册 |
|
|
插件加载 |
|
|
预设件加载 |
|
|
预设件安装 |
|
|
预设件附加 |
|
|
渲染器重置 |
|
|
运行时资产注册 |
|
|
域初始化 |
|
|
|
||
|
主循环剖析样本缓冲区计数¶
您可以设置包含在 Profiling build 中的主循环性能分析器的样本缓冲区大小。请参阅 测量 Kanzi Engine 的性能 和 ProfilingCategoryFilter。
在 |
|
||
|
|||
值 |
|
||
|
# Sets the maximum number of samples in main loop performance profilers
# to 3600.
MainLoopProfilingSampleBufferCount = 3600
|
||
// Sets the maximum number of samples in main loop performance profilers
// to 3600.
configuration.mainLoopProfilingSampleBufferCount = 3600;
|
图形缓存纹理大小¶
使用 Text Block 时,Kanzi 会为每种字体和字体大小组合创建一个字形缓存纹理。您可以设置字形缓存纹理的高度和宽度,以便在字形缓存纹理已满时或为了优化 Kanzi 应用程序的性能来调整字形缓存纹理的大小。
因为较大的字形缓存纹理会使用更多的 VRAM,请在设置最终大小之前尝试不同的大小。字形缓存纹理大小的上限取决于 GPU,但通常为 2048 x 2048 像素。字形缓存纹理的默认大小为 512 x 512 像素。
Kanzi 将字形缓存纹理的大小应用于所有字形缓存纹理。
在 |
|
||
|
|||
值 |
|
||
|
# Sets the glyph cache texture height to 768, and width to 1024 pixels.
GlyphCacheHeight = 768
GlyphCacheWidth = 1024
|
||
// Sets the glyph cache texture height to 768, and width to 1024 pixels.
configuration.glyphCacheHeight = 768;
configuration.glyphCacheWidth = 1024;
|
优化¶
InitializePlatform 初始化平台¶
在 integrity_rcar_rwm_aarch64 平台上,您可以设置是否要初始化应用程序图形。仅当您想手动同步同时初始化的多个应用程序的启动时,才在后期优化阶段使用此方法。
该配置控制图形驱动器和设备窗口管理器的初始化,以及显示的开关。当您禁用此配置时,要使您的 Kanzi 应用程序能够创建窗口,在同一进程中您必须初始化:
PVRGrfxServerInit()R_WM_DevInit()(可选)
R_WM_DevInfoGet()(可选)
R_WM_ScreenBgColorSet()R_WM_ScreenEnable()显式设置应用程序窗口的宽度和高度。请参阅 应用程序窗口位置和大小。
当图形初始化和此配置均禁用时,必须单独初始化每一个已禁用此设置的应用程序的图形。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Disables the graphics initialization.
InitializePlatform = 0
|
||||
// Disables the graphics initialization.
configuration.defaultWindowProperties.initializePlatform = 0;
|
MultisamplePreference¶
您可以设置您希望 Kanzi 如何执行多重采样:从渲染缓冲区进行位块传输或隐式多重采样。
当从渲染缓冲区 Kanzi 进行位块传输时,首先渲染到多重采样渲染缓冲区中。渲染完成后,Kanzi 通过将结果位块传输到常规纹理中来解析样本。从渲染缓冲区进行位块传输需要以下之一:
您的平台支持 OpenGL (ES) 3 或更高版本。
GL_ARB_framebuffer_object 扩展可用。
GL_NV_framebuffer_blit 和 GL_NV_framebuffer_multisample 扩展可用。
隐式多重采样意味着 Kanzi 对纹理执行多重采样渲染,而不需要显式解析多重采样数据,即将数据降采样为每像素单个样本。隐式多重采样要求以下扩展之一可用:
GL_EXT_multisampled_render_to_texture
GL_IMG_multisampled_render_to_texture
默认情况下,Kanzi 选择其认为最佳的多重采样方法:
在桌面平台上,Kanzi 从渲染缓冲区进行 blit 操作。
在使用 OpenGL ES 的平台上,Kanzi 使用隐式多重采样。
请参阅 应用抗锯齿功能。
在 |
|
||
|
|||
值 |
|
||
|
# Uses implicit multisampling.
MultisamplePreference = Implicit
|
||
// Uses implicit multisampling.
configuration.multisamplePreference = Renderer::RendererSettings::MultisamplePreferenceImplicit;
|
MmapMode¶
在支持该功能的操作系统上,您可以设置 Kanzi 如何指示系统进行内存映射文件:
惰性映射会等待您的 Kanzi 应用程序访问文件内容,然后再映射该部分文件。
急切映射会立即映射整个文件。
应用程序在这两种策略之间的行为是相同的,但您可以选择何时支付映射文件的运行时成本。
默认情况下,Kanzi 使用系统的默认内存映射策略。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Uses lazy memory mapping.
MmapMode = lazy
|
||
// Uses lazy memory mapping.
configuration.mmapMode = MmapMode::Lazy;
|
GPU 资源¶
处理GPU资源¶
您可以设置您的 Kanzi 应用程序在暂停状态 (MainLoopState::Paused) 下如何处理未存储在 kzb 文件中的 GPU 资源。
在 |
|
||
|
|||
值 |
|
||
|
# Invalidates the GPU resources.
HandleGPUResources = invalidate
|
||
// Invalidates the GPU resources.
configuration.handleGPUResources = ApplicationProperties::HandleGPUResources::Invalidate;
|
图形性能日志¶
GraphicsLoggingEnabled¶
如果您的目标支持命令行参数,您可以启用 Kanzi 在 Application::onConfigure 函数中、在 application.cfg 中,或使用命令行参数将应用程序的图形 API 调用打印到调试控制台。
在命令行使用:
-log-graphics记录图形 API 调用。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Enables the logging of the graphics API calls.
GraphicsLoggingEnabled = 1
|
||||
// Enables the logging of the graphics API calls.
configuration.graphicsLoggingEnabled = 1;
|
LogOpenGLExtensions¶
您可以启用 Kanzi 在应用程序启动时将与图形相关的扩展列表打印到调试控制台。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Enables the logging of the graphics-related extensions.
LogOpenGLExtensions = 1
|
||||
// Enables the logging of the graphics-related extensions.
configuration.extensionOutputEnabled = 1;
|
LogOpenGLInformation¶
您可以启用 Kanzi 以在应用程序启动时将此图形相关信息打印到调试控制台:
GL 供应商
GL 渲染器
GL 版本
着色语言版
在 |
|
||||
|
|||||
值 |
|
||||
|
# Enables the logging of the graphics-related information.
LogOpenGLInformation = 1
|
||||
// Enables the logging of the graphics-related information.
configuration.informationOutputEnabled = 1;
|
LogSurfaceInformation¶
您可以启用 Kanzi 以在应用程序启动时将这些与图形相关的属性打印到调试控制台:
请求并获取的表面属性。请参阅 表面属性。
整个桌面和每个显示屏的大小。
应用程序窗口的大小。请参阅 应用程序窗口位置和大小。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Enables the logging of the graphics-related properties.
LogSurfaceInformation = 1
|
||||
// Enables the logging of the graphics-related properties.
configuration.propertyOutputEnabled = 1;
|
QNX 系统记录器 (slogger2)¶
在 QNX 上,您可以使用 QNX 系统记录器 (slogger2) 来写入日志消息。当您将日志消息重定向到 slogger2 时,您的 Kanzi 应用程序会继续将日志消息写入默认记录器。
Kanzi 应用程序不使用默认的 slogger2 缓冲区,这使您可以使用 slog2_set_default_buffer。Kanzi 提供的 slogger2 仅支持记录到一个 slogger2 缓冲区。当 slogger2 停止记录时,Kanzi 调用 slog2_reset。要更改此行为,请参阅:slogger2 的清理工作。
请记住,slogger2 在 Kanzi 读取您的 Kanzi 应用程序的配置后初始化。因此,slogger2 日志不包含该时间之前的日志消息。
要使用 slogger2,您可以:
在
application.cfg或Application::onConfigure中配置 slogger2。为 Kanzi 记录器提供自定义 slogger2 缓冲区。请参阅 customSlog2Buffer。
QnxEnableSlogger2¶
在您可以将 slogger2 与您的 Kanzi 应用程序一起使用之前,您必须启用它。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Enable logging to slogger2.
QnxEnableSlogger2 = true
|
||||
// Enable logging to slogger2.
configuration.slog2Config.enabled = true;
|
QnxSlogger2VerbosityLevel¶
您可以设置要让 slogger2 记录哪些日志消息。Kanzi 应用程序配置的详细级别映射到 slogger2 日志的详细级别。
在 |
|
||||||||||||||||
|
|||||||||||||||||
值 |
|
||||||||||||||||
|
# Sets the slogger2 log level to SLOG2_INFO.
QnxSlogger2VerbosityLevel = Slog2Info
|
||||||||||||||||
// Sets the slogger2 log level to SLOG2_INFO.
configuration.slog2Config.verbosityLevel = Slog2VerbosityLevel::Slog2Info;
|
QnxSlogger2MaxRetries¶
在 QNX 版本 7.0.4 及更新版本中,您可以限制 slogger2 重试获取缓冲区的次数。
当您设置此限制并且 slogger2 达到该限制时,Kanzi 会丢弃日志消息并增加丢弃的消息计数。您可以在 slogger2 日志中查看丢弃消息的数量,该数量显示在日志消息之前写入的变量 code 的下一个未丢弃日志条目中。
在 |
|
||
|
|||
值 |
|
||
|
# Set the retry limit to 10 retries.
QnxSlogger2MaxRetries = 10
|
||
// Set the retry limit to 10 retries.
configuration.slog2Config.maxRetries = 10;
|
pageCount¶
您可以设置 QNX 记录器为内部 slogger2 缓冲区获取的 4KB 页的倍数。
|
|||
值 |
|
||
// For example, when you set the slogger2 verbosity level to
// SLOG2_ERROR slogger2 writes to log less frequently
// (low rate logging), and by decreasing the page count
// you can increase the logging pace.
configuration.slog2Config.pageCount = 1;
|
customSlog2Buffer¶
Kanzi 使您能够注册自定义 slogger2 缓冲区并将其传递给 Kanzi 应用程序。然后,您的 Kanzi 应用程序使用该缓冲区来写入日志。例如,当您想为缓冲区指定自定义名称或想要设置从传递给 slog2_register 的 slog2_buffer_set_config_t 结构中的任何属性时,可以注册自定义 slogger2 缓冲区。请参阅 QNX 系统记录器 (slogger2)。
图形库¶
在 Windows 操作系统上,您可以选择是否要在 Application::onConfigure 函数中、在 application.cfg 中,或使用命令行参数来使用 OpenGL ES 或 OpenGL,前提是您的目标支持命令行参数。
在命令行使用:
-gles要使用 OpenGL ES。-gl要使用 OpenGL-egl要使用 EGL-wgl要使用 WGL。-glx要使用 GLX
在 |
|
||||
|
|||||
值 |
|
||||
|
# Sets the surface target for OpenGL rendering and WGL graphics context.
SurfaceClientAPI = gl
GraphicsContextAPI = wgl
|
||||
// Sets the surface target for OpenGL rendering and WGL graphics context.
configuration.defaultSurfaceProperties.clientAPI = SurfaceClientAPI::OpenGL;
configuration.defaultSurfaceProperties.contextAPI = GraphicsContextAPI::WGL;
|
表面属性¶
表面属性控制着 Kanzi 渲染到的硬件加速图形表面的属性。它们控制图像质量与渲染速度之间的关系。
您设置的表面属性将被视为目标硬件的图形系统要匹配的请求。给定请求是被视为上限、下限还是精确值,取决于平台。
要获取与平台相关的表面属性默认值,请调用 kzsSurfaceGetDefaultProperties()。
颜色格式¶
您可以以位为单位设置RGB颜色通道和alpha通道的大小。
在 |
|
||||||||
|
|||||||||
值 |
每个通道的默认大小为 8 位。 要让平台选择该值,请使用 |
||||||||
|
# Set the sizes of the color and alpha channels for a typical
# high-speed rendering application.
SurfaceBitsRed = 5
SurfaceBitsGreen = 6
SurfaceBitsBlue = 5
SurfaceBitsAlpha = 0
# Let the platform choose the sizes of the color and alpha channels.
SurfaceBitsRed = "unspecified"
SurfaceBitsGreen = "unspecified"
SurfaceBitsBlue = "unspecified"
SurfaceBitsAlpha = "unspecified"
|
||||||||
// Set the sizes of the color and alpha channels for a typical
// high-speed rendering application.
configuration.defaultSurfaceProperties.bitsColorR = 5;
configuration.defaultSurfaceProperties.bitsColorG = 6;
configuration.defaultSurfaceProperties.bitsColorB = 5;
configuration.defaultSurfaceProperties.bitsAlpha = 0;
要让平台选择颜色和 alpha 通道大小:
|
SurfaceBitsStencil¶
您可以以位为单位设置模板缓冲区的大小。
在 |
|
||
|
|||
值 |
|
||
|
# Set the size of the stencil buffer to one bit.
SurfaceBitsStencil = 1
# Let the platform choose the size of the stencil buffer.
SurfaceBitsStencil = "unspecified"
|
||
// Set the size of the stencil buffer to one bit.
configuration.defaultSurfaceProperties.bitsStencil = 1;
要让平台选择模板缓冲区的大小:
|
SurfaceBitsDepthBuffer¶
您可以以位为单位设置深度缓冲区的大小。
在 |
|
||
|
|||
值 |
|
||
|
# Set the size of the depth buffer to 16 bits.
SurfaceBitsDepthBuffer = 16
# Let the platform choose the size of the depth buffer.
SurfaceBitsDepthBuffer = "unspecified"
|
||
// Set the size of the depth buffer to 16 bits.
configuration.defaultSurfaceProperties.bitsDepthBuffer = 16;
要让平台选择深度缓冲区的大小:
|
SurfaceBitsPadding¶
在 QNX 上,您可以设置要添加到 Kanzi 应用程序窗口的颜色格式的填充大小(以位为单位)。
在 |
|
||
|
|||
值 |
|
||
|
# Set the size of the padding to 2 bits.
SurfaceBitsPadding = 2
|
||
// Set the size of the padding to 2 bits.
configuration.defaultSurfaceProperties.bitsPadding = 2;
|
SurfaceColorSpace¶
您可以启用 OpenGL 的初始化,以用于显示您的 Kanzi 应用程序的硬件。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Set your application to use an unspecified color space.
SurfaceColorSpace = "legacy"
|
||
// Set your application to use an unspecified color space.
configuration.defaultSurfaceProperties.colorSpace = "legacy";
|
|||
命令行示例 |
将您的应用程序设置为使用未指定的颜色空间。 -surface-color-space=legacy
|
请参阅 颜色工作流程。
SurfaceSamplesAntialiasing¶
您可以设置用于抗锯齿的表面采样数。
在 |
|
||
|
|||
值 |
|
||
|
# Set the number of anti-aliasing samples to 4.
SurfaceSamplesAntialiasing = 4
|
||
// Set the number of anti-aliasing samples to 4.
configuration.defaultSurfaceProperties.antiAliasing = 4;
|
SwapBehavior¶
您可以设置在缓冲区交换期间是交换缓冲区还是复制缓冲区。
在 |
|
||
|
|||
值 |
|
||
|
# Copy buffers during buffer swap.
SwapBehavior = "copy"
|
||
// Copy buffers during buffer swap.
configuration.defaultSurfaceProperties.swapBehaviorCopy = SwapBehavior::Copy;
|
EGLIMGContextPriority¶
您可以创建一个带有优先级提示的 EGL IMG 上下文。默认情况下,Kanzi 让平台选择优先级。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Set the EGL IMG context priority to high.
EGLIMGContextPriority = "high"
# Let the platform choose the EGL IMG context priority.
EGLIMGContextPriority = "unspecified"
|
||
// Set the EGL IMG context priority to high.
configuration.defaultSurfaceProperties.priority = EGLIMGContextPriority::High;
要让平台选择 EGL IMG 上下文优先级:
|
|||
命令行示例 |
将 EGL IMG 上下文优先级设置为高。 -egl-img-context-priority=high
|
应用程序窗口位置和大小¶
您可以设置您的 Kanzi 应用程序在屏幕上相对于屏幕左上角的位置以及以像素为单位的应用程序窗口大小。窗口的默认大小为640x480像素,并位于设备屏幕的中心。
要使应用程序窗口具有固定大小、可调整大小、全屏或无边框,请参阅 WindowStyle。
要设置应用程序窗口出现的默认显示,请参阅 DefaultDisplayIndex。
在 |
|
||||||||||
|
|||||||||||
值 (Value) |
|
||||||||||
|
# Sets the width to 1280 and height to 720 pixels and place it 100 pixels
# from the top and 1 pixel from the left side of the device screen.
WindowWidth = 1280
WindowHeight = 720
WindowX = 100
WindowY = 1
# Places the application window in the top-left corner of the device screen.
WindowX = 0
WindowY = 0
# Sets the window order to 0.
WindowOrder = 0
# Sets the window order to 0xff.
WindowOrder = 0xff
|
||||||||||
// Sets the width to 1280 and height to 720 pixels and place it 100 pixels
// from the top and 1 pixel from the left side of the device screen.
configuration.defaultWindowProperties.width = 1280;
configuration.defaultWindowProperties.height = 720;
configuration.defaultWindowProperties.x = 100;
configuration.defaultWindowProperties.y = 1;
// Places the application window in the top-left corner of the device screen.
configuration.defaultWindowProperties.x = 0;
configuration.defaultWindowProperties.y = 0;
// Sets the window order to 0.
configuration.defaultWindowProperties.order = 0;
configuration.systemConfiguration[ConfigurationKeyDefaultWindowOrder] = "0";
// Sets the window order to 0xff.
configuration.defaultWindowProperties.order = 0xff;
configuration.systemConfiguration[ConfigurationKeyDefaultWindowOrder] = "0xff";
|
显卡选择¶
DeviceIdentifier¶
在使用 GBM 窗口系统的平台上,您可以设置希望 Kanzi 应用程序使用的图形卡。
在 |
|
||
|
|||
值 (Value) |
|
||
|
# Sets Kanzi to use the graphics card at /dev/dri/card1.
DeviceIdentifier = /dev/dri/card1
|
||
// Sets Kanzi to use the graphics card at /dev/dri/card1.
configuration.defaultDesktopProperties.deviceIdentifier = "/dev/dri/card1";
|
QNX 上下文类型选择¶
在 QNX 上,您可以设置希望 Kanzi 应用程序使用的上下文类型。在 application.cfg 中和在命令行上,您只能设置一种上下文类型。要设置多种上下文类型,请在 Application::onConfigure 中进行设置。
在 |
|
||
|
|||
在命令行上 |
|
||
值 (Value) |
|
||
|
# Sets Kanzi to use the SCREEN_DISPLAY_MANAGER_CONTEXT context type.
QnxContextType = SCREEN_DISPLAY_MANAGER_CONTEXT
|
||
// Sets Kanzi to use the SCREEN_WINDOW_MANAGER_CONTEXT and SCREEN_INPUT_PROVIDER_CONTEXT context types.
configuration.defaultDesktopProperties.contextFlags = SCREEN_WINDOW_MANAGER_CONTEXT | SCREEN_INPUT_PROVIDER_CONTEXT;
|
|||
命令行示例 |
将 Kanzi 设置为使用 SCREEN_DISPLAY_MANAGER_CONTEXT 上下文类型。 -qnx-context-type=SCREEN_DISPLAY_MANAGER_CONTEXT
|
应用程序窗口配置¶
WindowStyle¶
您可以设置 Kanzi 应用程序窗口的样式。除了用户可以调整大小的带边框的默认窗口外,您还可以将 Kanzi 应用程序设置为在无边框窗口、固定大小窗口以及占据整个设备屏幕的窗口中启动。
要设置应用程序窗口的位置和大小,请参阅 应用程序窗口位置和大小。
在 |
|
||
|
|||
值 (Value) |
|
||
|
# Launch the application in a window that occupies the whole screen of the device.
WindowStyle = "fullscreen"
|
||
// Launch the application in a window that occupies the whole screen of the device.
configuration.defaultWindowProperties.style = KZS_WINDOW_STYLE_FULL_SCREEN;
|
DefaultDisplayIndex¶
当您在具有多个显示器的系统上以全屏模式运行您的 Kanzi 应用程序时,您可以设置 Kanzi 应用程序窗口出现的默认显示器。
要使应用程序窗口全屏,请参阅 WindowStyle。
在 |
|
||
|
|||
值 (Value) |
|
||
|
# Sets the second display as the default display for the full-screen application window.
DefaultDisplayIndex = 1
|
||
// Sets the second display as the default display for the full-screen application window.
configuration.defaultWindowProperties.defaultDisplayIndex = 1;
|
WindowBufferCount¶
如果您目标设备的窗口系统支持设置窗口缓冲区数量,则可以设置您的 Kanzi 应用程序窗口使用的本机窗口缓冲区数量。例如,Renesas 窗口管理器和 QNX Screen 支持设置窗口缓冲区的数量。
在 |
|
||
|
|||
值 |
|
||
|
# Set the number of native window buffers used by the Kanzi application window to 3.
WindowBufferCount = 3
|
||
// Set the number of native window buffers used by the Kanzi application window to 3.
configuration.defaultWindowProperties.bufferCount = 3;
|
GroupName¶
在使用窗口组名称的窗口系统平台(例如 QNX)上,您可以为应用程序窗口组设置组名称。运行多个 Kanzi 应用程序时,请在每个 Kanzi 应用程序中为窗口组设置唯一的名称。
|
|||
值 |
|
||
// Set the Kanzi application window group name to Cluster.
configuration.defaultWindowProperties.groupName = "Cluster";
|
窗口标题¶
您可以设置 Kanzi 窗口标题。默认窗口标题为 “Kanzi”。
在 |
|
|
|
在命令行上 |
|
|
# Sets "kanzi" as window title.
WíndowTitle = kanzi
|
// Sets "kanzi" as window title.
configuration.systemConfiguration[ConfigurationKeyDefaultWindowTitle] = "kanzi";
|
|
命令行示例 |
将 “kanzi” 设置为窗口标题。 -window-title=kanzi
|
QnxPipelineID¶
您可以为您的 Kanzi 应用程序窗口设置 QNX Screen 管道 ID。图形管道 ID 是指向特定于目标设备的硬件分层的标识符。
当您设置管道 ID 时,您的 Kanzi 应用程序使用底层系统函数设置该 ID。默认情况下,Kanzi 应用程序不设置管道 ID。
如果您设置了管道 ID,确保将目标设备的管道顺序和应用程序窗口的 z 顺序合理结合。您可以使用 WindowOrder 设置 Kanzi 应用程序窗口的 z 顺序。请参阅 应用程序窗口位置和大小。
在 |
|
||
在命令行上 |
|
||
值 |
|
||
|
# Sets the QNX Screen pipeline ID to 1.
QnxPipelineID = 1
|
||
命令行示例 |
将 QNX Screen 管道 ID 设置为 1。 -qnx-pipeline-id=1
|
QnxWindowSelfLayout¶
对于 Kanzi 应用程序窗口,您可以以编程方式设置自布局 QNX Screen 属性。该属性使您能够设置否则只能由窗口管理器更改的属性。
m_applicationProperties.defaultWindowProperties.selfLayout = selfLayout;
configuration.systemConfiguration[ConfigurationKeyDefaultQnxWindowSelfLayout] = selfLayout;
|
|||
值 |
|
||
// To enable self layout for this window.
m_applicationProperties.defaultWindowProperties.selfLayout = 1;
configuration.systemConfiguration[ConfigurationKeyDefaultQnxWindowSelfLayout] = "1";
|
|||
|
# Sets the QNX window self layout to true.
QnxWindowSelfLayout = 1
|
||
命令行示例 |
为此窗口启用自布局。 -qnx-window-self-layout=1
|
QnxUsageFlags¶
对于 Kanzi 应用程序窗口,您可以以编程方式设置 QNX Screen 属性的使用标志。Screen 使用标志使您能够限制分配的 QNX 窗口缓冲区。
m_applicationProperties.defaultWindowProperties.usageFlags = usageFlags;
|
|||
值 |
|
||
// To use the OpenGL ES 3.X to render the QNX window buffer.
m_applicationProperties.defaultWindowProperties.usageFlags = SCREEN_USAGE_OPENGL_ES3;
|
EGLGraphicsFormatID¶
您可以为您的 Kanzi 应用程序设置 EGL 图形格式 ID。EGL 图形格式 ID 是一个标识符,指的是在支持 EGL 的平台上运行的 Kanzi 应用程序的 EGL 配置。使用命令行列出可用于您的 Kanzi 应用程序的 EGL 配置。
请记住,当您设置 EGL 图形格式 ID 时,您将覆盖 EGL 图形格式设置。
您可以为这些 EGL 图形输出设置 EGL 格式 ID:
Android WS
Emscripten
Wayland
X11
在 |
|
||
在命令行上 |
|
||
值 |
|
||
|
# Sets the EGL graphics format ID to 1.
EGLGraphicsFormatID = 1
|
||
命令行示例 |
将 EGL 图形格式 ID 设置为 1。 -egl-graphics-format-id=1
列出应用程序可用的 EGL 配置。 -enum-egl-configs
|
EGLContextClientVersion¶
您可以为以下 EGL 图形输出设置 EGL 上下文客户端版本:
Android WS
Emscripten
Wayland
QNX
X11
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Sets Kanzi to use ES2 context client version.
EGLContextClientVersion = es2
|
||
// Sets Kanzi to use ES2 context client version.
configuration.systemConfiguration[ConfigurationKeyEGLContextClientVersion] = "es2";
|
|||
命令行示例 |
将 Kanzi 设置为使用 ES2 上下文客户端版本。 -egl-context-client-version=es2
|
输入处理¶
您可以定义应用程序如何处理触摸和指针输入。当您在设备上运行应用程序时,您可以设置应用程序是否对设备的指针、触摸屏或两者都做出反应。您还可以设置输入事件坐标的变换矩阵。
Kanzi 应用程序默认情况下处理输入。要在您的应用程序中禁用输入处理,请用空实现覆盖 Application::setScreenOverride() 函数。请参阅 禁用输入处理。
InputTransform¶
您可以设置输入事件坐标的变换矩阵。此变换仅影响输入事件坐标,而不影响 Kanzi 应用程序屏幕的方向。例如,使用此方法可以旋转触摸屏以相对于您的应用程序屏幕。
在 |
|
||
|
|||
值 |
|
||
|
# Rotate a touch screen sized 1280x720 pixels by 180 degrees.
InputTransform = -1, 0, 0, 0, -1, 0, 1280, 720, 1
|
||
// Rotate a touch screen sized 1280x720 pixels by 180 degrees.
configuration.defaultEventSourceProperties.transformation = Matrix3x3::createTranslation(1280.0f, 720.0f) * Matrix3x3::createRotationInDegrees(180.0f);
|
示例使用此等式计算变换矩阵:
InputTranslation¶
您可以设置 Kanzi 如何转换指针和触摸事件。
在 |
|
||
|
|||
值 |
|
||
|
# Translate pointer events to touch events.
InputTranslation = pointertotouch
|
||
// Translate pointer events to touch events.
configuration.defaultEventSourceProperties.translation = TranslatePointerToTouch;
|
InputDiscardPointer¶
您可以设置应用程序是否响应设备指针。
在 |
|
||||||
|
|||||||
值 |
|
||||||
|
# Ignore pointer input.
InputDiscardPointer = 1
|
||||||
// Ignore pointer input.
configuration.defaultEventSourceProperties.discardPointerEvents = 1;
|
InputDiscardTouch¶
您可以设置应用程序是否响应触摸输入。
在 |
|
||||||
|
|||||||
值 |
|
||||||
|
# Ignore touch input.
InputDiscardTouch = 1
|
||||||
// Ignore touch input.
configuration.defaultEventSourceProperties.discardTouchEvents = 1;
|
Linux 上的输入事件设备¶
您可以在本机窗口系统不提供输入设备处理的 Linux 端口上配置 Kanzi 监听的输入事件设备。
这样,Kanzi 可以直接从操作系统提供的输入事件设备监听事件。
例如,在 Vivante fbdev 和 WSEGL 端口中,您可以配置 Kanzi 监听的输入事件设备。在 X11 和 Wayland 端口中,本地窗口系统处理输入设备。
默认情况下,Kanzi 监听 /dev/input 目录中所有名为 eventN 的输入事件设备,其中 N 是一个整数。
在 |
|
||
|
|||
值 |
|
||
|
# Listens to events from one input event device.
InputEventDevice = "/dev/input/event1"
# Listens to events from two input event devices.
InputEventDevice = "/dev/input/event0;/dev/input/event1"
# Disables listening to events from input event devices.
InputEventDevice = "none"
|
||
// Listens to events from one input event device.
configuration.defaultEventSourceProperties.inputEventDevice = "/dev/input/event1";
// Listens to events from two input event devices.
configuration.defaultEventSourceProperties.inputEventDevice = "/dev/input/event0;/dev/input/event1";
// Disables listening to events from input event devices.
configuration.defaultEventSourceProperties.inputEventDevice = "none";
|
平台配置¶
PlatformLoggingEnabled¶
您可以为平台层启用额外的日志。目前会影响 Wayland 和 DRM/GBM。
在 |
|
||||
|
|||||
在命令行上 |
|
||||
值 |
|
||||
|
# Sets Kanzi to produce additional logs for the Platform layer.
PlatformLoggingEnabled = true
|
||||
// Sets Kanzi to produce additional logs for the Platform layer.
configuration.systemConfiguration[ConfigurationKeyPlatformLoggingEnabled] = true;
|
|||||
命令行示例 |
将 Kanzi 设置为生成平台层的额外日志。 -log-platform
|
Wayland 配置¶
使用 Kanzi 在 Wayland 上时,您可以配置 Wayland 特定的参数。
Wayland shell¶
您可以设置 Kanzi 使用的 Wayland shell。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Sets Kanzi to use the IVI shell.
WaylandShell = ivi
|
||
// Sets Kanzi to use the IVI shell.
configuration.systemConfiguration[ConfigurationKeyWaylandShell] = "ivi";
|
|||
命令行示例 |
将 Kanzi 设置为使用 IVI shell。 -wayland-shell=ivi
|
Wayland 输入模式¶
如果您不想等待指针和触摸 frame() 事件,可以将 Kanzi 设置为立即处理输入事件。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Enable immediate input mode.
WaylandInputMode = immediate
|
||
// Enable immediate input mode.
configuration.systemConfiguration[ConfigurationKeyWaylandInputMode] = "immediate";
|
|||
命令行示例 |
启用立即输入模式。 -wayland-input-mode=immediate
|
Wayland app ID¶
您可以设置 Kanzi app ID。默认 app ID 为 “kanzi”。
在 |
|
|
|
在命令行上 |
|
|
# Sets "kanzi" as app ID.
WaylandAppId = kanzi
|
// Sets "kanzi" as app ID.
configuration.systemConfiguration[ConfigurationKeyWaylandAppId] = "kanzi";
|
|
命令行示例 |
将 “kanzi” 设置为 app ID。 -wayland-app-id=kanzi
|
Wayland IVI surface ID¶
使用 Wayland IVI shell 时,您可以设置 Kanzi 使用的 IVI surface ID。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Sets IVI surface ID to 4000.
WaylandIviSurfaceId = 4000
|
||
// Sets IVI surface ID to 4000.
configuration.systemConfiguration[ConfigurationKeyWaylandIviSurfaceId] = 4000;
|
|||
命令行示例 |
将 IVI 表面 ID 设置为 4000。 -wayland-ivi-surface-id=4000
|
Wayland IVI 扩展配置¶
使用 COVESA IVI extension 并将 Kanzi 构建为支持 IVI 扩展时,您可以通过设置各种 IVI 参数来控制 Kanzi。
Wayland IVI layer ID¶
Kanzi 需要一个专用的 IVI 层来显示其内容。您可以设置 Kanzi 使用的 IVI 层。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Sets IVI layer ID to 4000.
WaylandIviLayerId = 4000
|
||
// Sets IVI layer ID to 4000.
configuration.systemConfiguration[ConfigurationKeyWaylandIviLayerId] = 4000;
|
|||
命令行示例 |
将 IVI 层 ID 设置为 4000。 -wayland-ivi-layer-id=4000
|
Wayland IVI 表面不透明度¶
您可以设置 Kanzi IVI 表面的不透明度。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Sets the IVI surface to be fully transparent.
WaylandIviSurfaceOpacity = 0
|
||
// Sets the IVI surface to be fully transparent.
configuration.systemConfiguration[ConfigurationKeyWaylandIviSurfaceOpacity] = 0;
|
|||
命令行示例 |
将 IVI 表面设置为完全透明。 -wayland-ivi-surface-opacity=0
|
Wayland IVI 图层不透明度¶
您可以设置 Kanzi IVI 层的不透明度。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Sets the IVI layer to be fully transparent.
WaylandIviLayerOpacity = 0
|
||
// Sets the IVI layer to be fully transparent.
configuration.systemConfiguration[ConfigurationKeyWaylandIviLayerOpacity] = 0;
|
|||
命令行示例 |
将 IVI 层设置为完全透明。 -wayland-ivi-layer-opacity=0
|
Wayland IVI 表面可见性¶
您可以设置 Kanzi IVI 表面的可见性。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Hides the Kanzi IVI surface.
WaylandIviSurfaceVisibility = 0
|
||
// Hides the Kanzi IVI surface.
configuration.systemConfiguration[ConfigurationKeyWaylandIviSurfaceVisibility] = 0;
|
|||
命令行示例 |
隐藏 Kanzi IVI 表面。 -wayland-ivi-surface-visibility=0
|
Wayland IVI 图层可见性¶
您可以设置 Kanzi IVI 层的可见性。
在 |
|
||
|
|||
在命令行上 |
|
||
值 |
|
||
|
# Hides the Kanzi IVI layer.
WaylandIviLayerVisibility = 0
|
||
// Hides the Kanzi IVI layer.
configuration.systemConfiguration[ConfigurationKeyWaylandIviLayerVisibility] = 0;
|
|||
命令行示例 |
隐藏 Kanzi IVI 层。 -wayland-ivi-layer-visibility=0
|
图像加载 (Image loading)¶
Kanzi 使用第三方图像库,例如 libpng 和 libjpeg,以支持不同的图像格式。要使您的 Kanzi 应用程序更安全,您可以设置限制,以便 Kanzi 在使用这些库加载图像时使用。例如,为了防止加载恶意文件,您可以限制为 Kanzi 加载的每个对象分配的内存量。
libjpeg¶
您可以使用 libjpeg 图像库为 Kanzi 加载的每个 JPEG 对象设置要分配的最大内存字节数。
在 |
|
||
|
|||
值 |
|
||
|
# Sets the libjpeg memory allocation limit to 2 MB (2,000,000 bytes).
LibJPEGMaxMemory = 2000000
|
||
// Sets the libjpeg memory allocation limit to 2 MB (2,000,000 bytes).
configuration.imageLoad.libJPEGMaxMemory = 2000000;
|
libpng¶
您可以使用 libpng 图像库设置 PNG 数据流中辅助块的最大数量,以及为 Kanzi 加载的块分配的最大内存字节数。
默认情况下 Kanzi 使用 libpng 施加的这些限制:
sPLT、tEXt、iTXt、zTXt 和未知辅助块的总数最多为 1000。
为除 IDAT 之外的块分配的内存最大为 8 兆字节。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Sets the libpng limit for the number of ancillary chunks to 500.
LibPNGChunkCacheMax = 500
# Sets the libpng limit for the amount of memory that a chunk
# other than IDAT can occupy to 2 MB (2,000,000 bytes).
LibPNGChunkMallocMax = 2000000
|
||||
// Sets the libpng limit for the number of ancillary chunks to 500.
configuration.imageLoad.libPNGChunkCacheMax = 500;
// Sets the libpng limit for the amount of memory that a chunk
// other than IDAT can occupy to 2 MB (2,000,000 bytes).
configuration.imageLoad.libPNGChunkMallocMax = 2000000;
|
着色器二进制缓存¶
在性能受限的平台上,着色器编译可能会显著减慢应用程序启动速度并降低运行时性能。如果您的平台不提供离线着色器编译工具,您可以使用预先准备好应用程序所需的一组着色器的着色器二进制缓存。这样,您的应用程序在运行时就不必从源代码编译着色器。
请参阅 使用二进制着色器。
ShaderBinaryCacheDirectory¶
您可以设置目录,以便您的 Kanzi 应用程序缓存着色器二进制文件。在缓存时,该目录必须是可写的。出于生产目的,您可以将目录设置为只读。请参阅 ShaderBinaryCacheReadOnly。
要启用着色器二进制文件的缓存,请使用 ShaderBinaryCacheEnabled 设置。
在 |
|
||
|
|||
值 |
|
||
|
# Sets the shader binary cache directory to /tmp/shader-cache/.
ShaderBinaryCacheDirectory = "/tmp/shader-cache/"
|
||
// Sets the shader binary cache directory to /tmp/shader-cache/.
configuration.shaderBinaryCacheDirectory = "/tmp/shader-cache/";
|
ShaderBinaryCacheEnabled¶
您可以将应用程序设置为缓存着色器二进制文件。使用此方法可以在离线着色器编译工具不可用的平台上优化 Kanzi 应用程序性能。
着色器二进制文件的缓存要求 Kanzi Studio 将着色器的源代码导出到 kzb 文件中。在 Kanzi Studio 中,在 Project > Properties 中,确保将 Export Shader Source Code 属性启用。这是默认值。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Enables the caching of shader binaries.
ShaderBinaryCacheEnabled = true
|
||||
// Enables the caching of shader binaries.
configuration.shaderBinaryCacheEnabled = true;
|
ShaderBinaryCacheCollisionCheck¶
默认情况下,Kanzi 在缓存的着色器二进制文件名中仅存储着色器源代码的哈希值。然后,Kanzi 将该哈希值与从请求的着色器源派生的哈希值进行比较。哈希冲突虽然罕见但可能发生,会导致使用错误的着色器。
为了防止哈希冲突,您可以将应用程序设置为存储着色器源代码,并执行完整的字符串比较,以确保着色器是相同的。如果两个着色器产生相同的哈希值,应用程序会记录一个警告。
要节省磁盘空间并优化性能,请仅在开发期间启用哈希冲突检查。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Enables checking for hash collisions in cached shaders.
ShaderBinaryCacheCollisionCheck = true
|
||||
// Enables checking for hash collisions in cached shaders.
configuration.shaderBinaryCacheCollisionCheck = true;
|
ShaderBinaryCacheReadOnly¶
默认情况下,Kanzi 可以写入着色器二进制缓存。当您的应用程序准备好投入生产时,您可以将着色器二进制缓存设置为只读。
在 |
|
||||
|
|||||
值 |
|
||||
|
# Makes the shader binary cache read-only.
ShaderBinaryCacheReadOnly = true
|
||||
// Makes the shader binary cache read-only.
configuration.ShaderBinaryCacheReadOnly = true;
|