mLastRequiredSize(size),
mTextureId(TextureManager::INVALID_TEXTURE_ID),
mTextures(),
+ mNativeTexture(),
mImageVisualShaderFactory(shaderFactory),
mFittingMode(fittingMode),
mSamplingMode(samplingMode),
mLoadState(TextureManager::LoadState::NOT_STARTED),
mAttemptAtlasing(false),
mOrientationCorrection(true),
- mEnableBrokenImage(true)
+ mNeedYuvToRgb(false),
+ mNeedUnifiedYuvAndRgb(false),
+ mEnableBrokenImage(true),
+ mUseFastTrackUploading(false),
+ mRendererAdded(false),
+ mUseBrokenImageRenderer(false),
+ mUseSynchronousSizing(false)
{
EnablePreMultipliedAlpha(mFactoryCache.GetPreMultiplyOnLoad());
}
case Toolkit::ImageVisual::Property::ATLASING:
{
- value.Get(mAttemptAtlasing);
+ bool attemptAtlasing = false;
+ if(value.Get(attemptAtlasing))
+ {
+ mAttemptAtlasing = attemptAtlasing;
+ }
break;
}
case Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE:
{
- value.Get(mEnableBrokenImage);
+ bool enableBrokenImage = true;
+ if(value.Get(enableBrokenImage))
+ {
+ mEnableBrokenImage = enableBrokenImage;
+ }
break;
}
}
case Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION:
{
- value.Get(mOrientationCorrection);
+ bool orientationCorrection = true;
+ if(value.Get(orientationCorrection))
+ {
+ mOrientationCorrection = orientationCorrection;
+ }
break;
}
case Toolkit::DevelImageVisual::Property::FAST_TRACK_UPLOADING:
{
- value.Get(mUseFastTrackUploading);
+ bool useFastTrackUploading = false;
+ if(value.Get(useFastTrackUploading))
+ {
+ mUseFastTrackUploading = useFastTrackUploading;
+ }
break;
}
case Toolkit::DevelImageVisual::Property::SYNCHRONOUS_SIZING:
{
- value.Get(mUseSynchronousSizing);
+ bool useSynchronousSizing = false;
+ if(value.Get(useSynchronousSizing))
+ {
+ mUseSynchronousSizing = useSynchronousSizing;
+ }
break;
}
}
mImpl->mRenderer.SetTextures(mTextures);
ComputeTextureSize();
CheckMaskTexture();
+ UpdateNativeTextureInfomation(mTextures);
- bool needToUpdateShader = DevelTexture::IsNative(mTextures.GetTexture(0)) || mUseBrokenImageRenderer;
+ bool needToUpdateShader = (!!mNativeTexture) || mUseBrokenImageRenderer;
if(mTextures.GetTextureCount() == 3)
{
// Need to reset textureset after change load state.
mTextures.Reset();
+ UpdateNativeTextureInfomation(Dali::TextureSet());
Dali::ImageDimensions size = mUseSynchronousSizing ? mLastRequiredSize : mDesiredSize;
LoadTexture(attemptAtlasing, mAtlasRect, mTextures, size, TextureManager::ReloadPolicy::FORCED);
// Need to reset textureset after change load state.
mTextures.Reset();
+ UpdateNativeTextureInfomation(Dali::TextureSet());
bool attemptAtlasing = AttemptAtlasing();
LoadTexture(attemptAtlasing, mAtlasRect, mTextures, visualSize, TextureManager::ReloadPolicy::CACHED);
mImpl->mRenderer.SetTextures(textureInformation.textureSet);
ComputeTextureSize();
CheckMaskTexture();
+ UpdateNativeTextureInfomation(textureInformation.textureSet);
bool needToUpdateShader = mUseBrokenImageRenderer;
if(!mImpl->mRenderer)
{
mTextures = textureInformation.textureSet;
+
+ UpdateNativeTextureInfomation(mTextures);
}
// Image loaded, set status regardless of staged status.
Shader shader;
const bool useStandardShader = !mImpl->mCustomShader;
- const bool useNativeImage = (mTextures && DevelTexture::IsNative(mTextures.GetTexture(0)));
+ const bool useNativeImage = (!!mNativeTexture);
if(useStandardShader)
{
.ApplyDefaultTextureWrapMode(mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE)
.EnableRoundedCorner(IsRoundedCornerRequired(), IsSquircleCornerRequired())
.EnableBorderline(IsBorderlineRequired())
- .SetTextureForFragmentShaderCheck(useNativeImage ? mTextures.GetTexture(0) : Dali::Texture())
+ .SetTextureForFragmentShaderCheck(useNativeImage ? mNativeTexture : Dali::Texture())
.EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering)
.EnableYuvToRgb(mNeedYuvToRgb, mNeedUnifiedYuvAndRgb));
}
if(useNativeImage)
{
bool modifiedFragmentShader = false;
- Texture nativeTexture = mTextures.GetTexture(0);
std::string fragmentShaderString = std::string(fragmentShaderView);
- modifiedFragmentShader = DevelTexture::ApplyNativeFragmentShader(nativeTexture, fragmentShaderString);
+ modifiedFragmentShader = DevelTexture::ApplyNativeFragmentShader(mNativeTexture, fragmentShaderString);
if(modifiedFragmentShader)
{
fragmentShaderView = fragmentShaderString;
// Need to reset textureset after change load state.
mTextures.Reset();
+ UpdateNativeTextureInfomation(Dali::TextureSet());
}
void ImageVisual::ShowBrokenImage()
return geometry;
}
+void ImageVisual::UpdateNativeTextureInfomation(TextureSet textureSet)
+{
+ // Reset previous flags and infomations.
+ mNativeTexture.Reset();
+
+ if(textureSet && textureSet.GetTextureCount() > 0u)
+ {
+ Texture texture = textureSet.GetTexture(0u);
+ if(DevelTexture::IsNative(texture))
+ {
+ // Keep native texture handle.
+ mNativeTexture = texture;
+ }
+ }
+}
+
} // namespace Internal
} // namespace Toolkit
#define DALI_TOOLKIT_INTERNAL_IMAGE_VISUAL_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
*/
Geometry GenerateGeometry(TextureManager::TextureId textureId, bool createForce);
+ /**
+ * @brief Update the informations whether this visual using native texture or not.
+ */
+ void UpdateNativeTextureInfomation(TextureSet textureSet);
+
private:
Vector4 mPixelArea;
Property::Index mPixelAreaIndex;
Dali::ImageDimensions mLastRequiredSize;
TextureManager::TextureId mTextureId;
TextureSet mTextures;
+ Dali::Texture mNativeTexture; ///< The handle of native texture if we are using it.
Vector2 mTextureSize;
Vector2 mPlacementActorSize;
Dali::Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy;
Vector4 mAtlasRect;
Dali::ImageDimensions mAtlasRectSize;
- TextureManager::LoadState mLoadState; ///< The texture loading state
- bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
- bool mOrientationCorrection; ///< true if the image will have it's orientation corrected.
- bool mNeedYuvToRgb{false}; ///< true if we need to convert yuv to rgb.
- bool mNeedUnifiedYuvAndRgb{false}; ///< true if we need to support both yuv and rgb.
- bool mEnableBrokenImage{true}; ///< true if enable broken image.
- bool mUseFastTrackUploading{false}; ///< True if we use fast tack feature.
- bool mRendererAdded{false}; ///< True if renderer added into actor.
- bool mUseBrokenImageRenderer{false}; ///< True if renderer changed as broken image.
- bool mUseSynchronousSizing{false}; ///< True if we need to synchronize image texture size to visual size, otherwise use mDesiredSize.
+ TextureManager::LoadState mLoadState; ///< The texture loading state
+
+ bool mAttemptAtlasing : 1; ///< If true will attempt atlasing, otherwise create unique texture
+ bool mOrientationCorrection : 1; ///< true if the image will have it's orientation corrected.
+ bool mNeedYuvToRgb : 1; ///< true if we need to convert yuv to rgb.
+ bool mNeedUnifiedYuvAndRgb : 1; ///< true if we need to support both yuv and rgb.
+ bool mEnableBrokenImage : 1; ///< true if enable broken image.
+ bool mUseFastTrackUploading : 1; ///< True if we use fast tack feature.
+ bool mRendererAdded : 1; ///< True if renderer added into actor.
+ bool mUseBrokenImageRenderer : 1; ///< True if renderer changed as broken image.
+ bool mUseSynchronousSizing : 1; ///< True if we need to synchronize image texture size to visual size, otherwise use mDesiredSize.
};
} // namespace Internal