[M108 Migration] Support GLES 3.0 properly
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / command_line_efl.cc
1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "command_line_efl.h"
6
7 #include <string>
8 #include <cstring>
9 #include <sys/types.h>
10 #include <unistd.h>
11
12 #include "base/base_switches.h"
13 #include "base/logging.h"
14 #include "cc/base/switches.h"
15 #include "common/content_switches_efl.h"
16 #include "components/viz/common/switches.h"
17 #include "content/public/common/content_client.h"
18 #include "content/public/common/content_switches.h"
19 #include "efl/init.h"
20 #include "extensions/common/switches.h"
21 #include "gpu/config/gpu_switches.h"
22 #include "sandbox/policy/switches.h"
23 #include "tizen/system_info.h"
24 #include "ui/base/ui_base_switches.h"
25 #include "ui/events/event_switches.h"
26 #include "ui/gl/gl_switches.h"
27 #include "ui/ozone/public/ozone_switches.h"
28 #include "url/gurl.h"
29
30 int CommandLineEfl::argc_ = 0;
31 char** CommandLineEfl::argv_ = NULL;
32 CommandLineEfl::ArgumentVector CommandLineEfl::original_arguments_;
33 bool CommandLineEfl::is_initialized_ = false;
34
35 void CommandLineEfl::Init(int argc, char *argv[]) {
36   if (CommandLineEfl::is_initialized_) {
37     LOG(ERROR) << "CommandLineEfl::Init should not be called more than once";
38   }
39   base::CommandLine::Init(argc, argv);
40   argc_ = argc;
41   argv_ = argv;
42
43   // Unfortunately chromium modifies application's argument vector.
44   // during initialization. This means that chromium after initialization
45   // argv will only contain one valid entry, argv[0]. To be able to use
46   // user provided arguments after initialization we need to make a copy
47   // of them.
48   // See: chromium/src/content/common/set_process_title_linux.cc
49   for (int i = 0; i < argc; ++i)
50     original_arguments_.push_back(std::string(argv[i]));
51   CommandLineEfl::is_initialized_ = true;
52 }
53
54 content::MainFunctionParams CommandLineEfl::GetDefaultPortParams() {
55   if (!CommandLineEfl::is_initialized_) {
56     CommandLineEfl::Init(0, NULL);
57   }
58   base::CommandLine* p_command_line = base::CommandLine::ForCurrentProcess();
59
60   p_command_line->AppendSwitchASCII(switches::kUseGL,
61                                     gl::kGLImplementationEGLName);
62   p_command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox);
63   p_command_line->AppendSwitch(switches::kIgnoreGpuBlocklist);
64   p_command_line->AppendSwitch(switches::kInProcessGPU);
65   p_command_line->AppendSwitchASCII(switches::kOzonePlatform, "efl");
66   p_command_line->AppendSwitch(switches::kEnableOffscreenRendering);
67
68   AppendMemoryOptimizationSwitches(p_command_line);
69
70   if (IsDesktopProfile())
71     p_command_line->AppendSwitch(switches::kDisableES3GLContext);
72
73 #if defined(TIZEN_MULTIMEDIA_SUPPORT) && defined(ENABLE_WEBRTC)
74   p_command_line->AppendSwitch(switches::kEnableWebRtcHWH264Encoding);
75 #endif
76
77 #if BUILDFLAG(IS_TIZEN)
78 #if !defined(EWK_BRINGUP)  // FIXME:m85 bringup
79   p_command_line->AppendSwitchASCII(
80       switches::kAcceleratedCanvas2dMSAASampleCount, "4");
81   p_command_line->AppendSwitch(switches::kEnableGestureTapHighlight);
82   p_command_line->AppendSwitch(switches::kEnableSpatialNavigation);
83   p_command_line->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
84 #endif // EWK_BRINGUP
85 #endif
86
87   if (IsMobileProfile() || IsWearableProfile()) {
88     p_command_line->AppendSwitch(switches::kUseMobileUserAgent);
89     p_command_line->AppendSwitchASCII(
90         switches::kTouchEventFeatureDetection,
91         switches::kTouchEventFeatureDetectionEnabled);
92 #if !defined(EWK_BRINGUP)
93     p_command_line->AppendSwitch(switches::kEnablePinch);
94 #endif
95   }
96
97 #if !defined(EWK_BRINGUP)
98   if (p_command_line->HasSwitch(switches::kDisableIpcSandbox))
99     p_command_line->AppendSwitch(switches::kDisableRendererZygote);
100 #endif
101
102   // XXX: Skia benchmarking should be only used for testing,
103   // when enabled the following warning is printed to stderr:
104   // "Enabling unsafe Skia benchmarking extension."
105   // p_command_line->AppendSwitch(switches::kEnableSkiaBenchmarking);
106
107   AppendUserArgs(*p_command_line);
108
109   return content::MainFunctionParams(p_command_line);
110 }
111
112 void CommandLineEfl::AppendProcessSpecificArgs(base::CommandLine& command_line) {
113   std::string process_type = command_line.GetSwitchValueASCII(switches::kProcessType);
114
115   AppendUserArgs(command_line);
116 }
117
118 void CommandLineEfl::AppendSwitch(std::string arg) {
119   original_arguments_.push_back(arg);
120 }
121
122 void CommandLineEfl::AppendUserArgs(base::CommandLine& command_line) {
123   for (ArgumentVector::const_iterator it = original_arguments_.begin();
124        it != original_arguments_.end(); ++it) {
125     command_line.AppendSwitch(*it);
126   }
127 }
128
129 void CommandLineEfl::AppendMemoryOptimizationSwitches(
130     base::CommandLine* command_line) {
131 #if !defined(EWK_BRINGUP)
132 // [M44_2403] Temporary disabling the codes for switching to new chromium
133 //            FIXME: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=14040
134   // For optimizing tile buffer size.
135   command_line->AppendSwitchASCII(switches::kDefaultTileRoundUp, "16");
136   command_line->AppendSwitch(switches::kEnableMultipleTextureSizes);
137
138   // For purging unused resources.
139   command_line->AppendSwitch(switches::kEnablePurgingUnusedResources);
140
141   // For adding runtime switch to configure the discardable image cache size.
142   command_line->AppendSwitchASCII(switches::kImageCacheSize, "0");
143 #endif
144
145   // For reuse of timers with message pump
146   command_line->AppendSwitch(switches::kLimitMemoryAllocationInScheduleDelayedWork);
147
148 }