Chromium Code Reviews| Index: ui/ozone/public/native_pixmap_client.cc |
| diff --git a/ui/ozone/public/native_pixmap_client.cc b/ui/ozone/public/native_pixmap_client.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..38a08aa5e635108e276f6c86d03303750b661ca6 |
| --- /dev/null |
| +++ b/ui/ozone/public/native_pixmap_client.cc |
| @@ -0,0 +1,69 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/command_line.h" |
| +#include "base/lazy_instance.h" |
| +#include "base/logging.h" |
| +#include "base/trace_event/trace_event.h" |
| +#include "ui/ozone/platform_object.h" |
| +#include "ui/ozone/platform_selection.h" |
| +#include "ui/ozone/public/native_pixmap_client.h" |
| +#include "ui/ozone/public/ozone_platform.h" |
| +#include "ui/ozone/public/ozone_switches.h" |
| + |
| +namespace ui { |
| + |
| +namespace { |
| + |
| +NativePixmapClient* g_instance = nullptr; |
|
spang
2015/06/05 19:21:54
I would prefer if this object was managed inside c
reveman
2015/06/05 20:26:07
I think IOSurfaceManager and SurfaceTextureManager
dshwang
2015/06/08 11:15:14
IMO it should stay here. NativePixmapManager needs
spang
2015/06/08 17:47:57
It's true, we can't move NativePixmapManager imple
dshwang
2015/06/09 18:37:40
I understand your concern. However, it's quite com
|
| + |
| +} // namespace |
| + |
| +NativePixmapClient::NativePixmapClient() { |
| + DCHECK(!g_instance) << "There should only be a single NativePixmapClient."; |
| + g_instance = this; |
| +} |
| + |
| +NativePixmapClient::~NativePixmapClient() { |
| + DCHECK_EQ(g_instance, this); |
| + g_instance = nullptr; |
| +} |
| + |
| +// static |
| +void NativePixmapClient::InitializeIfNeeded() { |
| + if (g_instance) |
| + return; |
| + |
| + CreateInstance(); |
| + g_instance->Initialize(); |
| +} |
| + |
| +// static |
| +NativePixmapClient* NativePixmapClient::GetInstance() { |
| + DCHECK(g_instance) << "NativePixmapClient is not initialized"; |
| + return g_instance; |
| +} |
| + |
| +std::vector<NativePixmapClient::Configuration> |
| +NativePixmapClient::GetSupportedNativePixmapConfigurations() const { |
| + return std::vector<Configuration>(); |
| +} |
| + |
| +// static |
| +void NativePixmapClient::CreateInstance() { |
|
reveman
2015/06/05 20:26:07
why are you not using a normal singleton so that t
dshwang
2015/06/08 11:15:14
Done. nice suggestion.
|
| + DCHECK(!g_instance); |
| + TRACE_EVENT1("ozone", "NativePixmapClient::CreateInstance", "platform", |
| + GetOzonePlatformName()); |
| + scoped_ptr<NativePixmapClient> platform = |
| + PlatformObject<NativePixmapClient>::Create(); |
| + |
| + // TODO(spang): Currently need to leak this object. |
| + NativePixmapClient* pl = platform.release(); |
| + DCHECK_EQ(g_instance, pl); |
| +} |
| + |
| +void NativePixmapClient::Initialize() { |
| +} |
| + |
| +} // namespace ui |