#define DALI_INTERNAL_OWNER_KEY_CONTAINER_H
/*
- * 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.
}
// Not copyable or movable
- OwnerKeyContainer(const OwnerKeyContainer&) = delete; ///< Deleted copy constructor
- OwnerKeyContainer(OwnerKeyContainer&&) = delete; ///< Deleted move constructor
+ OwnerKeyContainer(const OwnerKeyContainer&) = delete; ///< Deleted copy constructor
+ OwnerKeyContainer(OwnerKeyContainer&&) = delete; ///< Deleted move constructor
OwnerKeyContainer& operator=(const OwnerKeyContainer&) = delete; ///< Deleted copy assignment operator
- OwnerKeyContainer& operator=(OwnerKeyContainer&&) = delete; ///< Deleted move assignment operator
+ OwnerKeyContainer& operator=(OwnerKeyContainer&&) = delete; ///< Deleted move assignment operator
/**
* Test whether the container is empty.
auto begin = BaseType::Begin();
auto end = BaseType::End();
- auto function = [predicate](auto& key)
- {
+ auto function = [predicate](auto& key) {
if(predicate(key.Get()))
{
delete key.Get();
/*
- * 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.
mColor[mColorAttachmentCount] = texture;
++mColorAttachmentCount;
- AttachColorTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer);
+ AttachColorTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel, layer);
}
}
else
{
mDepth = texture;
- AttachDepthTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel);
+ AttachDepthTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel);
}
}
else
{
mStencil = texture;
- AttachDepthStencilTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel);
+ AttachDepthStencilTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderTextureKey().Get(), mipmapLevel);
}
}
/*
- * 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.
return texture;
}
-Render::Texture* Texture::GetRenderObject() const
+Render::TextureKey Texture::GetRenderTextureKey() const
{
- return mRenderObject;
+ return mTextureKey;
}
Texture::Texture(TextureType::Type type, Pixel::Format format, ImageDimensions size)
: mEventThreadServices(EventThreadServices::Get()),
- mRenderObject(nullptr),
+ mTextureKey{},
mNativeImage(),
mSize(size),
mType(type),
Texture::Texture(NativeImageInterfacePtr nativeImageInterface)
: mEventThreadServices(EventThreadServices::Get()),
- mRenderObject(nullptr),
+ mTextureKey{},
mNativeImage(nativeImageInterface),
mSize(nativeImageInterface->GetWidth(), nativeImageInterface->GetHeight()),
mType(TextureType::TEXTURE_2D),
{
if(mNativeImage)
{
- mRenderObject = new Render::Texture(mNativeImage);
+ mTextureKey = Render::Texture::NewKey(mNativeImage);
}
else
{
- mRenderObject = new Render::Texture(mType, mFormat, mSize);
+ mTextureKey = Render::Texture::NewKey(mType, mFormat, mSize);
}
- OwnerPointer<Render::Texture> transferOwnership(mRenderObject);
- AddTexture(mEventThreadServices.GetUpdateManager(), transferOwnership);
+ AddTextureMessage(mEventThreadServices.GetUpdateManager(), mTextureKey);
}
}
Texture::~Texture()
{
- if(EventThreadServices::IsCoreRunning() && mRenderObject)
+ if(EventThreadServices::IsCoreRunning() && mTextureKey)
{
- RemoveTexture(mEventThreadServices.GetUpdateManager(), *mRenderObject);
+ RemoveTextureMessage(mEventThreadServices.GetUpdateManager(), mTextureKey);
}
}
"Parameter value out of range");
bool result(false);
- if(EventThreadServices::IsCoreRunning() && mRenderObject)
+ if(EventThreadServices::IsCoreRunning() && mTextureKey)
{
if(mNativeImage)
{
static_cast<uint16_t>(yOffset),
static_cast<uint16_t>(width),
static_cast<uint16_t>(height)};
- UploadTextureMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, pixelData, params);
+ UploadTextureMessage(mEventThreadServices.GetUpdateManager(), mTextureKey, pixelData, params);
// Request event processing and update forcely
mEventThreadServices.GetRenderController().RequestProcessEventsOnIdle(true);
void Texture::GenerateMipmaps()
{
- if(EventThreadServices::IsCoreRunning() && mRenderObject)
+ if(EventThreadServices::IsCoreRunning() && mTextureKey)
{
- GenerateMipmapsMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject);
+ GenerateMipmapsMessage(mEventThreadServices.GetUpdateManager(), mTextureKey);
}
}
#define DALI_INTERNAL_NEW_TEXTURE_H
/*
- * 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.
// INTERNAL INCLUDES
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/images/pixel-data-impl.h>
+#include <dali/internal/render/renderers/render-texture-key.h>
#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
#include <dali/public-api/images/image-operations.h> // Dali::ImageDimensions
{
namespace Internal
{
-namespace Render
-{
-class Texture;
-}
-
class Texture;
using TexturePtr = IntrusivePtr<Texture>;
*
* @return the texture render object
*/
- Render::Texture* GetRenderObject() const;
+ Render::TextureKey GetRenderTextureKey() const;
/**
* @copydoc Dali::Texture::Upload()
private: // data
Internal::EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
- Internal::Render::Texture* mRenderObject; ///<The Render::Texture associated to this texture
+ Internal::Render::TextureKey mTextureKey; ///<The Render::Texture associated to this texture
NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
ImageDimensions mSize; ///< Size of the texture
/*
- * Copyright (c) 2021 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.
mTextures[index] = texture;
- Render::Texture* renderTexture(nullptr);
+ Render::TextureKey renderTexture{};
if(texture)
{
- renderTexture = texture->GetRenderObject();
+ renderTexture = texture->GetRenderTextureKey();
}
SceneGraph::SetTextureMessage(mEventThreadServices, *mSceneObject, index, renderTexture);
#include <dali/public-api/math/rect.h>
#include <dali/graphics-api/graphics-controller.h>
+#include <dali/internal/common/owner-key-container.h>
#include <dali/internal/render/common/render-item.h>
-#include <dali/internal/update/manager/owner-key-container.h>
namespace Dali
{
/*
- * 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.
#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/update/render-tasks/scene-graph-camera.h>
+#include <dali/internal/common/owner-key-container.h>
+
#include <dali/internal/render/common/render-algorithms.h>
#include <dali/internal/render/common/render-debug.h>
#include <dali/internal/render/common/render-instruction.h>
Integration::StencilBufferAvailable stencilBufferAvailableParam,
Integration::PartialUpdateAvailable partialUpdateAvailableParam)
: graphicsController(graphicsController),
- renderQueue(),
renderAlgorithms(graphicsController),
- frameCount(0u),
- renderBufferIndex(SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX),
- rendererContainer(),
- samplerContainer(),
- textureContainer(),
- frameBufferContainer(),
- lastFrameWasRendered(false),
programController(graphicsController),
shaderCache(graphicsController),
depthBufferAvailable(depthBufferAvailableParam),
}
// the order is important for destruction,
- Graphics::Controller& graphicsController;
- RenderQueue renderQueue; ///< A message queue for receiving messages from the update-thread.
-
- std::vector<SceneGraph::Scene*> sceneContainer; ///< List of pointers to the scene graph objects of the scenes
-
- Render::RenderAlgorithms renderAlgorithms; ///< The RenderAlgorithms object is used to action the renders required by a RenderInstruction
-
- uint32_t frameCount; ///< The current frame count
- BufferIndex renderBufferIndex; ///< The index of the buffer to read from; this is opposite of the "update" buffer
-
- OwnerContainer<Render::Renderer*> rendererContainer; ///< List of owned renderers
- OwnerContainer<Render::Sampler*> samplerContainer; ///< List of owned samplers
- OwnerContainer<Render::Texture*> textureContainer; ///< List of owned textures
- OwnerContainer<Render::FrameBuffer*> frameBufferContainer; ///< List of owned framebuffers
- OwnerContainer<Render::VertexBuffer*> vertexBufferContainer; ///< List of owned vertex buffers
- OwnerContainer<Render::Geometry*> geometryContainer; ///< List of owned Geometries
-
- bool lastFrameWasRendered; ///< Keeps track of the last frame being rendered due to having render instructions
-
- OwnerContainer<Render::RenderTracker*> mRenderTrackers; ///< List of render trackers
+ Graphics::Controller& graphicsController;
+ RenderQueue renderQueue; ///< A message queue for receiving messages from the update-thread.
+ std::vector<SceneGraph::Scene*> sceneContainer; ///< List of pointers to the scene graph objects of the scenes
+ Render::RenderAlgorithms renderAlgorithms; ///< The RenderAlgorithms object is used to action the renders required by a RenderInstruction
+
+ OwnerContainer<Render::Renderer*> rendererContainer; ///< List of owned renderers
+ OwnerContainer<Render::Sampler*> samplerContainer; ///< List of owned samplers
+ OwnerContainer<Render::FrameBuffer*> frameBufferContainer; ///< List of owned framebuffers
+ OwnerContainer<Render::VertexBuffer*> vertexBufferContainer; ///< List of owned vertex buffers
+ OwnerContainer<Render::Geometry*> geometryContainer; ///< List of owned Geometries
+ OwnerContainer<Render::RenderTracker*> mRenderTrackers; ///< List of render trackers
+ OwnerKeyContainer<Render::Texture> textureContainer; ///< List of owned textures
ProgramController programController; ///< Owner of the programs
Render::ShaderCache shaderCache; ///< The cache for the graphics shaders
Vector<Graphics::Texture*> boundTextures; ///< The textures bound for rendering
Vector<Graphics::Texture*> textureDependencyList; ///< The dependency list of bound textures
+ uint32_t frameCount{0u}; ///< The current frame count
+ BufferIndex renderBufferIndex{SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX}; ///< The index of the buffer to read from; this is opposite of the "update" buffer
+
+ bool lastFrameWasRendered{false}; ///< Keeps track of the last frame being rendered due to having render instructions
bool commandBufferSubmitted{false};
};
mImpl->samplerContainer.EraseObject(sampler);
}
-void RenderManager::AddTexture(OwnerPointer<Render::Texture>& texture)
+void RenderManager::AddTexture(const Render::TextureKey& textureKey)
{
- texture->Initialize(mImpl->graphicsController);
- mImpl->textureContainer.PushBack(texture.Release());
+ DALI_ASSERT_DEBUG(textureKey && "Trying to add empty texture key");
+
+ textureKey->Initialize(mImpl->graphicsController);
+ mImpl->textureContainer.PushBack(textureKey);
}
-void RenderManager::RemoveTexture(Render::Texture* texture)
+void RenderManager::RemoveTexture(const Render::TextureKey& textureKey)
{
- DALI_ASSERT_DEBUG(NULL != texture);
+ DALI_ASSERT_DEBUG(textureKey && "Trying to remove empty texture key");
// Find the texture, use std::find so we can do the erase safely
- auto iter = std::find(mImpl->textureContainer.begin(), mImpl->textureContainer.end(), texture);
+ auto iter = std::find(mImpl->textureContainer.begin(), mImpl->textureContainer.end(), textureKey);
if(iter != mImpl->textureContainer.end())
{
- texture->Destroy();
+ textureKey->Destroy();
mImpl->textureContainer.Erase(iter); // Texture found; now destroy it
}
}
-void RenderManager::UploadTexture(Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params)
+void RenderManager::UploadTexture(const Render::TextureKey& textureKey, PixelDataPtr pixelData, const Texture::UploadParams& params)
{
- texture->Upload(pixelData, params);
+ DALI_ASSERT_DEBUG(textureKey && "Trying to upload to empty texture key");
+ textureKey->Upload(pixelData, params);
}
-void RenderManager::GenerateMipmaps(Render::Texture* texture)
+void RenderManager::GenerateMipmaps(const Render::TextureKey& textureKey)
{
- texture->GenerateMipmaps();
+ DALI_ASSERT_DEBUG(textureKey && "Trying to generate mipmaps on empty texture key");
+ textureKey->GenerateMipmaps();
}
void RenderManager::SetFilterMode(Render::Sampler* sampler, uint32_t minFilterMode, uint32_t magFilterMode)
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H
/*
- * 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.
* Adds a texture to the render manager
* @param[in] texture The texture to add
*/
- void AddTexture(OwnerPointer<Render::Texture>& texture);
+ void AddTexture(const Render::TextureKey& texture);
/**
* Removes a texture from the render manager
* @param[in] texture The texture to remove
*/
- void RemoveTexture(Render::Texture* texture);
+ void RemoveTexture(const Render::TextureKey& texture);
/**
* Uploads data to an existing texture
* @param[in] pixelData The pixel data object
* @param[in] params The parameters for the upload
*/
- void UploadTexture(Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params);
+ void UploadTexture(const Render::TextureKey& texture, PixelDataPtr pixelData, const Texture::UploadParams& params);
/**
* Generates mipmaps for a given texture
* @param[in] texture The texture
*/
- void GenerateMipmaps(Render::Texture* texture);
+ void GenerateMipmaps(const Render::TextureKey& texture);
/**
* Adds a framebuffer to the render manager
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H
/*
- * 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.
*/
#include <dali/internal/render/data-providers/uniform-map-data-provider.h>
+#include <dali/internal/render/renderers/render-texture-key.h>
#include <dali/public-api/common/dali-vector.h>
namespace Dali
* Returns the list of Textures
* @return The list of Textures
*/
- virtual const Dali::Vector<Render::Texture*>* GetTextures() const = 0;
+ virtual const Dali::Vector<Render::TextureKey>* GetTextures() const = 0;
/**
* Get the opacity
/*
- * 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.
{
uint32_t textureUnit = 0;
- const Dali::Vector<Render::Texture*>* textures(mRenderDataProvider->GetTextures());
- const Dali::Vector<Render::Sampler*>* samplers(mRenderDataProvider->GetSamplers());
+ auto textures(mRenderDataProvider->GetTextures());
+ auto samplers(mRenderDataProvider->GetSamplers());
std::vector<Graphics::TextureBinding> textureBindings;
for(auto& texture : textureResources)
{
auto& textureImpl = GetImplementation(texture);
- auto graphicsTexture = textureImpl.GetRenderObject()->GetGraphicsObject();
+ auto graphicsTexture = textureImpl.GetRenderTextureKey()->GetGraphicsObject();
auto properties = mGraphicsController->GetTextureProperties(*graphicsTexture);
--- /dev/null
+#ifndef DALI_INTERNAL_RENDER_RENDER_TEXTURE_KEY_H
+#define DALI_INTERNAL_RENDER_RENDER_TEXTURE_KEY_H
+
+/*
+ * 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.
+ * 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 <dali/internal/common/memory-pool-key.h>
+
+namespace Dali
+{
+namespace Internal::Render
+{
+class Texture;
+using TextureKey = MemoryPoolKey<Texture>;
+} // namespace Internal::Render
+
+template<>
+struct TypeTraits<Internal::Render::TextureKey> : public BasicTypes<Internal::Render::TextureKey>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
+} // namespace Dali
+
+#endif //DALI_INTERNAL_RENDER_RENDER_TEXTURE_KEY_H
/*
- * 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.
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <dali/internal/common/memory-pool-object-allocator.h>
namespace Dali
{
Debug::Filter* gTextureFilter = Debug::Filter::New(Debug::Concise, false, "LOG_TEXTURE");
#endif
+// Memory pool used to allocate new textures. Memory used by this pool will be released when shutting down DALi
+MemoryPoolObjectAllocator<Texture> gTextureMemoryPool;
+
/**
* Converts DALi pixel format to Graphics::Format
* @param format
} //Unnamed namespace
+TextureKey Texture::NewKey(Type type, Pixel::Format format, ImageDimensions size)
+{
+ void* ptr = gTextureMemoryPool.AllocateRawThreadSafe();
+ auto key = gTextureMemoryPool.GetKeyFromPtr(static_cast<Texture*>(ptr));
+ new(ptr) Texture(type, format, size);
+
+ return TextureKey(key);
+}
+
+TextureKey Texture::NewKey(NativeImageInterfacePtr nativeImageInterface)
+{
+ void* ptr = gTextureMemoryPool.AllocateRawThreadSafe();
+ auto key = gTextureMemoryPool.GetKeyFromPtr(static_cast<Texture*>(ptr));
+ new(ptr) Texture(nativeImageInterface);
+
+ return TextureKey(key);
+}
+
Texture::Texture(Type type, Pixel::Format format, ImageDimensions size)
: mGraphicsController(nullptr),
mGraphicsTexture(nullptr),
Texture::~Texture() = default;
+void Texture::operator delete(void* ptr)
+{
+ gTextureMemoryPool.FreeThreadSafe(static_cast<Texture*>(ptr));
+}
+
+Render::Texture* Texture::Get(TextureKey::KeyType key)
+{
+ return gTextureMemoryPool.GetPtrFromKey(key);
+}
+
void Texture::Initialize(Graphics::Controller& graphicsController)
{
mGraphicsController = &graphicsController;
#define DALI_INTERNAL_RENDER_TEXTURE_H
/*
- * 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.
using Type = Dali::TextureType::Type;
/**
+ * Factory method to return a new texture accessed by key.
+ */
+ static TextureKey NewKey(Type type, Pixel::Format format, ImageDimensions size);
+
+ /**
+ * Factory method to return a new texture accessed by key.
+ */
+ static TextureKey NewKey(NativeImageInterfacePtr nativeImageInterface);
+
+ /**
* Constructor
* @param[in] type The type of the texture
* @param[in] format The format of the pixel data
~Texture();
/**
+ * Deletes the texture from it's global memory pool
+ */
+ void operator delete(void* ptr);
+
+ static Texture* Get(TextureKey::KeyType);
+
+ /**
+ * Get the key of the given renderer in the associated memory pool.
+ * @param[in] renderer the given renderer
+ * @return The key in the associated memory pool.
+ */
+ static TextureKey GetKey(const Render::Texture& renderer);
+
+ /**
+ * Get the key of the given renderer in the associated memory pool.
+ * @param[in] renderer the given renderer
+ * @return The key in the associated memory pool, or -1 if not
+ * found.
+ */
+ static TextureKey GetKey(Render::Texture* renderer);
+
+ /**
* Stores the graphics controller for use when required.
*
* @param[in] graphicsController The graphics controller to use
/*
- * 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.
// INTERNAL INCLUDES
#include <dali/integration-api/core.h>
+#include <dali/internal/common/owner-key-container.h>
+
#include <dali/internal/event/animation/animation-playlist.h>
#include <dali/internal/event/common/notification-manager.h>
#include <dali/internal/event/common/property-notifier.h>
#include <dali/internal/update/controllers/render-message-dispatcher.h>
#include <dali/internal/update/controllers/scene-controller-impl.h>
#include <dali/internal/update/manager/frame-callback-processor.h>
-#include <dali/internal/update/manager/owner-key-container.h>
#include <dali/internal/update/manager/render-task-processor.h>
#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/manager/update-algorithms.h>
void SortSiblingNodesRecursively(Node& node)
{
NodeContainer& container = node.GetChildren();
- std::sort(container.Begin(), container.End(), [](Node* a, Node* b)
- { return a->GetDepthIndex() < b->GetDepthIndex(); });
+ std::sort(container.Begin(), container.End(), [](Node* a, Node* b) { return a->GetDepthIndex() < b->GetDepthIndex(); });
// Descend tree and sort as well
for(auto&& iter : container)
{
}
- ~SceneInfo() = default; ///< Default non-virtual destructor
- SceneInfo(SceneInfo&& rhs) = default; ///< Move constructor
- SceneInfo& operator=(SceneInfo&& rhs) = default; ///< Move assignment operator
- SceneInfo& operator=(const SceneInfo& rhs) = delete; ///< Assignment operator
- SceneInfo(const SceneInfo& rhs) = delete; ///< Copy constructor
+ ~SceneInfo() = default; ///< Default non-virtual destructor
+ SceneInfo(SceneInfo&& rhs) = default; ///< Move constructor
+ SceneInfo& operator=(SceneInfo&& rhs) = default; ///< Move assignment operator
+ SceneInfo& operator=(const SceneInfo& rhs) = delete; ///< Assignment operator
+ SceneInfo(const SceneInfo& rhs) = delete; ///< Copy constructor
Layer* root{nullptr}; ///< Root node (root is a layer). The layer is not stored in the node memory pool.
OwnerPointer<RenderTaskList> taskList; ///< Scene graph render task list
Layer* rootLayer = layer.Release();
- DALI_ASSERT_DEBUG(std::find_if(mImpl->scenes.begin(), mImpl->scenes.end(), [rootLayer](Impl::SceneInfoPtr& scene)
- { return scene && scene->root == rootLayer; }) == mImpl->scenes.end() &&
+ DALI_ASSERT_DEBUG(std::find_if(mImpl->scenes.begin(), mImpl->scenes.end(), [rootLayer](Impl::SceneInfoPtr& scene) { return scene && scene->root == rootLayer; }) == mImpl->scenes.end() &&
"Root Node already installed");
rootLayer->CreateTransform(&mImpl->transformManager);
new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachVertexBuffer, geometry, vertexBuffer);
}
-void UpdateManager::AddTexture(OwnerPointer<Render::Texture>& texture)
+void UpdateManager::AddTexture(const Render::TextureKey& texture)
{
- // Message has ownership of Texture while in transit from update -> render
- using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Texture>>;
+ using DerivedType = MessageValue1<RenderManager, Render::TextureKey>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddTexture, texture);
}
-void UpdateManager::RemoveTexture(Render::Texture* texture)
+void UpdateManager::RemoveTexture(const Render::TextureKey& texture)
{
- using DerivedType = MessageValue1<RenderManager, Render::Texture*>;
+ using DerivedType = MessageValue1<RenderManager, Render::TextureKey>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveTexture, texture);
}
-void UpdateManager::UploadTexture(Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params)
+void UpdateManager::UploadTexture(const Render::TextureKey& texture, PixelDataPtr pixelData, const Texture::UploadParams& params)
{
- using DerivedType = MessageValue3<RenderManager, Render::Texture*, PixelDataPtr, Texture::UploadParams>;
+ using DerivedType = MessageValue3<RenderManager, Render::TextureKey, PixelDataPtr, Texture::UploadParams>;
// Reserve some memory inside the message queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
new(slot) DerivedType(&mImpl->renderManager, &RenderManager::UploadTexture, texture, pixelData, params);
}
-void UpdateManager::GenerateMipmaps(Render::Texture* texture)
+void UpdateManager::GenerateMipmaps(const Render::TextureKey& texture)
{
- using DerivedType = MessageValue1<RenderManager, Render::Texture*>;
+ using DerivedType = MessageValue1<RenderManager, Render::TextureKey>;
// Reserve some memory inside the render queue
uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
#define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
/*
- * 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.
#include <dali/internal/common/type-abstraction-enums.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/rendering/texture-impl.h>
-#include <dali/internal/render/renderers/render-texture.h> // For OwnerPointer<Render::Texture>
+#include <dali/internal/render/renderers/render-texture-key.h> // For RenderTextureKey
+#include <dali/internal/render/renderers/render-texture.h> // For OwnerPointer<Render::Texture>
#include <dali/internal/render/renderers/render-vertex-buffer.h>
#include <dali/internal/render/shaders/render-shader.h> // for OwnerPointer< Shader >
#include <dali/internal/update/animation/scene-graph-animation.h>
* @param[in] texture The texture to add
* The texture will be owned by RenderManager
*/
- void AddTexture(OwnerPointer<Render::Texture>& texture);
+ void AddTexture(const Render::TextureKey& texture);
/**
* Removes a texture from the render manager
* @param[in] texture The texture to remove
* @post The texture will be destroyed in the render thread
*/
- void RemoveTexture(Render::Texture* texture);
+ void RemoveTexture(const Render::TextureKey& texture);
/**
* Uploads data to a texture owned by the RenderManager
* @param[in] pixelData The pixel data object
* @param[in] params The parameters for the upload
*/
- void UploadTexture(Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params);
+ void UploadTexture(const Render::TextureKey& texture, PixelDataPtr pixelData, const Texture::UploadParams& params);
/**
* Generates mipmaps for a texture owned by the RenderManager
* @param[in] texture The texture
*/
- void GenerateMipmaps(Render::Texture* texture);
+ void GenerateMipmaps(const Render::TextureKey& texture);
/**
* Adds a framebuffer to the render manager
new(slot) LocalType(&manager, &UpdateManager::SetGeometryType, &geometry, geometryType);
}
-inline void AddTexture(UpdateManager& manager, OwnerPointer<Render::Texture>& texture)
+inline void AddTextureMessage(UpdateManager& manager, const Render::TextureKey& texture)
{
- // Message has ownership of Texture while in transit from event -> update
- using LocalType = MessageValue1<UpdateManager, OwnerPointer<Render::Texture>>;
+ using LocalType = MessageValue1<UpdateManager, Render::TextureKey>;
// Reserve some memory inside the message queue
uint32_t* slot = manager.ReserveMessageSlot(sizeof(LocalType));
new(slot) LocalType(&manager, &UpdateManager::AddTexture, texture);
}
-inline void RemoveTexture(UpdateManager& manager, Render::Texture& texture)
+inline void RemoveTextureMessage(UpdateManager& manager, const Render::TextureKey& texture)
{
- using LocalType = MessageValue1<UpdateManager, Render::Texture*>;
+ using LocalType = MessageValue1<UpdateManager, Render::TextureKey>;
// Reserve some memory inside the message queue
uint32_t* slot = manager.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new(slot) LocalType(&manager, &UpdateManager::RemoveTexture, &texture);
+ new(slot) LocalType(&manager, &UpdateManager::RemoveTexture, texture);
}
-inline void UploadTextureMessage(UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params)
+inline void UploadTextureMessage(UpdateManager& manager, Render::TextureKey texture, PixelDataPtr pixelData, const Texture::UploadParams& params)
{
- using LocalType = MessageValue3<UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams>;
+ using LocalType = MessageValue3<UpdateManager, Render::TextureKey, PixelDataPtr, Texture::UploadParams>;
// Reserve some memory inside the message queue
uint32_t* slot = manager.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new(slot) LocalType(&manager, &UpdateManager::UploadTexture, &texture, pixelData, params);
+ new(slot) LocalType(&manager, &UpdateManager::UploadTexture, texture, pixelData, params);
}
-inline void GenerateMipmapsMessage(UpdateManager& manager, Render::Texture& texture)
+inline void GenerateMipmapsMessage(UpdateManager& manager, Render::TextureKey texture)
{
- using LocalType = MessageValue1<UpdateManager, Render::Texture*>;
+ using LocalType = MessageValue1<UpdateManager, Render::TextureKey>;
// Reserve some memory inside the message queue
uint32_t* slot = manager.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new(slot) LocalType(&manager, &UpdateManager::GenerateMipmaps, &texture);
+ new(slot) LocalType(&manager, &UpdateManager::GenerateMipmaps, texture);
}
inline void AddFrameBuffer(UpdateManager& manager, OwnerPointer<Render::FrameBuffer>& frameBuffer)
SetUpdated(true);
}
-const Vector<Render::Texture*>* Renderer::GetTextures() const
+const Vector<Render::TextureKey>* Renderer::GetTextures() const
{
return mTextureSet ? &(mTextureSet->GetTextures()) : nullptr;
}
{
namespace SceneGraph
{
-
using RendererContainer = Dali::Vector<RendererKey>;
using RendererIter = RendererContainer::Iterator;
using RendererConstIter = RendererContainer::ConstIterator;
/**
* @copydoc RenderDataProvider::GetTextures()
*/
- const Vector<Render::Texture*>* GetTextures() const override;
+ const Vector<Render::TextureKey>* GetTextures() const override;
/**
* @copydoc RenderDataProvider::GetSamplers()
/*
- * 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.
}
}
-void TextureSet::SetTexture(uint32_t index, Render::Texture* texture)
+void TextureSet::SetTexture(uint32_t index, const Render::TextureKey& texture)
{
const uint32_t textureCount = static_cast<uint32_t>(mTextures.Size());
if(textureCount < index + 1)
for(uint32_t i(textureCount); i <= index; ++i)
{
- mTextures[i] = nullptr;
+ mTextures[i] = Render::TextureKey{};
if(!samplerExist)
{
#define DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H
/*
- * 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.
*/
// INTERNAL INCLUDES
+#include <dali/public-api/rendering/texture-set.h>
+
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/public-api/rendering/texture-set.h>
+#include <dali/internal/render/renderers/render-texture-key.h>
namespace Dali
{
* @param[in] index The index of the texture
* @param[in] texture The texture
*/
- void SetTexture(uint32_t index, Render::Texture* texture);
+ void SetTexture(uint32_t index, const Render::TextureKey& texture);
/**
* Return whether any texture in the texture set has an alpha channel
/**
* Accessor for textures (used by RenderDataProvider impl)
*/
- const Vector<Render::Texture*>& GetTextures()
+ const Vector<Render::TextureKey>& GetTextures()
{
return mTextures;
}
*/
TextureSet();
-private: // Data
- Vector<Render::Sampler*> mSamplers; ///< List of samplers used by each texture. Not owned
- Vector<Render::Texture*> mTextures; ///< List of Textures. Not owned
- bool mHasAlpha; ///< if any of the textures has an alpha channel
+private:
+ Vector<Render::Sampler*> mSamplers; ///< List of samplers used by each texture. Not owned
+ Vector<Render::TextureKey> mTextures; ///< List of Textures. Not owned
+ bool mHasAlpha; ///< if any of the textures has an alpha channel
};
-inline void SetTextureMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Texture* texture)
+inline void SetTextureMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, const Render::TextureKey& textureKey)
{
- using LocalType = MessageValue2<TextureSet, uint32_t, Render::Texture*>;
+ using LocalType = MessageValue2<TextureSet, uint32_t, Render::TextureKey>;
// 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(&textureSet, &TextureSet::SetTexture, index, texture);
+ new(slot) LocalType(&textureSet, &TextureSet::SetTexture, index, textureKey);
}
inline void SetSamplerMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Sampler* sampler)