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 "ui/gfx/ozone/surface_factory_ozone.h" | 5 #include "ui/gfx/ozone/surface_factory_ozone.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "ui/gfx/ozone/impl/file_surface_factory_ozone.h" | 10 #include "ui/gfx/ozone/impl/file_surface_factory_ozone.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 }; | 44 }; |
45 | 45 |
46 SurfaceFactoryOzone::SurfaceFactoryOzone() { | 46 SurfaceFactoryOzone::SurfaceFactoryOzone() { |
47 } | 47 } |
48 | 48 |
49 SurfaceFactoryOzone::~SurfaceFactoryOzone() { | 49 SurfaceFactoryOzone::~SurfaceFactoryOzone() { |
50 } | 50 } |
51 | 51 |
52 SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() { | 52 SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() { |
53 if (!impl_) { | 53 CHECK(impl_) << "No SurfaceFactoryOzone implementation set."; |
54 const char kOzoneFileSurface[] = "ozone-dump-file"; | |
55 CommandLine* cmd = CommandLine::ForCurrentProcess(); | |
56 if (cmd->HasSwitch(kOzoneFileSurface)) { | |
57 base::FilePath location = cmd->GetSwitchValuePath(kOzoneFileSurface); | |
58 if (location.empty()) | |
59 location = base::FilePath("/dev/null"); | |
60 impl_ = new FileSurfaceFactoryOzone(location); | |
61 } else { | |
62 LOG(WARNING) << "No SurfaceFactoryOzone implementation set. Using default" | |
63 " gfx::SoftwareSurfaceFactoryOzone."; | |
64 impl_ = new SoftwareSurfaceFactoryOzone(); | |
65 } | |
66 } | |
67 return impl_; | 54 return impl_; |
68 } | 55 } |
69 | 56 |
70 void SurfaceFactoryOzone::SetInstance(SurfaceFactoryOzone* impl) { | 57 void SurfaceFactoryOzone::SetInstance(SurfaceFactoryOzone* impl) { |
71 impl_ = impl; | 58 impl_ = impl; |
72 } | 59 } |
73 | 60 |
74 const char* SurfaceFactoryOzone::DefaultDisplaySpec() { | 61 const char* SurfaceFactoryOzone::DefaultDisplaySpec() { |
75 char* envvar = getenv("ASH_DISPLAY_SPEC"); | 62 char* envvar = getenv("ASH_DISPLAY_SPEC"); |
76 if (envvar) | 63 if (envvar) |
(...skipping 21 matching lines...) Expand all Loading... |
98 const int32* desired_attributes) { | 85 const int32* desired_attributes) { |
99 return desired_attributes; | 86 return desired_attributes; |
100 } | 87 } |
101 | 88 |
102 // static | 89 // static |
103 SurfaceFactoryOzone* SurfaceFactoryOzone::CreateTestHelper() { | 90 SurfaceFactoryOzone* SurfaceFactoryOzone::CreateTestHelper() { |
104 return new SurfaceFactoryOzoneStub; | 91 return new SurfaceFactoryOzoneStub; |
105 } | 92 } |
106 | 93 |
107 } // namespace gfx | 94 } // namespace gfx |
OLD | NEW |