Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1113)

Unified Diff: cc/base/switches.cc

Issue 69123002: Generic version of caching cc switches to avoid searching of switches on each function call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified GPU Rasterization switch accordingly. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/switches.cc
diff --git a/cc/base/switches.cc b/cc/base/switches.cc
index 752abc607729186d3090c70a75c2e1c80610b949..a60d92c847bf1f0f782e1bf9570546ddc0809afd 100644
--- a/cc/base/switches.cc
+++ b/cc/base/switches.cc
@@ -156,56 +156,75 @@ const char kDisable4444Textures[] = "disable-4444-textures";
const char kDisableCompositorTouchHitTesting[] =
"disable-compositor-touch-hit-testing";
-bool IsLCDTextEnabled() {
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(cc::switches::kDisableLCDText))
- return false;
- else if (command_line->HasSwitch(cc::switches::kEnableLCDText))
- return true;
-
+static bool g_has_initialized_switches = false;
+static bool g_impl_side_painting_enabled = false;
+static bool g_map_image_enabled = false;
+static bool g_lcd_text_enabled = false;
+static bool g_gpu_rasterization_enabled = false;
+
+static void InitializeSwitchesIfNeeded() {
+ if (!g_has_initialized_switches) {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ // Impl-side painting.
+ if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) {
+ g_impl_side_painting_enabled = false;
+ } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) {
+ g_impl_side_painting_enabled = true;
+ } else {
#if defined(OS_ANDROID)
- return false;
+ g_impl_side_painting_enabled = true;
#else
- return true;
+ g_impl_side_painting_enabled = false;
#endif
-}
-
-namespace {
-bool CheckImplSidePaintingStatus() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
-
- if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting))
- return false;
- else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting))
- return true;
-
+ }
+
+ // Map-Image.
+ if (command_line.HasSwitch(cc::switches::kDisableMapImage))
+ g_map_image_enabled = false;
+ else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
+ g_map_image_enabled = true;
+ else
+ g_map_image_enabled = false;
+
+ // LCD-Text.
+ if (command_line.HasSwitch(cc::switches::kDisableLCDText)) {
+ g_lcd_text_enabled = false;
+ } else if (command_line.HasSwitch(cc::switches::kEnableLCDText)) {
+ g_lcd_text_enabled = true;
+ } else {
#if defined(OS_ANDROID)
- return true;
+ g_lcd_text_enabled = false;
#else
- return false;
+ g_lcd_text_enabled = true;
#endif
+ }
+
+ // GPU Rasterization.
+ if(command_line.HasSwitch(cc::switches::kEnableGPURasterization)) {
+ g_gpu_rasterization_enabled = true;
+ }
+ g_has_initialized_switches = true;
+ }
}
-} // namespace
bool IsImplSidePaintingEnabled() {
- static bool enabled = CheckImplSidePaintingStatus();
- return enabled;
+ InitializeSwitchesIfNeeded();
+ return g_impl_side_painting_enabled;
}
bool IsGPURasterizationEnabled() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- return command_line.HasSwitch(cc::switches::kEnableGPURasterization);
+ InitializeSwitchesIfNeeded();
+ return g_gpu_rasterization_enabled;
}
bool IsMapImageEnabled() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
-
- if (command_line.HasSwitch(cc::switches::kDisableMapImage))
- return false;
- else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
- return true;
+ InitializeSwitchesIfNeeded();
+ return g_map_image_enabled;
+}
- return false;
+bool IsLCDTextEnabled() {
+ InitializeSwitchesIfNeeded();
+ return g_lcd_text_enabled;
}
} // namespace switches
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698