1 // Copyright 2017 The Chromium Authors. 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 "components/exo/wayland/clients/blur.h"
6
7 #include <limits>
8
9 #include "base/at_exit.h"
10 #include "base/command_line.h"
11 #include "base/message_loop/message_pump_type.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "base/task/single_thread_task_executor.h"
14 #include "components/exo/wayland/clients/blur.h"
15
16 namespace switches {
17
18 // Specifies the sigma X to use.
19 const char kSigmaX[] = "sigma-x";
20
21 // Specifies the sigma Y to use.
22 const char kSigmaY[] = "sigma-y";
23
24 // Max sigma to allow without adjusting scale factor.
25 const char kMaxSigma[] = "max-sigma";
26
27 } // namespace switches
28
main(int argc,char * argv[])29 int main(int argc, char* argv[]) {
30 base::AtExitManager exit_manager;
31 base::CommandLine::Init(argc, argv);
32 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
33 exo::wayland::clients::ClientBase::InitParams params;
34 if (!params.FromCommandLine(*command_line))
35 return 1;
36
37 base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI);
38 exo::wayland::clients::Blur client;
39 if (!client.Init(params))
40 return 1;
41
42 double sigma_x = 30.0;
43 if (command_line->HasSwitch(switches::kSigmaX) &&
44 !base::StringToDouble(
45 command_line->GetSwitchValueASCII(switches::kSigmaX), &sigma_x)) {
46 LOG(ERROR) << "Invalid value for " << switches::kSigmaX;
47 return 1;
48 }
49
50 double sigma_y = 30.0;
51 if (command_line->HasSwitch(switches::kSigmaY) &&
52 !base::StringToDouble(
53 command_line->GetSwitchValueASCII(switches::kSigmaY), &sigma_y)) {
54 LOG(ERROR) << "Invalid value for " << switches::kSigmaY;
55 return 1;
56 }
57
58 double max_sigma = 4.0;
59 if (command_line->HasSwitch(switches::kMaxSigma) &&
60 !base::StringToDouble(
61 command_line->GetSwitchValueASCII(switches::kMaxSigma), &max_sigma)) {
62 LOG(ERROR) << "Invalid value for " << switches::kMaxSigma;
63 return 1;
64 }
65
66 client.Run(sigma_x, sigma_y, max_sigma, false /* offscreen */,
67 std::numeric_limits<int>::max());
68
69 return 0;
70 }
71