From: greynaga Date: Fri, 4 Aug 2017 10:44:33 +0000 (+0100) Subject: [dali_1.2.51] Merge branch 'devel/master' X-Git-Tag: dali_1.9.8~5^2~136 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=8e381f95668a543ac1e97dde1c640054e1ebbba3;hp=86a0a83bfad7dfbfd6c08c911b11d259c840fb21 [dali_1.2.51] Merge branch 'devel/master' Change-Id: Id3175b6b52278152da3c41e9b2a3c2816cc656a5 --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h index 5e71771..2e5a2cb 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h @@ -52,9 +52,9 @@ public: virtual void StartRender() {} - virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) { return false; } + virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) { return false; } - virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface ) {} + virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) {} virtual void StopRender() {} diff --git a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h index 2b53fc5..c609d34 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h @@ -30,6 +30,16 @@ namespace Toolkit namespace DevelTextLabel { +/** + * @brief Enumeration for the start and end property ranges for this control. + * @SINCE_1_0.0 + */ +enum PropertyRange +{ + ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, + ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices +}; + namespace Property { enum Type @@ -98,7 +108,14 @@ namespace Property * @brief line wrap mode when the text lines over layout width. * @details name "lineWrapMode", type string. */ - LINE_WRAP_MODE = OUTLINE + 6 + LINE_WRAP_MODE = OUTLINE + 6, + + /* + * @brief Animatable text color + * @details text color property to use if required to animate the text color + */ + TEXT_COLOR_ANIMATABLE = ANIMATABLE_PROPERTY_START_INDEX + }; } // namespace Property diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index ccddda5..d089d97 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1354,7 +1354,11 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType ) { if( mRenderer ) { + Dali::Toolkit::TextEditor handle = Dali::Toolkit::TextEditor( GetOwner() ); + renderableActor = mRenderer->Render( mController->GetView(), + handle, + Property::INVALID_INDEX, // Animatable property not supported mAlignmentOffset, DepthIndex::CONTENT ); } diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index d392b92..1ed87bd 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1390,7 +1390,11 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) { if( mRenderer ) { + Dali::Toolkit::TextField handle = Dali::Toolkit::TextField( GetOwner() ); + renderableActor = mRenderer->Render( mController->GetView(), + handle, + Property::INVALID_INDEX, // Animatable property not supported mAlignmentOffset, DepthIndex::CONTENT ); } diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index f484bbf..a6fa7ea 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -127,7 +127,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopDelay", FLO DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollStopMode", STRING, AUTO_SCROLL_STOP_MODE ) DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineWrapMode", STRING, LINE_WRAP_MODE ) - +DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, TextLabel, "textColorAnimatable", Color::WHITE, TEXT_COLOR_ANIMATABLE ) DALI_TYPE_REGISTRATION_END() } // namespace @@ -258,15 +258,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr case Toolkit::TextLabel::Property::TEXT_COLOR: { - if( impl.mController ) - { - const Vector4& textColor = value.Get< Vector4 >(); - if( impl.mController->GetDefaultColor() != textColor ) - { - impl.mController->SetDefaultColor( textColor ); - impl.mRenderer.Reset(); - } - } + SetProperty( object, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, value ); break; } @@ -597,6 +589,7 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde break; } case Toolkit::TextLabel::Property::TEXT_COLOR: + case Toolkit::DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE: { if ( impl.mController ) { @@ -850,6 +843,31 @@ float TextLabel::GetHeightForWidth( float width ) return mController->GetHeightForWidth( width ) + padding.top + padding.bottom; } +void TextLabel::OnPropertySet( Property::Index index, Property::Value propertyValue ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::OnPropertySet index[%d]\n", index ); + + switch ( index ) + { + case Toolkit::TextLabel::Property::TEXT_COLOR: + case Toolkit::DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE: + { + const Vector4& textColor = propertyValue.Get< Vector4 >(); + if( mController->GetDefaultColor() != textColor ) + { + mController->SetDefaultColor( textColor ); + mRenderer.Reset(); + } + break; + } + default: + { + Control::OnPropertySet( index, propertyValue ); // up call to control for non-handled properties + break; + } + } +} + void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container ) { DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnRelayout\n" ); @@ -887,7 +905,12 @@ void TextLabel::RenderText() float alignmentOffset = 0.f; if( mRenderer ) { + + Dali::Toolkit::TextLabel handle = Dali::Toolkit::TextLabel( GetOwner() ); + renderableActor = mRenderer->Render( mController->GetView(), + handle, + Toolkit::DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, alignmentOffset, DepthIndex::CONTENT ); } diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h index bc2459f..f15acbf 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h @@ -73,34 +73,39 @@ private: // From Control /** * @copydoc Control::OnInitialize() */ - virtual void OnInitialize(); + virtual void OnInitialize() override ; /** * @copydoc Control::OnStyleChange() */ - virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ); + virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) override ; /** * @copydoc Control::OnRelayout() */ - virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); + virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) override ; /** * @copydoc Control::GetNaturalSize() */ - virtual Vector3 GetNaturalSize(); + virtual Vector3 GetNaturalSize() override ; /** * @copydoc Control::GetHeightForWidth() */ - virtual float GetHeightForWidth( float width ); + virtual float GetHeightForWidth( float width ) override ; -// From ControlInterface + /** + * @copydoc Control::OnPropertySet() + */ + virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) override ; + + // From ControlInterface /** * @copydoc Text::ControlInterface::RequestTextRelayout() */ - virtual void RequestTextRelayout(); + virtual void RequestTextRelayout() override ; private: // from TextScroller diff --git a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp index 6fe86a4..e9b876d 100644 --- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -64,6 +65,7 @@ void main() const char* FRAGMENT_SHADER_L8 = MAKE_SHADER( uniform lowp vec4 uColor; +uniform lowp vec4 textColorAnimatable; uniform sampler2D sTexture; varying mediump vec2 vTexCoord; varying mediump vec4 vColor; @@ -71,18 +73,19 @@ varying mediump vec4 vColor; void main() { mediump vec4 color = texture2D( sTexture, vTexCoord ); - gl_FragColor = vec4( vColor.rgb * uColor.rgb, vColor.a * uColor.a * color.r ); + gl_FragColor = vec4( vColor.rgb * uColor.rgb * textColorAnimatable.rgb, uColor.a * vColor.a * textColorAnimatable.a * color.r ); } ); const char* FRAGMENT_SHADER_RGBA = MAKE_SHADER( uniform lowp vec4 uColor; +uniform lowp vec4 textColorAnimatable; uniform sampler2D sTexture; varying mediump vec2 vTexCoord; void main() { - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor; + gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * textColorAnimatable; } ); @@ -208,6 +211,8 @@ struct AtlasRenderer::Impl } void AddGlyphs( Text::ViewInterface& view, + Actor textControl, + Property::Index animatablePropertyIndex, const Vector& positions, const Vector& glyphs, const Vector4& defaultColor, @@ -460,7 +465,7 @@ struct AtlasRenderer::Impl { MeshRecord& meshRecord = *it; - Actor actor = CreateMeshActor( meshRecord, textSize, STYLE_NORMAL ); + Actor actor = CreateMeshActor( textControl, animatablePropertyIndex, defaultColor, meshRecord, textSize, STYLE_NORMAL ); // Whether the actor has renderers. const bool hasRenderer = actor.GetRendererCount() > 0u; @@ -480,7 +485,7 @@ struct AtlasRenderer::Impl vertex.mColor = shadowColor; } - Actor shadowActor = CreateMeshActor( meshRecord, textSize, STYLE_DROP_SHADOW ); + Actor shadowActor = CreateMeshActor(textControl, animatablePropertyIndex, defaultColor, meshRecord, textSize, STYLE_DROP_SHADOW ); #if defined(DEBUG_ENABLED) shadowActor.SetName( "Text Shadow renderable actor" ); #endif @@ -531,7 +536,8 @@ struct AtlasRenderer::Impl mTextCache.Resize( 0 ); } - Actor CreateMeshActor( const MeshRecord& meshRecord, const Vector2& actorSize, Style style ) + Actor CreateMeshActor( Actor textControl, Property::Index animatablePropertyIndex, const Vector4& defaultColor, const MeshRecord& meshRecord, + const Vector2& actorSize, Style style ) { PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat ); quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ), meshRecord.mMesh.mVertices.Size() ); @@ -564,6 +570,26 @@ struct AtlasRenderer::Impl shader = mShaderL8; } + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "defaultColor[%f, %f, %f, %f ]\n", defaultColor.r, defaultColor.g, defaultColor.b, defaultColor.a ); + + Dali::Property::Index shaderTextColorIndex = shader.RegisterProperty( "textColorAnimatable", defaultColor ); + + if ( animatablePropertyIndex != Property::INVALID_INDEX ) + { + // create constraint for the animatable text's color Property with textColorAnimatable in the shader. + if( shaderTextColorIndex ) + { + Constraint constraint = Constraint::New( shader, shaderTextColorIndex, EqualToConstraint() ); + constraint.AddSource( Source( textControl, animatablePropertyIndex ) ); + constraint.Apply(); + } + } + else + { + // If not animating the text colour then set to 1's so shader uses the current vertex color + shader.RegisterProperty( "textColorAnimatable", Vector4(1.0, 1.0, 1.0, 1.0 ) ); + } + Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, shader ); renderer.SetTextures( textureSet ); renderer.SetProperty( Dali::Renderer::Property::BLEND_MODE, BlendMode::ON ); @@ -814,6 +840,8 @@ Text::RendererPtr AtlasRenderer::New() } Actor AtlasRenderer::Render( Text::ViewInterface& view, + Actor textControl, + Property::Index animatablePropertyIndex, float& alignmentOffset, int depth ) { @@ -845,6 +873,8 @@ Actor AtlasRenderer::Render( Text::ViewInterface& view, const Vector4& defaultColor = view.GetTextColor(); mImpl->AddGlyphs( view, + textControl, + animatablePropertyIndex, positions, glyphs, defaultColor, diff --git a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.h b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.h index 2872395..f114b02 100644 --- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.h +++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.h @@ -47,6 +47,8 @@ public: * @copydoc Renderer::Render() */ virtual Actor Render( ViewInterface& view, + Actor textControl, + Property::Index animatablePropertyIndex, float& alignmentOffset, int depth ); diff --git a/dali-toolkit/internal/text/rendering/text-renderer.h b/dali-toolkit/internal/text/rendering/text-renderer.h index 06781b8..1d473c5 100644 --- a/dali-toolkit/internal/text/rendering/text-renderer.h +++ b/dali-toolkit/internal/text/rendering/text-renderer.h @@ -51,11 +51,15 @@ public: * @brief Render the glyphs from a ViewInterface. * * @param[in] view The interface to a view. + * @param[in] textControl handle to the text control + * @param[in] animatablePropertyIndex textControl specific animatable property * @param[out] alignmentOffset Offset used to internally align the placement actor. * @param[in] depth The depth in the tree of the parent. * @return The Renderable actor used to position the text. */ virtual Actor Render( ViewInterface& view, + Actor textContol, + Property::Index animatablePropertyIndex, float& alignmentOffset, int depth ) = 0; diff --git a/dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.cpp b/dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.cpp index 7f15b72..7fccc8d 100644 --- a/dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.cpp @@ -182,6 +182,8 @@ Text::RendererPtr VectorBasedRenderer::New() } Actor VectorBasedRenderer::Render( Text::ViewInterface& view, + Actor textControl, + Property::Index animatablePropertyIndex, float& alignmentOffset, int /*depth*/ ) { diff --git a/dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.h b/dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.h index 9d95655..9ba3930 100644 --- a/dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.h +++ b/dali-toolkit/internal/text/rendering/vector-based/vector-based-renderer.h @@ -47,6 +47,8 @@ public: * @copydoc Renderer::Render() */ virtual Actor Render( ViewInterface& view, + Actor textControl, // Functionality not supported but defined in interface + Property::Index animatablePropertyIndex, // Functionality not supported but defined in interface float& alignmentOffset, int depth ); diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index b558cfd..dcb222d 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -528,8 +528,20 @@ void ImageVisual::GetNaturalSize( Vector2& naturalSize ) naturalSize.y = mDesiredSize.GetHeight(); return; } + else if( mImpl->mRenderer ) // Check if we have a loaded image + { + auto textureSet = mImpl->mRenderer.GetTextures(); + + if( textureSet ) + { + auto texture = textureSet.GetTexture(0); + naturalSize.x = texture.GetWidth(); + naturalSize.y = texture.GetHeight(); + return; + } + } - else if( mMaskingData != NULL && mMaskingData->mAlphaMaskUrl.IsValid() && + if( mMaskingData != NULL && mMaskingData->mAlphaMaskUrl.IsValid() && mMaskingData->mCropToMask ) { ImageDimensions dimensions = Dali::GetClosestImageSize( mMaskingData->mAlphaMaskUrl.GetUrl() ); @@ -540,23 +552,26 @@ void ImageVisual::GetNaturalSize( Vector2& naturalSize ) } return; } - else if( mImageUrl.IsValid() && mImageUrl.GetLocation() == VisualUrl::LOCAL ) + else if( mImageUrl.IsValid() ) { - ImageDimensions dimensions = Dali::GetClosestImageSize( mImageUrl.GetUrl() ); - - if( dimensions != ImageDimensions( 0, 0 ) ) - { - naturalSize.x = dimensions.GetWidth(); - naturalSize.y = dimensions.GetHeight(); - } - else + if( mImageUrl.GetLocation() == VisualUrl::LOCAL ) { - Image brokenImage = VisualFactoryCache::GetBrokenVisualImage(); + ImageDimensions dimensions = Dali::GetClosestImageSize( mImageUrl.GetUrl() ); + + if( dimensions != ImageDimensions( 0, 0 ) ) + { + naturalSize.x = dimensions.GetWidth(); + naturalSize.y = dimensions.GetHeight(); + } + else + { + Image brokenImage = VisualFactoryCache::GetBrokenVisualImage(); - naturalSize.x = brokenImage.GetWidth(); - naturalSize.y = brokenImage.GetWidth(); + naturalSize.x = brokenImage.GetWidth(); + naturalSize.y = brokenImage.GetWidth(); + } + return; } - return; } naturalSize = Vector2::ZERO; diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 7a86660..8607741 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 2; -const unsigned int TOOLKIT_MICRO_VERSION = 50; +const unsigned int TOOLKIT_MICRO_VERSION = 51; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 9258cde..9b15785 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: The OpenGLES Canvas Core Library Toolkit -Version: 1.2.50 +Version: 1.2.51 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT