Add XCUI native image UV support

This commit is contained in:
2026-04-05 14:16:53 +08:00
parent daa54e0230
commit 231df6ee36
6 changed files with 68 additions and 18 deletions

View File

@@ -239,4 +239,33 @@ TEST(XCUIRHICommandCompilerTest, CompilePreservesMirroredImageUvForNegativeRectE
EXPECT_EQ(compiled.stats.compiledCommandCount, 1u);
}
TEST(XCUIRHICommandCompilerTest, CompileUsesExplicitImageUvRectWhenProvided) {
XCUIRHICommandCompiler compiler = {};
UIDrawData drawData = {};
UIDrawList& drawList = drawData.EmplaceDrawList("ExplicitUvImage");
drawList.AddImage(
UIRect(8.0f, 6.0f, 16.0f, 12.0f),
UITextureHandle{ 123u, 64u, 64u, UITextureHandleKind::ShaderResourceView },
UIColor(0.9f, 0.8f, 0.7f, 1.0f),
UIPoint(0.25f, 0.40f),
UIPoint(0.75f, 0.90f));
XCUIRHICommandCompiler::CompileConfig config = {};
config.surfaceClipRect = UIRect(0.0f, 0.0f, 64.0f, 64.0f);
XCUIRHICommandCompiler::CompiledDrawData compiled = {};
compiler.Compile(drawData, config, compiled);
ASSERT_EQ(compiled.batches.size(), 1u);
ASSERT_EQ(compiled.texturedVertices.size(), 6u);
EXPECT_FLOAT_EQ(compiled.texturedVertices[0].uv[0], 0.25f);
EXPECT_FLOAT_EQ(compiled.texturedVertices[0].uv[1], 0.40f);
EXPECT_FLOAT_EQ(compiled.texturedVertices[1].uv[0], 0.75f);
EXPECT_FLOAT_EQ(compiled.texturedVertices[1].uv[1], 0.40f);
EXPECT_FLOAT_EQ(compiled.texturedVertices[2].uv[0], 0.75f);
EXPECT_FLOAT_EQ(compiled.texturedVertices[2].uv[1], 0.90f);
EXPECT_EQ(compiled.stats.imageCommandCount, 1u);
EXPECT_EQ(compiled.stats.compiledCommandCount, 1u);
}
} // namespace