projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Trigger svg loading early
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
visuals
/
visual-url.cpp
diff --git
a/dali-toolkit/internal/visuals/visual-url.cpp
b/dali-toolkit/internal/visuals/visual-url.cpp
index
70c6dc2
..
c43af6d
100644
(file)
--- a/
dali-toolkit/internal/visuals/visual-url.cpp
+++ b/
dali-toolkit/internal/visuals/visual-url.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 202
1
Samsung Electronics Co., Ltd.
+ * Copyright (c) 202
2
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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-18,12
+18,9
@@
#include <dali-toolkit/internal/visuals/visual-url.h>
// EXTERNAL HEADERS
#include <dali-toolkit/internal/visuals/visual-url.h>
// EXTERNAL HEADERS
+#include <dali/devel-api/common/hash.h>
#include <cstring> // for toupper()
#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
namespace Dali
{
namespace Toolkit
@@
-108,7
+105,8
@@
VisualUrl::ProtocolType ResolveLocation(const std::string& url)
VisualUrl::Type ResolveType(const std::string& url)
{
// if only one char in string, can only be regular image
VisualUrl::Type ResolveType(const std::string& url)
{
// if only one char in string, can only be regular image
- const std::size_t count = url.size();
+ const std::size_t count = url.size();
+ VisualUrl::Type returnType = VisualUrl::REGULAR_IMAGE;
if(count > 0)
{
// parsing from the end for better chance of early outs
if(count > 0)
{
// parsing from the end for better chance of early outs
@@
-122,7
+120,9
@@
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 GIF[4] = {'f', 'i', 'g', '.'};
char WEBP[5] = {'p', 'b', 'e', 'w', '.'};
char JSON[5] = {'n', 'o', 's', 'j', '.'};
+ char TVG[4] = {'g', 'v', 't', '.'};
unsigned int svgScore = 0;
unsigned int svgScore = 0;
+ unsigned int tvgScore = 0;
unsigned int gifScore = 0;
unsigned int webpScore = 0;
unsigned int jsonScore = 0;
unsigned int gifScore = 0;
unsigned int webpScore = 0;
unsigned int jsonScore = 0;
@@
-139,20
+139,28
@@
VisualUrl::Type ResolveType(const std::string& url)
return VisualUrl::SVG;
}
}
return VisualUrl::SVG;
}
}
+ if((offsetFromEnd < sizeof(TVG)) && (currentChar == TVG[offsetFromEnd]))
+ {
+ // early out if TVG as can't be used in N patch for now
+ if(++tvgScore == sizeof(TVG))
+ {
+ return VisualUrl::TVG;
+ }
+ }
if((offsetFromEnd < sizeof(GIF)) && (currentChar == GIF[offsetFromEnd]))
{
if((offsetFromEnd < sizeof(GIF)) && (currentChar == GIF[offsetFromEnd]))
{
- //
early out if GIF as can't be used in N patch for now
+ //
find type, but need to be check used in N patch
if(++gifScore == sizeof(GIF))
{
if(++gifScore == sizeof(GIF))
{
- return VisualUrl::GIF;
+ return
Type =
VisualUrl::GIF;
}
}
if((offsetFromEnd < sizeof(WEBP)) && (currentChar == WEBP[offsetFromEnd]))
{
}
}
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))
{
if(++webpScore == sizeof(WEBP))
{
- return VisualUrl::WEBP;
+ //find type, but need to be check used in N patch
+ returnType = VisualUrl::WEBP;
}
}
if((offsetFromEnd < sizeof(JSON)) && (currentChar == JSON[offsetFromEnd]))
}
}
if((offsetFromEnd < sizeof(JSON)) && (currentChar == JSON[offsetFromEnd]))
@@
-182,7
+190,7
@@
VisualUrl::Type ResolveType(const std::string& url)
else
{
// early out, not a valid N/9-patch URL
else
{
// early out, not a valid N/9-patch URL
- return
VisualUrl::REGULAR_IMAGE
;
+ return
returnType
;
}
break;
}
}
break;
}
@@
-195,7
+203,7
@@
VisualUrl::Type ResolveType(const std::string& url)
else
{
// early out, not a valid N/9-patch URL
else
{
// early out, not a valid N/9-patch URL
- return
VisualUrl::REGULAR_IMAGE
;
+ return
returnType
;
}
break;
}
}
break;
}
@@
-203,7
+211,7
@@
VisualUrl::Type ResolveType(const std::string& url)
}
}
// if we got here it is a regular image
}
}
// if we got here it is a regular image
- return
VisualUrl::REGULAR_IMAGE
;
+ return
returnType
;
}
} // namespace
}
} // namespace
@@
-211,14
+219,16
@@
VisualUrl::Type ResolveType(const std::string& url)
VisualUrl::VisualUrl()
: mUrl(),
mType(VisualUrl::REGULAR_IMAGE),
VisualUrl::VisualUrl()
: mUrl(),
mType(VisualUrl::REGULAR_IMAGE),
- mLocation(VisualUrl::LOCAL)
+ mLocation(VisualUrl::LOCAL),
+ mUrlHash(0ull)
{
}
VisualUrl::VisualUrl(const std::string& url)
: mUrl(url),
mType(VisualUrl::REGULAR_IMAGE),
{
}
VisualUrl::VisualUrl(const std::string& url)
: mUrl(url),
mType(VisualUrl::REGULAR_IMAGE),
- mLocation(VisualUrl::LOCAL)
+ mLocation(VisualUrl::LOCAL),
+ mUrlHash(0ull)
{
if(!url.empty())
{
{
if(!url.empty())
{
@@
-228,85
+238,29
@@
VisualUrl::VisualUrl(const std::string& url)
// TEXTURE and BUFFER location url doesn't need type resolving, REGULAR_IMAGE is fine
mType = ResolveType(url);
}
// TEXTURE and BUFFER 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().UseExternalResource(*this);
- }
- }
}
}
VisualUrl::VisualUrl(const VisualUrl& url)
: mUrl(url.mUrl),
mType(url.mType),
}
}
VisualUrl::VisualUrl(const VisualUrl& url)
: mUrl(url.mUrl),
mType(url.mType),
- mLocation(url.mLocation)
+ mLocation(url.mLocation),
+ mUrlHash(url.mUrlHash)
{
{
- if(VisualUrl::TEXTURE == mLocation || VisualUrl::BUFFER == mLocation)
- {
- Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
- if(factory)
- {
- GetImplementation(factory).GetTextureManager().UseExternalResource(*this);
- }
- }
}
VisualUrl::~VisualUrl()
{
}
VisualUrl::~VisualUrl()
{
- if(VisualUrl::TEXTURE == mLocation)
- {
- Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
- if(factory)
- {
- GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl);
- }
- }
- else if(VisualUrl::BUFFER == mLocation)
- {
- Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
- if(factory)
- {
- GetImplementation(factory).GetTextureManager().RemoveExternalEncodedImageBuffer(mUrl);
- }
- }
}
VisualUrl& VisualUrl::operator=(const VisualUrl& url)
{
if(&url != this)
{
}
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);
- }
- }
- else if(VisualUrl::BUFFER == mLocation)
- {
- Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
- if(factory)
- {
- GetImplementation(factory).GetTextureManager().RemoveExternalEncodedImageBuffer(mUrl);
- }
- }
-
mUrl = url.mUrl;
mType = url.mType;
mLocation = url.mLocation;
mUrl = url.mUrl;
mType = url.mType;
mLocation = url.mLocation;
-
- if(VisualUrl::TEXTURE == mLocation || VisualUrl::BUFFER == mLocation)
- {
- Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
- if(factory)
- {
- GetImplementation(factory).GetTextureManager().UseExternalResource(*this);
- }
- }
+ mUrlHash = url.mUrlHash;
}
return *this;
}
}
return *this;
}
@@
-316,6
+270,11
@@
const std::string& VisualUrl::GetUrl() const
return mUrl;
}
return mUrl;
}
+const std::uint64_t& VisualUrl::GetUrlHash() const
+{
+ return DALI_UNLIKELY(mUrlHash == 0) ? (mUrlHash = Dali::CalculateHash(mUrl)) : mUrlHash;
+}
+
VisualUrl::Type VisualUrl::GetType() const
{
return mType;
VisualUrl::Type VisualUrl::GetType() const
{
return mType;