{
const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform mediump mat4 uModelView;\n
- uniform mediump mat4 uProjection;\n
- uniform mediump vec3 uSize;\n void main()\n {
- \n
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
- \n
- vertexPosition.xyz *= uSize;
- \n
- gl_Position = uProjection * uModelView * vertexPosition;
- \n
- }\n);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- uniform lowp vec4 uColor;\n void main()\n {
- \n
- gl_FragColor = uColor;
- \n
- }\n);
-
// Functor for EventProcessingFinished signal
struct EventProcessingFinishedFunctor
{
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
- Actor actor = CreateRenderableActor(image, VERTEX_SHADER, FRAGMENT_SHADER);
+ Actor actor = CreateRenderableActor();
actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
application.GetScene().Add(actor);
application.SendNotification();
- application.Render(0);
-
- Matrix projection;
- CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
- camera.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(projection);
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
// It should be changed.
DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
- // Check uniform
- Quaternion rotationAngle(Dali::ANGLE_0, Vector3::ZAXIS);
- Matrix rotation, newProjection;
- rotation.SetIdentity();
- rotation.SetTransformComponents(Vector3(1.0f, 1.0f, 1.0f), rotationAngle, Vector3(0.0f, 0.0f, 0.0f));
- Matrix::Multiply(newProjection, projection, rotation);
-
- DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uProjection", newProjection));
-
- // Change actor size to trigger rendering
- actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
-
- // Render again
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uProjection", newProjection));
-
END_TEST;
}
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
- Actor actor = CreateRenderableActor(image, VERTEX_SHADER, FRAGMENT_SHADER);
+ Actor actor = CreateRenderableActor();
actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
application.GetScene().Add(actor);
application.SendNotification();
- application.Render(0);
-
- Matrix projection;
- CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
- camera.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(projection);
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
// It should be changed.
DALI_TEST_EQUALS(orientation, 90, TEST_LOCATION);
- // Check uniform
- Quaternion rotationAngle(Dali::ANGLE_90, Vector3::ZAXIS);
- Matrix rotation, newProjection;
- rotation.SetIdentity();
- rotation.SetTransformComponents(Vector3(1.0f, 1.0f, 1.0f), rotationAngle, Vector3(0.0f, 0.0f, 0.0f));
- Matrix::Multiply(newProjection, projection, rotation);
-
- DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uProjection", newProjection));
-
- // Change actor size to trigger rendering
- actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
-
- // Render again
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uProjection", newProjection));
-
END_TEST;
}
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
- Actor actor = CreateRenderableActor(image, VERTEX_SHADER, FRAGMENT_SHADER);
+ Actor actor = CreateRenderableActor();
actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
application.GetScene().Add(actor);
application.SendNotification();
- application.Render(0);
-
- Matrix projection;
- CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
- camera.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(projection);
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
// It should be changed.
DALI_TEST_EQUALS(orientation, 180, TEST_LOCATION);
- // Check uniform
- Quaternion rotationAngle(Dali::ANGLE_180, Vector3::ZAXIS);
- Matrix rotation, newProjection;
- rotation.SetIdentity();
- rotation.SetTransformComponents(Vector3(1.0f, 1.0f, 1.0f), rotationAngle, Vector3(0.0f, 0.0f, 0.0f));
- Matrix::Multiply(newProjection, projection, rotation);
-
- DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uProjection", newProjection));
-
- // Change actor size to trigger rendering
- actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
-
- // Render again
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uProjection", newProjection));
-
END_TEST;
}
clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
application.RenderWithPartialUpdate(damagedRects, clippingRect);
- Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
- Actor actor = CreateRenderableActor(image, VERTEX_SHADER, FRAGMENT_SHADER);
+ Actor actor = CreateRenderableActor();
actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
application.GetScene().Add(actor);
application.SendNotification();
- application.Render(0);
-
- Matrix projection;
- CameraActor camera = application.GetScene().GetRenderTaskList().GetTask(0u).GetCameraActor();
- camera.GetProperty(CameraActor::CameraActor::Property::PROJECTION_MATRIX).Get(projection);
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
// It should be changed.
DALI_TEST_EQUALS(orientation, 270, TEST_LOCATION);
- // Check uniform
- Quaternion rotationAngle(Dali::ANGLE_270, Vector3::ZAXIS);
- Matrix rotation, newProjection;
- rotation.SetIdentity();
- rotation.SetTransformComponents(Vector3(1.0f, 1.0f, 1.0f), rotationAngle, Vector3(0.0f, 0.0f, 0.0f));
- Matrix::Multiply(newProjection, projection, rotation);
-
- DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uProjection", newProjection));
-
- // Change actor size to trigger rendering
- actor.SetProperty(Actor::Property::SIZE, Vector3(32.0f, 32.0f, 0.0f));
-
- // Render again
- application.SendNotification();
- application.Render(0);
-
- DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uProjection", newProjection));
-
END_TEST;
}
END_TEST;
}
+int UtcDaliSceneEnsureRenderTargetRecreated(void)
+{
+ tet_infoline("Ensure render target is re-created when surface replaced ");
+
+ TestApplication application;
+
+ // Create a new scene and set the background color of the main scene
+ auto defaultScene = application.GetScene();
+ defaultScene.SetBackgroundColor(Color::BLUE);
+
+ auto actor = CreateRenderableActor();
+ defaultScene.Add(actor);
+
+ auto& graphicsController = application.GetGraphicsController();
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& graphicsCallStack = graphicsController.mCallStack;
+ TraceCallStack::NamedParams empty{};
+ const TraceCallStack::NamedParams* matching = graphicsCallStack.FindLastMatch("PresentRenderTarget", empty);
+ DALI_TEST_CHECK(matching != nullptr);
+
+ graphicsCallStack.Reset();
+
+ int fakeSurface1;
+ Graphics::RenderTargetCreateInfo createInfo{};
+ createInfo.SetSurface(&fakeSurface1).SetExtent(Graphics::Extent2D{480u, 800u});
+ defaultScene.SetSurfaceRenderTarget(createInfo);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack::NamedParams query1;
+ query1["surface"] << std::hex << &fakeSurface1;
+ const TraceCallStack::NamedParams* matching2 = graphicsCallStack.FindLastMatch("CreateRenderTarget", query1);
+ DALI_TEST_CHECK(matching2 != nullptr);
+
+ const TraceCallStack::NamedParams* matching3 = graphicsCallStack.FindLastMatch("PresentRenderTarget", empty);
+ DALI_TEST_CHECK(matching3 != nullptr);
+ DALI_TEST_EQUALS((*matching3)["surface"].str(), query1["surface"].str(), TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliSceneEmptySceneRendering(void)
{
tet_infoline("Ensure not rendering before a Renderer is added");
*
* @param[in] renderTarget The render target.
*/
- void SetSurfaceRenderTarget(Graphics::RenderTarget* renderTarget)
- {
- mRenderTarget = renderTarget;
- }
+ void SetSurfaceRenderTargetCreateInfo(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo);
/**
* Get the render target created for the scene
*/
[[nodiscard]] Graphics::RenderTarget* GetSurfaceRenderTarget() const
{
- return mRenderTarget;
+ return mRenderTarget.get();
}
/**
RenderInstructionContainer mInstructions; ///< Render instructions for the scene
+ Graphics::Controller* mGraphicsController; ///< Graphics controller
+
Dali::Integration::Scene::FrameCallbackContainer mFrameRenderedCallbacks; ///< Frame rendered callbacks
Dali::Integration::Scene::FrameCallbackContainer mFramePresentedCallbacks; ///< Frame presented callbacks
// Render pass and render target
+ Graphics::RenderTargetCreateInfo mRenderTargetCreateInfo; // Passed in by message before 2nd stage Initialization happens.
+
/**
* Render pass is created on fly depending on Load and Store operations
* The default render pass (most likely to be used) is the load = CLEAR
* and store = STORE for color attachment.
*/
- Graphics::UniquePtr<Graphics::RenderPass> mRenderPass{nullptr}; ///< The render pass created to render the surface
- Graphics::UniquePtr<Graphics::RenderPass> mRenderPassNoClear{nullptr}; ///< The render pass created to render the surface without clearing color
- Graphics::RenderTarget* mRenderTarget{nullptr}; ///< This is created in the event thread when surface is created/resized/replaced
+ Graphics::UniquePtr<Graphics::RenderPass> mRenderPass{nullptr}; ///< The render pass created to render the surface
+ Graphics::UniquePtr<Graphics::RenderPass> mRenderPassNoClear{nullptr}; ///< The render pass created to render the surface without clearing color
+ Graphics::UniquePtr<Graphics::RenderTarget> mRenderTarget{nullptr}; ///< This is created in Update/Render thread when surface is created/resized/replaced
std::vector<Graphics::ClearValue> mClearValues{}; ///< Clear colors
std::vector<Dali::Internal::SceneGraph::DirtyRect> mItemsDirtyRects{}; ///< Dirty rect list
new(slot) LocalType(&scene, &Scene::SetRotationCompletedAcknowledgement);
}
-inline void SetSurfaceRenderTargetMessage(EventThreadServices& eventThreadServices, const Scene& scene, Graphics::RenderTarget* renderTarget)
+inline void SetSurfaceRenderTargetCreateInfoMessage(EventThreadServices& eventThreadServices, const Scene& scene, const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo)
{
- using LocalType = MessageValue1<Scene, Graphics::RenderTarget*>;
+ using LocalType = MessageValue1<Scene, Graphics::RenderTargetCreateInfo>;
// Reserve some memory inside the message queue
uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new(slot) LocalType(&scene, &Scene::SetSurfaceRenderTarget, renderTarget);
+ new(slot) LocalType(&scene, &Scene::SetSurfaceRenderTargetCreateInfo, renderTargetCreateInfo);
}
} // namespace SceneGraph