mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Overlay: Support globbing
Makes it less tedious to specify multiple widgets. In particular, it also makes it possible to select many widgets on Android through `adb shell setprop debug.angle.overlay` which has a hard limit of 92 characters for the property. Bug: angleproject:5881 Change-Id: I93bd166cd3dbf8f87e5c6a5fce3f86ebb3e379a3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3697437 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
This commit is contained in:
committed by
Angle LUCI CQ
parent
2587e50882
commit
0408b12938
@@ -108,14 +108,14 @@ Currently, to enable overlay items an environment variable is used. For example:
|
||||
On Desktop:
|
||||
|
||||
```commandline
|
||||
$ export ANGLE_OVERLAY=FPS:VulkanSecondaryCommandBufferPoolWaste
|
||||
$ export ANGLE_OVERLAY=FPS:Vulkan*PipelineCache*
|
||||
$ ./hello_triangle --use-angle=vulkan
|
||||
```
|
||||
|
||||
On Android:
|
||||
|
||||
```
|
||||
$ adb shell setprop debug.angle.overlay FPS:VulkanSecondaryCommandBufferPoolWaste
|
||||
$ adb shell setprop debug.angle.overlay FPS:Vulkan*PipelineCache*
|
||||
$ ./hello_triangle --use-angle=vulkan
|
||||
```
|
||||
|
||||
|
||||
@@ -313,28 +313,28 @@ std::vector<std::string> GetCachedStringsFromEnvironmentVarOrAndroidProperty(
|
||||
return SplitString(environment, separator, TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
|
||||
}
|
||||
|
||||
// reference name can have *.
|
||||
bool NamesMatchWithWildcard(const char *ref, const char *testName)
|
||||
// glob can have * as wildcard
|
||||
bool NamesMatchWithWildcard(const char *glob, const char *name)
|
||||
{
|
||||
// Find the first * in ref.
|
||||
const char *firstWildcard = strchr(ref, '*');
|
||||
// Find the first * in glob.
|
||||
const char *firstWildcard = strchr(glob, '*');
|
||||
|
||||
// If there are no wildcards, match the strings precisely.
|
||||
if (firstWildcard == nullptr)
|
||||
{
|
||||
return strcmp(ref, testName) == 0;
|
||||
return strcmp(glob, name) == 0;
|
||||
}
|
||||
|
||||
// Otherwise, match up to the wildcard first.
|
||||
size_t preWildcardLen = firstWildcard - ref;
|
||||
if (strncmp(ref, testName, preWildcardLen) != 0)
|
||||
size_t preWildcardLen = firstWildcard - glob;
|
||||
if (strncmp(glob, name, preWildcardLen) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *postWildcardRef = ref + preWildcardLen + 1;
|
||||
const char *postWildcardRef = glob + preWildcardLen + 1;
|
||||
|
||||
// As a small optimization, if the wildcard is the last character in ref, accept the match
|
||||
// As a small optimization, if the wildcard is the last character in glob, accept the match
|
||||
// already.
|
||||
if (postWildcardRef[0] == '\0')
|
||||
{
|
||||
@@ -342,9 +342,9 @@ bool NamesMatchWithWildcard(const char *ref, const char *testName)
|
||||
}
|
||||
|
||||
// Try to match the wildcard with a number of characters.
|
||||
for (size_t matchSize = 0; testName[matchSize] != '\0'; ++matchSize)
|
||||
for (size_t matchSize = 0; name[matchSize] != '\0'; ++matchSize)
|
||||
{
|
||||
if (NamesMatchWithWildcard(postWildcardRef, testName + matchSize))
|
||||
if (NamesMatchWithWildcard(postWildcardRef, name + matchSize))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ std::vector<std::string> GetCachedStringsFromEnvironmentVarOrAndroidProperty(
|
||||
const char *propertyName,
|
||||
const char *separator);
|
||||
|
||||
// reference name can have *.
|
||||
bool NamesMatchWithWildcard(const char *ref, const char *testName);
|
||||
// glob can have * as wildcard
|
||||
bool NamesMatchWithWildcard(const char *glob, const char *name);
|
||||
} // namespace angle
|
||||
|
||||
#endif // LIBANGLE_STRING_UTILS_H_
|
||||
|
||||
@@ -61,11 +61,14 @@ void Overlay::enableOverlayWidgetsFromEnvironment()
|
||||
|
||||
for (const std::pair<const char *, WidgetId> &widgetName : kWidgetNames)
|
||||
{
|
||||
if (std::find(enabledWidgets.begin(), enabledWidgets.end(), widgetName.first) !=
|
||||
enabledWidgets.end())
|
||||
for (const std::string &enabledWidget : enabledWidgets)
|
||||
{
|
||||
mState.mOverlayWidgets[widgetName.second]->enabled = true;
|
||||
++mState.mEnabledWidgetCount;
|
||||
if (angle::NamesMatchWithWildcard(enabledWidget.c_str(), widgetName.first))
|
||||
{
|
||||
mState.mOverlayWidgets[widgetName.second]->enabled = true;
|
||||
++mState.mEnabledWidgetCount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user