svgVisual2.GetNaturalSize(naturalSize);
DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100
- // Batch Image visual
- TestPlatformAbstraction& platform = application.GetPlatform();
- Vector2 testSize(80.f, 160.f);
- platform.SetClosestImageSize(testSize);
- propertyMap.Clear();
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( "batchingEnabled", true );
- Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
- batchImageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
- batchImageVisual.GetNaturalSize( naturalSize );
- DALI_TEST_EQUALS( naturalSize, Vector2( 80.0f, 160.0f ), TEST_LOCATION );
-
// Text visual.
// Load some fonts to get the same metrics on different platforms.
END_TEST;
}
-int UtcDaliVisualGetPropertyMapBatchImageVisual(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisual:" );
-
- VisualFactory factory = VisualFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
- propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
-
- Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( batchImageVisual );
-
- Property::Map resultMap;
- batchImageVisual.CreatePropertyMap( resultMap );
-
- // Check the property values from the returned map from visual
- Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
-
- value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
-
- value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 20 );
-
- value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 30 );
-
- END_TEST;
-}
-
//Text shape visual
int UtcDaliVisualGetPropertyMap10(void)
{
END_TEST;
}
-int UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas:" );
-
- VisualFactory factory = VisualFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
-
- // Set the desired size to be larger than the atlas limit of 1024x1024.
- propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 2048 );
- propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 2048 );
-
- // Create the visual.
- Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
-
- DALI_TEST_CHECK( batchImageVisual );
-
- DummyControl dummyControl = DummyControl::New(true);
- Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
- dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, batchImageVisual );
- Stage::GetCurrent().Add( dummyControl );
-
- DALI_TEST_CHECK( dummyControl.GetRendererCount() == 1u );
-
- END_TEST;
-}
-
int UtcDaliVisualAnimateBorderVisual01(void)
{
ToolkitTestApplication application;
END_TEST;
}
-int UtcDaliVisualFactoryGetBatchImageVisual1(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual1: Request a Batch Image visual with a Property::Map" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
-
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
-
- DummyControl actor = DummyControl::New();
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
- dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
-
- actor.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( actor );
- visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.0f, 200.0f ) );
-
- // Test SetOnStage().
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- application.SendNotification();
- application.Render();
-
- // Test SetOffStage().
- actor.Unparent();
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
- END_TEST;
-}
-
-int UtcDaliVisualFactoryGetBatchImageVisual2(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual2: Request Batch Image visual from an Image Visual with batchingEnabled set" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Property::Map propertyMap;
- // Create a normal Image Visual.
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- // Instruct the factory to change Image Visuals to Batch-Image Visuals.
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
-
- // Properties for the Batch-Image Visual.
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
-
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
-
- // Check that a Batch-Image visual was created instead of an Image visual.
- Property::Map resultMap;
- visual.CreatePropertyMap( resultMap );
-
- Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
-
- DummyControl actor = DummyControl::New();
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
- dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
-
- actor.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( actor );
- visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.0f, 200.0f ) );
-
- // Test SetOnStage().
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- application.SendNotification();
- application.Render();
-
- // Test SetOffStage().
- actor.Unparent();
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
- END_TEST;
-}
-
-int UtcDaliVisualFactoryGetBatchImageVisual3(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual3: Create an ImageView that uses a batched visual internally" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- // Create a property-map that enables batching.
- Property::Map propertyMap;
- propertyMap[ Dali::Toolkit::ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME ;
- propertyMap[ "desiredHeight" ] = 200;
- propertyMap[ "desiredWidth" ] = 200;
- propertyMap[ "batchingEnabled" ] = true;
-
- // Create an ImageView, passing the property-map in to instruct it to use batching.
- Toolkit::ImageView imageView = Toolkit::ImageView::New();
- imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap );
-
- imageView.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( imageView );
-
- END_TEST;
-}
-
-int UtcDaliVisualFactoryGetBatchImageVisual4N(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual4: Create an ImageView that uses a batched visual, with desired properties of the wrong type" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- // Create a property-map that enables batching.
- Property::Map propertyMap;
- propertyMap[ Dali::Toolkit::ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME ;
- propertyMap[ "desiredHeight" ] = Vector2(100, 100);
- propertyMap[ "desiredWidth" ] = Vector3(1, 1, 1);
- propertyMap[ "batchingEnabled" ] = true;
-
- // Create an ImageView, passing the property-map in to instruct it to use batching.
- Toolkit::ImageView imageView = Toolkit::ImageView::New();
- imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap );
-
- imageView.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( imageView );
-
- END_TEST;
-}
-
int UtcDaliVisualFactoryGetAnimatedImageVisual1(void)
{
ToolkitTestApplication application;
$(toolkit_src_dir)/visuals/gradient/linear-gradient.cpp \
$(toolkit_src_dir)/visuals/gradient/radial-gradient.cpp \
$(toolkit_src_dir)/visuals/gradient/gradient-visual.cpp \
- $(toolkit_src_dir)/visuals/image/batch-image-visual.cpp \
$(toolkit_src_dir)/visuals/image/image-visual.cpp \
$(toolkit_src_dir)/visuals/mesh/mesh-visual.cpp \
$(toolkit_src_dir)/visuals/npatch/npatch-visual.cpp \
+++ /dev/null
-/*
- * Copyright (c) 2016 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "batch-image-visual.h"
-
-// EXTERNAL HEADER
-#include <cstring> // for strncasecmp
-#include <dali/public-api/images/resource-image.h>
-#include <dali/public-api/images/native-image.h>
-#include <dali/integration-api/debug.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
-#include <dali/devel-api/rendering/renderer-devel.h>
-#include <dali/public-api/images/pixel-data.h>
-#include <dali/public-api/rendering/texture.h>
-#include <dali/public-api/rendering/texture-set.h>
-#include <dali/public-api/rendering/texture-set.h>
-
-// INTERNAL HEADER
-#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
-#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
-#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
-#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
-#include <dali-toolkit/internal/visuals/visual-base-impl.h>
-#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
-#include <dali-toolkit/internal/visuals/visual-string-constants.h>
-#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-const char HTTP_URL[] = "http://";
-const char HTTPS_URL[] = "https://";
-
-// Properties:
-const char * const DESIRED_WIDTH( "desiredWidth" );
-const char * const DESIRED_HEIGHT( "desiredHeight" );
-
-const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
-
-// The shader used for batched rendering. It uses interleaved data for
-// attributes. Limitation is that all batched renderers will share same set of uniforms.
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- attribute mediump vec2 aTexCoord;\n
- uniform mediump mat4 uMvpMatrix;\n
- varying mediump vec2 vTexCoord;\n
- \n
- void main()\n
- {\n
- vTexCoord = aTexCoord;\n
- gl_Position = uMvpMatrix * vec4( aPosition, 0.0, 1.0 );\n
- }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec4 mixColor;\n
- uniform lowp float preMultipliedAlpha;\n
- lowp vec4 visualMixColor()\n
- {\n
- return vec4( mixColor.rgb * mix( 1.0, mixColor.a, preMultipliedAlpha ), mixColor.a );\n
- }\n
- \n
- void main()\n
- {\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * visualMixColor();
- }\n
-);
-
-} // unnamed namespace
-
-BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache, const std::string& url, const Property::Map& properties )
-{
- BatchImageVisualPtr visual = new BatchImageVisual( factoryCache );
- visual->mImageUrl = url;
- visual->SetProperties( properties );
-
- return visual;
-}
-
-BatchImageVisual::BatchImageVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache ),
- mImageUrl(""),
- mDesiredSize()
-{
-}
-
-BatchImageVisual::~BatchImageVisual()
-{
-}
-
-void BatchImageVisual::DoSetProperties( const Property::Map& propertyMap )
-{
- // url already passed in constructor
-
- for( Property::Map::SizeType iter = 0; iter < propertyMap.Count(); ++iter )
- {
- KeyValuePair keyValue = propertyMap.GetKeyValue( iter );
- if( keyValue.first.type == Property::Key::INDEX )
- {
- DoSetProperty( keyValue.first.indexKey, keyValue.second );
- }
- else
- {
- if( keyValue.first == DESIRED_WIDTH )
- {
- DoSetProperty( Toolkit::ImageVisual::Property::DESIRED_WIDTH, keyValue.second );
- }
- else if( keyValue.first == DESIRED_HEIGHT )
- {
- DoSetProperty( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, keyValue.second );
- }
- }
- }
-}
-
-void BatchImageVisual::DoSetProperty( Property::Index index, const Property::Value& value )
-{
- switch( index )
- {
- case Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH:
- {
- int width;
- if( value.Get( width ) )
- {
- mDesiredSize.SetWidth( width );
- }
- else
- {
- DALI_LOG_ERROR("BatchImageVisual: width property has incorrect type\n");
- }
- break;
- }
- case Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT:
- {
- int height;
- if( value.Get( height ) )
- {
- mDesiredSize.SetHeight( height );
- }
- else
- {
- DALI_LOG_ERROR("BatchImageVisual: height property has incorrect type\n");
- }
- break;
- }
- }
-}
-
-void BatchImageVisual::GetNaturalSize( Vector2& naturalSize )
-{
- if( mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0 )
- {
- naturalSize.x = mDesiredSize.GetWidth();
- naturalSize.y = mDesiredSize.GetHeight();
- return;
- }
- else if( !mImageUrl.empty() )
- {
- ImageDimensions dimentions = ResourceImage::GetImageSize( mImageUrl );
- naturalSize.x = dimentions.GetWidth();
- naturalSize.y = dimentions.GetHeight();
- return;
- }
-
- naturalSize = Vector2::ZERO;
-}
-
-void BatchImageVisual::InitializeRenderer( const std::string& imageUrl )
-{
- if( imageUrl.empty() )
- {
- return;
- }
-
- mImageUrl = imageUrl;
- mImpl->mRenderer.Reset();
- mAtlasRect = FULL_TEXTURE_RECT;
-
- if( !mImpl->mCustomShader &&
- ( strncasecmp( imageUrl.c_str(),HTTP_URL, sizeof( HTTP_URL ) -1 ) != 0 ) && // Ignore remote images
- ( strncasecmp( imageUrl.c_str(), HTTPS_URL, sizeof( HTTPS_URL ) -1 ) != 0 ) )
- {
- if( !mImpl->mRenderer )
- {
- TextureSet textureSet = mFactoryCache.GetAtlasManager()->Add(
- mAtlasRect,
- imageUrl,
- mDesiredSize );
-
- // If image doesn't fit the atlas, create new texture set with texture that
- // is used as whole.
- if( !textureSet )
- {
- BitmapLoader loader = BitmapLoader::New( imageUrl, mDesiredSize );
- loader.Load();
- Dali::PixelData pixelData = loader.GetPixelData();
- Texture texture = Texture::New( TextureType::TEXTURE_2D,
- pixelData.GetPixelFormat(),
- pixelData.GetWidth(),
- pixelData.GetHeight() );
- texture.Upload( pixelData );
- textureSet = TextureSet::New();
- textureSet.SetTexture( 0, texture );
- mAtlasRect = FULL_TEXTURE_RECT;
- }
-
- Geometry geometry = mFactoryCache.CreateBatchQuadGeometry( mAtlasRect );
- Shader shader( GetBatchShader( mFactoryCache ) );
- mImpl->mRenderer = Renderer::New( geometry, shader );
- mImpl->mRenderer.SetTextures( textureSet );
-
- // Turn batching on, to send message it must be on stage.
- mImpl->mRenderer.SetProperty( Dali::DevelRenderer::Property::BATCHING_ENABLED, true );
- }
- mImpl->mFlags |= Impl::IS_FROM_CACHE;
- }
-}
-
-void BatchImageVisual::DoSetOnStage( Actor& actor )
-{
- if( !mImageUrl.empty() )
- {
- InitializeRenderer( mImageUrl );
- }
- // Turn batching on, to send message it must be on stage
- mImpl->mRenderer.SetProperty( Dali::DevelRenderer::Property::BATCHING_ENABLED, true );
-
- actor.AddRenderer( mImpl->mRenderer );
-}
-
-void BatchImageVisual::DoSetOffStage( Actor& actor )
-{
- actor.RemoveRenderer( mImpl->mRenderer );
-
- // If we own the image then make sure we release it when we go off stage
- if( !mImageUrl.empty() )
- {
- CleanCache( mImageUrl );
- }
- else
- {
- mImpl->mRenderer.Reset();
- }
-}
-
-void BatchImageVisual::DoCreatePropertyMap( Property::Map& map ) const
-{
- map.Clear();
- map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE );
-
- if( !mImageUrl.empty() )
- {
- map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
- map.Insert( Toolkit::ImageVisual::Property::BATCHING_ENABLED, true );
- map.Insert( Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth() );
- map.Insert( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight() );
- }
-}
-
-Shader BatchImageVisual::GetBatchShader( VisualFactoryCache& factoryCache )
-{
- Shader shader = factoryCache.GetShader( VisualFactoryCache::BATCH_IMAGE_SHADER );
- if( !shader )
- {
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- factoryCache.SaveShader( VisualFactoryCache::BATCH_IMAGE_SHADER, shader );
- }
- return shader;
-}
-
-void BatchImageVisual::CleanCache(const std::string& url)
-{
- TextureSet textureSet = mImpl->mRenderer.GetTextures();
- mImpl->mRenderer.Reset();
- if( mFactoryCache.CleanRendererCache( url ) )
- {
- mFactoryCache.GetAtlasManager()->Remove( textureSet, mAtlasRect );
- }
-}
-
-void BatchImageVisual::OnSetTransform()
-{
- if( mImpl->mRenderer )
- {
- //Register transform properties
- mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
- }
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H
-#define DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H
-
-/*
- * Copyright (c) 2016 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/intrusive-ptr.h>
-
-// INTERNAL HEADER
-#include <dali-toolkit/internal/visuals/visual-base-impl.h>
-#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
-
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Internal
-{
-
-class BatchImageVisual;
-typedef IntrusivePtr< BatchImageVisual > BatchImageVisualPtr;
-
-class BatchImageVisual: public Visual::Base, public ConnectionTracker
-{
-public:
-
- /**
- * @brief Create a new batch-image visual.
- *
- * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
- * @param[in] url The URL of the image to use
- * @param[in] properties A Property::Map containing settings for this visual
- * @return A smart-pointer to the newly allocated visual.
- */
- static BatchImageVisualPtr New( VisualFactoryCache& factoryCache, const std::string& url, const Property::Map& properties = Property::Map() );
-
-public: // from Visual
-
- /**
- * @copydoc Visual::Base::GetNaturalSize
- */
- virtual void GetNaturalSize( Vector2& naturalSize );
-
- /**
- * @copydoc Visual::Base::CreatePropertyMap
- */
- virtual void DoCreatePropertyMap( Property::Map& map ) const;
-
-protected:
-
- /**
- * @brief Constructor.
- *
- * @param[in] factoryCache The VisualFactoryCache object
- */
- BatchImageVisual( VisualFactoryCache& factoryCache );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- ~BatchImageVisual();
-
- /**
- * @copydoc Visua::Base::DoSetProperties
- */
- virtual void DoSetProperties( const Property::Map& propertyMap );
-
- /**
- * @copydoc Visual::Base::DoSetOnStage
- */
- virtual void DoSetOnStage( Actor& actor );
-
- /**
- * @copydoc Visual::Base::DoSetOffStage
- */
- virtual void DoSetOffStage( Actor& actor );
-
- /**
- * @copydoc Visual::Base::OnSetTransform
- */
- virtual void OnSetTransform();
-
-private:
-
- /**
- * Get the batch image rendering shader.
- * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
- */
- static Shader GetBatchShader( VisualFactoryCache& factoryCache );
-
- /**
- * @brief Initializes the Dali::Renderer from an image url string
- *
- * @param[in] imageUrl The image url string to intialize this ImageVisual from
- */
- void InitializeRenderer( const std::string& imageUrl );
-
- /**
- * Clean the Visual from cache, and remove the image from atlas if it is not used anymore
- */
- void CleanCache( const std::string& url );
-
- /**
- * Helper method to set individual values by index key.
- * @param[in] index The index key of the value
- * @param[in] value The value
- */
- void DoSetProperty( Property::Index index, const Property::Value& value );
-
-private:
-
- Vector4 mAtlasRect;
- std::string mImageUrl;
- Dali::ImageDimensions mDesiredSize;
-};
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H
const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
-const char * const BATCHING_ENABLED( "batchingEnabled" );
// fitting modes
DALI_ENUM_TO_STRING_TABLE_BEGIN( FITTING_MODE )
* | underline | STRING |
* | shadow | STRING |
* | outline | STRING |
- * | batchingEnabled | BOOLEAN |
*
*/
class TextVisual : public Visual::Base
return geometry;
}
-Geometry VisualFactoryCache::CreateBatchQuadGeometry( Vector4 texCoords )
-{
- const float halfWidth = 0.5f;
- const float halfHeight = 0.5f;
- struct QuadVertex {
- QuadVertex( const Vector2& vertexPosition, const Vector2& vertexTexCoords )
- : position( vertexPosition ),
- texCoords( vertexTexCoords )
- {}
- Vector2 position;
- Vector2 texCoords;
- };
-
- // special case, when texture takes whole space
- if( texCoords == Vector4::ZERO )
- {
- texCoords = Vector4(0.0f, 0.0f, 1.0f, 1.0f);
- }
-
- QuadVertex quadVertexData[6] =
- {
- QuadVertex( Vector2(-halfWidth, -halfHeight ), Vector2(texCoords.x, texCoords.y) ),
- QuadVertex( Vector2( halfWidth, -halfHeight ), Vector2(texCoords.z, texCoords.y) ),
- QuadVertex( Vector2(-halfWidth, halfHeight ), Vector2(texCoords.x, texCoords.w) ),
- QuadVertex( Vector2( halfWidth, -halfHeight ), Vector2(texCoords.z, texCoords.y) ),
- QuadVertex( Vector2(-halfWidth, halfHeight ), Vector2(texCoords.x, texCoords.w) ),
- QuadVertex( Vector2( halfWidth, halfHeight ), Vector2(texCoords.z, texCoords.w) ),
- };
-
- Property::Map vertexFormat;
- vertexFormat[ "aPosition" ] = Property::VECTOR2;
- vertexFormat[ "aTexCoord" ] = Property::VECTOR2;
- PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat );
- vertexBuffer.SetData( quadVertexData, 6 );
-
- // create geometry as normal, single quad
- Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer( vertexBuffer );
- geometry.SetType( Geometry::TRIANGLES );
-
- return geometry;
-}
-
Image VisualFactoryCache::GetBrokenVisualImage()
{
return ResourceImage::New( BROKEN_VISUAL_IMAGE_URL );
GRADIENT_SHADER_RADIAL_USER_SPACE,
GRADIENT_SHADER_RADIAL_BOUNDING_BOX,
IMAGE_SHADER,
- BATCH_IMAGE_SHADER,
IMAGE_SHADER_ATLAS_DEFAULT_WRAP,
IMAGE_SHADER_ATLAS_CUSTOM_WRAP,
NINE_PATCH_SHADER,
static Geometry CreateGridGeometry( Uint16Pair gridSize );
/**
- * Create the batchable geometry
- * @param[in] texCoords The texture atlas rect coordinates
- * @return The created batchable geometry
- */
- static Geometry CreateBatchQuadGeometry( Vector4 texCoords );
-
- /**
* @brief Returns an image to be used when a visual has failed to correctly render
* @return The broken image handle.
*/
#include <dali-toolkit/internal/visuals/border/border-visual.h>
#include <dali-toolkit/internal/visuals/color/color-visual.h>
#include <dali-toolkit/internal/visuals/gradient/gradient-visual.h>
-#include <dali-toolkit/internal/visuals/image/batch-image-visual.h>
#include <dali-toolkit/internal/visuals/image/image-visual.h>
#include <dali-toolkit/internal/visuals/mesh/mesh-visual.h>
#include <dali-toolkit/internal/visuals/npatch/npatch-visual.h>
namespace
{
-const char * const BATCHING_ENABLED( "batchingEnabled" );
BaseHandle Create()
{
BaseHandle handle = Toolkit::VisualFactory::Get();
}
else // Regular image
{
- bool batchingEnabled( false );
- Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED );
- if( batchingEnabledValue )
- {
- batchingEnabledValue->Get( batchingEnabled );
- }
-
- if( batchingEnabled )
- {
- visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap );
- }
- else
- {
- visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap );
- }
+ visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap );
}
}
BORDER_ONLY,
/**
- * @brief This enables Image visuals to automatically be converted to Batch-Image visuals.
- * @details Name "batchingEnabled", type Property::BOOLEAN.
- * @SINCE_1_2.0
- * @note Optional. If not specified, the default is false.
- * @note For Image visuals only. Not to be used with NPatch or SVG images.
- */
- BATCHING_ENABLED,
-
- /**
* @brief The image area to be displayed.
* @details Name "pixelArea", type Property::VECTOR4.
* It is a rectangular area.