* So we change its value to MASKING_ON_RENDERING even if the visual sets the MASKING_TYPE as MASKING_ON_LOADING when it uses external texture.
* @note It is used in the ImageVisual and AnimatedImageVisual. The default is MASKING_ON_LOADING.
*/
- MASKING_TYPE = ORIENTATION_CORRECTION + 12
+ MASKING_TYPE = ORIENTATION_CORRECTION + 12,
+
+ /**
+ * @brief Whether to animated image visual uses fixed cache or not.
+ * @details Name "useFixedCache", type Property::BOOLEAN.
+ * If this property is true, animated image visual uses fixed cache for loading and keeps loaded frame
+ * until the visual is removed. It reduces CPU cost when the animated image will be looping.
+ * But it can spend a lot of memory if the resource has high resolution image or many frame count.
+ * @note It is used in the AnimatedImageVisual. The default is false
+ */
+ USE_FIXED_CACHE = ORIENTATION_CORRECTION + 13
};
} //namespace Property
mLoadFailed(false),
mRendererAdded(false),
mCoreShutdown(false),
- mRedrawInScalingDown(true)
+ mRedrawInScalingDown(true),
+ mUseFixedCache(false)
{
// the rasterized image is with pre-multiplied alpha format
mImpl->mFlags |= Visual::Base::Impl::IS_PREMULTIPLIED_ALPHA;
map.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, IsSynchronousLoadingRequired());
map.Insert(Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth());
map.Insert(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight());
+ map.Insert(Toolkit::DevelImageVisual::Property::USE_FIXED_CACHE, mUseFixedCache);
}
void AnimatedVectorImageVisual::DoCreateInstancePropertyMap(Property::Map& map) const
{
DoSetProperty(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, keyValue.second);
}
+ else if(keyValue.first == USE_FIXED_CACHE)
+ {
+ DoSetProperty(Toolkit::DevelImageVisual::Property::USE_FIXED_CACHE, keyValue.second);
+ }
}
}
}
break;
}
+
+ case Toolkit::DevelImageVisual::Property::USE_FIXED_CACHE:
+ {
+ bool useFixedCache = false;
+ if(value.Get(useFixedCache))
+ {
+ mUseFixedCache = useFixedCache;
+ if(mVectorAnimationTask)
+ {
+ mVectorAnimationTask->KeepRasterizedBuffer(mUseFixedCache);
+ }
+ }
+ break;
+ }
}
}
mVectorAnimationTask->ResourceReadySignal().Connect(this, &AnimatedVectorImageVisual::OnResourceReady);
mVectorAnimationTask->SetAnimationFinishedCallback(new EventThreadCallback(MakeCallback(this, &AnimatedVectorImageVisual::OnAnimationFinished)));
+ mVectorAnimationTask->KeepRasterizedBuffer(mUseFixedCache);
mVectorAnimationTask->RequestLoad(mUrl.GetUrl(), IsSynchronousLoadingRequired());
auto& vectorAnimationManager = mFactoryCache.GetVectorAnimationManager();
bool mRendererAdded;
bool mCoreShutdown;
bool mRedrawInScalingDown;
+ bool mUseFixedCache;
};
} // namespace Internal
mAnimationDataUpdated(false),
mDestroyTask(false),
mLoadRequest(false),
- mLoadFailed(false)
+ mLoadFailed(false),
+ mUseFixedCache(false),
+ mSizeUpdated(false)
{
mVectorRenderer.UploadCompletedSignal().Connect(this, &VectorAnimationTask::OnUploadCompleted);
}
mWidth = width;
mHeight = height;
+ if(mUseFixedCache)
+ {
+ if(mTotalFrame > 0 && !mLoadFailed)
+ {
+ DALI_LOG_ERROR("fixed texture cache is assigned in SetSize\n");
+ mVectorRenderer.KeepRasterizedBuffer();
+ }
+ else
+ {
+ mSizeUpdated = true;
+ }
+ }
DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetSize: width = %d, height = %d [%p]\n", width, height, this);
}
{
if(!mLoadFailed)
{
+ if(mUseFixedCache && mSizeUpdated)
+ {
+ mVectorRenderer.KeepRasterizedBuffer();
+ mSizeUpdated = false;
+ }
mResourceReadySignal.Emit(ResourceStatus::LOADED);
}
else
*/
TimePoint GetNextFrameTime();
+ void KeepRasterizedBuffer(bool useFixedCache)
+ {
+ mUseFixedCache = useFixedCache;
+ }
+
+ bool IsKeptRasterizedBuffer()
+ {
+ return mUseFixedCache;
+ }
+
private:
/**
* @brief Loads the animation file.
bool mDestroyTask;
bool mLoadRequest;
bool mLoadFailed;
+ bool mUseFixedCache;
+ bool mSizeUpdated;
};
} // namespace Internal
const char* const REDRAW_IN_SCALING_DOWN_NAME("redrawInScalingDown");
const char* const MASKING_TYPE_NAME("maskingType");
const char* const MASK_TEXTURE_RATIO_NAME("maskTextureRatio");
+const char* const USE_FIXED_CACHE("useFixedCache");
// Text visual
const char* const TEXT_PROPERTY("text");
extern const char* const REDRAW_IN_SCALING_DOWN_NAME;
extern const char* const MASKING_TYPE_NAME;
extern const char* const MASK_TEXTURE_RATIO_NAME;
+extern const char* const USE_FIXED_CACHE;
// Text visual
extern const char* const TEXT_PROPERTY;