X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-url.cpp;h=1979f780dceb119b31226e5e2f90d341fdf88e77;hb=f4b327350bf7873847f8f08bb27d11361f60f759;hp=97bc9b930031fdba80fdc4321b0334bdb53cb6d2;hpb=ef1f2122e3825ec5fa1d2d3b568caec69ecd3d0c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/visual-url.cpp b/dali-toolkit/internal/visuals/visual-url.cpp index 97bc9b9..1979f78 100644 --- a/dali-toolkit/internal/visuals/visual-url.cpp +++ b/dali-toolkit/internal/visuals/visual-url.cpp @@ -20,6 +20,10 @@ // EXTERNAL HEADERS #include // for toupper() +// INTERNAL HEADERS +#include +#include + namespace Dali { namespace Toolkit @@ -103,12 +107,10 @@ VisualUrl::Type ResolveType(const std::string& url) char GIF[4] = {'f', 'i', 'g', '.'}; char WEBP[5] = {'p', 'b', 'e', 'w', '.'}; char JSON[5] = {'n', 'o', 's', 'j', '.'}; - char RIVE[4] = {'v', 'i', 'r', '.'}; unsigned int svgScore = 0; unsigned int gifScore = 0; unsigned int webpScore = 0; unsigned int jsonScore = 0; - unsigned int riveScore = 0; int index = count; while(--index >= 0) { @@ -146,14 +148,6 @@ VisualUrl::Type ResolveType(const std::string& url) return VisualUrl::JSON; } } - if((offsetFromEnd < sizeof(RIVE)) && (currentChar == RIVE[offsetFromEnd])) - { - // early out if RIVE as can't be used in N patch for now - if(++riveScore == sizeof(RIVE)) - { - return VisualUrl::RIVE; - } - } switch(state) { case SUFFIX: @@ -219,6 +213,14 @@ VisualUrl::VisualUrl(const std::string& url) // TEXTURE location url doesn't need type resolving, REGULAR_IMAGE is fine mType = ResolveType(url); } + else + { + Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); + if(factory) + { + GetImplementation(factory).GetTextureManager().UseExternalTexture(*this); + } + } } } @@ -227,15 +229,53 @@ VisualUrl::VisualUrl(const VisualUrl& url) mType(url.mType), mLocation(url.mLocation) { + if(VisualUrl::TEXTURE == mLocation) + { + Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); + if(factory) + { + GetImplementation(factory).GetTextureManager().UseExternalTexture(*this); + } + } +} + +VisualUrl::~VisualUrl() +{ + if(VisualUrl::TEXTURE == mLocation) + { + Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); + if(factory) + { + GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl); + } + } } VisualUrl& VisualUrl::operator=(const VisualUrl& url) { if(&url != this) { + if(VisualUrl::TEXTURE == mLocation) + { + Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); + if(factory) + { + GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl); + } + } + mUrl = url.mUrl; mType = url.mType; mLocation = url.mLocation; + + if(VisualUrl::TEXTURE == mLocation) + { + Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); + if(factory) + { + GetImplementation(factory).GetTextureManager().UseExternalTexture(*this); + } + } } return *this; } @@ -267,12 +307,7 @@ bool VisualUrl::IsLocalResource() const 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; + return GetLocation(mUrl); } std::string VisualUrl::CreateTextureUrl(const std::string& location) @@ -280,6 +315,22 @@ std::string VisualUrl::CreateTextureUrl(const std::string& location) return "dali://" + location; } +VisualUrl::ProtocolType VisualUrl::GetProtocolType(const std::string& url) +{ + return ResolveLocation(url); +} + +std::string VisualUrl::GetLocation(const std::string& url) +{ + const auto location = url.find("://"); + if(std::string::npos != location) + { + return url.substr(location + 3u); // 3 characters forwards from the start of :// + } + return url; +} + + } // namespace Internal } // namespace Toolkit