From ec9d6942fa2b99eab2db54500c50929733b24585 Mon Sep 17 00:00:00 2001 From: HaoXinyu Date: Wed, 15 Jan 2025 15:05:05 +0800 Subject: [PATCH] native testcase update Signed-off-by: HaoXinyu --- graphic_test/graphic_test/BUILD.gn | 21 +- .../appearance_border_test.cpp | 73 ++++- .../property_display/appearance_clip_test.cpp | 69 +++++ ...cpp => appearance_g2cornerradius_test.cpp} | 0 .../appearance_outlineborder_radius_test.cpp | 99 +++++++ .../appearance_outlineborder_test.cpp | 93 ++++++ ...h.cpp => appearance_pixelstretch_test.cpp} | 24 ++ .../appearance_shadow_test.cpp | 65 +++++ ...ender.cpp => background_blender_tedst.cpp} | 0 ...nd_Filter.cpp => background_blur_test.cpp} | 0 ...nd_Color.cpp => background_color_test.cpp} | 24 +- ...rRipple.cpp => background_effect_test.cpp} | 0 ...nd_Image.cpp => background_image_test.cpp} | 6 +- .../background_shader_test.cpp | 273 ++++++++++++++++++ ...fect.cpp => background_useeffect_test.cpp} | 0 .../property_display/fg_colorfilter_test.cpp | 35 +++ .../property_display/geom_clip_test.cpp | 10 +- .../property_display/geom_persp_test.cpp | 30 +- .../geom_pivotandrotation_test.cpp | 12 +- .../property_display/geom_scale_test.cpp | 30 ++ ...ground_GreyCoef.cpp => geom_skew_test.cpp} | 37 ++- ...sform_Test.cpp => geom_transform_test.cpp} | 0 .../geom_translation_test.cpp | 25 +- .../src/rs_graphic_test_img.cpp | 3 +- 24 files changed, 868 insertions(+), 61 deletions(-) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_G2_CornerRadius.cpp => appearance_g2cornerradius_test.cpp} (100%) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_Appearance_PixelStretch.cpp => appearance_pixelstretch_test.cpp} (88%) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_RSBackground_BeginBlender.cpp => background_blender_tedst.cpp} (100%) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_RSBackground_Filter.cpp => background_blur_test.cpp} (100%) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_RSBackground_Color.cpp => background_color_test.cpp} (89%) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_RSBackground_WaterRipple.cpp => background_effect_test.cpp} (100%) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_RSBackground_Image.cpp => background_image_test.cpp} (97%) create mode 100644 graphic_test/graphic_test/rs_display_effect/property_display/background_shader_test.cpp rename graphic_test/graphic_test/rs_display_effect/property_display/{test_RSBackground_UseEffect.cpp => background_useeffect_test.cpp} (100%) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_RSBackground_GreyCoef.cpp => geom_skew_test.cpp} (52%) rename graphic_test/graphic_test/rs_display_effect/property_display/{test_Geometry_Transform_Test.cpp => geom_transform_test.cpp} (100%) diff --git a/graphic_test/graphic_test/BUILD.gn b/graphic_test/graphic_test/BUILD.gn index fe1baf794c..cca391a86b 100644 --- a/graphic_test/graphic_test/BUILD.gn +++ b/graphic_test/graphic_test/BUILD.gn @@ -25,10 +25,19 @@ rs_display_effect_sources = [ "rs_display_effect/property_display/appearance_border_radius_test.cpp", "rs_display_effect/property_display/appearance_border_test.cpp", "rs_display_effect/property_display/appearance_clip_test.cpp", + "rs_display_effect/property_display/appearance_g2cornerradius_test.cpp", "rs_display_effect/property_display/appearance_outlineborder_radius_test.cpp", "rs_display_effect/property_display/appearance_outlineborder_test.cpp", + "rs_display_effect/property_display/appearance_pixelstretch_test.cpp", "rs_display_effect/property_display/appearance_shadow_test.cpp", "rs_display_effect/property_display/appearance_spherize_test.cpp", + "rs_display_effect/property_display/background_blender_tedst.cpp", + "rs_display_effect/property_display/background_blur_test.cpp", + "rs_display_effect/property_display/background_color_test.cpp", + "rs_display_effect/property_display/background_effect_test.cpp", + "rs_display_effect/property_display/background_image_test.cpp", + "rs_display_effect/property_display/background_shader_test.cpp", + "rs_display_effect/property_display/background_useeffect_test.cpp", "rs_display_effect/property_display/fg_blur_test.cpp", "rs_display_effect/property_display/fg_colorbrightness_test.cpp", "rs_display_effect/property_display/fg_colorfilter_test.cpp", @@ -44,17 +53,9 @@ rs_display_effect_sources = [ "rs_display_effect/property_display/geom_persp_test.cpp", "rs_display_effect/property_display/geom_pivotandrotation_test.cpp", "rs_display_effect/property_display/geom_scale_test.cpp", + "rs_display_effect/property_display/geom_skew_test.cpp", + "rs_display_effect/property_display/geom_transform_test.cpp", "rs_display_effect/property_display/geom_translation_test.cpp", - "rs_display_effect/property_display/test_Appearance_PixelStretch.cpp", - "rs_display_effect/property_display/test_G2_CornerRadius.cpp", - "rs_display_effect/property_display/test_Geometry_Transform_Test.cpp", - "rs_display_effect/property_display/test_RSBackground_BeginBlender.cpp", - "rs_display_effect/property_display/test_RSBackground_Color.cpp", - "rs_display_effect/property_display/test_RSBackground_Filter.cpp", - "rs_display_effect/property_display/test_RSBackground_GreyCoef.cpp", - "rs_display_effect/property_display/test_RSBackground_Image.cpp", - "rs_display_effect/property_display/test_RSBackground_UseEffect.cpp", - "rs_display_effect/property_display/test_RSBackground_WaterRipple.cpp", ] rs_framework_sources = [] rs_func_feature_sources = [ "rs_func_feature/component_capture/demo.cpp" ] diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_border_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_border_test.cpp index 8ae4e48f31..863fdec7ae 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_border_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_border_test.cpp @@ -265,7 +265,7 @@ GRAPHIC_TEST(AppearanceTest02, CONTENT_DISPLAY_TEST, Appearance_Border_Touch_Tes uint32_t styleList[] = { 0, 1, 0, 1 }; float xList[] = { 50, 50, 505, 505 }; float yList[] = { 50, 50, 0, 0 }; - + const int nodeCount = 4; const int columnCount = 2; const int nodeSize = 500; @@ -285,9 +285,9 @@ GRAPHIC_TEST(AppearanceTest02, CONTENT_DISPLAY_TEST, Appearance_Border_Touch_Tes auto testNode1 = RSCanvasNode::Create(); testNode1->SetBounds({ x, y, nodeSize, nodeSize }); testNode1->SetBackgroundColor(0xff000000); - testNode1->SetBorderStyle(styleList[i], styleList[i], styleList[i], styleList[i]); + testNode1->SetBorderStyle(Vector4(static_cast(styleList[i]))); testNode1->SetBorderDashGap({ dashGap, dashGap, dashGap, dashGap }); - testNode1->SetBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); + testNode1->SetBorderWidth({ borderWidth, borderWidth, borderWidth, borderWidth }); testNode1->SetBorderColor(0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000); GetRootNode()->AddChild(testNode1); RegisterNode(testNode1); @@ -296,12 +296,75 @@ GRAPHIC_TEST(AppearanceTest02, CONTENT_DISPLAY_TEST, Appearance_Border_Touch_Tes testNode2->SetBounds({ x, y, nodeSize, nodeSize }); testNode2->SetTranslate(xList[i], yList[i], 0); testNode2->SetBackgroundColor(0xff000000); - testNode2->SetBorderStyle(styleList[i], styleList[i], styleList[i], styleList[i]); + testNode2->SetBorderStyle(Vector4(static_cast(styleList[i]))); testNode2->SetBorderDashGap({ dashGap, dashGap, dashGap, dashGap }); - testNode2->SetBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); + testNode2->SetBorderWidth({ borderWidth, borderWidth, borderWidth, borderWidth }); testNode2->SetBorderColor(0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff); GetRootNode()->AddChild(testNode2); RegisterNode(testNode2); } } + +GRAPHIC_TEST(AppearanceTest02, CONTENT_DISPLAY_TEST, Appearance_Bounds_Test) +{ + int columnCount = 2; + int rowCount = 4; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + std::vector valueList = { -10, 0, 10, 100 }; + + // each row we draw a node with bounds width, and a node with bounds height + for (int i = 0; i < rowCount; i++) { + // node with bounds width + int y = (i % rowCount) * sizeY; + auto testNodeBackGround = RSCanvasNode::Create(); + testNodeBackGround->SetBackgroundColor(0xff00ffff); // Node BgColor set to Blue + testNodeBackGround->SetBounds({ 0, y, sizeX - 10, sizeY - 10 }); + testNodeBackGround->SetBoundsWidth(valueList[i]); + GetRootNode()->AddChild(testNodeBackGround); + RegisterNode(testNodeBackGround); + + // node with bounds height + auto testNodeBackGround2 = RSCanvasNode::Create(); + testNodeBackGround2->SetBackgroundColor(0xffff0000); // Node BgColor set to Red + testNodeBackGround2->SetBounds({ sizeX, y, sizeX - 10, sizeY - 10 }); + testNodeBackGround2->SetBoundsHeight(valueList[i]); + GetRootNode()->AddChild(testNodeBackGround2); + RegisterNode(testNodeBackGround2); + }; +} + +GRAPHIC_TEST(AppearanceTest02, CONTENT_DISPLAY_TEST, Appearance_OuterBorder_Style_Test_1) +{ + const int nodeCount = 4; + const int columnCount = 2; + const int nodeSize = 450; + const int nodePos = 510; + const int borderWidth = 10; + + for (int i = 0; i < nodeCount; i++) { + int x = (i % columnCount) * nodePos; + int y = (i / columnCount) * nodePos; + auto testNodeStyle = RSCanvasNode::Create(); + testNodeStyle->SetBounds({ x, y, nodeSize, nodeSize }); + testNodeStyle->SetOuterBorderStyle(Vector4(static_cast(i))); + testNodeStyle->SetOuterBorderWidth({ borderWidth, borderWidth, borderWidth, borderWidth }); + testNodeStyle->SetOuterBorderColor(Vector4(Color::FromArgbInt(0xff000000))); + testNodeStyle->SetOuterBorderRadius({ 50.0, 50.0, 50.0, 50.0 }); + GetRootNode()->AddChild(testNodeStyle); + RegisterNode(testNodeStyle); + } + + // four different style + auto testNodeFourStyle = RSCanvasNode::Create(); + testNodeFourStyle->SetBounds({ 0, nodePos * 2, nodeSize, nodeSize }); + testNodeFourStyle->SetOuterBorderStyle( + { BorderStyle::SOLID, BorderStyle::DASHED, BorderStyle::DOTTED, BorderStyle::NONE }); + testNodeFourStyle->SetOuterBorderWidth({ borderWidth, borderWidth, borderWidth, borderWidth }); + testNodeFourStyle->SetOuterBorderColor(Vector4(Color::FromArgbInt(0xff000000))); + testNodeFourStyle->SetOuterBorderRadius({ 50.0, 50.0, 50.0, 50.0 }); + GetRootNode()->AddChild(testNodeFourStyle); + RegisterNode(testNodeFourStyle); +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_clip_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_clip_test.cpp index d3ca11a50d..19bb27ebea 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_clip_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_clip_test.cpp @@ -117,4 +117,73 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, ClipRRect_Test_2) } } } + +GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, CustomClipToFrame_Test_1) +{ + const Vector4f rect[] = { { 0.1, 0.2, 0.3, 0.4 }, { 0.5, 1.0, 0.5, 1.0 }, { 1, 1, 1, 1 }, + { -0.1, 1.1, -0.2, 2.1 } }; + + const int columnCount = 2; + const int rowCount = 2; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + const int counts = 4; + for (int i = 0; i < counts; i++) { + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNode = + SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { x, y, sizeX - 10, sizeY - 10 }); + testNode->SetBorderStyle(0, 0, 0, 0); + testNode->SetBorderWidth(5, 5, 5, 5); + testNode->SetBorderColor(Vector4(RgbPalette::Green())); + testNode->SetClipToFrame(true); + testNode->SetCustomClipToFrame(rect[i]); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } +} + +GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, SetClipBounds_RSPath_Test_1) +{ + int columnCount = 2; + int rowCount = 4; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + std::vector drawingPath(4, Drawing::Path()); + drawingPath[0].AddRect(0, 0, 200, 450, Drawing::PathDirection::CW_DIRECTION); + drawingPath[1].AddCircle(160, 260, 245); + std::vector triangle = { { 50, 50 }, { 250, 50 }, { 150, 250 } }; + drawingPath[2].AddPoly(triangle, 3, true); + std::vector star = { { 50, 15 }, { 61, 39 }, { 88, 39 }, { 66, 57 }, { 74, 84 }, { 50, 69 }, + { 26, 84 }, { 34, 57 }, { 12, 39 }, { 39, 39 } }; + drawingPath[3].AddPoly(star, 10, true); + drawingPath[3].AddCircle(160, 260, 145); + + for (int i = 0; i < rowCount; i++) { + auto clipPath = RSPath::CreateRSPath(drawingPath[i]); + int y = i * sizeY; + auto testNode1 = RSCanvasNode::Create(); + testNode1->SetBounds({ 0, y, sizeX - 10, sizeY - 10 }); + testNode1->SetBackgroundColor(0xff00ff00); + testNode1->SetBorderStyle(0, 0, 0, 0); + testNode1->SetBorderWidth(5, 5, 5, 5); + testNode1->SetBorderColor(Vector4(RgbPalette::Red())); + testNode1->SetClipToBounds(true); + testNode1->SetClipBounds(clipPath); + GetRootNode()->AddChild(testNode1); + RegisterNode(testNode1); + + auto testNode2 = + SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { sizeX, y, sizeX - 10, sizeY - 10 }); + testNode2->SetBorderStyle(0, 0, 0, 0); + testNode2->SetBorderWidth(5, 5, 5, 5); + testNode2->SetBorderColor(Vector4(RgbPalette::Green())); + testNode2->SetClipToBounds(true); + testNode2->SetClipBounds(clipPath); + GetRootNode()->AddChild(testNode2); + RegisterNode(testNode2); + } +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_G2_CornerRadius.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_g2cornerradius_test.cpp similarity index 100% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_G2_CornerRadius.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/appearance_g2cornerradius_test.cpp diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_outlineborder_radius_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_outlineborder_radius_test.cpp index 98839518c9..73387b9426 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_outlineborder_radius_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_outlineborder_radius_test.cpp @@ -236,6 +236,56 @@ GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Ra RegisterNode(testNodeSolid); } +GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Radius_OutlineDashWidth_Test_1) +{ + uint32_t widthList[] = { 0, 20, 120, 250 }; + Vector4 style = Vector4((BorderStyle)1); + Color color(0, 0, 0); + Vector4 outLineColor = { color, color, color, color }; + + for (int i = 0; i < 4; i++) { + int x = (i % 2) * 520; + int y = (i / 2) * 520; + auto testNodeDashWidth = RSCanvasNode::Create(); + testNodeDashWidth->SetBounds({ x, y, 500, 500 }); + testNodeDashWidth->SetTranslate(20, 20, 0); + // dash style + testNodeDashWidth->SetOutlineStyle(style); + testNodeDashWidth->SetOutlineDashWidth({ widthList[i], widthList[i], widthList[i], widthList[i] }); + testNodeDashWidth->SetOutlineWidth({ 5, 5, 5, 5 }); + testNodeDashWidth->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); + testNodeDashWidth->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeDashWidth); + RegisterNode(testNodeDashWidth); + } + + // four different dash width + auto testNodeFourDashWidth = RSCanvasNode::Create(); + testNodeFourDashWidth->SetBounds({ 0, 520 * 2, 500, 500 }); + testNodeFourDashWidth->SetTranslate(20, 20, 0); + testNodeFourDashWidth->SetOutlineStyle(style); + testNodeFourDashWidth->SetOutlineDashWidth( + { widthList[1] * 0, widthList[1] * 2, widthList[1] * 4, widthList[1] * 8 }); + testNodeFourDashWidth->SetOutlineWidth({ 5, 5, 5, 5 }); + testNodeFourDashWidth->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); + testNodeFourDashWidth->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeFourDashWidth); + RegisterNode(testNodeFourDashWidth); + + // not dash style, set dash width + auto testNodeSolid = RSCanvasNode::Create(); + testNodeSolid->SetBounds({ 520, 520 * 2, 500, 500 }); + testNodeSolid->SetTranslate(20, 20, 0); + // solid style + testNodeSolid->SetOutlineStyle(style); + testNodeSolid->SetOutlineDashWidth({ widthList[1], widthList[1], widthList[1], widthList[1] }); + testNodeSolid->SetOutlineWidth({ 5, 5, 5, 5 }); + testNodeSolid->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); + testNodeSolid->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeSolid); + RegisterNode(testNodeSolid); +} + // Dash Gap GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Radius_DashGap_Test_1) { @@ -286,6 +336,55 @@ GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Ra RegisterNode(testNodeSolid); } +GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Radius_OutlineDashGap_Test_1) +{ + uint32_t gapList[] = { 0, 20, 120, 250 }; + Vector4 style = Vector4((BorderStyle)1); + Color color(0, 0, 0); + Vector4 outLineColor = { color, color, color, color }; + + for (int i = 0; i < 4; i++) { + int x = (i % 2) * 520; + int y = (i / 2) * 520; + auto testNodeDashGap = RSCanvasNode::Create(); + testNodeDashGap->SetBounds({ x, y, 500, 500 }); + testNodeDashGap->SetTranslate(20, 20, 0); + // dash style + testNodeDashGap->SetOutlineStyle(style); + testNodeDashGap->SetOutlineDashGap({ gapList[i], gapList[i], gapList[i], gapList[i] }); + testNodeDashGap->SetOutlineWidth({ 5, 5, 5, 5 }); + testNodeDashGap->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); + testNodeDashGap->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeDashGap); + RegisterNode(testNodeDashGap); + } + + // four different dash width + auto testNodeFourDashGap = RSCanvasNode::Create(); + testNodeFourDashGap->SetBounds({ 0, 520 * 2, 500, 500 }); + testNodeFourDashGap->SetTranslate(20, 20, 0); + testNodeFourDashGap->SetOutlineStyle(style); + testNodeFourDashGap->SetOutlineDashGap({ gapList[1] * 0, gapList[1] * 2, gapList[1] * 4, gapList[1] * 8 }); + testNodeFourDashGap->SetOutlineWidth({ 5, 5, 5, 5 }); + testNodeFourDashGap->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); + testNodeFourDashGap->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeFourDashGap); + RegisterNode(testNodeFourDashGap); + + // not dash style, set dash width + auto testNodeSolid = RSCanvasNode::Create(); + testNodeSolid->SetBounds({ 520, 520 * 2, 500, 500 }); + testNodeSolid->SetTranslate(20, 20, 0); + // solid style + testNodeSolid->SetOutlineStyle(style); + testNodeSolid->SetOutlineDashGap({ gapList[1], gapList[1], gapList[1], gapList[1] }); + testNodeSolid->SetOutlineWidth({ 5, 5, 5, 5 }); + testNodeSolid->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); + testNodeSolid->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeSolid); + RegisterNode(testNodeSolid); +} + // two node eoverlay & touch GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Radius_Touch_Test_1) { diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_outlineborder_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_outlineborder_test.cpp index bf0ac42ede..331328fd55 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_outlineborder_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_outlineborder_test.cpp @@ -206,6 +206,53 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Da RegisterNode(testNodeSolid); } +GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_OutlineDashWidth_Test_1) +{ + uint32_t widthList[] = { 0, 20, 120, TWO_HUNDRED_FIFTY_ }; + Vector4 style = Vector4((BorderStyle)1); + Color color(0, 0, 0); + Vector4 outLineColor = { color, color, color, color }; + + for (int i = 0; i < FOUR_; i++) { + int x = (i % TWO_) * FIVE_HUNDRED_TWENTY_; + int y = (i / TWO_) * FIVE_HUNDRED_TWENTY_; + auto testNodeDashWidth = RSCanvasNode::Create(); + testNodeDashWidth->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ }); + testNodeDashWidth->SetTranslate(TWENTY_, TWENTY_, 0); + // dash style + testNodeDashWidth->SetOutlineStyle(style); + testNodeDashWidth->SetOutlineDashWidth({ widthList[i], widthList[i], widthList[i], widthList[i] }); + testNodeDashWidth->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ }); + testNodeDashWidth->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeDashWidth); + RegisterNode(testNodeDashWidth); + } + + // four different dash width + auto testNodeFourDashWidth = RSCanvasNode::Create(); + testNodeFourDashWidth->SetBounds({ 0, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ }); + testNodeFourDashWidth->SetTranslate(TWENTY_, TWENTY_, 0); + testNodeFourDashWidth->SetOutlineStyle(style); + testNodeFourDashWidth->SetOutlineDashWidth( + { widthList[1] * 0, widthList[1] * 2, widthList[1] * 4, widthList[1] * 8 }); + testNodeFourDashWidth->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ }); + testNodeFourDashWidth->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeFourDashWidth); + RegisterNode(testNodeFourDashWidth); + + // not dash style, set dash width + auto testNodeSolid = RSCanvasNode::Create(); + testNodeSolid->SetBounds({ FIVE_HUNDRED_TWENTY_, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ }); + testNodeSolid->SetTranslate(TWENTY_, TWENTY_, 0); + // solid style + testNodeSolid->SetOutlineStyle(style); + testNodeSolid->SetOutlineDashWidth({ widthList[1], widthList[1], widthList[1], widthList[1] }); + testNodeSolid->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ }); + testNodeSolid->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeSolid); + RegisterNode(testNodeSolid); +} + // Dash Gap GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_DashGap_Test_1) { @@ -253,6 +300,52 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Da RegisterNode(testNodeSolid); } +GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_OutlineDashGap_Test_1) +{ + uint32_t gapList[] = { 0, 20, 120, TWO_HUNDRED_FIFTY_ }; + Vector4 style = Vector4((BorderStyle)1); + Color color(0, 0, 0); + Vector4 outLineColor = { color, color, color, color }; + + for (int i = 0; i < FOUR_; i++) { + int x = (i % TWO_) * FIVE_HUNDRED_TWENTY_; + int y = (i / TWO_) * FIVE_HUNDRED_TWENTY_; + auto testNodeDashGap = RSCanvasNode::Create(); + testNodeDashGap->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ }); + testNodeDashGap->SetTranslate(TWENTY_, TWENTY_, 0); + // dash style + testNodeDashGap->SetOutlineStyle(style); + testNodeDashGap->SetOutlineDashGap({ gapList[i], gapList[i], gapList[i], gapList[i] }); + testNodeDashGap->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ }); + testNodeDashGap->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeDashGap); + RegisterNode(testNodeDashGap); + } + + // four different dash width + auto testNodeFourDashGap = RSCanvasNode::Create(); + testNodeFourDashGap->SetBounds({ 0, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ }); + testNodeFourDashGap->SetTranslate(TWENTY_, TWENTY_, 0); + testNodeFourDashGap->SetOutlineStyle(style); + testNodeFourDashGap->SetOutlineDashGap({ gapList[1] * 0, gapList[1] * 2, gapList[1] * 4, gapList[1] * 8 }); + testNodeFourDashGap->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ }); + testNodeFourDashGap->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeFourDashGap); + RegisterNode(testNodeFourDashGap); + + // not dash style, set dash width + auto testNodeSolid = RSCanvasNode::Create(); + testNodeSolid->SetBounds({ FIVE_HUNDRED_TWENTY_, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ }); + testNodeSolid->SetTranslate(TWENTY_, TWENTY_, 0); + // solid style + testNodeSolid->SetOutlineStyle(style); + testNodeSolid->SetOutlineDashGap({ gapList[1], gapList[1], gapList[1], gapList[1] }); + testNodeSolid->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ }); + testNodeSolid->SetOutlineColor(outLineColor); + GetRootNode()->AddChild(testNodeSolid); + RegisterNode(testNodeSolid); +} + // two node eoverlay & touch GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Touch_Test_1) { diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_Appearance_PixelStretch.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_pixelstretch_test.cpp similarity index 88% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_Appearance_PixelStretch.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/appearance_pixelstretch_test.cpp index e456bdca7d..f4e7b316a7 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/test_Appearance_PixelStretch.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_pixelstretch_test.cpp @@ -16,6 +16,8 @@ #include "rs_graphic_test.h" #include "rs_graphic_test_img.h" +#include "property/rs_properties.h" + using namespace testing; using namespace testing::ext; @@ -181,4 +183,26 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_MagnifierParams_Te RegisterNode(testNodeBackGround2); } +GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_FrameGravity_Test) +{ + int columnCount = 4; + int rowCount = 4; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + for (int i = static_cast(Gravity::CENTER); i <= static_cast(Gravity::RESIZE_ASPECT_FILL_BOTTOM_RIGHT); + i++) { + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNodeBackGround = + SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { x, y, sizeX - 10, sizeY - 10 }); + testNodeBackGround->SetBorderStyle(0, 0, 0, 0); + testNodeBackGround->SetBorderWidth(5, 5, 5, 5); + testNodeBackGround->SetBorderColor(Vector4(RgbPalette::Green())); + testNodeBackGround->SetFrameGravity(static_cast(i)); + GetRootNode()->AddChild(testNodeBackGround); + RegisterNode(testNodeBackGround); + } +} + } // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_shadow_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_shadow_test.cpp index 12171c6b4c..ae34d771b4 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/appearance_shadow_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/appearance_shadow_test.cpp @@ -381,4 +381,69 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Touch_Test_ } } +GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Filter_Test_1) +{ + int nodePos = 500; + int nodeSize = 20; + + uint32_t colorList[] = { 0xff000000, 0xffff0000, 0xff00ff00, 0xff0000ff }; + std::vector drawingPath(4, Drawing::Path()); + drawingPath[0].AddRect(0, 0, 200, 450, Drawing::PathDirection::CW_DIRECTION); + drawingPath[1].AddCircle(160, 260, 245); + std::vector triangle = { { 50, 50 }, { 250, 50 }, { 150, 250 } }; + drawingPath[2].AddPoly(triangle, 3, true); + std::vector star = { { 50, 15 }, { 61, 39 }, { 88, 39 }, { 66, 57 }, { 74, 84 }, { 50, 69 }, + { 26, 84 }, { 34, 57 }, { 12, 39 }, { 39, 39 } }; + drawingPath[3].AddPoly(star, 10, true); + drawingPath[3].AddCircle(160, 260, 145); + + for (int i = 0; i < 4; i++) { + auto shadowPath = RSPath::CreateRSPath(drawingPath[i]); + int x = (i % 2) * nodePos; + int y = (i / 2) * nodePos; + auto testNode = RSCanvasNode::Create(); + testNode->SetBounds({ x, y, nodeSize, nodeSize }); + testNode->SetBackgroundColor(0xffc0c0c0); + testNode->SetShadowColor(colorList[i]); + testNode->SetShadowRadius(30); + testNode->SetShadowPath(shadowPath); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } +} + +GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Filter_Test_2) +{ + int nodePos = 500; + int nodeSize = 20; + + uint32_t colorList[] = { 0xff000000, 0xffff0000, 0xff00ff00, 0xff0000ff }; + std::vector drawingPath(4, Drawing::Path()); + drawingPath[0].AddRect(0, 0, 200, 450, Drawing::PathDirection::CW_DIRECTION); + drawingPath[1].AddCircle(160, 260, 245); + std::vector triangle = { { 50, 50 }, { 250, 50 }, { 150, 250 } }; + drawingPath[2].AddPoly(triangle, 3, true); + std::vector star = { { 50, 15 }, { 61, 39 }, { 88, 39 }, { 66, 57 }, { 74, 84 }, { 50, 69 }, + { 26, 84 }, { 34, 57 }, { 12, 39 }, { 39, 39 } }; + drawingPath[3].AddPoly(star, 10, true); + drawingPath[3].AddCircle(160, 260, 145); + std::vector filledList = { false, true, false, true }; + + for (int i = 0; i < 4; i++) { + auto shadowPath = RSPath::CreateRSPath(drawingPath[i]); + int x = (i % 2) * nodePos; + int y = (i / 2) * nodePos; + auto testNode = RSCanvasNode::Create(); + testNode->SetBounds({ x, y, nodeSize, nodeSize }); + testNode->SetBackgroundColor(0xffc0c0c0); + testNode->SetShadowColor(colorList[i]); + testNode->SetShadowElevation(30); + testNode->SetShadowOffset(50, 50); + testNode->SetShadowIsFilled(filledList[i]); + testNode->SetShadowPath(shadowPath); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } +} + } // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_BeginBlender.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/background_blender_tedst.cpp similarity index 100% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_BeginBlender.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/background_blender_tedst.cpp diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_Filter.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/background_blur_test.cpp similarity index 100% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_Filter.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/background_blur_test.cpp diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_Color.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/background_color_test.cpp similarity index 89% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_Color.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/background_color_test.cpp index ed9c249757..b9306b2d89 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_Color.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/background_color_test.cpp @@ -168,27 +168,23 @@ GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, BackGround_Brightness_Fract_T } } -GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, BackGround_Shader_Test) +GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, Grey_Coef_Test) { int columnCount = 2; - int rowCount = 2; + int rowCount = 3; auto sizeX = screenWidth / columnCount; auto sizeY = screenHeight / rowCount; - std::vector> shaderEffectList = { - OHOS::Rosen::Drawing::ShaderEffect::CreateColorShader(Drawing::Color::COLOR_CYAN), - OHOS::Rosen::Drawing::ShaderEffect::CreateLinearGradient({ 10, 10 }, { 100, 100 }, - { Drawing::Color::COLOR_GREEN, Drawing::Color::COLOR_BLUE, Drawing::Color::COLOR_RED }, { 0.0, 0.5, 1.0 }, - Drawing::TileMode::MIRROR) - }; - for (int i = 0; i < shaderEffectList.size(); i++) { + std::vector greyCoefList = { { -10, -10 }, { -1, -1 }, { 0, 0 }, { 0.5, 0.5 }, { 1, 1 }, { 10, 10 } }; + + for (int i = 0; i < greyCoefList.size(); i++) { int x = (i % columnCount) * sizeX; int y = (i / columnCount) * sizeY; - auto testNodeBackGround = RSCanvasNode::Create(); - testNodeBackGround->SetBounds({ x, y, sizeX - 10, sizeY - 10 }); - auto currentShader = RSShader::CreateRSShader(shaderEffectList[i]); - testNodeBackGround->SetBackgroundShader(currentShader); - testNodeBackGround->SetBorderWidth(5); + auto testNodeBackGround = + SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { x, y, sizeX - 10, sizeY - 10 }); + testNodeBackGround->SetGreyCoef(greyCoefList[i]); + testNodeBackGround->SetBorderStyle(0, 0, 0, 0); + testNodeBackGround->SetBorderWidth(5, 5, 5, 5); testNodeBackGround->SetBorderColor(Vector4(RgbPalette::Red())); GetRootNode()->AddChild(testNodeBackGround); RegisterNode(testNodeBackGround); diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_WaterRipple.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/background_effect_test.cpp similarity index 100% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_WaterRipple.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/background_effect_test.cpp diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_Image.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/background_image_test.cpp similarity index 97% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_Image.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/background_image_test.cpp index dc353b1a77..a429a7042f 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_Image.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/background_image_test.cpp @@ -188,8 +188,7 @@ GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, Background_BackgroundImage_Co auto testNodeBackGround = SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { x, y, borderWidth, borderHeight }); - testNodeBackGround->SetBgImagePositionX(20); - testNodeBackGround->SetBgImagePositionY(20); + testNodeBackGround->SetBgImagePosition(20, 20); testNodeBackGround->SetBgImageWidth(borderWidth * 0.8); testNodeBackGround->SetBgImageHeight(borderHeight * 0.8); testNodeBackGround->SetCornerRadius(sizeX * 0.2); @@ -206,8 +205,7 @@ GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, Background_BackgroundImage_Co testNodeBackGround = SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { x, y, borderWidth, borderHeight }); - testNodeBackGround->SetBgImagePositionX(20); - testNodeBackGround->SetBgImagePositionY(borderHeight * 0.3); + testNodeBackGround->SetBgImagePosition(20, borderHeight * 0.3); testNodeBackGround->SetBgImageWidth(borderWidth * 0.8); testNodeBackGround->SetBgImageHeight(borderHeight * 0.8); diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/background_shader_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/background_shader_test.cpp new file mode 100644 index 0000000000..78ace20014 --- /dev/null +++ b/graphic_test/graphic_test/rs_display_effect/property_display/background_shader_test.cpp @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rs_graphic_test.h" +#include "rs_graphic_test_img.h" + +#include "effect/shader_effect.h" +#include "render/rs_dot_matrix_shader.h" +#include "render/rs_flow_light_sweep_shader.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Rosen { + +class BackgroundTest : public RSGraphicTest { +private: + const int screenWidth = 1200; + const int screenHeight = 2000; + +public: + // called before each tests + void BeforeEach() override + { + SetScreenSurfaceBounds({ 0, 0, screenWidth, screenHeight }); + } +}; + +struct DotMatrixTestParam { +public: + std::vector dotColorList; + std::vector dotRadiusList; + std::vector dotSpacingList; + std::vector bgColorList; + std::vector progressList; + std::vector> effectColorList; + std::vector> colorFractionsList; + std::vector> startPointsList; + std::vector pathWidthList; + std::vector inverseEffectList; + + void InitRippleEffectParam() + { + dotColorList = { 0xffff0000, 0xffff0000, 0xffff0000, 0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff, + 0xff0000ff }; + dotRadiusList = { -0.7, 0.02, 0.05, 0.1, 0.2, 0.4, 0.6, 1.0, 10.0 }; + dotSpacingList = { -10.0, 10.0, 50.0, 20.0, 40.0, 60.0, 10.0, 50.0, 100.0 }; + bgColorList = { 0xffffffff, 0xff888888, 0xff000000, 0xffffffff, 0xff888888, 0xff000000, 0xffffffff, 0xff888888, + 0xff000000 }; + effectColorList = { { 0xffffff00, 0xffffff00, 0xff00ffff, 0xff00ffff }, + { 0xffff00ff, 0xffff00ff, 0xffffff00, 0xffffff00 }, { 0xff00ffff, 0xff00ffff, 0xff0000ff, 0xff0000ff }, + { 0xffff0000, 0xffff0000, 0xffffff00, 0xffffff00 }, { 0xff0000ff, 0xff0000ff, 0xff00ffff, 0xff00ffff }, + { 0xff00ffff, 0xff00ffff, 0xffff00ff, 0xffff00ff }, { 0xffff0000, 0xff00ff00, 0xff0000ff, 0xffffffff }, + { 0xffffffff, 0xff888888, 0xff000000, 0xff888888 }, { 0xff0000ff, 0xff00ff00, 0xff0000ff, 0xffff0000 } }; + progressList = { -18.6, 0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 2.0, 20.0 }; + colorFractionsList = { { -0.2, -0.2 }, { 0.0, 0.0 }, { 0.5, 1.2 }, { 0.2, 0.3 }, { 0.8, 0.1 }, { 0.5, 1.0 }, + { 1.0, 0.2 }, { 0.5, 0.5 }, { 0.1, 0.9 } }; + startPointsList = { + {}, + { Drawing::PointF(0.1, 0.9) }, + { Drawing::PointF(0.5, 0.5), Drawing::PointF(0.2, 0.2) }, + { Drawing::PointF(-0.5, 0.5), Drawing::PointF(1.2, 0.2) }, + { Drawing::PointF(0, 1), Drawing::PointF(1, 0) }, + { Drawing::PointF(0.2, 0.8), Drawing::PointF(0.8, 0.2) }, + { Drawing::PointF(0, 0), Drawing::PointF(1, 1) }, + { Drawing::PointF(0.2, 0.8), Drawing::PointF(0.8, 0.2) }, + { Drawing::PointF(0, 0), Drawing::PointF(1, 1) }, + }; + pathWidthList = { -0.5, 0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0, 5.0 }; + inverseEffectList = { false, true, false, true, false, true, false, true, false }; + } +}; + +GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, BackGround_Shader_Test) +{ + int columnCount = 2; + int rowCount = 2; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + std::vector> shaderEffectList = { + OHOS::Rosen::Drawing::ShaderEffect::CreateColorShader(Drawing::Color::COLOR_CYAN), + OHOS::Rosen::Drawing::ShaderEffect::CreateLinearGradient({ 10, 10 }, { 100, 100 }, + { Drawing::Color::COLOR_GREEN, Drawing::Color::COLOR_BLUE, Drawing::Color::COLOR_RED }, { 0.0, 0.5, 1.0 }, + Drawing::TileMode::MIRROR) + }; + for (int i = 0; i < shaderEffectList.size(); i++) { + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNodeBackGround = RSCanvasNode::Create(); + testNodeBackGround->SetBounds({ x, y, sizeX - 10, sizeY - 10 }); + auto currentShader = RSShader::CreateRSShader(shaderEffectList[i]); + testNodeBackGround->SetBackgroundShader(currentShader); + testNodeBackGround->SetBorderWidth(5); + testNodeBackGround->SetBorderColor(Vector4(RgbPalette::Red())); + GetRootNode()->AddChild(testNodeBackGround); + RegisterNode(testNodeBackGround); + } +} + + +GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, BackGround_DotMatrix_Shader_NoEffect_Test) +{ + int columnCount = 3; + int rowCount = 3; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + std::vector dotColorList = { 0xffff0000, 0xffff0000, 0xffff0000, 0xff00ff00, 0xff00ff00, 0xff00ff00, + 0xff0000ff, 0xff0000ff, 0xff0000ff }; + std::vector dotRadiusList = { -0.7, 0.02, 0.05, 0.1, 0.2, 0.4, 0.6, 1.0, 10.0 }; + std::vector dotSpacingList = { -10.0, 10.0, 50.0, 20.0, 40.0, 60.0, 10.0, 50.0, 100.0 }; + std::vector bgColorList = { 0xffffffff, 0xff888888, 0xff000000, 0xffffffff, 0xff888888, 0xff000000, + 0xffffffff, 0xff888888, 0xff000000 }; + + for (int i = 0; i < dotColorList.size(); i++) { + auto dotMatShader = std::make_shared(); + if (dotMatShader == nullptr) { + return; + } + dotMatShader->SetNormalParams(dotColorList[i], dotSpacingList[i], dotRadiusList[i], bgColorList[i]); + dotMatShader->SetNoneEffect(); + + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNodeBackGround = RSCanvasNode::Create(); + testNodeBackGround->SetBounds({ x, y, sizeX - 10, sizeY - 10 }); + testNodeBackGround->SetBackgroundShader(dotMatShader); + testNodeBackGround->SetBackgroundShaderProgress(1.0); + GetRootNode()->AddChild(testNodeBackGround); + RegisterNode(testNodeBackGround); + } +} + +GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, BackGround_DotMatrix_Shader_RotateEffect_Test) +{ + int columnCount = 3; + int rowCount = 3; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + std::vector dotColorList = { 0xffff0000, 0xffff0000, 0xffff0000, 0xff00ff00, 0xff00ff00, 0xff00ff00, + 0xff0000ff, 0xff0000ff, 0xff0000ff }; + std::vector dotRadiusList = { -0.7, 0.02, 0.05, 0.1, 0.2, 0.4, 0.6, 1.0, 10.0 }; + std::vector dotSpacingList = { -10.0, 10.0, 50.0, 20.0, 40.0, 60.0, 10.0, 50.0, 100.0 }; + std::vector bgColorList = { 0xffffffff, 0xff888888, 0xff000000, 0xffffffff, 0xff888888, 0xff000000, + 0xffffffff, 0xff888888, 0xff000000 }; + std::vector> effectColorList = { { 0xffffff00, 0xffffff00, 0xff00ffff, 0xff00ffff }, + { 0xffff00ff, 0xffff00ff, 0xffffff00, 0xffffff00 }, { 0xff00ffff, 0xff00ffff, 0xff0000ff, 0xff0000ff }, + { 0xffff0000, 0xffff0000, 0xffffff00, 0xffffff00 }, { 0xff0000ff, 0xff0000ff, 0xff00ffff, 0xff00ffff }, + { 0xff00ffff, 0xff00ffff, 0xffff00ff, 0xffff00ff }, { 0xffff0000, 0xff00ff00, 0xff0000ff, 0xffffffff }, + { 0xffffffff, 0xff888888, 0xff000000, 0xff888888 }, { 0xff0000ff, 0xff00ff00, 0xff0000ff, 0xffff0000 } }; + std::vector progressList = { -18.6, 0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 2.0, 20.0 }; + + for (int i = 0; i < dotColorList.size(); i++) { + auto dotMatShader = std::make_shared(); + if (dotMatShader == nullptr) { + return; + } + dotMatShader->SetNormalParams(dotColorList[i], dotSpacingList[i], dotRadiusList[i], bgColorList[i]); + + RotateEffectParams rotateEffectParams; + rotateEffectParams.effectColors_ = effectColorList[i]; // vector size == 4 + rotateEffectParams.pathDirection_ = static_cast(i); + dotMatShader->SetRotateEffect(rotateEffectParams); + + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNodeBackGround = RSCanvasNode::Create(); + testNodeBackGround->SetBounds({ x, y, sizeX - 10, sizeY - 10 }); + testNodeBackGround->SetBackgroundShader(dotMatShader); + testNodeBackGround->SetBackgroundShaderProgress(progressList[i]); + GetRootNode()->AddChild(testNodeBackGround); + RegisterNode(testNodeBackGround); + } +} + +GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, BackGround_DotMatrix_Shader_RippleEffect_Test) +{ + int columnCount = 3; + int rowCount = 3; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + DotMatrixTestParam testParam; + testParam.InitRippleEffectParam(); + + for (int i = 0; i < columnCount * rowCount; i++) { + auto dotMatShader = std::make_shared(); + if (dotMatShader == nullptr) { + return; + } + dotMatShader->SetNormalParams(testParam.dotColorList[i], testParam.dotSpacingList[i], + testParam.dotRadiusList[i], testParam.bgColorList[i]); + + RippleEffectParams rippleEffectParams; + rippleEffectParams.effectColors_ = testParam.effectColorList[i]; // vector size >= 2 + rippleEffectParams.colorFractions_ = testParam.colorFractionsList[i]; + rippleEffectParams.startPoints_ = testParam.startPointsList[i]; + rippleEffectParams.pathWidth_ = testParam.pathWidthList[i]; + rippleEffectParams.inverseEffect_ = testParam.inverseEffectList[i]; + dotMatShader->SetRippleEffect(rippleEffectParams); + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNodeBackGround = RSCanvasNode::Create(); + testNodeBackGround->SetBounds({ x, y, sizeX - 10, sizeY - 10 }); + testNodeBackGround->SetBackgroundShader(dotMatShader); + testNodeBackGround->SetBackgroundShaderProgress(testParam.progressList[i]); + GetRootNode()->AddChild(testNodeBackGround); + RegisterNode(testNodeBackGround); + } +} + +GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, BackGround_FlowLightSweep_Shader_Test) +{ + int columnCount = 4; + int rowCount = 4; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + // create dot color list, the float value range is [0, 1] + std::vector> effectColor_1 = { { Drawing::Color::COLOR_RED, 0.0 }, + { Drawing::Color::COLOR_GREEN, 0.2 }, { Drawing::Color::COLOR_BLUE, 0.4 }, + { Drawing::Color::COLOR_YELLOW, 0.6 }, { Drawing::Color::COLOR_CYAN, 0.8 }, + { Drawing::Color::COLOR_MAGENTA, 1.0 } }; + + std::vector> effectColor_2 = { { Drawing::Color::COLOR_RED, -1.0 }, + { Drawing::Color::COLOR_GREEN, 0.2 }, { Drawing::Color::COLOR_BLUE, 0.5 }, + { Drawing::Color::COLOR_YELLOW, 0.5 }, { Drawing::Color::COLOR_CYAN, 0.2 }, + { Drawing::Color::COLOR_MAGENTA, 2.0 } }; + + std::vector> effectColor_3 = { { Drawing::Color::COLOR_BLACK, 1.0 }, + { Drawing::Color::COLOR_GREEN, 0.2 }, { Drawing::Color::COLOR_GRAY, 0.8 }, + { Drawing::Color::COLOR_YELLOW, 0.5 }, { Drawing::Color::COLOR_WHITE, 0.3 }, + { Drawing::Color::COLOR_MAGENTA, 0.7 } }; + + std::vector> effectColor_4 = { { Drawing::Color::COLOR_RED, -10.0 }, + { Drawing::Color::COLOR_GREEN, 0.3 }, { Drawing::Color::COLOR_BLUE, 10.0 } }; + + std::vector>> effectColorList = { effectColor_1, effectColor_2, + effectColor_3, effectColor_4 }; + + std::vector progressList = { -10, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 10, 0.25, 0.75, + 0.66 }; + + for (int i = 0; i < columnCount * rowCount; i++) { + auto flowLightShader = std::make_shared(effectColorList[i / columnCount]); + if (flowLightShader == nullptr) { + return; + } + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNodeBackGround = RSCanvasNode::Create(); + testNodeBackGround->SetBounds({ x, y, sizeX - 10, sizeY - 10 }); + testNodeBackGround->SetBackgroundShader(flowLightShader); + testNodeBackGround->SetBackgroundShaderProgress(progressList[i % progressList.size()]); + GetRootNode()->AddChild(testNodeBackGround); + RegisterNode(testNodeBackGround); + } +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_UseEffect.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/background_useeffect_test.cpp similarity index 100% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_UseEffect.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/background_useeffect_test.cpp diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/fg_colorfilter_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/fg_colorfilter_test.cpp index 288d807d21..23258a9225 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/fg_colorfilter_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/fg_colorfilter_test.cpp @@ -17,6 +17,8 @@ #include "rs_graphic_test.h" #include "rs_graphic_test_img.h" +#include "render/rs_material_filter.h" + using namespace testing; using namespace testing::ext; @@ -156,4 +158,37 @@ GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Color_AiInvert_Test_1) } } +GRAPHIC_TEST(ForegroundTest01, CONTENT_DISPLAY_TEST, Foreground_Filter_Test_1) +{ + int columnCount = 2; + int rowCount = 2; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + std::vector radiusList = { 0.1, 0.5, 2.9, 100 }; + std::vector saturateList = { 0.5, 0.6, 2.8, 100.0 }; + std::vector brightnessList = { 0.1, 0.2, 2.9, 50.0 }; + std::vector maskColorList = { 0xff000000, 0xffff0000, 0xff00ff00, 0xff0000ff }; + + for (int i = 0; i < radiusList.size(); i++) { + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, sizeX - 10, sizeY - 10 }); + testNode->SetBorderStyle(0, 0, 0, 0); + testNode->SetBorderWidth(5, 5, 5, 5); + testNode->SetBorderColor(Vector4(RgbPalette::Red())); + + MaterialParam materialParam; + materialParam.brightness = brightnessList[i]; + materialParam.maskColor = Color::FromArgbInt(maskColorList[i]); + materialParam.radius = radiusList[i]; + materialParam.saturation = saturateList[i]; + auto materialFilter = std::make_shared( + materialParam, BLUR_COLOR_MODE::AVERAGE); // BLUR_COLOR_MODE::AVERAGE == 1 + testNode->SetFilter(materialFilter); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } +} + } // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/geom_clip_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/geom_clip_test.cpp index 05a8b0da1f..c07a6738a6 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/geom_clip_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/geom_clip_test.cpp @@ -50,7 +50,7 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_ClipFlame_Test_1) for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { auto testFaNode = RSCanvasNode::Create(); - testFaNode->SetFrame({ i * 410.0, j * 500.0, 400.0, 400.0 }); + testFaNode->SetBounds({ i * 410.0, j * 500.0, 400.0, 400.0 }); testFaNode->SetFrame({ i * 410.0, j * 500.0, 400.0, 400.0 }); auto imageModifier = std::make_shared(); imageModifier->SetWidth(400); @@ -89,7 +89,7 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_ClipFlame_Test_2) for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { auto testFaNode = RSCanvasNode::Create(); - testFaNode->SetFrame({ i * 410.0, j * 500.0, 400.0, 400.0 }); + testFaNode->SetFrame(i * 410.0, j * 500.0, 400.0, 400.0); auto imageModifier = std::make_shared(); imageModifier->SetWidth(400); imageModifier->SetHeight(400); @@ -97,7 +97,11 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_ClipFlame_Test_2) testFaNode->AddModifier(imageModifier); testFaNode->SetClipToFrame(false); auto testNode = RSCanvasNode::Create(); - testNode->SetFrame({ 0.0, 50.0, 400.0, 400.0 }); + + // testNode->SetFrame({ 0.0, 50.0, 400.0, 400.0 }) convert to SetFramePositionXY + testNode->SetFrame(0.0, 0.0, 400.0, 400.0); + testNode->SetFramePositionX(0.0); + testNode->SetFramePositionY(50.0); testNode->SetBackgroundColor(0xff00ff00); testFaNode->AddChild(testNode); testFaNode->SetClipRRect(rect[i], radius[j]); diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/geom_persp_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/geom_persp_test.cpp index 8853bbf32b..0fe37bcfc8 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/geom_persp_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/geom_persp_test.cpp @@ -56,8 +56,34 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_Persp_Test_2) auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { 380, (i - 1) * 680 + 40, 600, 600 }); testNode->SetPivot(Vector2f(0.5, 0.5)); testNode->SetRotation(45.0, 0, 45.0); - testNode->SetPerspX(xList[i]); - testNode->SetPerspY(yList[i]); + testNode->SetPersp(xList[i], yList[i]); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } +} + +GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_Persp_Test_3) +{ + float xList[] = { -1.0, 0.0, 1 }; + float yList[] = { -1.0, 0.0, 0 }; + for (int i = 1; i < 3; i++) { + auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { 380, (i - 1) * 680 + 40, 600, 600 }); + testNode->SetPivot(Vector2f(0.5, 0.5)); + testNode->SetRotation(45.0, 0, 45.0); + testNode->SetPersp({ xList[i], yList[i] }); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } +} + +GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_Persp_Test_4) +{ + float persp[] = { 0.8, 1.0 }; + for (int i = 0; i < 2; i++) { + auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { 380, i * 880 + 200, 600, 600 }); + testNode->SetPivot(Vector2f(0.5, 0.5)); + testNode->SetRotation(0.0, 0, 45.0); + testNode->SetPersp(persp[i]); GetRootNode()->AddChild(testNode); RegisterNode(testNode); } diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/geom_pivotandrotation_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/geom_pivotandrotation_test.cpp index 0f6dd7264a..387f8cc304 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/geom_pivotandrotation_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/geom_pivotandrotation_test.cpp @@ -94,7 +94,8 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Pivot_0_Rotation_quaternion_Tes }; for (int i = 0; i < 4; i++) { auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { 280, i * 480 + 40, 400, 400 }); - testNode->SetPivot(Vector2f(0, 0)); + testNode->SetPivotX(0); + testNode->SetPivotY(0); testNode->SetRotation(degreeList[i]); GetRootNode()->AddChild(testNode); RegisterNode(testNode); @@ -111,7 +112,8 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Pivot_05_Rotation_quaternion_Te }; for (int i = 0; i < 4; i++) { auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { 280, i * 480 + 40, 400, 400 }); - testNode->SetPivot(Vector2f(0.5, 0.5)); + testNode->SetPivotX(0.5); + testNode->SetPivotY(0.5); testNode->SetRotation(degreeList[i]); GetRootNode()->AddChild(testNode); RegisterNode(testNode); @@ -128,7 +130,8 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Pivot_1_Rotation_quaternion_Tes }; for (int i = 0; i < 4; i++) { auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { 280, i * 480 + 40, 400, 400 }); - testNode->SetPivot(Vector2f(1, 1)); + testNode->SetPivotX(1); + testNode->SetPivotY(1); testNode->SetRotation(degreeList[i]); GetRootNode()->AddChild(testNode); RegisterNode(testNode); @@ -140,7 +143,8 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, PivotZ_Rotation_Test_1) float zList[] = { 0.0, 0.5, 1.0, 100.0 }; for (int i = 0; i < 4; i++) { auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { 280, i * 480 + 40, 400, 400 }); - testNode->SetPivot(Vector2f(0.5, 0.5)); + testNode->SetPivotX(0.5); + testNode->SetPivotY(0.5); testNode->SetPivotZ(zList[i]); testNode->SetRotation(0, 45.0, 0); GetRootNode()->AddChild(testNode); diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/geom_scale_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/geom_scale_test.cpp index ef0b5ae45e..cafd548315 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/geom_scale_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/geom_scale_test.cpp @@ -49,4 +49,34 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_Scale_Test_1) } } +GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_Scale_Test_2) +{ + float zList[] = { 1, 0.5, 2 }; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + auto testNode = + SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { j * 420 + 110, i * 420 + 110, 200, 200 }); + testNode->SetPivot(Vector2f(0.5, 0.5)); + testNode->SetScale(zList[i], zList[j]); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } + } +} + +GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_Scale_Test_3) +{ + float zList[] = { 1, 0.5, 2 }; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + auto testNode = + SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { j * 420 + 110, i * 420 + 110, 200, 200 }); + testNode->SetPivot(Vector2f(0.5, 0.5)); + testNode->SetScale({ zList[i], zList[j] }); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } + } +} + } // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_GreyCoef.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/geom_skew_test.cpp similarity index 52% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_GreyCoef.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/geom_skew_test.cpp index 12be410c9b..c505613113 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/test_RSBackground_GreyCoef.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/geom_skew_test.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ -#include "rs_graphic_test.h" #include "rs_graphic_test_img.h" using namespace testing; @@ -21,7 +20,7 @@ using namespace testing::ext; namespace OHOS::Rosen { -class BackgroundTest : public RSGraphicTest { +class GeometryTest : public RSGraphicTest { private: const int screenWidth = 1200; const int screenHeight = 2000; @@ -34,27 +33,33 @@ public: } }; -GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, Grey_Coef_Test) +GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_Skew_Test_1) { int columnCount = 2; - int rowCount = 3; + int rowCount = 4; auto sizeX = screenWidth / columnCount; auto sizeY = screenHeight / rowCount; - std::vector greyCoefList = { { -10, -10 }, { -1, -1 }, { 0, 0 }, { 0.5, 0.5 }, { 1, 1 }, { 10, 10 } }; - - for (int i = 0; i < greyCoefList.size(); i++) { + std::vector> skewValues = { { -0.5, -0.1 }, { 0.1, 0.5 }, { 0.2, 0.3 }, { 1.5, 0.5 }, + { 0.5, 1.5 }, { 10, 20 }, { 0.5, 0.5 }, { 1.2, 1.2 } }; + for (int i = 0; i < skewValues.size(); ++i) { int x = (i % columnCount) * sizeX; int y = (i / columnCount) * sizeY; - auto testNodeBackGround = - SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { x, y, sizeX - 10, sizeY - 10 }); - testNodeBackGround->SetGreyCoef(greyCoefList[i]); - testNodeBackGround->SetBorderStyle(0, 0, 0, 0); - testNodeBackGround->SetBorderWidth(5, 5, 5, 5); - testNodeBackGround->SetBorderColor(Vector4(RgbPalette::Red())); - GetRootNode()->AddChild(testNodeBackGround); - RegisterNode(testNodeBackGround); + auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { x, y, sizeX - 10, sizeY - 10 }); + testNode->SetPivot(Vector2f(0.0, 0.0)); + // try to cover all SetSkew funcitons + if (i < 2) { + testNode->SetSkew({ skewValues[i][0], skewValues[i][1] }); + } else if (i < 4) { + testNode->SetSkew(skewValues[i][0], skewValues[i][1]); + } else if (i < 6) { + testNode->SetSkewX(skewValues[i][0]); + testNode->SetSkewY(skewValues[i][1]); + } else { + testNode->SetSkew(skewValues[i][0]); + } + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); } } - } // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/test_Geometry_Transform_Test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/geom_transform_test.cpp similarity index 100% rename from graphic_test/graphic_test/rs_display_effect/property_display/test_Geometry_Transform_Test.cpp rename to graphic_test/graphic_test/rs_display_effect/property_display/geom_transform_test.cpp diff --git a/graphic_test/graphic_test/rs_display_effect/property_display/geom_translation_test.cpp b/graphic_test/graphic_test/rs_display_effect/property_display/geom_translation_test.cpp index 2a35907ceb..78eacff9bd 100644 --- a/graphic_test/graphic_test/rs_display_effect/property_display/geom_translation_test.cpp +++ b/graphic_test/graphic_test/rs_display_effect/property_display/geom_translation_test.cpp @@ -55,11 +55,34 @@ GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_TranslationZ_Test_2) int y = (i / 2) * 510; auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { x, y, 500, 500 }); testNode->SetPivot(Vector2f(0, 0)); - testNode->SetTranslate(Vector2f(transList[i], transList[i])); + testNode->SetTranslateX(transList[i]); + testNode->SetTranslateY(transList[i]); testNode->SetTranslateZ(transList[i]); GetRootNode()->AddChild(testNode); RegisterNode(testNode); } } +GRAPHIC_TEST(GeometryTest, CONTENT_DISPLAY_TEST, Geometry_SetPositionZ_Test_1) +{ + int columnCount = 2; + int rowCount = 4; + auto sizeX = screenWidth / columnCount; + auto sizeY = screenHeight / rowCount; + + float transList[] = { -100, 0, 250, 500 }; + + for (int i = 0; i < columnCount * rowCount; i++) { + int x = (i % columnCount) * sizeX; + int y = (i / columnCount) * sizeY; + auto testNode = SetUpNodeBgImage("/data/local/tmp/geom_test.jpg", { x, y, sizeX - 10, sizeY - 10 }); + testNode->SetPivot(Vector2f(0, 0)); + testNode->SetPositionZ(transList[i / 2]); + bool flag = i % 2 == 0 ? true : false; + testNode->SetPositionZApplicableCamera3D(flag); + GetRootNode()->AddChild(testNode); + RegisterNode(testNode); + } +} + } // namespace OHOS::Rosen \ No newline at end of file diff --git a/graphic_test/graphic_test_framework/src/rs_graphic_test_img.cpp b/graphic_test/graphic_test_framework/src/rs_graphic_test_img.cpp index baead5f457..711e8bcbd7 100644 --- a/graphic_test/graphic_test_framework/src/rs_graphic_test_img.cpp +++ b/graphic_test/graphic_test_framework/src/rs_graphic_test_img.cpp @@ -55,8 +55,7 @@ std::shared_ptr SetUpNodeBgImage(const std::string& pathNam image->SetImageFit((int)ImageFit::FILL); auto node = Rosen::RSCanvasNode::Create(); node->SetBounds(bounds); - node->SetBgImageWidth(bounds[WIDTH_INDEX]); - node->SetBgImageHeight(bounds[HEIGHT_INDEX]); + node->SetBgImageSize(bounds[WIDTH_INDEX], bounds[HEIGHT_INDEX]); node->SetBgImage(image); return node; }