END_TEST;
}
+
+int UtcDaliImageViewUsingAtlasAndGetNaturalSize(void)
+{
+ ToolkitTestApplication application;
+
+ // Check ImageView with background and main image, to ensure both visuals are marked as loaded
+ ImageView imageView = ImageView::New();
+ Property::Map imageMap;
+ imageMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
+ imageMap[ Toolkit::ImageVisual::Property::URL ] = gImage_34_RGBA;
+ imageMap[ Toolkit::ImageVisual::Property::ATLASING ] = true;
+ imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
+ Stage::GetCurrent().Add( imageView );
+
+ // Trigger a potential relayout
+ application.SendNotification();
+ application.Render();
+
+ Vector3 naturalSize = imageView.GetNaturalSize();
+
+ DALI_TEST_EQUALS( naturalSize.width, 34.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( naturalSize.height, 34.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
AtlasUploadObserver* atlasObserver = nullptr;
ImageAtlasManagerPtr imageAtlasManager = nullptr;
Vector4 textureRect;
+ Dali::ImageDimensions textureRectSize;
auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
mTextureManager.LoadTexture(
url, ImageDimensions(), FittingMode::SCALE_TO_FILL,
SamplingMode::BOX_THEN_LINEAR, maskInfo,
- synchronousLoading, mImageUrls[ mUrlIndex ].mTextureId, textureRect,
+ synchronousLoading, mImageUrls[ mUrlIndex ].mTextureId, textureRect, textureRectSize,
atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT,
Dali::WrapMode::Type::DEFAULT, this,
atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED,
AtlasUploadObserver* atlasObserver = nullptr;
ImageAtlasManagerPtr imageAtlasManager = nullptr;
Vector4 textureRect;
+ Dali::ImageDimensions textureRectSize;
auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
mTextureManager.LoadTexture(
mImageUrls[ imageFrame.mFrameNumber ].mUrl, ImageDimensions(), FittingMode::SCALE_TO_FILL,
SamplingMode::BOX_THEN_LINEAR, maskInfo,
- synchronousLoading, mImageUrls[ imageFrame.mFrameNumber ].mTextureId, textureRect,
+ synchronousLoading, mImageUrls[ imageFrame.mFrameNumber ].mTextureId, textureRect, textureRectSize,
atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT,
Dali::WrapMode::Type::DEFAULT, NULL,
atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply );
AtlasUploadObserver* atlasObserver = nullptr;
ImageAtlasManagerPtr imageAtlasManager = nullptr;
Vector4 textureRect;
+ Dali::ImageDimensions textureRectSize;
auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
mTextureManager.LoadTexture(
url, ImageDimensions(), FittingMode::SCALE_TO_FILL,
SamplingMode::BOX_THEN_LINEAR, maskInfo,
- synchronousLoading, mImageUrls[ imageFrame.mUrlIndex ].mTextureId, textureRect,
+ 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,
TextureSet ImageAtlasManager::Add( Vector4& textureRect,
const std::string& url,
- ImageDimensions size,
+ ImageDimensions& size,
FittingMode::Type fittingMode,
bool orientationCorrection,
AtlasUploadObserver* atlasUploadObserver )
{
return TextureSet();
}
+ size = dimensions;
unsigned int i = 0;
for( AtlasContainer::iterator iter = mAtlasList.begin(); iter != mAtlasList.end(); ++iter)
*
* @param [out] textureRect The texture area of the resource image in the atlas.
* @param [in] url The URL of the resource image file to use.
- * @param [in] size The width and height to fit the loaded image to.
+ * @param [in, out] size The width and height to fit the loaded image to.
* @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
* @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
* @param [in] atlasUploadObserver The object to observe the uploading state inside ImageAtlas.
*/
TextureSet Add( Vector4& textureRect,
const std::string& url,
- ImageDimensions size = ImageDimensions(),
+ ImageDimensions& size,
FittingMode::Type fittingMode = FittingMode::DEFAULT,
bool orientationCorrection = true,
AtlasUploadObserver* atlasUploadObserver = NULL );
mLoadPolicy( Toolkit::ImageVisual::LoadPolicy::ATTACHED ),
mReleasePolicy( Toolkit::ImageVisual::ReleasePolicy::DETACHED ),
mAtlasRect( 0.0f, 0.0f, 0.0f, 0.0f ),
+ mAtlasRectSize( 0, 0 ),
mAttemptAtlasing( false ),
mLoading( false ),
mOrientationCorrection( true )
}
else if( mImpl->mRenderer ) // Check if we have a loaded image
{
- auto textureSet = mImpl->mRenderer.GetTextures();
+ if( mImpl->mFlags & Impl::IS_ATLASING_APPLIED )
+ {
+ naturalSize.x = mAtlasRectSize.GetWidth();
+ naturalSize.y = mAtlasRectSize.GetHeight();
+ return;
+ }
+ auto textureSet = mImpl->mRenderer.GetTextures();
if( textureSet )
{
auto texture = textureSet.GetTexture(0);
textures = textureManager.LoadTexture( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode,
mMaskingData, IsSynchronousResourceLoading(), mTextureId,
- atlasRect, atlasing, mLoading, mWrapModeU,
+ atlasRect, mAtlasRectSize, atlasing, mLoading, mWrapModeU,
mWrapModeV, textureObserver, atlasUploadObserver, atlasManager,
mOrientationCorrection, forceReload, preMultiplyOnLoad);
Dali::Toolkit::ImageVisual::LoadPolicy::Type mLoadPolicy;
Dali::Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy;
Vector4 mAtlasRect;
+ Dali::ImageDimensions mAtlasRectSize;
bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
bool mLoading; ///< True if the texture is still loading.
bool mOrientationCorrection; ///< true if the image will have it's orientation corrected.
const VisualUrl& url, Dali::ImageDimensions desiredSize, Dali::FittingMode::Type fittingMode,
Dali::SamplingMode::Type samplingMode, const MaskingDataPointer& maskInfo,
bool synchronousLoading, TextureManager::TextureId& textureId, Vector4& textureRect,
- bool& atlasingStatus, bool& loadingStatus, Dali::WrapMode::Type wrapModeU,
- Dali::WrapMode::Type wrapModeV, TextureUploadObserver* textureObserver,
+ Dali::ImageDimensions& textureRectSize, bool& atlasingStatus, bool& loadingStatus,
+ Dali::WrapMode::Type wrapModeU, Dali::WrapMode::Type wrapModeV, TextureUploadObserver* textureObserver,
AtlasUploadObserver* atlasObserver, ImageAtlasManagerPtr imageAtlasManager, bool orientationCorrection,
TextureManager::ReloadPolicy reloadPolicy, TextureManager::MultiplyOnLoad& preMultiplyOnLoad )
{
textureSet = TextureSet::New();
textureSet.SetTexture( 0u, texture );
}
+ else
+ {
+ textureRectSize.SetWidth(data.GetWidth());
+ textureRectSize.SetHeight(data.GetHeight());
+ }
}
}
else
loadingStatus = true;
if( atlasingStatus )
{
- textureSet = imageAtlasManager->Add( textureRect, url.GetUrl(), desiredSize, fittingMode, true, atlasObserver );
+ textureSet = imageAtlasManager->Add( textureRect, url.GetUrl(), desiredSize, fittingMode, true, atlasObserver);
}
if( !textureSet ) // big image, no atlasing or atlasing failed
{
textureSet = GetTextureSet( textureId );
}
}
+ else
+ {
+ textureRectSize = desiredSize;
+ }
}
if( ! atlasingStatus && textureSet )
* @param[in] maskInfo Mask info structure
* @param[in] synchronousLoading true if the URL should be loaded synchronously
* @param[out] textureId, The textureId of the URL
- * @param[out] textureRect The rectangle within the texture atlas that this URL occupies
+ * @param[out] textureRect The rectangle within the texture atlas that this URL occupies,
+ * this is the rectangle in normalized coordinates.
+ * @param[out] textureRectSize The rectangle within the texture atlas that this URL occupies,
+ * this is the same rectangle in pixels.
* @param[in,out] atlasingStatus Set to USE_ATLAS to attempt atlasing. If atlasing fails, the image will still
* be loaded, and marked successful, but this will be set to false.
* If atlasing succeeds, this will be set to true.
bool synchronousLoading,
TextureManager::TextureId& textureId,
Vector4& textureRect,
+ Dali::ImageDimensions& textureRectSize,
bool& atlasingStatus,
bool& loadingStatus,
Dali::WrapMode::Type wrapModeU,