{
if(animatedImageLoading)
{
- pixelBuffer = animatedImageLoading.LoadFrame(frameIndex);
+ pixelBuffer = animatedImageLoading.LoadFrame(frameIndex, dimensions, fittingMode, samplingMode);
}
else if(encodedImageBuffer)
{
{
namespace
{
+
+// sampling modes
+DALI_ENUM_TO_STRING_TABLE_BEGIN(SAMPLING_MODE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::SamplingMode, BOX)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::SamplingMode, NEAREST)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::SamplingMode, LINEAR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::SamplingMode, BOX_THEN_NEAREST)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::SamplingMode, BOX_THEN_LINEAR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::SamplingMode, NO_FILTER)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::SamplingMode, DONT_CARE)
+DALI_ENUM_TO_STRING_TABLE_END(SAMPLING_MODE)
+
// stop behavior
DALI_ENUM_TO_STRING_TABLE_BEGIN(STOP_BEHAVIOR)
DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::Toolkit::DevelImageVisual::StopBehavior, CURRENT_FRAME)
if(mAnimatedImageLoading)
{
- mImageCache = new RollingAnimatedImageCache(textureManager, mAnimatedImageLoading, mMaskingData, *this, mCacheSize, mBatchSize, IsSynchronousLoadingRequired());
+ mImageCache = new RollingAnimatedImageCache(textureManager, mDesiredSize, mSamplingMode, mAnimatedImageLoading, mMaskingData, *this, mCacheSize, mBatchSize, IsSynchronousLoadingRequired());
}
else if(mImageUrls)
{
uint16_t cacheSize = std::max(std::min(std::max(batchSize, mCacheSize), numUrls), MINIMUM_CACHESIZE);
if(cacheSize < numUrls)
{
- mImageCache = new RollingImageCache(textureManager, *mImageUrls, mMaskingData, *this, cacheSize, batchSize, mFrameDelay);
+ mImageCache = new RollingImageCache(textureManager, mDesiredSize, mSamplingMode, *mImageUrls, mMaskingData, *this, cacheSize, batchSize, mFrameDelay);
}
else
{
- mImageCache = new FixedImageCache(textureManager, *mImageUrls, mMaskingData, *this, batchSize, mFrameDelay);
+ mImageCache = new FixedImageCache(textureManager, mDesiredSize, mSamplingMode, *mImageUrls, mMaskingData, *this, batchSize, mFrameDelay);
}
}
mLoadPolicy(Toolkit::ImageVisual::LoadPolicy::ATTACHED),
mReleasePolicy(Toolkit::ImageVisual::ReleasePolicy::DETACHED),
mMaskingData(),
+ mSamplingMode(SamplingMode::BOX_THEN_LINEAR),
+ mDesiredSize(),
mFrameCount(0),
mImageSize(),
mActionStatus(DevelAnimatedImageVisual::Action::PLAY),
void AnimatedImageVisual::GetNaturalSize(Vector2& naturalSize)
{
+ if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
+ {
+ naturalSize.x = mDesiredSize.GetWidth();
+ naturalSize.y = mDesiredSize.GetHeight();
+ return;
+ }
+
naturalSize = Vector2::ZERO;
if(mImageSize.GetWidth() == 0 && mImageSize.GetHeight() == 0)
{
map.Insert(Toolkit::ImageVisual::Property::LOAD_POLICY, mLoadPolicy);
map.Insert(Toolkit::ImageVisual::Property::RELEASE_POLICY, mReleasePolicy);
+ map.Insert(Toolkit::ImageVisual::Property::SAMPLING_MODE, mSamplingMode);
+ map.Insert(Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth());
+ map.Insert(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight());
}
void AnimatedImageVisual::DoCreateInstancePropertyMap(Property::Map& map) const
{
- // Do nothing
+ map.Clear();
+ map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::ANIMATED_IMAGE);
+ if(mImageUrl.IsValid())
+ {
+ map.Insert(Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth());
+ map.Insert(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight());
+ }
}
void AnimatedImageVisual::OnDoAction(const Dali::Property::Index actionId, const Dali::Property::Value& attributes)
{
DoSetProperty(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, keyValue.second);
}
+ else if(keyValue.first == IMAGE_SAMPLING_MODE)
+ {
+ DoSetProperty(Toolkit::ImageVisual::Property::SAMPLING_MODE, keyValue.second);
+ }
+ else if(keyValue.first == IMAGE_DESIRED_WIDTH)
+ {
+ DoSetProperty(Toolkit::ImageVisual::Property::DESIRED_WIDTH, keyValue.second);
+ }
+ else if(keyValue.first == IMAGE_DESIRED_HEIGHT)
+ {
+ DoSetProperty(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, keyValue.second);
+ }
}
}
// Load image immediately if LOAD_POLICY requires it
mLoadPolicy = Toolkit::ImageVisual::LoadPolicy::Type(loadPolicy);
break;
}
+
+ case Toolkit::ImageVisual::Property::SAMPLING_MODE:
+ {
+ int samplingMode = 0;
+ Scripting::GetEnumerationProperty(value, SAMPLING_MODE_TABLE, SAMPLING_MODE_TABLE_COUNT, samplingMode);
+ mSamplingMode = Dali::SamplingMode::Type(samplingMode);
+ break;
+ }
+
+ case Toolkit::ImageVisual::Property::DESIRED_WIDTH:
+ {
+ float desiredWidth = 0.0f;
+ if(value.Get(desiredWidth))
+ {
+ mDesiredSize.SetWidth(desiredWidth);
+ }
+ else
+ {
+ DALI_LOG_ERROR("AnimatedImageVisual: desiredWidth property has incorrect type\n");
+ }
+ break;
+ }
+
+ case Toolkit::ImageVisual::Property::DESIRED_HEIGHT:
+ {
+ float desiredHeight = 0.0f;
+ if(value.Get(desiredHeight))
+ {
+ mDesiredSize.SetHeight(desiredHeight);
+ }
+ else
+ {
+ DALI_LOG_ERROR("AnimatedImageVisual: desiredHeight property has incorrect type\n");
+ }
+ break;
+ }
}
}
Dali::Toolkit::ImageVisual::LoadPolicy::Type mLoadPolicy;
Dali::Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy;
TextureManager::MaskingDataPointer mMaskingData;
+ Dali::SamplingMode::Type mSamplingMode : 4;
+ Dali::ImageDimensions mDesiredSize;
// Shared variables
uint32_t mFrameCount; // Number of frames
} // namespace
FixedImageCache::FixedImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::SamplingMode::Type samplingMode,
UrlList& urlList,
TextureManager::MaskingDataPointer& maskingData,
ImageCache::FrameReadyObserver& observer,
uint32_t batchSize,
uint32_t interval)
-: ImageCache(textureManager, maskingData, observer, batchSize, interval),
+: ImageCache(textureManager, size, samplingMode, maskingData, observer, batchSize, interval),
mImageUrls(urlList),
mFront(FIRST_FRAME_INDEX)
{
auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
TextureSet textureSet = mTextureManager.LoadTexture(
- url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, mMaskingData, synchronousLoading, mImageUrls[frameIndex].mTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
+ url,
+ mDesiredSize,
+ FittingMode::SCALE_TO_FILL,
+ mSamplingMode,
+ mMaskingData,
+ synchronousLoading,
+ mImageUrls[frameIndex].mTextureId,
+ textureRect,
+ textureRectSize,
+ atlasingStatus,
+ loadingStatus,
+ Dali::WrapMode::Type::DEFAULT,
+ Dali::WrapMode::Type::DEFAULT,
+ this,
+ atlasObserver,
+ imageAtlasManager,
+ ENABLE_ORIENTATION_CORRECTION,
+ TextureManager::ReloadPolicy::CACHED,
+ preMultiply);
// If textureSet is returned but loadingState is false than load state is LOAD_FINISHED. (Notification is not comming yet.)
// If textureSet is null and the request is synchronous, load state is LOAD_FAILED.
/**
* Constructor.
* @param[in] textureManager The texture manager
+ * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] samplingMode The SamplingMode of the resource to load
* @param[in] urlList List of urls to cache
* @param[in] maskingData Masking data to be applied.
* @param[in] observer FrameReady observer
* batch and cache sizes. The cache is as large as the number of urls.
*/
FixedImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::SamplingMode::Type samplingMode,
UrlList& urlList,
TextureManager::MaskingDataPointer& maskingData,
ImageCache::FrameReadyObserver& observer,
namespace Internal
{
ImageCache::ImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::SamplingMode::Type samplingMode,
TextureManager::MaskingDataPointer& maskingData,
ImageCache::FrameReadyObserver& observer,
uint32_t batchSize,
: mTextureManager(textureManager),
mObserver(observer),
mMaskingData(maskingData),
+ mDesiredSize(size),
+ mSamplingMode(samplingMode),
mBatchSize(batchSize),
mInterval(interval),
mRequestingLoad(false),
/**
* @brief Constructor.
* @param[in] textureManager The texture manager
+ * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] samplingMode The SamplingMode of the resource to load
* @param[in] observer FrameReady observer
* @param[in] maskingData Masking data to be applied.
* @param[in] batchSize The size of a batch to load
* batch and cache sizes. The cache is as large as the number of urls.
*/
ImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::SamplingMode::Type samplingMode,
TextureManager::MaskingDataPointer& maskingData,
ImageCache::FrameReadyObserver& observer,
uint32_t batchSize,
TextureManager& mTextureManager;
FrameReadyObserver& mObserver;
TextureManager::MaskingDataPointer& mMaskingData;
+ Dali::ImageDimensions mDesiredSize;
+ Dali::SamplingMode::Type mSamplingMode : 4;
uint32_t mBatchSize;
uint32_t mInterval;
bool mRequestingLoad : 1;
} // namespace
RollingAnimatedImageCache::RollingAnimatedImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::SamplingMode::Type samplingMode,
AnimatedImageLoading& animatedImageLoading,
TextureManager::MaskingDataPointer& maskingData,
ImageCache::FrameReadyObserver& observer,
uint16_t cacheSize,
uint16_t batchSize,
bool isSynchronousLoading)
-: ImageCache(textureManager, maskingData, observer, batchSize, 0u),
+: ImageCache(textureManager, size, samplingMode, maskingData, observer, batchSize, 0u),
mAnimatedImageLoading(animatedImageLoading),
mFrameCount(SINGLE_IMAGE_COUNT),
mFrameIndex(FIRST_FRAME_INDEX),
loadingStatus,
mImageUrls[frameIndex].mTextureId,
mMaskingData,
- SamplingMode::BOX_THEN_LINEAR,
+ mDesiredSize,
+ mSamplingMode,
Dali::WrapMode::Type::DEFAULT,
Dali::WrapMode::Type::DEFAULT,
synchronousLoading,
/**
* @brief Constructor.
* @param[in] textureManager The texture manager
- * @param[in] animatedImageLoading The loaded animated image
+ * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] samplingMode The SamplingMode of the resource to load
+ * @param[in] animatedImageLoading The loaded animated image
* @param[in] maskingData Masking data to be applied.
* @param[in] observer FrameReady observer
* @param[in] cacheSize The size of the cache
* batch and cache sizes.
*/
RollingAnimatedImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::SamplingMode::Type samplingMode,
AnimatedImageLoading& animatedImageLoading,
TextureManager::MaskingDataPointer& maskingData,
ImageCache::FrameReadyObserver& observer,
namespace Internal
{
RollingImageCache::RollingImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::SamplingMode::Type samplingMode,
UrlList& urlList,
TextureManager::MaskingDataPointer& maskingData,
ImageCache::FrameReadyObserver& observer,
uint16_t cacheSize,
uint16_t batchSize,
uint32_t interval)
-: ImageCache(textureManager, maskingData, observer, batchSize, interval),
+: ImageCache(textureManager, size, samplingMode, maskingData, observer, batchSize, interval),
mImageUrls(urlList),
mQueue(cacheSize)
{
auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
TextureSet textureSet = mTextureManager.LoadTexture(
- url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, mMaskingData, synchronousLoading, mImageUrls[imageFrame.mUrlIndex].mTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
+ url,
+ mDesiredSize,
+ FittingMode::SCALE_TO_FILL,
+ mSamplingMode,
+ mMaskingData,
+ synchronousLoading,
+ mImageUrls[imageFrame.mUrlIndex].mTextureId,
+ textureRect,
+ textureRectSize,
+ atlasingStatus,
+ loadingStatus,
+ Dali::WrapMode::Type::DEFAULT,
+ Dali::WrapMode::Type::DEFAULT,
+ this,
+ atlasObserver,
+ imageAtlasManager,
+ ENABLE_ORIENTATION_CORRECTION,
+ TextureManager::ReloadPolicy::CACHED,
+ preMultiply);
// If textureSet is returned but loadingState is false than load state is LOAD_FINISHED. (Notification is not comming yet.)
// If textureSet is null and the request is synchronous, load state is LOAD_FAILED.
/**
* Constructor.
* @param[in] textureManager The texture manager
+ * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] samplingMode The SamplingMode of the resource to load
* @param[in] urlList List of urls to cache
* @param[in] maskingData Masking data to be applied.
* @param[in] observer FrameReady observer
* batch and cache sizes.
*/
RollingImageCache(TextureManager& textureManager,
+ ImageDimensions size,
+ Dali::SamplingMode::Type samplingMode,
UrlList& urlList,
TextureManager::MaskingDataPointer& maskingData,
ImageCache::FrameReadyObserver& observer,
bool& loadingStatus,
TextureManager::TextureId& textureId,
MaskingDataPointer& maskInfo,
+ Dali::ImageDimensions desiredSize,
Dali::SamplingMode::Type samplingMode,
Dali::WrapMode::Type wrapModeU,
Dali::WrapMode::Type wrapModeV,
Devel::PixelBuffer pixelBuffer;
if(animatedImageLoading)
{
- pixelBuffer = animatedImageLoading.LoadFrame(frameIndex);
+ pixelBuffer = animatedImageLoading.LoadFrame(frameIndex, desiredSize, FittingMode::SCALE_TO_FILL, samplingMode);
}
if(!pixelBuffer)
{
alphaMaskId,
contentScaleFactor,
cropToMask,
- ImageDimensions(),
+ desiredSize,
FittingMode::SCALE_TO_FILL,
- SamplingMode::BOX_THEN_LINEAR,
+ samplingMode,
TextureManager::NO_ATLAS,
StorageType::UPLOAD_TO_TEXTURE,
textureObserver,
* @param[out] loadingStatus The loading status of the texture
* @param[out] textureId The textureId of the frame
* @param[in, out] maskInfo Mask info structure
+ * @param[in] desiredSize The size the image is likely to appear at. This can be set to 0,0 for automatic
* @param[in] samplingMode The SamplingMode to use
* @param[in] wrapModeU Horizontal Wrap mode
* @param[in] wrapModeV Vertical Wrap mode
bool& loadingStatus,
TextureManager::TextureId& textureId,
MaskingDataPointer& maskInfo,
+ Dali::ImageDimensions desiredSize,
Dali::SamplingMode::Type samplingMode,
Dali::WrapMode::Type wrapModeU,
Dali::WrapMode::Type wrapModeV,