| Index: ui/ozone/ozone_platform.cc
|
| diff --git a/ui/ozone/ozone_platform.cc b/ui/ozone/ozone_platform.cc
|
| index e8199b2ce93f86846235f73b8459b9f650859d5f..730be363bec8176fa8ae609cab292b08855a9fbe 100644
|
| --- a/ui/ozone/ozone_platform.cc
|
| +++ b/ui/ozone/ozone_platform.cc
|
| @@ -40,31 +40,28 @@ std::string GetPlatformName() {
|
|
|
| } // namespace
|
|
|
| -OzonePlatform::OzonePlatform() {}
|
| +OzonePlatform::OzonePlatform() {
|
| + CHECK(!instance_) << "There should only be a single OzonePlatform.";
|
| + instance_ = this;
|
| +}
|
|
|
| OzonePlatform::~OzonePlatform() {
|
| - gfx::SurfaceFactoryOzone::SetInstance(NULL);
|
| - ui::EventFactoryOzone::SetInstance(NULL);
|
| - ui::CursorFactoryOzone::SetInstance(NULL);
|
| + CHECK_EQ(instance_, this);
|
| + instance_ = NULL;
|
| }
|
|
|
| // static
|
| -void OzonePlatform::Initialize() {
|
| - if (instance_)
|
| - return;
|
| -
|
| - std::string platform = GetPlatformName();
|
| -
|
| - TRACE_EVENT1("ozone", "OzonePlatform::Initialize", "platform", platform);
|
| -
|
| - instance_ = CreatePlatform(platform);
|
| -
|
| - // Inject ozone interfaces.
|
| - gfx::SurfaceFactoryOzone::SetInstance(instance_->GetSurfaceFactoryOzone());
|
| - ui::EventFactoryOzone::SetInstance(instance_->GetEventFactoryOzone());
|
| +void OzonePlatform::InitializeForUI() {
|
| + CreateInstance();
|
| + instance_->InitializeUI();
|
| ui::InputMethodContextFactoryOzone::SetInstance(
|
| instance_->GetInputMethodContextFactoryOzone());
|
| - ui::CursorFactoryOzone::SetInstance(instance_->GetCursorFactoryOzone());
|
| +}
|
| +
|
| +// static
|
| +void OzonePlatform::InitializeForGPU() {
|
| + CreateInstance();
|
| + instance_->InitializeGPU();
|
| }
|
|
|
| // static
|
| @@ -74,6 +71,15 @@ OzonePlatform* OzonePlatform::GetInstance() {
|
| }
|
|
|
| // static
|
| +void OzonePlatform::CreateInstance() {
|
| + if (!instance_) {
|
| + std::string platform = GetPlatformName();
|
| + TRACE_EVENT1("ozone", "OzonePlatform::Initialize", "platform", platform);
|
| + CreatePlatform(platform);
|
| + }
|
| +}
|
| +
|
| +// static
|
| OzonePlatform* OzonePlatform::instance_;
|
|
|
| } // namespace ui
|
|
|