X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-url.cpp;h=451ac06fdad8212328f03803588a4175added098;hp=1878e31b4304d38454fd1fccd462a15ffe56b779;hb=e9ce8b35ce64531e5c6c6214527a5bf9b9747a36;hpb=0dba002791383a83d22f94e2584d85dbd67026d0 diff --git a/dali-toolkit/internal/visuals/visual-url.cpp b/dali-toolkit/internal/visuals/visual-url.cpp index 1878e31..451ac06 100644 --- a/dali-toolkit/internal/visuals/visual-url.cpp +++ b/dali-toolkit/internal/visuals/visual-url.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -30,7 +30,7 @@ namespace Internal namespace { -VisualUrl::Location ResolveLocation( const std::string& url ) +VisualUrl::ProtocolType ResolveLocation( const std::string& url ) { const char* urlCStr = url.c_str(); const uint32_t length = url.size(); @@ -99,8 +99,12 @@ VisualUrl::Type ResolveType( const std::string& url ) enum { SUFFIX, HASH, HASH_DOT } state = SUFFIX; char SVG[ 4 ] = { 'g', 'v', 's', '.' }; char GIF[ 4 ] = { 'f', 'i', 'g', '.' }; + char WEBP[ 5 ] = { 'p', 'b', 'e', 'w', '.' }; + char JSON[ 5 ] = { 'n', 'o', 's', 'j', '.' }; unsigned int svgScore = 0; unsigned int gifScore = 0; + unsigned int webpScore = 0; + unsigned int jsonScore = 0; int index = count; while( --index >= 0 ) { @@ -122,6 +126,22 @@ VisualUrl::Type ResolveType( const std::string& url ) return VisualUrl::GIF; } } + if( ( offsetFromEnd < sizeof(WEBP) )&&( currentChar == WEBP[ offsetFromEnd ] ) ) + { + // early out if WEBP as can't be used in N patch for now + if( ++webpScore == sizeof(WEBP) ) + { + return VisualUrl::WEBP; + } + } + if( ( offsetFromEnd < sizeof(JSON) )&&( currentChar == JSON[ offsetFromEnd ] ) ) + { + // early out if JSON as can't be used in N patch for now + if( ++jsonScore == sizeof(JSON) ) + { + return VisualUrl::JSON; + } + } switch( state ) { case SUFFIX: @@ -219,7 +239,7 @@ VisualUrl::Type VisualUrl::GetType() const return mType; } -VisualUrl::Location VisualUrl::GetLocation() const +VisualUrl::ProtocolType VisualUrl::GetProtocolType() const { return mLocation; } @@ -234,6 +254,21 @@ bool VisualUrl::IsLocalResource() const return mLocation == VisualUrl::LOCAL; } +std::string VisualUrl::GetLocation() const +{ + const auto location = mUrl.find( "://" ); + if( std::string::npos != location ) + { + return mUrl.substr( location + 3u ); // 3 characters forwards from the start of :// + } + return mUrl; +} + +std::string VisualUrl::CreateTextureUrl( const std::string& location ) +{ + return "dali://" + location; +} + } // Internal } // Toolkit