// EXTERNAL HEADERS
#include <cstring> // for toupper()
+// INTERNAL HEADERS
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+
namespace Dali
{
namespace Toolkit
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)
{
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:
// 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);
+ }
+ }
}
}
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;
}
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)
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