| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "ui/events/devices/device_data_manager.h" | 8 #include "ui/events/devices/device_data_manager.h" |
| 9 #include "ui/ozone/platform_object.h" | 9 #include "ui/ozone/platform_object.h" |
| 10 #include "ui/ozone/platform_selection.h" | 10 #include "ui/ozone/platform_selection.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 g_platform_initialized_gpu = false; | 27 g_platform_initialized_gpu = false; |
| 28 } | 28 } |
| 29 | 29 |
| 30 OzonePlatform::~OzonePlatform() { | 30 OzonePlatform::~OzonePlatform() { |
| 31 DCHECK_EQ(instance_, this); | 31 DCHECK_EQ(instance_, this); |
| 32 instance_ = NULL; | 32 instance_ = NULL; |
| 33 } | 33 } |
| 34 | 34 |
| 35 // static | 35 // static |
| 36 void OzonePlatform::InitializeForUI() { | 36 void OzonePlatform::InitializeForUI() { |
| 37 const InitParams params; |
| 38 OzonePlatform::InitializeForUI(params); |
| 39 } |
| 40 |
| 41 // static |
| 42 void OzonePlatform::InitializeForUI(const InitParams& args) { |
| 37 CreateInstance(); | 43 CreateInstance(); |
| 38 if (g_platform_initialized_ui) | 44 if (g_platform_initialized_ui) |
| 39 return; | 45 return; |
| 40 g_platform_initialized_ui = true; | 46 g_platform_initialized_ui = true; |
| 41 instance_->InitializeUI(); | 47 instance_->InitializeUI(args); |
| 42 // This is deliberately created after initializing so that the platform can | 48 // This is deliberately created after initializing so that the platform can |
| 43 // create its own version of DDM. | 49 // create its own version of DDM. |
| 44 DeviceDataManager::CreateInstance(); | 50 DeviceDataManager::CreateInstance(); |
| 45 } | 51 } |
| 46 | 52 |
| 47 // static | 53 // static |
| 48 void OzonePlatform::InitializeForGPU() { | 54 void OzonePlatform::InitializeForGPU() { |
| 55 const InitParams params; |
| 56 OzonePlatform::InitializeForGPU(params); |
| 57 } |
| 58 |
| 59 // static |
| 60 void OzonePlatform::InitializeForGPU(const InitParams& args) { |
| 49 CreateInstance(); | 61 CreateInstance(); |
| 50 if (g_platform_initialized_gpu) | 62 if (g_platform_initialized_gpu) |
| 51 return; | 63 return; |
| 52 g_platform_initialized_gpu = true; | 64 g_platform_initialized_gpu = true; |
| 53 instance_->InitializeGPU(); | 65 instance_->InitializeGPU(args); |
| 54 } | 66 } |
| 55 | 67 |
| 56 // static | 68 // static |
| 57 OzonePlatform* OzonePlatform::GetInstance() { | 69 OzonePlatform* OzonePlatform::GetInstance() { |
| 58 DCHECK(instance_) << "OzonePlatform is not initialized"; | 70 DCHECK(instance_) << "OzonePlatform is not initialized"; |
| 59 return instance_; | 71 return instance_; |
| 60 } | 72 } |
| 61 | 73 |
| 62 // static | 74 // static |
| 63 void OzonePlatform::CreateInstance() { | 75 void OzonePlatform::CreateInstance() { |
| 64 if (!instance_) { | 76 if (!instance_) { |
| 65 TRACE_EVENT1("ozone", | 77 TRACE_EVENT1("ozone", |
| 66 "OzonePlatform::Initialize", | 78 "OzonePlatform::Initialize", |
| 67 "platform", | 79 "platform", |
| 68 GetOzonePlatformName()); | 80 GetOzonePlatformName()); |
| 69 std::unique_ptr<OzonePlatform> platform = | 81 std::unique_ptr<OzonePlatform> platform = |
| 70 PlatformObject<OzonePlatform>::Create(); | 82 PlatformObject<OzonePlatform>::Create(); |
| 71 | 83 |
| 72 // TODO(spang): Currently need to leak this object. | 84 // TODO(spang): Currently need to leak this object. |
| 73 OzonePlatform* pl = platform.release(); | 85 OzonePlatform* pl = platform.release(); |
| 74 DCHECK_EQ(instance_, pl); | 86 DCHECK_EQ(instance_, pl); |
| 75 } | 87 } |
| 76 } | 88 } |
| 77 | 89 |
| 78 // static | 90 // static |
| 79 OzonePlatform* OzonePlatform::instance_; | 91 OzonePlatform* OzonePlatform::instance_; |
| 80 | 92 |
| 93 // Convenience methods to facilitate transitionning to new API. |
| 94 void OzonePlatform::InitializeUI(const InitParams& args) { |
| 95 InitializeUI(); |
| 96 } |
| 97 void OzonePlatform::InitializeGPU(const InitParams& args) { |
| 98 InitializeGPU(); |
| 99 } |
| 100 |
| 101 void OzonePlatform::AddInterfaces(shell::Connection* connection) {} |
| 102 |
| 81 } // namespace ui | 103 } // namespace ui |
| OLD | NEW |