/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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 HEADERS
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
+#include <dali/internal/render/renderers/render-texture.h>
#include <dali/internal/update/rendering/scene-graph-renderer.h>
namespace //Unnamed namespace
{
//Memory pool used to allocate new texture sets. Memory used by this pool will be released when shutting down DALi
Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::TextureSet> gTextureSetMemoryPool;
-}
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
TextureSet* TextureSet::New()
{
- return new ( gTextureSetMemoryPool.AllocateRawThreadSafe() ) TextureSet();
+ return new(gTextureSetMemoryPool.AllocateRawThreadSafe()) TextureSet();
}
TextureSet::TextureSet()
: mSamplers(),
- mRenderers(),
- mHasAlpha( false )
+ mHasAlpha(false)
{
}
{
}
-void TextureSet::operator delete( void* ptr )
+void TextureSet::operator delete(void* ptr)
{
- gTextureSetMemoryPool.FreeThreadSafe( static_cast<TextureSet*>( ptr ) );
+ gTextureSetMemoryPool.FreeThreadSafe(static_cast<TextureSet*>(ptr));
}
-void TextureSet::SetSampler( size_t index, Render::Sampler* sampler )
+void TextureSet::SetSampler(uint32_t index, Render::Sampler* sampler)
{
- size_t samplerCount( mSamplers.Size() );
- if( samplerCount < index + 1 )
+ const uint32_t samplerCount = static_cast<uint32_t>(mSamplers.Size());
+ if(samplerCount < index + 1)
{
- mSamplers.Resize( index + 1 );
- for( size_t i(samplerCount); i<=index; ++i )
+ mSamplers.Resize(index + 1);
+ for(uint32_t i(samplerCount); i <= index; ++i)
{
- mSamplers[i] = NULL;
+ mSamplers[i] = nullptr;
}
}
mSamplers[index] = sampler;
- NotifyChangeToRenderers();
+
+ if(index < static_cast<uint32_t>(mTextures.Size()))
+ {
+ mTextures[index]->SetUpdated(true);
+ }
}
-void TextureSet::SetTexture( size_t index, Render::Texture* texture )
+void TextureSet::SetTexture(uint32_t index, Render::Texture* texture)
{
- const size_t textureCount( mTextures.Size() );
- if( textureCount < index + 1 )
+ const uint32_t textureCount = static_cast<uint32_t>(mTextures.Size());
+ if(textureCount < index + 1)
{
- mTextures.Resize( index + 1 );
+ mTextures.Resize(index + 1);
bool samplerExist = true;
- if( mSamplers.Size() < index + 1 )
+ if(mSamplers.Size() < index + 1)
{
- mSamplers.Resize( index + 1 );
+ mSamplers.Resize(index + 1);
samplerExist = false;
}
- for( size_t i(textureCount); i<=index; ++i )
+ for(uint32_t i(textureCount); i <= index; ++i)
{
- mTextures[i] = 0;
+ mTextures[i] = nullptr;
- if( !samplerExist )
+ if(!samplerExist)
{
- mSamplers[i] = 0;
+ mSamplers[i] = nullptr;
}
}
}
mTextures[index] = texture;
- if( texture )
+ if(texture)
{
mHasAlpha |= texture->HasAlphaChannel();
+ texture->SetUpdated(true);
}
-
- NotifyChangeToRenderers();
}
bool TextureSet::HasAlpha() const
return mHasAlpha;
}
-void TextureSet::AddObserver( Renderer* renderer )
+uint32_t TextureSet::GetMemoryPoolCapacity()
{
- size_t rendererCount( mRenderers.Size() );
- for( size_t i(0); i<rendererCount; ++i )
- {
- if( mRenderers[i] == renderer )
- {
- //Renderer already in the list
- return;
- }
- }
-
- mRenderers.PushBack( renderer );
-}
-
-void TextureSet::RemoveObserver( Renderer* renderer )
-{
- size_t rendererCount( mRenderers.Size() );
- for( size_t i(0); i<rendererCount; ++i )
- {
- if( mRenderers[i] == renderer )
- {
- mRenderers.Remove( mRenderers.Begin() + i );
- return;
- }
- }
-}
-
-void TextureSet::NotifyChangeToRenderers()
-{
- size_t rendererCount = mRenderers.Size();
- for( size_t i(0); i<rendererCount; ++i )
- {
- mRenderers[i]->TextureSetChanged();
- }
+ return gTextureSetMemoryPool.GetCapacity();
}
} // namespace SceneGraph