From: Heeyong Song Date: Tue, 27 Mar 2018 01:25:02 +0000 (+0000) Subject: Merge "supports remote URL gif image" into devel/master X-Git-Tag: dali_1.3.18~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=e3a661ed9b8268e1ebac5ab26088673de706c509;hp=1c8981a624dad48be2624e39b2a3ff62ebc0d220 Merge "supports remote URL gif image" into devel/master --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp index ebada51..af5f1a6 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp @@ -66,7 +66,7 @@ int UtcTextureManagerRequestLoad(void) TextureManager::ReloadPolicy::CACHED, preMultiply); - const VisualUrl& url = textureManager.GetVisualUrl( textureId ); + VisualUrl url = textureManager.GetVisualUrl( textureId ); DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION ); diff --git a/dali-toolkit/internal/text/markup-processor.cpp b/dali-toolkit/internal/text/markup-processor.cpp index 5bbe5ad..25b4616 100755 --- a/dali-toolkit/internal/text/markup-processor.cpp +++ b/dali-toolkit/internal/text/markup-processor.cpp @@ -153,6 +153,11 @@ void Initialize( FontDescriptionRun& fontRun ) */ void ParseAttributes( Tag& tag ) { + if( tag.buffer == NULL ) + { + return; + } + tag.attributes.Resize( MAX_NUM_OF_ATTRIBUTES ); // Find first the tag name. diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.cpp b/dali-toolkit/internal/text/rendering/text-typesetter.cpp index faac5ef..c5fa932 100755 --- a/dali-toolkit/internal/text/rendering/text-typesetter.cpp +++ b/dali-toolkit/internal/text/rendering/text-typesetter.cpp @@ -85,14 +85,6 @@ void TypesetGlyph( GlyphData& data, // Pointer to the color glyph if there is one. const uint32_t* const colorGlyphBuffer = isColorGlyph ? reinterpret_cast( data.glyphBitmap.buffer ) : NULL; - // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel. - // The format is RGBA8888. - uint32_t packedColor = 0u; - uint8_t* packedColorBuffer = reinterpret_cast( &packedColor ); - *( packedColorBuffer + 2 ) = static_cast( color->b * 255.f ); - *( packedColorBuffer + 1 ) = static_cast( color->g * 255.f ); - *packedColorBuffer = static_cast( color->r * 255.f ); - // Initial vertical offset. const int yOffset = data.verticalOffset + position->y; @@ -126,27 +118,35 @@ void TypesetGlyph( GlyphData& data, uint32_t packedColorGlyph = *( colorGlyphBuffer + glyphBufferOffset + index ); uint8_t* packedColorGlyphBuffer = reinterpret_cast( &packedColorGlyph ); - if( Typesetter::STYLE_SHADOW == style ) - { - // The shadow of color glyph needs to have the shadow color. - *( packedColorGlyphBuffer + 2 ) = static_cast( color->b * 255.f ); - *( packedColorGlyphBuffer + 1 ) = static_cast( color->g * 255.f ); - *packedColorGlyphBuffer = static_cast( color->r * 255.f ); - } - else - { - std::swap( *packedColorGlyphBuffer, *( packedColorGlyphBuffer + 2u ) ); // Swap B and R. - } - // Update the alpha channel. if( Typesetter::STYLE_MASK == style || Typesetter::STYLE_OUTLINE == style ) // Outline not shown for color glyph { // Create an alpha mask for color glyph. *( packedColorGlyphBuffer + 3u ) = 0u; + *( packedColorGlyphBuffer + 2u ) = 0u; + *( packedColorGlyphBuffer + 1u ) = 0u; + *packedColorGlyphBuffer = 0u; } else { - *( packedColorGlyphBuffer + 3u ) = static_cast( color->a * static_cast( *( packedColorGlyphBuffer + 3u ) ) ); + uint8_t colorAlpha = static_cast( color->a * static_cast( *( packedColorGlyphBuffer + 3u ) ) ); + *( packedColorGlyphBuffer + 3u ) = colorAlpha; + + if( Typesetter::STYLE_SHADOW == style ) + { + // The shadow of color glyph needs to have the shadow color. + *( packedColorGlyphBuffer + 2u ) = static_cast( color->b * colorAlpha ); + *( packedColorGlyphBuffer + 1u ) = static_cast( color->g * colorAlpha ); + *packedColorGlyphBuffer = static_cast( color->r * colorAlpha ); + } + else + { + std::swap( *packedColorGlyphBuffer, *( packedColorGlyphBuffer + 2u ) ); // Swap B and R. + + *( packedColorGlyphBuffer + 2u ) = ( *( packedColorGlyphBuffer + 2u ) * colorAlpha / 255 ); + *( packedColorGlyphBuffer + 1u ) = ( *( packedColorGlyphBuffer + 1u ) * colorAlpha / 255 ); + *packedColorGlyphBuffer = ( *( packedColorGlyphBuffer ) * colorAlpha / 255 ); + } } // Set the color into the final pixel buffer. @@ -154,6 +154,11 @@ void TypesetGlyph( GlyphData& data, } else { + // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel. + // The format is RGBA8888. + uint32_t packedColor = 0u; + uint8_t* packedColorBuffer = reinterpret_cast( &packedColor ); + // Update the alpha channel. const uint8_t alpha = *( data.glyphBitmap.buffer + glyphBufferOffset + index ); @@ -164,14 +169,18 @@ void TypesetGlyph( GlyphData& data, uint32_t& currentColor = *( bitmapBuffer + verticalOffset + xOffsetIndex ); uint8_t* packedCurrentColorBuffer = reinterpret_cast( ¤tColor ); - uint8_t currentAlpha = *( packedCurrentColorBuffer + 3u ); - uint8_t newAlpha = static_cast( color->a * static_cast( alpha ) ); - // For any pixel overlapped with the pixel in previous glyphs, make sure we don't // overwrite a previous bigger alpha with a smaller alpha (in order to avoid // semi-transparent gaps between joint glyphs with overlapped pixels, which could // happen, for example, in the RTL text when we copy glyphs from right to left). - *( packedColorBuffer + 3u ) = std::max( currentAlpha, newAlpha ); + uint8_t currentAlpha = *( packedCurrentColorBuffer + 3u ); + currentAlpha = std::max( currentAlpha, alpha ); + + // Color is pre-muliplied with its alpha. + *( packedColorBuffer + 3u ) = static_cast( color->a * currentAlpha ); + *( packedColorBuffer + 2u ) = static_cast( color->b * currentAlpha ); + *( packedColorBuffer + 1u ) = static_cast( color->g * currentAlpha ); + *( packedColorBuffer ) = static_cast( color->r * currentAlpha ); // Set the color into the final pixel buffer. currentColor = packedColor; @@ -222,13 +231,12 @@ void TypesetGlyph( GlyphData& data, { // Check alpha of overlapped pixels uint8_t& currentAlpha = *( bitmapBuffer + verticalOffset + xOffsetIndex ); - uint8_t newAlpha = static_cast( color->a * static_cast( alpha ) ); // For any pixel overlapped with the pixel in previous glyphs, make sure we don't // overwrite a previous bigger alpha with a smaller alpha (in order to avoid // semi-transparent gaps between joint glyphs with overlapped pixels, which could // happen, for example, in the RTL text when we copy glyphs from right to left). - *( bitmapBuffer + verticalOffset + xOffsetIndex ) = std::max( currentAlpha, newAlpha ); + *( bitmapBuffer + verticalOffset + xOffsetIndex ) = std::max( currentAlpha, alpha ); } } } @@ -631,20 +639,25 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth // Retrieves the glyph's color. const ColorIndex colorIndex = *( colorIndexBuffer + glyphIndex ); - const Vector4* color; + Vector4 color; if ( style == Typesetter::STYLE_SHADOW ) { - color = &( mModel->GetShadowColor() ); + color = mModel->GetShadowColor(); } else if ( style == Typesetter::STYLE_OUTLINE ) { - color = &( mModel->GetOutlineColor() ); + color = mModel->GetOutlineColor(); } else { - color = ( useDefaultColor || ( 0u == colorIndex ) ) ? &defaultColor : colorsBuffer + ( colorIndex - 1u ); + color = ( useDefaultColor || ( 0u == colorIndex ) ) ? defaultColor : *( colorsBuffer + ( colorIndex - 1u ) ); } + // Premultiply alpha + color.r *= color.a; + color.g *= color.a; + color.b *= color.a; + // Retrieves the glyph's bitmap. glyphData.glyphBitmap.buffer = NULL; glyphData.glyphBitmap.width = glyphInfo->width; // Desired width and height. @@ -669,7 +682,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth { TypesetGlyph( glyphData, position, - color, + &color, style, pixelFormat); // delete the glyphBitmap.buffer as it is now copied into glyphData.bitmapBuffer @@ -705,10 +718,11 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth uint8_t* underlinePixelBuffer = reinterpret_cast( &underlinePixel ); // Write the underline color to the pixel buffer - *( underlinePixelBuffer ) = static_cast( underlineColor.r * 255.f ); - *( underlinePixelBuffer + 1u ) = static_cast( underlineColor.g * 255.f ); - *( underlinePixelBuffer + 2u ) = static_cast( underlineColor.b * 255.f ); - *( underlinePixelBuffer + 3u ) = static_cast( underlineColor.a * 255.f ); + uint8_t colorAlpha = static_cast< uint8_t >( underlineColor.a * 255.f ); + *( underlinePixelBuffer + 3u ) = colorAlpha; + *( underlinePixelBuffer + 2u ) = static_cast< uint8_t >( underlineColor.b * colorAlpha ); + *( underlinePixelBuffer + 1u ) = static_cast< uint8_t >( underlineColor.g * colorAlpha ); + *( underlinePixelBuffer ) = static_cast< uint8_t >( underlineColor.r * colorAlpha ); *( bitmapBuffer + y * glyphData.width + x ) = underlinePixel; } @@ -742,10 +756,11 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth uint8_t* backgroundPixelBuffer = reinterpret_cast( &backgroundPixel ); // Write the background color to the pixel buffer - *( backgroundPixelBuffer ) = static_cast( backgroundColor.r * 255.f ); - *( backgroundPixelBuffer + 1u ) = static_cast( backgroundColor.g * 255.f ); - *( backgroundPixelBuffer + 2u ) = static_cast( backgroundColor.b * 255.f ); - *( backgroundPixelBuffer + 3u ) = static_cast( backgroundColor.a * 255.f ); + uint8_t colorAlpha = static_cast< uint8_t >( backgroundColor.a * 255.f ); + *( backgroundPixelBuffer + 3u ) = colorAlpha; + *( backgroundPixelBuffer + 2u ) = static_cast< uint8_t >( backgroundColor.b * colorAlpha ); + *( backgroundPixelBuffer + 1u ) = static_cast< uint8_t >( backgroundColor.g * colorAlpha ); + *( backgroundPixelBuffer ) = static_cast< uint8_t >( backgroundColor.r * colorAlpha ); *( bitmapBuffer + y * glyphData.width + x ) = backgroundPixel; } @@ -798,15 +813,14 @@ Devel::PixelBuffer Typesetter::CombineImageBuffer( Devel::PixelBuffer topPixelBu // Otherwise, copy pixel from topBuffer to combinedBuffer. unsigned int alphaBuffer1 = topBuffer[pixelIndex*4+3]; - unsigned int alphaBuffer2 = bottomBuffer[pixelIndex*4+3]; - if ( alphaBuffer1 != 255 || alphaBuffer2 != 255 ) + if ( alphaBuffer1 != 255 ) { // At least one pixel is not fully opaque // "Over" blend the the pixel from topBuffer with the pixel in bottomBuffer - combinedBuffer[pixelIndex*4] = ( topBuffer[pixelIndex*4] * topBuffer[pixelIndex*4+3] / 255 ) + ( bottomBuffer[pixelIndex*4] * bottomBuffer[pixelIndex*4+3] * ( 255 - topBuffer[pixelIndex*4+3] ) / ( 255*255 ) ); - combinedBuffer[pixelIndex*4+1] = ( topBuffer[pixelIndex*4+1] * topBuffer[pixelIndex*4+3] / 255 ) + ( bottomBuffer[pixelIndex*4+1] * bottomBuffer[pixelIndex*4+3] * ( 255 - topBuffer[pixelIndex*4+3] ) / ( 255*255 ) ); - combinedBuffer[pixelIndex*4+2] = ( topBuffer[pixelIndex*4+2] * topBuffer[pixelIndex*4+3] / 255 ) + ( bottomBuffer[pixelIndex*4+2] * bottomBuffer[pixelIndex*4+3] * ( 255 - topBuffer[pixelIndex*4+3] ) / ( 255*255 ) ); + combinedBuffer[pixelIndex*4] = topBuffer[pixelIndex*4] + ( bottomBuffer[pixelIndex*4] * ( 255 - topBuffer[pixelIndex*4+3] ) / 255 ); + combinedBuffer[pixelIndex*4+1] = topBuffer[pixelIndex*4+1] + ( bottomBuffer[pixelIndex*4+1] * ( 255 - topBuffer[pixelIndex*4+3] ) / 255 ); + combinedBuffer[pixelIndex*4+2] = topBuffer[pixelIndex*4+2] + ( bottomBuffer[pixelIndex*4+2] * ( 255 - topBuffer[pixelIndex*4+3] ) / 255 ); combinedBuffer[pixelIndex*4+3] = topBuffer[pixelIndex*4+3] + ( bottomBuffer[pixelIndex*4+3] * ( 255 - topBuffer[pixelIndex*4+3] ) / 255 ); } else diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index b40dba5..5f34488 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -106,6 +106,7 @@ EventData::EventData( DecoratorPtr decorator ) mAllTextSelected( false ), mUpdateInputStyle( false ), mPasswordInput( false ), + mCheckScrollAmount( false ), mIsPlaceholderPixelSize( false ), mIsPlaceholderElideEnabled( false ), mPlaceholderEllipsisFlag( false ), diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp index f421cf7..e6da930 100644 --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -88,7 +88,6 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( discard;\n \n mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n - textTexture.rgb *= mix( 1.0, textTexture.a, preMultipliedAlpha );\n \n gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 ); }\n diff --git a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp index b9f9bb6..fcb3811 100755 --- a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp @@ -332,7 +332,7 @@ void AnimatedImageVisual::DoSetProperty( Property::Index index, } case Toolkit::ImageVisual::Property::WRAP_MODE_U: { - int wrapMode; + int wrapMode = 0; if(Scripting::GetEnumerationProperty( value, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, wrapMode )) { mWrapModeU = Dali::WrapMode::Type(wrapMode); @@ -345,7 +345,7 @@ void AnimatedImageVisual::DoSetProperty( Property::Index index, } case Toolkit::ImageVisual::Property::WRAP_MODE_V: { - int wrapMode; + int wrapMode = 0; if(Scripting::GetEnumerationProperty( value, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, wrapMode )) { mWrapModeV = Dali::WrapMode::Type(wrapMode); diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index d475b39..6aaa271 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -410,7 +410,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v { case Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING: { - bool sync; + bool sync = false; if( value.Get( sync ) ) { if( sync ) @@ -431,7 +431,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::DESIRED_WIDTH: { - float desiredWidth; + float desiredWidth = 0.0f; if( value.Get( desiredWidth ) ) { mDesiredSize.SetWidth( desiredWidth ); @@ -445,7 +445,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::DESIRED_HEIGHT: { - float desiredHeight; + float desiredHeight = 0.0f; if( value.Get( desiredHeight ) ) { mDesiredSize.SetHeight( desiredHeight ); @@ -459,7 +459,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::FITTING_MODE: { - int fittingMode; + int fittingMode = 0; Scripting::GetEnumerationProperty( value, FITTING_MODE_TABLE, FITTING_MODE_TABLE_COUNT, fittingMode ); mFittingMode = Dali::FittingMode::Type( fittingMode ); break; @@ -467,7 +467,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::SAMPLING_MODE: { - int samplingMode; + int samplingMode = 0; Scripting::GetEnumerationProperty( value, SAMPLING_MODE_TABLE, SAMPLING_MODE_TABLE_COUNT, samplingMode ); mSamplingMode = Dali::SamplingMode::Type( samplingMode ); break; @@ -481,7 +481,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::WRAP_MODE_U: { - int wrapMode; + int wrapMode = 0; Scripting::GetEnumerationProperty( value, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, wrapMode ); mWrapModeU = Dali::WrapMode::Type( wrapMode ); break; @@ -489,7 +489,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::WRAP_MODE_V: { - int wrapMode; + int wrapMode = 0; Scripting::GetEnumerationProperty( value, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, wrapMode ); mWrapModeV = Dali::WrapMode::Type( wrapMode ); break; @@ -503,7 +503,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::ALPHA_MASK_URL: { - std::string alphaUrl; + std::string alphaUrl = ""; if( value.Get( alphaUrl ) ) { AllocateMaskData(); @@ -517,7 +517,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::MASK_CONTENT_SCALE: { - float scale; + float scale = 1.0f; if( value.Get( scale ) ) { AllocateMaskData(); @@ -539,7 +539,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::RELEASE_POLICY: { - int releasePolicy; + int releasePolicy = 0; Scripting::GetEnumerationProperty( value, RELEASE_POLICY_TABLE, RELEASE_POLICY_TABLE_COUNT, releasePolicy ); mReleasePolicy = Toolkit::ImageVisual::ReleasePolicy::Type( releasePolicy ); break; @@ -547,7 +547,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::LOAD_POLICY: { - int loadPolicy; + int loadPolicy = 0; Scripting::GetEnumerationProperty( value, LOAD_POLICY_TABLE, LOAD_POLICY_TABLE_COUNT, loadPolicy ); mLoadPolicy = Toolkit::ImageVisual::LoadPolicy::Type( loadPolicy ); break; diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index e894d2b..eb2dc04 100755 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -151,7 +151,7 @@ const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE = DALI_COMPOSE_SHADER( mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );\n // Draw the text as overlay above the style - gl_FragColor = ( uTextColorAnimatable * textTexture + styleTexture * ( 1.0 - textTexture ) ) * uColor * vec4( mixColor, 1.0 );\n + gl_FragColor = ( uTextColorAnimatable * textTexture + styleTexture * ( 1.0 - uTextColorAnimatable.a * textTexture ) ) * uColor * vec4( mixColor, 1.0 );\n }\n ); @@ -297,6 +297,15 @@ Dali::Property::Index StringKeyToIndexKey( const std::string& stringKey ) return result; } +void TextColorConstraint( Vector4& current, const PropertyInputContainer& inputs ) +{ + Vector4 color = inputs[0]->GetVector4(); + current.r = color.r * color.a; + current.g = color.g * color.a; + current.b = color.b * color.a; + current.a = color.a; +} + void OpacityConstraint( float& current, const PropertyInputContainer& inputs ) { current = inputs[0]->GetVector4().a; @@ -453,7 +462,7 @@ void TextVisual::DoSetOnStage( Actor& actor ) // Create constraint for the animatable text's color Property with uTextColorAnimatable in the renderer. if( shaderTextColorIndex != Property::INVALID_INDEX ) { - Constraint colorConstraint = Constraint::New( mImpl->mRenderer, shaderTextColorIndex, EqualToConstraint() ); + Constraint colorConstraint = Constraint::New( mImpl->mRenderer, shaderTextColorIndex, TextColorConstraint ); colorConstraint.AddSource( Source( actor, mAnimatableTextColorPropertyIndex ) ); colorConstraint.Apply(); diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index 272ad4e..1ec606c 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -474,13 +474,20 @@ void TextureManager::Remove( const TextureManager::TextureId textureId ) } } -const VisualUrl& TextureManager::GetVisualUrl( TextureId textureId ) +VisualUrl TextureManager::GetVisualUrl( TextureId textureId ) { + VisualUrl visualUrl(""); int cacheIndex = GetCacheIndexFromId( textureId ); - DALI_ASSERT_DEBUG( cacheIndex != INVALID_CACHE_INDEX && "TextureId out of range"); - TextureInfo& cachedTextureInfo( mTextureInfoContainer[ cacheIndex ] ); - return cachedTextureInfo.url; + if( cacheIndex != INVALID_CACHE_INDEX ) + { + DALI_LOG_INFO( gTextureManagerLogFilter, Debug::Concise, "TextureManager::GetVisualUrl. Using cached texture id=%d, textureId=%d\n", + cacheIndex, textureId ); + + TextureInfo& cachedTextureInfo( mTextureInfoContainer[ cacheIndex ] ); + visualUrl = cachedTextureInfo.url; + } + return visualUrl; } TextureManager::LoadState TextureManager::GetTextureState( TextureId textureId ) @@ -763,8 +770,11 @@ void TextureManager::ApplyMask( float contentScale, bool cropToMask ) { int maskCacheIndex = GetCacheIndexFromId( maskTextureId ); - Devel::PixelBuffer maskPixelBuffer = mTextureInfoContainer[maskCacheIndex].pixelBuffer; - pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); + if( maskCacheIndex != INVALID_CACHE_INDEX ) + { + Devel::PixelBuffer maskPixelBuffer = mTextureInfoContainer[maskCacheIndex].pixelBuffer; + pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); + } } diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.h b/dali-toolkit/internal/visuals/texture-manager-impl.h index 8685ec6..b8c6ab8 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.h +++ b/dali-toolkit/internal/visuals/texture-manager-impl.h @@ -307,9 +307,11 @@ public: void Remove( const TextureManager::TextureId textureId ); /** - * Get the visualUrl associated with the texture id + * @brief Get the visualUrl associated with the texture id. + * @param[in] textureId The texture Id to get + * @return The visual Url associated with the texture id. */ - const VisualUrl& GetVisualUrl( TextureId textureId ); + VisualUrl GetVisualUrl( TextureId textureId ); /** * @brief Get the current state of a texture diff --git a/dali-toolkit/third-party/nanosvg/nanosvg.cc b/dali-toolkit/third-party/nanosvg/nanosvg.cc index 1022a98..603f977 100644 --- a/dali-toolkit/third-party/nanosvg/nanosvg.cc +++ b/dali-toolkit/third-party/nanosvg/nanosvg.cc @@ -2753,14 +2753,21 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi) NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi) { FILE* fp = NULL; - size_t size; + size_t size = 0; + long value = 0; char* data = NULL; NSVGimage* image = NULL; fp = fopen(filename, "rb"); if (!fp) goto error; fseek(fp, 0, SEEK_END); - size = ftell(fp); + value = ftell(fp); + /** + * In the original file, unsigned long type 'size' gets a return value. But, the return value of 'ftell()' is + * signed long type. To prevent interpreting an unexpected large value, we put the comparitive condition here. + */ + if( value < 0 ) goto error; + size = value; fseek(fp, 0, SEEK_SET); data = (char*)malloc(size+1); if (data == NULL) goto error;