${internal_src_dir}/render/common/render-item.cpp
${internal_src_dir}/render/common/render-tracker.cpp
${internal_src_dir}/render/common/render-manager.cpp
- ${internal_src_dir}/render/data-providers/render-data-provider.cpp
${internal_src_dir}/render/queue/render-queue.cpp
${internal_src_dir}/render/renderers/gpu-buffer.cpp
${internal_src_dir}/render/renderers/pipeline-cache.cpp
+++ /dev/null
-/*
- * Copyright (c) 2021 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 "render-data-provider.h"
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-RenderDataProvider::RenderDataProvider(AnimatableProperty<float>& opacity)
-: mUniformMapDataProvider(nullptr),
- mShader(nullptr),
- mOpacity(opacity)
-{
-}
-
-RenderDataProvider::~RenderDataProvider() = default;
-
-void RenderDataProvider::SetUniformMap(const UniformMapDataProvider& uniformMapDataProvider)
-{
- mUniformMapDataProvider = &uniformMapDataProvider;
-}
-
-const UniformMapDataProvider& RenderDataProvider::GetUniformMap() const
-{
- return *mUniformMapDataProvider;
-}
-
-void RenderDataProvider::SetShader(Shader& shader)
-{
- mShader = &shader;
-}
-
-Shader& RenderDataProvider::GetShader() const
-{
- return *mShader;
-}
-
-RenderDataProvider::Samplers& RenderDataProvider::GetSamplers()
-{
- return mSamplers;
-}
-
-std::vector<Render::Texture*>& RenderDataProvider::GetTextures()
-{
- return mTextures;
-}
-
-float RenderDataProvider::GetOpacity(BufferIndex bufferIndex)
-{
- return mOpacity[bufferIndex];
-}
-
-} // namespace SceneGraph
-} // namespace Internal
-} // namespace Dali
*/
class RenderDataProvider
{
-public:
- using Samplers = std::vector<Render::Sampler*>;
-
- /**
- * Constructor.
- * The RendererAttachment that creates this object will initialize the members
- * directly.
- */
- explicit RenderDataProvider(AnimatableProperty<float>& opacity);
-
+protected:
/**
* Destructor
*/
- ~RenderDataProvider();
+ virtual ~RenderDataProvider() = default;
public:
/**
- * Set the uniform map data provider
- * @param[in] uniformMapDataProvider The uniform map data provider
- */
- void SetUniformMap(const UniformMapDataProvider& uniformMapDataProvider);
-
- /**
* Get the uniform map data provider
*/
- [[nodiscard]] const UniformMapDataProvider& GetUniformMap() const;
-
- /**
- * Set the shader data provider
- * @param[in] shader The shader data provider
- */
- void SetShader(Shader& shader);
+ virtual const UniformMapDataProvider& GetUniformMapDataProvider() const = 0;
/**
* Returns the shader
* @return The shader
*/
- [[nodiscard]] Shader& GetShader() const;
+ virtual const Shader& GetShader() const = 0;
/**
* Returns the list of samplers
* @return The list of samplers
*/
- Samplers& GetSamplers();
+ virtual const Dali::Vector<Render::Sampler*>* GetSamplers() const = 0;
/**
* Returns the list of Textures
* @return The list of Textures
*/
- std::vector<Render::Texture*>& GetTextures();
+ virtual const Dali::Vector<Render::Texture*>* GetTextures() const = 0;
/**
* Get the opacity
* @return The opacity
*/
- float GetOpacity(BufferIndex bufferIndex);
-
-private:
- const UniformMapDataProvider* mUniformMapDataProvider;
- Shader* mShader;
- std::vector<Render::Texture*> mTextures;
- Samplers mSamplers;
- AnimatableProperty<float>& mOpacity;
-
- // Give Renderer access to our private data to reduce copying vectors on construction.
- friend class Renderer;
+ virtual float GetOpacity(BufferIndex bufferIndex) const = 0;
};
} // namespace SceneGraph
#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/data-providers/node-data-provider.h>
#include <dali/internal/render/data-providers/uniform-map-data-provider.h>
+#include <dali/internal/render/renderers/pipeline-cache.h>
#include <dali/internal/render/renderers/render-sampler.h>
#include <dali/internal/render/renderers/render-texture.h>
#include <dali/internal/render/renderers/render-vertex-buffer.h>
#include <dali/internal/render/shaders/program.h>
#include <dali/internal/render/shaders/render-shader.h>
#include <dali/internal/update/common/uniform-map.h>
-#include <dali/internal/render/renderers/pipeline-cache.h>
namespace Dali::Internal
{
namespace
{
// Helper to get the property value getter by type
-typedef const float&(PropertyInputImpl::*FuncGetter )(BufferIndex) const;
+typedef const float& (PropertyInputImpl::*FuncGetter)(BufferIndex) const;
constexpr FuncGetter GetPropertyValueGetter(Property::Type type)
{
switch(type)
* Helper function that returns size of uniform datatypes based
* on property type.
*/
-constexpr int GetPropertyValueSizeForUniform( Property::Type type )
+constexpr int GetPropertyValueSizeForUniform(Property::Type type)
{
switch(type)
{
- case Property::Type::BOOLEAN:{ return sizeof(bool);}
- case Property::Type::FLOAT:{ return sizeof(float);}
- case Property::Type::INTEGER:{ return sizeof(int);}
- case Property::Type::VECTOR2:{ return sizeof(Vector2);}
- case Property::Type::VECTOR3:{ return sizeof(Vector3);}
- case Property::Type::VECTOR4:{ return sizeof(Vector4);}
- case Property::Type::MATRIX3:{ return sizeof(Matrix3);}
- case Property::Type::MATRIX:{ return sizeof(Matrix);}
+ case Property::Type::BOOLEAN:
+ {
+ return sizeof(bool);
+ }
+ case Property::Type::FLOAT:
+ {
+ return sizeof(float);
+ }
+ case Property::Type::INTEGER:
+ {
+ return sizeof(int);
+ }
+ case Property::Type::VECTOR2:
+ {
+ return sizeof(Vector2);
+ }
+ case Property::Type::VECTOR3:
+ {
+ return sizeof(Vector3);
+ }
+ case Property::Type::VECTOR4:
+ {
+ return sizeof(Vector4);
+ }
+ case Property::Type::MATRIX3:
+ {
+ return sizeof(Matrix3);
+ }
+ case Property::Type::MATRIX:
+ {
+ return sizeof(Matrix);
+ }
default:
{
return 0;
void Renderer::SetGeometry(Render::Geometry* geometry)
{
- mGeometry = geometry;
- mUpdated = true;
+ mGeometry = geometry;
+ mUpdated = true;
}
void Renderer::SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size)
{
{
uint32_t textureUnit = 0;
- std::vector<Render::Sampler*>& samplers(mRenderDataProvider->GetSamplers());
- std::vector<Render::Texture*>& textures(mRenderDataProvider->GetTextures());
+ const Dali::Vector<Render::Texture*>* textures(mRenderDataProvider->GetTextures());
+ const Dali::Vector<Render::Sampler*>* samplers(mRenderDataProvider->GetSamplers());
std::vector<Graphics::TextureBinding> textureBindings;
- for(uint32_t i = 0; i < static_cast<uint32_t>(textures.size()); ++i) // not expecting more than uint32_t of textures
+
+ if(textures != nullptr)
{
- if(textures[i] && textures[i]->GetGraphicsObject())
+ for(uint32_t i = 0; i < static_cast<uint32_t>(textures->Count()); ++i) // not expecting more than uint32_t of textures
{
- // if the sampler exists,
- // if it's default, delete the graphics object
- // otherwise re-initialize it if dirty
+ if((*textures)[i] && (*textures)[i]->GetGraphicsObject())
+ {
+ // if the sampler exists,
+ // if it's default, delete the graphics object
+ // otherwise re-initialize it if dirty
- const Graphics::Sampler* graphicsSampler = (samplers[i] ? samplers[i]->GetGraphicsObject()
- : nullptr);
+ const Graphics::Sampler* graphicsSampler = samplers ? ((*samplers)[i] ? (*samplers)[i]->GetGraphicsObject()
+ : nullptr)
+ : nullptr;
- boundTextures.PushBack(textures[i]->GetGraphicsObject());
- const Graphics::TextureBinding textureBinding{textures[i]->GetGraphicsObject(), graphicsSampler, textureUnit};
- textureBindings.push_back(textureBinding);
+ boundTextures.PushBack((*textures)[i]->GetGraphicsObject());
+ const Graphics::TextureBinding textureBinding{(*textures)[i]->GetGraphicsObject(), graphicsSampler, textureUnit};
+ textureBindings.push_back(textureBinding);
- ++textureUnit;
+ ++textureUnit;
+ }
}
}
}
// Create Program
- ShaderDataPtr shaderData = mRenderDataProvider->GetShader().GetShaderData();
+ ShaderDataPtr shaderData = mRenderDataProvider->GetShader().GetShaderData();
- Program* program = Program::New(*mProgramCache,
+ Program* program = Program::New(*mProgramCache,
shaderData,
*mGraphicsController);
if(!program)
{
- DALI_LOG_ERROR("Failed to get program for shader at address %p.\n", reinterpret_cast<void*>(&mRenderDataProvider->GetShader()));
+ DALI_LOG_ERROR("Failed to get program for shader at address %p.\n", reinterpret_cast<const void*>(&mRenderDataProvider->GetShader()));
return false;
}
// If program doesn't have Gfx program object assigned yet, prepare it.
if(!program->GetGraphicsProgramPtr())
{
- const std::vector<char> &vertShader = shaderData->GetShaderForPipelineStage(Graphics::PipelineStage::VERTEX_SHADER);
- const std::vector<char> &fragShader = shaderData->GetShaderForPipelineStage(Graphics::PipelineStage::FRAGMENT_SHADER);
- Dali::Graphics::Shader &vertexShader = mShaderCache->GetShader(
+ const std::vector<char>& vertShader = shaderData->GetShaderForPipelineStage(Graphics::PipelineStage::VERTEX_SHADER);
+ const std::vector<char>& fragShader = shaderData->GetShaderForPipelineStage(Graphics::PipelineStage::FRAGMENT_SHADER);
+ Dali::Graphics::Shader& vertexShader = mShaderCache->GetShader(
vertShader,
Graphics::PipelineStage::VERTEX_SHADER,
shaderData->GetSourceMode());
- Dali::Graphics::Shader &fragmentShader = mShaderCache->GetShader(
+ Dali::Graphics::Shader& fragmentShader = mShaderCache->GetShader(
fragShader,
Graphics::PipelineStage::FRAGMENT_SHADER,
shaderData->GetSourceMode());
// Check if the map has changed
DALI_ASSERT_DEBUG(mRenderDataProvider && "No Uniform map data provider available");
- const SceneGraph::UniformMapDataProvider& uniformMapDataProvider = mRenderDataProvider->GetUniformMap();
+ const SceneGraph::UniformMapDataProvider& uniformMapDataProvider = mRenderDataProvider->GetUniformMapDataProvider();
if(uniformMapDataProvider.GetUniformMapChanged(bufferIndex) ||
node.GetUniformMapChanged(bufferIndex) ||
// Create the UBO
uint32_t uboOffset{0u};
- auto &reflection = mGraphicsController->GetProgramReflection(program->GetGraphicsProgram());
+ auto& reflection = mGraphicsController->GetProgramReflection(program->GetGraphicsProgram());
uint32_t uniformBlockAllocationBytes = program->GetUniformBlocksMemoryRequirements().totalSizeRequired;
iter != end;
++iter)
{
- auto& uniform = *iter;
- int arrayIndex = uniform.arrayIndex;
+ auto& uniform = *iter;
+ int arrayIndex = uniform.arrayIndex;
if(!uniform.uniformFunc)
{
uniform.uniformOffset = uniformInfo.offset;
uniform.uniformLocation = uniformInfo.location;
- if (uniformFound)
+ if(uniformFound)
{
auto dst = ubo.GetOffset() + uniformInfo.offset;
const auto typeSize = GetPropertyValueSizeForUniform((*iter).propertyValue->GetType());
const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
const auto func = uniform.uniformFunc;
-
ubo.Write(&((*iter).propertyValue->*func)(updateBufferIndex),
typeSize,
dest);
return true;
}
- for(const auto& texture : mRenderDataProvider->GetTextures())
+ auto* textures = mRenderDataProvider->GetTextures();
+ if(textures)
{
- if(texture && texture->IsNativeImage())
+ for(auto iter = textures->Begin(), end = textures->End(); iter < end; ++iter)
{
- return true;
+ auto texture = *iter;
+ if(texture && texture->IsNativeImage())
+ {
+ return true;
+ }
}
}
hash = uniformProperty.propertyPtr->Hash(bufferIndex, hash);
}
- const SceneGraph::UniformMapDataProvider& uniformMapDataProvider = mRenderDataProvider->GetUniformMap();
+ const SceneGraph::UniformMapDataProvider& uniformMapDataProvider = mRenderDataProvider->GetUniformMapDataProvider();
const SceneGraph::CollectedUniformMap& uniformMap = uniformMapDataProvider.GetUniformMap(bufferIndex);
for(const auto& uniformProperty : uniformMap)
{
// Prepare query info
PipelineCacheQueryInfo queryInfo{};
- queryInfo.program = &program;
- queryInfo.renderer = this;
- queryInfo.geometry = mGeometry;
- queryInfo.blendingEnabled = blend;
- queryInfo.blendingOptions = &mBlendingOptions;
- queryInfo.alphaPremultiplied = mPremultipliedAlphaEnabled;
+ queryInfo.program = &program;
+ queryInfo.renderer = this;
+ queryInfo.geometry = mGeometry;
+ queryInfo.blendingEnabled = blend;
+ queryInfo.blendingOptions = &mBlendingOptions;
+ queryInfo.alphaPremultiplied = mPremultipliedAlphaEnabled;
queryInfo.cameraUsingReflection = instruction.GetCamera()->GetReflectionUsed();
- auto pipelineResult = mPipelineCache->GetPipeline( queryInfo, true );
+ auto pipelineResult = mPipelineCache->GetPipeline(queryInfo, true);
// should be never null?
return *pipelineResult.pipeline;
bool Updated(BufferIndex bufferIndex, const SceneGraph::NodeDataProvider* node);
template<class T>
- bool WriteDefaultUniform(const Graphics::UniformInfo* uniformInfo,
- Render::UniformBufferView& ubo,
- const T& data);
+ bool WriteDefaultUniform(const Graphics::UniformInfo* uniformInfo,
+ Render::UniformBufferView& ubo,
+ const T& data);
template<class T>
- void WriteUniform(Render::UniformBufferView& ubo,
- const Graphics::UniformInfo& uniformInfo,
- const T& data);
+ void WriteUniform(Render::UniformBufferView& ubo,
+ const Graphics::UniformInfo& uniformInfo,
+ const T& data);
- void WriteUniform(Render::UniformBufferView& ubo,
- const Graphics::UniformInfo& uniformInfo,
- const void* data,
- uint32_t size);
+ void WriteUniform(Render::UniformBufferView& ubo,
+ const Graphics::UniformInfo& uniformInfo,
+ const void* data,
+ uint32_t size);
[[nodiscard]] FaceCullingMode::Type GetFaceCullMode() const
{
BufferIndex updateBufferIndex);
private:
- Graphics::Controller* mGraphicsController;
- OwnerPointer<SceneGraph::RenderDataProvider> mRenderDataProvider;
+ Graphics::Controller* mGraphicsController;
+ SceneGraph::RenderDataProvider* mRenderDataProvider;
Render::Geometry* mGeometry;
using Hash = unsigned long;
- typedef const float&(PropertyInputImpl::*FuncGetter )(BufferIndex) const;
+ typedef const float& (PropertyInputImpl::*FuncGetter)(BufferIndex) const;
struct UniformIndexMap
{
Hash uniformNameHashNoArray{0u};
int32_t arrayIndex{-1}; ///< The array index
- int16_t uniformLocation{0u};
- uint16_t uniformOffset{0u};
- uint16_t uniformSize{0u};
- FuncGetter uniformFunc{0};
+ int16_t uniformLocation{0u};
+ uint16_t uniformOffset{0u};
+ uint16_t uniformSize{0u};
+ FuncGetter uniformFunc{0};
};
using UniformIndexMappings = Dali::Vector<UniformIndexMap>;
if(renderable.mRenderer)
{
- partialRenderingCacheInfo.textureSet = renderable.mRenderer->GetTextures();
+ partialRenderingCacheInfo.textureSet = renderable.mRenderer->GetTextureSet();
}
item.mNode = renderable.mNode;
if(DALI_LIKELY(renderable.mRenderer))
{
item.mRenderer = &renderable.mRenderer->GetRenderer();
- item.mTextureSet = renderable.mRenderer->GetTextures();
+ item.mTextureSet = renderable.mRenderer->GetTextureSet();
item.mDepthIndex += renderable.mRenderer->GetDepthIndex();
}
else
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
#include <dali/internal/render/data-providers/node-data-provider.h>
+#include <dali/internal/render/data-providers/render-data-provider.h>
#include <dali/internal/render/queue/render-queue.h>
#include <dali/internal/render/renderers/render-geometry.h>
#include <dali/internal/render/shaders/program.h>
mTextureSet(nullptr),
mGeometry(nullptr),
mShader(nullptr),
- mRenderDataProvider(nullptr),
mBlendColor(nullptr),
mStencilParameters(RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP),
mIndexedDrawFirstElement(0u),
{
if(mTextureSet)
{
- mTextureSet->RemoveObserver(this);
mTextureSet = nullptr;
}
if(mShader)
{
DALI_ASSERT_DEBUG(textureSet != NULL && "Texture set pointer is NULL");
- if(mTextureSet)
- {
- mTextureSet->RemoveObserver(this);
- }
-
- mTextureSet = textureSet;
- mTextureSet->AddObserver(this);
+ mTextureSet = textureSet;
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
+}
- UpdateTextureSet();
+const Vector<Render::Texture*>* Renderer::GetTextures() const
+{
+ return mTextureSet ? &(mTextureSet->GetTextures()) : nullptr;
+}
+
+const Vector<Render::Sampler*>* Renderer::GetSamplers() const
+{
+ return mTextureSet ? &(mTextureSet->GetSamplers()) : nullptr;
}
void Renderer::SetShader(Shader* shader)
mShader->AddConnectionObserver(*this);
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
mResendFlag |= RESEND_GEOMETRY | RESEND_SHADER;
-
- if(mRenderDataProvider)
- {
- mRenderDataProvider->mShader = mShader;
- }
}
void Renderer::SetGeometry(Render::Geometry* geometry)
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
mSceneController = &sceneController;
- mRenderDataProvider = new RenderDataProvider(mOpacity);
- mRenderDataProvider->mUniformMapDataProvider = this;
-
- mRenderer = Render::Renderer::New(mRenderDataProvider, mGeometry, mBlendBitmask, GetBlendColor(), static_cast<FaceCullingMode::Type>(mFaceCullingMode), mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters);
+ mRenderer = Render::Renderer::New(this, mGeometry, mBlendBitmask, GetBlendColor(), static_cast<FaceCullingMode::Type>(mFaceCullingMode), mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters);
OwnerPointer<Render::Renderer> transferOwnership(mRenderer);
mSceneController->GetRenderMessageDispatcher().AddRenderer(transferOwnership);
mSceneController->GetRenderMessageDispatcher().RemoveRenderer(*mRenderer);
mRenderer = nullptr;
}
- mSceneController = nullptr;
- mRenderDataProvider = nullptr;
-}
-
-void Renderer::UpdateTextureSet()
-{
- if(mRenderDataProvider)
- {
- if(mTextureSet)
- {
- uint32_t textureCount = mTextureSet->GetTextureCount();
- mRenderDataProvider->mTextures.resize(textureCount);
- mRenderDataProvider->mSamplers.resize(textureCount);
- for(uint32_t i = 0; i < textureCount; ++i)
- {
- mRenderDataProvider->mTextures[i] = mTextureSet->GetTexture(i);
- mRenderDataProvider->mSamplers[i] = mTextureSet->GetTextureSampler(i);
- }
- }
- else
- {
- mRenderDataProvider->mTextures.clear();
- mRenderDataProvider->mSamplers.clear();
- }
- }
+ mSceneController = nullptr;
}
Render::Renderer& Renderer::GetRenderer()
return opacityType;
}
-void Renderer::TextureSetChanged()
-{
- mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
-
- UpdateTextureSet();
-}
-
-void Renderer::TextureSetDeleted()
-{
- mTextureSet = nullptr;
-
- mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
-
- UpdateTextureSet();
-}
-
void Renderer::ConnectionsChanged(PropertyOwner& object)
{
// One of our child objects has changed it's connections. Ensure the uniform
class Renderer : public PropertyOwner,
public UniformMapDataProvider,
+ public RenderDataProvider,
public UniformMap::Observer,
public ConnectionChangePropagator::Observer
{
*/
void SetTextures(TextureSet* textureSet);
- /**
- * Returns current texture set object
- * @return Pointer to the texture set
- */
- const TextureSet* GetTextures() const
+ const SceneGraph::TextureSet* GetTextureSet() const
{
return mTextureSet;
}
/**
+ * @copydoc RenderDataProvider::GetTextures()
+ */
+ const Vector<Render::Texture*>* GetTextures() const override;
+
+ /**
+ * @copydoc RenderDataProvider::GetSamplers()
+ */
+ const Vector<Render::Sampler*>* GetSamplers() const override;
+
+ /**
* Set the shader for the renderer
* @param[in] shader The shader this renderer will use
*/
void SetShader(Shader* shader);
/**
- * Get the shader used by this renderer
- * @return the shader this renderer uses
+ * @copydoc RenderDataProvider::GetShader()
*/
- const Shader& GetShader() const
+ const Shader& GetShader() const override
{
return *mShader;
}
void BakeOpacity(BufferIndex updateBufferIndex, float opacity);
/**
- * Gets the opacity
- * @param[in] bufferIndex The buffer to read from.
- * @return The opacity
+ * @copydoc RenderDataProvider::GetOpacity()
*/
- float GetOpacity(BufferIndex updateBufferIndex) const;
+ float GetOpacity(BufferIndex updateBufferIndex) const override;
/**
* Sets the rendering behavior
OpacityType GetOpacityType(BufferIndex updateBufferIndex, const Node& node) const;
/**
- * Called by the TextureSet to notify to the renderer that it has changed
- */
- void TextureSetChanged();
-
- /**
- * Called by the TextureSet to notify to the renderer that it is about to be deleted
- */
- void TextureSetDeleted();
-
- /**
* Connect the object to the scene graph
*
* @param[in] sceneController The scene controller - used for sending messages to render thread
*/
void DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex);
+ /**
+ * @copydoc RenderDataProvider::GetUniformMapDataProvider()
+ */
+ const UniformMapDataProvider& GetUniformMapDataProvider() const override
+ {
+ return *this;
+ };
+
public: // Implementation of ConnectionChangePropagator
/**
* @copydoc ConnectionChangePropagator::AddObserver
*/
Renderer();
- /**
- * Update texture set to the render data provider
- */
- void UpdateTextureSet();
-
private:
CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps collected by the renderer
- SceneController* mSceneController; ///< Used for initializing renderers
- Render::Renderer* mRenderer; ///< Raw pointer to the renderer (that's owned by RenderManager)
- TextureSet* mTextureSet; ///< The texture set this renderer uses. (Not owned)
- Render::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned)
- Shader* mShader; ///< The shader this renderer uses. (Not owned)
- RenderDataProvider* mRenderDataProvider; ///< The render data provider
- OwnerPointer<Vector4> mBlendColor; ///< The blend color for blending operation
+ SceneController* mSceneController; ///< Used for initializing renderers
+ Render::Renderer* mRenderer; ///< Raw pointer to the renderer (that's owned by RenderManager)
+ TextureSet* mTextureSet; ///< The texture set this renderer uses. (Not owned)
+ Render::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned)
+ Shader* mShader; ///< The shader this renderer uses. (Not owned)
+ OwnerPointer<Vector4> mBlendColor; ///< The blend color for blending operation
Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
TextureSet::TextureSet()
: mSamplers(),
- mRenderers(),
mHasAlpha(false)
{
}
TextureSet::~TextureSet()
{
- for(auto&& renderer : mRenderers)
- {
- renderer->TextureSetDeleted();
- }
}
void TextureSet::operator delete(void* ptr)
}
mSamplers[index] = sampler;
- NotifyChangeToRenderers();
}
void TextureSet::SetTexture(uint32_t index, Render::Texture* texture)
{
mHasAlpha |= texture->HasAlphaChannel();
}
-
- NotifyChangeToRenderers();
}
bool TextureSet::HasAlpha() const
return mHasAlpha;
}
-void TextureSet::AddObserver(Renderer* renderer)
-{
- for(auto&& element : mRenderers)
- {
- if(element == renderer)
- {
- //Renderer already in the list
- return;
- }
- }
-
- mRenderers.PushBack(renderer);
-}
-
-void TextureSet::RemoveObserver(Renderer* renderer)
-{
- for(auto &&iter = mRenderers.Begin(), end = mRenderers.End(); iter != end; ++iter)
- {
- if(*iter == renderer)
- {
- mRenderers.Remove(iter);
- return;
- }
- }
-}
-
-void TextureSet::NotifyChangeToRenderers()
-{
- for(auto&& element : mRenderers)
- {
- element->TextureSetChanged();
- }
-}
-
} // namespace SceneGraph
} // namespace Internal
bool HasAlpha() const;
/**
- * Adds a renderer to the Renderers list of the texture set.
- * Renderers using the TextureSet get a notification when the texture set changes
- *
- * @param[in] renderer The renderer using the TextureSet
+ * Accessor for textures (used by RenderDataProvider impl)
*/
- void AddObserver(Renderer* renderer);
-
- /**
- * Removes a renderer from the TextureSet renderers list
- *
- * @param[in] renderer The renderer no longer using the TextureSet
- */
- void RemoveObserver(Renderer* renderer);
-
- /**
- * Get the sampler of a texture in the TextureSet
- * @param[in] index The index of the texture in the textures array
- * @return the sampler used by the texture
- */
- Render::Sampler* GetTextureSampler(uint32_t index)
- {
- return mSamplers[index];
- }
-
- /**
- * Get the number of Textures in the texture set
- * @return The number of Textures
- */
- uint32_t GetTextureCount()
+ const Vector<Render::Texture*>& GetTextures()
{
- return static_cast<uint32_t>(mTextures.Size());
+ return mTextures;
}
/**
- * Get the pointer to a Texture in the TextureSet
- * @param[in] index The index of the texture in the textures array
- * @return the pointer to the Texture in that position
+ * Accessor for samplers (used by RenderDataProvider impl)
*/
- Render::Texture* GetTexture(uint32_t index)
+ const Vector<Render::Sampler*>& GetSamplers()
{
- return mTextures[index];
+ return mSamplers;
}
private:
*/
TextureSet();
- /**
- * Helper method to notify the renderers observing the TextureSet
- * that the TextureSet has changed
- */
- void NotifyChangeToRenderers();
-
-private: // Data
- Vector<Render::Sampler*> mSamplers; ///< List of samplers used by each texture. Not owned
- Vector<Render::Texture*> mTextures; ///< List of Textures. Not owned
- Vector<Renderer*> mRenderers; ///< List of renderers using the TextureSet
- bool mHasAlpha; ///< if any of the textures has an alpha channel
+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
};
inline void SetTextureMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Texture* texture)