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

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: Adding the default case for MapImageEnabled 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 be4a2c55adfbcb22214a0a92439f59da8fd112e2..5dbf26cbf86ef8003624c43db301118cd03b5e40 100644
--- a/cc/base/switches.cc
+++ b/cc/base/switches.cc
@@ -151,51 +151,94 @@ 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;
+class CCSwitchHandler {
danakj 2013/11/13 19:37:40 you're already in the cc:: namespace. How about ju
+ public:
+ static bool isImplSidePaintingEnabled();
danakj 2013/11/13 19:37:40 IsImplSidePaintingEnabled <- capitalized for all
+ static bool isMapImageEnabled();
+ static bool isLCDTextEnabled();
+
+ private:
+ static void initializeCCSwitchesIfRequired();
+
+ private:
+ static bool s_has_initialized_switches_;
danakj 2013/11/13 19:37:40 no trailing _ on static variables. they are not in
+ static bool s_impl_side_painting_enabled_;
+ static bool s_map_image_enabled_;
+ static bool s_lcd_text_enabled_;
+};
+
+bool CCSwitchHandler::isImplSidePaintingEnabled() {
+ initializeCCSwitchesIfRequired();
+ return s_impl_side_painting_enabled_;
+}
-#if defined(OS_ANDROID)
- return false;
-#else
- return true;
-#endif
+bool CCSwitchHandler::isMapImageEnabled() {
+ initializeCCSwitchesIfRequired();
+ return s_map_image_enabled_;
}
-namespace {
-bool CheckImplSidePaintingStatus() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+bool CCSwitchHandler::isLCDTextEnabled() {
+ initializeCCSwitchesIfRequired();
+ return s_lcd_text_enabled_;
+}
+
+void CCSwitchHandler::initializeCCSwitchesIfRequired() {
+ if (s_has_initialized_switches_)
+ return;
- if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting))
- return false;
- else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting))
- return true;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ // Impl-side painting.
+ if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) {
+ s_impl_side_painting_enabled_ = false;
+ } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) {
+ s_impl_side_painting_enabled_ = true;
+ } else {
+#if defined(OS_ANDROID)
+ s_impl_side_painting_enabled_ = true;
+#else
+ s_impl_side_painting_enabled_ = false;
+#endif
+ }
+ // Map-Image.
+ if (command_line.HasSwitch(cc::switches::kDisableMapImage))
+ s_map_image_enabled_ = false;
+ else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
+ s_map_image_enabled_ = true;
+ else
+ s_map_image_enabled_ = false;
+
+ // LCD-Text.
+ if (command_line.HasSwitch(cc::switches::kDisableLCDText)) {
+ s_lcd_text_enabled_ = false;
+ } else if (command_line.HasSwitch(cc::switches::kEnableLCDText)) {
+ s_lcd_text_enabled_ = true;
+ } else {
#if defined(OS_ANDROID)
- return true;
+ s_lcd_text_enabled_ = false;
#else
- return false;
+ s_lcd_text_enabled_ = true;
#endif
+ }
+
+ s_has_initialized_switches_ = true;
}
-} // namespace
+
+bool CCSwitchHandler::s_has_initialized_switches_ = false;
+bool CCSwitchHandler::s_impl_side_painting_enabled_ = false;
+bool CCSwitchHandler::s_map_image_enabled_ = false;
+bool CCSwitchHandler::s_lcd_text_enabled_ = false;
bool IsImplSidePaintingEnabled() {
- static bool enabled = CheckImplSidePaintingStatus();
- return enabled;
+ return CCSwitchHandler::isImplSidePaintingEnabled();
}
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;
+ return CCSwitchHandler::isMapImageEnabled();
+}
- return false;
+bool IsLCDTextEnabled() {
+ return CCSwitchHandler::isLCDTextEnabled();
}
} // 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