/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/devel-api/rendering/texture-devel.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/actors/layer.h>
#include <dali/public-api/adaptor-framework/async-task-manager.h>
// INTERNAL HEADERS
#include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
#include <dali-toolkit/internal/texture-manager/texture-manager-impl.h>
-#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
-#include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
-#include <dali-toolkit/internal/visuals/image-visual-shader-feature-builder.h>
+#include <dali-toolkit/internal/visuals/image/image-atlas-manager.h>
+#include <dali-toolkit/internal/visuals/image/image-visual-shader-factory.h>
+#include <dali-toolkit/internal/visuals/image/image-visual-shader-feature-builder.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(7); // ltr, wrap, pixel area, atlas, pixalign, crop to mask, mask texture ratio
+const int CUSTOM_PROPERTY_COUNT(8); // ltr, wrap, pixel area, atlas, pixalign, crop to mask, mask texture ratio, pre-multiplied alpha
// fitting modes
DALI_ENUM_TO_STRING_TABLE_BEGIN(FITTING_MODE)
DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::FittingMode, SCALE_TO_FILL)
DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::FittingMode, FIT_WIDTH)
DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::FittingMode, FIT_HEIGHT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::FittingMode, VISUAL_FITTING)
DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::FittingMode, DEFAULT)
DALI_ENUM_TO_STRING_TABLE_END(FITTING_MODE)
{RELEASE_POLICY_NAME, Toolkit::ImageVisual::Property::RELEASE_POLICY},
{ORIENTATION_CORRECTION_NAME, Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION},
{FAST_TRACK_UPLOADING_NAME, Toolkit::DevelImageVisual::Property::FAST_TRACK_UPLOADING},
+ {SYNCHRONOUS_SIZING, Toolkit::DevelImageVisual::Property::SYNCHRONOUS_SIZING},
};
const int NAME_INDEX_MATCH_TABLE_SIZE = sizeof(NAME_INDEX_MATCH_TABLE) / sizeof(NAME_INDEX_MATCH_TABLE[0]);
ImageDimensions size,
FittingMode::Type fittingMode,
Dali::SamplingMode::Type samplingMode)
-: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE),
+: Visual::Base(factoryCache, Visual::FittingMode::DONT_CARE, Toolkit::Visual::IMAGE),
mPixelArea(FULL_TEXTURE_RECT),
mPixelAreaIndex(Property::INVALID_INDEX),
+ mPreMultipliedAlphaIndex(Property::INVALID_INDEX),
mPlacementActor(),
mImageUrl(imageUrl),
mMaskingData(),
mDesiredSize(size),
+ mLastRequiredSize(size),
mTextureId(TextureManager::INVALID_TEXTURE_ID),
mTextures(),
mImageVisualShaderFactory(shaderFactory),
ImageVisual::~ImageVisual()
{
- if(Stage::IsInstalled())
+ if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
{
if(mImageUrl.IsValid())
{
if(mImageUrl.GetProtocolType() == VisualUrl::TEXTURE)
{
TextureManager& textureManager = mFactoryCache.GetTextureManager();
- textureManager.RemoveExternalTexture(mImageUrl.GetUrl());
+ textureManager.RemoveExternalTexture(mImageUrl);
}
else if(mImageUrl.IsBufferResource())
{
TextureManager& textureManager = mFactoryCache.GetTextureManager();
- textureManager.RemoveEncodedImageBuffer(mImageUrl.GetUrl());
+ textureManager.RemoveEncodedImageBuffer(mImageUrl);
}
}
if(mLoadPolicy == Toolkit::ImageVisual::LoadPolicy::IMMEDIATE)
{
auto attemptAtlasing = AttemptAtlasing();
- LoadTexture(attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection, TextureManager::ReloadPolicy::CACHED);
+ LoadTexture(attemptAtlasing, mAtlasRect, mTextures, mDesiredSize, TextureManager::ReloadPolicy::CACHED);
}
}
value.Get(mUseFastTrackUploading);
break;
}
+
+ case Toolkit::DevelImageVisual::Property::SYNCHRONOUS_SIZING:
+ {
+ value.Get(mUseSynchronousSizing);
+ break;
+ }
}
}
void ImageVisual::GetNaturalSize(Vector2& naturalSize)
{
- if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
+ if(mUseSynchronousSizing && (mLastRequiredSize.GetWidth() > 0 && mLastRequiredSize.GetHeight() > 0))
+ {
+ if(mImpl->mRenderer)
+ {
+ auto textureSet = mImpl->mRenderer.GetTextures();
+ if(textureSet && textureSet.GetTextureCount())
+ {
+ auto texture = textureSet.GetTexture(0);
+ if(texture)
+ {
+ if(mTextureSize != Vector2::ZERO)
+ {
+ naturalSize = mTextureSize;
+ return;
+ }
+ }
+ }
+ }
+
+ naturalSize.x = mLastRequiredSize.GetWidth();
+ naturalSize.y = mLastRequiredSize.GetHeight();
+ return;
+ }
+ else if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
{
+ if(mImpl->mRenderer)
+ {
+ auto textureSet = mImpl->mRenderer.GetTextures();
+ if(textureSet && textureSet.GetTextureCount())
+ {
+ auto texture = textureSet.GetTexture(0);
+ if(texture)
+ {
+ if(mTextureSize != Vector2::ZERO)
+ {
+ naturalSize = mTextureSize;
+ return;
+ }
+ }
+ }
+ }
+
naturalSize.x = mDesiredSize.GetWidth();
naturalSize.y = mDesiredSize.GetHeight();
return;
{
if(mImageUrl.GetProtocolType() == VisualUrl::LOCAL)
{
- ImageDimensions dimensions = Dali::GetClosestImageSize(mImageUrl.GetUrl());
+ // Note that We don't consider desired image size for this case.
+ // Just use (0, 0) value for desired size of image.
+ ImageDimensions dimensions = Dali::GetClosestImageSize(mImageUrl.GetUrl(), ImageDimensions(0, 0), mFittingMode, mSamplingMode, mOrientationCorrection);
if(dimensions != ImageDimensions(0, 0))
{
imageSize = mPlacementActorSize;
}
+ mUseBrokenImageRenderer = true;
mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
Texture brokenImage = mImpl->mRenderer.GetTextures().GetTexture(0);
naturalSize.x = brokenImage.GetWidth();
void ImageVisual::OnInitialize()
{
- Geometry geometry;
-
- // Get the geometry
- if(mImpl->mCustomShader)
- {
- geometry = CreateGeometry(mFactoryCache, mImpl->mCustomShader->mGridSize);
- }
- else // Get any geometry associated with the texture
- {
- TextureManager& textureManager = mFactoryCache.GetTextureManager();
-
- uint32_t firstElementCount{0u};
- uint32_t secondElementCount{0u};
- geometry = textureManager.GetRenderGeometry(mTextureId, firstElementCount, secondElementCount);
-
- if(!firstElementCount && !secondElementCount) // Otherwise use quad
- {
- geometry = CreateGeometry(mFactoryCache, ImageDimensions(1, 1));
- }
- }
-
// Increase reference count of External Resources :
// EncodedImageBuffer or ExternalTextures.
// Reference count will be decreased at destructor of the visual.
if(mImageUrl.IsValid() && (mImageUrl.IsBufferResource() || mImageUrl.GetProtocolType() == VisualUrl::TEXTURE))
{
TextureManager& textureManager = mFactoryCache.GetTextureManager();
- textureManager.UseExternalResource(mImageUrl.GetUrl());
+ textureManager.UseExternalResource(mImageUrl);
}
- Shader shader = GenerateShader();
+ // Generate geometry and shader. Note that we should check AddOn when generate geometry, due to LoadPolicy::IMMEDIATE case
+ Geometry geometry = GenerateGeometry(mTextureId, true);
+ Shader shader = GenerateShader();
// Create the renderer
mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
}
}
-void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& textures, bool orientationCorrection, TextureManager::ReloadPolicy forceReload)
+void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& textures, const Dali::ImageDimensions& size, TextureManager::ReloadPolicy forceReload)
{
TextureManager& textureManager = mFactoryCache.GetTextureManager();
+ mLastRequiredSize = size;
+
ImageAtlasManagerPtr atlasManager = nullptr;
AtlasUploadObserver* atlasUploadObserver = nullptr;
auto textureObserver = this;
forceReload == TextureManager::ReloadPolicy::CACHED &&
(mImageUrl.GetProtocolType() == VisualUrl::LOCAL || mImageUrl.GetProtocolType() == VisualUrl::REMOTE) &&
!synchronousLoading &&
+ !mUseSynchronousSizing &&
!atlasing &&
!mImpl->mCustomShader &&
!(mMaskingData && mMaskingData->mAlphaMaskUrl.IsValid()))
}
else if(mUseFastTrackUploading)
{
- DALI_LOG_DEBUG_INFO("FastTrack : Fail to load fast track. mUrl : [%s]%s%s%s%s%s%s%s%s\n",
- mImageUrl.GetUrl().c_str(),
+ DALI_LOG_DEBUG_INFO("FastTrack : Fail to load fast track. mUrl : [%s]%s%s%s%s%s%s%s%s%s\n",
+ mImageUrl.GetEllipsedUrl().c_str(),
(mLoadPolicy != Toolkit::ImageVisual::LoadPolicy::ATTACHED) ? "/ mLoadPolicy != ATTACHED" : "",
(mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::DETACHED) ? "/ mReleasePolicy != DETACHED" : "",
(forceReload != TextureManager::ReloadPolicy::CACHED) ? "/ forceReload != CACHED" : "",
(!(mImageUrl.GetProtocolType() == VisualUrl::LOCAL || mImageUrl.GetProtocolType() == VisualUrl::REMOTE)) ? "/ url is not image" : "",
(synchronousLoading) ? "/ synchronousLoading" : "",
+ (mUseSynchronousSizing) ? "/ useSynchronousSizing " : "",
(atlasing) ? "/ atlasing" : "",
(mImpl->mCustomShader) ? "/ use customs shader" : "",
(mMaskingData && mMaskingData->mAlphaMaskUrl.IsValid()) ? "/ use masking url" : "");
EnablePreMultipliedAlpha(preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD);
// Set new TextureSet with fast track loading task
- mFastTrackLoadingTask = new FastTrackLoadingTask(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mOrientationCorrection, preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD ? DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF, mFactoryCache.GetLoadYuvPlanes(), MakeCallback(this, &ImageVisual::FastLoadComplete));
+ mFastTrackLoadingTask = new FastTrackLoadingTask(mImageUrl, size, mFittingMode, mSamplingMode, mOrientationCorrection, preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD ? DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF, mFactoryCache.GetLoadYuvPlanes(), MakeCallback(this, &ImageVisual::FastLoadComplete));
TextureSet textureSet = TextureSet::New();
if(!mFastTrackLoadingTask->mLoadPlanesAvaliable)
}
else
{
- textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
+ textures = textureManager.LoadTexture(mImageUrl, size, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
}
if(textures)
}
EnablePreMultipliedAlpha(preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD);
- if(!atlasing)
+ if(!atlasing && (mWrapModeU != Dali::WrapMode::DEFAULT || mWrapModeV != Dali::WrapMode::DEFAULT))
{
Sampler sampler = Sampler::New();
sampler.SetWrapMode(mWrapModeU, mWrapModeV);
}
}
-bool ImageVisual::AttemptAtlasing()
+bool ImageVisual::AttemptAtlasing() const
{
return (!mImpl->mCustomShader && (mImageUrl.IsLocalResource() || mImageUrl.IsBufferResource()) && mAttemptAtlasing);
}
{
if(mTextureId == TextureManager::INVALID_TEXTURE_ID)
{
- LoadTexture(attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection, TextureManager::ReloadPolicy::CACHED);
+ LoadTexture(attemptAtlasing, mAtlasRect, mTextures, mUseSynchronousSizing ? mLastRequiredSize : mDesiredSize, TextureManager::ReloadPolicy::CACHED);
}
else
{
mTextures = mFactoryCache.GetTextureManager().GetTextureSet(mTextureId);
- if(!(mImpl->mFlags & Visual::Base::Impl::IS_ATLASING_APPLIED) && mTextures)
+ if(!(mImpl->mFlags & Visual::Base::Impl::IS_ATLASING_APPLIED) &&
+ mTextures &&
+ (mWrapModeU != Dali::WrapMode::DEFAULT || mWrapModeV != Dali::WrapMode::DEFAULT))
{
Sampler sampler = Sampler::New();
sampler.SetWrapMode(mWrapModeU, mWrapModeV);
ComputeTextureSize();
CheckMaskTexture();
- bool needToUpdateShader = DevelTexture::IsNative(mTextures.GetTexture(0));
+ bool needToUpdateShader = DevelTexture::IsNative(mTextures.GetTexture(0)) || mUseBrokenImageRenderer;
if(mTextures.GetTextureCount() == 3)
{
UpdateShader();
}
mTextures.Reset(); // Visual should not keep a handle to the texture after this point.
+
+ if(DALI_UNLIKELY(mUseBrokenImageRenderer))
+ {
+ // We need to re-generate geometry only if it was broken image before, and result changed after Reload.
+ auto geometry = GenerateGeometry(mTextureId, true);
+
+ // Update geometry only if we need.
+ if(geometry)
+ {
+ mImpl->mRenderer.SetGeometry(geometry);
+ }
+ }
+
+ // We don't use broken image anymore.
+ mUseBrokenImageRenderer = false;
}
if(attemptAtlasing) // the texture is packed inside atlas
map.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, sync);
if(mImageUrl.IsValid())
{
+ Dali::ImageDimensions size = mUseSynchronousSizing ? mLastRequiredSize : mDesiredSize;
+
map.Insert(Toolkit::ImageVisual::Property::URL, mImageUrl.GetUrl());
- map.Insert(Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth());
- map.Insert(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight());
+ map.Insert(Toolkit::ImageVisual::Property::DESIRED_WIDTH, size.GetWidth());
+ map.Insert(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, size.GetHeight());
}
map.Insert(Toolkit::ImageVisual::Property::FITTING_MODE, mFittingMode);
map.Insert(Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION, mOrientationCorrection);
map.Insert(Toolkit::DevelImageVisual::Property::FAST_TRACK_UPLOADING, mUseFastTrackUploading);
+ map.Insert(Toolkit::DevelImageVisual::Property::SYNCHRONOUS_SIZING, mUseSynchronousSizing);
}
void ImageVisual::DoCreateInstancePropertyMap(Property::Map& map) const
map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
if(mImageUrl.IsValid())
{
- map.Insert(Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth());
- map.Insert(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight());
+ Dali::ImageDimensions size = mUseSynchronousSizing ? mLastRequiredSize : mDesiredSize;
+ map.Insert(Toolkit::ImageVisual::Property::DESIRED_WIDTH, size.GetWidth());
+ map.Insert(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, size.GetHeight());
}
}
+void ImageVisual::EnablePreMultipliedAlpha(bool preMultiplied)
+{
+ if(mImpl->mRenderer)
+ {
+ if(mPreMultipliedAlphaIndex != Property::INVALID_INDEX || !preMultiplied)
+ {
+ // RegisterUniqueProperty call SetProperty internally.
+ // Register PREMULTIPLIED_ALPHA only if it become false.
+ // Default PREMULTIPLIED_ALPHA value is 1.0f, at image-visual-shader-factory.cpp
+ mPreMultipliedAlphaIndex = mImpl->mRenderer.RegisterUniqueProperty(mPreMultipliedAlphaIndex, PREMULTIPLIED_ALPHA, preMultiplied ? 1.0f : 0.0f);
+ }
+ }
+
+ Visual::Base::EnablePreMultipliedAlpha(preMultiplied);
+}
+
void ImageVisual::OnDoAction(const Dali::Property::Index actionId, const Dali::Property::Value& attributes)
{
// Check if action is valid for this visual type and perform action if possible
case DevelImageVisual::Action::RELOAD:
{
auto attemptAtlasing = AttemptAtlasing();
- LoadTexture(attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection, TextureManager::ReloadPolicy::FORCED);
+
+ // Reset resource ready status when we call reload.
+ ResourceReady(Toolkit::Visual::ResourceStatus::PREPARING);
+ mLoadState = TextureManager::LoadState::NOT_STARTED;
+
+ // Need to reset textureset after change load state.
+ mTextures.Reset();
+
+ Dali::ImageDimensions size = mUseSynchronousSizing ? mLastRequiredSize : mDesiredSize;
+ LoadTexture(attemptAtlasing, mAtlasRect, mTextures, size, TextureManager::ReloadPolicy::FORCED);
break;
}
}
{
mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
}
+
+ if(mUseSynchronousSizing)
+ {
+ // Get current visual size
+ Vector2 size = mImpl->mTransform.GetVisualSize(mImpl->mControlSize);
+ uint32_t maximumNumber = std::numeric_limits<uint16_t>::max();
+ uint32_t sizeWidth = static_cast<uint32_t>(roundf(size.width));
+ sizeWidth = std::min(sizeWidth, maximumNumber);
+ uint32_t sizeHeight = static_cast<uint32_t>(roundf(size.height));
+ sizeHeight = std::min(sizeHeight, maximumNumber);
+ Dali::ImageDimensions visualSize = Dali::ImageDimensions(sizeWidth, sizeHeight);
+
+ // Reload if visual size is updated
+ if(mLastRequiredSize != visualSize)
+ {
+ RemoveTexture();
+ mLoadState = TextureManager::LoadState::NOT_STARTED;
+
+ // Need to reset textureset after change load state.
+ mTextures.Reset();
+
+ bool attemptAtlasing = AttemptAtlasing();
+ LoadTexture(attemptAtlasing, mAtlasRect, mTextures, visualSize, TextureManager::ReloadPolicy::CACHED);
+ }
+ }
}
void ImageVisual::UpdateShader()
void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureInformation)
{
Toolkit::Visual::ResourceStatus resourceStatus;
+
if(mImpl->mRenderer)
{
EnablePreMultipliedAlpha(textureInformation.preMultiplied);
}
else
{
- Sampler sampler = Sampler::New();
- sampler.SetWrapMode(mWrapModeU, mWrapModeV);
- textureInformation.textureSet.SetSampler(0u, sampler);
+ if(mWrapModeU != Dali::WrapMode::DEFAULT || mWrapModeV != Dali::WrapMode::DEFAULT)
+ {
+ Sampler sampler = Sampler::New();
+ sampler.SetWrapMode(mWrapModeU, mWrapModeV);
+ textureInformation.textureSet.SetSampler(0u, sampler);
+ }
mImpl->mRenderer.SetTextures(textureInformation.textureSet);
ComputeTextureSize();
CheckMaskTexture();
+ bool needToUpdateShader = mUseBrokenImageRenderer;
+
if(textureInformation.textureSet.GetTextureCount() == 3)
{
if(textureInformation.textureSet.GetTexture(0).GetPixelFormat() == Pixel::L8 && textureInformation.textureSet.GetTexture(1).GetPixelFormat() == Pixel::CHROMINANCE_U && textureInformation.textureSet.GetTexture(2).GetPixelFormat() == Pixel::CHROMINANCE_V)
{
- mNeedYuvToRgb = true;
- UpdateShader();
+ mNeedYuvToRgb = true;
+ needToUpdateShader = true;
}
}
+ if(needToUpdateShader)
+ {
+ UpdateShader();
+ }
+
if(actor)
{
actor.AddRenderer(mImpl->mRenderer);
// reset the weak handle so that the renderer only get added to actor once
mPlacementActor.Reset();
}
+
+ auto geometry = GenerateGeometry(textureInformation.textureId, mUseBrokenImageRenderer);
+
+ if(DALI_UNLIKELY(geometry))
+ {
+ // Rare cases. If load successed image don't use quad geometry (i.e. Show some n-patch broken image, and call Reload(), and success)
+ // or If given texture use AddOn,
+ // then we need to make to use quad geometry and update shader agian.
+ mImpl->mRenderer.SetGeometry(geometry);
+ }
+
+ // We don't use broken image anymore.
+ mUseBrokenImageRenderer = false;
}
}
mLoadState = TextureManager::LoadState::LOAD_FAILED;
}
- // use geometry if needed
- if(loadingSuccess)
- {
- uint32_t firstElementCount{0u};
- uint32_t secondElementCount{0u};
- auto geometry = mFactoryCache.GetTextureManager().GetRenderGeometry(mTextureId, firstElementCount, secondElementCount);
- if(mImpl->mRenderer && geometry)
- {
- mImpl->mRenderer.SetGeometry(geometry);
- Dali::DevelRenderer::DrawCommand drawCommand{};
- drawCommand.drawType = DevelRenderer::DrawType::INDEXED;
-
- if(firstElementCount)
- {
- drawCommand.firstIndex = 0;
- drawCommand.elementCount = firstElementCount;
- drawCommand.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
- DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand);
- }
-
- if(secondElementCount)
- {
- drawCommand.firstIndex = firstElementCount;
- drawCommand.elementCount = secondElementCount;
- drawCommand.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT;
- DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand);
- }
- }
- }
-
// Signal to observers ( control ) that resources are ready. Must be all resources.
ResourceReady(resourceStatus);
}
// Create and cache the standard shader
shader = mImageVisualShaderFactory.GetShader(
mFactoryCache,
- ImageVisualShaderFeatureBuilder()
+ ImageVisualShaderFeature::FeatureBuilder()
.EnableTextureAtlas(mImpl->mFlags & Visual::Base::Impl::IS_ATLASING_APPLIED && !useNativeImage)
.ApplyDefaultTextureWrapMode(mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE)
.EnableRoundedCorner(IsRoundedCornerRequired())
{
mImpl->mRenderer.RegisterProperty(MASK_TEXTURE_RATIO_NAME, ComputeMaskTextureRatio());
}
+ else
+ {
+ mImpl->mRenderer.RegisterProperty(MASK_TEXTURE_RATIO_NAME, Vector2::ONE);
+ }
maskLoadFailed = false;
}
ComputeTextureSize();
mLoadState = TextureManager::LoadState::NOT_STARTED;
+
+ // Need to reset textureset after change load state.
+ mTextures.Reset();
}
void ImageVisual::ShowBrokenImage()
}
}
+ mUseBrokenImageRenderer = true;
mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
if(actor)
{
}
}
+Geometry ImageVisual::GenerateGeometry(TextureManager::TextureId textureId, bool createForce)
+{
+ Geometry geometry;
+ if(DALI_LIKELY(Dali::Adaptor::IsAvailable()))
+ {
+ if(mImpl->mCustomShader)
+ {
+ if(createForce)
+ {
+ geometry = CreateGeometry(mFactoryCache, mImpl->mCustomShader->mGridSize);
+ }
+ }
+ else
+ {
+ uint32_t firstElementCount{0u};
+ uint32_t secondElementCount{0u};
+
+ geometry = mFactoryCache.GetTextureManager().GetRenderGeometry(textureId, firstElementCount, secondElementCount);
+ if(geometry)
+ {
+ if(mImpl->mRenderer)
+ {
+ Dali::DevelRenderer::DrawCommand drawCommand{};
+ drawCommand.drawType = DevelRenderer::DrawType::INDEXED;
+
+ if(firstElementCount)
+ {
+ drawCommand.firstIndex = 0;
+ drawCommand.elementCount = firstElementCount;
+ drawCommand.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
+ DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand);
+ }
+
+ if(secondElementCount)
+ {
+ drawCommand.firstIndex = firstElementCount;
+ drawCommand.elementCount = secondElementCount;
+ drawCommand.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT;
+ DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand);
+ }
+ }
+ }
+ else if(createForce)
+ {
+ // Create default quad geometry now
+ geometry = CreateGeometry(mFactoryCache, ImageDimensions(1, 1));
+ }
+ }
+ }
+
+ return geometry;
+}
+
} // namespace Internal
} // namespace Toolkit