/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
Scene::~Scene()
{
- if(EventThreadServices::IsCoreRunning() && mSceneObject)
- {
- ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- RemoveSceneMessage(tls->GetUpdateManager(), *mSceneObject);
- }
-
if(mDefaultCamera)
{
// its enough to release the handle so the object is released
}
}
+void Scene::RemoveSceneObject()
+{
+ if(EventThreadServices::IsCoreRunning() && mSceneObject)
+ {
+ ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
+ RemoveSceneMessage(tls->GetUpdateManager(), *mSceneObject);
+ mSceneObject = nullptr;
+ }
+}
+
void Scene::Discard()
{
- if(ThreadLocalStorage::Created())
+ if(EventThreadServices::IsCoreRunning())
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
tls->RemoveScene(this);
int32_t Scene::GetCurrentSurfaceOrientation() const
{
- return mSceneObject->GetSurfaceOrientation();
+ return mSceneObject ? mSceneObject->GetSurfaceOrientation() : 0;
}
int32_t Scene::GetCurrentScreenOrientation() const
{
- return mSceneObject->GetScreenOrientation();
+ return mSceneObject ? mSceneObject->GetScreenOrientation() : 0;
}
const Rect<int32_t>& Scene::GetCurrentSurfaceRect() const
{
- return mSceneObject->GetSurfaceRect();
+ static Rect<int32_t> emptyRect{};
+ return mSceneObject ? mSceneObject->GetSurfaceRect() : emptyRect;
}
void Scene::ChangedSurface(float width, float height, int32_t windowOrientation, int32_t screenOrientation)
{
- bool changedOrientation = false;
+ bool changedOrientation = false;
Rect<int32_t> newSize(0, 0, static_cast<int32_t>(width), static_cast<int32_t>(height)); // truncated
mSize.width = width;
mSize.height = height;
}
mSurfaceOrientation = windowOrientation;
- mScreenOrientation = screenOrientation;
+ mScreenOrientation = screenOrientation;
// Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
mDefaultCamera->SetPerspectiveProjection(mSize);
bool Scene::IsSurfaceRectChanged() const
{
- return mSceneObject->IsSurfaceRectChanged();
+ return mSceneObject ? mSceneObject->IsSurfaceRectChanged() : false;
}
bool Scene::IsRotationCompletedAcknowledgementSet() const
{
- return mSceneObject->IsRotationCompletedAcknowledgementSet();
+ return mSceneObject ? mSceneObject->IsRotationCompletedAcknowledgementSet() : false;
}
void Scene::SetRotationCompletedAcknowledgement()
void Scene::GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
{
- mSceneObject->GetFrameRenderedCallback(callbacks);
+ if(mSceneObject)
+ {
+ mSceneObject->GetFrameRenderedCallback(callbacks);
+ }
}
void Scene::GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
{
- mSceneObject->GetFramePresentedCallback(callbacks);
+ if(mSceneObject)
+ {
+ mSceneObject->GetFramePresentedCallback(callbacks);
+ }
}
Integration::Scene::KeyEventSignalType& Scene::KeyEventSignal()
Internal::Scene& sceneInternal = GetImplementation(scene);
SceneGraph::Scene* sceneObject = sceneInternal.GetSceneObject();
- if(sceneObject->IsRenderingSkipped())
+ if(!sceneObject || sceneObject->IsRenderingSkipped())
{
// We don't need to calculate dirty rects
return;
void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo)
{
- SceneGraph::Scene* sceneObject = GetImplementation(scene).GetSceneObject();
- Rect<int> clippingRect = sceneObject->GetSurfaceRect();
+ SceneGraph::Scene* sceneObject = GetImplementation(scene).GetSceneObject();
+ if(!sceneObject)
+ {
+ return;
+ }
+ Rect<int> clippingRect = sceneObject->GetSurfaceRect();
RenderScene(status, scene, renderToFbo, clippingRect);
}
Internal::Scene& sceneInternal = GetImplementation(scene);
SceneGraph::Scene* sceneObject = sceneInternal.GetSceneObject();
+ if(!sceneObject)
+ {
+ return;
+ }
uint32_t count = sceneObject->GetRenderInstructions().Count(mImpl->renderBufferIndex);
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
// Construct message in the render queue memory; note that delete should not be called on the return value
new(slot) DerivedType(&mImpl->renderManager, &RenderManager::UninitializeScene, scene);
+ scene->RemoveSurfaceRenderTarget();
+
for(auto&& sceneInfo : mImpl->scenes)
{
if(sceneInfo && sceneInfo->scene && sceneInfo->scene.Get() == scene)