OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "ui/base/ozone/ozone_platform.h" | 7 #include "ui/base/ozone/ozone_platform.h" |
8 #include "ui/base/ozone/ozone_platform_list.h" | |
9 #include "ui/base/ozone/ozone_switches.h" | |
8 | 10 |
9 namespace ui { | 11 namespace ui { |
10 | 12 |
13 namespace { | |
14 | |
15 OzonePlatform* CreatePlatform(const std::string& platform_name) { | |
16 for (int i = 0; i < kOzonePlatformCount; ++i) | |
rjkroege
2013/10/28 16:02:15
default maps to the first element in the list righ
spang
2013/10/28 16:27:39
Done.
| |
17 if (platform_name == kOzonePlatforms[i].name || platform_name == "default") | |
18 return kOzonePlatforms[i].constructor(); | |
19 | |
20 LOG(FATAL) << "Invalid ozone platform: " << platform_name; | |
21 return NULL; // not reached | |
22 } | |
23 | |
24 std::string GetRequestedPlatform() { | |
rjkroege
2013/10/28 16:02:15
maybe add a comment here saying "returns the name
spang
2013/10/28 16:27:39
Done.
| |
25 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform)) | |
26 return "default"; | |
27 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
28 switches::kOzonePlatform); | |
29 } | |
30 | |
31 } // namespace | |
32 | |
11 OzonePlatform::OzonePlatform() {} | 33 OzonePlatform::OzonePlatform() {} |
12 | 34 |
13 OzonePlatform::~OzonePlatform() { | 35 OzonePlatform::~OzonePlatform() { |
14 gfx::SurfaceFactoryOzone::SetInstance(NULL); | 36 gfx::SurfaceFactoryOzone::SetInstance(NULL); |
15 ui::EventFactoryOzone::SetInstance(NULL); | 37 ui::EventFactoryOzone::SetInstance(NULL); |
16 } | 38 } |
17 | 39 |
18 // static | 40 // static |
19 OzonePlatform* OzonePlatform::Create() { | 41 OzonePlatform* OzonePlatform::Create() { |
20 OzonePlatform* platform = CreateDefaultOzonePlatform(); | 42 OzonePlatform* platform = CreatePlatform(GetRequestedPlatform()); |
21 | 43 |
22 gfx::SurfaceFactoryOzone::SetInstance(platform->GetSurfaceFactoryOzone()); | 44 gfx::SurfaceFactoryOzone::SetInstance(platform->GetSurfaceFactoryOzone()); |
23 ui::EventFactoryOzone::SetInstance(platform->GetEventFactoryOzone()); | 45 ui::EventFactoryOzone::SetInstance(platform->GetEventFactoryOzone()); |
24 | 46 |
25 return platform; | 47 return platform; |
26 } | 48 } |
27 | 49 |
28 } // namespace ui | 50 } // namespace ui |
OLD | NEW |