X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-GlViewDirectRendering.cpp;h=85f17461d7271b3e573bb8ebe4ea9e7bbb0c2967;hb=e0021cf09240ce2f6c6f5257f249cf5f8aec6939;hp=82e3be942e08ed25fe8e28078040a0fce110cc36;hpb=191971e925a183b648ca1a4123405ae1cf631d0d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-GlViewDirectRendering.cpp b/automated-tests/src/dali-toolkit/utc-Dali-GlViewDirectRendering.cpp index 82e3be9..85f1746 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-GlViewDirectRendering.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-GlViewDirectRendering.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ #include #include #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -186,28 +187,52 @@ int UtcDaliGlViewDirectRenderingOnSizeSet(void) namespace DirectRenderingCode { - // Internal callback function -void glInit(void) +void glInit(Dali::RenderCallbackInput& input) { } -int glRenderFrame(void) +int glRenderFrame(Dali::RenderCallbackInput& input) { static unsigned int retFlag = 0; return retFlag++; } -void glTerminate(void) +int gBoundTextureCount = 0; + +int glRenderFrameWithTextures(Dali::RenderCallbackInput& input) { + gBoundTextureCount = input.textureBindings.size(); + return 1; } -void resizeCB(Vector2 size) +void glTerminate(Dali::RenderCallbackInput& input) { } +// Internal callback function +void glInitMT(Dali::RenderCallbackInput& input) +{ +} + +int gDRFramesRendered = 0; + +int glRenderFrameMT(Dali::RenderCallbackInput& input) +{ + gDRFramesRendered++; + return 1; } +void glTerminateMT(Dali::RenderCallbackInput& input) +{ +} + +void resizeCB(Vector2 size) +{ +} + +} // namespace DirectRenderingCode + int UtcDaliGlViewDirectRenderingRegisterGlCallbacksN(void) { ToolkitTestApplication application; @@ -359,6 +384,32 @@ int UtcDaliGlViewDirectRenderingResize(void) END_TEST; } +int UtcDaliGlViewDirectRenderingDirectResize(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliGlViewDirectRenderingResize"); + GlView view = Toolkit::GlView::New(GlView::BackendMode::UNSAFE_DIRECT_RENDERING, GlView::ColorFormat::RGB888); + + application.GetScene().Add(view); + view.SetGraphicsConfig(true, true, 0, GlView::GraphicsApiVersion::GLES_VERSION_2_0); + view.RegisterGlCallbacks(Dali::MakeCallback(DirectRenderingCode::glInit), Dali::MakeCallback(DirectRenderingCode::glRenderFrame), Dali::MakeCallback(DirectRenderingCode::glTerminate)); + view.SetResizeCallback(Dali::MakeCallback(DirectRenderingCode::resizeCB)); + view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + view.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 360.0f)); + + application.SendNotification(); + application.Render(); + + //To GlViewRenderThread can recognize Resize signal the main thread have to sleep. + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(true); + END_TEST; +} + int UtcDaliGlViewDirectRenderingTerminateCallback(void) { ToolkitTestApplication application; @@ -375,8 +426,6 @@ int UtcDaliGlViewDirectRenderingTerminateCallback(void) application.SendNotification(); application.Render(); - - //To GlViewRenderThread can recognize Resize signal the main thread have to sleep. std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -385,4 +434,155 @@ int UtcDaliGlViewDirectRenderingTerminateCallback(void) DALI_TEST_CHECK(true); END_TEST; -} \ No newline at end of file +} + +int UtcDaliGlViewDirectRenderingTextureBinding(void) +{ + ToolkitTestApplication application; + + GlView view = Toolkit::GlView::New(GlView::BackendMode::DIRECT_RENDERING, GlView::ColorFormat::RGB888); + + view.SetRenderingMode(GlView::RenderingMode::CONTINUOUS); + view.SetGraphicsConfig(true, true, 0, GlView::GraphicsApiVersion::GLES_VERSION_2_0); + view.RegisterGlCallbacks(Dali::MakeCallback(DirectRenderingCode::glInit), Dali::MakeCallback(DirectRenderingCode::glRenderFrameWithTextures), Dali::MakeCallback(DirectRenderingCode::glTerminate)); + view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + view.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 360.0f)); + + // Set size on the actor (half the window size to show that glClear() and scissor test work together) + view.SetProperty(Actor::Property::SIZE, Size(100, 100)); + view.SetProperty(Actor::Property::POSITION, Vector2(0, 0)); + + application.GetScene().Add(view); + + // Prepare texture 1 + Texture texture1 = Texture::New(Dali::TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 512, 512); + auto* data1 = reinterpret_cast(malloc(512 * 512 * 4)); + PixelData pixelData1 = PixelData::New(data1, 512 * 512 * 4, 512, 512, Pixel::Format::RGBA8888, PixelData::ReleaseFunction::FREE); + texture1.Upload(pixelData1); + + // Prepare texture 2 + Texture texture2 = Texture::New(Dali::TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 512, 512); + auto* data2 = reinterpret_cast(malloc(512 * 512 * 4)); + PixelData pixelData2 = PixelData::New(data2, 512 * 512 * 4, 512, 512, Pixel::Format::RGBA8888, PixelData::ReleaseFunction::FREE); + texture2.Upload(pixelData2); + + std::vector texturesToBind; + texturesToBind.push_back(texture1); + texturesToBind.push_back(texture2); + + view.BindTextureResources(texturesToBind); + + DirectRenderingCode::gBoundTextureCount = 0; + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(DirectRenderingCode::gBoundTextureCount, texturesToBind.size(), TEST_LOCATION); + + END_TEST; +} + +// Positive test case for a method +int UtcDaliGlViewDirectRenderingThreadedNew(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliGlViewDirectRenderingThreadedNew"); + GlView view = GlView::New(GlView::BackendMode::DIRECT_RENDERING_THREADED, GlView::ColorFormat::RGBA8888); + DALI_TEST_CHECK(view); + + auto mode1 = view.GetBackendMode(); + + DALI_TEST_EQUALS(mode1, GlView::BackendMode::DIRECT_RENDERING_THREADED, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliGlViewDirectRenderingThreadedOnScene(void) +{ + ToolkitTestApplication application; + + GlView view = Toolkit::GlView::New(GlView::BackendMode::DIRECT_RENDERING_THREADED, GlView::ColorFormat::RGB888); + + //Onscene + application.GetScene().Add(view); + view.SetRenderingMode(GlView::RenderingMode::CONTINUOUS); + view.SetGraphicsConfig(true, true, 0, GlView::GraphicsApiVersion::GLES_VERSION_3_0); + view.RegisterGlCallbacks(Dali::MakeCallback(DirectRenderingCode::glInitMT), Dali::MakeCallback(DirectRenderingCode::glRenderFrameMT), Dali::MakeCallback(DirectRenderingCode::glTerminateMT)); + view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + + // Set size on the actor (half the window size to show that glClear() and scissor test work together) + view.SetProperty(Actor::Property::SIZE, Size(100, 100)); + view.SetProperty(Actor::Property::POSITION, Vector2(0, 0)); + + while(DirectRenderingCode::gDRFramesRendered < 1) + { + application.SendNotification(); + application.Render(); + } + DALI_TEST_CHECK(true); + END_TEST; +} + +extern "C" bool gDirectRenderingFailCreateShader; +extern "C" bool gDirectRenderingFailCreateProgram; + +int UtcDaliGlViewDirectRenderingThreadedOnScene1(void) +{ + ToolkitTestApplication application; + + GlView view = Toolkit::GlView::New(GlView::BackendMode::DIRECT_RENDERING_THREADED, GlView::ColorFormat::RGB888); + + // This test will fail instantiating shaders + gDirectRenderingFailCreateShader = true; + + //Onscene + application.GetScene().Add(view); + view.SetRenderingMode(GlView::RenderingMode::CONTINUOUS); + view.SetGraphicsConfig(true, true, 0, GlView::GraphicsApiVersion::GLES_VERSION_3_0); + view.RegisterGlCallbacks(Dali::MakeCallback(DirectRenderingCode::glInitMT), Dali::MakeCallback(DirectRenderingCode::glRenderFrameMT), Dali::MakeCallback(DirectRenderingCode::glTerminateMT)); + view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + + // Set size on the actor (half the window size to show that glClear() and scissor test work together) + view.SetProperty(Actor::Property::SIZE, Size(100, 100)); + view.SetProperty(Actor::Property::POSITION, Vector2(0, 0)); + + while(DirectRenderingCode::gDRFramesRendered < 1) + { + application.SendNotification(); + application.Render(); + } + DALI_TEST_CHECK(true); + END_TEST; +} + +int UtcDaliGlViewDirectRenderingThreadedOnScene2(void) +{ + ToolkitTestApplication application; + + GlView view = Toolkit::GlView::New(GlView::BackendMode::DIRECT_RENDERING_THREADED, GlView::ColorFormat::RGB888); + + // This test will fail instantiating shaders + gDirectRenderingFailCreateProgram = true; + + //Onscene + application.GetScene().Add(view); + view.SetRenderingMode(GlView::RenderingMode::CONTINUOUS); + view.SetGraphicsConfig(true, true, 0, GlView::GraphicsApiVersion::GLES_VERSION_3_0); + view.RegisterGlCallbacks(Dali::MakeCallback(DirectRenderingCode::glInitMT), Dali::MakeCallback(DirectRenderingCode::glRenderFrameMT), Dali::MakeCallback(DirectRenderingCode::glTerminateMT)); + view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + + // Set size on the actor (half the window size to show that glClear() and scissor test work together) + view.SetProperty(Actor::Property::SIZE, Size(100, 100)); + view.SetProperty(Actor::Property::POSITION, Vector2(0, 0)); + + while(DirectRenderingCode::gDRFramesRendered < 1) + { + application.SendNotification(); + application.Render(); + } + DALI_TEST_CHECK(true); + END_TEST; +}