/*
- * 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/blending-options.h>
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
-#include <dali/internal/event/rendering/decorated-visual-renderer-impl.h> // For DecoratedVisualRenderer::AnimatableDecoratedVisualProperties
#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>
mOpacity(1.0f),
mDepthIndex(0)
{
- // Observe our own PropertyOwner's uniform map.
- AddUniformMapObserver(*this);
}
Renderer::~Renderer()
{
- if(mShader)
- {
- mShader->RemoveUniformMapObserver(*this);
- mShader = nullptr;
- }
}
void Renderer::operator delete(void* ptr)
bool Renderer::PrepareRender(BufferIndex updateBufferIndex)
{
- bool rendererUpdated = mResendFlag || mRenderingBehavior == DevelRenderer::Rendering::CONTINUOUSLY || mUpdateDecay > 0;
+ bool rendererUpdated = mResendFlag || mRenderingBehavior == DevelRenderer::Rendering::CONTINUOUSLY || mUpdateDecay > 0;
+ auto shaderMapChangeCounter = mShader ? mShader->GetUniformMap().GetChangeCounter() : 0u;
+ bool shaderMapChanged = mShader && (mShaderMapChangeCounter != shaderMapChangeCounter);
+ if(shaderMapChanged)
+ {
+ mShaderMapChangeCounter = shaderMapChangeCounter;
+ }
- if(mUniformMapChangeCounter != mUniformMaps.GetChangeCounter())
+ if(mUniformMapChangeCounter != mUniformMaps.GetChangeCounter() || shaderMapChanged)
{
// The map has changed since the last time we checked.
- rendererUpdated = true;
- mRegenerateUniformMap = true;
- mUpdateDecay = Renderer::Decay::INITIAL; // Render at least twice if the map has changed/actor has been added
+ rendererUpdated = true;
+ mRegenerateUniformMap = true;
+ mUpdateDecay = Renderer::Decay::INITIAL; // Render at least twice if the map has changed/actor has been added
+
+ // Update local counters to identify any future changes to maps
+ // (unlikely, but allowed by API).
mUniformMapChangeCounter = mUniformMaps.GetChangeCounter();
}
if(mUpdateDecay > 0)
{
DALI_ASSERT_DEBUG(shader != NULL && "Shader pointer is NULL");
- if(mShader)
- {
- mShader->RemoveUniformMapObserver(*this);
- }
-
- mShader = shader;
- mShader->AddUniformMapObserver(*this);
- mRegenerateUniformMap = true;
+ mShader = shader;
+ mShaderMapChangeCounter = 0u;
+ mRegenerateUniformMap = true;
mResendFlag |= RESEND_GEOMETRY | RESEND_SHADER;
mDirtyFlag = true;
}
break;
}
+ case BlendMode::USE_ACTOR_OPACITY: // the renderer should never use blending
+ {
+ // renderer should determine opacity using the actor color
+ float alpha = node.GetWorldColor(updateBufferIndex).a;
+ if(alpha <= FULLY_TRANSPARENT)
+ {
+ opacityType = Renderer::TRANSPARENT;
+ }
+ else if(alpha < FULLY_OPAQUE)
+ {
+ opacityType = Renderer::TRANSLUCENT;
+ }
+ else
+ {
+ opacityType = Renderer::OPAQUE;
+ }
+ break;
+ }
case BlendMode::OFF: // the renderer should never use blending
default:
{
localMap.AddMappings(mShader->GetUniformMap());
}
localMap.UpdateChangeCounter();
+
mRegenerateUniformMap = false;
SetUpdated(true);
}
SetUpdated(false);
}
-void Renderer::UniformMappingsChanged(const UniformMap& mappings)
+uint32_t Renderer::GetMemoryPoolCapacity()
{
- // The mappings are either from PropertyOwner base class, or the Shader
+ return gRendererMemoryPool.GetCapacity();
+}
+
+void Renderer::OnMappingChanged()
+{
+ // Properties have been registered on the base class.
mRegenerateUniformMap = true; // Should remain true until this renderer is added to a RenderList.
}
{
if(mVisualProperties)
{
+ auto& coefficient = mVisualProperties->mCoefficient;
+
// TODO : We may need to get some method that visual properties changed, without hash.
// Or, need to call this API in PreRender side.
hash = mVisualProperties->mTransformAnchorPoint.Hash(updateBufferIndex, hash);
hash = mVisualProperties->mExtraSize.Hash(updateBufferIndex, hash);
- if(mVisualPropertiesCoefficient.hash != hash)
+ if(coefficient.hash != hash)
{
- mVisualPropertiesCoefficient.hash = hash;
+ coefficient.hash = hash;
// VisualProperty
const Vector2 transformOffset = mVisualProperties->mTransformOffset.Get(updateBufferIndex);
// + transformOffset * transformOffsetSizeMode.xy
// D = max((1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth, 2.0 * blurRadius)
- mVisualPropertiesCoefficient.coefXA = transformSize * Vector2(1.0f - transformOffsetSizeMode.z, 1.0f - transformOffsetSizeMode.w);
- mVisualPropertiesCoefficient.coefXB = mVisualPropertiesCoefficient.coefXA * transformAnchorPoint + transformOffset * Vector2(1.0f - transformOffsetSizeMode.x, 1.0f - transformOffsetSizeMode.y) + transformOrigin;
- mVisualPropertiesCoefficient.coefCA = transformSize * Vector2(transformOffsetSizeMode.z, transformOffsetSizeMode.w) + extraSize;
- mVisualPropertiesCoefficient.coefCB = mVisualPropertiesCoefficient.coefCA * transformAnchorPoint + transformOffset * Vector2(transformOffsetSizeMode.x, transformOffsetSizeMode.y);
+ coefficient.coefXA = transformSize * Vector2(1.0f - transformOffsetSizeMode.z, 1.0f - transformOffsetSizeMode.w);
+ coefficient.coefXB = coefficient.coefXA * transformAnchorPoint + transformOffset * Vector2(1.0f - transformOffsetSizeMode.x, 1.0f - transformOffsetSizeMode.y) + transformOrigin;
+ coefficient.coefCA = transformSize * Vector2(transformOffsetSizeMode.z, transformOffsetSizeMode.w) + extraSize;
+ coefficient.coefCB = coefficient.coefCA * transformAnchorPoint + transformOffset * Vector2(transformOffsetSizeMode.x, transformOffsetSizeMode.y);
}
if(mVisualProperties->mExtendedProperties)
{
- const auto decoratedVisualProperties = static_cast<DecoratedVisualRenderer::AnimatableDecoratedVisualProperties*>(mVisualProperties->mExtendedProperties);
+ const auto decoratedVisualProperties = static_cast<VisualRenderer::AnimatableDecoratedVisualProperties*>(mVisualProperties->mExtendedProperties);
uint64_t decoratedHash = 0xc70f6907UL;
decoratedHash = decoratedVisualProperties->mBorderlineOffset.Hash(updateBufferIndex, decoratedHash);
decoratedHash = decoratedVisualProperties->mBlurRadius.Hash(updateBufferIndex, decoratedHash);
- if(mVisualPropertiesCoefficient.decoratedHash != decoratedHash)
+ if(coefficient.decoratedHash != decoratedHash)
{
- mVisualPropertiesCoefficient.decoratedHash = decoratedHash;
+ coefficient.decoratedHash = decoratedHash;
// DecoratedVisualProperty
const float borderlineWidth = decoratedVisualProperties->mBorderlineWidth.Get(updateBufferIndex);
// D coefficients be used only decoratedVisual.
// It can be calculated parallely with transform.
- mVisualPropertiesCoefficient.coefD = std::max((1.0f + Dali::Clamp(borderlineOffset, -1.0f, 1.0f)) * borderlineWidth, 2.0f * blurRadius);
+ coefficient.coefD = std::max((1.0f + Dali::Clamp(borderlineOffset, -1.0f, 1.0f)) * borderlineWidth, 2.0f * blurRadius);
}
}
const Vector2 originalXY = Vector2(originalUpdateArea.x, originalUpdateArea.y);
const Vector2 originalWH = Vector2(originalUpdateArea.z, originalUpdateArea.w);
- const Vector2 basicVertexPosition = mVisualPropertiesCoefficient.coefXB * originalWH + mVisualPropertiesCoefficient.coefCB;
- const Vector2 scaleVertexPosition = mVisualPropertiesCoefficient.coefXA * originalWH + mVisualPropertiesCoefficient.coefCA;
+ const Vector2 basicVertexPosition = coefficient.coefXB * originalWH + coefficient.coefCB;
+ const Vector2 scaleVertexPosition = coefficient.coefXA * originalWH + coefficient.coefCA;
// TODO : We need to re-generate coefficient to consitder area width/height
const Vector4 resultArea = Vector4(originalXY.x,
originalXY.y,
- scaleVertexPosition.x + 2.0f * abs(basicVertexPosition.x) + mVisualPropertiesCoefficient.coefD,
- scaleVertexPosition.y + 2.0f * abs(basicVertexPosition.y) + mVisualPropertiesCoefficient.coefD);
+ scaleVertexPosition.x + 2.0f * abs(basicVertexPosition.x) + coefficient.coefD,
+ scaleVertexPosition.y + 2.0f * abs(basicVertexPosition.y) + coefficient.coefD);
DALI_LOG_INFO(gSceneGraphRendererLogFilter, Debug::Verbose, "%f %f %f %f--> %f %f %f %f\n", originalUpdateArea.x, originalUpdateArea.y, originalUpdateArea.z, originalUpdateArea.w, resultArea.x, resultArea.y, resultArea.z, resultArea.w);