int UtcDaliDliLoaderLoadSceneExercise(void)
{
+ TestApplication app;
Context ctx;
auto path = ctx.pathProvider(ResourceType::Mesh) + "exercise.dli";
Customization::Choices choices;
- TestApplication app;
-
Actor root = Actor::New();
SetActorCentered(root);
for(auto iRoot : scene.GetRoots())
int UtcDaliGltfLoaderAnimationLoadingTest(void)
{
+ TestApplication app;
Context ctx;
auto& resources = ctx.resources;
Customization::Choices choices;
- TestApplication app;
-
Actor root = Actor::New();
SetActorCentered(root);
for(auto iRoot : roots)
q = Dali::Accessibility::Accessible::Get(buttonB);
DALI_TEST_CHECK(q);
states = q->GetStates();
- DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
+ DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
q = Dali::Accessibility::Accessible::Get(buttonC);
DALI_TEST_CHECK(q);
/*
- * 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.
source.resize(graphicsShader->mCreateInfo.sourceSize);
memcpy(&source[0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize);
- if(!std::equal(source.begin(), source.end(), cacheEntry.shaders[shader.pipelineStage].begin()))
+ if(!std::equal(source.begin(), source.end(), cacheEntry.shaders[shader.pipelineStage].begin(), cacheEntry.shaders[shader.pipelineStage].end()))
{
found = false;
break;
{
return true;
}
- void CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool softwareItailc, bool softwareBold, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth)
+ void CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool softwareItailc, bool softwareBold, Dali::TextAbstraction::GlyphBufferData& data, int outlineWidth)
{
}
PixelData CreateBitmap(FontId fontId, GlyphIndex glyphIndex, int outlineWidth)
{
}
-FontClient::GlyphBufferData::GlyphBufferData()
+GlyphBufferData::GlyphBufferData()
{
}
-FontClient::GlyphBufferData::~GlyphBufferData()
+GlyphBufferData::~GlyphBufferData()
{
}
return GetImplementation(*this).GetGlyphMetrics(array, size, horizontal);
}
-void FontClient::CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool softwareItailc, bool softwareBold, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth)
+void FontClient::CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool softwareItailc, bool softwareBold, Dali::TextAbstraction::GlyphBufferData& data, int outlineWidth)
{
GetImplementation(*this).CreateBitmap(fontId, glyphIndex, softwareItailc, softwareBold, data, outlineWidth);
}
return (HasSucceeded()) ? mEnvironmentMapData.GetTexture() : Texture();
}
+uint32_t EnvironmentMapLoadTask::GetMipmapLevels()
+{
+ return (HasSucceeded()) ? mEnvironmentMapData.GetMipmapLevels() : 1u;
+}
+
} // namespace Internal
} // namespace Scene3D
*/
Dali::Texture GetLoadedTexture();
+ /**
+ * Retrieves Mipmap levels of loaded Ibl texture
+ * @return mipmap levels of loaded Ibl texture
+ */
+ uint32_t GetMipmapLevels();
+
private:
// Undefined
EnvironmentMapLoadTask(const EnvironmentMapLoadTask& task) = delete;
* @param[in] diffuseTexture cube map texture that can be used as a diffuse IBL source.
* @param[in] specularTexture cube map texture that can be used as a specular IBL source.
* @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f]. Default value is 1.0f.
+ * @param[in] specularMipmapLevels mipmap levels of specular texture
*/
- virtual void NotifyImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor) = 0;
+ virtual void NotifyImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor, uint32_t specularMipmapLevels) = 0;
/**
* @brief Notifies Scale Factor of Image Based Light is changed by parent SceneView.
mModelPivot(AnchorPoint::CENTER),
mSceneIblScaleFactor(1.0f),
mIblScaleFactor(1.0f),
+ mSceneSpecularMipmapLevels(1u),
+ mSpecularMipmapLevels(1u),
mModelChildrenSensitive(DEFAULT_MODEL_CHILDREN_SENSITIVE),
mModelChildrenFocusable(DEFAULT_MODEL_CHILDREN_FOCUSABLE),
mModelResourceReady(false),
NotifyResourceReady();
}
-void Model::SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor)
-{
- // If input texture is wrong, Model is rendered with SceneView's IBL.
- if(mDiffuseTexture != diffuseTexture || mSpecularTexture != specularTexture)
- {
- mDiffuseTexture = diffuseTexture;
- mSpecularTexture = specularTexture;
- mIblScaleFactor = scaleFactor;
- UpdateImageBasedLightTexture();
- }
-}
-
void Model::SetImageBasedLightScaleFactor(float scaleFactor)
{
mIblScaleFactor = scaleFactor;
void Model::UpdateImageBasedLightTexture()
{
- Dali::Texture currentDiffuseTexture = (mDiffuseTexture && mSpecularTexture) ? mDiffuseTexture : mSceneDiffuseTexture;
- Dali::Texture currentSpecularTexture = (mDiffuseTexture && mSpecularTexture) ? mSpecularTexture : mSceneSpecularTexture;
- float currentIblScaleFactor = (mDiffuseTexture && mSpecularTexture) ? mIblScaleFactor : mSceneIblScaleFactor;
+ Dali::Texture currentDiffuseTexture = (mDiffuseTexture && mSpecularTexture) ? mDiffuseTexture : mSceneDiffuseTexture;
+ Dali::Texture currentSpecularTexture = (mDiffuseTexture && mSpecularTexture) ? mSpecularTexture : mSceneSpecularTexture;
+ float currentIblScaleFactor = (mDiffuseTexture && mSpecularTexture) ? mIblScaleFactor : mSceneIblScaleFactor;
+ uint32_t currentIblSpecularMipmapLevels = (mDiffuseTexture && mSpecularTexture) ? mSpecularMipmapLevels : mSceneSpecularMipmapLevels;
if(!currentDiffuseTexture || !currentSpecularTexture)
{
- currentDiffuseTexture = mDefaultDiffuseTexture;
- currentSpecularTexture = mDefaultSpecularTexture;
- currentIblScaleFactor = Dali::Scene3D::Loader::EnvironmentDefinition::GetDefaultIntensity();
+ currentDiffuseTexture = mDefaultDiffuseTexture;
+ currentSpecularTexture = mDefaultSpecularTexture;
+ currentIblScaleFactor = Dali::Scene3D::Loader::EnvironmentDefinition::GetDefaultIntensity();
+ currentIblSpecularMipmapLevels = 1u;
}
for(auto&& actor : mRenderableActors)
}
}
renderableActor.RegisterProperty(Dali::Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), currentIblScaleFactor);
+ renderableActor.RegisterProperty(Dali::Scene3D::Loader::NodeDefinition::GetIblMaxLodUniformName().data(), static_cast<float>(currentIblSpecularMipmapLevels));
}
}
camera.SetProperty(Actor::Property::SCALE, resultScale);
}
-void Model::NotifyImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor)
+void Model::NotifyImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor, uint32_t specularMipmapLevels)
{
if(mSceneDiffuseTexture != diffuseTexture || mSceneSpecularTexture != specularTexture)
{
- mSceneDiffuseTexture = diffuseTexture;
- mSceneSpecularTexture = specularTexture;
- mSceneIblScaleFactor = scaleFactor;
+ mSceneDiffuseTexture = diffuseTexture;
+ mSceneSpecularTexture = specularTexture;
+ mSceneIblScaleFactor = scaleFactor;
+ mSceneSpecularMipmapLevels = specularMipmapLevels;
// If Model IBL is not set, use SceneView's IBL.
if(!mDiffuseTexture || !mSpecularTexture)
{
void Model::OnIblSpecularLoadComplete()
{
- mSpecularTexture = mIblSpecularLoadTask->GetLoadedTexture();
+ mSpecularTexture = mIblSpecularLoadTask->GetLoadedTexture();
+ mSpecularMipmapLevels = mIblSpecularLoadTask->GetMipmapLevels();
ResetResourceTask(mIblSpecularLoadTask);
mIblSpecularResourceReady = true;
if(mIblDiffuseResourceReady && mIblSpecularResourceReady)
void SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor);
/**
- * @copydoc Model::SetImageBasedLightTexture()
- */
- void SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor);
-
- /**
* @copydoc Model::SetImageBasedLightScaleFactor()
*/
void SetImageBasedLightScaleFactor(float scaleFactor);
/**
* @copydoc Dali::Scene3D::Internal::ImageBasedLightObserver::NotifyImageBasedLightTexture()
*/
- void NotifyImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor) override;
+ void NotifyImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor, uint32_t specularMipmapLevels) override;
/**
* @copydoc Dali::Scene3D::Internal::ImageBasedLightObserver::NotifyImageBasedLightScaleFactor()
Vector3 mModelPivot;
float mSceneIblScaleFactor;
float mIblScaleFactor;
+ uint32_t mSceneSpecularMipmapLevels;
+ uint32_t mSpecularMipmapLevels;
bool mModelChildrenSensitive;
bool mModelChildrenFocusable;
bool mModelResourceReady;
{
if(item)
{
- item->NotifyImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor);
+ item->NotifyImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor, mSpecularMipmapLevels);
mItems.push_back(item);
}
}
mDiffuseTexture.Reset();
mSpecularTexture.Reset();
+ mSpecularMipmapLevels = 1u;
NotifyImageBasedLightTextureChange();
}
else
void SceneView::OnIblSpecularLoadComplete()
{
mSpecularTexture = mIblSpecularLoadTask->GetLoadedTexture();
+ mSpecularMipmapLevels = mIblSpecularLoadTask->GetMipmapLevels();
mIblSpecularResourceReady = true;
if(mIblDiffuseResourceReady && mIblSpecularResourceReady)
{
{
if(item)
{
- item->NotifyImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor);
+ item->NotifyImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor, mSpecularMipmapLevels);
}
}
}
Dali::Texture mDiffuseTexture;
Dali::Texture mSpecularTexture;
float mIblScaleFactor{1.0f};
+ uint32_t mSpecularMipmapLevels{1u};
bool mUseFrameBuffer{false};
bool mSkyboxResourceReady{true};
bool mIblDiffuseResourceReady{true};
uniform float uOcclusionStrength;
#endif
-#ifdef EMISSIVE
+#ifdef EMISSIVE_TEXTURE
uniform sampler2D sEmissive;
-uniform vec3 uEmissiveFactor;
#endif
+uniform vec3 uEmissiveFactor;
uniform float uSpecularFactor;
uniform vec3 uSpecularColorFactor;
uniform samplerCube sSpecularEnvSampler;
uniform float uIblIntensity;
uniform vec3 uYDirection;
+uniform float uMaxLOD;
// For Alpha Mode.
uniform lowp float uOpaque;
vec3 FssEss = specularWeight * (k_S * brdf.x + brdf.y);
// Specular Light
- lowp vec3 specularLight = linear(texture(sSpecularEnvSampler, reflection * uYDirection).rgb);
+ // uMaxLOD that means mipmap level of specular texture is used for bluring of reflection of specular following roughness.
+ float lod = perceptualRoughness * (uMaxLOD - 1.0);
+ lowp vec3 specularLight = linear(textureLod(sSpecularEnvSampler, reflection * uYDirection, lod).rgb);
lowp vec3 specular = specularLight * FssEss;
// Diffuse Light
color = mix(color, color * ao, uOcclusionStrength);
#endif // OCCLUSION
-#ifdef EMISSIVE
+#ifdef EMISSIVE_TEXTURE
lowp vec3 emissive = linear(texture(sEmissive, vUV).rgb) * uEmissiveFactor;
+#else
+ lowp vec3 emissive = uEmissiveFactor;
+#endif // EMISSIVE_TEXTURE
color += emissive;
-#endif // EMISSIVE
FragColor = vec4(pow(color, vec3(1.0 / 2.2)), baseColor.a) * uColor;
}
/*
-* 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.
16,
static_cast<uint32_t>(-1)};
-const std::map<std::string_view, AccessorType::Type> ACCESSOR_TYPES{
- ENUM_STRING_MAPPING(AccessorType, SCALAR),
- ENUM_STRING_MAPPING(AccessorType, VEC2),
- ENUM_STRING_MAPPING(AccessorType, VEC3),
- ENUM_STRING_MAPPING(AccessorType, VEC4),
- ENUM_STRING_MAPPING(AccessorType, MAT2),
- ENUM_STRING_MAPPING(AccessorType, MAT3),
- ENUM_STRING_MAPPING(AccessorType, MAT4),
-};
-
-const std::map<std::string_view, AlphaMode::Type> ALPHA_MODE_TYPES{
- ENUM_STRING_MAPPING(AlphaMode::Type, OPAQUE),
- ENUM_STRING_MAPPING(AlphaMode::Type, MASK),
- ENUM_STRING_MAPPING(AlphaMode::Type, BLEND),
-};
-
-const std::map<std::string_view, Attribute::Type> ATTRIBUTE_TYPES{
- ENUM_STRING_MAPPING(Attribute::Type, POSITION),
- ENUM_STRING_MAPPING(Attribute::Type, NORMAL),
- ENUM_STRING_MAPPING(Attribute::Type, TANGENT),
- ENUM_STRING_MAPPING(Attribute::Type, TEXCOORD_0),
- ENUM_STRING_MAPPING(Attribute::Type, TEXCOORD_1),
- ENUM_STRING_MAPPING(Attribute::Type, COLOR_0),
- ENUM_STRING_MAPPING(Attribute::Type, JOINTS_0),
- ENUM_STRING_MAPPING(Attribute::Type, WEIGHTS_0),
-};
-
-const std::map<std::string_view, Animation::Sampler::Interpolation::Type> ANIMATION_SAMPLER_INTERPOLATION{
- ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, STEP),
- ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, LINEAR),
- ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, CUBICSPLINE),
-};
-
-const std::map<std::string_view, Animation::Channel::Target::Type> ANIMATION_CHANNEL_TARGET_PATH_TYPES{
- ENUM_STRING_MAPPING(Animation::Channel::Target::Type, TRANSLATION),
- ENUM_STRING_MAPPING(Animation::Channel::Target::Type, ROTATION),
- ENUM_STRING_MAPPING(Animation::Channel::Target::Type, SCALE),
- ENUM_STRING_MAPPING(Animation::Channel::Target::Type, WEIGHTS),
-};
+const std::map<std::string_view, AccessorType::Type>& GetAccessorTypes()
+{
+ static const std::map<std::string_view, AccessorType::Type> ACCESSOR_TYPES{
+ ENUM_STRING_MAPPING(AccessorType, SCALAR),
+ ENUM_STRING_MAPPING(AccessorType, VEC2),
+ ENUM_STRING_MAPPING(AccessorType, VEC3),
+ ENUM_STRING_MAPPING(AccessorType, VEC4),
+ ENUM_STRING_MAPPING(AccessorType, MAT2),
+ ENUM_STRING_MAPPING(AccessorType, MAT3),
+ ENUM_STRING_MAPPING(AccessorType, MAT4),
+ };
+ return ACCESSOR_TYPES;
+}
+
+const std::map<std::string_view, AlphaMode::Type>& GetAlphaModeTypes()
+{
+ static const std::map<std::string_view, AlphaMode::Type> ALPHA_MODE_TYPES{
+ ENUM_STRING_MAPPING(AlphaMode::Type, OPAQUE),
+ ENUM_STRING_MAPPING(AlphaMode::Type, MASK),
+ ENUM_STRING_MAPPING(AlphaMode::Type, BLEND),
+ };
+ return ALPHA_MODE_TYPES;
+}
+
+const std::map<std::string_view, Attribute::Type>& GetAttributeTypes()
+{
+ static const std::map<std::string_view, Attribute::Type> ATTRIBUTE_TYPES{
+ ENUM_STRING_MAPPING(Attribute::Type, POSITION),
+ ENUM_STRING_MAPPING(Attribute::Type, NORMAL),
+ ENUM_STRING_MAPPING(Attribute::Type, TANGENT),
+ ENUM_STRING_MAPPING(Attribute::Type, TEXCOORD_0),
+ ENUM_STRING_MAPPING(Attribute::Type, TEXCOORD_1),
+ ENUM_STRING_MAPPING(Attribute::Type, COLOR_0),
+ ENUM_STRING_MAPPING(Attribute::Type, JOINTS_0),
+ ENUM_STRING_MAPPING(Attribute::Type, WEIGHTS_0),
+ };
+ return ATTRIBUTE_TYPES;
+}
+
+const std::map<std::string_view, Animation::Sampler::Interpolation::Type>& GetAnimationSamplerInterpolation()
+{
+ static const std::map<std::string_view, Animation::Sampler::Interpolation::Type> ANIMATION_SAMPLER_INTERPOLATION{
+ ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, STEP),
+ ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, LINEAR),
+ ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, CUBICSPLINE),
+ };
+ return ANIMATION_SAMPLER_INTERPOLATION;
+}
+
+const std::map<std::string_view, Animation::Channel::Target::Type>& GetAnimationChannelTargetPathTypes()
+{
+ static const std::map<std::string_view, Animation::Channel::Target::Type> ANIMATION_CHANNEL_TARGET_PATH_TYPES{
+ ENUM_STRING_MAPPING(Animation::Channel::Target::Type, TRANSLATION),
+ ENUM_STRING_MAPPING(Animation::Channel::Target::Type, ROTATION),
+ ENUM_STRING_MAPPING(Animation::Channel::Target::Type, SCALE),
+ ENUM_STRING_MAPPING(Animation::Channel::Target::Type, WEIGHTS),
+ };
+ return ANIMATION_CHANNEL_TARGET_PATH_TYPES;
+}
} // namespace
-ENUM_TYPE_FROM_STRING(AccessorType, ACCESSOR_TYPES)
-ENUM_TYPE_FROM_STRING(AlphaMode, ALPHA_MODE_TYPES)
-ENUM_TYPE_FROM_STRING(Attribute, ATTRIBUTE_TYPES)
-ENUM_TYPE_FROM_STRING(Animation::Sampler::Interpolation, ANIMATION_SAMPLER_INTERPOLATION)
-ENUM_TYPE_FROM_STRING(Animation::Channel::Target, ANIMATION_CHANNEL_TARGET_PATH_TYPES)
+ENUM_TYPE_FROM_STRING(AccessorType, GetAccessorTypes())
+ENUM_TYPE_FROM_STRING(AlphaMode, GetAlphaModeTypes())
+ENUM_TYPE_FROM_STRING(Attribute, GetAttributeTypes())
+ENUM_TYPE_FROM_STRING(Animation::Sampler::Interpolation, GetAnimationSamplerInterpolation())
+ENUM_TYPE_FROM_STRING(Animation::Channel::Target, GetAnimationChannelTargetPathTypes())
bool Component::IsUnsigned(Type t)
{
MeshDefinition::Blob::ApplyMinMax(accessor.mMin, accessor.mMax, accessor.mCount, values);
}
-const auto BUFFER_READER = std::move(json::Reader<gltf2::Buffer>()
+const json::Reader<gltf2::Buffer>& GetBufferReader()
+{
+ static const auto BUFFER_READER = std::move(json::Reader<gltf2::Buffer>()
.Register(*json::MakeProperty("byteLength", json::Read::Number<uint32_t>, &gltf2::Buffer::mByteLength))
.Register(*json::MakeProperty("uri", json::Read::StringView, &gltf2::Buffer::mUri)));
+ return BUFFER_READER;
+}
-const auto BUFFER_VIEW_READER = std::move(json::Reader<gltf2::BufferView>()
+const json::Reader<gltf2::BufferView>& GetBufferViewReader()
+{
+ static const auto BUFFER_VIEW_READER = std::move(json::Reader<gltf2::BufferView>()
.Register(*json::MakeProperty("buffer", gltf2::RefReader<gltf2::Document>::Read<gltf2::Buffer, &gltf2::Document::mBuffers>, &gltf2::BufferView::mBuffer))
.Register(*json::MakeProperty("byteOffset", json::Read::Number<uint32_t>, &gltf2::BufferView::mByteOffset))
.Register(*json::MakeProperty("byteLength", json::Read::Number<uint32_t>, &gltf2::BufferView::mByteLength))
.Register(*json::MakeProperty("byteStride", json::Read::Number<uint32_t>, &gltf2::BufferView::mByteStride))
.Register(*json::MakeProperty("target", json::Read::Number<uint32_t>, &gltf2::BufferView::mTarget)));
+ return BUFFER_VIEW_READER;
+}
-const auto BUFFER_VIEW_CLIENT_READER = std::move(json::Reader<gltf2::BufferViewClient>()
+const json::Reader<gltf2::BufferViewClient>& GetBufferViewClientReader()
+{
+ static const auto BUFFER_VIEW_CLIENT_READER = std::move(json::Reader<gltf2::BufferViewClient>()
.Register(*json::MakeProperty("bufferView", gltf2::RefReader<gltf2::Document>::Read<gltf2::BufferView, &gltf2::Document::mBufferViews>, &gltf2::BufferViewClient::mBufferView))
.Register(*json::MakeProperty("byteOffset", json::Read::Number<uint32_t>, &gltf2::BufferViewClient::mByteOffset)));
+ return BUFFER_VIEW_CLIENT_READER;
+}
-const auto COMPONENT_TYPED_BUFFER_VIEW_CLIENT_READER = std::move(json::Reader<gltf2::ComponentTypedBufferViewClient>()
+const json::Reader<gltf2::ComponentTypedBufferViewClient>& GetComponentTypedBufferViewClientReader()
+{
+ static const auto COMPONENT_TYPED_BUFFER_VIEW_CLIENT_READER = std::move(json::Reader<gltf2::ComponentTypedBufferViewClient>()
.Register(*new json::Property<gltf2::ComponentTypedBufferViewClient, gltf2::Ref<gltf2::BufferView>>("bufferView", gltf2::RefReader<gltf2::Document>::Read<gltf2::BufferView, &gltf2::Document::mBufferViews>, &gltf2::ComponentTypedBufferViewClient::mBufferView))
.Register(*new json::Property<gltf2::ComponentTypedBufferViewClient, uint32_t>("byteOffset", json::Read::Number<uint32_t>, &gltf2::ComponentTypedBufferViewClient::mByteOffset))
.Register(*json::MakeProperty("componentType", json::Read::Enum<gltf2::Component::Type>, &gltf2::ComponentTypedBufferViewClient::mComponentType)));
+ return COMPONENT_TYPED_BUFFER_VIEW_CLIENT_READER;
+}
-const auto ACCESSOR_SPARSE_READER = std::move(json::Reader<gltf2::Accessor::Sparse>()
+const json::Reader<gltf2::Accessor::Sparse>& GetAccessorSparseReader()
+{
+ static const auto ACCESSOR_SPARSE_READER = std::move(json::Reader<gltf2::Accessor::Sparse>()
.Register(*json::MakeProperty("count", json::Read::Number<uint32_t>, &gltf2::Accessor::Sparse::mCount))
.Register(*json::MakeProperty("indices", json::ObjectReader<gltf2::ComponentTypedBufferViewClient>::Read, &gltf2::Accessor::Sparse::mIndices))
.Register(*json::MakeProperty("values", json::ObjectReader<gltf2::BufferViewClient>::Read, &gltf2::Accessor::Sparse::mValues)));
+ return ACCESSOR_SPARSE_READER;
+}
-const auto ACCESSOR_READER = std::move(json::Reader<gltf2::Accessor>()
+const json::Reader<gltf2::Accessor>& GetAccessorReader()
+{
+ static const auto ACCESSOR_READER = std::move(json::Reader<gltf2::Accessor>()
.Register(*new json::Property<gltf2::Accessor, gltf2::Ref<gltf2::BufferView>>("bufferView",
gltf2::RefReader<gltf2::Document>::Read<gltf2::BufferView, &gltf2::Document::mBufferViews>,
&gltf2::Accessor::mBufferView))
.Register(*json::MakeProperty("min", json::Read::Array<float, json::Read::Number>, &gltf2::Accessor::mMin))
.Register(*json::MakeProperty("max", json::Read::Array<float, json::Read::Number>, &gltf2::Accessor::mMax))
.Register(*new json::Property<gltf2::Accessor, gltf2::Accessor::Sparse>("sparse", json::ObjectReader<gltf2::Accessor::Sparse>::Read, &gltf2::Accessor::SetSparse)));
+ return ACCESSOR_READER;
+}
-const auto IMAGE_READER = std::move(json::Reader<gltf2::Image>()
+const json::Reader<gltf2::Image>& GetImageReader()
+{
+ static const auto IMAGE_READER = std::move(json::Reader<gltf2::Image>()
.Register(*new json::Property<gltf2::Image, std::string_view>("name", json::Read::StringView, &gltf2::Material::mName))
.Register(*json::MakeProperty("uri", json::Read::StringView, &gltf2::Image::mUri))
.Register(*json::MakeProperty("mimeType", json::Read::StringView, &gltf2::Image::mMimeType))
.Register(*json::MakeProperty("bufferView", gltf2::RefReader<gltf2::Document>::Read<gltf2::BufferView, &gltf2::Document::mBufferViews>, &gltf2::Image::mBufferView)));
+ return IMAGE_READER;
+}
-const auto SAMPLER_READER = std::move(json::Reader<gltf2::Sampler>()
+const json::Reader<gltf2::Sampler>& GetSamplerReader()
+{
+ static const auto SAMPLER_READER = std::move(json::Reader<gltf2::Sampler>()
.Register(*json::MakeProperty("minFilter", json::Read::Enum<gltf2::Filter::Type>, &gltf2::Sampler::mMinFilter))
.Register(*json::MakeProperty("magFilter", json::Read::Enum<gltf2::Filter::Type>, &gltf2::Sampler::mMagFilter))
.Register(*json::MakeProperty("wrapS", json::Read::Enum<gltf2::Wrap::Type>, &gltf2::Sampler::mWrapS))
.Register(*json::MakeProperty("wrapT", json::Read::Enum<gltf2::Wrap::Type>, &gltf2::Sampler::mWrapT)));
+ return SAMPLER_READER;
+}
-const auto TEXURE_READER = std::move(json::Reader<gltf2::Texture>()
+const json::Reader<gltf2::Texture>& GetTextureReader()
+{
+ static const auto TEXURE_READER = std::move(json::Reader<gltf2::Texture>()
.Register(*json::MakeProperty("source", gltf2::RefReader<gltf2::Document>::Read<gltf2::Image, &gltf2::Document::mImages>, &gltf2::Texture::mSource))
.Register(*json::MakeProperty("sampler", gltf2::RefReader<gltf2::Document>::Read<gltf2::Sampler, &gltf2::Document::mSamplers>, &gltf2::Texture::mSampler)));
+ return TEXURE_READER;
+}
-const auto TEXURE_INFO_READER = std::move(json::Reader<gltf2::TextureInfo>()
+const json::Reader<gltf2::TextureInfo>& GetTextureInfoReader()
+{
+ static const auto TEXURE_INFO_READER = std::move(json::Reader<gltf2::TextureInfo>()
.Register(*json::MakeProperty("index", gltf2::RefReader<gltf2::Document>::Read<gltf2::Texture, &gltf2::Document::mTextures>, &gltf2::TextureInfo::mTexture))
.Register(*json::MakeProperty("texCoord", json::Read::Number<uint32_t>, &gltf2::TextureInfo::mTexCoord))
.Register(*json::MakeProperty("scale", json::Read::Number<float>, &gltf2::TextureInfo::mScale))
.Register(*json::MakeProperty("strength", json::Read::Number<float>, &gltf2::TextureInfo::mStrength)));
+ return TEXURE_INFO_READER;
+}
-const auto MATERIAL_PBR_READER = std::move(json::Reader<gltf2::Material::Pbr>()
+const json::Reader<gltf2::Material::Pbr>& GetMaterialPbrReader()
+{
+ static const auto MATERIAL_PBR_READER = std::move(json::Reader<gltf2::Material::Pbr>()
.Register(*json::MakeProperty("baseColorFactor", gltf2::ReadDaliVector<Vector4>, &gltf2::Material::Pbr::mBaseColorFactor))
.Register(*json::MakeProperty("baseColorTexture", json::ObjectReader<gltf2::TextureInfo>::Read, &gltf2::Material::Pbr::mBaseColorTexture))
.Register(*json::MakeProperty("metallicFactor", json::Read::Number<float>, &gltf2::Material::Pbr::mMetallicFactor))
.Register(*json::MakeProperty("roughnessFactor", json::Read::Number<float>, &gltf2::Material::Pbr::mRoughnessFactor))
.Register(*json::MakeProperty("metallicRoughnessTexture", json::ObjectReader<gltf2::TextureInfo>::Read, &gltf2::Material::Pbr::mMetallicRoughnessTexture)));
+ return MATERIAL_PBR_READER;
+}
-const auto MATERIAL_SPECULAR_READER = std::move(json::Reader<gltf2::MaterialSpecular>()
+const json::Reader<gltf2::MaterialSpecular>& GetMaterialSpecularReader()
+{
+ static const auto MATERIAL_SPECULAR_READER = std::move(json::Reader<gltf2::MaterialSpecular>()
.Register(*json::MakeProperty("specularFactor", json::Read::Number<float>, &gltf2::MaterialSpecular::mSpecularFactor))
.Register(*json::MakeProperty("specularTexture", json::ObjectReader<gltf2::TextureInfo>::Read, &gltf2::MaterialSpecular::mSpecularTexture))
.Register(*json::MakeProperty("specularColorFactor", gltf2::ReadDaliVector<Vector3>, &gltf2::MaterialSpecular::mSpecularColorFactor))
.Register(*json::MakeProperty("specularColorTexture", json::ObjectReader<gltf2::TextureInfo>::Read, &gltf2::MaterialSpecular::mSpecularColorTexture)));
+ return MATERIAL_SPECULAR_READER;
+}
-const auto MATERIAL_IOR_READER = std::move(json::Reader<gltf2::MaterialIor>()
+const json::Reader<gltf2::MaterialIor>& GetMaterialIorReader()
+{
+ static const auto MATERIAL_IOR_READER = std::move(json::Reader<gltf2::MaterialIor>()
.Register(*json::MakeProperty("ior", json::Read::Number<float>, &gltf2::MaterialIor::mIor)));
+ return MATERIAL_IOR_READER;
+}
-const auto MATERIAL_EXTENSION_READER = std::move(json::Reader<gltf2::MaterialExtensions>()
+const json::Reader<gltf2::MaterialExtensions>& GetMaterialExtensionsReader()
+{
+ static const auto MATERIAL_EXTENSION_READER = std::move(json::Reader<gltf2::MaterialExtensions>()
.Register(*json::MakeProperty("KHR_materials_ior", json::ObjectReader<gltf2::MaterialIor>::Read, &gltf2::MaterialExtensions::mMaterialIor))
.Register(*json::MakeProperty("KHR_materials_specular", json::ObjectReader<gltf2::MaterialSpecular>::Read, &gltf2::MaterialExtensions::mMaterialSpecular)));
+ return MATERIAL_EXTENSION_READER;
+}
-const auto MATERIAL_READER = std::move(json::Reader<gltf2::Material>()
+const json::Reader<gltf2::Material>& GetMaterialReader()
+{
+ static const auto MATERIAL_READER = std::move(json::Reader<gltf2::Material>()
.Register(*new json::Property<gltf2::Material, std::string_view>("name", json::Read::StringView, &gltf2::Material::mName))
.Register(*json::MakeProperty("pbrMetallicRoughness", json::ObjectReader<gltf2::Material::Pbr>::Read, &gltf2::Material::mPbrMetallicRoughness))
.Register(*json::MakeProperty("normalTexture", json::ObjectReader<gltf2::TextureInfo>::Read, &gltf2::Material::mNormalTexture))
.Register(*json::MakeProperty("alphaCutoff", json::Read::Number<float>, &gltf2::Material::mAlphaCutoff))
.Register(*json::MakeProperty("doubleSided", json::Read::Boolean, &gltf2::Material::mDoubleSided))
.Register(*json::MakeProperty("extensions", json::ObjectReader<gltf2::MaterialExtensions>::Read, &gltf2::Material::mMaterialExtensions)));
+ return MATERIAL_READER;
+}
std::map<gltf2::Attribute::Type, gltf2::Ref<gltf2::Accessor>> ReadMeshPrimitiveAttributes(const json_value_s& j)
{
return result;
}
-const auto MESH_PRIMITIVE_READER = std::move(json::Reader<gltf2::Mesh::Primitive>()
+const json::Reader<gltf2::Mesh::Primitive>& GetMeshPrimitiveReader()
+{
+ static const auto MESH_PRIMITIVE_READER = std::move(json::Reader<gltf2::Mesh::Primitive>()
.Register(*json::MakeProperty("attributes", ReadMeshPrimitiveAttributes, &gltf2::Mesh::Primitive::mAttributes))
.Register(*json::MakeProperty("indices", gltf2::RefReader<gltf2::Document>::Read<gltf2::Accessor, &gltf2::Document::mAccessors>, &gltf2::Mesh::Primitive::mIndices))
.Register(*json::MakeProperty("material", gltf2::RefReader<gltf2::Document>::Read<gltf2::Material, &gltf2::Document::mMaterials>, &gltf2::Mesh::Primitive::mMaterial))
.Register(*json::MakeProperty("mode", json::Read::Enum<gltf2::Mesh::Primitive::Mode>, &gltf2::Mesh::Primitive::mMode))
.Register(*json::MakeProperty("targets", ReadMeshPrimitiveTargets, &gltf2::Mesh::Primitive::mTargets)));
+ return MESH_PRIMITIVE_READER;
+}
-const auto MESH_READER = std::move(json::Reader<gltf2::Mesh>()
+const json::Reader<gltf2::Mesh>& GetMeshReader()
+{
+ static const auto MESH_READER = std::move(json::Reader<gltf2::Mesh>()
.Register(*new json::Property<gltf2::Mesh, std::string_view>("name", json::Read::StringView, &gltf2::Mesh::mName))
.Register(*json::MakeProperty("primitives",
json::Read::Array<gltf2::Mesh::Primitive, json::ObjectReader<gltf2::Mesh::Primitive>::Read>,
&gltf2::Mesh::mPrimitives))
.Register(*json::MakeProperty("weights", json::Read::Array<float, json::Read::Number>, &gltf2::Mesh::mWeights)));
+ return MESH_READER;
+}
-const auto SKIN_READER = std::move(json::Reader<gltf2::Skin>()
+const json::Reader<gltf2::Skin>& GetSkinReader()
+{
+ static const auto SKIN_READER = std::move(json::Reader<gltf2::Skin>()
.Register(*new json::Property<gltf2::Skin, std::string_view>("name", json::Read::StringView, &gltf2::Skin::mName))
.Register(*json::MakeProperty("inverseBindMatrices",
gltf2::RefReader<gltf2::Document>::Read<gltf2::Accessor, &gltf2::Document::mAccessors>,
.Register(*json::MakeProperty("joints",
json::Read::Array<gltf2::Ref<gltf2::Node>, gltf2::RefReader<gltf2::Document>::Read<gltf2::Node, &gltf2::Document::mNodes>>,
&gltf2::Skin::mJoints)));
+ return SKIN_READER;
+}
-const auto CAMERA_PERSPECTIVE_READER = std::move(json::Reader<gltf2::Camera::Perspective>()
+const json::Reader<gltf2::Camera::Perspective>& GetCameraPerspectiveReader()
+{
+ static const auto CAMERA_PERSPECTIVE_READER = std::move(json::Reader<gltf2::Camera::Perspective>()
.Register(*json::MakeProperty("aspectRatio", json::Read::Number<float>, &gltf2::Camera::Perspective::mAspectRatio))
.Register(*json::MakeProperty("yfov", json::Read::Number<float>, &gltf2::Camera::Perspective::mYFov))
.Register(*json::MakeProperty("zfar", json::Read::Number<float>, &gltf2::Camera::Perspective::mZFar))
.Register(*json::MakeProperty("znear", json::Read::Number<float>, &gltf2::Camera::Perspective::mZNear))); // TODO: infinite perspective projection, where znear is omitted
+ return CAMERA_PERSPECTIVE_READER;
+}
-const auto CAMERA_ORTHOGRAPHIC_READER = std::move(json::Reader<gltf2::Camera::Orthographic>()
+const json::Reader<gltf2::Camera::Orthographic>& GetCameraOrthographicReader()
+{
+ static const auto CAMERA_ORTHOGRAPHIC_READER = std::move(json::Reader<gltf2::Camera::Orthographic>()
.Register(*json::MakeProperty("xmag", json::Read::Number<float>, &gltf2::Camera::Orthographic::mXMag))
.Register(*json::MakeProperty("ymag", json::Read::Number<float>, &gltf2::Camera::Orthographic::mYMag))
.Register(*json::MakeProperty("zfar", json::Read::Number<float>, &gltf2::Camera::Orthographic::mZFar))
.Register(*json::MakeProperty("znear", json::Read::Number<float>, &gltf2::Camera::Orthographic::mZNear)));
+ return CAMERA_ORTHOGRAPHIC_READER;
+}
-const auto CAMERA_READER = std::move(json::Reader<gltf2::Camera>()
+const json::Reader<gltf2::Camera>& GetCameraReader()
+{
+ static const auto CAMERA_READER = std::move(json::Reader<gltf2::Camera>()
.Register(*new json::Property<gltf2::Camera, std::string_view>("name", json::Read::StringView, &gltf2::Camera::mName))
.Register(*json::MakeProperty("type", json::Read::StringView, &gltf2::Camera::mType))
.Register(*json::MakeProperty("perspective", json::ObjectReader<gltf2::Camera::Perspective>::Read, &gltf2::Camera::mPerspective))
.Register(*json::MakeProperty("orthographic", json::ObjectReader<gltf2::Camera::Orthographic>::Read, &gltf2::Camera::mOrthographic)));
+ return CAMERA_READER;
+}
-const auto NODE_READER = std::move(json::Reader<gltf2::Node>()
+const json::Reader<gltf2::Node>& GetNodeReader()
+{
+ static const auto NODE_READER = std::move(json::Reader<gltf2::Node>()
.Register(*new json::Property<gltf2::Node, std::string_view>("name", json::Read::StringView, &gltf2::Node::mName))
.Register(*json::MakeProperty("translation", gltf2::ReadDaliVector<Vector3>, &gltf2::Node::mTranslation))
.Register(*json::MakeProperty("rotation", gltf2::ReadQuaternion, &gltf2::Node::mRotation))
.Register(*json::MakeProperty("children", json::Read::Array<gltf2::Ref<gltf2::Node>, gltf2::RefReader<gltf2::Document>::Read<gltf2::Node, &gltf2::Document::mNodes>>, &gltf2::Node::mChildren))
.Register(*json::MakeProperty("mesh", gltf2::RefReader<gltf2::Document>::Read<gltf2::Mesh, &gltf2::Document::mMeshes>, &gltf2::Node::mMesh))
.Register(*json::MakeProperty("skin", gltf2::RefReader<gltf2::Document>::Read<gltf2::Skin, &gltf2::Document::mSkins>, &gltf2::Node::mSkin)));
+ return NODE_READER;
+}
-const auto ANIMATION_SAMPLER_READER = std::move(json::Reader<gltf2::Animation::Sampler>()
+const json::Reader<gltf2::Animation::Sampler>& GetAnimationSamplerReader()
+{
+ static const auto ANIMATION_SAMPLER_READER = std::move(json::Reader<gltf2::Animation::Sampler>()
.Register(*json::MakeProperty("input", gltf2::RefReader<gltf2::Document>::Read<gltf2::Accessor, &gltf2::Document::mAccessors>, &gltf2::Animation::Sampler::mInput))
.Register(*json::MakeProperty("output", gltf2::RefReader<gltf2::Document>::Read<gltf2::Accessor, &gltf2::Document::mAccessors>, &gltf2::Animation::Sampler::mOutput))
.Register(*json::MakeProperty("interpolation", gltf2::ReadStringEnum<gltf2::Animation::Sampler::Interpolation>, &gltf2::Animation::Sampler::mInterpolation)));
+ return ANIMATION_SAMPLER_READER;
+}
-const auto ANIMATION_TARGET_READER = std::move(json::Reader<gltf2::Animation::Channel::Target>()
+const json::Reader<gltf2::Animation::Channel::Target>& GetAnimationChannelTargetReader()
+{
+ static const auto ANIMATION_TARGET_READER = std::move(json::Reader<gltf2::Animation::Channel::Target>()
.Register(*json::MakeProperty("node", gltf2::RefReader<gltf2::Document>::Read<gltf2::Node, &gltf2::Document::mNodes>, &gltf2::Animation::Channel::Target::mNode))
.Register(*json::MakeProperty("path", gltf2::ReadStringEnum<gltf2::Animation::Channel::Target>, &gltf2::Animation::Channel::Target::mPath)));
+ return ANIMATION_TARGET_READER;
+}
-const auto ANIMATION_CHANNEL_READER = std::move(json::Reader<gltf2::Animation::Channel>()
+const json::Reader<gltf2::Animation::Channel>& GetAnimationChannelReader()
+{
+ static const auto ANIMATION_CHANNEL_READER = std::move(json::Reader<gltf2::Animation::Channel>()
.Register(*json::MakeProperty("target", json::ObjectReader<gltf2::Animation::Channel::Target>::Read, &gltf2::Animation::Channel::mTarget))
.Register(*json::MakeProperty("sampler", gltf2::RefReader<gltf2::Animation>::Read<gltf2::Animation::Sampler, &gltf2::Animation::mSamplers>, &gltf2::Animation::Channel::mSampler)));
+ return ANIMATION_CHANNEL_READER;
+}
-const auto ANIMATION_READER = std::move(json::Reader<gltf2::Animation>()
+const json::Reader<gltf2::Animation>& GetAnimationReader()
+{
+ static const auto ANIMATION_READER = std::move(json::Reader<gltf2::Animation>()
.Register(*new json::Property<gltf2::Animation, std::string_view>("name", json::Read::StringView, &gltf2::Animation::mName))
.Register(*json::MakeProperty("samplers",
json::Read::Array<gltf2::Animation::Sampler, json::ObjectReader<gltf2::Animation::Sampler>::Read>,
.Register(*json::MakeProperty("channels",
json::Read::Array<gltf2::Animation::Channel, json::ObjectReader<gltf2::Animation::Channel>::Read>,
&gltf2::Animation::mChannels)));
+ return ANIMATION_READER;
+}
-const auto SCENE_READER = std::move(json::Reader<gltf2::Scene>()
+const json::Reader<gltf2::Scene>& GetSceneReader()
+{
+ static const auto SCENE_READER = std::move(json::Reader<gltf2::Scene>()
.Register(*new json::Property<gltf2::Scene, std::string_view>("name", json::Read::StringView, &gltf2::Scene::mName))
.Register(*json::MakeProperty("nodes",
json::Read::Array<gltf2::Ref<gltf2::Node>, gltf2::RefReader<gltf2::Document>::Read<gltf2::Node, &gltf2::Document::mNodes>>,
&gltf2::Scene::mNodes)));
+ return SCENE_READER;
+}
-const auto DOCUMENT_READER = std::move(json::Reader<gltf2::Document>()
+const json::Reader<gltf2::Document>& GetDocumentReader()
+{
+ static const auto DOCUMENT_READER = std::move(json::Reader<gltf2::Document>()
.Register(*json::MakeProperty("buffers",
json::Read::Array<gltf2::Buffer, json::ObjectReader<gltf2::Buffer>::Read>,
&gltf2::Document::mBuffers))
json::Read::Array<gltf2::Scene, json::ObjectReader<gltf2::Scene>::Read>,
&gltf2::Document::mScenes))
.Register(*json::MakeProperty("scene", gltf2::RefReader<gltf2::Document>::Read<gltf2::Scene, &gltf2::Document::mScenes>, &gltf2::Document::mScene)));
+ return DOCUMENT_READER;
+}
void ConvertBuffer(const gltf2::Buffer& buffer, decltype(ResourceBundle::mBuffers)& outBuffers, const std::string& resourcePath)
{
}
}
+void AddTextureStage(uint32_t semantic, MaterialDefinition& materialDefinition, gltf2::TextureInfo textureInfo, const Dali::Scene3D::Loader::ImageMetadata& metaData, ConversionContext& context)
+{
+ materialDefinition.mTextureStages.push_back({semantic, ConvertTextureInfo(textureInfo, context, metaData)});
+ materialDefinition.mFlags |= semantic;
+}
+
void ConvertMaterial(const gltf2::Material& material, const std::unordered_map<std::string, ImageMetadata>& imageMetaData, decltype(ResourceBundle::mMaterials)& outMaterials, ConversionContext& context)
{
- auto getTextureMetaData = [](const std::unordered_map<std::string, ImageMetadata>& metaData, const gltf2::TextureInfo& info)
- {
+ auto getTextureMetaData = [](const std::unordered_map<std::string, ImageMetadata>& metaData, const gltf2::TextureInfo& info) {
if(!info.mTexture->mSource->mUri.empty())
{
if(auto search = metaData.find(info.mTexture->mSource->mUri.data()); search != metaData.end())
materialDefinition.mTextureStages.reserve(!!pbr.mBaseColorTexture + !!pbr.mMetallicRoughnessTexture + !!material.mNormalTexture + !!material.mOcclusionTexture + !!material.mEmissiveTexture);
if(pbr.mBaseColorTexture)
{
- const auto semantic = MaterialDefinition::ALBEDO;
- materialDefinition.mTextureStages.push_back({semantic, ConvertTextureInfo(pbr.mBaseColorTexture, context, getTextureMetaData(imageMetaData, pbr.mBaseColorTexture))});
- // TODO: and there had better be one
- materialDefinition.mFlags |= semantic;
+ AddTextureStage(MaterialDefinition::ALBEDO, materialDefinition, pbr.mBaseColorTexture, getTextureMetaData(imageMetaData, pbr.mBaseColorTexture), context);
}
else
{
if(pbr.mMetallicRoughnessTexture)
{
- const auto semantic = MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS |
- MaterialDefinition::GLTF_CHANNELS;
- materialDefinition.mTextureStages.push_back({semantic, ConvertTextureInfo(pbr.mMetallicRoughnessTexture, context, getTextureMetaData(imageMetaData, pbr.mMetallicRoughnessTexture))});
- // TODO: and there had better be one
- materialDefinition.mFlags |= semantic;
+ AddTextureStage(MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS | MaterialDefinition::GLTF_CHANNELS,
+ materialDefinition,
+ pbr.mMetallicRoughnessTexture,
+ getTextureMetaData(imageMetaData, pbr.mMetallicRoughnessTexture),
+ context);
}
else
{
materialDefinition.mNormalScale = material.mNormalTexture.mScale;
if(material.mNormalTexture)
{
- const auto semantic = MaterialDefinition::NORMAL;
- materialDefinition.mTextureStages.push_back({semantic, ConvertTextureInfo(material.mNormalTexture, context, getTextureMetaData(imageMetaData, material.mNormalTexture))});
- // TODO: and there had better be one
- materialDefinition.mFlags |= semantic;
+ AddTextureStage(MaterialDefinition::NORMAL, materialDefinition, material.mNormalTexture, getTextureMetaData(imageMetaData, material.mNormalTexture), context);
}
else
{
if(material.mOcclusionTexture)
{
- const auto semantic = MaterialDefinition::OCCLUSION;
- materialDefinition.mTextureStages.push_back({semantic, ConvertTextureInfo(material.mOcclusionTexture, context, getTextureMetaData(imageMetaData, material.mOcclusionTexture))});
- // TODO: and there had better be one
- materialDefinition.mFlags |= semantic;
+ AddTextureStage(MaterialDefinition::OCCLUSION, materialDefinition, material.mOcclusionTexture, getTextureMetaData(imageMetaData, material.mOcclusionTexture), context);
materialDefinition.mOcclusionStrength = material.mOcclusionTexture.mStrength;
}
+ materialDefinition.mEmissiveFactor = material.mEmissiveFactor;
if(material.mEmissiveTexture)
{
- const auto semantic = MaterialDefinition::EMISSIVE;
- materialDefinition.mTextureStages.push_back({semantic, ConvertTextureInfo(material.mEmissiveTexture, context, getTextureMetaData(imageMetaData, material.mEmissiveTexture))});
- // TODO: and there had better be one
- materialDefinition.mFlags |= semantic;
- materialDefinition.mEmissiveFactor = material.mEmissiveFactor;
+ AddTextureStage(MaterialDefinition::EMISSIVE, materialDefinition, material.mEmissiveTexture, getTextureMetaData(imageMetaData, material.mEmissiveTexture), context);
}
if(!Dali::Equals(material.mMaterialExtensions.mMaterialIor.mIor, gltf2::UNDEFINED_FLOAT_VALUE))
if(material.mMaterialExtensions.mMaterialSpecular.mSpecularTexture)
{
- const auto semantic = MaterialDefinition::SPECULAR;
- materialDefinition.mTextureStages.push_back({semantic, ConvertTextureInfo(material.mMaterialExtensions.mMaterialSpecular.mSpecularTexture, context, getTextureMetaData(imageMetaData, material.mMaterialExtensions.mMaterialSpecular.mSpecularTexture))});
- materialDefinition.mFlags |= semantic;
+ AddTextureStage(MaterialDefinition::SPECULAR, materialDefinition, material.mMaterialExtensions.mMaterialSpecular.mSpecularTexture, getTextureMetaData(imageMetaData, material.mMaterialExtensions.mMaterialSpecular.mSpecularTexture), context);
}
if(material.mMaterialExtensions.mMaterialSpecular.mSpecularColorTexture)
{
- const auto semantic = MaterialDefinition::SPECULAR_COLOR;
- materialDefinition.mTextureStages.push_back({semantic, ConvertTextureInfo(material.mMaterialExtensions.mMaterialSpecular.mSpecularColorTexture, context, getTextureMetaData(imageMetaData, material.mMaterialExtensions.mMaterialSpecular.mSpecularColorTexture))});
- materialDefinition.mFlags |= semantic;
+ AddTextureStage(MaterialDefinition::SPECULAR_COLOR, materialDefinition, material.mMaterialExtensions.mMaterialSpecular.mSpecularColorTexture, getTextureMetaData(imageMetaData, material.mMaterialExtensions.mMaterialSpecular.mSpecularColorTexture), context);
}
materialDefinition.mDoubleSided = material.mDoubleSided;
auto& resources = output.mResources;
const auto index = scene.GetNodeCount();
- auto weakNode = scene.AddNode([&]()
- {
+ auto weakNode = scene.AddNode([&]() {
std::unique_ptr<NodeDefinition> nodeDefinition{new NodeDefinition()};
nodeDefinition->mParentIdx = parentIndex;
return duration;
}
+template<typename T>
+float LoadAnimation(AnimationDefinition& animationDefinition, Index nodeIndex, Index propertyIndex, const std::string& propertyName, const gltf2::Animation::Channel& channel, ConversionContext& context)
+{
+ AnimatedProperty& animatedProperty = animationDefinition.mProperties[propertyIndex];
+
+ animatedProperty.mNodeIndex = nodeIndex;
+ animatedProperty.mPropertyName = propertyName;
+
+ animatedProperty.mKeyFrames = KeyFrames::New();
+ float duration = LoadKeyFrames<T>(context, channel, animatedProperty.mKeyFrames, channel.mTarget.mPath);
+ animatedProperty.mTimePeriod = {0.f, duration};
+
+ return duration;
+}
+
void ConvertAnimations(const gltf2::Document& document, ConversionContext& context)
{
auto& output = context.mOutput;
for(const auto& animation : document.mAnimations)
{
- AnimationDefinition animationDef;
+ AnimationDefinition animationDefinition;
if(!animation.mName.empty())
{
- animationDef.mName = animation.mName;
+ animationDefinition.mName = animation.mName;
}
uint32_t numberOfProperties = 0u;
numberOfProperties++;
}
}
- animationDef.mProperties.resize(numberOfProperties);
+ animationDefinition.mProperties.resize(numberOfProperties);
Index propertyIndex = 0u;
for(const auto& channel : animation.mChannels)
{
case gltf2::Animation::Channel::Target::TRANSLATION:
{
- AnimatedProperty& animatedProperty = animationDef.mProperties[propertyIndex];
-
- animatedProperty.mNodeIndex = nodeIndex;
- animatedProperty.mPropertyName = POSITION_PROPERTY;
-
- animatedProperty.mKeyFrames = KeyFrames::New();
- duration = LoadKeyFrames<Vector3>(context, channel, animatedProperty.mKeyFrames, channel.mTarget.mPath);
-
- animatedProperty.mTimePeriod = {0.f, duration};
+ duration = LoadAnimation<Vector3>(animationDefinition, nodeIndex, propertyIndex, POSITION_PROPERTY.data(), channel, context);
break;
}
case gltf2::Animation::Channel::Target::ROTATION:
{
- AnimatedProperty& animatedProperty = animationDef.mProperties[propertyIndex];
-
- animatedProperty.mNodeIndex = nodeIndex;
- animatedProperty.mPropertyName = ORIENTATION_PROPERTY;
-
- animatedProperty.mKeyFrames = KeyFrames::New();
- duration = LoadKeyFrames<Quaternion>(context, channel, animatedProperty.mKeyFrames, channel.mTarget.mPath);
-
- animatedProperty.mTimePeriod = {0.f, duration};
+ duration = LoadAnimation<Quaternion>(animationDefinition, nodeIndex, propertyIndex, ORIENTATION_PROPERTY.data(), channel, context);
break;
}
case gltf2::Animation::Channel::Target::SCALE:
{
- AnimatedProperty& animatedProperty = animationDef.mProperties[propertyIndex];
-
- animatedProperty.mNodeIndex = nodeIndex;
- animatedProperty.mPropertyName = SCALE_PROPERTY;
-
- animatedProperty.mKeyFrames = KeyFrames::New();
- duration = LoadKeyFrames<Vector3>(context, channel, animatedProperty.mKeyFrames, channel.mTarget.mPath);
-
- animatedProperty.mTimePeriod = {0.f, duration};
+ duration = LoadAnimation<Vector3>(animationDefinition, nodeIndex, propertyIndex, SCALE_PROPERTY.data(), channel, context);
break;
}
case gltf2::Animation::Channel::Target::WEIGHTS:
{
- duration = LoadBlendShapeKeyFrames(context, channel, nodeIndex, propertyIndex, animationDef.mProperties);
+ duration = LoadBlendShapeKeyFrames(context, channel, nodeIndex, propertyIndex, animationDefinition.mProperties);
break;
}
}
}
- animationDef.mDuration = std::max(duration, animationDef.mDuration);
+ animationDefinition.mDuration = std::max(duration, animationDefinition.mDuration);
++propertyIndex;
}
- output.mAnimationDefinitions.push_back(std::move(animationDef));
+ output.mAnimationDefinitions.push_back(std::move(animationDefinition));
}
}
void SetObjectReaders()
{
- json::SetObjectReader(BUFFER_READER);
- json::SetObjectReader(BUFFER_VIEW_READER);
- json::SetObjectReader(BUFFER_VIEW_CLIENT_READER);
- json::SetObjectReader(COMPONENT_TYPED_BUFFER_VIEW_CLIENT_READER);
- json::SetObjectReader(ACCESSOR_SPARSE_READER);
- json::SetObjectReader(ACCESSOR_READER);
- json::SetObjectReader(IMAGE_READER);
- json::SetObjectReader(SAMPLER_READER);
- json::SetObjectReader(TEXURE_READER);
- json::SetObjectReader(TEXURE_INFO_READER);
- json::SetObjectReader(MATERIAL_PBR_READER);
- json::SetObjectReader(MATERIAL_SPECULAR_READER);
- json::SetObjectReader(MATERIAL_IOR_READER);
- json::SetObjectReader(MATERIAL_EXTENSION_READER);
- json::SetObjectReader(MATERIAL_READER);
- json::SetObjectReader(MESH_PRIMITIVE_READER);
- json::SetObjectReader(MESH_READER);
- json::SetObjectReader(SKIN_READER);
- json::SetObjectReader(CAMERA_PERSPECTIVE_READER);
- json::SetObjectReader(CAMERA_ORTHOGRAPHIC_READER);
- json::SetObjectReader(CAMERA_READER);
- json::SetObjectReader(NODE_READER);
- json::SetObjectReader(ANIMATION_SAMPLER_READER);
- json::SetObjectReader(ANIMATION_TARGET_READER);
- json::SetObjectReader(ANIMATION_CHANNEL_READER);
- json::SetObjectReader(ANIMATION_READER);
- json::SetObjectReader(SCENE_READER);
+ json::SetObjectReader(GetBufferReader());
+ json::SetObjectReader(GetBufferViewReader());
+ json::SetObjectReader(GetBufferViewClientReader());
+ json::SetObjectReader(GetComponentTypedBufferViewClientReader());
+ json::SetObjectReader(GetAccessorSparseReader());
+ json::SetObjectReader(GetAccessorReader());
+ json::SetObjectReader(GetImageReader());
+ json::SetObjectReader(GetSamplerReader());
+ json::SetObjectReader(GetTextureReader());
+ json::SetObjectReader(GetTextureInfoReader());
+ json::SetObjectReader(GetMaterialPbrReader());
+ json::SetObjectReader(GetMaterialSpecularReader());
+ json::SetObjectReader(GetMaterialIorReader());
+ json::SetObjectReader(GetMaterialExtensionsReader());
+ json::SetObjectReader(GetMaterialReader());
+ json::SetObjectReader(GetMeshPrimitiveReader());
+ json::SetObjectReader(GetMeshReader());
+ json::SetObjectReader(GetSkinReader());
+ json::SetObjectReader(GetCameraPerspectiveReader());
+ json::SetObjectReader(GetCameraOrthographicReader());
+ json::SetObjectReader(GetCameraReader());
+ json::SetObjectReader(GetNodeReader());
+ json::SetObjectReader(GetAnimationSamplerReader());
+ json::SetObjectReader(GetAnimationChannelTargetReader());
+ json::SetObjectReader(GetAnimationChannelReader());
+ json::SetObjectReader(GetAnimationReader());
+ json::SetObjectReader(GetSceneReader());
}
void SetDefaultEnvironmentMap(const gltf2::Document& document, ConversionContext& context)
void ReadDocument(const json_object_s& jsonObject, gltf2::Document& document)
{
- DOCUMENT_READER.Read(jsonObject, document);
+ GetDocumentReader().Read(jsonObject, document);
}
void ReadDocumentFromParsedData(const json_object_s& jsonObject, gltf2::Document& document)
return true;
}
-const std::map<std::string, Property::Value (*)(const TreeNode*)> kTypeIds{
- // NONE
- {"boolean", [](const TreeNode* tn) {
- return ReadPrimitiveHelper<bool>(tn, ReadBool);
- }},
- {"float", [](const TreeNode* tn) {
- return ReadPrimitiveHelper<float>(tn, ReadFloat);
- }},
- {"integer", [](const TreeNode* tn) {
- return ReadPrimitiveHelper<int>(tn, ReadInt);
- }},
- {"vector2", ReadVectorHelper<Vector2>},
- {"vector3", ReadVectorHelper<Vector3>},
- {"vector4", ReadVectorHelper<Vector4>},
- {"matrix3", ReadVectorHelper<Matrix3>},
- {"matrix", ReadVectorHelper<Matrix>},
- {"rectangle", [](const TreeNode* tn) {
- Rect<int> value;
- if(ReadQuadHelper<int>(tn, {&value.x, &value.y, &value.width, &value.height}))
- {
- return Property::Value(value);
- }
- return Property::Value();
- }},
- {"rotation", ReadRotationHelper},
- // STRING - not particularly animatable
- // ARRAY - not particularly animatable
- // MAP - not particularly animatable
- {"extents", [](const TreeNode* tn) {
- Extents value;
- if(ReadQuadHelper<uint16_t>(tn, {&value.start, &value.end, &value.top, &value.bottom}))
- {
- return Property::Value(value);
- }
- return Property::Value();
- }},
-};
+const std::map<std::string_view, Property::Value (*)(const TreeNode*)>& GetTypeIds()
+{
+ static const std::map<std::string_view, Property::Value (*)(const TreeNode*)> kTypeIds{
+ // NONE
+ {"boolean", [](const TreeNode* tn) {
+ return ReadPrimitiveHelper<bool>(tn, ReadBool);
+ }},
+ {"float", [](const TreeNode* tn) {
+ return ReadPrimitiveHelper<float>(tn, ReadFloat);
+ }},
+ {"integer", [](const TreeNode* tn) {
+ return ReadPrimitiveHelper<int>(tn, ReadInt);
+ }},
+ {"vector2", ReadVectorHelper<Vector2>},
+ {"vector3", ReadVectorHelper<Vector3>},
+ {"vector4", ReadVectorHelper<Vector4>},
+ {"matrix3", ReadVectorHelper<Matrix3>},
+ {"matrix", ReadVectorHelper<Matrix>},
+ {"rectangle", [](const TreeNode* tn) {
+ Rect<int> value;
+ if(ReadQuadHelper<int>(tn, {&value.x, &value.y, &value.width, &value.height}))
+ {
+ return Property::Value(value);
+ }
+ return Property::Value();
+ }},
+ {"rotation", ReadRotationHelper},
+ // STRING - not particularly animatable
+ // ARRAY - not particularly animatable
+ // MAP - not particularly animatable
+ {"extents", [](const TreeNode* tn) {
+ Extents value;
+ if(ReadQuadHelper<uint16_t>(tn, {&value.start, &value.end, &value.top, &value.bottom}))
+ {
+ return Property::Value(value);
+ }
+ return Property::Value();
+ }},
+ };
+ return kTypeIds;
+}
Property::Value (*const kArrayPropertyProcessors[])(const TreeNode*){
ReadVectorHelper<Matrix>,
auto jsonType = tn.GetChild("type");
if(jsonType && jsonType->GetType() == TreeNode::STRING)
{
- auto iFind = kTypeIds.find(jsonType->GetString());
- if(iFind != kTypeIds.end())
+ auto iFind = GetTypeIds().find(jsonType->GetString());
+ if(iFind != GetTypeIds().end())
{
propValue = iFind->second(tn.GetChild("value"));
}
GetImpl(*this).SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
}
-void Model::SetImageBasedLightTexture(Texture diffuseTexture, Texture specularTexture, float scaleFactor)
-{
- GetImpl(*this).SetImageBasedLightTexture(diffuseTexture, specularTexture, scaleFactor);
-}
-
void Model::SetImageBasedLightScaleFactor(float scaleFactor)
{
GetImpl(*this).SetImageBasedLightScaleFactor(scaleFactor);
void SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor = 1.0f);
/**
- * @brief Sets Image Based Light Texture.
- *
- * @SINCE_2_1.41
- * @param[in] diffuseTexture cube map texture that can be used as a diffuse IBL source.
- * @param[in] specularTexture cube map texture that can be used as a specular IBL source.
- * @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f]. Default value is 1.0f.
- *
- * @note Both of diffuse texture and specular texture should be available. If not, nothing applied.
- */
- void SetImageBasedLightTexture(Texture diffuseTexture, Texture specularTexture, float scaleFactor = 1.0f);
-
- /**
* @brief Sets Scale Factor of Image Based Light Source.
*
* @SINCE_2_1.41
- * @note If SetImageBasedLightSource() or SetImageBasedLightTexture() method is called after this method, scaleFactor is overrided.
+ * @note If SetImageBasedLightSource() method is called after this method, scaleFactor is overrided.
*
* @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f].
*/
* @brief Sets Scale Factor of Image Based Light Source.
*
* @SINCE_2_1.41
- * @note If SetImageBasedLightSource() or SetImageBasedLightTexture() method is called after this method, scaleFactor is overriden.
+ * @note If SetImageBasedLightSource() method is called after this method, scaleFactor is overriden.
* @note Default value is 1.0f.
*
* @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f].
#define DALI_ALPHA_FUNCTION_ENTRY(x) { #x, AlphaFunction::x }
// clang-format on
-std::unordered_map<std::string, AlphaFunction> sFunctions{
- DALI_ALPHA_FUNCTION_ENTRY(DEFAULT),
- DALI_ALPHA_FUNCTION_ENTRY(LINEAR),
- DALI_ALPHA_FUNCTION_ENTRY(REVERSE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SQUARE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SQUARE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SINE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SINE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT_SINE),
- DALI_ALPHA_FUNCTION_ENTRY(BOUNCE),
- DALI_ALPHA_FUNCTION_ENTRY(SIN),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_BACK),
-};
+std::unordered_map<std::string, AlphaFunction>& GetFunctions()
+{
+ static std::unordered_map<std::string, AlphaFunction> sFunctions{
+ DALI_ALPHA_FUNCTION_ENTRY(DEFAULT),
+ DALI_ALPHA_FUNCTION_ENTRY(LINEAR),
+ DALI_ALPHA_FUNCTION_ENTRY(REVERSE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SQUARE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SQUARE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SINE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SINE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT_SINE),
+ DALI_ALPHA_FUNCTION_ENTRY(BOUNCE),
+ DALI_ALPHA_FUNCTION_ENTRY(SIN),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_BACK),
+ };
+ return sFunctions;
+}
#undef DALI_ALPHA_FUNCTION_ENTRY
AlphaFunction GetAlphaFunction(const std::string& name, bool* found)
{
- auto iFind = sFunctions.find(name);
- bool success = iFind != sFunctions.end();
+ auto iFind = GetFunctions().find(name);
+ bool success = iFind != GetFunctions().end();
if(found)
{
*found = success;
void RegisterAlphaFunction(const std::string& name, AlphaFunction alphaFn)
{
- DALI_ASSERT_ALWAYS(sFunctions.insert({name, alphaFn}).second &&
+ DALI_ASSERT_ALWAYS(GetFunctions().insert({name, alphaFn}).second &&
"Function with given key already exists.");
}
// This texture should have 6 faces and 6 mipmaps
if(!raw.mSpecular.mPixelData.empty())
{
- textures.mSpecular = raw.mSpecular.GetTexture();
+ textures.mSpecular = raw.mSpecular.GetTexture();
+ textures.mSpecularMipmapLevels = raw.mSpecular.GetMipmapLevels();
}
if(raw.mBrdf)
{
struct Textures
{
- Texture mDiffuse; // irradiance
- Texture mSpecular; // radiance
- Texture mBrdf; // pre-computed brdf
+ Texture mDiffuse; // irradiance
+ Texture mSpecular; // radiance
+ Texture mBrdf; // pre-computed brdf
+ uint32_t mSpecularMipmapLevels{1u};
bool IsLoaded() const
{
return mEnvironmentMapType;
}
+ void SetMipmapLevels(uint32_t mipmapLevels)
+ {
+ mMipmapLevels = mipmapLevels;
+ }
+
+ uint32_t GetMipmapLevels()
+ {
+ return mMipmapLevels;
+ }
+
public:
std::vector<std::vector<PixelData> > mPixelData;
Dali::Texture mEnvironmentMapTexture;
Dali::Shader mEnvironmentMapShader;
Dali::Scene3D::EnvironmentMapType mEnvironmentMapType{Dali::Scene3D::EnvironmentMapType::AUTO};
+ uint32_t mMipmapLevels{1u};
};
} // namespace Dali::Scene3D::Loader
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <string.h>
+#include <cmath>
#include <filesystem>
// INTERNAL INCLUDES
{
environmentMapData.mPixelData[i][0] = GetCubeFace(pixelBuffer, i, cubeType, faceWidth, faceHeight);
}
+ uint32_t mipmap = static_cast<uint32_t>(1 + std::floor(std::log2(std::max(environmentMapData.mPixelData[0][0].GetWidth(), environmentMapData.mPixelData[0][0].GetHeight()))));
+ environmentMapData.SetMipmapLevels(mipmap);
environmentMapData.SetEnvironmentMapType(Scene3D::EnvironmentMapType::CUBEMAP);
}
else
std::string extension = modelPath.extension();
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
- return (extension == KTX_EXTENSION) ? Dali::Scene3D::Loader::LoadKtxData(environmentMapUrl, environmentMapData) : LoadEnvironmentMapData(environmentMapUrl, environmentMapData);
+ bool successed = (extension == KTX_EXTENSION) ? Dali::Scene3D::Loader::LoadKtxData(environmentMapUrl, environmentMapData) : LoadEnvironmentMapData(environmentMapUrl, environmentMapData);
+
+ return successed;
}
} // namespace Loader
header.numberOfArrayElements = std::max(header.numberOfArrayElements, 1u);
header.pixelDepth = std::max(header.pixelDepth, 1u);
header.pixelHeight = std::max(header.pixelHeight, 1u);
+ environmentMapData.SetMipmapLevels(header.numberOfMipmapLevels);
environmentMapData.mPixelData.resize(header.numberOfFaces);
for(uint32_t face = 0u; face < header.numberOfFaces; ++face)
WrapMode::CLAMP_TO_EDGE,
WrapMode::MIRRORED_REPEAT};
-const SamplerFlags::Type SINGLE_VALUE_SAMPLER = SamplerFlags::Encode(FilterMode::NEAREST, FilterMode::NEAREST, WrapMode::CLAMP_TO_EDGE, WrapMode::CLAMP_TO_EDGE);
+const SamplerFlags::Type GetSingleValueSampler()
+{
+ static const SamplerFlags::Type SINGLE_VALUE_SAMPLER = SamplerFlags::Encode(FilterMode::NEAREST, FilterMode::NEAREST, WrapMode::CLAMP_TO_EDGE, WrapMode::CLAMP_TO_EDGE);
+ return SINGLE_VALUE_SAMPLER;
+}
static constexpr std::string_view EMBEDDED_DATA_PREFIX = "data:";
static constexpr std::string_view EMBEDDED_DATA_IMAGE_MEDIA_TYPE = "image/";
{
const auto bufferSize = 4;
uint8_t* buffer = new uint8_t[bufferSize]{0x7f, 0x7f, 0xff, 0xff}; // normal of (0, 0, 1), roughness of 1
- raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
+ raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY), GetSingleValueSampler()});
}
}
else
buffer[0] = static_cast<uint8_t>(mColor.r * 255.f);
buffer[1] = static_cast<uint8_t>(mColor.g * 255.f);
buffer[2] = static_cast<uint8_t>(mColor.b * 255.f);
- raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, format, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
+ raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, format, PixelData::DELETE_ARRAY), GetSingleValueSampler()});
}
// If we have transparency, or an image based albedo map, we will have to continue with separate metallicRoughness + normal.
// glTF2 uses B & G, so we might as well just set all components to 1.0.
const auto bufferSize = 4;
uint8_t* buffer = new uint8_t[bufferSize]{0xff, 0xff, 0xff, 0xff};
- raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
+ raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY), GetSingleValueSampler()});
}
if(checkStage(NORMAL))
{
const auto bufferSize = 3;
uint8_t* buffer = new uint8_t[bufferSize]{0x7f, 0x7f, 0xff}; // normal of (0, 0, 1)
- raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGB888, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
+ raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGB888, PixelData::DELETE_ARRAY), GetSingleValueSampler()});
}
else // single-value normal-roughness
{
const auto bufferSize = 4;
uint8_t* buffer = new uint8_t[bufferSize]{0x7f, 0x7f, 0xff, 0xff}; // normal of (0, 0, 1), roughness of 1.0
- raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
+ raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY), GetSingleValueSampler()});
}
}
}
{
constexpr std::string_view IBL_INTENSITY_STRING("uIblIntensity");
constexpr std::string_view IBL_Y_DIRECTION("uYDirection");
+constexpr std::string_view IBL_MAXLOD("uMaxLOD");
} // namespace
namespace Scene3D
return IBL_Y_DIRECTION;
}
+std::string_view NodeDefinition::GetIblMaxLodUniformName()
+{
+ return IBL_MAXLOD;
+}
+
bool NodeDefinition::GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const
{
if(mRenderables.empty())
actor.RegisterProperty("uSpecularFactor", matDef.mSpecularFactor);
actor.RegisterProperty("uSpecularColorFactor", matDef.mSpecularColorFactor);
actor.RegisterProperty("uNormalScale", matDef.mNormalScale);
+ actor.RegisterProperty("uEmissiveFactor", matDef.mEmissiveFactor);
if(matDef.mFlags & MaterialDefinition::OCCLUSION)
{
renderer.RegisterProperty("uOcclusionStrength", matDef.mOcclusionStrength);
}
- if(matDef.mFlags & MaterialDefinition::EMISSIVE)
- {
- renderer.RegisterProperty("uEmissiveFactor", matDef.mEmissiveFactor);
- }
Index envIdx = matDef.mEnvironmentIdx;
renderer.RegisterProperty(IBL_INTENSITY_STRING.data(), resources.mEnvironmentMaps[envIdx].first.mIblIntensity);
renderer.SetTextures(textures);
+ uint32_t specularMipmap = resources.mEnvironmentMaps[envIdx].second.mSpecularMipmapLevels;
actor.SetProperty(Actor::Property::COLOR, mColor);
+ actor.RegisterProperty(IBL_MAXLOD.data(), static_cast<float>(specularMipmap));
}
void ArcRenderable::OnCreate(const NodeDefinition& node, NodeDefinition::CreateParams& params, Actor& actor) const
*/
static std::string_view GetIblYDirectionUniformName();
+ /**
+ * @brief Retrieves ibl MaxLod uniform name.
+ * This uniform name can be used to set max lod of ibl in shader.
+ * @return std::string_view of the Max Lod uniform name.
+ */
+ static std::string_view GetIblMaxLodUniformName();
+
public: // DATA
static const char* ORIGINAL_MATRIX_PROPERTY_NAME;
{
namespace
{
-std::map<std::string_view, Type> COMPARISONS{
-#define DECL_COMPARISON(x) {#x, Comparison::x}
- DECL_COMPARISON(NEVER),
- DECL_COMPARISON(ALWAYS),
- DECL_COMPARISON(LESS),
- DECL_COMPARISON(GREATER),
- DECL_COMPARISON(EQUAL),
- DECL_COMPARISON(NOT_EQUAL),
- DECL_COMPARISON(LESS_EQUAL),
- DECL_COMPARISON(GREATER_EQUAL),
-#undef DECL_COMPARISON
-};
+const std::map<std::string_view, Type>& GetComparisons()
+{
+ static const std::map<std::string_view, Type> COMPARISONS{
+ #define DECL_COMPARISON(x) {#x, Comparison::x}
+ DECL_COMPARISON(NEVER),
+ DECL_COMPARISON(ALWAYS),
+ DECL_COMPARISON(LESS),
+ DECL_COMPARISON(GREATER),
+ DECL_COMPARISON(EQUAL),
+ DECL_COMPARISON(NOT_EQUAL),
+ DECL_COMPARISON(LESS_EQUAL),
+ DECL_COMPARISON(GREATER_EQUAL),
+ #undef DECL_COMPARISON
+ };
+ return COMPARISONS;
+}
Type InterpretComparison(const std::string_view& str)
{
Type value = 0x0;
- auto iFind = COMPARISONS.find(str);
- if(iFind != COMPARISONS.end())
+ auto iFind = GetComparisons().find(str);
+ if(iFind != GetComparisons().end())
{
value = iFind->second;
}
return value;
}
-std::map<std::string_view, Type> BLEND_FACTORS{
-#define DECL_BLEND_FACTOR(x) {#x, Dali::Scene3D::Loader::BlendFactor::x}
- DECL_BLEND_FACTOR(ZERO),
- DECL_BLEND_FACTOR(ONE),
- DECL_BLEND_FACTOR(SRC_COLOR),
- DECL_BLEND_FACTOR(ONE_MINUS_SRC_COLOR),
- DECL_BLEND_FACTOR(SRC_ALPHA),
- DECL_BLEND_FACTOR(ONE_MINUS_SRC_ALPHA),
- DECL_BLEND_FACTOR(DST_ALPHA),
- DECL_BLEND_FACTOR(ONE_MINUS_DST_ALPHA),
- DECL_BLEND_FACTOR(DST_COLOR),
- DECL_BLEND_FACTOR(ONE_MINUS_DST_COLOR),
- DECL_BLEND_FACTOR(SRC_ALPHA_SATURATE),
- DECL_BLEND_FACTOR(CONSTANT_COLOR),
- DECL_BLEND_FACTOR(ONE_MINUS_CONSTANT_COLOR),
- DECL_BLEND_FACTOR(CONSTANT_ALPHA),
- DECL_BLEND_FACTOR(ONE_MINUS_CONSTANT_ALPHA),
-#undef DECL_BLEND_FACTOR
-};
+const std::map<std::string_view, Type>& GetBlendFactors()
+{
+ static const std::map<std::string_view, Type> BLEND_FACTORS{
+ #define DECL_BLEND_FACTOR(x) {#x, Dali::Scene3D::Loader::BlendFactor::x}
+ DECL_BLEND_FACTOR(ZERO),
+ DECL_BLEND_FACTOR(ONE),
+ DECL_BLEND_FACTOR(SRC_COLOR),
+ DECL_BLEND_FACTOR(ONE_MINUS_SRC_COLOR),
+ DECL_BLEND_FACTOR(SRC_ALPHA),
+ DECL_BLEND_FACTOR(ONE_MINUS_SRC_ALPHA),
+ DECL_BLEND_FACTOR(DST_ALPHA),
+ DECL_BLEND_FACTOR(ONE_MINUS_DST_ALPHA),
+ DECL_BLEND_FACTOR(DST_COLOR),
+ DECL_BLEND_FACTOR(ONE_MINUS_DST_COLOR),
+ DECL_BLEND_FACTOR(SRC_ALPHA_SATURATE),
+ DECL_BLEND_FACTOR(CONSTANT_COLOR),
+ DECL_BLEND_FACTOR(ONE_MINUS_CONSTANT_COLOR),
+ DECL_BLEND_FACTOR(CONSTANT_ALPHA),
+ DECL_BLEND_FACTOR(ONE_MINUS_CONSTANT_ALPHA),
+ #undef DECL_BLEND_FACTOR
+ };
+ return BLEND_FACTORS;
+}
Type InterpretBlendFactor(const std::string_view& str, uint8_t item)
{
Type value = 0x0;
- auto iFind = BLEND_FACTORS.find(str);
- if(iFind != BLEND_FACTORS.end())
+ auto iFind = GetBlendFactors().find(str);
+ if(iFind != GetBlendFactors().end())
{
value = iFind->second << (BLEND_FACTOR_BASE_SHIFT + BLEND_FACTOR_ITEM_BITS * item);
}
return value;
}
-std::map<std::string_view, Type> BUFFER_MODES{
-#define DECL_BUFFER_MODE(x) {#x, BufferMode::x}
- DECL_BUFFER_MODE(NONE),
- DECL_BUFFER_MODE(AUTO),
- DECL_BUFFER_MODE(COLOR),
- DECL_BUFFER_MODE(STENCIL),
- DECL_BUFFER_MODE(COLOR_STENCIL),
-};
+const std::map<std::string_view, Type>& GetBufferModes()
+{
+ static const std::map<std::string_view, Type> BUFFER_MODES{
+ #define DECL_BUFFER_MODE(x) {#x, BufferMode::x}
+ DECL_BUFFER_MODE(NONE),
+ DECL_BUFFER_MODE(AUTO),
+ DECL_BUFFER_MODE(COLOR),
+ DECL_BUFFER_MODE(STENCIL),
+ DECL_BUFFER_MODE(COLOR_STENCIL),
+ #undef DECL_BUFFER_MODE
+ };
+ return BUFFER_MODES;
+}
Type InterpretBufferMode(const std::string_view& str)
{
Type value = 0x0;
- auto iFind = BUFFER_MODES.find(str);
- if(iFind != BUFFER_MODES.end())
+ auto iFind = GetBufferModes().find(str);
+ if(iFind != GetBufferModes().end())
{
value = iFind->second << BUFFER_MODE_SHIFT;
}
return value;
}
-std::map<std::string_view, Type (*)(const std::string_view&)> RENDERER_STATE_PROCESSORS{
- {"DEPTH_WRITE", [](const std::string_view&) -> Type { return DEPTH_WRITE; }},
- {"DEPTH_TEST", [](const std::string_view&) -> Type { return DEPTH_TEST; }},
- {"CULL_FRONT", [](const std::string_view&) -> Type { return CULL_FRONT; }},
- {"CULL_BACK", [](const std::string_view&) -> Type { return CULL_BACK; }},
- {"ALPHA_BLEND", [](const std::string_view&) -> Type { return ALPHA_BLEND; }},
- {"DEPTH_FUNC", [](const std::string_view& arg) -> Type {
- Type value = (arg[0] == ':') ? (InterpretComparison(std::string_view(arg.data() + 1, arg.size() - 1)) << DEPTH_FUNCTION_SHIFT) : 0x0;
- return value;
- }},
- {"BLEND_SRC_RGB", [](const std::string_view& arg) -> Type {
- Type value = (arg[0] == ':') ? InterpretBlendFactor(std::string_view(arg.data() + 1, arg.size() - 1), 0) : 0x0;
- return value;
- }},
- {"BLEND_DST_RGB", [](const std::string_view& arg) -> Type {
- Type value = (arg[0] == ':') ? InterpretBlendFactor(std::string_view(arg.data() + 1, arg.size() - 1), 1) : 0x0;
- return value;
- }},
- {"BLEND_SRC_ALPHA", [](const std::string_view& arg) -> Type {
- Type value = (arg[0] == ':') ? InterpretBlendFactor(std::string_view(arg.data() + 1, arg.size() - 1), 2) : 0x0;
- return value;
- }},
- {"BLEND_DST_ALPHA", [](const std::string_view& arg) -> Type {
- Type value = (arg[0] == ':') ? InterpretBlendFactor(std::string_view(arg.data() + 1, arg.size() - 1), 3) : 0x0;
- return value;
- }},
- {"BUFFER_MODE", [](const std::string_view& arg) -> Type {
- Type value = (arg[0] == ':') ? InterpretBufferMode(std::string_view(arg.data() + 1, arg.size() - 1)) : 0x0;
- return value;
- }},
-};
+const std::map<std::string_view, Type (*)(const std::string_view&)>& GetRendererStateProcessors()
+{
+ static const std::map<std::string_view, Type (*)(const std::string_view&)> RENDERER_STATE_PROCESSORS{
+ {"DEPTH_WRITE", [](const std::string_view&) -> Type { return DEPTH_WRITE; }},
+ {"DEPTH_TEST", [](const std::string_view&) -> Type { return DEPTH_TEST; }},
+ {"CULL_FRONT", [](const std::string_view&) -> Type { return CULL_FRONT; }},
+ {"CULL_BACK", [](const std::string_view&) -> Type { return CULL_BACK; }},
+ {"ALPHA_BLEND", [](const std::string_view&) -> Type { return ALPHA_BLEND; }},
+ {"DEPTH_FUNC", [](const std::string_view& arg) -> Type {
+ Type value = (arg[0] == ':') ? (InterpretComparison(std::string_view(arg.data() + 1, arg.size() - 1)) << DEPTH_FUNCTION_SHIFT) : 0x0;
+ return value;
+ }},
+ {"BLEND_SRC_RGB", [](const std::string_view& arg) -> Type {
+ Type value = (arg[0] == ':') ? InterpretBlendFactor(std::string_view(arg.data() + 1, arg.size() - 1), 0) : 0x0;
+ return value;
+ }},
+ {"BLEND_DST_RGB", [](const std::string_view& arg) -> Type {
+ Type value = (arg[0] == ':') ? InterpretBlendFactor(std::string_view(arg.data() + 1, arg.size() - 1), 1) : 0x0;
+ return value;
+ }},
+ {"BLEND_SRC_ALPHA", [](const std::string_view& arg) -> Type {
+ Type value = (arg[0] == ':') ? InterpretBlendFactor(std::string_view(arg.data() + 1, arg.size() - 1), 2) : 0x0;
+ return value;
+ }},
+ {"BLEND_DST_ALPHA", [](const std::string_view& arg) -> Type {
+ Type value = (arg[0] == ':') ? InterpretBlendFactor(std::string_view(arg.data() + 1, arg.size() - 1), 3) : 0x0;
+ return value;
+ }},
+ {"BUFFER_MODE", [](const std::string_view& arg) -> Type {
+ Type value = (arg[0] == ':') ? InterpretBufferMode(std::string_view(arg.data() + 1, arg.size() - 1)) : 0x0;
+ return value;
+ }},
+ };
+ return RENDERER_STATE_PROCESSORS;
+}
} // namespace
{
auto iNextToken = std::find(string, iEnd, '|');
auto iColon = std::find(string, iNextToken, ':');
- auto i = RENDERER_STATE_PROCESSORS.find(std::string_view(string, iColon - string));
- if(i != RENDERER_STATE_PROCESSORS.end() && size_t(std::distance(string, iNextToken)) >= i->first.size())
+ auto i = GetRendererStateProcessors().find(std::string_view(string, iColon - string));
+ if(i != GetRendererStateProcessors().end() && size_t(std::distance(string, iNextToken)) >= i->first.size())
{
value |= i->second(std::string_view(string + i->first.size(), iNextToken - iColon));
}
{
const char* JOINT_MATRIX{"jointMatrix"};
-const std::map<Property::Type, Constraint (*)(Actor&, Property::Index)> sConstraintFactory = {
- {Property::Type::BOOLEAN,
- [](Actor& a, Property::Index i) {
- return Constraint::New<bool>(a, i, [](bool& current, const PropertyInputContainer& inputs) {
- current = inputs[0]->GetBoolean();
- });
- }},
- {Property::Type::INTEGER,
- [](Actor& a, Property::Index i) {
- return Constraint::New<int>(a, i, [](int& current, const PropertyInputContainer& inputs) {
- current = inputs[0]->GetInteger();
- });
- }},
- {Property::Type::FLOAT,
- [](Actor& a, Property::Index i) {
- return Constraint::New<float>(a, i, EqualToConstraint());
- }},
- {Property::Type::VECTOR2,
- [](Actor& a, Property::Index i) {
- return Constraint::New<Vector2>(a, i, EqualToConstraint());
- }},
- {Property::Type::VECTOR3,
- [](Actor& a, Property::Index i) {
- return Constraint::New<Vector3>(a, i, EqualToConstraint());
- }},
- {Property::Type::VECTOR4,
- [](Actor& a, Property::Index i) {
- return Constraint::New<Vector4>(a, i, EqualToConstraint());
- }},
- {Property::Type::MATRIX,
- [](Actor& a, Property::Index i) {
- return Constraint::New<Matrix>(a, i, EqualToConstraint());
- }},
- {Property::Type::MATRIX3,
- [](Actor& a, Property::Index i) {
- return Constraint::New<Matrix3>(a, i, EqualToConstraint());
- }},
- {Property::Type::ROTATION,
- [](Actor& a, Property::Index i) {
- return Constraint::New<Quaternion>(a, i, EqualToConstraint());
- }},
-};
+const std::map<Property::Type, Constraint (*)(Actor&, Property::Index)>& GetConstraintFactory()
+{
+ static const std::map<Property::Type, Constraint (*)(Actor&, Property::Index)> sConstraintFactory = {
+ {Property::Type::BOOLEAN,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<bool>(a, i, [](bool& current, const PropertyInputContainer& inputs) {
+ current = inputs[0]->GetBoolean();
+ });
+ }},
+ {Property::Type::INTEGER,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<int>(a, i, [](int& current, const PropertyInputContainer& inputs) {
+ current = inputs[0]->GetInteger();
+ });
+ }},
+ {Property::Type::FLOAT,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<float>(a, i, EqualToConstraint());
+ }},
+ {Property::Type::VECTOR2,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<Vector2>(a, i, EqualToConstraint());
+ }},
+ {Property::Type::VECTOR3,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<Vector3>(a, i, EqualToConstraint());
+ }},
+ {Property::Type::VECTOR4,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<Vector4>(a, i, EqualToConstraint());
+ }},
+ {Property::Type::MATRIX,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<Matrix>(a, i, EqualToConstraint());
+ }},
+ {Property::Type::MATRIX3,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<Matrix3>(a, i, EqualToConstraint());
+ }},
+ {Property::Type::ROTATION,
+ [](Actor& a, Property::Index i) {
+ return Constraint::New<Quaternion>(a, i, EqualToConstraint());
+ }},
+ };
+ return sConstraintFactory;
+}
struct ResourceReflector : IResourceReflector
{
if(iTarget != Property::INVALID_INDEX)
{
auto propertyType = cr.mTarget.GetPropertyType(iTarget);
- auto iFind = sConstraintFactory.find(propertyType);
- if(iFind == sConstraintFactory.end())
+ auto iFind = GetConstraintFactory().find(propertyType);
+ if(iFind == GetConstraintFactory().end())
{
onError(FormatString("node '%s': Property '%s' has unsupported type '%s'; ignored.",
sourceName,
if(MaskMatch(materialDef.mFlags, MaterialDefinition::EMISSIVE))
{
- shaderDef.mDefines.push_back("EMISSIVE");
+ shaderDef.mDefines.push_back("EMISSIVE_TEXTURE");
}
if(MaskMatch(materialDef.mFlags, MaterialDefinition::SPECULAR))
}
}
- shaderDef.mUniforms["uMaxLOD"] = 6.f;
shaderDef.mUniforms["uCubeMatrix"] = Matrix::IDENTITY;
Index result = resources.mShaders.size();
return true;
}
- auto childExtent = child->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
while(parent)
{
auto control = Dali::Toolkit::Control::DownCast(parent->Self());
{
return false;
}
- auto clipMode = control.GetProperty(Actor::Property::CLIPPING_MODE).Get<bool>();
- auto parentExtent = parent->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
- if((clipMode != ClippingMode::DISABLED) && !parentExtent.Intersects(childExtent))
- {
- return false;
- }
parent = dynamic_cast<Toolkit::DevelControl::ControlAccessible*>(parent->GetParent());
}
if(mStyleMonitor)
{
mStyleMonitor.StyleChangeSignal().Connect(this, &StyleManager::StyleMonitorChange);
- mDefaultFontSize = mStyleMonitor.GetDefaultFontSize();
}
// Set the full path for the default style theme.
builder.ApplyStyle(styleName, control);
}
+ if(mDefaultFontSize == -1 && mStyleMonitor.EnsureFontClientCreated())
+ {
+ mDefaultFontSize = mStyleMonitor.GetDefaultFontSize();
+ }
+
if(mDefaultFontSize >= 0)
{
// Apply the style for logical font size
textUpdateInfo.Clear();
textUpdateInfo.mClearAll = true;
- if(textSize.width >= layoutSize.width || textSize.height >= layoutSize.height)
+ if(textSize.width > layoutSize.width || textSize.height > layoutSize.height)
{
return false;
}
#include <dali/devel-api/common/singleton-service.h>
#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/emoji-helper.h>
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_MULTI_LANGUAGE_SUPPORT");
#endif
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_FONT_PERFORMANCE_MARKER, false);
+
const Dali::Toolkit::Text::Character UTF32_A = 0x0041;
} // namespace
return;
}
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_FONTS_VALIDATE");
+
// Find the first index where to insert the font run.
FontRunIndex fontIndex = 0u;
if(0u != startIndex)
if(!isOutline || (isOutline && !isColorGlyph))
{
// Retrieve the emoji's bitmap.
- TextAbstraction::FontClient::GlyphBufferData glyphBufferData;
+ TextAbstraction::GlyphBufferData glyphBufferData;
glyphBufferData.width = isColorGlyph ? glyph.width : 0; // Desired width and height.
glyphBufferData.height = isColorGlyph ? glyph.height : 0;
uint32_t glyphBufferSize = glyphBufferData.width * glyphBufferData.height * Pixel::GetBytesPerPixel(glyphBufferData.format);
// If glyph buffer data don't have ownership, Or if we need to decompress, create new memory and replace ownership.
- if(!glyphBufferData.isBufferOwned || glyphBufferData.compressionType != TextAbstraction::FontClient::GlyphBufferData::CompressionType::NO_COMPRESSION)
+ if(!glyphBufferData.isBufferOwned || glyphBufferData.compressionType != TextAbstraction::GlyphBufferData::CompressionType::NO_COMPRESSION)
{
uint8_t* newBuffer = (uint8_t*)malloc(glyphBufferSize);
if(DALI_LIKELY(newBuffer != nullptr))
{
- TextAbstraction::FontClient::GlyphBufferData::Decompress(glyphBufferData, newBuffer);
+ TextAbstraction::GlyphBufferData::Decompress(glyphBufferData, newBuffer);
if(glyphBufferData.isBufferOwned)
{
// Release previous buffer
}
glyphBufferData.isBufferOwned = true;
glyphBufferData.buffer = newBuffer;
- glyphBufferData.compressionType = TextAbstraction::FontClient::GlyphBufferData::CompressionType::NO_COMPRESSION;
+ glyphBufferData.compressionType = TextAbstraction::GlyphBufferData::CompressionType::NO_COMPRESSION;
}
}
/*
- * 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 ((xy << 15) + (xy << 7) + xy) >> 23;
}
+/// Helper macro define for glyph typesetter. It will reduce some duplicated code line.
+// clang-format off
+/**
+ * @brief Prepare decode glyph bitmap data. It must be call END_GLYPH_BITMAP end of same scope.
+ */
+#define BEGIN_GLYPH_BITMAP(data) \
+{ \
+ uint32_t glyphOffet = 0u; \
+ const bool useLocalScanline = data.glyphBitmap.compressionType != TextAbstraction::GlyphBufferData::CompressionType::NO_COMPRESSION; \
+ uint8_t* __restrict__ glyphScanline = useLocalScanline ? (uint8_t*)malloc(data.glyphBitmap.width * glyphPixelSize) : data.glyphBitmap.buffer;
+
+/**
+ * @brief Macro to skip useless line fast.
+ */
+#define SKIP_GLYPH_SCANLINE(skipLine) \
+if(useLocalScanline) \
+{ \
+ for(int32_t lineIndex = 0; lineIndex < skipLine; ++lineIndex) \
+ { \
+ TextAbstraction::GlyphBufferData::DecompressScanline(data.glyphBitmap, glyphScanline, glyphOffet); \
+ } \
+} \
+else \
+{ \
+ glyphScanline += skipLine * static_cast<int32_t>(data.glyphBitmap.width * glyphPixelSize); \
+}
+
+/**
+ * @brief Prepare scanline of glyph bitmap data per each lines. It must be call END_GLYPH_SCANLINE_DECODE end of same scope.
+ */
+#define BEGIN_GLYPH_SCANLINE_DECODE(data) \
+{ \
+ if(useLocalScanline) \
+ { \
+ TextAbstraction::GlyphBufferData::DecompressScanline(data.glyphBitmap, glyphScanline, glyphOffet); \
+ }
+
+/**
+ * @brief Finalize scanline of glyph bitmap data per each lines.
+ */
+#define END_GLYPH_SCANLINE_DECODE(data) \
+ if(!useLocalScanline) \
+ { \
+ glyphScanline += data.glyphBitmap.width * glyphPixelSize; \
+ } \
+} // For ensure that we call BEGIN_GLYPH_SCANLINE_DECODE before
+
+/**
+ * @brief Finalize decode glyph bitmap data.
+ */
+#define END_GLYPH_BITMAP() \
+ if(useLocalScanline) \
+ { \
+ free(glyphScanline); \
+ } \
+} // For ensure that we call BEGIN_GLYPH_BITMAP before
+
+// clang-format on
+/// Helper macro define end.
+
/**
* @brief Data struct used to set the buffer of the glyph's bitmap into the final bitmap's buffer.
*/
struct GlyphData
{
- Devel::PixelBuffer bitmapBuffer; ///< The buffer of the whole bitmap. The format is RGBA8888.
- Vector2* position; ///< The position of the glyph.
- TextAbstraction::FontClient::GlyphBufferData glyphBitmap; ///< The glyph's bitmap.
- uint32_t width; ///< The bitmap's width.
- uint32_t height; ///< The bitmap's height.
- int32_t horizontalOffset; ///< The horizontal offset to be added to the 'x' glyph's position.
- int32_t verticalOffset; ///< The vertical offset to be added to the 'y' glyph's position.
+ Devel::PixelBuffer bitmapBuffer; ///< The buffer of the whole bitmap. The format is RGBA8888.
+ Vector2* position; ///< The position of the glyph.
+ TextAbstraction::GlyphBufferData glyphBitmap; ///< The glyph's bitmap.
+ uint32_t width; ///< The bitmap's width.
+ uint32_t height; ///< The bitmap's height.
+ int32_t horizontalOffset; ///< The horizontal offset to be added to the 'x' glyph's position.
+ int32_t verticalOffset; ///< The vertical offset to be added to the 'y' glyph's position.
};
/**
const bool swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
- // Offset byte value of glyph bitmap.
- uint32_t glyphOffet = 0u;
-
- // Allocate scanline memory for glyph bitmap if we need.
- const bool useLocalScanline = data.glyphBitmap.compressionType != TextAbstraction::FontClient::GlyphBufferData::CompressionType::NO_COMPRESSION;
- uint8_t* __restrict__ glyphScanline = useLocalScanline ? (uint8_t*)malloc(data.glyphBitmap.width * glyphPixelSize) : data.glyphBitmap.buffer;
-
// Precalculate input color's packed result.
uint32_t packedInputColor = 0u;
uint8_t* __restrict__ packedInputColorBuffer = reinterpret_cast<uint8_t*>(&packedInputColor);
*(packedInputColorBuffer + 1u) = static_cast<uint8_t>(color->g * 255);
*(packedInputColorBuffer) = static_cast<uint8_t>(color->r * 255);
+ // Prepare glyph bitmap
+ BEGIN_GLYPH_BITMAP(data);
+
// Skip basic line of glyph.
- if(useLocalScanline)
- {
- for(int32_t lineIndex = 0; lineIndex < lineIndexRangeMin; ++lineIndex)
- {
- TextAbstraction::FontClient::GlyphBufferData::DecompressScanline(data.glyphBitmap, glyphScanline, glyphOffet);
- }
- }
- else
- {
- glyphScanline += lineIndexRangeMin * static_cast<int32_t>(data.glyphBitmap.width * glyphPixelSize);
- }
+ SKIP_GLYPH_SCANLINE(lineIndexRangeMin);
// Traverse the pixels of the glyph line per line.
if(isColorGlyph)
{
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- if(useLocalScanline)
- {
- TextAbstraction::FontClient::GlyphBufferData::DecompressScanline(data.glyphBitmap, glyphScanline, glyphOffet);
- }
+ BEGIN_GLYPH_SCANLINE_DECODE(data);
for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
}
bitmapBuffer += data.width;
- if(!useLocalScanline)
- {
- glyphScanline += data.glyphBitmap.width * glyphPixelSize;
- }
+
+ END_GLYPH_SCANLINE_DECODE(data);
}
}
else
{
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- if(useLocalScanline)
- {
- TextAbstraction::FontClient::GlyphBufferData::DecompressScanline(data.glyphBitmap, glyphScanline, glyphOffet);
- }
+ BEGIN_GLYPH_SCANLINE_DECODE(data);
for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
}
bitmapBuffer += data.width;
- if(!useLocalScanline)
- {
- glyphScanline += data.glyphBitmap.width * glyphPixelSize;
- }
+
+ END_GLYPH_SCANLINE_DECODE(data);
}
}
- if(useLocalScanline)
- {
- free(glyphScanline);
- }
+ END_GLYPH_BITMAP();
}
else // Pixel::L8
{
if(!isColorGlyph)
{
uint8_t* __restrict__ bitmapBuffer = data.bitmapBuffer.GetBuffer();
-
- // Offset byte value of glyph bitmap.
- uint32_t glyphOffet = 0u;
-
- // Allocate scanline memory for glyph bitmap if we need.
- const bool useLocalScanline = data.glyphBitmap.compressionType != TextAbstraction::FontClient::GlyphBufferData::CompressionType::NO_COMPRESSION;
- uint8_t* __restrict__ glyphScanline = useLocalScanline ? (uint8_t*)malloc(data.glyphBitmap.width * glyphPixelSize) : data.glyphBitmap.buffer;
-
// Skip basic line.
bitmapBuffer += (lineIndexRangeMin + yOffset) * static_cast<int32_t>(data.width);
+ // Prepare glyph bitmap
+ BEGIN_GLYPH_BITMAP(data);
+
// Skip basic line of glyph.
- if(useLocalScanline)
- {
- for(int32_t lineIndex = 0; lineIndex < lineIndexRangeMin; ++lineIndex)
- {
- TextAbstraction::FontClient::GlyphBufferData::DecompressScanline(data.glyphBitmap, glyphScanline, glyphOffet);
- }
- }
- else
- {
- glyphScanline += lineIndexRangeMin * static_cast<int32_t>(data.glyphBitmap.width * glyphPixelSize);
- }
+ SKIP_GLYPH_SCANLINE(lineIndexRangeMin);
// Traverse the pixels of the glyph line per line.
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- if(useLocalScanline)
- {
- TextAbstraction::FontClient::GlyphBufferData::DecompressScanline(data.glyphBitmap, glyphScanline, glyphOffet);
- }
+ BEGIN_GLYPH_SCANLINE_DECODE(data);
for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
}
bitmapBuffer += data.width;
- if(!useLocalScanline)
- {
- glyphScanline += data.glyphBitmap.width * glyphPixelSize;
- }
- }
- if(useLocalScanline)
- {
- free(glyphScanline);
+ END_GLYPH_SCANLINE_DECODE(data);
}
+
+ END_GLYPH_BITMAP();
}
}
}
/*
- * 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.
{
Length numberOfSecondHalfGlyphs = numberOfLaidOutGlyphs - firstMiddleIndexOfElidedGlyphs + 1u;
+ // Make sure that out-of-boundary does not occur.
+ if(secondMiddleIndexOfElidedGlyphs + numberOfSecondHalfGlyphs > numberOfGlyphs)
+ {
+ numberOfSecondHalfGlyphs = numberOfGlyphs - secondMiddleIndexOfElidedGlyphs;
+ }
+
//Copy elided glyphs after the ellipsis glyph.
memcpy(glyphs + firstMiddleIndexOfElidedGlyphs + 1u, glyphs + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(GlyphInfo));
memcpy(glyphPositions + firstMiddleIndexOfElidedGlyphs + 1u, glyphPositions + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(Vector2));
/*
- * 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.
SvgVisual::~SvgVisual()
{
+ if(Stage::IsInstalled())
+ {
+ if(mLoadingTask)
+ {
+ Dali::AsyncTaskManager::Get().RemoveTask(mLoadingTask);
+ }
+ if(mRasterizingTask)
+ {
+ Dali::AsyncTaskManager::Get().RemoveTask(mRasterizingTask);
+ }
+ }
}
void SvgVisual::OnInitialize()
if(IsSynchronousLoadingRequired() && mImageUrl.IsLocalResource())
{
mLoadingTask->Process();
+ mLoadingTask.Reset(); // We don't need it now
}
else
{
void SvgVisual::DoSetOffScene(Actor& actor)
{
// Remove loading & rasterizing task
- Dali::AsyncTaskManager::Get().RemoveTask(mLoadingTask);
- Dali::AsyncTaskManager::Get().RemoveTask(mRasterizingTask);
- mLoadingTask.Reset();
- mRasterizingTask.Reset();
+ if(mLoadingTask)
+ {
+ Dali::AsyncTaskManager::Get().RemoveTask(mLoadingTask);
+ mLoadingTask.Reset();
+ }
+ if(mRasterizingTask)
+ {
+ Dali::AsyncTaskManager::Get().RemoveTask(mRasterizingTask);
+ mRasterizingTask.Reset();
+ }
actor.RemoveRenderer(mImpl->mRenderer);
mPlacementActor.Reset();
{
mRasterizingTask->Process();
ApplyRasterizedImage(mRasterizingTask);
+ mRasterizingTask.Reset(); // We don't need it now
}
else
{
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/image-loading.h>
-#include <dali/devel-api/images/pixel-data-devel.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/devel-api/rendering/texture-devel.h>
#include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
{
const unsigned int TOOLKIT_MAJOR_VERSION = 2;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 18;
+const unsigned int TOOLKIT_MICRO_VERSION = 19;
const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali2-toolkit
Summary: Dali 3D engine Toolkit
-Version: 2.2.18
+Version: 2.2.19
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT