OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 "base/command_line.h" | |
6 #include "base/lazy_instance.h" | |
7 #include "base/logging.h" | |
8 #include "base/trace_event/trace_event.h" | |
9 #include "ui/ozone/platform_object.h" | |
10 #include "ui/ozone/platform_selection.h" | |
11 #include "ui/ozone/public/native_pixmap_client.h" | |
12 #include "ui/ozone/public/ozone_platform.h" | |
13 #include "ui/ozone/public/ozone_switches.h" | |
14 | |
15 namespace ui { | |
16 | |
17 namespace { | |
18 | |
19 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
| |
20 | |
21 } // namespace | |
22 | |
23 NativePixmapClient::NativePixmapClient() { | |
24 DCHECK(!g_instance) << "There should only be a single NativePixmapClient."; | |
25 g_instance = this; | |
26 } | |
27 | |
28 NativePixmapClient::~NativePixmapClient() { | |
29 DCHECK_EQ(g_instance, this); | |
30 g_instance = nullptr; | |
31 } | |
32 | |
33 // static | |
34 void NativePixmapClient::InitializeIfNeeded() { | |
35 if (g_instance) | |
36 return; | |
37 | |
38 CreateInstance(); | |
39 g_instance->Initialize(); | |
40 } | |
41 | |
42 // static | |
43 NativePixmapClient* NativePixmapClient::GetInstance() { | |
44 DCHECK(g_instance) << "NativePixmapClient is not initialized"; | |
45 return g_instance; | |
46 } | |
47 | |
48 std::vector<NativePixmapClient::Configuration> | |
49 NativePixmapClient::GetSupportedNativePixmapConfigurations() const { | |
50 return std::vector<Configuration>(); | |
51 } | |
52 | |
53 // static | |
54 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.
| |
55 DCHECK(!g_instance); | |
56 TRACE_EVENT1("ozone", "NativePixmapClient::CreateInstance", "platform", | |
57 GetOzonePlatformName()); | |
58 scoped_ptr<NativePixmapClient> platform = | |
59 PlatformObject<NativePixmapClient>::Create(); | |
60 | |
61 // TODO(spang): Currently need to leak this object. | |
62 NativePixmapClient* pl = platform.release(); | |
63 DCHECK_EQ(g_instance, pl); | |
64 } | |
65 | |
66 void NativePixmapClient::Initialize() { | |
67 } | |
68 | |
69 } // namespace ui | |
OLD | NEW |